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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
52620e98159c90ff11cd1c3d56c9626bb62d504e | 17e77e661335e91326d72e53bfa068bd5fb79b1a | /PropRoom3D/Team/ArtDirector/Film/Tile.cpp | 7106b7df6638c45d865cee8f68de604ec6c0f528 | [] | no_license | wibus/ExperimentalTheatre | cfd92546aed84138d21ad9845bf4518c828badf8 | 46c0e83d2319c5731fc7a7dbad6b0efee95d289c | refs/heads/master | 2020-04-04T07:41:51.935537 | 2019-03-19T08:03:57 | 2019-03-19T08:03:57 | 7,976,973 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,817 | cpp | Tile.cpp | #include "Tile.h"
#include "Film.h"
namespace prop3
{
const glm::ivec2 Tile::END_PIXEL = glm::ivec2(-1,-1);
TileIterator::TileIterator(
Tile& tile,
const glm::ivec2& startPos) :
_tile(tile),
_position(startPos)
{
}
double TileIterator::sampleWeight() const
{
return _tile.pixelPriority(_position)
/ _tile.priorityThreshold();
}
TileIterator& TileIterator::operator++()
{
if(_position != Tile::END_PIXEL)
{
do
{
if(++_position.x >= _tile.maxCorner().x)
{
_position.x = _tile.minCorner().x;
if(++_position.y >= _tile.maxCorner().y)
{
_position = Tile::END_PIXEL;
return *this;
}
}
}
while(_tile.priorityThreshold() > _tile.pixelPriority(_position));
}
return *this;
}
Tile::Tile(Film& film,
const glm::ivec2& minCorner,
const glm::ivec2& maxCorner) :
_film(film),
_tileId(-1),
_endIterator(*this, END_PIXEL),
_minCorner(minCorner),
_maxCorner(maxCorner),
_startPix(_minCorner + glm::ivec2(-1, 0)),
_tilePriority(1.0),
_divergence(0.0)
{
glm::ivec2 tileDim = _maxCorner - _minCorner;
_pixelCount = tileDim.x * + tileDim.y;
}
Tile::~Tile()
{
}
void Tile::setTileId(size_t id)
{
_tileId = id;
}
TileIterator Tile::begin()
{
return ++TileIterator(*this, _startPix);
}
TileIterator Tile::end()
{
return _endIterator;
}
void Tile::lock()
{
_mutex.lock();
}
void Tile::unlock()
{
_mutex.unlock();
}
glm::dvec4 Tile::pixelSample(int i, int j) const
{
return _film.pixelSample(i, j);
}
void Tile::addSample(
int i, int j,
const glm::dvec4& sample)
{
_film.addSample(i, j, sample);
}
void Tile::addSample(
const glm::ivec2& position,
const glm::dvec4& sample)
{
addSample(position.x, position.y, sample);
}
double Tile::pixelPriority(const glm::ivec2& position) const
{
return _film.pixelPriority(position);
}
double Tile::priorityThreshold() const
{
return _film.priorityThreshold();
}
double Tile::sampleMultiplicity() const
{
return _film.sampleMultiplicity();
}
void Tile::setTilePriority(double priority)
{
_tilePriority = priority;
}
void Tile::setDivergence(double div)
{
_divergence = div;
}
}
|
8ff61c26bec8b6a8e1e2873ef3ac543ede548cd5 | 15f0514701a78e12750f68ba09d68095172493ee | /C++/859.cpp | ced13f5505fa76a87bec348abfbcdc8e483c9d96 | [
"MIT"
] | permissive | strengthen/LeetCode | 5e38c8c9d3e8f27109b9124ae17ef8a4139a1518 | 3ffa6dcbeb787a6128641402081a4ff70093bb61 | refs/heads/master | 2022-12-04T21:35:17.872212 | 2022-11-30T06:23:24 | 2022-11-30T06:23:24 | 155,958,163 | 936 | 365 | MIT | 2021-11-15T04:02:45 | 2018-11-03T06:47:38 | null | UTF-8 | C++ | false | false | 1,601 | cpp | 859.cpp | __________________________________________________________________________________________________
sample 4 ms submission
auto speedup =[]() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return nullptr;
}();
class Solution {
public:
bool buddyStrings(const string& A, const string& B)
{
if (A.size() != B.size()) {
return false;
} else if (A == B) {
return unordered_set<char>(A.begin(), A.end()).size() < A.size();
} else {
vector<int> pos;
for (int i = 0; i < A.size(); ++i) {
if (A[i] != B[i])
pos.push_back(i);
}
return pos.size() == 2 && A[pos[0]] == B[pos[1]] && A[pos[1]] == B[pos[0]];
}
}
};
__________________________________________________________________________________________________
sample 8948 kb submission
class Solution {
public:
bool buddyStrings(string A, string B) {
if (A.length() != B.length()) return false;
vector<int> ca(26), cb(26);
int diff = 0;
for (int i = 0; i < A.length(); ++i) {
if (A[i] != B[i] && diff++ > 2) return false;
++ca[A[i]-'a'];
++cb[B[i]-'a'];
}
for (int i = 0; i < 26; ++i) {
if (diff == 0 && ca[i] > 1) return true;
if (ca[i] != cb[i]) return false;
}
return diff == 2;
//return true;
}
};
__________________________________________________________________________________________________
|
f785fc1b902c6765cff3bfcadf5efd0c8f812a8b | f6602796607fdbe2286dad795090aad7e4e89312 | /dragonpoop_alpha/dragonpoop/gfx/dpbitmap/dpbitmap_bitmap_loader.cpp | 43368decef8bae04e5bc7a1478a8f0255b76ca27 | [] | no_license | rvaughn4/dragonpoop_alpha | a38ffde088a35d7c43a0e96480fd99ac2e2794a9 | 5a516c21749a63c951cb19c75f6325b9af484d4e | refs/heads/master | 2020-04-05T22:51:38.273761 | 2016-01-20T09:54:11 | 2016-01-20T09:54:11 | 39,721,963 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,442 | cpp | dpbitmap_bitmap_loader.cpp |
#include "dpbitmap_bitmap_loader.h"
#include <fstream>
#include <string.h>
namespace dragonpoop
{
//ctor
dpbitmap_bitmap_loader::dpbitmap_bitmap_loader( dpbitmap *img )
{
this->img = img;
}
//dtor
dpbitmap_bitmap_loader::~dpbitmap_bitmap_loader( void )
{
}
//open file
bool dpbitmap_bitmap_loader::openFile( std::string *fname )
{
std::fstream f;
std::size_t s;
char *b;
unsigned int sz;
bool r;
f.open( fname->c_str(), f.binary | f.in );
if( !f.is_open() )
return 0;
f.seekg( 0, f.end );
s = f.tellg();
f.seekg( 0, f.beg );
sz = (unsigned int)s;
if( !sz )
return 0;
b = new char[ sz ];
if( !b )
return 0;
f.read( b, sz );
f.close();
r = this->parseHeader( b, sz );
delete[] b;
return r;
}
//writes bitmap to file
bool dpbitmap_bitmap_loader::writeFile( std::string *fname )
{
std::fstream f;
char *b;
unsigned int sz;
f.open( fname->c_str(), f.binary | f.out | f.trunc );
if( !f.is_open() )
return 0;
sz = this->writeHeader( 0, 0 );
if( !sz )
return 0;
b = new char[ sz ];
if( !b )
return 0;
this->writeHeader( b, sz );
f.write( b, sz );
delete[] b;
return 1;
}
//parse header
bool dpbitmap_bitmap_loader::parseHeader( char *b, unsigned int size )
{
bmp_file_header *fh;
union
{
bmp_info *ih;
bmp_info_v3 *ih3;
};
bmp_info dh;
if( size < sizeof( bmp_file_header ) + sizeof( bmp_info_header ) )
return 0;
fh = (bmp_file_header *)b;
if( fh->size_of_file > size )
return 0;
if( fh->offset_to_pixels > size )
return 0;
ih = (bmp_info *)&b[ sizeof( bmp_file_header ) ];
if( ih->hdr.bits != 24 && ih->hdr.bits != 32 )
return 0;
if( !this->resizeDst( abs( ih->hdr.width ), abs( ih->hdr.height ) ) )
return 0;
if( ih->hdr.compression != 3 )
{
memset( &dh.color_masks, 0, sizeof( dh.color_masks ) );
dh.color_masks.r.c[ 2 ] = 255;
dh.color_masks.g.c[ 1 ] = 255;
dh.color_masks.b.c[ 0 ] = 255;
dh.color_masks.a.c[ 3 ] = 255;
return this->parsePixels( &b[ fh->offset_to_pixels ], size - fh->offset_to_pixels, ih->hdr.width, ih->hdr.height, ih->hdr.bits, dh.color_masks.r.c, dh.color_masks.g.c, dh.color_masks.b.c, dh.color_masks.a.c );
}
if( ih->hdr.size == sizeof( bmp_info_header ) )
return this->parsePixels( &b[ fh->offset_to_pixels ], size - fh->offset_to_pixels, ih->hdr.width, ih->hdr.height, ih->hdr.bits, ih->color_masks.r.c, ih->color_masks.g.c, ih->color_masks.b.c, ih->color_masks.a.c );
return this->parsePixels( &b[ fh->offset_to_pixels ], size - fh->offset_to_pixels, ih->hdr.width, ih->hdr.height, ih->hdr.bits, ih3->hdr.color_masks.r.c, ih3->hdr.color_masks.g.c, ih3->hdr.color_masks.b.c, ih3->hdr.color_masks.a.c );
}
//writes header to memory, then rest of image, returns size used/needed
unsigned int dpbitmap_bitmap_loader::writeHeader( char *b, unsigned int sizeMax )
{
const char *bm = "BM0";
unsigned int szn, scn, bpp;
bmp_file_header *fh;
bmp_info_v3 *ih;
unsigned int bits = 32, h_size = sizeof( bmp_info_header_v3 );
bpp = bits / 8;
scn = 0;
while( scn < this->img->getWidth() * bpp )
scn += 4;
szn = sizeof( bmp_file_header ) + sizeof( bmp_info_v4 ) + this->img->getHeight() * scn;
if( !b || sizeMax < szn )
return szn;
memset( b, 0, sizeof( bmp_file_header ) + sizeof( bmp_info ) );
fh = (bmp_file_header *)b;
ih = (bmp_info_v3 *)&b[ sizeof(bmp_file_header) ];
memcpy( &fh->f_type, bm, 2 );
fh->size_of_file = szn;
fh->offset_to_pixels = sizeof( bmp_file_header ) + sizeof( bmp_info_header_v4 );
ih->hdr.bits = bits;
ih->hdr.planes = 1;
ih->hdr.width = this->img->getWidth();
ih->hdr.height = this->img->getHeight();
ih->hdr.size = h_size;
ih->hdr.size_image = scn * ih->hdr.height;
if( ih->hdr.bits == 32 )
{
fh->offset_to_pixels = sizeof( bmp_file_header ) + sizeof( bmp_info_v4 );
ih->hdr.compression = 3;
ih->color_masks.r.c[ 0 ] = 255;
ih->color_masks.g.c[ 1 ] = 255;
ih->color_masks.b.c[ 2 ] = 255;
ih->color_masks.a.c[ 3 ] = 255;
ih->hdr.color_masks.r.c[ 0 ] = 255;
ih->hdr.color_masks.g.c[ 1 ] = 255;
ih->hdr.color_masks.b.c[ 2 ] = 255;
ih->hdr.color_masks.a.c[ 3 ] = 255;
}
this->writePixels( &b[ fh->offset_to_pixels ], ih->hdr.size_image, ih->hdr.bits );
return szn;
}
//resize dst image
bool dpbitmap_bitmap_loader::resizeDst( unsigned int w, unsigned int h )
{
this->img->reset();
return this->img->resize( w, h );
}
//copy pixels
bool dpbitmap_bitmap_loader::parsePixels( char *b, unsigned int size, int w, int h, unsigned int bits, uint8_t *red_mask, uint8_t *green_mask, uint8_t *blue_mask, uint8_t *alpha_mask )
{
unsigned int wu, hu, px, py, sb, scn, pi;
dprgba clr;
dpxy pp;
uint8_t *p;
wu = abs( w );
hu = abs( h );
sb = bits / 8;
scn = 0;
while( scn < wu * sb )
scn += 4;
for( pp.y = 0; pp.y < (int)hu; pp.y++ )
{
if( h <= 0 )
py = pp.y * scn;
else
py = ( hu - pp.y - 1 ) * scn;
for( pp.x = 0; pp.x < (int)wu; pp.x++ )
{
if( w >= 0 )
px = pp.x * sb;
else
px = ( wu - pp.x - 1 ) * sb;
pi = py + px;
if( pi >= size - sb )
continue;
p = (uint8_t *)&b[ pi ];
switch( bits )
{
case 32:
clr.b = ( p[ 0 ] & blue_mask[ 0 ] )
+ ( p[ 1 ] & blue_mask[ 1 ] )
+ ( p[ 2 ] & blue_mask[ 2 ] )
+ ( p[ 3 ] & blue_mask[ 3 ] );
clr.g = ( p[ 0 ] & green_mask[ 0 ] )
+ ( p[ 1 ] & green_mask[ 1 ] )
+ ( p[ 2 ] & green_mask[ 2 ] )
+ ( p[ 3 ] & green_mask[ 3 ] );
clr.r = ( p[ 0 ] & red_mask[ 0 ] )
+ ( p[ 1 ] & red_mask[ 1 ] )
+ ( p[ 2 ] & red_mask[ 2 ] )
+ ( p[ 3 ] & red_mask[ 3 ] );
clr.a = ( p[ 0 ] & alpha_mask[ 0 ] )
+ ( p[ 1 ] & alpha_mask[ 1 ] )
+ ( p[ 2 ] & alpha_mask[ 2 ] )
+ ( p[ 3 ] & alpha_mask[ 3 ] );
break;
case 24:
clr.b = ( p[ 0 ] & blue_mask[ 0 ] )
+ ( p[ 1 ] & blue_mask[ 1 ] )
+ ( p[ 2 ] & blue_mask[ 2 ] )
+ ( p[ 3 ] & blue_mask[ 3 ] );
clr.g = ( p[ 0 ] & green_mask[ 0 ] )
+ ( p[ 1 ] & green_mask[ 1 ] )
+ ( p[ 2 ] & green_mask[ 2 ] )
+ ( p[ 3 ] & green_mask[ 3 ] );
clr.r = ( p[ 0 ] & red_mask[ 0 ] )
+ ( p[ 1 ] & red_mask[ 1 ] )
+ ( p[ 2 ] & red_mask[ 2 ] )
+ ( p[ 3 ] & red_mask[ 3 ] );
clr.a = 255;
break;
}
this->img->setColor( &clr, &pp, 0 );
}
}
return 1;
}
//write image pixels to memory
unsigned int dpbitmap_bitmap_loader::writePixels( char *b, unsigned int sizeMax, unsigned int bits )
{
dpxy pp;
unsigned int w, h, py, px, pi, scn, sb;
uint8_t *p;
dprgba c;
w = this->img->getWidth();
h = this->img->getHeight();
sb = bits / 8;
scn = 0;
while( scn < w * sb )
scn += 4;
for( pp.y = 0; pp.y < (int)h; pp.y++ )
{
py = (h - pp.y - 1) * scn;
for( pp.x = 0; pp.x < (int)w; pp.x++ )
{
px = pp.x * sb;
pi = py + px;
if( pi >= sizeMax )
continue;
p = (uint8_t *)&b[ pi ];
this->img->getColor( &c, &pp );
switch( bits )
{
case 24:
p[ 2 ] = c.r;
p[ 1 ] = c.g;
p[ 0 ] = c.b;
break;
case 32:
p[ 0 ] = c.r;
p[ 1 ] = c.g;
p[ 2 ] = c.b;
p[ 3 ] = c.a;
break;
}
}
}
return h * scn;
}
//loads a bitmap file
bool dpbitmap_bitmap_loader::loadFile( dpbitmap *img, const char *fname )
{
dpbitmap_bitmap_loader bl( img );
std::string s( fname );
return bl.openFile( &s );
}
//loads a bitmap from memory
bool dpbitmap_bitmap_loader::loadMemory( dpbitmap *img, char *b, unsigned int size )
{
dpbitmap_bitmap_loader bl( img );
return bl.parseHeader( b, size );
}
//saves a bitmap file
bool dpbitmap_bitmap_loader::saveFile( dpbitmap *img, const char *fname )
{
dpbitmap_bitmap_loader bl( img );
std::string s( fname );
return bl.writeFile( &s );
}
//saves a bitmap to memory, returns size used/needed when params are null
unsigned int dpbitmap_bitmap_loader::saveMemory( dpbitmap *img, char *b, unsigned int sizeMax )
{
dpbitmap_bitmap_loader bl( img );
return bl.writeHeader( b, sizeMax );
}
};
|
38f7b346453c463e3c6304691d5805f25f44adef | 9e4cb0c415adfaee2d4ac2866f9992aeae84200b | /C++ Object Videos/1-Class and Constructors/2-Member Functions/MemberFunction.cpp | 3da5567727fd2f2975c96e8d30ea02226d2a449f | [] | no_license | CyberChimeraUSA/Cpp-Tutorials | 1648e8efe8fdeb0ec7f6957f0a0cb71cbcac36e5 | 04245959be4e684b9faa81b0303fbb4754b748a8 | refs/heads/master | 2021-05-04T14:53:42.498165 | 2019-08-18T21:48:50 | 2019-08-18T21:48:50 | 120,214,317 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 995 | cpp | MemberFunction.cpp | //============================================================================
// Name : SimpleClassC++.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
class OhmsCalculation
{
public:
double current;
double resistance;
//member function declarations
double getVoltage(void);
void setCurrent (double I);
void setResistance (double R);
};
double OhmsCalculation :: getVoltage(void)
{
return current * resistance;
}
void OhmsCalculation :: setCurrent(double I)
{
current = I;
}
void OhmsCalculation :: setResistance(double R)
{
resistance = R;
}
int main() {
OhmsCalculation Ohmsresult1;
double voltage = 0.0;
Ohmsresult1.setCurrent(0.03);
Ohmsresult1.setResistance(100);
voltage = Ohmsresult1.getVoltage();
cout << "Voltage of Ohmsresult1 :" << voltage;
return 0;
}
|
56ec9f70575ffa0376116a943800a0e8685118a0 | 2ec7d1fd4b1343aaf5d92308a53e8590aa8236ef | /follow_traj_skcontrol/src/follow_traj_skcontroller.cpp | 369b2c8cf209776933230bd864e21982db500d84 | [] | no_license | JIeHaocn/Autodriving_Controller | 39cb75f05089327451ef1f403ecd16cfb0f1b8ef | 8e009996becba4f8e41be1d8e9b331eec0cd3fa5 | refs/heads/master | 2023-01-08T00:24:22.552454 | 2020-11-10T09:31:19 | 2020-11-10T09:31:19 | 289,200,848 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,271 | cpp | follow_traj_skcontroller.cpp | #include "follow_traj_skcontrol/follow_traj_skcontroller.h"
const bool DEBUG=true;
namespace DecisionSK{
SKControl::SKControl(ros::NodeHandle nh, const std::vector<double> &traj_points)
{
trajectory_points = traj_points;
control_signal_pub = nh.advertise<ackermann_msgs::AckermannDriveStamped>("/vesc/high_level/ackermann_cmd_mux/input/nav_0",10);
current_pose_sub = nh.subscribe("/vesc/odom", 1, &SKControl::CurrentPoseCallback,this);
ros::param::get("~para_k", SKControl::k);
ROS_INFO("k: %.3f", SKControl::k);
ros::Duration(1).sleep(); //sleep for 1s to wait the sub and pub init
SKControl::next_pose.x = SKControl::trajectory_points[0];
SKControl::next_pose.y = SKControl::trajectory_points[1];
} // SKControl
void SKControl::ControlSignal()
{
ros::spinOnce();
ros::Rate loop_rate(20);
while(ros::ok())
{
GoNextPoseCallback();
loop_rate.sleep();
ros::spinOnce();
}
} // ControlSignal
void SKControl::GoNextPoseCallback()
{
bool hasnextpoint;
hasnextpoint = FindNextTrajectoryPose();
// Stanley Kinematic Controller uses front pose, transform from rear to front
SKControl::next_pose.x = SKControl::next_pose.x + SKControl::L*cos(SKControl::next_pose.theta);
SKControl::next_pose.y = SKControl::next_pose.y + SKControl::L*sin(SKControl::next_pose.theta);
ackermann_msgs::AckermannDriveStamped Ackermann_msg;
ros::Time timestamp = ros::Time::now();
Ackermann_msg.header.stamp = timestamp;
Ackermann_msg.header.frame_id = "base_link";
Ackermann_msg.drive.acceleration = 0;
Ackermann_msg.drive.jerk = 0;
Ackermann_msg.drive.steering_angle_velocity = 0;
SKControl::crosstrack_error = (SKControl::next_pose.y-SKControl::current_pose.y)*cos(SKControl::next_pose.theta)-sin(SKControl::next_pose.theta)*(SKControl::next_pose.x-SKControl::current_pose.x);
SKControl::psi = SKControl::next_pose.theta - SKControl::current_pose.theta;
if (SKControl::current_velocity==0)
SKControl::steering_angle_pub = 0;
else
SKControl::steering_angle_pub = psi + atan2(SKControl::k*SKControl::crosstrack_error/SKControl::current_velocity, 1.0);
SKControl::speed_pub = SKControl::trajectory_points[4*SKControl::point_index+3];
if(DEBUG)
{
double distan;
distan = sqrt(pow(SKControl::next_pose.x-SKControl::current_pose.x,2)+pow(SKControl::next_pose.y-SKControl::current_pose.y,2));
ROS_INFO("Delta y: %.3f",SKControl::next_pose.y-SKControl::current_pose.y);
ROS_INFO("Delta x: %.3f",SKControl::next_pose.x-SKControl::current_pose.x);
ROS_INFO("Distance: %.3f", distan);
ROS_INFO("Cross track error: %.3f",SKControl::crosstrack_error);
ROS_INFO("Psi: %.3f", SKControl::psi);
}
Ackermann_msg.drive.steering_angle = SKControl::steering_angle_pub;
Ackermann_msg.drive.speed = SKControl::speed_pub;
if(!hasnextpoint)
{
if(pow(SKControl::current_pose.x-SKControl::next_pose.x,2)+pow(SKControl::current_pose.y-SKControl::next_pose.y,2)<pow(0.2,2)){
Ackermann_msg.drive.steering_angle = 0;
Ackermann_msg.drive.speed = 0;
control_signal_pub.publish(Ackermann_msg);
ROS_INFO("Get Final");
return;
}
}
control_signal_pub.publish(Ackermann_msg);
if(DEBUG) ROS_INFO("steering_angle_publisher: %.3f,speed_publisher:%.3f", SKControl::steering_angle_pub,SKControl::speed_pub);
} // GoNextPoseCallback
bool SKControl::FindNextTrajectoryPose()
{
if ( SKControl::trajectory_points.size()<=4*(SKControl::point_index+1))
return false ;
// double line_angle = 0.0;
// double car_point_angle = 0.0;
// line_angle = atan2(SKControl::trajectory_points[3*(SKControl::point_index+1)+1]-SKControl::trajectory_points[3*SKControl::point_index+1], SKControl::trajectory_points[3*(SKControl::point_index+1)]-SKControl::trajectory_points[3*SKControl::point_index]);
// car_point_angle = atan2(SKControl::current_pose.y-SKControl::trajectory_points[3*SKControl::point_index+1], SKControl::current_pose.x-SKControl::trajectory_points[3*SKControl::point_index]);
// if((car_point_angle-line_angle) >-M_PI/2 && (car_point_angle-line_angle)<M_PI/2)
// {
// SKControl::point_index++;
// }
std::vector<double> distan2(SKControl::trajectory_points.size()/4,0);
auto distan2_iter = distan2.begin();
auto distan2_e = distan2.end();
auto points_iter = SKControl::trajectory_points.cbegin();
double refpose_theta = 0.0;
bool iflag = false;
while(distan2_iter!=distan2_e)
{
*distan2_iter = pow(SKControl::current_pose.x-*points_iter,2)+pow(SKControl::current_pose.y-*(points_iter+1),2);
points_iter = points_iter + 4;
distan2_iter++;
}
std::vector<double>::iterator distan2_smallest = std::min_element(std::begin(distan2), std::end(distan2));
point_index = std::distance(std::begin(distan2), distan2_smallest);
// Check if the refernce pose is lagging behind the current pose
// If ture, choose the next point
refpose_theta = atan2( SKControl::trajectory_points[4*SKControl::point_index+1],SKControl::trajectory_points[4*SKControl::point_index]);
iflag = (cos(refpose_theta)*(SKControl::current_pose.x-SKControl::trajectory_points[4*SKControl::point_index])+sin( refpose_theta)*SKControl::current_pose.y-SKControl::trajectory_points[4*SKControl::point_index+1]) > 0;
if(iflag)
SKControl::point_index++;
SKControl::next_pose.x = SKControl::trajectory_points[4*SKControl::point_index];
SKControl::next_pose.y = SKControl::trajectory_points[4*SKControl::point_index+1];
SKControl::next_pose.theta = SKControl::trajectory_points[4*SKControl::point_index+2];
if(DEBUG) ROS_INFO("Points_to_pursuit: %d, x_coordinate: %.3f, y_coordinate: %.3f", SKControl::point_index,SKControl::next_pose.x,SKControl::next_pose.y);
return true;
} // FindNextTrajectoryPose
void SKControl::CurrentPoseCallback(const nav_msgs::Odometry& odom)
{
SKControl::current_pose.x = odom.pose.pose.position.x;
SKControl::current_pose.y = odom.pose.pose.position.y;
SKControl::current_pose.theta = 2*acos(odom.pose.pose.orientation.w);
SKControl::current_velocity = odom.twist.twist.linear.x;
SKControl::current_pose.x = SKControl::current_pose.x + SKControl::L*cos(SKControl::current_pose.theta);
SKControl::current_pose.y = SKControl::current_pose.y + SKControl::L*sin(SKControl::current_pose.theta);
if(DEBUG) ROS_INFO("current_pose: %.3f %.3f %.3f; current_velocity: %.3f", SKControl::current_pose.x, SKControl::current_pose.y, SKControl::current_pose.theta, SKControl::current_velocity);
} // CurrentPoseCallback
}
|
0ad2c17486209000cb94cfd875cdb2a46775592d | 101aa26f440ad6c9a754dda448e2a1064978775d | /Dictionary.h | 3a666b6b64e5cd6fddc96073f934a74b42515b40 | [] | no_license | MilkaValkanova/Data-structures-FMI-course--homework-3 | bcdf0a1a0a4056acebd82c643f54150e4bcf7b74 | 830a3bc46036c709cddef234dd79e2fe6291ab18 | refs/heads/master | 2021-01-25T07:50:17.437048 | 2017-06-07T20:24:53 | 2017-06-07T20:24:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 473 | h | Dictionary.h | /**
*
* Solution to homework task
* Data Structures Course
* Faculty of Mathematics and Informatics of Sofia University
* Winter semester 2016/2017
*
* @author Milka Valkanova
* @idnumber 45155
* @task 1
* @compiler VC
*
*/
#pragma once
#include "RadixTree.h"
#include <fstream>
class Dictionary
{
private:
Trie dictionary;
public:
Dictionary(const char*);
void search(const char*)const;
inline void print() const{ dictionary.print(); }
};
|
3b73f121db0b7d9949708be490b349e3968bb2d2 | 7bd42a9171a339c3c352450b22d96b64e7a6a34d | /PathTracing_V2/Object_PT.h | 41b2b387f46558161de1796b59e4472cd209c2b7 | [] | no_license | SpectreSpect/PathTracing_V2 | 5f015d2921d033a29b1c63822c0cc12030b9c826 | abbe91fd48df98dac01af8899ae8034020dec833 | refs/heads/master | 2023-09-01T12:50:17.028173 | 2021-10-12T09:21:19 | 2021-10-12T09:21:19 | 277,036,919 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 210 | h | Object_PT.h | #pragma once
#include <vector>
#include "float3.h"
class Object_PT
{
public:
enum class ObjectType_PT
{
Model = 0,
Sphere = 1,
Camera = 2
};
ObjectType_PT type;
float4 albedo;
float4 emission;
};
|
6e4d4c9c12d43efb02a8773946217cd1f336ed0b | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_6377668744314880_1/C++/TimeString/+SUBMIT2.cpp | 4e04c22ea6f9b560bcd6ed538238d2617df4dde1 | [] | 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 | 2,100 | cpp | +SUBMIT2.cpp | #include <stdio.h>
#include <algorithm>
using namespace std;
struct A {
long long x, y;
int dir;
A(long long _x = 0, long long _y = 0) : x(_x), y(_y) {
if (x > 0 && y == 0)
dir = 1;
else if (x > 0 && y > 0)
dir = 2;
else if (x == 0 && y > 0)
dir = 3;
else if (x < 0 && y > 0)
dir = 4;
else if (x < 0 && y == 0)
dir = 5;
else if (x < 0 && y < 0)
dir = 6;
else if (x == 0 && y < 0)
dir = 7;
else
dir = 8;
}
bool operator < (const A &r) const {
if (dir != r.dir)
return dir < r.dir;
else
return (x * r.y - y * r.x > 0);
}
bool sameSide(const A &r) const {
return (x * r.y - y * r.x >= 0);
}
};
int main(int argc, char *argv[]) {
int ecase, ecount;
int caseStart = -1, caseEnd = 9999999;
scanf("%d", &ecase);
if (argc > 1) {
if (sscanf(argv[1], "%d", &caseStart) == 1) {
if (argc > 2)
sscanf(argv[2], "%d", &caseEnd);
}
if (caseEnd < caseStart)
caseEnd = caseStart;
if (caseEnd != 9999999 && caseEnd >= 1 && caseStart <= 0)
caseStart = 1;
if (caseStart > 0)
fprintf(stderr, "....................DEBUG MODE ENABLED (FROM CASE %d to %d)\n", caseStart, caseEnd);
}
int en;
int ex[10010], ey[10010];
A points[10010];
for (ecount = 1; ecount <= ecase; ecount++) {
if (ecount < caseStart || ecount > caseEnd)
continue;
if (caseStart > 0)
fprintf(stderr, "....................CASE %d START\n", ecount);
scanf("%d", &en);
for (int i = 0; i < en; i++)
scanf("%d%d", &ex[i], &ey[i]);
printf("Case #%d:\n", ecount);
for (int i = 0; i < en; i++) {
int tidx = 0;
for (int j = 0; j < en; j++) {
if (j != i)
points[tidx++] = A(ex[j] - ex[i], ey[j] - ey[i]);
}
sort(points, points + en - 1);
int fp = 0;
int ans = en-1;
for (int j = 0; j < en-1; j++) {
while (fp - j < en-1 && points[j].sameSide( points[ fp%(en-1) ] )) {
fp++;
}
int td = en - 1 - (fp - j);
if (td < ans)
ans = td;
}
printf("%d\n", ans);
}
if (caseStart > 0)
fprintf(stderr, "....................CASE %d END\n", ecount);
}
return 0;
}
|
674a39537e542287533ad9eb3cd811064ed4eb12 | 0eaf7140ca4ba760d81deb6a6ac81819beb89107 | /Weekly_197/1_Number_of_Good_Pairs.cpp | 1bfa3decac384e8b2a360de9404a535c44cf38e8 | [] | no_license | AshwinkumarPillai/LEETCODE_CHALLENGES | c1283509f6ea71f9c22cea595964f00370573a85 | a0971171aa8b3b372e42ca1c42e6cdd0ac35c149 | refs/heads/master | 2023-04-27T16:43:05.757152 | 2021-05-15T16:11:28 | 2021-05-15T16:11:28 | 268,556,788 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 344 | cpp | 1_Number_of_Good_Pairs.cpp | class Solution
{
public:
int numIdenticalPairs(vector<int> &nums)
{
long long ans = 0;
unordered_map<int, int> m;
for (int x : nums)
m[x]++;
for (auto p : m)
{
if (p.second > 1)
ans += (p.second * (p.second - 1)) / 2;
}
return ans;
}
}; |
cf7eb4325bc04c64b020fa6a2a567b55dd174e91 | 2d1f82fe5c4818ef1da82d911d0ed81a0b41ec85 | /UVaOJ/UVa11125.cpp | c65ebcd66fe30f8b73a7029515cff1b006b5f849 | [] | no_license | OrigenesZhang/-1s | d12bad12dee37d4bb168647d7b888e2e198e8e56 | 08a88e4bb84b67a44eead1b034a42f5338aad592 | refs/heads/master | 2020-12-31T00:43:17.972520 | 2020-12-23T14:56:38 | 2020-12-23T14:56:38 | 80,637,191 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,357 | cpp | UVa11125.cpp | #include <iostream>
#include <cstring>
using namespace std;
int dp[1<<12][4][4][4][4], t, n, idle, tot, table[5], S, C;
int dfs(int colour, int sz, int len){
if(!len) return (colour!=C)&&(sz!=S);
int state=0;
for(int i=0; i<4; i++)
state=(state<<3)+table[i];
if(dp[state][S][C][sz][colour]!=-1) return dp[state][S][C][sz][colour];
dp[state][S][C][sz][colour]=0;
for(int i=0; i<n; i++){
if(i==colour) continue;
for(int j=1; j<4&&j<=table[i]; j++){
if(j==sz) continue;
table[i]-=j;
dp[state][S][C][sz][colour]+=dfs(i, j, len-j);
table[i]+=j;
}
}
return dp[state][S][C][sz][colour];
}
int main(){
cin>>t;
memset(dp, -1, sizeof(dp));
while(t--){
cin>>n;
idle=tot=0;
memset(table, 0, sizeof(table));
for(int i=0; i<n; i++){
cin>>table[i];
idle=(idle<<3)+table[i];
tot+=table[i];
}
if(!tot){
cout<<1<<endl;
continue;
}
int s=0;
for(int i=0; i<n; i++){
for(int j=1; j<4&&j<=table[i]; j++){
C=i;
S=j;
table[i]-=j;
s+=dfs(i, j, tot-j);
table[i]+=j;
}
}
cout<<s<<endl;
}
return 0;
}
|
1044468474496085ee1426c213dc23a4e1b4711d | 9d74b8a8d42a217669e27534132787b522829e03 | /sdk/YyShiKejiVideoServer/YyShiKejiVideoServer.h | 2ad760d1569b415a5cd39e4b306a67fc0090f8ae | [] | no_license | TommyZhang936/TChallaOld | c8450880135d1ff2392236e288c515ccb799216e | 6d980b31f40fc7e6b789b862e2e7f408296dadfc | refs/heads/master | 2020-07-01T08:15:02.259552 | 2016-11-10T01:32:59 | 2016-11-10T01:32:59 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 3,036 | h | YyShiKejiVideoServer.h | #ifndef HIKAN_VIDEOSERVER_H
#define HIKAN_VIDEOSERVER_H
#include "../../VideoServer/IVideoServer.h"
#include "NetDEVSDK.h"
#include <memory>
#include <mutex>
#include <string>
// #define LNM_TEST
class CFactory : public IVideoServerFactory
{
public:
CFactory();
~CFactory();
bool init();
void clean();
virtual const char* name()
{
return "รรฎรรยฟรยผยผ";
}
virtual int defaultPort()
{
return 0;
}
virtual const char* defaultUser()
{
return "admin";
}
virtual const char* defaultPasswords()
{
return "123456";
}
virtual DeviceFactory factory()
{
return SISC_IPC_YUSHIKEJI;
}
virtual void videoFileExterns(std::vector<std::string>& externs)
{
externs.push_back("mp4");
}
virtual IVideoServer* create();
};
class DownloadPosCaculator
{
public:
DownloadPosCaculator();
void init(__int64 size, const std::string& sFile)
{
mTotalSize = size;
mSaveFile = sFile;
}
static __int64 getFileSize(const std::string& sFile);
int getPos(__int64& totalSize, __int64& currentSize);
const char* getSaveFile(){
return mSaveFile.c_str();
}
__int64 getLastCurrentSize(){
return mLastSize;
}
bool isMaybeFishish(){
return mMaybeFinish;
}
private:
__int64 mTotalSize;
__int64 mLastSize;
std::string mSaveFile;
int mLittleTimes;
bool mMaybeFinish;
};
class YyShiKejiVideoServer : public IVideoServer
{
friend class CFactory;
public:
static std::recursive_mutex sMtServers;
static std::vector<YyShiKejiVideoServer*> sServers;
public:
YyShiKejiVideoServer();
~YyShiKejiVideoServer();
virtual IVideoServer* clone();
virtual bool login(const char* IP, __int32 port, const char* user, const char* password, std::map<__int32, std::string >& channels);
virtual bool logout();
virtual bool GetRecordFileList(std::vector<RecordFile>& files, const std::vector<int>& channelVec, __time64_t timeStart,
__time64_t timeEnd);
virtual bool downLoadByRecordFile(const char* saveFileName, const RecordFile& file, download_handle_t& hdl);
virtual bool stopDownload(download_handle_t h);
virtual bool PlayBackByRecordFile(const RecordFile& file, HWND hwnd, play_handle_t& playbackHandle);
bool SetPlayBack(download_handle_t playbackHandle, __int32 pos);
virtual bool StopPlayBack(download_handle_t playbackHandle,__int32 mPause);
virtual bool getDownloadPos(download_handle_t h, __int64* totalSize, __int64* currentSize, bool* failed);
private:
bool playVideo(INT64 beginTime, INT64 tEndTime, int channel);
__time64_t mStartPlayTime;
std::map<download_handle_t, DownloadPosCaculator> mMpDownloadPosCaculators;
std::map<download_handle_t, RecordFile> mMpDownloadRecords;
protected:
NETDEV_DEVICE_INFO_S m_deviceInfo;
const RecordFile* m_pPlayFile;
};
#endif // HIKAN_VIDEOSERVER_H
|
90f81df1c2cdaae231ffa8f0f67e6a63e5cbe1f0 | 0e93d7418c6ae4528a0d3d353080683ba7a3bd0a | /exceptions/include/exception.h | d1e86eaabb2880bec62909effecd4a25716d7a4a | [] | no_license | boa85/socks5_proxy | 3e3cfeeb536a52cfe59dc79736037ce0d1de6c4b | 996e5dc22d79cf31a5aa6f6dc7ed8c38dea3dd9d | refs/heads/master | 2021-01-23T01:12:14.028614 | 2017-09-05T08:15:35 | 2017-09-05T08:15:35 | 102,431,563 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,516 | h | exception.h | //
// Created by boa on 05.09.17.
//
#ifndef S5P_EXCEPTION_HPP
#define S5P_EXCEPTION_HPP
#include <boost/system/system_error.hpp>
#include <exception>
#include "../../service/include/service.h"
namespace socks5_proxy {
namespace exceptions {
using namespace service;
class BasicError : public std::exception {
public:
BasicError();
};
class BasicBoostError : public BasicError {
public:
explicit BasicBoostError(b_sys::system_error &&systemError);
const b_sys::error_code &code() const;
const char *what() const noexcept override;
private:
b_sys::system_error systemError_;
};
class ResolutionError : public BasicBoostError {
public:
explicit ResolutionError(b_sys::system_error &&systemError);
};
class ConnectionError : public BasicBoostError {
public:
explicit ConnectionError(b_sys::system_error &&systemError);
};
class BasicPlainError : public BasicError {
public:
explicit BasicPlainError(const std::string &message);
const char *what() const noexcept override;
private:
std::string message_;
};
class Socks5Error : public BasicPlainError {
public:
explicit Socks5Error(const std::string &message);
};
class EndOfFileError : public BasicError {
};
}
}
#endif
|
aa293353c47365294eeb6d797a43181dfaccadc1 | 352f43aab0521dcdb4897298961daed575d457f6 | /BOCA/BE/src/generator.cpp | 2f0502ec100bca249f446f1d7eb6e283d7d5c688 | [
"MIT"
] | permissive | danielsaad/PC1-IFB-CC | 012947dff72b55a1acb83fd1453102ff55dd2247 | 36b55e95373a5f022651545248d8cb66bac1cd3f | refs/heads/master | 2022-02-21T22:23:59.122236 | 2019-10-18T14:06:08 | 2019-10-18T14:06:08 | 100,300,073 | 1 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 2,561 | cpp | generator.cpp | #include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
const int MIN_N = 1;
const int MAX_N = 1000;
const int MIN_K = 0;
const int MAX_K = 95;
const int MIN_L = 1;
const int MAX_L = 80;
const int rnd_test_n = 100;
const int extreme_test_n = 100;
string generate_line(int n){
string s;
for(int i=0;i<n;i++){
s.push_back(32+rnd.next(MIN_K,MAX_K-1));
}
return s;
}
template <typename T> void append(vector<T> &dest, const vector<T> &orig) {
dest.insert(dest.end(), orig.begin(), orig.end());
}
string output_tc(vector<string> vs,int k) {
ostringstream oss;
oss << vs.size() << " " << k << endl;
for(auto line : vs){
oss << line << endl;
}
return oss.str();
}
vector<string> generate_sample_tests() {
vector<string> tests;
tests.push_back(output_tc({"abcdef"},3));
tests.push_back(output_tc({"int main(void){"," return 0;","}"},3));
tests.push_back(output_tc({"atirei o pau no gato","mas o gato nao morreu","5 bicas,","5 pipas,","5 bombas.","Tira da boca da bica,","bota na boca da bomba."},10));
return tests;
}
string rnd_test(int i){
int min_n = MIN_N;
int max_n = MAX_N;
if(i<rnd_test_n/3){
max_n = 10;
}
else if(i<rnd_test_n/2){
max_n = 100;
}
int n = rnd.next(min_n,max_n);
int k = rnd.next(MIN_K,MAX_K);
vector<string> vs;
for(int i=0;i<n;i++){
vs.push_back(generate_line(rnd.next(MIN_L,MAX_L)));
}
return output_tc(vs,k);
}
vector<string> generate_manual_tests(){
vector<string> tests;
tests.push_back(output_tc({"uma vez flamento","sempre flamengo"},95));
return tests;
}
vector<string> generate_random_tests() {
vector<string> tests;
for (int i = 0; i < rnd_test_n; i++){
tests.push_back(rnd_test(i));
}
return tests;
}
string extreme_test(){
vector<string> vs;
for(int i=0;i<MAX_N;i++){
vs.push_back(generate_line(MAX_L));
}
return output_tc(vs,rnd.next(MIN_K,MAX_K));
}
vector<string> generate_extreme_tests(){
vector<string> tests;
for(int i=0;i<extreme_test_n;i++){
tests.push_back(extreme_test());
}
return tests;
}
int main(int argc, char *argv[]) {
registerGen(argc, argv, 1);
vector<string> tests;
size_t test = 0;
append(tests, generate_sample_tests());
append(tests, generate_manual_tests());
append(tests, generate_random_tests());
append(tests, generate_extreme_tests());
for (const auto &t : tests) {
startTest(++test);
cout << t;
}
return 0;
} |
0c4ec965d410c092c92317976fe5b04f09711259 | 928198c9e8696396f1447c7ec2a8e20e6efacec9 | /1238B.cpp | 859d81b142944d9030c8b8d9749c1b0ffaa6b8b1 | [] | no_license | Jeeukrishnan/codeforces_solution | 98f691b22f99bcc963a3fe99421ab923f8abab19 | f6755510ca737e8d2a0763933ed9fe5119027f6d | refs/heads/master | 2020-08-18T23:15:58.302842 | 2019-12-27T16:51:20 | 2019-12-27T16:51:20 | 215,846,534 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 878 | cpp | 1238B.cpp | /*#include<bits/stdc++.h>
using namespace std;
void jeeu()
{
int n,k;
cin>>n>>k;
vector<int>a(n);
for(int i=0;i<n;i++)
{cin>>a[i];}
sort(a.begin(), a.end());
//a.erase(unique(ar.begin(),ar.end()),ar.end());
a.erase( unique( a.begin(), a.end() ), a.end() );
int count=0;
for(int i=n-1;i>=0;i--)
{
//if(ar[i-1]==ar[i])
//continue;
if((a[i]-(k*count))>0)
count++;
}
cout<<max(1,count)<<endl;
}
int main()
{ int t;
cin>>t;
while(t--)
{ jeeu();}}*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int q;
int n,r,count;
int ar[100003];
cin>>q;
while(q--)
{
count =0;
cin>>n>>r;
for(int i=0;i<n;i++)
cin>>ar[i];
sort(ar,ar+n);
for(int i=n-1;i>=0;i--)
{
if(ar[i-1]==ar[i])
continue;
if((ar[i]-(r*count))>0)
count++;
}
cout<<max(1,count)<<endl;
}
} |
3af6f34f461735123d9510410bc03ee5a7e3bcd5 | f2c845dd4096f909eea40418194c6eb5596dd584 | /RiestraRenderEngine/ModelCreator.cpp | 8de41ada393d2a5023d52747ac4eeeb1b0c06ba0 | [] | no_license | christianrxd/RiestraRenderEngine | d2a92fb9f5bf7d03994294da240def030bd3622f | f08e01122200e736f81ee500ac06ca0e784bf823 | refs/heads/master | 2020-08-05T16:38:27.424041 | 2019-10-03T17:17:25 | 2019-10-03T17:17:25 | 212,617,836 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,436 | cpp | ModelCreator.cpp |
#include <vector>
#include <string>
#include "ModelCreator.h"
#include "Vertex.h"
#include "Plane.h"
#include "Model.h"
using namespace std;
ModelCreator::ModelCreator()
{
}
Model ModelCreator::CreateCube(double size)
{
Vertex A = Vertex(-size, -size, -size);
Vertex B = Vertex(-size, -size, size);
Vertex C = Vertex(size, -size, size);
Vertex D = Vertex(size, -size, -size);
Vertex E = Vertex(-size, size, -size);
Vertex F = Vertex(-size, size, size);
Vertex G = Vertex(size, size, size);
Vertex H = Vertex(size, size, -size);
Model myCube;
myCube.AddPlane(A, B, C, D);
myCube.AddPlane(E, F, G, H);
myCube.AddPlane(A, B, F, E);
myCube.AddPlane(D, C, G, H);
myCube.AddPlane(B, C, G, F);
myCube.AddPlane(A, D, H, E);
return myCube;
}
Model ModelCreator::CreateHeart(double size)
{
Model myHeart;
for (int lcv = -2; lcv <= 2; lcv += 1)
{
vector<Vertex> vertexList;
vertexList.push_back(Vertex(0, 4, lcv));
vertexList.push_back(Vertex(2, 6, lcv));
vertexList.push_back(Vertex(5, 6, lcv));
vertexList.push_back(Vertex(7, 4, lcv));
vertexList.push_back(Vertex(7, 0, lcv));
vertexList.push_back(Vertex(0, -7, lcv));
vertexList.push_back(Vertex(-7, 0, lcv));
vertexList.push_back(Vertex(-7, 4, lcv));
vertexList.push_back(Vertex(-5, 6, lcv));
vertexList.push_back(Vertex(-2, 6, lcv));
vertexList.push_back(Vertex(0, 4, lcv));
myHeart.AddPlane(vertexList);
}
return myHeart;
} |
31ef34d859d6ba323999cb42ae88e6a920384d6e | 9970998bdcd1a0552a95a932e9a594c421a77125 | /98/main.cc | f6411df0a695883f9ffc48e3bd76cdaca3d2c8d9 | [] | no_license | steliospaps/stelios-paps-project-euler | 277957c659e924fd661877e9611e855ddb91652c | fad8a210cdb91a93100f1348f2109ec397bc577d | refs/heads/master | 2016-09-02T02:01:59.744407 | 2015-10-24T21:46:45 | 2015-10-24T21:46:45 | 4,705,411 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,888 | cc | main.cc | #include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
typedef map<string,set<string> > map_t;
bool is_square(const int num){
int max=num;
int min=1;
while(true){
int mid = min + (max-min)/2;
int mid2=mid*mid;
if(min>max){
return false;
}else if(mid2==num){
return true;
}else if(mid2>num){
max=mid-1;
}else if(mid2<num){
min=mid+1;
}else{
cerr<<"WTF? "<<num<<" "<<mid<<endl;
}
}
}
typedef pair<vector<int>,vector<int> > pair_t;
const pair_t make_pair_vec(const string&a, const string& b){
vector<int> map_a,map_b;
}
int numerise(std::map<char,int>&map,const std::string&str){
int result=0;
for(size_t i=0;i<str.size();i++){
result*=10;
result+=map[str[i]];
}
return result;
}
int biggest=0;
void check_squareness_recurse(size_t index,std::set<int>&used_numbers,std::map<char,int>&map,const std::string&a,const std::string& b){
if(index==a.size()){
int a_num=numerise(map,a);
int b_num=numerise(map,b);
if(is_square(a_num) && is_square(b_num)){
biggest=max(biggest,a_num);
biggest=max(biggest,b_num);
cout<<" "<<a_num<<" "<<b_num<<endl;
cout<<"biggest "<<biggest<<endl;
}
//end of the line
}else if(map.find(a[index])!=map.end()){
//duplicate letter
check_squareness_recurse(index+1,used_numbers,map,a,b);
}else{
for(int i=0;i<=9;i++){
if(used_numbers.find(i)!=used_numbers.end()){
continue;
}
if(i==0&&a[index]==b[0]){
//b would start with 0;
continue;
}
used_numbers.insert(i);
map[a[index]]=i;
check_squareness_recurse(index+1,used_numbers,map,a,b);
map.erase(a[index]);
used_numbers.erase(i);
}
}
}
void check_squareness(const string&a, const string& b){
cout<<"check_squareness "<<a<<" "<<b<<endl;
for(int i=1;i<=9;i++){
std::set<int> used_numbers;
std::map<char,int> map;
map[a[0]]=i;
used_numbers.insert(i);
check_squareness_recurse(1,used_numbers,map,a,b);
}
}
int main(){
ifstream in("words_split.txt");
string word;
map_t words;
while(in>>word){
string key=word;
sort(key.begin(),key.end());
words[key].insert(word);
//cout<<"["<<word<<"]"<<endl;
}
for(map_t::iterator i = words.begin();
i!= words.end();
++i){
if(i->second.size()>1){
cout<<i->first<<" :";
for(map_t::value_type::second_type::iterator j=i->second.begin();
j!=i->second.end();
++j){
cout<<" "<<*j;
}
cout<<endl;
for(map_t::value_type::second_type::iterator j=i->second.begin();
j!=i->second.end();
++j){
for(map_t::value_type::second_type::iterator k=j;
k!=i->second.end();
++k){
if(k!=j){
check_squareness(*j,*k);
}
}
}
}
}
cout<<biggest<<endl;
return 0;
}
|
a56178540326ca2f14ec0282c0dac7998e3e4622 | 5724c6c5cbece818d7ad776d1e1c59181e404f6f | /d01/ex09/main.cpp | 0c2600fc86263caf135f611da4a0fddfad4345ca | [] | no_license | etugoluk/CPP_pool | 17d40b77a117f983ca37f831550f87a39c153fca | 863a2f2e1d85aece6373f88e56609a5b133a3916 | refs/heads/master | 2020-03-29T20:37:52.472717 | 2018-10-14T17:26:36 | 2018-10-14T17:26:36 | 150,322,213 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,048 | cpp | main.cpp | // ************************************************************************** //
// //
// ::: :::::::: //
// main.cpp :+: :+: :+: //
// +:+ +:+ +:+ //
// By: etugoluk <etugoluk@student.unit.ua> +#+ +:+ +#+ //
// +#+#+#+#+#+ +#+ //
// Created: 2018/10/03 15:33:04 by etugoluk #+# #+# //
// Updated: 2018/10/03 15:33:05 by etugoluk ### ########.fr //
// //
// ************************************************************************** //
#include "Logger.hpp"
int main()
{
Logger l;
l.setFilename("out");
l.log("console", "write to console");
l.log("file", "write to file");
return (0);
} |
2001aac8eb6bfb0bd30558cd7c707033560de1ae | 26f8306fc51a45f75bc42b6d33b9aba3ad2598e3 | /CS211/prog5/proj5Main.cpp | 4ac50a5539aa5fae166ee0b5fd647b708031bc88 | [] | no_license | LachezarLyubenov/Completed-Projects | 51359d14e711dc1dd5f4688566ae2a30475fc3dd | 4308513863e7e0786517d2db94898352718a40fa | refs/heads/master | 2020-03-19T08:42:20.426856 | 2018-06-05T20:42:20 | 2018-06-05T20:42:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,740 | cpp | proj5Main.cpp | <<<<<<< HEAD
/* This file contains the user interface code for the Infix Evaluation Project
* Project 5 for CS 211 for Fall 2017
*
* Date: 03/19/2018
*
* Author: Lachezar Lyubenov
*
*/
#include "proj5Tokens.h"
#include "myStack.h"
bool debugMode = false;
void printCommands();
void processExpression (Token inputToken, TokenReader *tr, myStack &numberArray, myStack &operatorArray);
int eval (int firstValue, char operation, int secondValue)
{
if (operation == '+') return firstValue + secondValue;
else if (operation == '-') return firstValue - secondValue;
else if (operation == '*') return firstValue * secondValue;
else if (operation == '/') return firstValue / secondValue;
else{
return -9999;
}
}
void popAndEval (myStack* operatorArray, myStack* numberArray)
{
char operation = operatorArray->top();
operatorArray->pop(operatorArray->top());
int secondValue = numberArray->top();
numberArray->pop(operatorArray->top());
int firstValue = numberArray->top();
numberArray->pop(operatorArray->top());
int result = 0;
result = eval ( firstValue, operation, secondValue );
numberArray->push(result);
}
int main(int argc, char *argv[])
{
/***************************************************************/
/* Add code for checking command line arguments for debug mode */
for (int x = 0; x < argc; ++x)
{
if (argv[x] == "-d")
{
debugMode = true;
}
}
Token inputToken;
TokenReader tr;
myStack numberArray;
myStack operatorArray;
printf ("Starting Expression Evaluation Program\n\n");
printf ("Enter Expression: ");
inputToken = tr.getNextToken ();
while (inputToken.equalsType(QUIT) == false)
{
/* check first Token on Line of input */
if(inputToken.equalsType(HELP))
{
printCommands();
tr.clearToEoln();
}
else if(inputToken.equalsType(ERROR))
{
printf ("Invalid Input - For a list of valid commands, type ?\n");
tr.clearToEoln();
}
else if(inputToken.equalsType(EOLN))
{
printf ("Blank Line - Do Nothing\n");
/* blank line - do nothing */
}
else
{
processExpression (inputToken, &tr, numberArray, operatorArray);
}
printf ("\nEnter Expression: ");
inputToken = tr.getNextToken ();
}
printf ("Quitting Program\n");
return 1;
}
void printCommands()
{
printf ("The commands for this program are:\n\n");
printf ("q - to quit the program\n");
printf ("? - to list the accepted commands\n");
printf ("or any infix mathematical expression using operators of (), *, /, +, -\n");
}
void processExpression (Token inputToken, TokenReader *tr, myStack &numberArray, myStack &operatorArray)
{
/**********************************************/
/* Declare both stack head pointers here */
numberArray.reset();
operatorArray.reset();
/* Loop until the expression reaches its End */
while (inputToken.equalsType(EOLN) == false)
{
/* The expression contain a VALUE */
if (inputToken.equalsType(VALUE))
{
if (debugMode == true)
{
printf("Val: %d, ", inputToken.getValue());
}
// add code to perform this operation here
numberArray.push(inputToken.getValue());
}
/* The expression contains an OPERATOR */
else if (inputToken.equalsType(OPERATOR))
{
if (inputToken.equalsOperator('('))
{
if (debugMode == true)
{
printf("Val: %d, ", inputToken.getValue());
}
// add code to perform this operation here
operatorArray.push(inputToken.getOperator());
}
if ((inputToken.equalsOperator('+')) || (inputToken.equalsOperator('-')))
{
while (!operatorArray.isEmpty() && ((operatorArray.top() == '+' || operatorArray.top() == '-' || operatorArray.top() == '*' || operatorArray.top() == '/')))
{
popAndEval (&operatorArray, &numberArray);
}
if (debugMode == true)
{
printf("Val: %d, ", inputToken.getValue());
}
operatorArray.push(inputToken.getOperator());
}
if (inputToken.equalsOperator('*') || inputToken.equalsOperator('/'))
{
while (!operatorArray.isEmpty() && (operatorArray.top() == '*' || operatorArray.top() == '/'))
{
popAndEval (&operatorArray, &numberArray);
}
operatorArray.push(inputToken.getOperator());
}
if (inputToken.equalsOperator(')'))
{
while (!operatorArray.isEmpty() && (operatorArray.top() != '('))
{
popAndEval (&operatorArray, &numberArray);
}
if (operatorArray.isEmpty())
{
printf ("Error!");
}
else{
operatorArray.pop(inputToken.getOperator());
}
}
}
/* get next token from input */
inputToken = tr->getNextToken ();
}
/* The expression has reached its end */
printf ("\n");
// add code to perform this operation here
while (!operatorArray.isEmpty())
{
popAndEval (&operatorArray, &numberArray);
}
if (debugMode == true)
{
printf("Expression is done, result below:");
}
printf ("Answer: %d", numberArray.top());
numberArray.reset();
operatorArray.reset();
if (!numberArray.isEmpty())
{
printf ("Error! Not empty!");
}
printf ("\n");
}
=======
/* This file contains the user interface code for the Infix Evaluation Project
* Project 5 for CS 211 for Fall 2017
*
* Date: 03/19/2018
*
* Author: Lachezar Lyubenov
*
*/
#include "proj5Tokens.h"
#include "myStack.h"
bool debugMode = false;
void printCommands();
void processExpression (Token inputToken, TokenReader *tr, myStack &numberArray, myStack &operatorArray);
int eval (int firstValue, char operation, int secondValue)
{
if (operation == '+') return firstValue + secondValue;
else if (operation == '-') return firstValue - secondValue;
else if (operation == '*') return firstValue * secondValue;
else if (operation == '/') return firstValue / secondValue;
else{
return -9999;
}
}
void popAndEval (myStack* operatorArray, myStack* numberArray)
{
char operation = operatorArray->top();
operatorArray->pop(operatorArray->top());
int secondValue = numberArray->top();
numberArray->pop(operatorArray->top());
int firstValue = numberArray->top();
numberArray->pop(operatorArray->top());
int result = 0;
result = eval ( firstValue, operation, secondValue );
numberArray->push(result);
}
int main(int argc, char *argv[])
{
/***************************************************************/
/* Add code for checking command line arguments for debug mode */
for (int x = 0; x < argc; ++x)
{
if (argv[x] == "-d")
{
debugMode = true;
}
}
Token inputToken;
TokenReader tr;
myStack numberArray;
myStack operatorArray;
printf ("Starting Expression Evaluation Program\n\n");
printf ("Enter Expression: ");
inputToken = tr.getNextToken ();
while (inputToken.equalsType(QUIT) == false)
{
/* check first Token on Line of input */
if(inputToken.equalsType(HELP))
{
printCommands();
tr.clearToEoln();
}
else if(inputToken.equalsType(ERROR))
{
printf ("Invalid Input - For a list of valid commands, type ?\n");
tr.clearToEoln();
}
else if(inputToken.equalsType(EOLN))
{
printf ("Blank Line - Do Nothing\n");
/* blank line - do nothing */
}
else
{
processExpression (inputToken, &tr, numberArray, operatorArray);
}
printf ("\nEnter Expression: ");
inputToken = tr.getNextToken ();
}
printf ("Quitting Program\n");
return 1;
}
void printCommands()
{
printf ("The commands for this program are:\n\n");
printf ("q - to quit the program\n");
printf ("? - to list the accepted commands\n");
printf ("or any infix mathematical expression using operators of (), *, /, +, -\n");
}
void processExpression (Token inputToken, TokenReader *tr, myStack &numberArray, myStack &operatorArray)
{
/**********************************************/
/* Declare both stack head pointers here */
numberArray.reset();
operatorArray.reset();
/* Loop until the expression reaches its End */
while (inputToken.equalsType(EOLN) == false)
{
/* The expression contain a VALUE */
if (inputToken.equalsType(VALUE))
{
if (debugMode == true)
{
printf("Val: %d, ", inputToken.getValue());
}
// add code to perform this operation here
numberArray.push(inputToken.getValue());
}
/* The expression contains an OPERATOR */
else if (inputToken.equalsType(OPERATOR))
{
if (inputToken.equalsOperator('('))
{
if (debugMode == true)
{
printf("Val: %d, ", inputToken.getValue());
}
// add code to perform this operation here
operatorArray.push(inputToken.getOperator());
}
if ((inputToken.equalsOperator('+')) || (inputToken.equalsOperator('-')))
{
while (!operatorArray.isEmpty() && ((operatorArray.top() == '+' || operatorArray.top() == '-' || operatorArray.top() == '*' || operatorArray.top() == '/')))
{
popAndEval (&operatorArray, &numberArray);
}
if (debugMode == true)
{
printf("Val: %d, ", inputToken.getValue());
}
operatorArray.push(inputToken.getOperator());
}
if (inputToken.equalsOperator('*') || inputToken.equalsOperator('/'))
{
while (!operatorArray.isEmpty() && (operatorArray.top() == '*' || operatorArray.top() == '/'))
{
popAndEval (&operatorArray, &numberArray);
}
operatorArray.push(inputToken.getOperator());
}
if (inputToken.equalsOperator(')'))
{
while (!operatorArray.isEmpty() && (operatorArray.top() != '('))
{
popAndEval (&operatorArray, &numberArray);
}
if (operatorArray.isEmpty())
{
printf ("Error!");
}
else{
operatorArray.pop(inputToken.getOperator());
}
}
}
/* get next token from input */
inputToken = tr->getNextToken ();
}
/* The expression has reached its end */
printf ("\n");
// add code to perform this operation here
while (!operatorArray.isEmpty())
{
popAndEval (&operatorArray, &numberArray);
}
if (debugMode == true)
{
printf("Expression is done, result below:");
}
printf ("Answer: %d", numberArray.top());
numberArray.reset();
operatorArray.reset();
if (!numberArray.isEmpty())
{
printf ("Error! Not empty!");
}
printf ("\n");
}
>>>>>>> a6d97162d4cf417e38a009717e669e5b9bd310b4
|
9c6a7697b2c3b0f1466972c1b3d2ec17b483e192 | 3d28c9c97f8a4ee9b8e7a5f30acc9cd574de7c02 | /paper_1_question_1.cpp | a681c169abfb07b13530717c1ba5872f2bfd169e | [] | no_license | disha03/C-Solution | 4cd6987bb4587c24ec46df2bce846a8a1e27e869 | 1aef042af3167c1916e6f36873193f39c5461570 | refs/heads/main | 2023-02-20T02:41:09.590136 | 2021-01-18T11:35:37 | 2021-01-18T11:35:37 | 330,646,436 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,386 | cpp | paper_1_question_1.cpp | #include <bits/stdc++.h>
using namespace std;
priority_queue<int>maxi;
priority_queue<int,vector<int>,greater<int> >mini;
vector<double>Median(vector<int> a) {
vector<double>result;
for(int i=0;i<a.size();i++){
int num=a[i];
if(maxi.empty() || num < maxi.top())
maxi.push(num);
else
mini.push(num);
if(maxi.size() > mini.size() + 1)
{
mini.push(maxi.top());
maxi.pop();
}
if(mini.size() > maxi.size() + 1)
{
maxi.push(mini.top());
mini.pop();
}
if(maxi.size() == mini.size())
result.push_back((maxi.top() + mini.top())*0.5);
else if(maxi.size() > mini.size())
result.push_back(maxi.top());
else
result.push_back(mini.top());
}
return result;
}
int main()
{
int i,j,k,t,n;
cout<<"Enter Size of Array :"<<"\n";
cin>>n;
// size of array or total number of input elements
vector<int>a(n+1);
//assumed integers are stored in array
cout<<"Enter elements of array :" <<"\n";
for(i=0;i<n;i++)
{
cin>>a[i];
}
vector<double> result = Median(a);
cout<<"Median in a stream of integers are : ";
for(i=0;i<n;i++)
{
cout<<result[i]<<" ";
}
return 0;
}
|
16207004a777e4f8ea6fca59220b5e77d7f57754 | 6497be8e118c9a5cd6376392dd2fce45429f8d1f | /Graphs/graph.cpp | 6aeb5d6cb8790c4ac229e4e54d6fec60bd46fc42 | [] | no_license | g33kyaditya/DS-A | 6632d805bef2ef892f4ca9ff4c9c7ed07deeb5f7 | 11335ede96efd7fe0f2cb995bd7139388ece298e | refs/heads/master | 2020-04-06T06:55:09.295016 | 2016-08-29T18:24:50 | 2016-08-29T18:24:50 | 65,494,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,229 | cpp | graph.cpp | #include "graph.h"
#include <queue>
Graph::Graph(int total) {
V = total;
adj = new list<int>[V+1];
}
void Graph::addEdge(int vert1, int vert2) {
adj[vert1].push_back(vert2);
adj[vert2].push_back(vert1);
}
void Graph::BFS(int start) {
bool *visited = new bool[V+1];
for (int i = 0; i <= V; i++)
visited[i] = false;
queue<int> q;
cout << "The Breadth First Search is ... \n";
q.push(start);
visited[start] = true;
int u;
list<int>::iterator it;
while(!q.empty()) {
u = q.front();
cout << u << " ";
q.pop();
for (it = adj[u].begin(); it != adj[u].end(); ++it) {
if (!visited[*it]) {
visited[u] = true;
q.push(*it);
}
}
}
}
void Graph::DFS(int start) {
bool * visited = new bool[V+1];
for (int i = 0; i <= V; i++)
visited[i] = false;
DFSUtil(start, visited);
}
void Graph::DFSUtil(int start, bool * visited) {
cout << start << " ";
visited[start] = true;
list<int>::iterator it;
for (it = adj[start].begin(); it != adj[start].end(); it++) {
if (!visited[*it]) {
DFSUtil(*it, visited);
}
}
}
|
96e73616f7031ce348744d573ef91bed838431fe | e1e23e6eb20425c43e0ba869b6e47917bc811593 | /model_wrappers/cpp/ClipperRPC.cpp | 7b44d0c155b07c248c8086dee67aae7a71da02b6 | [] | no_license | HuaizhengZhang/clipper-v0 | cf5705e2aac2b57e35450b569971f85a9cdd00f6 | cb7913d3fb040a066adbc7ec95beb14a49ab54eb | refs/heads/master | 2020-08-08T02:25:34.523877 | 2016-10-14T23:51:00 | 2016-10-14T23:51:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,309 | cpp | ClipperRPC.cpp | #include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include <vector>
#include "ClipperRPC.h"
#include "Model.h"
#define SHUTDOWN_CODE 0
#define FIXEDINT_CODE 1
#define FIXEDFLOAT_CODE 2
#define FIXEDBYTE_CODE 3
#define VARINT_CODE 4
#define VARFLOAT_CODE 5
#define VARBYTE_CODE 6
#define STRING_CODE 7
void error(const char* error_msg) {
fprintf(stderr, "%s\n", error_msg);
exit(1);
}
bool is_fixed_format(char input_type) {
return input_type == FIXEDINT_CODE ||
input_type == FIXEDFLOAT_CODE || input_type == FIXEDBYTE_CODE;
}
bool is_var_format(char input_type) {
return input_type == VARINT_CODE ||
input_type == VARFLOAT_CODE || input_type == VARBYTE_CODE;
}
void ClipperRPC::handle(int newsockfd) {
char buffer[256];
int i, j, n, bytes_read, header_bytes = 5;
int additional_header_bytes, total_bytes_expected;
uint32_t input_type, num_inputs, input_len, shutdown_msg;
vector<vector<char> > v_byte;
vector<vector<double> > v_double;
vector<vector<uint32_t> > v_int;
vector<vector<string> > v_str;
vector<double> predictions;
printf("Handling new connection\n");
while (true) {
bytes_read = 0;
while (bytes_read < header_bytes) {
n = read(newsockfd, &buffer[bytes_read], header_bytes);
if (n < 0) {
error("ERROR reading from socket");
}
bytes_read += n;
}
input_type = buffer[0];
memcpy(&num_inputs, &buffer[1], 4);
if (input_type == SHUTDOWN_CODE) {
printf("Shutting down connection\n");
shutdown_msg = 1234;
write(newsockfd, &shutdown_msg, 4);
return;
}
if (is_fixed_format(input_type)) {
additional_header_bytes = 4;
while (bytes_read < header_bytes + additional_header_bytes) {
n = read(newsockfd, &buffer[bytes_read], header_bytes);
if (n < 0) {
error("ERROR reading from socket");
}
bytes_read += n;
}
memcpy(&input_len, &buffer[header_bytes], additional_header_bytes);
bytes_read -= (header_bytes + additional_header_bytes);
if (input_type == FIXEDBYTE_CODE) {
total_bytes_expected = input_len*num_inputs;
char data[total_bytes_expected];
memset(data, 0, total_bytes_expected);
memcpy(data, &buffer[header_bytes + additional_header_bytes],
bytes_read);
while (bytes_read < total_bytes_expected) {
n = read(newsockfd, &data[bytes_read], 256);
if (n < 0) {
error("ERROR reading from socket");
}
bytes_read += n;
}
v_byte = vector<vector<char> >(num_inputs,
vector<char>(input_len, 0));
for (i = 0; i < num_inputs; i++) {
for (j = 0; j < input_len; j++) {
v_byte[i][j] = data[i*input_len + j];
}
}
} else if (input_type == FIXEDFLOAT_CODE) {
total_bytes_expected = 8*input_len*num_inputs;
char data[total_bytes_expected];
memset(data, 0, total_bytes_expected);
memcpy(data, &buffer[header_bytes + additional_header_bytes],
bytes_read);
while (bytes_read < total_bytes_expected) {
n = read(newsockfd, &data[bytes_read], 256);
if (n < 0) {
error("ERROR reading from socket");
}
bytes_read += n;
}
v_double = vector<vector<double> >(num_inputs,
vector<double>(input_len, 0));
for (i = 0; i < num_inputs; i++) {
for (j = 0; j < input_len; j++) {
v_double[i][j] = *((double *) &data[8*(i*input_len + j)]);
}
}
} else if (input_type == FIXEDINT_CODE) {
total_bytes_expected = 4*input_len*num_inputs;
char data[total_bytes_expected];
memset(data, 0, total_bytes_expected);
memcpy(data, &buffer[header_bytes + additional_header_bytes],
bytes_read);
while (bytes_read < total_bytes_expected) {
n = read(newsockfd, &data[bytes_read], 256);
if (n < 0) {
error("ERROR reading from socket");
}
bytes_read += n;
}
v_int = vector<vector<uint32_t> >(num_inputs,
vector<uint32_t>(input_len, 0));
for (i = 0; i < num_inputs; i++) {
for (j = 0; j < input_len; j++) {
v_int[i][j] = *((uint32_t *) &data[4*(i*input_len + j)]);
}
}
}
} else if (is_var_format(input_type)) {
error("ERROR: variable lengths not yet implemented");
} else if (input_type == STRING_CODE) {
error("ERROR: String type not yet implemented");
} else {
error("ERROR: Invalid input type");
}
if (input_type == FIXEDBYTE_CODE || input_type == VARBYTE_CODE) {
predictions = model->predict_bytes(v_byte);
} else if (input_type == FIXEDFLOAT_CODE || input_type == VARFLOAT_CODE) {
predictions = model->predict_floats(v_double);
} else if (input_type == FIXEDINT_CODE || input_type == VARINT_CODE) {
predictions = model->predict_ints(v_int);
} else {
predictions = model->predict_strings(v_str);
}
for (int i = 0; i < predictions.size(); i++) {
write(newsockfd, &predictions[i], 8);
}
}
}
void ClipperRPC::serve_forever() {
int sockfd, newsockfd, pid;
socklen_t clilen;
struct sockaddr_in serv_addr, cli_addr;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0) {
error("ERROR opening socket");
}
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
inet_aton(s_addr, &serv_addr.sin_addr);
serv_addr.sin_port = htons(portno);
if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
error("ERROR binding socket");
}
listen(sockfd, 10);
clilen = sizeof(cli_addr);
while (true) {
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
if (newsockfd < 0) {
error("ERROR opening client connection");
}
handle(newsockfd);
close(newsockfd);
printf("Closing connection\n");
}
}
ClipperRPC::ClipperRPC(std::unique_ptr<Model> &model,
char *s_addr, int portno) :
model(std::move(model)), s_addr(s_addr), portno(portno) {}
|
2ccfbefe5d426d4c9b7930b6ef2a09fcc8e48152 | bde250a5bd97435abf0ffa505ba3da1f129720d8 | /security/gina/gpext/appmgmt/common/dbg.hxx | 64142a89d3dee0e27d880047f6de52d4df37fac8 | [] | no_license | KernelPanic-OpenSource/Win2K3_NT_ds | f45afd1a1243e42a8ccb489048f4a73946dad99f | 0d97393773ee5ecdc29aae15023492e383f7ee7f | refs/heads/master | 2023-04-04T00:34:51.876505 | 2021-04-14T04:49:28 | 2021-04-14T04:49:28 | 357,774,650 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,230 | hxx | dbg.hxx | //*************************************************************
//
// Copyright (c) Microsoft Corporation 1998
// All rights reserved
//
// dbg.hxx
//
//*************************************************************
#ifndef __COMMON_DBG_HXX__
#define __COMMON_DBG_HXX__
extern HINSTANCE ghDllInstance;
extern DWORD gDebugLevel;
extern DWORD gDebugBreak;
//
// Official diagnostic key/value names.
//
#define DIAGNOSTICS_KEY L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Diagnostics"
#define DIAGNOSTICS_POLICY_VALUE L"RunDiagnosticLoggingApplicationManagement"
//
// Additional debug settings.
//
#define DEBUG_KEY_NAME L"AppMgmtDebugLevel"
#define DEBUGBREAK_KEY_NAME L"AppMgmtDebugBreak"
//
// Debug Levels. Must specify DL_NORMAL or DL_VERBOSE to get eventlog
// or logfile output.
//
#define DL_NONE 0x00000000
#define DL_NORMAL 0x00000001
#define DL_VERBOSE 0x00000002 // do verbose logging
#define DL_EVENTLOG 0x00000004 // sent debug to the event log
#define DL_LOGFILE 0x00000008 // sent debug to a log file
#define DL_EVENT 0x00000010 // set a special event when finished processing
#define DL_APPLY 0x00000020 // always apply policy
#define DL_NODBGOUT 0x00000040 // no debugger output
#define DL_CSTORE 0x00000080 // really detailed ds query logging
//
// Debug message types
//
#define DM_ASSERT 0x1
#define DM_WARNING 0x2
#define DM_VERBOSE 0x4
#define DM_NO_EVENTLOG 0x8
#define DEBUGMODE_POLICY 1
#define DEBUGMODE_SERVICE 2
#define DEBUGMODE_CLIENT 3
void
_DebugMsg(
DWORD mask,
DWORD MsgID,
...
);
void
LogTime();
void
ConditionalBreakIntoDebugger();
void
InitDebugSupport( DWORD DebugMode );
BOOL
DebugLevelOn( DWORD mask );
HANDLE
OpenUnicodeLogFile ( LPCTSTR lpszFilePath );
BOOL
GetDebugLogFileName(
WCHAR* wszLogFile,
LONG cchLogFile );
//
// Debug macros
//
#if DBG
#define DebugMsg(x) _DebugMsg x
#else
#define DebugMsg(x) if ( gDebugLevel != DL_NONE ) _DebugMsg x
#endif // DBG
#define VerboseDebugDump( String ) DebugMsg((DM_VERBOSE | DM_NO_EVENTLOG, IDS_STRING, String))
#endif // ifndef __COMMON_DBG_HXX__
|
87b574d388dea26d3a908dccd419c85ac11704ba | accd6e4daa3fc1103c86d245c784182e31681ea4 | /HappyHunter/Core/d3dutils.cpp | ad85766ebcabda02eb2003a89633d22a1ddf6ca4 | [] | no_license | linfuqing/zero3d | d87ad6cf97069aea7861332a9ab8fc02b016d286 | cebb12c37fe0c9047fb5b8fd3c50157638764c24 | refs/heads/master | 2016-09-05T19:37:56.213992 | 2011-08-04T01:37:36 | 2011-08-04T01:37:36 | 34,048,942 | 0 | 1 | null | null | null | null | ISO-8859-7 | C++ | false | false | 16,837 | cpp | d3dutils.cpp | #include "StdAfx.h"
#include "d3dutils.h"
using namespace zerO;
void zerO::UpdateSkinnedMesh(
const D3DXMATRIX *pBoneTransforms,
zerO::UINT uNumBones,
const void* pVerticesSrc,
void* pVerticesDst,
zerO::UINT uNumTotalVertices,
zerO::UINT uStride,
zerO::PUINT puNumBoneInfluences,
LPDWORD* ppdwVerticesIndices,
zerO::PFLOAT* ppfWeights,
const D3DXVECTOR3* pTangentSrc,
D3DXVECTOR3* pTangentDst
)
{
UINT i, uNumVertices, uOffsetByte, uNormalByte, uIndex, VectorSize = sizeof(D3DXVECTOR3);
FLOAT fWeight;
UINT8 *pDest = (zerO::PUINT8)pVerticesDst;
D3DXVECTOR3 *Src, Temp;
const UINT8 *pSrc = (zerO::PUINT8)pVerticesSrc;
memcpy(pDest, pSrc, uNumTotalVertices * uStride);
for(i = 0; i < uNumBones; i++)
{
uNumVertices = puNumBoneInfluences[i];
if(uNumVertices <= 0)
continue;
while(uNumVertices --)
{
uIndex = ppdwVerticesIndices[i][uNumVertices];
fWeight = ppfWeights[i][uNumVertices];
uOffsetByte = uIndex * uStride;
uNormalByte = uOffsetByte + VectorSize;
Src = (D3DXVECTOR3 *)(pSrc + uOffsetByte);
D3DXVec3TransformCoord(&Temp, Src, &pBoneTransforms[i]);
*( (D3DXVECTOR3 *)(pDest + uOffsetByte) ) += (Temp - *Src) * fWeight;
Src = (D3DXVECTOR3 *)(pSrc + uNormalByte); //ยทยจฮฮฏ
D3DXVec3TransformNormal(&Temp, Src, &pBoneTransforms[i]);
*( (D3DXVECTOR3 *)(pDest + uNormalByte) ) += (Temp - *Src) * fWeight;
}
}
if(pTangentSrc && pTangentDst)
{
memcpy(pTangentDst, pTangentSrc, uNumTotalVertices * VectorSize);
for(i = 0; i < uNumBones; i++)
{
uNumVertices = puNumBoneInfluences[i];
if(uNumVertices <= 0)
continue;
while(uNumVertices --)
{
uIndex = ppdwVerticesIndices[i][uNumVertices];
fWeight = ppfWeights[i][uNumVertices];
D3DXVec3TransformNormal(&Temp, &pTangentSrc[uIndex], &pBoneTransforms[i]);
pTangentDst[uIndex] += (Temp - pTangentSrc[uIndex]) * fWeight;
}
}
}
}
void zerO::DirectionToRotation(FLOAT& x, FLOAT& y, const D3DXVECTOR3& Direction)
{
if( Direction.x == 0 && Direction.z == 0 && Direction.y == 0 )
{
x = 0;
y = 0;
}
else if( Direction.x == 0 && Direction.z == 0 )
{
x = - asin( Direction.y / D3DXVec3Length(&Direction) );
y = 0;
}
else if( Direction.z < 0 )
{
x = - asin( Direction.y / D3DXVec3Length(&Direction) );
y = D3DX_PI - asin( Direction.x / sqrt(Direction.x * Direction.x + Direction.z * Direction.z) );
}
else
{
x = - asin( Direction.y / D3DXVec3Length(&Direction) );
y = asin( Direction.x / sqrt(Direction.x * Direction.x + Direction.z * Direction.z) );
}
}
void zerO::SceneDirectionToRotation(FLOAT& x, FLOAT& y, const D3DXVECTOR3& Direction)
{
DirectionToRotation(x, y, -Direction);
}
void zerO::QuaternionToEular(D3DXVECTOR3& Eular, const D3DXQUATERNION& Quaternion)
{
FLOAT sqx = Quaternion.x * Quaternion.x;
FLOAT sqy = Quaternion.y * Quaternion.y;
FLOAT sqz = Quaternion.z * Quaternion.z;
FLOAT sqw = Quaternion.w * Quaternion.w;
Eular.x = atan2( 2 * (Quaternion.y * Quaternion.z + Quaternion.x * Quaternion.w), - sqx - sqy + sqz + sqw);
Eular.y = asin( - 2 * (Quaternion.x * Quaternion.z - Quaternion.y * Quaternion.w) );
Eular.z = atan2( 2 * (Quaternion.x * Quaternion.y + Quaternion.z * Quaternion.w), sqx - sqy - sqz + sqw);
}
void zerO::MatrixDecompose(D3DXVECTOR3 *pOutScale, D3DXVECTOR3 *pOutRotation, D3DXVECTOR3 *pOutTranslation, const D3DXMATRIX& Matrix)
{
if(pOutRotation)
{
D3DXQUATERNION Quaternion;
D3DXMatrixDecompose(pOutScale, &Quaternion, pOutTranslation, &Matrix);
D3DXQuaternionNormalize(&Quaternion, &Quaternion);
QuaternionToEular(*pOutRotation, Quaternion);
}
else
D3DXMatrixDecompose(pOutScale, NULL, pOutTranslation, &Matrix);
}
void zerO::TransformPlane(D3DXPLANE& OutPlane, const D3DXPLANE& InPlane, const D3DXMATRIX Matrix)
{
D3DXMATRIX Temp;
D3DXMatrixInverse(&Temp, NULL, &Matrix);
D3DXMatrixTranspose(&Temp, &Temp);
D3DXPlaneTransform(&OutPlane, &InPlane, &Temp);
}
zerO::UINT zerO::GetPrimitiveCount(D3DPRIMITIVETYPE Type, UINT uNumIndices)
{
UINT uNumFaces;
switch(Type)
{
case D3DPT_TRIANGLELIST:
uNumFaces = uNumIndices / 3;
break;
case D3DPT_TRIANGLESTRIP:
uNumFaces = uNumIndices - 2;
break;
case D3DPT_TRIANGLEFAN:
uNumFaces = (uNumIndices - 1) / 2;
break;
}
return uNumFaces;
}
bool zerO::ComputeMeshNoraml(
UINT uNumVertices, UINT uNumIndices,
void* pIndicesStream , UINT uIndexStride , D3DPRIMITIVETYPE Type ,
void* pPositionStream, UINT uPositionStride, UINT uPositionOffset,
void* pNormalStream , UINT uNormalStride , UINT uNormalOffset )
{
D3DXVECTOR3 Normal;
LPD3DXVECTOR3 pVertex0, pVertex1, pVertex2;
PUINT8 pBuffer, pIndices = (PUINT8)pIndicesStream, pPosition = (PUINT8)pPositionStream, pNormal = (PUINT8)pNormalStream;
UINT i, uIndex0 = 0, uIndex1 = 0, uIndex2 = 0, uIndex = 0, uNumFaces = GetPrimitiveCount(Type, uNumIndices);
pBuffer = pNormal + uNormalOffset;
for(i = 0; i < uNumVertices; i ++)
{
memset( pBuffer, 0, sizeof(D3DXVECTOR3) );
pBuffer += uNormalStride;
}
pBuffer = pIndices;
switch(Type)
{
case D3DPT_TRIANGLESTRIP:
memcpy(&uIndex1, pBuffer, uIndexStride);
pBuffer += uIndexStride;
memcpy(&uIndex0, pBuffer, uIndexStride);
pBuffer += uIndexStride;
for(i = 0; i < uNumFaces; i ++)
{
if(i & 0x1)
{
SWAP(uIndex1, uIndex2, uIndex);
uIndex0 = 0;
memcpy(&uIndex0, pBuffer, uIndexStride);
pBuffer += uIndexStride;
}
else
{
SWAP(uIndex0, uIndex1, uIndex);
uIndex2 = 0;
memcpy(&uIndex2, pBuffer, uIndexStride);
pBuffer += uIndexStride;
}
pVertex0 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex0 + uPositionOffset);
pVertex1 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex1 + uPositionOffset);
pVertex2 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex2 + uPositionOffset);
D3DXVec3Cross( &Normal, &(*pVertex0 - *pVertex2), &(*pVertex1 - *pVertex0) );
D3DXVec3Normalize(&Normal, &Normal);
pVertex0 = (LPD3DXVECTOR3)(pNormal + uNormalStride * uIndex0 + uNormalOffset);
pVertex1 = (LPD3DXVECTOR3)(pNormal + uNormalStride * uIndex1 + uNormalOffset);
pVertex2 = (LPD3DXVECTOR3)(pNormal + uNormalStride * uIndex2 + uNormalOffset);
(*pVertex0) += Normal;
(*pVertex1) += Normal;
(*pVertex2) += Normal;
}
break;
case D3DPT_TRIANGLEFAN:
memcpy(&uIndex0, pBuffer, uIndexStride);
pBuffer += uIndexStride;
for(i = 0; i < uNumFaces; i ++)
{
uIndex1 = 0;
memcpy(&uIndex1, pBuffer, uIndexStride);
pBuffer += uIndexStride;
uIndex2 = 0;
memcpy(&uIndex2, pBuffer, uIndexStride);
pBuffer += uIndexStride;
pVertex0 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex0 + uPositionOffset);
pVertex1 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex1 + uPositionOffset);
pVertex2 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex2 + uPositionOffset);
D3DXVec3Cross( &Normal, &(*pVertex0 - *pVertex1), &(*pVertex2 - *pVertex0) );
D3DXVec3Normalize(&Normal, &Normal);
pVertex0 = (LPD3DXVECTOR3)(pNormal + uNormalStride * uIndex0 + uNormalOffset);
pVertex1 = (LPD3DXVECTOR3)(pNormal + uNormalStride * uIndex1 + uNormalOffset);
pVertex2 = (LPD3DXVECTOR3)(pNormal + uNormalStride * uIndex2 + uNormalOffset);
(*pVertex0) += Normal;
(*pVertex1) += Normal;
(*pVertex2) += Normal;
}
break;
default:
for(i = 0; i < uNumFaces; i ++)
{
uIndex0 = 0;
memcpy(&uIndex0, pBuffer, uIndexStride);
pBuffer += uIndexStride;
uIndex1 = 0;
memcpy(&uIndex1, pBuffer, uIndexStride);
pBuffer += uIndexStride;
uIndex2 = 0;
memcpy(&uIndex2, pBuffer, uIndexStride);
pBuffer += uIndexStride;
pVertex0 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex0 + uPositionOffset);
pVertex1 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex1 + uPositionOffset);
pVertex2 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex2 + uPositionOffset);
D3DXVec3Cross( &Normal, &(*pVertex0 - *pVertex2), &(*pVertex1 - *pVertex0) );
D3DXVec3Normalize(&Normal, &Normal);
pVertex0 = (LPD3DXVECTOR3)(pNormal + uNormalStride * uIndex0 + uNormalOffset);
pVertex1 = (LPD3DXVECTOR3)(pNormal + uNormalStride * uIndex1 + uNormalOffset);
pVertex2 = (LPD3DXVECTOR3)(pNormal + uNormalStride * uIndex2 + uNormalOffset);
(*pVertex0) += Normal;
(*pVertex1) += Normal;
(*pVertex2) += Normal;
}
break;
}
pBuffer = pNormal + uNormalOffset;
for(i = 0; i < uNumVertices; i ++)
{
D3DXVec3Normalize( (D3DXVECTOR3*)pBuffer, (D3DXVECTOR3*)pBuffer );
pBuffer += uNormalStride;
}
return true;
}
bool zerO::ComputeMeshTangent(
UINT uNumVertices, UINT uNumIndices,
void* pIndicesStream , UINT uIndexStride , D3DPRIMITIVETYPE Type,
void* pPositionStream, UINT uPositionStride, UINT uPositionOffset ,
void* pUVStream , UINT uUVStride , UINT uUVOffset ,
void* pTangentStream , UINT uTangentStride , UINT uTangentOffset ,
void* pNormalStream , UINT uNormalStride , UINT uNormalOffset ,
void* pBinormalStream, UINT uBinormalStride, UINT uBinormalOffset)
{
LPD3DXVECTOR3 pVertex0, pVertex1, pVertex2;
LPD3DXVECTOR2 pUV0, pUV1, pUV2;
D3DXVECTOR3 Tangent, Edge0, Edge1;
D3DXVECTOR2 UV0, UV1;
FLOAT fComponent, fInvertComponent;
PUINT8 pBuffer, pIndices = (PUINT8)pIndicesStream, pPosition = (PUINT8)pPositionStream, pUV = (PUINT8)pUVStream, pTangent = (PUINT8)pTangentStream;//, pNormal = (PUINT8)pNormalStream, pBinormal = (PUINT8)pBinormalStream;
UINT i, uIndex0 = 0, uIndex1 = 0, uIndex2 = 0, uIndex = 0, uNumFaces = GetPrimitiveCount(Type, uNumIndices);
pBuffer = pTangent + uTangentOffset;
for(i = 0; i < uNumVertices; i ++)
{
memset( pBuffer, 0, sizeof(D3DXVECTOR3) );
pBuffer += uTangentStride;
}
pBuffer = pIndices;
switch(Type)
{
case D3DPT_TRIANGLESTRIP:
memcpy(&uIndex1, pBuffer, uIndexStride);
pBuffer += uIndexStride;
memcpy(&uIndex0, pBuffer, uIndexStride);
pBuffer += uIndexStride;
for(i = 0; i < uNumFaces; i ++)
{
if(i & 0x1)
{
SWAP(uIndex1, uIndex2, uIndex);
uIndex0 = 0;
memcpy(&uIndex0, pBuffer, uIndexStride);
pBuffer += uIndexStride;
}
else
{
SWAP(uIndex0, uIndex1, uIndex);
uIndex2 = 0;
memcpy(&uIndex2, pBuffer, uIndexStride);
pBuffer += uIndexStride;
}
pVertex0 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex0 + uPositionOffset);
pVertex1 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex1 + uPositionOffset);
pVertex2 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex2 + uPositionOffset);
pUV0 = (LPD3DXVECTOR2)(pUV + uUVStride * uIndex0 + uUVOffset );
pUV1 = (LPD3DXVECTOR2)(pUV + uUVStride * uIndex1 + uUVOffset );
pUV2 = (LPD3DXVECTOR2)(pUV + uUVStride * uIndex2 + uUVOffset );
Edge0 = *pVertex1 - *pVertex0;
Edge1 = *pVertex2 - *pVertex0;
UV0 = *pUV1 - *pUV0;
UV1 = *pUV2 - *pUV0;
fComponent = D3DXVec2CCW(&UV1, &UV0);
if(fComponent)
{
fInvertComponent = 1.0f / fComponent;
Tangent = (Edge0 * - UV1.y + Edge1 * UV0.y) * fInvertComponent;
D3DXVec3Normalize(&Tangent, &Tangent);
pVertex0 = (LPD3DXVECTOR3)(pTangent + uTangentStride * uIndex0 + uTangentOffset);
pVertex1 = (LPD3DXVECTOR3)(pTangent + uTangentStride * uIndex1 + uTangentOffset);
pVertex2 = (LPD3DXVECTOR3)(pTangent + uTangentStride * uIndex2 + uTangentOffset);
(*pVertex0) += Tangent;
(*pVertex1) += Tangent;
(*pVertex2) += Tangent;
}
}
break;
case D3DPT_TRIANGLEFAN:
memcpy(&uIndex0, pBuffer, uIndexStride);
pBuffer += uIndexStride;
for(i = 0; i < uNumFaces; i ++)
{
uIndex1 = 0;
memcpy(&uIndex1, pBuffer, uIndexStride);
pBuffer += uIndexStride;
uIndex2 = 0;
memcpy(&uIndex2, pBuffer, uIndexStride);
pBuffer += uIndexStride;
pVertex0 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex0 + uPositionOffset);
pVertex1 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex1 + uPositionOffset);
pVertex2 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex2 + uPositionOffset);
pUV0 = (LPD3DXVECTOR2)(pUV + uUVStride * uIndex0 + uUVOffset );
pUV1 = (LPD3DXVECTOR2)(pUV + uUVStride * uIndex1 + uUVOffset );
pUV2 = (LPD3DXVECTOR2)(pUV + uUVStride * uIndex2 + uUVOffset );
Edge0 = *pVertex1 - *pVertex0;
Edge1 = *pVertex2 - *pVertex0;
UV0 = *pUV1 - *pUV0;
UV1 = *pUV2 - *pUV0;
fComponent = D3DXVec2CCW(&UV1, &UV0);
if(fComponent)
{
fInvertComponent = 1.0f / fComponent;
Tangent = (Edge0 * - UV1.y + Edge1 * UV0.y) * fInvertComponent;
D3DXVec3Normalize(&Tangent, &Tangent);
pVertex0 = (LPD3DXVECTOR3)(pTangent + uTangentStride * uIndex0 + uTangentOffset);
pVertex1 = (LPD3DXVECTOR3)(pTangent + uTangentStride * uIndex1 + uTangentOffset);
pVertex2 = (LPD3DXVECTOR3)(pTangent + uTangentStride * uIndex2 + uTangentOffset);
(*pVertex0) += Tangent;
(*pVertex1) += Tangent;
(*pVertex2) += Tangent;
}
}
break;
default:
for(i = 0; i < uNumFaces; i ++)
{
uIndex0 = 0;
memcpy(&uIndex0, pBuffer, uIndexStride);
pBuffer += uIndexStride;
uIndex1 = 0;
memcpy(&uIndex1, pBuffer, uIndexStride);
pBuffer += uIndexStride;
uIndex2 = 0;
memcpy(&uIndex2, pBuffer, uIndexStride);
pBuffer += uIndexStride;
pVertex0 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex0 + uPositionOffset);
pVertex1 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex1 + uPositionOffset);
pVertex2 = (LPD3DXVECTOR3)(pPosition + uPositionStride * uIndex2 + uPositionOffset);
pUV0 = (LPD3DXVECTOR2)(pUV + uUVStride * uIndex0 + uUVOffset );
pUV1 = (LPD3DXVECTOR2)(pUV + uUVStride * uIndex1 + uUVOffset );
pUV2 = (LPD3DXVECTOR2)(pUV + uUVStride * uIndex2 + uUVOffset );
Edge0 = *pVertex1 - *pVertex0;
Edge1 = *pVertex2 - *pVertex0;
UV0 = *pUV1 - *pUV0;
UV1 = *pUV2 - *pUV0;
fComponent = D3DXVec2CCW(&UV1, &UV0);
if(fComponent)
{
fInvertComponent = 1.0f / fComponent;
Tangent = (Edge0 * - UV1.y + Edge1 * UV0.y) * fInvertComponent;
D3DXVec3Normalize(&Tangent, &Tangent);
pVertex0 = (LPD3DXVECTOR3)(pTangent + uTangentStride * uIndex0 + uTangentOffset);
pVertex1 = (LPD3DXVECTOR3)(pTangent + uTangentStride * uIndex1 + uTangentOffset);
pVertex2 = (LPD3DXVECTOR3)(pTangent + uTangentStride * uIndex2 + uTangentOffset);
(*pVertex0) += Tangent;
(*pVertex1) += Tangent;
(*pVertex2) += Tangent;
}
}
break;
}
pBuffer = pTangent + uTangentOffset;
if(pNormalStream)
{
PUINT8 pNormalBuffer = (PUINT8)pNormalStream + uNormalOffset;
if(pBinormalStream)
{
PUINT8 pBinormalBuffer = (PUINT8)pBinormalStream + uBinormalOffset;
for(i = 0; i < uNumVertices; i ++)
{
const D3DXVECTOR3& TANGENT = *(LPD3DXVECTOR3)pBuffer;
const D3DXVECTOR3& NORMAL = *(LPD3DXVECTOR3)pNormalBuffer;
D3DXVec3Normalize( &Tangent, &( TANGENT - NORMAL * D3DXVec3Dot(&TANGENT, &NORMAL) ) );
D3DXVec3Normalize( (D3DXVECTOR3*)pBinormalBuffer, D3DXVec3Cross( (D3DXVECTOR3*)pBinormalBuffer, &Tangent, &NORMAL ) );
*(LPD3DXVECTOR3)pBuffer = Tangent;
pBuffer += uTangentStride;
pNormalBuffer += uNormalStride;
pBinormalBuffer += uBinormalStride;
}
}
else
{
for(i = 0; i < uNumVertices; i ++)
{
const D3DXVECTOR3& TANGENT = *(LPD3DXVECTOR3)pBuffer;
const D3DXVECTOR3& NORMAL = *(LPD3DXVECTOR3)pNormalBuffer;
D3DXVec3Normalize( (D3DXVECTOR3*)pBuffer, &( TANGENT - NORMAL * D3DXVec3Dot(&TANGENT, &NORMAL) ) );
pBuffer += uTangentStride;
pNormalBuffer += uNormalStride;
}
}
}
else
{
for(i = 0; i < uNumVertices; i ++)
{
D3DXVec3Normalize( (D3DXVECTOR3*)pBuffer, (D3DXVECTOR3*)pBuffer );
pBuffer += uTangentStride;
}
}
return true;
} |
7493ec2d0f5432f1e1383b6b86191b735ad54da4 | 4d4c880d587af089410aae114c93acaf4ff34ae2 | /src/interface/TWAnySigner.cpp | 2aab0fd9df06dcf32c440b0160cb215491cbb9a3 | [
"MIT"
] | permissive | kudryavchik/wallet-core | a2bc6d33235f858223dc632ea8712433b634337e | cfbde7b4497e1f2e24c2360295c5052ddc5862c2 | refs/heads/master | 2020-09-29T06:45:47.625228 | 2019-12-08T22:22:54 | 2019-12-08T22:22:54 | 226,979,149 | 2 | 0 | MIT | 2019-12-09T22:21:15 | 2019-12-09T22:21:14 | null | UTF-8 | C++ | false | false | 1,523 | cpp | TWAnySigner.cpp | // Copyright ยฉ 2017-2019 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#include <TrustWalletCore/TWAnySigner.h>
#include "Any/Signer.h"
using namespace TW;
using namespace TW::Any;
TW_Any_Proto_SigningOutput TWAnySignerSign(TW_Any_Proto_SigningInput data)
{
Proto::SigningInput input;
input.ParseFromArray(TWDataBytes(data), static_cast<int>(TWDataSize(data)));
auto signer = new TWAnySigner{ Signer(input) };
Proto::SigningOutput output = signer->impl.sign();
auto serialized = output.SerializeAsString();
return TWDataCreateWithBytes(reinterpret_cast<const uint8_t *>(serialized.data()), serialized.size());
}
bool TWAnySignerIsSignEnabled(enum TWCoinType coinType)
{
Proto::SigningInput input;
input.set_coin_type(coinType);
input.set_private_key("0000000000000000000000000000000000000000000000000000000000000001");
input.set_transaction("<invalid json>");
auto signer = new TWAnySigner{ Signer(input) };
Proto::SigningOutput output = signer->impl.sign();
// If the coin is not supported, the error code is SignerErrorCodeNotSupported.
// If the sign method return an SignerErrorCodeInvalidJson, it means the coin is
// supported but couldn't parse the transaction (which is invalid by default)
return output.error().code() == SignerErrorCodeInvalidJson;
}
|
ae0d42e01479b3b79cfdc924801ed35c6a14f73a | 2ef0b8d082d16426edd4bb03204a805dfc52e626 | /mt-kahypar/datastructures/array.h | aedecd65c20c56afeaa58ae08e972474c40e51f4 | [
"MIT"
] | permissive | kahypar/mt-kahypar | 1a0e0980cd60d6951c5562fcbfaab70d622cf1da | 858c9f0e1123d75c47de142edd49f4662be1d8d1 | refs/heads/master | 2023-09-03T21:31:24.741019 | 2023-08-23T08:51:04 | 2023-08-23T08:51:04 | 205,879,380 | 76 | 18 | MIT | 2023-09-13T13:12:28 | 2019-09-02T14:54:18 | C++ | UTF-8 | C++ | false | false | 13,405 | h | array.h | /*******************************************************************************
* MIT License
*
* This file is part of Mt-KaHyPar.
*
* Copyright (C) 2019 Lars Gottesbรผren <lars.gottesbueren@kit.edu>
* Copyright (C) 2019 Tobias Heuer <tobias.heuer@kit.edu>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
#pragma once
#include <thread>
#include <memory>
#include <iterator>
#include "tbb/parallel_for.h"
#include "tbb/scalable_allocator.h"
#include "tbb//parallel_invoke.h"
#include "mt-kahypar/macros.h"
#include "mt-kahypar/parallel/memory_pool.h"
#include "mt-kahypar/parallel/stl/scalable_unique_ptr.h"
#include "mt-kahypar/utils/exception.h"
namespace mt_kahypar {
namespace ds {
template <typename T>
class Array {
class ArrayIterator {
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = T;
using reference = T&;
using pointer = T*;
using difference_type = std::ptrdiff_t;
ArrayIterator() : _ptr(nullptr) { }
ArrayIterator(T* ptr) : _ptr(ptr) { }
ArrayIterator(const ArrayIterator& other) : _ptr(other._ptr) { }
reference operator*() const {
return *_ptr;
}
pointer operator->() const {
return _ptr;
}
ArrayIterator& operator++() {
++_ptr;
return *this;
}
ArrayIterator& operator--() {
--_ptr;
return *this;
}
ArrayIterator operator++(int) {
ArrayIterator tmp_it(_ptr);
++_ptr;
return tmp_it;
}
ArrayIterator operator--(int) {
ArrayIterator tmp_it(_ptr);
--_ptr;
return tmp_it;
}
ArrayIterator operator+(const difference_type& n) const {
return ArrayIterator(_ptr + n);
}
ArrayIterator& operator+=(const difference_type& n) {
_ptr += n;
return *this;
}
ArrayIterator operator-(const difference_type& n) const {
return ArrayIterator(_ptr - n);
}
ArrayIterator& operator-=(const difference_type& n) {
_ptr -= n;
return *this;
}
reference operator[](const difference_type& n) const {
return *_ptr[n];
}
bool operator==(const ArrayIterator& other) const {
return _ptr == other._ptr;
}
bool operator!=(const ArrayIterator& other) const {
return _ptr != other._ptr;
}
bool operator<(const ArrayIterator& other) const {
return _ptr < other._ptr;
}
bool operator>(const ArrayIterator& other) const {
return _ptr > other._ptr;
}
bool operator<=(const ArrayIterator& other) const {
return _ptr <= other._ptr;
}
bool operator>=(const ArrayIterator& other) const {
return _ptr >= other._ptr;
}
difference_type operator+(const ArrayIterator& other) const {
return ( _ptr + other._ptr );
}
difference_type operator-(const ArrayIterator& other) const {
return (_ptr - other._ptr);
}
private:
T* _ptr;
};
public:
// Type Traits
using value_type = T;
using size_type = size_t;
using reference = T&;
using const_reference = const T&;
using iterator = ArrayIterator;
using const_iterator = const ArrayIterator;
Array() :
_group(""),
_key(""),
_size(0),
_data(nullptr),
_underlying_data(nullptr) { }
Array(const size_type size,
const value_type init_value = value_type()) :
_group(""),
_key(""),
_size(0),
_data(nullptr),
_underlying_data(nullptr) {
resize(size, init_value);
}
Array(const std::string& group,
const std::string& key,
const size_type size,
const bool zero_initialize = false,
const bool assign_parallel = true) :
_group(""),
_key(""),
_size(size),
_data(nullptr),
_underlying_data(nullptr) {
resize(group, key, size, zero_initialize, assign_parallel);
}
Array(const Array&) = delete;
Array & operator= (const Array &) = delete;
Array(Array&& other) :
_group(std::move(other._group)),
_key(std::move(other._key)),
_size(other._size),
_data(std::move(other._data)),
_underlying_data(std::move(other._underlying_data)) {
other._size = 0;
other._data = nullptr;
other._underlying_data = nullptr;
}
Array & operator=(Array&& other) {
_group = std::move(other._group);
_key = std::move(other._key);
_size = other._size;
_data = std::move(other._data);
_underlying_data = std::move(other._underlying_data);
other._size = 0;
other._data = nullptr;
other._underlying_data = nullptr;
return *this;
}
~Array() {
if ( !_data && _underlying_data && !_group.empty() && !_key.empty() ) {
// Memory was allocated from memory pool
// => Release Memory
parallel::MemoryPool::instance().release_mem_chunk(_group, _key);
}
}
// ####################### Access Operators #######################
// ! Returns a reference to the element at specified location pos
reference operator[](const size_type pos) {
ASSERT(pos < _size);
return _underlying_data[pos];
}
// ! Returns a reference to the element at specified location pos
const_reference operator[](const size_type pos) const {
ASSERT(pos < _size);
return _underlying_data[pos];
}
reference back() {
ASSERT(_underlying_data && _size > 0);
return _underlying_data[_size - 1];
}
const_reference back() const {
ASSERT(_underlying_data && _size > 0);
return _underlying_data[_size - 1];
}
value_type* data() {
ASSERT(_underlying_data);
return _underlying_data;
}
const value_type* data() const {
ASSERT(_underlying_data);
return _underlying_data;
}
// ####################### Iterators #######################
iterator begin() {
ASSERT(_underlying_data);
return iterator(_underlying_data);
}
const_iterator cbegin() const {
ASSERT(_underlying_data);
return const_iterator(_underlying_data);
}
iterator end() {
ASSERT(_underlying_data);
return iterator(_underlying_data + _size);
}
const_iterator cend() const {
ASSERT(_underlying_data);
return const_iterator(_underlying_data + _size);
}
// ####################### Capacity #######################
bool empty() const {
return _size == 0;
}
size_type size() const {
return _size;
}
// ####################### Initialization #######################
void resize(const size_type size,
const value_type init_value = value_type(),
const bool assign_parallel = true) {
if ( _data || _underlying_data ) {
throw SystemException("Memory of vector already allocated");
}
allocate_data(size);
assign(size, init_value, assign_parallel);
}
void resize(const std::string& group,
const std::string& key,
const size_type size,
const bool zero_initialize = false,
const bool assign_parallel = true) {
_size = size;
char* data = parallel::MemoryPool::instance().request_mem_chunk(
group, key, size, sizeof(value_type));
if ( data ) {
_group = group;
_key = key;
_underlying_data = reinterpret_cast<value_type*>(data);
if ( zero_initialize ) {
assign(size, value_type(), assign_parallel);
}
} else {
resize_with_unused_memory(size, zero_initialize, assign_parallel);
}
}
void resize_with_unused_memory(const size_type size,
const bool zero_initialize = false,
const bool assign_parallel = true) {
_size = size;
char* data = parallel::MemoryPool::instance().request_unused_mem_chunk(size, sizeof(value_type));
if ( data ) {
_underlying_data = reinterpret_cast<value_type*>(data);
if ( zero_initialize ) {
assign(size, value_type(), assign_parallel);
}
} else {
resize(size, value_type(), assign_parallel);
}
}
// ! Replaces the contents of the container
void assign(const size_type count,
const value_type value,
const bool assign_parallel = true) {
if ( _underlying_data ) {
ASSERT(count <= _size);
if ( assign_parallel ) {
const size_t step = std::max(count / std::thread::hardware_concurrency(), UL(1));
tbb::parallel_for(UL(0), count, step, [&](const size_type i) {
for ( size_t j = i; j < std::min(i + step, count); ++j ) {
_underlying_data[j] = value;
}
});
} else {
for ( size_t i = 0; i < count; ++i ) {
_underlying_data[i] = value;
}
}
} else {
resize(count, value, assign_parallel);
}
}
private:
void allocate_data(const size_type size) {
_data = parallel::make_unique<value_type>(size);
_underlying_data = _data.get();
_size = size;
}
std::string _group;
std::string _key;
size_type _size;
parallel::tbb_unique_ptr<value_type> _data;
value_type* _underlying_data;
};
} // namespace ds
namespace parallel {
template<typename T>
static inline void free(ds::Array<T>& vec) {
ds::Array<T> tmp_vec;
vec = std::move(tmp_vec);
}
template<typename T1,
typename T2>
MT_KAHYPAR_ATTRIBUTE_ALWAYS_INLINE static void parallel_free(ds::Array<T1>& vec1,
ds::Array<T2>& vec2) {
tbb::parallel_invoke([&] {
free(vec1);
}, [&] {
free(vec2);
});
}
template<typename T1,
typename T2,
typename T3>
MT_KAHYPAR_ATTRIBUTE_ALWAYS_INLINE static void parallel_free(ds::Array<T1>& vec1,
ds::Array<T2>& vec2,
ds::Array<T3>& vec3) {
tbb::parallel_invoke([&] {
free(vec1);
}, [&] {
free(vec2);
}, [&] {
free(vec3);
});
}
template<typename T1,
typename T2,
typename T3,
typename T4>
MT_KAHYPAR_ATTRIBUTE_ALWAYS_INLINE static void parallel_free(ds::Array<T1>& vec1,
ds::Array<T2>& vec2,
ds::Array<T3>& vec3,
ds::Array<T4>& vec4) {
tbb::parallel_invoke([&] {
free(vec1);
}, [&] {
free(vec2);
}, [&] {
free(vec3);
}, [&] {
free(vec4);
});
}
template<typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
MT_KAHYPAR_ATTRIBUTE_ALWAYS_INLINE static void parallel_free(ds::Array<T1>& vec1,
ds::Array<T2>& vec2,
ds::Array<T3>& vec3,
ds::Array<T4>& vec4,
ds::Array<T5>& vec5) {
tbb::parallel_invoke([&] {
free(vec1);
}, [&] {
free(vec2);
}, [&] {
free(vec3);
}, [&] {
free(vec4);
}, [&] {
free(vec5);
});
}
template<typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
MT_KAHYPAR_ATTRIBUTE_ALWAYS_INLINE static void parallel_free(ds::Array<T1>& vec1,
ds::Array<T2>& vec2,
ds::Array<T3>& vec3,
ds::Array<T4>& vec4,
ds::Array<T5>& vec5,
ds::Array<T6>& vec6) {
tbb::parallel_invoke([&] {
free(vec1);
}, [&] {
free(vec2);
}, [&] {
free(vec3);
}, [&] {
free(vec4);
}, [&] {
free(vec5);
}, [&] {
free(vec6);
});
}
}
} // namespace mt_kahypar |
d7a694473893243eee9b8dd1cd95f5f93e29d849 | 0af6a4592d013e4b563e25a58f62f4cf77a74a2c | /adrenosdk-linux/Development/Samples/Framework/Model/FrmVertexBuffer.cpp | 9f6c306046a49ee670499de1d435018317a7e498 | [] | no_license | sunzhiyuan/opencl | b03f8deb4034f254245d6d40b6cd06acbb89d1bd | 9e0e9a46b4ec1e336eecd4f4d167f69e04b26dbc | refs/heads/master | 2016-09-10T02:08:07.636786 | 2014-12-12T05:12:39 | 2014-12-12T10:41:43 | 27,906,253 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,135 | cpp | FrmVertexBuffer.cpp | //-----------------------------------------------------------------------------
//
// VertexBuffer
//
// Copyright (c) 2011 QUALCOMM Incorporated.
// All Rights Reserved. QUALCOMM Proprietary/GTDR
//
//-----------------------------------------------------------------------------
#include "FrmVertexBuffer.h"
//-----------------------------------------------------------------------------
Adreno::VertexBuffer::VertexBuffer()
: Format()
, NumVerts( 0 )
, BufferSize( 0 )
, Buffer( NULL )
{
}
//-----------------------------------------------------------------------------
Adreno::VertexBuffer::~VertexBuffer()
{
if( Buffer )
{
delete[] Buffer;
Buffer = NULL;
}
}
//-----------------------------------------------------------------------------
void Adreno::VertexBuffer::IntializeBuffer( UINT32 num_verts )
{
if( Buffer )
{
delete[] Buffer;
Buffer = NULL;
}
NumVerts = num_verts;
INT32 vertex_stride = Format.Stride;
BufferSize = num_verts * vertex_stride;
if( BufferSize > 0 )
{
Buffer = new UINT8[ BufferSize ];
}
}
|
2ee479b558e7c3cf4bc4a5916a5e1bf69b8584e7 | 624a105dbe52630ac0cb123e69c0ace95fe9d34b | /1st semester/hw07/02/main.cpp | 207a3894d157acc0a1d6add24eee9c8e51cd774b | [] | no_license | Axroy/SPbSU_study | f6769618d5ca4279a1a8a6cf1c90f0153461e948 | 6bd43d1b3e4105f898d1960f823b44595be020f9 | refs/heads/master | 2020-12-25T17:03:59.820392 | 2016-06-01T14:33:10 | 2016-06-01T14:33:10 | 30,873,932 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 995 | cpp | main.cpp | #include <stdio.h>
#include "line.h"
int main()
{
//char array[3] = {'a', 'b', 'c'};
char array2[5] = {'e', 'd', 'c', 'b', 'a'};
Line *test = createLine();
Line *test2 = createLine(50);
Line *test4 = createLine(3, "abc");
Line *test5 = createLine(5, array2);
printLine(test4);
printLine(test5);
//deleteLine(test);
concat(test5, test4);
printLine(test4);
printf("%d\n\n", lineLength(test4));
Line *test3 = clone(test4);
printf("%d\n\n", areEqual(test3, test4));
printf("%d\n", isEmpty(test));
printf("%d\n\n", isEmpty(test2));
int length = lineLength(test);
printf("%d\n\n", length);
Line *test6 = copy(test3, 4, 4);
printLine(test6);
printf("%d\n\n", lineLength(test6));
char *testSymbols = getSymbols(test3);
for (int i = 0; i < 8; i++)
printf("%c", testSymbols[i]);
delete[] testSymbols;
printf("\n\n");
addLength(test6, 5);
printLine(test6);
return 0;
}
|
60043fbc34c08dd0df74578c809f020fbf672b5c | 469100067213102f9942bc375ffb74c098cc0337 | /hdu/5349/main.cpp | bee3061cef09e69be73809a9f4430258343f7279 | [] | no_license | xuziye0327/acm | 52c2dc245ad8bf5a684da677a0ebe57e0b4f8a59 | e0737fdbbebc698e2f36e3136c8939729cad50b9 | refs/heads/master | 2021-04-22T12:59:31.525803 | 2016-11-13T08:44:23 | 2016-11-13T08:44:23 | 41,278,480 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 491 | cpp | main.cpp | #include <cstdio>
#include <set>
using namespace std;
int main() {
multiset<int> m;
int n;
scanf("%d", &n);
while(n--) {
int x, cmd;
scanf("%d", &cmd);
if(cmd == 1) {
scanf("%d", &x);
m.insert(x);
} else if(cmd == 2) {
if(!m.empty())
m.erase(m.begin());
} else {
if(m.empty()) printf("0\n");
else printf("%d\n", *m.rbegin());
}
}
return 0;
} |
6166e8b1cf7f78bec41066e8f15b499307d605a9 | db92214392a7f20a8a7c9713cd9e8ba4b2d94c7a | /algorithm/isMatch.cpp | ac803134b3895107059e6c1b89d1e4b282de74d9 | [] | no_license | SoftwareKiller/ubuntu | fd2af7be1738bdbdccd38a58c7f17b340f618363 | 6bf390fc8d8c3efc17a7db3331d5f5405abd05bf | refs/heads/master | 2022-01-29T23:26:56.528101 | 2022-01-11T08:38:03 | 2022-01-11T08:38:03 | 137,650,835 | 1 | 0 | null | 2020-12-16T15:21:42 | 2018-06-17T11:42:35 | C++ | UTF-8 | C++ | false | false | 4,761 | cpp | isMatch.cpp | #include <cstring>
#include <iostream>
#include <string>
#include <vector>
/*
* ๆญฃๅ่กจ่พพๅผๅน้
.*ไธคไธช็ฌฆๅท
* */
using namespace std;
/*
* ็จ็ถๆๆบๅคชๅคๆ๏ผ่งฃ้ขๅคฑ่ดฅ๏ผ่ฟๆฏๅพๅจๆ่งๅ
* */
bool isMatch_(string s, string p)
{
int m = s.length();
int n = p.length();
int i = 0, j = 0;
char star = '*', point = '.';
enum STATUS{
MATCH_ONE,
MATCH_ALL,
NOT_MATCH
};
STATUS status = NOT_MATCH;
pair<STATUS, char> match_char{NOT_MATCH, ' '};
while(i < m && j < n)
{
if(s[i] == p[j] || p[j] == point)
{
++i, ++j;
match_char.first = MATCH_ONE;
match_char.second = s[i];
continue;
}
if(s[i] == match_char.second && p[j] == star)
{
++i;
match_char.first = MATCH_ALL;
continue;
}
else if(p[j] == star)
{
++j;
match_char.first = NOT_MATCH;
match_char.second = ' ';
continue;
}
}
if(i < m)
return false;
return true;
}
void printResult(bool flag)
{
if(flag)
cout << "true" << endl;
else
cout << "false" << endl;
}
//ๅฎๆน็ๆฌ
bool _isMatch(string s, string p)
{
int m = s.length();
int n = p.length();
auto matchs = [&](int i, int j)
{
if(i == 0)
return false;
if(p[j - 1] == '.')
return true;
return s[i - 1] == p[j - 1];
};
vector<vector<int>> dp(m + 1, vector<int>(n + 1));
dp[0][0] = true;
for(int i = 0; i <= m; ++i)
{
for(int j = 1; j <= n; ++j)
{
if(p[j - 1] == '*')
{
//่ฟๆฏไธบไบaab, aabc*่ฟ็งๆ
ๅต๏ผtrue
dp[i][j] |= dp[i][j - 2];
if(matchs(i, j - 1))
{
dp[i][j] |= dp[i - 1][j];
}
}
else
{
if(matchs(i, j))
{
dp[i][j] |= dp[i - 1][j - 1];
}
}
}
}
return dp[m][n];
}
//ไธไธช็จๅพฎๅฅฝ็่งฃไธ็น็น็็ๆฌ
//
/*
* dp[i][j]่กจ็คบs็ๅiไธชๆฏๅฆ่ฝ่ขซp็ๅjไธชๅน้
* 1.ๆ็ฎๅ็ๆ่ทฏ๏ผๅ้ข็ๅฎๅ
จๅน้
๏ผๅdp[i][j]ๅน้
* dp[i][j] = dp[i-1][j-1]
* 2.ไฝๆฏp[j]ๅฏ่ฝ็ญไบ"."ๅ"*"๏ผ่ฟๆๅ็ง็ฌฆๅท
* 2.1 p[j] == '.'
* dp[i][j] == dp[i-1][j-1]
* 2.2 p[j] == '*'
* ๅๅ
ฅๆ
ๅต3่ฎจ่ฎบ
*
* 3.'*'็ๆๆๆฏๅน้
*ๅท็ๅไธไธชๅญ็ฌฆ๏ผๆฐ้้ถไธชๅฐๅคไธช้ฝๅฏ๏ผๆณจๆๆฏ้ถไธช
* 3.1 '*'ๅทๅๆฏ้ถไธชๅน้
๏ผabc ๅ abcd*ๆฏๅน้
็๏ผๆ้ถไธชd
* dp[i][j] = dp[i][j-2]
* 3.2 '*'ๅทๅๆไธไธชๅน้
* dp[i][j] = dp[i][j-1]
* 3.3 '*'ๅทๅๆๅคไธชๅน้
* dp[i][j] = dp[i-1][j]
* */
bool isMatch(string s, string p)
{
s = " " + s;
p = " " + p;
int m = s.size(), n = p.size();
bool dp[m + 1][n + 1];
memset(dp, false, (m+1)*(n+1));
dp[0][0] = true; //ๆๅฐๅญ้ไธบ็๏ผๅ ไธบ้ฝๆฏspace
for(int i = 1; i <= m; ++i)
{
for(int j = 1; j <=n; ++j)
{
//ๅฏนๅบๆ
ๅต1ๅ2.1
if(s[i - 1] == p[j - 1] || p[j - 1] == '.')
{
dp[i][j] = dp[i-1][j-1];
}
else if(p[j - 1] == '*') //ๅฏนๅบๆ
ๅต3
{
if(s[i - 1] != p[j - 2] && p[j - 2] != '.')
{
//ๅค็ๅฆ๏ผaabๅc*a*b
dp[i][j] = dp[i][j - 2];
}
else
{
//ๅฏนๅบๆ
ๅต3.1----3.3
dp[i][j] = dp[i][j - 1] || dp[i][j - 2] || dp[i - 1][j];
}
}
}
}
return dp[m][n];
}
bool isMatch2(string s, string p)
{
s = " " + s;
p = " " + p;
int m = s.length(), n = p.length();
vector<vector<bool>> dp(m+1, vector<bool>(n+1, false));
dp[0][0] = true;
for(int i = 1; i <= m; ++i)
{
for(int j = 1; j <= n; ++j)
{
if(s[i-1] == p[j-1] || p[j-1] == '?' )
dp[i][j] = dp[i-1][j-1];
else if(p[j-1] == '*')
{
//dp[i-1][j]่กจ็คบไธบ็ฉบไธฒ
dp[i][j] = dp[i-1][j] || dp[i][j-1];
}
}
}
return dp[m][n];
}
int main()
{
string s{""};
string p{"*"};
printResult(isMatch2(s, p));
s = "adceb";
p = "a*b";
printResult(isMatch2(s, p));
s = "aaaa";
p = "a";
printResult(isMatch2(s, p));
s = "cb";
p = "?a";
printResult(isMatch2(s, p));
s = "acdcb";
p = "a*c?b";
printResult(isMatch2(s, p));
}
|
af53d6a1c317e87cdb1a5824d2850ec1202a76ce | 43083741d5eb9bc75e5bcafe5696bbfc0d79ef92 | /A/colorful_stones.cpp | 4b52425159005f75f1d580a2aff1a20f1c73b487 | [] | no_license | shubhamamsa/Code-Forces | bf6bdb57ef801bfe48aa218e60dd2beaa0997aa7 | e45dbf4c70ae10abfd6960cffccd2d4242b695ac | refs/heads/master | 2021-12-23T22:25:07.588221 | 2021-09-28T14:14:44 | 2021-09-28T14:14:44 | 187,487,958 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 255 | cpp | colorful_stones.cpp | #include<iostream>
using namespace std;
int main() {
string s, t;
getline(cin, s);
getline(cin, t);
int k=0;
for(int i=0;i<t.size();i++) {
if(t[i] == s[k])
k++;
}
cout << k+1 << endl;
return 0;
} |
96f143ca2049da9598fd94d4f05e85d75ae9de7e | 508efd553572f28ebeb93bac77d913b514094256 | /codeforces/222A.cpp | 73f33ac62012a7f2f7c54aed2db8c05befc8112c | [] | no_license | pimukthee/competitive-prog | 4eaa917c27ddd02c8e4ff56502fa53eb7f884011 | 0a40e9fe8b229ce3534ad6e6e316e0b94c028847 | refs/heads/master | 2021-05-23T05:59:02.243040 | 2018-06-08T08:54:03 | 2018-06-08T08:54:03 | 94,750,445 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | cpp | 222A.cpp | #include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
int n, k;
scanf("%d %d", &n, &k);
for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
int i = k;
while(a[i] == a[k]) i++;
while(k >= 1 && a[k] == a[i - 1]) k--;
printf("%d", (i == n + 1) ? k : -1);
return 0;
}
|
6184ed8be1c1e4f5e08ba6126bbc18b16937e7c1 | b0049e549a2437cbd76acab350a7e7eb18a9b10e | /mincost_maxflow_dijkstra.cpp | facd2d0c59d28fc2fea1c6443f3b00bdf2439f2f | [] | no_license | Forestryks/algo | 1b8341329b02d76c00da443230accf0a94d40813 | 13730391d13f94238fd86f2038f47eee8b4d71b7 | refs/heads/master | 2020-05-04T23:52:53.526824 | 2020-01-16T13:00:11 | 2020-01-16T13:00:11 | 179,558,183 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,351 | cpp | mincost_maxflow_dijkstra.cpp | ///////////////////////////////////////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define FILE_IO(x) freopen((string(x) + ".in").c_str(), "r", stdin); freopen((string(x) + ".out").c_str(), "w", stdout)
#define f first
#define s second
#define x1 x1qwer
#define y1 y1qwer
#define foreach(it, v) for (auto it : v)
#define rep(it, n) for (int it = 0; it < n; ++it)
#define forin(it, l, r) for (int it = l; it < r; ++it)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const double DINF = numeric_limits<double>::infinity();
const ll MOD = 1e9 + 7;
const double EPS = 1e-7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
mt19937 mmtw_(MOD);
uniform_int_distribution<ll> rd_;
ll randomll() { return rd_(mmtw_);}
ll rnd(ll x, ll y) { return rd_(mmtw_) % (y - x + 1) + x; }
template <class T> T fact(T n) { if (n == 1) return 1; return n * fact(n - 1); }
////////////////////////////////////////////////////////////////////////////////////////////////
namespace mincost {
struct edge {
int p, q;
ll f, c, w;
};
const int inf = 2e9;
const int MAXN = 1e5 + 5;
int n;
int s, t;
vector<int> g[MAXN];
vector<edge> e;
int pr[MAXN];
bool used[MAXN];
int d[MAXN];
void spfa() {
fill(pr, pr + n, inf);
fill(used, used + n, false);
queue<int> q;
q.push(s);
used[s] = true;
pr[s] = 0;
while (!q.empty()) {
int v = q.front();
q.pop();
used[v] = false;
if (pr[v] == inf) continue;
for (auto x : g[v]) {
int to = e[x].q;
ll w = e[x].w;
if (e[x].c - e[x].f < 1) continue;
if (pr[v] + w < pr[to]) {
pr[to] = pr[v] + w;
if (!used[to]) {
q.push(to);
}
}
}
}
}
bool dijkstra() {
fill(used, used + n, false);
fill(d, d + n, inf);
d[s] = 0;
for (int qq = 0; qq < n; ++qq) {
int v = -1;
for (int i = 0; i < n; ++i) {
if (used[i]) continue;
if (v == -1 || d[i] < d[v]) {
v = i;
}
}
if (d[v] == inf) break;
used[v] = true;
for (auto x : g[v]) {
if (e[x].c - e[x].f < 1) continue;
int to = e[x].q;
ll w = e[x].w + pr[v] - pr[to];
if (d[v] + w < d[to]) {
d[to] = d[v] + w;
}
}
}
for (int i = 0; i < n; ++i) {
pr[i] += d[i];
}
return d[t] != inf;
}
int dfs(int v, int mn) {
used[v] = true;
if (v == t) return mn;
for (auto x : g[v]) {
int to = e[x].q;
ll w = e[x].w + pr[v] - pr[to];
if (e[x].c - e[x].f < 1) continue;
if (w != 0) continue;
if (used[to]) continue;
int res = dfs(to, min<ll>(mn, e[x].c - e[x].f));
if (res > 0) {
e[x].f += res;
e[x ^ 1].f -= res;
return res;
}
}
return 0;
}
void maxflow() {
spfa();
while (dijkstra()) {
fill(used, used + n, false);
dfs(s, inf);
}
}
void link(int p, int q, ll c, ll w) {
g[p].push_back(e.size());
g[q].push_back(e.size() + 1);
e.push_back({p, q, 0, c, w});
e.push_back({q, p, 0, 0, -w});
}
};
int n, m;
int main() {
FAST_IO;
cin >> n >> m;
rep(i, m) {
int p, q, c, w;
cin >> p >> q >> c >> w;
mincost::link(p - 1, q - 1, c, w);
}
mincost::s = 0;
mincost::t = n - 1;
mincost::n = n;
mincost::maxflow();
ll res = 0;
for (int i = 0; i < mincost::e.size(); i += 2) {
res += mincost::e[i].f * mincost::e[i].w;
}
cout << res << endl;
}
|
b6d7724f2e18f22add84cc95fc91fff0b6e31c5b | f57610ce330076f2ba95041bbf5f295a9ef40dfe | /Solution/058-length-of-last-word/length-of-last-word.cpp | 0284d8b97c1a5e28192f1c0b137cff11a21c4761 | [] | no_license | derek-zr/leetcode | 095df86dd00c85b98a3f3ef51e784a65ab75c13d | ec7edcca6a63648d87bed6dd557738b89511368d | refs/heads/master | 2021-01-21T21:07:07.114659 | 2020-11-27T09:29:35 | 2020-11-27T09:29:35 | 92,308,067 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,333 | cpp | length-of-last-word.cpp | // Given a string s consists of some words separated by spaces, return the length of the last wordย in the string. If the last word does not exist, return 0.
//
// A word is a maximal substring consistingย of non-space characters only.
//
// ย
// Example 1:
// Input: s = "Hello World"
// Output: 5
// Example 2:
// Input: s = " "
// Output: 0
//
// ย
// Constraints:
//
//
// 1 <= s.length <= 104
// s consists of only English letters and spaces ' '.
//
//
/*
* [58] Length of Last Word
*
* https://leetcode.com/problems/length-of-last-word/description/
*
* algorithms
* Easy (32.08%)
* Total Accepted: 210.4K
* Total Submissions: 655.8K
* Testcase Example: '"Hello World"'
*
* Given a string s consists of upper/lower-case alphabets and empty space
* characters ' ', return the length of last word in the string.
*
* If the last word does not exist, return 0.
*
* Note: A word is defined as a character sequence consists of non-space
* characters only.
*
* Example:
*
* Input: "Hello World"
* Output: 5
*
*
*/
class Solution {
public:
int lengthOfLastWord(string s) {
int len=s.size();
int i=len-1;
int ans=0;
while(s[i]==' ') i--;
for(i;i>=0;i--){
if(s[i]!=' ') ans++;
else break;
}
return ans;
}
};
|
d4d73a10695fcec86c368b1a577e2b41b546d950 | 4ce67fdf156419061474082db726a0113264b3ae | /xkill-renderer/DebugShapeD3D.cpp | a18d326f570146e57a98003d0b312e9610cdb383 | [] | no_license | L0mion/xkill-source | 559d179fa2262a260ddef88bfcf02ad72eea47d7 | 08709ac9cff31b4b1dd05a1aff3884fa4def3a90 | refs/heads/master | 2016-08-02T21:31:58.845252 | 2014-04-02T18:57:10 | 2014-04-02T18:57:10 | 6,520,111 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 253 | cpp | DebugShapeD3D.cpp | #include "VB.h"
#include "IB.h"
#include "DebugShapeD3D.h"
DebugShapeD3D::DebugShapeD3D(VB<VertexPosColor>* vb)
{
vb_ = vb;
}
DebugShapeD3D::~DebugShapeD3D()
{
if(vb_)
delete vb_;
}
VB<VertexPosColor>* DebugShapeD3D::getVB() const
{
return vb_;
} |
471180a7872a53c8f3c10ecec016ab1136412bc6 | 63d7819a32a5dcfb3396e764265601b8844c6f36 | /src/Planner/Conditions/BaseCondition.h | dd083842b7cacc666de29da1a719afc3ee99a22b | [
"MIT"
] | permissive | ddelamare/BotWithAPlan | a360c09b6ee88345105da8e5c927a221fad4bc52 | 534dfd55ea767b7d860da720f7a65a211c2c8ea4 | refs/heads/master | 2021-06-02T23:10:31.673710 | 2020-07-18T03:13:34 | 2020-07-18T03:13:34 | 119,787,556 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,026 | h | BaseCondition.h | #pragma once
#include <vector>
#include <string>
#include <iostream>
#include <stdarg.h>
#include "Common/ResourceState.h"
#include "Common/Resource.h"
using namespace std;
class BaseCondition
{
private:
protected:
string name = "Generic Condition";
bool HasAllResources(ResourceState* state);
ResourceMap requiredResources;
public:
BaseCondition() {
requiredResources = ResourceMap();
}
BaseCondition(string condName, int numDeps, ...)
{
name = condName;
requiredResources = ResourceMap();
// Dynamically create a Condition based on dependencies
va_list vl;
va_start(vl, numDeps);
for (int i = 0; i < numDeps; i += 2)
{
sc2::UNIT_TYPEID res = va_arg(vl, sc2::UNIT_TYPEID);
int numReq = va_arg(vl, int);
requiredResources[res] = numReq;
}
va_end(vl);
}
virtual bool IsMet(GameState* gs);
virtual bool IsMet(ResourceState*);
virtual ResourceMap GetRequiredResources(ResourceState* state);
ResourceMap UnmetResources(ResourceState* state);
string GetName()
{
return name;
}
}; |
f06efb268caec86e3eb38803be30c6b148dad2f2 | e2171ad810384af43f7b5a88bfb6bdfd2ee20bea | /Technology-Challenge/ใCookiesใไบบ่ธ่ฏๅซ/TYSMRTE/TYSMExtension/Extension/brfv4/utils/BRFv4PointUtils.hpp | e2d82782e80b39218d6226f5ae4be1a05792a60f | [
"MIT"
] | permissive | AgoraIO-Community/RTE-2021-Innovation-Challenge | 249965c82697d1b248f39fbf2df6a3cbd6de6c78 | 558c96cf0f029fb02188ca83f60920c89afd210f | refs/heads/master | 2022-07-25T12:27:17.937730 | 2022-01-21T12:58:11 | 2022-01-21T12:58:11 | 355,093,340 | 36 | 128 | null | 2021-11-07T17:13:28 | 2021-04-06T07:12:11 | C++ | UTF-8 | C++ | false | false | 2,803 | hpp | BRFv4PointUtils.hpp | #ifndef __brf_BRFv4PointUtils_hpp
#define __brf_BRFv4PointUtils_hpp
namespace brf {
class BRFv4PointUtils {
public: static double PI;
public: static double abs(double a) {
return (a < 0.0) ? -a : a;
}
public: static double max(double a, double b, double c) {
double _max = a;
if(b > _max) _max = b;
if(c > _max) _max = c;
return _max;
}
public: static void setPoint(std::vector< double >& v, int i, brf::Point& p) {
p.x = v[i * 2]; p.y = v[i * 2 + 1];
}
public: static void applyMovementVector(brf::Point& p, brf::Point& p0, brf::Point& pmv, double f) {
p.x = p0.x + pmv.x * f;
p.y = p0.y + pmv.y * f;
}
public: static void interpolatePoint(brf::Point& p, brf::Point& p0, brf::Point& p1, double f) {
p.x = p0.x + f * (p1.x - p0.x);
p.y = p0.y + f * (p1.y - p0.y);
}
public: static void calcMovementVector(brf::Point& p, brf::Point& p0, brf::Point& p1, double f) {
p.x = f * (p1.x - p0.x);
p.y = f * (p1.y - p0.y);
}
public: static void calcMovementVectorOrthogonalCW(brf::Point& p, brf::Point& p0, brf::Point& p1, double f) {
calcMovementVector(p, p0, p1, f);
double x = p.x;
double y = p.y;
p.x = -y;
p.y = x;
}
public: static void calcMovementVectorOrthogonalCCW(brf::Point& p, brf::Point& p0, brf::Point& p1, double f) {
calcMovementVector(p, p0, p1, f);
double x = p.x;
double y = p.y;
p.x = y;
p.y = -x;
}
public: static void calcIntersectionPoint(brf::Point& p, brf::Point& pk0, brf::Point& pk1, brf::Point& pg0, brf::Point& pg1) {
//y1 = m1 * x1 + t1 ... y2 = m2 * x2 + t1
//m1 * x + t1 = m2 * x + t2
//m1 * x - m2 * x = (t2 - t1)
//x * (m1 - m2) = (t2 - t1)
double dx1 = (pk1.x - pk0.x); if(dx1 == 0) dx1 = 0.01;
double dy1 = (pk1.y - pk0.y); if(dy1 == 0) dy1 = 0.01;
double dx2 = (pg1.x - pg0.x); if(dx2 == 0) dx2 = 0.01;
double dy2 = (pg1.y - pg0.y); if(dy2 == 0) dy2 = 0.01;
double m1 = dy1 / dx1;
double t1 = pk1.y - m1 * pk1.x;
double m2 = dy2 / dx2;
double t2 = pg1.y - m2 * pg1.x;
double m1m2 = (m1 - m2); if(m1m2 == 0) m1m2 = 0.01;
double t2t1 = (t2 - t1); if(t2t1 == 0) t2t1 = 0.01;
double px = t2t1 / m1m2;
double py = m1 * px + t1;
p.x = px;
p.y = py;
}
public: static double calcDistance(brf::Point& p0, brf::Point& p1) {
return sqrt(
(p1.x - p0.x) * (p1.x - p0.x) +
(p1.y - p0.y) * (p1.y - p0.y));
}
public: static double calcAngle(brf::Point& p0, brf::Point& p1) {
return atan2((p1.y - p0.y), (p1.x - p0.x));
}
public: static double toDegree(double x) {
return x * 180.0 / brf::BRFv4PointUtils::PI;
}
public: static double toRadian(double x) {
return x * brf::BRFv4PointUtils::PI / 180.0;
}
}; // namespace BRFv4PointUtils
double BRFv4PointUtils::PI = 3.14159265358979323846;
} // namespace brf
#endif // __brf_BRFv4PointUtils_hpp
|
deadec356f8e4c01b22dad05dae5c2605a732e03 | ba7d6989b8a7fadfe8a35dfa6cb3f1b5a69821a0 | /C++็ฌ่ฎฐ/็ฌฌไน็ซ /9-8/9-8/9-8.cpp | 4c7c2e6ebce5f96350dadd0dee2c4025be15a8ce | [] | no_license | GJP1106/C-_Study | 4e14116db6a3927d32541609f657ae92cf0b49d2 | 465bcbcef412e9ee85394d0a40b042df38a72ce1 | refs/heads/master | 2020-10-01T06:49:19.092299 | 2020-04-20T23:57:04 | 2020-04-20T23:57:04 | 227,479,151 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,279 | cpp | 9-8.cpp | ๏ปฟ// 9-8.cpp : ๆญคๆไปถๅ
ๅซ "main" ๅฝๆฐใ็จๅบๆง่กๅฐๅจๆญคๅคๅผๅงๅนถ็ปๆใ
//
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
using namespace std;
class CT {
public:
void myfuncpt(int x, int y) {
auto mylambad1 = [this] //ๆ ่ฎบๆฏthis๏ผ่ฟๆฏ& ๆ่
= ้ฝๅฏไปฅ่พพๅฐ่ฎฟ้ฎ็ฑปๆๅ็็ฎ็
{
return m_i; //ๅ ไธบๆไบthis๏ผ่ฟไธช่ฎฟ้ฎๅๆณ็๏ผ็จ& = ไน่ก
};
cout << mylambad1() << endl;
}
int m_i = 6;
};
void myfunc(int i) {
cout << i << endl;
}
int main()
{
//ไธใ็จๆณ็ฎไป
//c++11๏ผไนๆฏไธ็งๅฏ่ฐ็จๅฏน่ฑก
//lambda่กจ่พพๅผ๏ผๅฎๅฎไนไบไธไธชๅฟๅๅฝๆฐ๏ผๅนถไธๅฏไปฅๆ่ทไธๅฎ่ๅดๅ
็ๅ้ใ
#if 0
//auto f = [](int a)->int {
auto f = [](int a){
return a + 1;
};
cout << f(1) << endl;
#endif
//็น็น๏ผ
//a)ๆฏไธชๅฟๅๅฝๆฐ๏ผไนๅฏไปฅ็่งฃไธบโๅฏ่ฐ็จ็ไปฃ็ ๅๅ
โ๏ผๆ่
็่งฃๆ ๆชๅฝๅ็ๅ
่ๅฝๆฐใ
//b)ๅฎไนๆไธไธช่ฟๅ็ฑปๅ๏ผไธไธชๅๆฐๅ่กจ๏ผไธไธชๅฝๆฐไฝ
//c)ไธๅฝๆฐไธๅ็ๆฏ๏ผlambda่กจ่พพๅผๅฏไปฅๅจๅฝๆฐๅ
้จๅฎไน๏ผ่ฟไธชๆฏๅธธ่งๅฝๆฐๅไธๅฐ็๏ผ
//ๆ ผๅผ:
//[ๆ่ทๅ่กจ](ๅๆฐๅ่กจ)->่ฟๅ็ฑปๅ{ๅฝๆฐไฝ};
//a)่ฟๆฏไธไธช่ฟๅ็ฑปๅๅ็ฝฎ่ฟ็ง่ฏญๆณ(lambda่กจ่พพๅผ็่ฟๅ็ฑปๅๅ็ฝฎๆฏๅฟ
้กป็๏ผ่ฟไธช่ฏญๆณๅฐฑ่ฟไน่งๅฎ)๏ผ
//ๅ ไธบๅพๅคๆถๅlambda่กจ่พพๅผ่ฟๅๅผ็นๅซๆๆพ๏ผๆไปฅๅ
่ฎธlambda่กจ่พพๅผ่ฟๅ็ฑปๅ ็็ฅ๏ผ็ผ่ฏๅจๅฏไปฅ่ชๅจๆจๅฏผ
//lambdaๅๆฐๅฏไปฅๆ้ป่ฎคๅผ
//ๅคงๅฎถ่ฆๆณจๆ๏ผ็ผ่ฏๅจๅนถไธๆฏๆป่ฝๆจๆญๅบ่ฟๅๅผ็ฑปๅ๏ผๅฆๆ็ผ่ฏๅจๆจๆญไธๅบๆฅ็ๆถๅ๏ผๅฎไผๆฅ้๏ผ่ฟไธชๆถๅไฝ ๅฐฑ่ฆๆพๅผ็ปๅบๅ
ทไฝ็่ฟๅๅผ็ฑปๅใ
//b)ๆฒกๆๅๆฐ็ๆถๅ๏ผๅๆฐๅ่กจๅฏไปฅ็็ฅ๏ผ็่ณ()ไน่ฝ็็ฅ๏ผๆไปฅๅฆไธ่ฟไบๆ ผๅผ้ฝๅๆณ๏ผ
#if 0
auto f1 = []() {return 1; };
auto f2 = [] {return 2; };
cout << f1() << endl;
cout << f2() << endl;
#endif
//c)ๆ่ทๅ่กจ[]ๅๅฝๆฐไฝไธ่ฝ็๏ผๅฟ
้กปๆถๅปๅ
ๅซใ
//d)lambda่ฐ็จๆนๆณๅๆฎ้ๅฝๆฐ็ธๅ๏ผ้ฝๆฏไฝฟ็จ()่ฟ็งๅฝๆฐ่ฐ็จ่ฟ็ฎ็ฌฆ๏ผ
//e)lambda่กจ่พพๅผๅฏไปฅไธ่ฟๅไปปไฝ็ฑปๅ๏ผไธ่ฟๅไปปไฝ็ฑปๅๅฐฑๆฏvoid๏ผ
//auto f3 = [] {};
//f)ๅฝๆฐไฝๆซๅฐพ็ๅๅทไธ่ฝ็็ฅ๏ผ
//ไบใๆ่ทๅ่กจ๏ผ[ๆ่ทๅ่กจ]:้่ฟๆ่ทๅ่กจๆฅๆ่ทไธๅฎ่ๅดๅ
็ๅ้๏ผ่ๅดๆฏๅฅๆๆๅข๏ผ
//a)[] ไธๆ่ทไปปไฝๅ้๏ผไฝไธๅ
ๆฌ้ๆๅฑ้จๅ้ใlambdaๅฏไปฅ็ดๆฅไฝฟ็จๅฑ้จ้ๆๅ้(ๅฑ้จ้ๆๅ้ๆฏไธ้่ฆๆ่ท็)
#if 0
//int i = 9;
static int i = 9;
auto f1 = [] {
return i; //ๆฅ้(ๆ ๆณๆ่ทๅค้จๅ้)๏ผไธ่ฎค่ฏ่ฟไธชiๅจๅช้ๅฎไนใ
};
#endif
//b)[&] ๆ่ทๅค้จไฝ็จๅไธญๆๆๅ้๏ผๅนถไฝไธบๅผ็จๅจๅฝๆฐไฝๅ
ไฝฟ็จ
#if 0
int i = 9;
auto f1 = [&] {
i = 5; //ๅ ไธบ&็ๅญๅจ๏ผ้ฃไนๅฐฑๅ
่ฎธ็ปi่ตๅผ๏ผไป่ไนๅฐฑๆนๅไบi็ๅผ
return i;
};
cout << f1() << endl;
cout << i << endl;
#endif
//c)[=] ๆ่ทๅค้จไฝ็จๅไธญๆๆๅ้๏ผๅนถไฝไธบๅฏๆฌ(ๆๅผ)ๅจๅฝๆฐไธญไฝฟ็จ๏ผไนๅฐฑๆฏๅฏไปฅ ็จๅฎ็ๅผ๏ผไฝไธ่ฎธ็ปๅฎ่ตๅผ
#if 0
int i = 9;
auto f1 = [=]
{
//i = 5; //้ๆณ๏ผไธๅฏไปฅ็ปๅฎ่ตๅผ๏ผๅ ไธบๆฏไปฅๅผ็ๆนๅผๆ่ท
return i;
};
cout << f1() << endl;
#endif
//d)[this] ไธ่ฌ็จไบ็ฑปไธญ๏ผๆ่ทๅฝๅ็ฑปไธญthisๆ้๏ผ่ฎฉlambda่กจ่พพๅผๆๅๅฝๅ็ฑปๆๅๅฝๆฐๅๆ ท็่ฎฟ้ฎๆ้ใ
//ๅฆๆ[]ไธญๅทฒ็ปไฝฟ็จไบ & ๆ่
= ๏ผ้ฃไน้ป่ฎคๅฐฑๅทฒ็ปไฝฟ็จไบ this๏ผ่ฏด็ฝไบ๏ผๆ่ทthis็็ฎ็ๅฐฑๆฏไธบไบๅจlambdaไธญไฝฟ็จๅฝๅ็ฑป็ๆๅๅฝๆฐๅๆๅๅ้
#if 0
CT ct;
ct.myfuncpt(3, 4);
#endif
//e)[ๅ้ๅ] ๅฆๆๆฏๅคไธชๅ้ๅ๏ผๅๅฝผๆญคไน้ด็จ,ๅ้ใ[ๅ้ๅ]่กจ็คบๆๅผๆ่ทๅ้ๅไปฃ่กจ็ๅ้๏ผๅๆถไธๆ่ทๅ
ถไปๅ้
//[&ๅ้ๅ] ๏ผ ๆๅผ็จๆ่ทๅ้ๅไปฃ่กจ็ๅ้๏ผๅๆถไธๆ่ทๅ
ถไปๅ้
//f)[=, &ๅ้ๅ] //ๆๅผๆ่ทๆ็จๅค้จๅ้๏ผไฝๆๅผ็จๆ่ท&ไธญๆๆ็ๅ้๏ผ่ฟไธช=ๅฟ
้กปๅๅจๅผๅคดไฝ็ฝฎ๏ผๅผๅคด่ฟไธชไฝ็ฝฎ่กจ็คบ ้ป่ฎคๆ่ทๆนๅผ๏ผ
//ไนๅฐฑๆฏ่ฏด๏ผ่ฟไธชๆ่ทๅ่กจ๏ผ็ฌฌไธไธชไฝ็ฝฎ่กจ็คบ็ๆฏ้ป่ฎคๆ่ทๆนๅผ(้ๅผๆ่ทๆนๅผ)ๅ็ปญๅ
ถไป็้ฝๆฏๆพๅผๆ่ทๆนๅผใ
//g)[&, ๅ้ๅ] ๏ผ ๆๅผ็จๆฅๆ่ทๆๆๅค้จๅ้๏ผไฝๆๅผๆฅๆ่ทๅ้ๅๆไปฃ่กจ็ๅ้๏ผ่ฟ้่ฟไธช&ๅฟ
้กปๅๅจๅผๅคดไฝ็ฝฎ๏ผๅผๅคด่ฟไธชไฝ็ฝฎ่กจ็คบ ้ป่ฎคๆ่ทๆนๅผ
//ๆป็ป๏ผlambda่กจ่พพๅผๅฏนไบ่ฝ่ฎฟ้ฎ็ๅค้จๅ้ๆงๅถ็้ๅธธ็ป่ด
//ไธใlambda่กจ่พพๅผๅปถ่ฟ่ฐ็จๆๅบ็ฐ็ป่ๅๆ
#if 0
int x = 5;
//auto f = [=] //ๅฝ้ๅฐauto่ฟไธ่ก๏ผไนๅฐฑๆฏๅจๆ่ท็่ฟไธชๆถๅป๏ผx็ๅผๅฐฑๅทฒ็ป่ขซ่ตๅผๅฐไบ่ฟไธชfไธญไบ
auto f = [&]
{
return x;
};
x = 10;
cout << f() << endl; //ๆไปฌ่ฎคไธบๆฏ10๏ผไฝๅฎ้
ๆฏ5
#endif
//ไนๅฐฑๆฏ่ฏด๏ผๅกๆฏๆๅผๆ่ท็ๅค้จๅ้๏ผๅจlambda่กจ่พพๅผๅฎไน็่ฟไธชๆถๅป๏ผๆๆ่ฟไบๅค้จๅ้ๅผๅฐฑ่ขซๅคๅถไบไธไปฝๅญๅจๅจlambda่กจ่พพๅผไธ
//่งฃๅณๅๆณๅฐฑๆฏๆๅผ็จ็ปๅฎ
//ๅใlambda่กจ่พพๅผไธญ็mutable(ๆๅ็)
#if 0
int x = 5;
auto f = [=]() mutable //ๆณจๆ่ฆๅ mutable,ๅ()ๅๆฐๅ่กจไนๅค็่ฟไธชๅๆฌๅทไธ่ฝ็็ฅ
{
x = 6;
return x;
};
#endif
//ไบใlambda่กจ่พพๅผ็็ฑปๅๅๅญๅจ
//c++11ไธญ๏ผlambda่กจ่พพๅผ็็ฑปๅ่ขซ็งฐๅผไธบโ้ญๅ
็ฑปๅโ๏ผ
//้ญๅ
๏ผๅฝๆฐๅ
็ๅฝๆฐ(ๅฏ่ฐ็จๅฏน่ฑก)ใๆฌ่ดจไธๅฐฑๆฏlambda่กจ่พพๅผๅๅปบ็่ฟ่กๆถๆ็ๅฏน่ฑกใ
//lambda่กจ่พพๅผๆฏไธ็งๆฏ่พ็นๆฎ็๏ผๅฟๅ็๏ผ็ฑป็ฑปๅ[้ญๅ
็ฑป]็ๅฏน่ฑก(ไนๅฐฑๆฏๅฎไนไบไธไธช็ฑป็ฑปๅ)ใๅ็ๆไบไธไธชๅฟๅ็ๅฏน่ฑก
//ๆไปฌๅฏไปฅ่ฎคไธบๅฎๆฏไธไธชๅธฆๆoperator()็็ฑป็ฑปๅๅฏน่ฑกใไนๅฐฑๆฏไปฟๅฝๆฐ(ๅฝๆฐๅฏน่ฑก)
//ๆไปฅ๏ผๆไปฌไนๅฏไปฅ็จstd::functionๅstd::bindๆฅไฟๅญๅ่ฐ็จlambda่กจ่พพๅผ๏ผๆฏไธชlambda้ฝไผๅบๅ็ผ่ฏๅจ็ปๅฑไปฌ็ๆไธไธช็ฌไธๆ ไบ็็ฑป็ฑปๅ
//lambda่กจ่พพๅผ่ฟ็ง่ฏญๆณ๏ผๆฏๆไปฌๅฏไปฅๅฐฑๅฐๅฎไนๅฟๅๅฝๆฐ(ๅฐฑๅฐๅฐ่ฃ
็ญๅฐ็ๅ่ฝ้ญๅ
)๏ผ
#if 0
std::function<int(int)> fc1 = [](int tv) {return tv; };
cout << fc1(15) << endl;
std::function<int(int)> fc2 = std::bind( //bind็ฌฌไธไธชๅๆฐๆฏๅฝๆฐๆ้๏ผ็ฌฌไบไธชๅๆฐๅผๅงๅฐฑๆฏ็ๆญฃ็ๅฝๆฐๅๆฐ
[](int tv) {
return tv;
},
16
);
cout << fc2(13) << endl;
#endif
//ไธๆ่ทไปปไฝๅ้็lambda่กจ่พพๅผ๏ผไนๅฐฑๆฏๆ่ทๅ่กจไธบ็ฉบ๏ผๅฏไปฅ่ฝฌๆขๆไธไธชๆฎ้็ๅฝๆฐๆ้๏ผ
#if 0
using functype = int(*)(int); //ๅฎไนไธไธชๅฝๆฐๆ้็ฑปๅ
functype fp = [](int tv) {return tv; };
cout << fp(17) << endl;
#endif
//(5.1)่ฏญๆณ็ณๆฆๅฟต
//่ฏญๆณ็ณ๏ผไธ็งไพฟๆทๅๆณ็ๆๆ
//int a[5];
//a[0] = 1; //ไพฟๆทๅๆณ
//่ฏญๆณ็ณ่ฟไธช่ฏ๏ผ่ฎฉๆไปฌๅ็ไปฃ็ ๆด็ฎๅ๏ผ็่ตทๆฅไนๆดๅฎนๆ็่งฃ๏ผๆๆ็ๅๅฐๅไปฃ็ ๅบ้็ๆบ็
//่ฏญๆณ็ณๆฏๆๅบไบ่ฏญ่จ็ฐๆ็นๆง๏ผๆๅปบๅบไธไธชไธ่ฅฟ๏ผ็จๅบๅ็จ่ตทๆฅไผๅพๆนไพฟใไฝๅฎๆฒกๆๅขๅ ่ฏญ่จ็ๅๆๅ่ฝ๏ผ
//ๆไปฅ๏ผ่ฟไธชlambda่กจ่พพๅผ๏ผๅคงๅฎถไนๅฏไปฅ็ๆๆฏๅฎไนไปฟๅฝๆฐ้ญๅ
(ๅฝๆฐไธญ็ๅฝๆฐ)็่ฏญๆณ็ณ
//ๅ
ญใlambda่กจ่พพๅผๅๆผ็คบๅไผ็นๆป็ป
//(6.1)for_each็ฎไป:ๆฏไธชๅฝๆฐๆจกๆฟ
/*vector<int> myvector = { 10,20,30,40,50 };
for_each(myvector.begin(), myvector.end(), myfunc);*/
#if 0
vector<int> myvector = { 10,20,30,40,50 };
int isum = 0;
for_each(
myvector.begin(), myvector.end(), [&isum](int val) {
isum += val;
cout << val << endl;
}
);
cout << "sum = " << isum << endl;
#endif
//(6.2)find_if ็ฎไป๏ผๅฝๆฐๆจกๆฟfind_if
//็จๆฅๆฅๆพไธไธชไธ่ฅฟ๏ผๆฅไปไนๅข๏ผๅๅณไบๅฎ็็ฌฌไธไธชๅๆฐ๏ผๅฎ็็ฌฌไธไธชๅๆฐไนๆฏไธชๅฝๆฐๅฏน่ฑก(lambda่กจ่พพๅผ)
vector<int> myvector = { 10,20,30,40,50 };
auto result = find_if(myvector.begin(), myvector.end(), [](int val) {
cout << val << endl;
return false; //ๅช่ฆๆ่ฟๅfalse๏ผ้ฃไนfind_ifๅฐฑไธๅ็้ๅ๏ผไธ็ดๅฐ่ฟๅtrueๆ่
้ๅๅฎไธบๆญข
});
//ๅฆๆfind_if็ฌฌไธไธชๅๆฐ่ฟไธชๅฏ่ฐ็จๅฏน่ฑก(lambda)่ฟๅtrue,find_ifๅฐฑๅๆญข้ๅ๏ผ
//find_if็่ฐ็จ่ฟๅไธไธช่ฟญไปฃๅจ๏ผๆๅ็ฌฌไธไธชๆปก่ถณๆกไปถ็ๅ
็ด ๏ผๅฆๆ่ฟๆ ท็ๅ
็ด ไธๅญๅจ๏ผๅ่ฟไธช่ฟญไปฃๅจไผๆๅmyvector.end
//ๆป็ป๏ผๅ็จlambda่กจ่พพๅผ๏ผ่ฎฉไปฃ็ ๆด็ฎๆดใๆด็ตๆดปใๆดๅผบๅคงใๆ้ซๅผๅๆ็๏ผๆ้ซๅฏ็ปดๆคๆง็ญ็ญ
return 0;
}
|
22ca6a9905758c28c55f922c4f394a9a45b18a5c | 37bc7a0855886c005fbdf2e1e0f3f0cda42d7a52 | /Laboratorio/laboratorio.cpp | 6981a9bccfa8d89446286b7bbce08c411df99ff8 | [] | no_license | AugustoNicola/OIA | edfc3eb7426d2e4bd657842adef86fd923401412 | 93d474e8b8eed671dd1d334b00bd48edf5a16b37 | refs/heads/main | 2023-05-09T09:08:59.646383 | 2021-05-22T15:48:33 | 2021-05-22T15:48:33 | 304,144,206 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,586 | cpp | laboratorio.cpp | #include <vector>
#include <string>
#include <iostream>
#include <utility>
#include <queue>
using namespace std;
void BFS(int x, int y);
struct baldosa
{
bool visitado = false;
bool accesible = true;
bool esEntrada = false;
};
pair<int,int> movimientos[4] = {{-1,0}, {0,-1}, {1, 0}, {0,1}};
vector<vector<baldosa> > baldosas;
vector<pair<int,int>> visitadosIteracion;
int N, M, P;
int baldosasAccesibles;
vector<int> laboratorio(vector<string> mapa, vector<int> perrosFila, vector<int> perrosColumna)
{
N = mapa.size(); M = mapa[0].size(); P = perrosFila.size(); vector<int> estadoBaldosas(P);
baldosas.resize(N,vector<baldosa>(M));
baldosasAccesibles = N * M; //inicializa el numero al maximo
// localiza las entradas y los escritorios
for(int i = 0; i < N; i++)
{
for(int j = 0; j < M; j++)
{
if(mapa[i][j] == '#')
{
baldosas[i][j].accesible = false;
baldosasAccesibles--;
}
if(mapa[i][j] == 'E')
{
baldosas[i][j].esEntrada = true;
}
}
}
for(int p = 0; p < P; p++)
{
// ? entrada de cada perro
int x = perrosFila[p], y = perrosColumna[p];
// si la baldosa no era accesible no es posible que se altere ninguna otra baldosa
if(baldosas[x][y].accesible)
{
baldosas[x][y].accesible = false;
baldosas[x][y].esEntrada = false;
baldosasAccesibles--;
// * busca realizar el BFS
for(pair<int,int>& mov : movimientos)
{
int a = x + mov.first; int b = y + mov.second;
if(
a >= 0 && a < N &&
b >= 0 && b < M &&
baldosas[a][b].accesible &&
!baldosas[a][b].visitado // si fue visitado y es accesible ya sabemos que es accesible
) { BFS(a,b); }
}
// * visitados reseteados
for(pair<int,int>& v : visitadosIteracion) baldosas[v.first][v.second].visitado = false;
visitadosIteracion = {};
}
estadoBaldosas[p] = baldosasAccesibles;
}
return estadoBaldosas;
}
// * precondicion: es accesible y existe
void BFS(int x, int y)
{
bool salidaEncontrada = false;
queue<pair<int,int>> cola; cola.emplace(x,y);
vector<pair<int,int>> visitados;
baldosas[x][y].visitado = true;
while(!cola.empty())
{
// ? nuevo elemento
pair<int,int> bald = cola.front(); cola.pop();
int b_x = bald.first, b_y = bald.second;
visitados.emplace_back(b_x, b_y); visitadosIteracion.emplace_back(b_x,b_y);
if (baldosas[b_x][b_y].esEntrada)
{
salidaEncontrada = true; baldosas[b_x][b_y].visitado = false;
}
else //no puede seguir el BFS si es una entrada
{
// * busca hijos no recorridos
for(pair<int,int>& mov : movimientos)
{
int a = b_x + mov.first, b = b_y + mov.second;
//si es una baldosa visitable
if(
a >= 0 && a < N &&
b >= 0 && b < M &&
!baldosas[a][b].visitado &&
baldosas[a][b].accesible
) { cola.emplace(a,b); baldosas[a][b].visitado = true; }
}
}
}
// ? marca como no accesibles de ser necesario
if(!salidaEncontrada)
{
for(pair<int,int>& v : visitados)
{
// !visitados no reseteados
baldosas[v.first][v.second].accesible = false;
baldosasAccesibles--;
}
}
}
// ! poscondicion: el estado de visitado de todas las baldosas es false
int main()
{
vector<string> mapa = {
"E..#...#..",
"E..#...#..",
"E..#...#..",
"E..##.##.#",
"E.........",
"E..##.##.#",
"E..#...#..",
"E..#...#..",
"E..#...#..",
"E..#...#..",
};
vector<int> pF = {3, 5, 3, 5, 4, 4};
vector<int> pC = {5, 5, 8, 8, 7, 3};
vector<int> respuesta = laboratorio(mapa, pF, pC);
for (int& r : respuesta)
{
std::cout << r << " ";
}
return 0;
} |
1935c95c1fa7ae891a407c2b46593edf2c574796 | 1949be1776c4124cd19cced3f9130b320628a871 | /source/m.cpp | 23f7caca54b1561f0bc5fd50f1066b8c42edaa86 | [] | no_license | pulsar541/gish2 | 88abb769b893db49f1e40f9977d328decef60191 | d5d39259fafa4b22f9efb3eb236ed9c5c3df8676 | refs/heads/master | 2022-11-20T16:13:01.939015 | 2020-07-20T13:58:51 | 2020-07-20T13:58:51 | 279,861,063 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 59,249 | cpp | m.cpp |
#include "glut.h"
#include <windows.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <vector>
//#include<gl/glaux.h>
//#include "tgalib.h"
using namespace std;
float crossX ;
float crossY ;
int curDescI, curDescJ;
#include "mystuctures.h"
#include "constants.h"
#include "mygish.h"
#include "enemy.h"
#include "draw.h"
#include "spisok.h"
#include "scene.h"
#include "levelManager.h"
DESC desc[100][100];
bool onlgt[2];
bool moveUP=false;
bool moveDOWN=false;
bool moveLEFT=false;
bool moveRIGHT=false;
bool moveUP_2=false;
bool moveDOWN_2=false;
bool moveLEFT_2=false;
bool moveRIGHT_2=false;
bool jump=false;
float YROT= 0;
float XROT= 0;
float ZROT= 0;
bool cameraHeroOrientation = true;
char command[100];
bool playing=true;
//PointF light[2];
PointF MEDGISH;
GLsizei width,height;
GLenum format;
GLenum type;
POINT mousePos;
PointF camera;
GLfloat d=0;
int NUMLINES;
int NUM_TR;
int RMX = limitX;
int LMX = 0;
int BMY = limitY;
int TMY = 0;
MyGish gish;
Primitive prim[MAXPRIMCOUNT];
Enemy enemy[MAXENEMYCOUNT];
Weapon weapon[11];
Door door[MAXDOORCOUNT];
Key key[MAXDOORCOUNT];
Item item[MAXITEMS];
int enemyCount = 0;
int doorCount = 0;
int keyCount = 0;
int itemCount = 0;
vector<Building> ball;
vector<int> n_prim_graph_actual;
vector<int> n_prim_actual;
//vector<Primitive> ::iterator iter_prim;
vector<Building> ::iterator pBall;
vector<Enemy> ::iterator iter_enemy;
vector<int> n_enemy_actual;
PointF Hero;
PointF exitLevel;
PointF startLevel;
PointF respawnPoint;
PointF checkPoint[CHECKPOINT_COUNT];
Scene scene;
LevelManager levelManager;
float FVector::gravity = 0.16;
bool isMap = false;
bool noclipMode = false;
float colorGeo[3];
float colorWalk[3];
float lightColor[100][100][3];
bool researched[100][100];
char dat[101][101];
GLfloat real_lightmodel[4]={0.1,0.1,0.1,1};
PointF forbombPoint;
void GetQuadCoord(int *I,int *J, PointF heroPos)
{
*I = heroPos.x / SIZE1;
*J = 101-heroPos.y / SIZE2;
if (*I<0 || *I>99) *I=0;
if (*J<0 || *J>99) *J=0;
}
bool underCameraUnit (PointF unit, PointF camera, int area)
{
int iii,jjj;
GetQuadCoord(&iii,&jjj, unit);
int iii2,jjj2;
GetQuadCoord(&iii2,&jjj2, camera);
if(fabs(iii-iii2) < area && fabs(jjj-jjj2) < area)
return true;
return false;
}
bool researchedUnit (PointF unit)
{
int iii,jjj;
GetQuadCoord(&iii,&jjj, unit);
if(iii >=0 && iii<100 && jjj>=0 && jjj<100)
if(researched[iii][jjj])
return true;
return false;
}
void DescCollision(Unit *unit, int *primIndex)
{
int iii,jjj;
GetQuadCoord(&iii,&jjj, *unit);
int primi = -1;
for (int n = iii-2; n<=iii+1; n++)
for(int m = jjj-1; m<=jjj+1; m++)
{
if(n >=0 && m>=0 && n<100 && m<100)
{
if((primi = Collision( unit, &prim[desc[n][m].num1])) != -1) {*primIndex = primi; }
if((primi = Collision( unit, &prim[desc[n][m].num2])) != -1) {*primIndex = primi; }
}
}
for(int d=0;d<doorCount;d++)
{
if(door[d].inBox(unit))
Collision( unit, &door[d]);
}
}
void SimpleCollision(Unit *unit)
{
int iii,jjj;
GetQuadCoord(&iii,&jjj, *unit);
Collision( unit, &prim[desc[iii][jjj].num1]);
Collision( unit, &prim[desc[iii][jjj].num2]);
}
void Collisions()
{
GetQuadCoord(&curDescI,&curDescJ,gish.medium());
//curDescI = gish.medium().x / SIZE1;
//curDescJ = 101-gish.medium().y / SIZE2;
int i;
if(!noclipMode)
{
if(gish.LIP && !gish.SKOL)
{
for (int n = curDescI-1; n<=curDescI+1; n++)
for(int m = curDescJ-1; m<=curDescJ+1; m++)
{
if(n >=0 && m>=0 && n<100 && m<100)
{
for(int k =0; k<2 ; k++)
{ gish.Slipanie(&prim[desc[n][m].num1],NUM_TR,6,
moveUP || moveUP_2 ,
moveDOWN || moveDOWN_2,
moveLEFT || moveLEFT_2,
moveRIGHT || moveRIGHT_2
);
gish.Slipanie(&prim[desc[n][m].num2],NUM_TR,6,
moveUP || moveUP_2 ,
moveDOWN || moveDOWN_2,
moveLEFT || moveLEFT_2,
moveRIGHT || moveRIGHT_2
);
}
}
}
for(int k=0;door[k].corrected();k++)
gish.Slipanie(&door[k],NUM_TR,6.51,
moveUP || moveUP_2 ,
moveDOWN || moveDOWN_2,
moveLEFT || moveLEFT_2,
moveRIGHT || moveRIGHT_2
);
}
for(int i=0;i<gish.N;i++)
{
gish.bui[i]->inWater = false;
gish.bui[i]->onHard = false;
int primi=-1;
DescCollision(gish.bui[i],&primi);
if(primi >=0 && primi<MAXPRIMCOUNT)
{
gish.AdditionColliz(
&prim[primi],
NUM_TR,
moveUP || moveUP_2 ,
moveDOWN || moveDOWN_2,
moveLEFT || moveLEFT_2,
moveRIGHT || moveRIGHT_2,
jump,
i);
}
}
FVector::gravity =DEFAULT_GRAVITY;
}
else FVector::gravity = 0;
//float dx = -(float)sin((-90+ZROT)*_torad) * 0.05f;
// float dy = (float)cos((-90+ZROT)*_torad) * 0.05f;
gish.oldMed = gish.medium();
for(int i=0;i<gish.N;i++)
{
if(!gish.bui[i]->moveble)
gish.bui[i]->CalcVector();
if(moveDOWN || moveDOWN_2 ) gish.bui[i]->FMove.addImpulse(0, -0.04);
if(moveUP|| moveUP_2 ) gish.bui[i]->FMove.addImpulse(0, 0.04);
if(YROT >= 90 && YROT < 270)
{ if(moveRIGHT || moveRIGHT_2 ) gish.bui[i]->FMove.addImpulse(-0.04, 0);
if(moveLEFT || moveLEFT_2) gish.bui[i]->FMove.addImpulse(0.04, 0);
}
else
{ if(moveLEFT || moveLEFT_2) gish.bui[i]->FMove.addImpulse(-0.04, 0);
if(moveRIGHT || moveRIGHT_2) gish.bui[i]->FMove.addImpulse(0.04, 0);
}
// if(moveDOWN) gish.bui[i]->FMove.addImpulse(-dx, -dy);
// if(moveUP) gish.bui[i]->FMove.addImpulse(dx, dy);
if(!gish.bui[i]->moveble)
{ gish.bui[i]->CalcDxDy();
gish.bui[i]->Move();
}
}
gish.Kaplya();
////////////
/////////////
////////////
int ENEMY_ACTUAL_COUNT = n_enemy_actual.size();
for(int d=0;key[d].corrected();d++)
{
int primi;
DescCollision(&key[d],&primi);
MyGishCollision(&gish,&key[d]);
key[d].CalcVector();
key[d].CalcDxDy();
key[d].Move();
}
for(int k=0;k<11;k++)
{ weapon[k].inWater = false;
weapon[k].onHard = false;
if(gish.currentWeapon != k)
{ MyGishCollision(&gish,&weapon[k]);
int primi;
DescCollision(&weapon[k],&primi);
for(int d = 0; d < 10; d++)
if(d!=k)
Proch(&weapon[k],&weapon[d], weapon[d].radius + weapon[k].radius);
for(int d=0; door[d].corrected();d++)
{
Proch(&weapon[k], &key[d], key[d].radius + weapon[k].radius);
}
// int ENEMY_ACTUAL_COUNT = n_enemy_actual.size();
for(int j = 0; j < ENEMY_ACTUAL_COUNT; j++)
{
Proch(&weapon[k],&enemy[n_enemy_actual[j]], enemy[n_enemy_actual[j]].radius + weapon[k].radius);
}
}
weapon[k].CalcVector();
weapon[k].CalcDxDy();
weapon[k].Move();
for(int i=0; i<10;i++)
weapon[k].impact[i].inWater = false;
for(int i=0; i<10; i++)
{
int iii,jjj;
GetQuadCoord(&iii,&jjj, weapon[k].impact[i]);
Collision( &weapon[k].impact[i], &prim[desc[iii][jjj].num1]);
Collision( &weapon[k].impact[i], &prim[desc[iii][jjj].num2]);
for(int d=0; door[d].corrected();d++)
{
Collision( &weapon[k].impact[i], &door[d]);
}
if(weapon[k].impact[i].H)
{ weapon[k].impact[i].CalcVector();
weapon[k].impact[i].CalcDxDy();
weapon[k].impact[i].Move();
}
}
}
int j;
for(int j = 0; j < ENEMY_ACTUAL_COUNT; j++)
{
Enemy *tmpEnemy;
tmpEnemy = &enemy[n_enemy_actual[j]];
tmpEnemy->inWater = false;
tmpEnemy->onHard = false;
for(int k = 0; k < ENEMY_ACTUAL_COUNT; k++)
{ if(n_enemy_actual[j]==n_enemy_actual[k]) continue;
Enemy *tmpEnemy2;
tmpEnemy2 = &enemy[n_enemy_actual[k]];
Proch( tmpEnemy2, tmpEnemy, tmpEnemy->radius + tmpEnemy2->radius);
}
MyGishCollision(&gish,tmpEnemy); /////!
int primi;
DescCollision(&enemy[n_enemy_actual[j]],&primi);
enemy[n_enemy_actual[j]].CalcVector();
enemy[n_enemy_actual[j]].CalcDxDy();
enemy[n_enemy_actual[j]].Move();
}
for(int j = 0; j < ENEMY_ACTUAL_COUNT; j++)
{
Enemy *tmpEnemy;
tmpEnemy = &enemy[n_enemy_actual[j]];
for(int k=0; k<10;k++)
{
tmpEnemy->impact[k].inWater = false;
tmpEnemy->impact[k].onHard = false;
SimpleCollision(&tmpEnemy->impact[k]);
MyGishCollision(&gish,&tmpEnemy->impact[k]);
if(tmpEnemy->impact[k].onHard)tmpEnemy->impact[k].H = 0;
for(int d = 0; d < ENEMY_ACTUAL_COUNT; d++)
{
if(d!=j)
{
if(enemy[n_enemy_actual[d]].health > 0)
PROCH(&tmpEnemy->impact[k],&enemy[n_enemy_actual[d]], enemy[n_enemy_actual[d]].radius,5000);
}
}
if(tmpEnemy->impact[k].H)
{ tmpEnemy->impact[k].CalcVector();
tmpEnemy->impact[k].CalcDxDy();
tmpEnemy->impact[k].Move();
if(tmpEnemy->impact[k].onHard )
{ tmpEnemy->impact[k].H=0;
tmpEnemy->impact[k].setPos(10000,1000000);
}
}
}
}
// TROS ((Unit**)ball,0,ball.size()-1,12.4,2000);
TROS(&ball,20,5000);
// SVIAZKA (&ball[0],&ball[ball.size()-1],12.4,2000);
// if(moveUP) weapon[GUN].y+=5;
// if(moveDOWN) weapon[GUN].y-=5;
// if(moveLEFT) weapon[GUN].x-=5;
// if(moveRIGHT) weapon[GUN].x+=5;
// if(moveUP_2) weapon[SUPER_WEAPON].y+=5;
// if(moveDOWN_2) weapon[SUPER_WEAPON].y-=5;
// if(moveLEFT_2) weapon[SUPER_WEAPON].x-=5;
// if(moveRIGHT_2) weapon[SUPER_WEAPON].x+=5;
ball[0].x = weapon[SUPER_WEAPON].x;
ball[0].y = weapon[SUPER_WEAPON].y;
// ball[ball.size()-1].x = weapon[GUN].x;
// ball[ball.size()-1].y = weapon[GUN].y;
int k = 0;
Building* currBall;
for(pBall=ball.begin(); pBall!=ball.end(); pBall++, k++)
{
currBall = &ball.at(k);
for(int j = 0; j < ENEMY_ACTUAL_COUNT; j++)
{
Enemy *tmpEnemy;
tmpEnemy = &enemy[n_enemy_actual[j]];
if(tmpEnemy->health > 0)
Proch((Unit*)tmpEnemy, currBall, (currBall->radius + tmpEnemy->radius));
}
int primi;
DescCollision(currBall, &primi);
pBall->CalcVector();
pBall->CalcDxDy();
pBall->Move();
/* for(int int i=0;i<gish.N;i++)
{
if(gish.LIP && Dist(gish.bui[i],pBall)<gish.bui[i]->radius+pBall->radius+5)
{
SVIAZKA(gish.bui[i],pBall,14,5000);
}
else Proch(pBall, gish.bui[i], 6+pBall->radius);
}*/
}
}
void setDeath()
{
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 0.9);
glEnable (GL_LIGHT1);
glDisable (GL_LIGHT0);
real_lightmodel[0]=0;
real_lightmodel[1]=0;
real_lightmodel[2]=0;
real_lightmodel[3]=1;
// glClearColor(0.1,0,0,1);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,real_lightmodel);
GLfloat diffuse[4]={1,0.5,0.5,1};
glLightfv(GL_LIGHT1,GL_DIFFUSE,diffuse);
}
void setDay()
{ glDisable (GL_LIGHT0);
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 0.9);
glEnable (GL_LIGHT1);
glDisable (GL_LIGHT2);
real_lightmodel[0]=0.1;
real_lightmodel[1]=0.1;
real_lightmodel[2]=0.1;
real_lightmodel[3]=1;
glClearColor(0.95,1,1,1);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,real_lightmodel);
GLfloat diffuse[4]={1,1,1,1};
glLightfv(GL_LIGHT1,GL_DIFFUSE,diffuse);
GLfloat myLightPosition[] = {
0,
10000,
0,
1
};
glLightfv(GL_LIGHT1, GL_POSITION, myLightPosition);
}
void setLocalLight(int number,
int x,int y,float z,
float difR, float difG, float difB,
GLfloat k)
{
glDisable (GL_LIGHT0);
glLightf(GL_LIGHT0+number, GL_QUADRATIC_ATTENUATION, k);
glEnable (GL_LIGHT0+number);
real_lightmodel[0]=0.02;
real_lightmodel[1]=0.02;
real_lightmodel[2]=0.02;
real_lightmodel[3]=1;
glClearColor(0,0,0,1);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,real_lightmodel);
// int n,m;
// GetQuadCoord(&n,&m, ToPointF(x,y));
int n = x/SIZE1;
int m = 101 - y/SIZE2;
// if(number > 1)
/* {
glLightfv(GL_LIGHT0+number,GL_DIFFUSE,diffuse);
}
else{*/
GLfloat diffuse[4]={difR,difG,difB,1};
glLightfv(GL_LIGHT0+number,GL_DIFFUSE,diffuse);
// }
GLfloat myLightPosition[] = {
x,
y,
z,
1
};
glLightfv(GL_LIGHT0+number, GL_POSITION, myLightPosition);
}
DWORD starttime1=timeGetTime(),time_1;
DWORD starttime2=timeGetTime(),time_2;
DWORD starttime3=timeGetTime(),time_3;
DWORD tGT=timeGetTime ();
void CreateLines(char *path);
void MyMouseFunc();
int deathPause = 0;
void myIdle()
{
try{
int n;
tGT = timeGetTime ();
time_1 = tGT-starttime1;
time_2 = tGT-starttime2;
time_3 = tGT-starttime3;
if(time_3>1000/100)
{
// MyMouseFunc();
glutPostRedisplay();
starttime3+=time_3;
}
if(pauseMode)
return;
gish.timer();
for(int i=0; i<10; i++)
weapon[i].timer();
for(int d=0;d<MAXDOORCOUNT;d++)
door[d].timer();
// if ( gish.time[0] >= 45000 )
// {
// respawnPoint = gish.medium();
// gish.starttime[0] += gish.time[0];
// }
// int numEnemyActual = n_enemy_actual.size();
for(int n=0; n < enemyCount; n++)
{ // if( enemy[n_enemy_actual[n]].health>0)
enemy[n].timer();
}
if ( time_2 > 1000/5)
{ starttime2 += time_2;
/* int numEnemyActual = n_enemy_actual.size();
for(int n=0; n < numEnemyActual; n++)
{
enemy[n_enemy_actual[n]].setGoal(gish.medium().x, gish.medium().y);
}*/
if( gish.H<= 0 || weapon[BOMB].health <=0)
{
gish.H = 0 ;
deathPause++;
setDeath();
if(deathPause > 25)
{ //glClearColor(0,0,0,1);
// setNight();
weapon[BOMB].health = gish.H = 100;
PointF tmpP = respawnPoint;
CreateLines((char*)levelManager.getCurrentLevel().c_str());
gish.SetPos(tmpP.x, tmpP.y);
deathPause=0;
}
}
if(Dist(gish.medium(), exitLevel) < 50)
CreateLines((char*)levelManager.nextLevel("mapscript.dat").c_str());
for(int d=0; door[d].corrected(); d++)
for(int k=0; key[k].corrected(); k++)
if(key[k].NUM == door[d].NUM)
if(key[k].x + key[k].radius > door[d].boxMIN.x
&& key[k].x - key[k].radius < door[d].boxMAX.x
&&key[k].y + key[k].radius > door[d].boxMIN.y
&& key[k].y - key[k].radius < door[d].boxMAX.y )
{door[d].open();
key[k].radius = 0;
}
for(n = 0; n<MAXPRIMCOUNT; n++)
prim[n].Move();
n_enemy_actual.clear();
for (n = 0; n < enemyCount; n++)
{
enemy[n].ACTUAL =
simple_rasst((PointF)enemy[n],gish.medium(),1500)
|| simple_rasst((PointF)enemy[n],weapon[BOMB],1500);
if( enemy[n].ACTUAL)
{ n_enemy_actual.push_back(n);
/*
if(weapon[BOMB].active && Dist(&weapon[BOMB],&enemy[n]) < Dist(&gish.medium(), &enemy[n]))
enemy[n].setGoal(weapon[BOMB].x, weapon[BOMB].y);
else
enemy[n].setGoal(gish.medium().x, gish.medium().y);*/
enemy[n].setGoal(gish.medium().x, gish.medium().y);
if(weapon[BOMB].active)
enemy[n].setGoal(weapon[BOMB].x, weapon[BOMB].y);
}
}
/////////////////////////////////////////////////////////////////
gish.oldH = gish.H;
for(n=0; n< CHECKPOINT_COUNT; n++)
if(Dist(gish.medium(), checkPoint[n]) < 70)
respawnPoint = checkPoint[n] ;
if(Dist(gish.medium(), weapon[BOMB]) < 105)
{
if(!weapon[BOMB].active )
{ for(int i=0;i<enemyCount; i++)
enemy[i].setLive();
weapon[BOMB].active = true;
}
}
if(weapon[DETONATOR].fire)
{
int iii,jjj;
GetQuadCoord(&iii,&jjj, weapon[BOMB]);
for(int n = iii-1; n<=iii+1; n++)
for(int m=jjj-1; m<=jjj+1; m++)
{
if(prim[desc[n][m].num1].type == FORBOMB || prim[desc[n][m].num2].type == FORBOMB) {
prim[desc[n][m].num1].setPos(ToPointF(0,0), ToPointF(0,1), ToPointF(1,1));
prim[desc[n][m].num2].setPos(ToPointF(0,0), ToPointF(0,1), ToPointF(1,1));
weapon[DETONATOR].setPos(100000,10000);
weapon[DETONATOR].setMassive(false);
weapon[DETONATOR].active=false;
weapon[BOMB].setPos(100000,10000);
weapon[BOMB].setMassive(false);
if(weapon[BOMB].active)
{ weapon[BOMB].active=false;
for(int i=0;i<enemyCount; i++)
enemy[i].setLive();
// enemy[i].setSpirit(true);
}
}
}
}
for(n=0; n< itemCount; n++)
{
if(Dist(gish.medium(), item[n]) < 70 )
{
if(gish.H < 100)
{ gish.H += item[n].radius*2 ;
item[n].setPos(100000,100000);
}
if(gish.H > 100)
gish.H = 100;
}
}
/* if(gish.FIRE)
{
PointF A = gish.medium();
PointF B = ToPointF(gish.impact[0].x,gish.impact[0].y);
int ENEMY_ACTUAL_COUNT = n_enemy_actual.size();
float dist = 10000000000;
int numnearEnemy = -1;
for(int int j = 0; j < ENEMY_ACTUAL_COUNT; j++)
{
if(enemy[n_enemy_actual[j]].health>0)
{
float curdist = Dist( (PointF)enemy[n_enemy_actual[j]], gish.medium()) ;
if( curdist < dist
&& CircleIntersects(&enemy[n_enemy_actual[j]].x, &enemy[n_enemy_actual[j]].y, enemy[n_enemy_actual[j]].radius, Dist(A, B), A, B))
{ dist = curdist;
numnearEnemy = n_enemy_actual[j];
}
}
}
if(numnearEnemy > -1)
{
enemy[numnearEnemy].health -= 3;
}
}
*/
int ENEMY_ACTUAL_COUNT = n_enemy_actual.size();
for (int j = 0; j < ENEMY_ACTUAL_COUNT; j++)
{
if(researchedUnit( enemy[n_enemy_actual[j]]) )
enemy[n_enemy_actual[j]].sleeping = false;
if( enemy[n_enemy_actual[j]].health>0)
{
Enemy *tmpEnemy;
tmpEnemy = &enemy[n_enemy_actual[j]];
if(weapon[BOMB].active && Dist(&weapon[BOMB],tmpEnemy)<=tmpEnemy->radius+weapon[BOMB].radius+1)
{
weapon[BOMB].health-= minirand()*3;
}
for(int i=0;i<gish.N;i++)
{
if(Dist(gish.bui[i],tmpEnemy)<tmpEnemy->radius)
{
gish.H -= minirand()*3;
}
if(gish.TVER && Dist(gish.bui[i],tmpEnemy)<tmpEnemy->radius+10)
{
tmpEnemy->health -=2;
}
/* for(int i=0;i<10;i++)
if(Dist(&gish.medium(), &tmpEnemy->impact[i])<tmpEnemy->radius + 20)
{
gish.H -= minirand()*10;
tmpEnemy->impact[i].H=0;
tmpEnemy->impact[i].setPos(tmpEnemy->x,tmpEnemy->y );
// tmpEnemy->impact[i].setDxDy(0, 0);
}*/
}
for(int k=0;k<10;k++)
{ for(int i=0;i<gish.N;i++)
if(Dist(&gish.medium(), &tmpEnemy->impact[k])<tmpEnemy->radius + 20)
{
gish.H -= minirand()*10;
tmpEnemy->impact[k].H=0;
tmpEnemy->impact[k].setPos(tmpEnemy->x,tmpEnemy->y );
// tmpEnemy->impact[i].setDxDy(0, 0);
}
if(weapon[BOMB].active && Dist(&weapon[BOMB],&tmpEnemy->impact[k])<weapon[BOMB].radius)
{
weapon[BOMB].health-= minirand()*3;
tmpEnemy->impact[k].H=0;
tmpEnemy->impact[k].setPos(tmpEnemy->x,tmpEnemy->y );
}
}
}
}
gish.Red = false;
if(gish.H < gish.oldH)
{
gish.color[0] = 1;
gish.color[1] = 0;
gish.color[2] = 0;
}
else
{
gish.color[0] = 1;
gish.color[1] = 1;
gish.color[2] = 1;
}
static float night_color = 0;
static bool rassvet = true;
if(night_color <= 0) rassvet = true;
if(night_color >= 1) rassvet = false;
if(rassvet) night_color+=0.0005;
else night_color-=0.0005;
// glClearColor(night_color*0.95,night_color,night_color,1);
}//if
/* if(glutGetModifiers() && GLUT_ACTIVE_SHIFT )
{
gish.SLOMO=true;
}
else gish.SLOMO=false;
*/
/* int dtimer = 1000/100;
if(gish.SLOMO)
dtimer = 1000/10;
*/
if (time_1 > 1000/100)
{
starttime1 += time_1;
static float deltaOpen[4];
static int napr=1;
static int TT = 0;
if(TT++>300) {TT=0; napr=-napr;}
MEDGISH = gish.medium();
int k;
// for(int k=0; k<10; k++)
// weapon[k].setPos(0, 0);
if(curDescI >=0 && curDescI <100 && curDescJ >=0 && curDescJ <100)
{
int k=0;
for(int i=curDescI; k<4; i++, k++ )
{
if(i>=0 && i<100)
researched[i][curDescJ] = true;
if( dat[i][curDescJ] == '0' || dat[i][curDescJ] == 'W') {}
else break;
}
k=0;
for(int i=curDescI, k=0; k<4; i--, k++ )
{
if(i>=0 && i<100)
researched[i][curDescJ] = true;
if( dat[i][curDescJ] == '0' || dat[i][curDescJ] == 'W') {}
else break;
}
k=0;
for(int j=curDescJ; k<4; j++, k++ )
{
if(j>=0 && j<100)
researched[curDescI][j] = true;
if( dat[curDescI][j] == '0' || dat[curDescI][j] == 'W') {}
else break;
}
k=0;
for(int j=curDescJ; k<4; j--, k++ )
{
if(j>=0 && j<100)
researched[curDescI][j] = true;
if( dat[curDescI][j] == '0' || dat[curDescI][j] == 'W') {}
else break;
}
for(int i=curDescI-1; i<curDescI+2; i++)
for(int j=curDescJ-1; j<curDescJ+2; j++)
{
if( dat[i][j] != '0' )
break;
if(i>=0 && i<100 && j>=0 && j<100)
researched[i][j] = true;
}
}
// if(gish.LIP)
for(int i=0;i<gish.N;i++)
for(int k=0;k<MAXWEAPONTYPES;k++)
if(k!=gish.currentWeapon && k!=BOMB
&& weapon[gish.currentWeapon].y > weapon[k].y
&& Dist(&weapon[gish.currentWeapon],&weapon[k]) < weapon[k].radius*2.2 )
{
weapon[gish.currentWeapon].setPos(gish.medium().x, gish.medium().y+70);
gish.currentWeapon = k;
i=gish.N;
k=MAXWEAPONTYPES;
}
if(gish.currentWeapon!=BOMB )
weapon[gish.currentWeapon].setPos(gish.medium().x, gish.medium().y);
for(int i=0;i<gish.N;i++)
{
if(Dist(gish.bui[i], gish.bui[gish.soot(i)]) < 20 )
gish.H -= 1;
for(int k=0; key[k].corrected(); k++)
if(Dist(gish.bui[i], &key[k]) < key[k].radius*1.1 )
{ key[k].setSpirit(true);
// key[k].setMassive(false);
}
// else
// { key[k].setSpirit(false);
// key[k].setMassive(true);
// }
}
for(int k=0; key[k].corrected(); k++)
{
if(key[k].spirit)
key[k].setPos(gish.bui[key[k].NUM]->x , gish.bui[key[k].NUM]->y);
}
Collisions();
int ENEMY_ACTUAL_COUNT = n_enemy_actual.size();
for(int n = 0; n < ENEMY_ACTUAL_COUNT; n++)
{
enemy[n_enemy_actual[n]].Controller();
enemy[n_enemy_actual[n]].InvalidateView();
// iter_enemy->Move();
}
float dist = Dist(gish.medium(),ToPointF(crossX,crossY));
float impactVectorX = ( crossX - gish.medium().x ) / dist;
float impactVectorY = ( crossY - gish.medium().y ) / dist;
weapon[gish.currentWeapon].setImpactVector(impactVectorX,impactVectorY);
/* if(weapon[gish.currentWeapon].fire)
{
for(int i=0;i<gish.N ;i++)
{// gish.bui[i]->CalcVector();
gish.bui[i]->setDxDy(0,0);
// gish.bui[i]->CalcDxDy();
gish.bui[i]->Move();
}
for(int i=0;i<gish.N ;i++)
{
gish.bui[i]->CalcVector();
gish.bui[i]->FMove.addImpulse
(-weapon[gish.currentWeapon].impactVectorX,
-weapon[gish.currentWeapon].impactVectorY );
gish.bui[i]->CalcDxDy();
gish.bui[i]->Move();
}
}*/
Building* currBall;
int o = 0;
for(pBall=ball.begin(); pBall!=ball.end(); pBall++, o++)
{
currBall = &ball.at(o);
for(int j = 0; j < ENEMY_ACTUAL_COUNT; j++)
{
Enemy *tmpEnemy;
tmpEnemy = &enemy[n_enemy_actual[j]];
if(Dist(currBall,(Unit*)tmpEnemy)<tmpEnemy->radius+pBall->radius)
{
tmpEnemy->health = 0;
}
}
}
for(int k=0; k<10; k++)
{ if(k==SUPER_WEAPON)
{
if(weapon[k].fire)
for(int i=0;i<20;i++)
ball[i].setMassive(-1);
else
for(int i=0;i<20;i++)
ball[i].setMassive(1);
}
if(weapon[k].fire)
{
if(k == GRENADE || k==BLASTER || k==ROCKET_LAUNCHER)
{
int ENEMY_ACTUAL_COUNT = n_enemy_actual.size();
for(int j = 0; j < ENEMY_ACTUAL_COUNT; j++)
{
if( enemy[n_enemy_actual[j]].health>0)
{
Enemy *tmpEnemy;
tmpEnemy = &enemy[n_enemy_actual[j]];
for(int i=0;i<10;i++)
{
if(weapon[k].impact[i].H > 0 )
{
if(Dist(&weapon[k].impact[i],tmpEnemy)<tmpEnemy->radius)
{
tmpEnemy->health -= 25;
weapon[k].impact[i].H=0;
}
}
// for(int i=0;i<10;i++)
// if(Dist(ToPointF(gish.bui[i]->x,gish.bui[i]->y) ,
// ToPointF(tmpEnemy->impact[i].x,tmpEnemy->impact[i].y)
// )<gish.bui[i]->radius+35)
// {
// gish.H -= 0.1;
// tmpEnemy->impact[i].H=0;
// tmpEnemy->impact[i].setPos(100000000, 100000000);
// tmpEnemy->impact[i].setDxDy(0, 0);
// }
}
}
}
}
else if(weapon[k].impact[0].H > 0)
{
for(int i=0; i<10; i++)
{
if(weapon[k].impact[i].x == 0)
continue;
PointF A = ToPointF(
weapon[k].impact[0].x,
weapon[k].impact[0].y);
PointF B = ToPointF(
weapon[k].impact[i].x,
weapon[k].impact[i].y);
int ENEMY_ACTUAL_COUNT = n_enemy_actual.size();
float dist = 10000000000;
int numnearEnemy = -1;
for(int j = 0; j < ENEMY_ACTUAL_COUNT; j++)
{
// if(enemy[n_enemy_actual[j]].health>0)
{
float curdist = Dist( (PointF)enemy[n_enemy_actual[j]], A) ;
if( curdist < dist
&& CircleIntersects(
&enemy[n_enemy_actual[j]].x,
&enemy[n_enemy_actual[j]].y,
enemy[n_enemy_actual[j]].radius,
Dist(A, B), A, B))
{ dist = curdist;
numnearEnemy = n_enemy_actual[j];
}
}
}
if(numnearEnemy > -1)
{
enemy[numnearEnemy].health -= 3;
// enemy[numnearEnemy].CalcVector();
// enemy[numnearEnemy].setDxDy(0,0);
// enemy[numnearEnemy].CalcDxDy();
// enemy[numnearEnemy].Move();
enemy[numnearEnemy].CalcVector();
// enemy[numnearEnemy].setDxDy(weapon[k].impactVectorX*0.3 ,weapon[k].impactVectorY*0.3);
enemy[numnearEnemy].FMove.addImpulse(weapon[k].impactVectorX*0.7 ,weapon[k].impactVectorY*0.7 );
enemy[numnearEnemy].CalcDxDy();
enemy[numnearEnemy].Move();
;
// weapon[k].impact[0].H = 0;
}
}
}
}
}
}
}catch(int){}
}
bool levelFreeSpace(char c)
{
return (c=='0' || c=='W');
}
void CreateLines(char *path)
{
ball.clear();
NUM_TR = 0;
FILE *fp;
/* prim[num].set(ToPointF(-limitX/2,0), ToPointF(limitX+limitX/2,0),ToPointF(limitX/2,-4000), 120,num++);
prim[num].set(ToPointF(0,limitY), ToPointF(0,-limitY/2), ToPointF(-4000,limitY/2), 120,num++);
prim[num].set(ToPointF(limitX,-limitY/2), ToPointF(limitX,limitY), ToPointF(limitX+4000,limitY/2), 120,num++);
*/
colorGeo[0] = minirand();
colorGeo[1] = minirand();
colorGeo[2] = minirand();
colorWalk[0] = 1-minirand()*0.5;
colorWalk[1] = 1-minirand()*0.5;
colorWalk[2] = 1-minirand()*0.5;
for(int n=0;n<100;n++)
for(int m=0;m<100; m++)
{
lightColor[n][m][0] = 1-minirand()*0.5;
lightColor[n][m][1] = 1-minirand()*0.5;
lightColor[n][m][2] = 1-minirand()*0.5;
researched[n][m] = false;
}
for(int i=0;i<10;i++)
weapon[i].set(i);
for(int i=0; i< enemyCount; i++)
{
enemy[i].correct=false;
enemy[i].setPos(4000000,4000000);
}
// int NUMPRIMS = prim.size();
for(int n = 0; n<MAXPRIMCOUNT; n++)
{
prim[n].type = 0;
prim[n].A.x = 3000000;
prim[n].B.x = 1000000;
prim[n].C.x = 2000000;
prim[n].A.y = 3000000;
prim[n].B.y = 4000000;
prim[n].C.y = 5000000;
prim[n].line[0].a.x = 10000000;
prim[n].line[0].a.y = 20000000;
prim[n].line[0].b.x = 10000000;
prim[n].line[0].b.y = 20000000;
prim[n].line[1].a.x = 10000000;
prim[n].line[1].a.y = 20000000;
prim[n].line[1].b.x = 10000000;
prim[n].line[1].b.y = 20000000;
prim[n].line[2].a.x = 10000000;
prim[n].line[2].a.y = 20000000;
prim[n].line[2].b.x = 10000000;
prim[n].line[2].b.y = 20000000;
prim[n].typeOfImpact = GOOD;
}
int minLevelI = 100;
int minLevelJ = 100;
int maxLevelI = 0;
int maxLevelJ = 0;
if(path[0]!=0)
{
cout << path[0];
fp=fopen(path,"r");
// return;
int j;
for(int j=0; j<100; j++)
for(int i=0; i<100; i++)
dat[i][j] = '1';
for(int j=0; j<100; j++)
for(int i=0; i<100; i++)
dat[i][j] = '0';
for(int j=0; j<100; j++)
{ for(int i=0; i<100; i++)
{
dat[i][j] = getc(fp);
}
getc(fp);
}
int counter = 0;
int num = 0;
float redcol=0.75,greencol=0.75,bluecol=0.75;
int ienem=0;
int icheck = 0;
enemyCount = 0;
doorCount = 0;
keyCount = 0;
itemCount = 0;
for(int j=0; j<100; j++)
{
for(int i=0; i<100; i++)
{
// if((counter++)>1000)
// {counter = 0;
// redcol=1-minirand()*0.7;
// greencol=1-minirand()*0.7;
// bluecol=1-minirand()*0.7;
// }
int I = i;
int J = j;
char c = '0';
c= dat[i][j];
PointF A = ToPointF(I*SIZE1, limitY - J*SIZE2);
PointF B = ToPointF(I*SIZE1, limitY - J*SIZE2+SIZE2);
PointF C = ToPointF(I*SIZE1 + SIZE1, limitY - J*SIZE2+SIZE2);
PointF D = ToPointF(I*SIZE1 + SIZE1, limitY - J*SIZE2);
PointF E;
E.x = (A.x + D.x) / 2;
E.y = A.y-SIZE2/2;
PointF A0 = ToPointF(I*SIZE1, limitY - J*SIZE2);
PointF B0 = ToPointF(I*SIZE1, limitY - J*SIZE2+SIZE2);
PointF C0 = ToPointF(I*SIZE1 + SIZE1, limitY - J*SIZE2+SIZE2);
PointF D0 = ToPointF(I*SIZE1 + SIZE1, limitY - J*SIZE2);
if(c!='0')
{
if(I > maxLevelI) maxLevelI = I;
if(J > maxLevelJ) maxLevelJ = J;
if(I < minLevelI) minLevelI = I;
if(J < minLevelJ) minLevelJ = J;
}
if(c == '1' || c == 'I' || c == 's' || c== 'F')
{
desc[i][j].num1 = num;
desc[i][j].num2 = num+1;
if(c=='1')
{
prim[num].set(GEO, A ,B ,C,WIDTH,true,num);
num++;
prim[num].set(GEO,C ,D ,A,WIDTH,true,num);
num++;
}
else if(c=='I')
{
prim[num].set(ICE, A ,B ,C,WIDTH,true,num);
num++;
prim[num].set(ICE,C ,D ,A,WIDTH,true,num);
num++;
}
else if(c=='s')
{
prim[num].set(SAND, A ,B ,C,WIDTH,true,num);
num++;
prim[num].set(SAND, C ,D ,A,WIDTH,true,num);
num++;
}
else if(c=='F')
{
// forbombPoint = A;
prim[num].set(FORBOMB, A ,B ,C,WIDTH,true,num);
forbombPoint.x = (prim[num].B.x + prim[num].C.x)/2;
forbombPoint.y = (prim[num].B.y + prim[num].C.y)/2;
num++;
prim[num].set(FORBOMB, C ,D ,A,WIDTH,true,num);
num++;
}
prim[num-2].setColor(redcol,greencol,bluecol,1,1);
prim[num-1].setColor(redcol,greencol,bluecol,1,1);
if(dat[i-1][j]==c && dat[i][j-1]==c &&
dat[i+1][j]==c && dat[i][j+1]==c &&
i>=0 && i<100 && j>=0 && j<100 )
{
prim[num-1].isDepth = true;
prim[num-2].isDepth = true;
}
}
if(c == 'W')
{
desc[i][j].num1 = num;
desc[i][j].num2 = num+1;
prim[num].set(HYDRO, A0 ,B0 ,C0,WIDTH,true, num);
prim[num].setColor(0,0.7,0.6,.4);
num++;
prim[num].set(HYDRO, C0 ,D0 ,A0,WIDTH,true, num);
prim[num].setColor(0,0.7,0.6,.4);
num++;
// prim[num-2].uppest = (dat[i][j-1]==' ' || dat[i][j-1]=='0');
prim[num-2].uppest = dat[i][j-1]!='W';
}
if(c == 'L')
{ desc[i][j].num1 = num;
desc[i][j].num2 = num+1;
prim[num].set(HYDRO,A0 ,B0 ,C0,WIDTH,true,num);
prim[num].typeOfImpact = EVIL;
prim[num].setColor(1,0,0,.5);
num++;
prim[num].set(HYDRO,C0 ,D0 ,A0,WIDTH,true,num);
prim[num].typeOfImpact = EVIL;
prim[num].setColor(1,0,0,.5);
num++;
prim[num-2].uppest = (dat[i][j-1]!='L');
// prim[num].uppest = dat[i][j-1]!='W';
}
/* if(c == 'X')
{
thpick.push_back(ThornPrickle(A ,B ,C,WIDTH,true,num++);
thpick.push_back(ThornPrickle(C ,D ,A,WIDTH,true,num++);
(thpick.end()-2)->setColor(0,0,0,.5,1);
(thpick.end()-1)->setColor(0,0,0,.5,1);
}*/
if(c == '2')
{ desc[i][j].num1 = num;
prim[num].set(GEO,A ,B ,C,WIDTH,false,num);
prim[num].setColor(redcol,greencol,bluecol,1,true);
num++;
if(i<100 && dat[i+1][j]=='W')
{
prim[num].set(HYDRO, C0 ,D0 ,A0,WIDTH,false, num);
prim[num].setColor(0,0.7,0.7,.4);
desc[i][j].num2 = num;
num++;
}
}
if(c == '3')
{ desc[i][j].num1 = num;
prim[num].set(GEO, A ,B ,D,WIDTH,false,num);
prim[num].setColor(redcol,greencol,bluecol,1,true);
num++;
if(i<100 && dat[i+1][j]=='W')
{
prim[num].set(HYDRO,D0 ,B0 ,C0,WIDTH,false,num);
prim[num].setColor(0,0.7,0.7,.4);
desc[i][j].num2 = num;
num++;
}
}
if(c == '4')
{
if(i>0 && dat[i-1][j]=='W')
{
desc[i][j].num1 = num;
prim[num].set(HYDRO,A ,B ,D,WIDTH,false,num);
prim[num].setColor(0,0.7,0.7,.4);
num++;
}
prim[num].set(GEO, D, B , C,WIDTH,false,num++);
prim[num].setColor(redcol,greencol,bluecol,1,true);
desc[i][j].num2 = num;
num++;
}
if(c == '5')
{
prim[num].set(GEO,C ,D ,A,WIDTH,false,num);
prim[num].setColor(redcol,greencol,bluecol,1,true);
desc[i][j].num1 = num;
num++;
if(i>0 && dat[i-1][j]=='W')
{
prim[num].set(HYDRO,A0 ,B0 ,C0,WIDTH,false,num);
prim[num].setColor(0,0.7,0.7,.4);
desc[i][j].num2 = num;
num++;
}
}
if(c == '6')
{ desc[i][j].num1 = num;
prim[num].set(ICE,A ,B ,C,WIDTH,false,num);
prim[num].setColor(redcol,greencol,bluecol,1,true);
num++;
if(i<100 && dat[i+1][j]=='W')
{
prim[num].set(HYDRO, C0 ,D0 ,A0,WIDTH,false, num);
prim[num].setColor(0,0.7,0.7,.4);
desc[i][j].num2 = num;
num++;
}
}
if(c == '7')
{ desc[i][j].num1 = num;
prim[num].set(ICE, A ,B ,D,WIDTH,false,num);
prim[num].setColor(redcol,greencol,bluecol,1,true);
num++;
if(i<100 && dat[i+1][j]=='W')
{
prim[num].set(HYDRO,D0 ,B0 ,C0,WIDTH,false,num);
prim[num].setColor(0,0.7,0.7,.4);
desc[i][j].num2 = num;
num++;
}
}
if(c == '8')
{
if(i>0 && dat[i-1][j]=='W')
{
desc[i][j].num1 = num;
prim[num].set(HYDRO,A ,B ,D,WIDTH,false,num);
prim[num].setColor(0,0.7,0.7,.4);
num++;
}
prim[num].set(ICE, D, B , C,WIDTH,false,num++);
prim[num].setColor(redcol,greencol,bluecol,1,true);
desc[i][j].num2 = num;
num++;
}
if(c == '9')
{
prim[num].set(ICE,C ,D ,A,WIDTH,false,num);
prim[num].setColor(redcol,greencol,bluecol,1,true);
desc[i][j].num1 = num;
num++;
if(i>0 && dat[i-1][j]=='W')
{
prim[num].set(HYDRO,A0 ,B0 ,C0,WIDTH,false,num);
prim[num].setColor(0,0.7,0.7,.4);
desc[i][j].num2 = num;
num++;
}
}
if(c == 'R') { door[doorCount].set(GEO,E, B, C,WIDTH,false,RED); doorCount++;}
if(c == 'G') { door[doorCount] .set(GEO,E, B, C,WIDTH,false,GREEN);doorCount++;}
if(c == 'B') { door[doorCount].set(GEO,E, B, C,WIDTH,false,BLUE); doorCount++;}
if(c == 'Y') { door[doorCount].set(GEO,E, B, C,WIDTH,false,YELLOW);doorCount++;}
if(c == 'r') { key[keyCount].set(RED,I*SIZE1+75,limitY - J*SIZE2+75);keyCount++;}
if(c == 'g') { key[keyCount]. set(GREEN,I*SIZE1+75,limitY - J*SIZE2+75);keyCount++;}
if(c == 'b') { key[keyCount].set(BLUE,I*SIZE1+75,limitY - J*SIZE2+75);keyCount++;}
if(c == 'y') { key[keyCount].set(YELLOW,I*SIZE1+75,limitY - J*SIZE2+75);keyCount++;}
if(c == 'S')
{
startLevel.x = I*SIZE1+75;
startLevel.y = limitY - J*SIZE2+75;
respawnPoint = startLevel;
gish.SetPos(I*SIZE1+75,limitY - J*SIZE2+75);
item[itemCount].setPos(I*SIZE1+60, limitY - J*SIZE2+60);
item[itemCount].setType(HEALTH);
itemCount++;
}
if(c == 't' )
{
int enT = TURRET;
enemy[ienem++].set(enT,I*SIZE1+SIZE1/2, limitY - J*SIZE2+SIZE2/2);enemyCount++;
// int count = rand()%5;
// if(enT != TURRET)
// for(int cn=0; cn<count; cn++)
// enemy[ienem++].set(enT,I*SIZE1+SIZE1/2, limitY - J*SIZE2+SIZE2/2);
}
if (c == '@')
{
weapon[BOMB].set(BOMB);
weapon[BOMB].setPos(I*SIZE1+SIZE1/2, limitY - J*SIZE2+SIZE2/2);
}
if (c == '!')
{
weapon[DETONATOR].set(DETONATOR);
weapon[DETONATOR].setPos(I*SIZE1+SIZE1/2, limitY - J*SIZE2+SIZE2/2);
}
if(c == 'e' )
{
int enT = rand()%_MAX_ENEMY_TYPE_;
enemy[ienem++].set(enT,I*SIZE1+SIZE1/2, limitY - J*SIZE2+SIZE2/2);enemyCount++;
}
if(c == 'E')
{ exitLevel.x = I*SIZE1+60;
exitLevel.y = limitY - J*SIZE2+60;
}
}
// getc(fp);
}
fclose(fp);
fp = NULL;
}
else
{
int num=0;
for(int i=0;i<50;i++)
{ int x1= rand () %(int)limitX;
int x2= x1+100+rand()%1000;
int y1 = rand () %(int)limitY;
int y2 = y1+100+rand ()%1000;
prim[num].set(GEO, ToPointF(MIN(x1,x2),limitY-y1),
ToPointF(MAX(x1,x2),limitY-y1+rand()%150-75),
ToPointF((x1+x2)/2+rand()%700-350,limitY-y2),
120,false,num++);
prim[num].setColor(minirand(),
minirand(),
minirand(),1,true);
}
}
// MMM:
// CreateLevel();
/*
PISTOL 1
GUN 2
AUTOMAT 3
GRENADE 4
MACHINE_GUN 5
BLASTER 6
ROCKET_LAUNCHER 7
SUPER_WEAPON 8
*/
// weapon[LAMP].setPos(gish.medium().x-150, gish.medium().y+100);
/// for(int i=0; door[i].corrected(); i++)
// cout<<i<<endl;
for(int i=0;i<MAXWEAPONTYPES-1;i++)
{
if(i!=BOMB)
if(i!=DETONATOR)
weapon[i].setPos(
interrRand(minLevelI,maxLevelI)*SIZE1+60,
(100-interrRand(minLevelJ,maxLevelJ))*SIZE2+60);
}
/*
if(levelFreeSpace(c)
&& dat[i][j+1] !='0'
&& ( dat[i][j-1] !='0' || dat[i][j-2] !='0')
a // && ( !levelFreeSpace(dat[i][j-1]) || !levelFreeSpace(dat[i][j-2]) )
)*/
{
for(int icheck=0;icheck<CHECKPOINT_COUNT;icheck++)
{
checkPoint[icheck].setPos(
interrRand(minLevelI,maxLevelI+10)*SIZE1+60,
(100-interrRand(minLevelJ,maxLevelJ+10))*SIZE2+60);
}
for(int itemCount=0;itemCount<MAXITEMS;itemCount++)
{
item[itemCount].setPos(
interrRand(minLevelI,maxLevelI+10)*SIZE1+60,
(100-interrRand(minLevelJ,maxLevelJ+10))*SIZE2+60);
item[itemCount].setType(HEALTH);
}
}
for(int g=0;g<20;g++)
{
ball.push_back(Building(weapon[SUPER_WEAPON].x+g,weapon[SUPER_WEAPON].y+10,10,g));
ball[g].setInertion(0.99);
// if(g<12)ball[g].setMassive(-1);
// else
ball[g].setMassive(0);
ball[g].setFriction(false);
ball[g].cred = 0.1;
ball[g].cgreen = 0;
ball[g].cblue = 0;
}
ball[19].setMassive(1);
playing = true;
}
void myInit()
{
srand ((unsigned)time(NULL));
CreateLines((char*)levelManager.nextLevel("mapscript.dat").c_str());
scene.font.CreateOpenGLFont("Verdana",12);
scene.fontBig.CreateOpenGLFont("Verdana",30);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(viewAngle, (float)winW / (float)(winH), 5, ZFAR);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_NORMALIZE);
glEnable(GL_SCISSOR_TEST);
ShowCursor(false);
}
void myReshape(int width, int height)
{
// glViewport(0, 0, width, height);
}
bool console_mode=false;
void myKeyboardDown(unsigned char key, int x, int y)
{
static int n=0;
if(key == 27)
{
glDeleteLists(888,1);
exit(0);
}
if(!console_mode)
{
if(key == 'a' || key == 'ั') moveLEFT_2 = true;
if(key == 'd' || key == 'ะฒ') moveRIGHT_2 = true;
if(key == 'w' || key == 'ั') moveUP_2 = true;
if(key == 's' || key == 'ั') moveDOWN_2= true;
if(key == 'r' || key == 'ะบ' )
{
cameraHeroOrientation = false;
/* for(int i=0;i <enemyCount;i++)
{ enemy[i].setSpirit(true);
enemy[i].setType(FLY);
}*/
}
if(key == 'p' || key == 'ะท' )
{
pauseMode = !pauseMode;
}
if(weapon[BOMB].active) {
if(key == 'q' || key == 'ะน' ) {
if((gish.H - 10)>0)
{ gish.H -= 10;
weapon[BOMB].health +=10;
}
}
if(key == 'e' || key == 'ั' ) {
if((weapon[BOMB].health - 10)>0)
{ weapon[BOMB].health -= 10;
gish.H +=10;
}
}
}
//SLOMO_K = 5;
/* if(key == 'l')
{
static bool day = true;
day = !day;
if(day)
{ setDay();
}
else
{
// setNight();
}
}*/
// if(key >= 48 && key <=57)
// gish.currentWeapon = key - 48;
if(key == 32) jump = true;
/* if(key == 'l' || key == 'z') gish.LIP = true;
if(key == 'k') gish.SKOL = true;
if(key == 'x') gish.TVER = true;
if(key == 'h') gish.FIRE = true;
*/
if( key == 'm' )
{ /*glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-winW*7, winW*7, -winH*7, winH*7,1,ZFAR);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
DEBUG_MODE=true;*/
// ORTHO = true;
isMap = !isMap;
}
/* else if(key == 'p' || key == 'm')
{ glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(viewAngle, (float)winW / (float)winH, 5, ZFAR);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
DISTANCETOSCENE = 1400;
// DEBUG_MODE=false;
}
*/
if(key == 'y') SH1 = !SH1;
}
else
{
if(key==13)
{command[n] = '\0';n=0;
if(strstr(command,"maps"))
{
CreateLines(command);
levelManager.numCurrentLevel--;
}
if(strstr(command,"noclip"))
{
noclipMode = !noclipMode;
}
console_mode = false;
}
else if (key==8)
{
if(n>0) n--;
for(int i=n;i<100;i++ )
command[i] = '\0';
}
else
{
command[n] = key;
n++;
}
}
if(key == '`')
{console_mode = !console_mode;
n=0;
for(int i=0;i<strlen(command);i++)
command[i]=0;
}
}
void MyMouseFunc()
{
POINT p;
GetCursorPos( &p );
SetCursorPos( winW >> 1, winH >> 1 );
ZROT -= (((winH >> 1) - p.y )*0.3);
YROT += (((winW >> 1) - p.x )*0.3);
if(ZROT > 360) ZROT = 0;
if(ZROT < 0) ZROT = 360;
if(YROT > 360) YROT = 0;
if(YROT < 0) YROT = 360;
}
void MouseButton(int key,int state,int x,int y)
{
if(key==GLUT_LEFT_BUTTON)
{
if(state==GLUT_DOWN)
{
weapon[gish.currentWeapon].startFire();
}
if(state==GLUT_UP)
{
weapon[gish.currentWeapon].endFire();
}
}
if(key==GLUT_RIGHT_BUTTON)
{
if(state==GLUT_UP)
{gish.LIP = false;
}
if(state==GLUT_DOWN)
{gish.LIP = true;
}
}
if(key==GLUT_MIDDLE_BUTTON)
{
if(state==GLUT_UP)
{gish.TVER = false;
}
if(state==GLUT_DOWN)
{gish.TVER = true;
}
}
}
void myKeyboardUp(unsigned char key, int x, int y)
{
if(key == 27) exit(0);
if(!console_mode)
{
if(key == 'a' || key == 'ั') moveLEFT_2 = false;
if(key == 'd' || key == 'ะฒ') moveRIGHT_2 = false;
if(key == 'w' || key == 'ั') moveUP_2 = false;
if(key == 's' || key == 'ั') moveDOWN_2= false;
if(key == 'l' || key == 'z') gish.LIP = false;
if(key == 'k') gish.SKOL = false;
if(key == 'x') gish.TVER = false;
if(key == 'h') gish.FIRE = false;
// if(key == 'e' || key == 'ั' ) SLOMO_K = 1;
if(key == 'r' || key == 'ะบ' ) cameraHeroOrientation = true;
if(key == 32) jump = false;
}
}
void mySpecUp( int key,int x, int y)
{
if(key == GLUT_KEY_LEFT) moveLEFT = false;
if(key == GLUT_KEY_RIGHT) moveRIGHT = false;
if(key == GLUT_KEY_UP) moveUP = false;
if(key == GLUT_KEY_DOWN) moveDOWN= false;
}
void mySpecDown(int key, int x, int y)
{
if(key == GLUT_KEY_LEFT) moveLEFT = true;
if(key == GLUT_KEY_RIGHT) moveRIGHT = true;
if(key == GLUT_KEY_UP) moveUP = true;
if(key == GLUT_KEY_DOWN) moveDOWN= true;
}
void myDisplay();
void timer(int value)
{
if (value == 1)
{
MessageBox(NULL,"sdfsd","sesdef",0);
//glutTimerFunc(3000, timer, 1);
}
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
// glutGameModeString("1024x768:32");
int screenW = winW = glutGet(GLUT_SCREEN_WIDTH);//GetSystemMetrics(SM_CXSCREEN);
int screenH = winH = glutGet(GLUT_SCREEN_HEIGHT);//GetSystemMetrics(SM_CYSCREEN);
// winW -= 8;
// winH -= 100;
if(argc == 1)
glutEnterGameMode();
else {
glutInitWindowSize(winW, winH);
glutInitWindowPosition(screenW/2-winW/2, 0);
glutCreateWindow("Game. Demo from Useinov Evgeni");
}
// glutEnterGameMode();//////////////////////////
// glutFullScreen();
glutDisplayFunc(myDisplay);
glutReshapeFunc(myReshape);
glutKeyboardFunc(myKeyboardDown);
glutKeyboardUpFunc(myKeyboardUp);
glutSpecialFunc(mySpecDown);
glutSpecialUpFunc(mySpecUp);
glutMouseFunc (MouseButton); myInit();
// glutTimerFunc(3000, timer, 1);
glutIdleFunc(myIdle);
setDay();
//if(minirand()>0.5)setDay();
//else
// setNight();
spisok();
HKL hKbLayout = NULL;
char szName[9];
DWORD dwLangID = MAKELANGID( LANG_ENGLISH,
SUBLANG_ENGLISH_US );
wsprintf( szName, "%8.8X", dwLangID );
hKbLayout = LoadKeyboardLayout( szName, KLF_REPLACELANG );
glutMainLoop();
if ( hKbLayout )
{
ActivateKeyboardLayout( (HKL)HKL_NEXT, 0 );
UnloadKeyboardLayout( hKbLayout );
}
getch();
return 0;
}
float t=0;
static float a = 0;
void ShowUnits()
{
ShowGish(&gish);
for(int i=0;i<MAXWEAPONTYPES;i++)
{
if(underCameraUnit (weapon[i], camera,12) && researchedUnit(weapon[i]))
ShowWeaponWithImpacts(&weapon[i]);
}
if(researchedUnit(exitLevel))
ShowExit(&exitLevel);
for(int n=0;n<CHECKPOINT_COUNT; n++)
{
if(underCameraUnit (checkPoint[n], camera,12) && researchedUnit(checkPoint[n]))
ShowCheckPoint(&checkPoint[n]);
}
for(int n=0;n<itemCount; n++)
{
if(underCameraUnit (item[n], camera,12) && researchedUnit(item[n]))
ShowItem(&item[n]);
}
int ENEMY_ACTUAL_COUNT = n_enemy_actual.size();
for(int n = 0; n < ENEMY_ACTUAL_COUNT; n++)
{ // if( enemy[n_enemy_actual[n]].health>0)
pum
if(underCameraUnit (enemy[n_enemy_actual[n]], camera,12) && researchedUnit(enemy[n_enemy_actual[n]]))
ShowEnemy(&enemy[n_enemy_actual[n]]);
pom
ShowEnemyImpacts(&enemy[n_enemy_actual[n]]);
}
pum
for(int i = 0; i<keyCount; i++)
{
ShowKey(&key[i]);
}
pom
}
void displayByCamera(PointF cameraPos, int interval, int area)
{
glLoadIdentity ();
pum;
YROT = -MousePosX(winW)*0.08;
XROT = MousePosY(winH)*0.1;
glTranslatef(0,0 ,-(DISTANCETOSCENE - (DISTANCETOSCENE/3)));
if(interval==0){
glRotatef(-XROT+5,1,0,0);
glRotatef(-YROT,0,1,0);
}
glTranslatef(0,0 ,-(DISTANCETOSCENE/3));
if(isMap)
glScalef(0.3,0.3,0.3);
camera = cameraPos;
glTranslatef(-cameraPos.x ,-cameraPos.y ,0);
for(int nl=0; nl<8;nl ++)
glDisable(GL_LIGHT0+nl);
// loff
int lightNumber = 1;
setLocalLight(lightNumber,
gish.medium().x,
gish.medium().y ,
150,
1,
weapon[BOMB].health/100,
weapon[BOMB].health/100,
0.000001 );
lightNumber++;
if(prim[desc[curDescI][curDescJ].num2].type == HYDRO )
{// ShowWeaponWithImpacts(&weapon[LAMP]);
setLocalLight(lightNumber, gish.medium().x,gish.medium().y,180, 1,1,1, 0.0001);
lightNumber++;
}
if(weapon[BOMB].active)
{ setLocalLight(lightNumber, weapon[BOMB].x, weapon[BOMB].y ,0,
1,weapon[BOMB].health/100,weapon[BOMB].health/100,
0.00000000001 );
lightNumber++;
}
if(weapon[DETONATOR].active)
{ setLocalLight(lightNumber, weapon[DETONATOR].x, weapon[DETONATOR].y ,0,
1,0,1,
0.00001 );
lightNumber++;
}
int inerv = 25;
// if(prim[desc[curDescI][curDescJ].num2].type == HYDRO )inerv=10;
if(!weapon[BOMB].active)
for(int n = curDescI-inerv; n<=curDescI+inerv; n++)
for(int m = curDescJ-inerv; m<=curDescJ+inerv; m++)
{
// if(n > 0 && m > 0 && n < 100 && m < 100 ) {}
// else continue;
if(lightNumber<7)
{
if(((n%inerv) == 0 && (m%inerv) == 0 ) )
{
setLocalLight(lightNumber, n*SIZE1,(100-m)*SIZE2,200,
lightColor[n][m][0],lightColor[n][m][1],lightColor[n][m][2], 0.000001);
pum
glTranslatef(n*SIZE1,(100-m)*SIZE2,10);loff
glColor3f(1,1,1
// (lightColor[n][m][0]*0.5 + 0.5),
// (lightColor[n][m][1]*0.5 + 0.5),
// (lightColor[n][m][2]*0.5 + 0.5)
);
glutSolidSphere(10,8,8);lon
pom
lightNumber++;
}
} else break;
}
lon
if(playing)
{
int n;
crossX = gish.medium().x + MousePosX(winW)/2;
crossY = gish.medium().y + MousePosY(winH)/2;
pum
loff
doff
glColor3f(0,0,0);
// glLineWidth(5);
glTranslatef(crossX,crossY,10);
glLineWidth(1);
glutWireCube(20);
don
lon
pom
::ShowImpactLine(&gish);
int iii,jjj;
GetQuadCoord(&iii,&jjj,cameraPos);
pum
glBegin(GL_TRIANGLES);
for (int i = 0; i<doorCount; i++)
{
if(researchedUnit(door[i].A))
ShowDoor(&door[i]);
}
glEnd();
pom
blon
ShowUnits();
if(interval == 0)
{
pum
glTranslatef(0,0,-prim[0].Width*2);
// glScalef(1,1,-1);
ShowUnits();
pom
}
pum
glBegin(GL_TRIANGLES);
for(int n = iii-area; n<=iii+area; n++)
for(int m = jjj-area; m<=jjj+area; m++)
{
if(n >=0 && m>=0 && n<100 && m<100)
{
if(prim[desc[n][m].num1].type == GEO)
ShowPrimitive(&prim[desc[n][m].num1]);
if(prim[desc[n][m].num2].type == GEO)
ShowPrimitive(&prim[desc[n][m].num2]);
}
}
for(int n = iii-area; n<=iii+area; n++)
for(int m = jjj-area; m<=jjj+area; m++)
{
if(n >=0 && m>=0 && n<100 && m<100)
{
if(prim[desc[n][m].num1].type != GEO && prim[desc[n][m].num1].typeOfImpact == EVIL)
ShowPrimitive(&prim[desc[n][m].num1]);
if(prim[desc[n][m].num2].type != GEO && prim[desc[n][m].num2].typeOfImpact == EVIL)
ShowPrimitive(&prim[desc[n][m].num2]);
}
}
for(int n = iii-area; n<=iii+area; n++)
for(int m = jjj-area; m<=jjj+area; m++)
{
if(n >=0 && m>=0 && n<100 && m<100)
{ if( prim[desc[n][m].num1].type == FORBOMB) continue;
if(prim[desc[n][m].num1].type != GEO && prim[desc[n][m].num1].typeOfImpact == GOOD)
ShowPrimitive(&prim[desc[n][m].num1]);
if(prim[desc[n][m].num2].type != GEO && prim[desc[n][m].num2].typeOfImpact == GOOD)
ShowPrimitive(&prim[desc[n][m].num2]);
}
}
glEnd();
blon
glBegin(GL_TRIANGLES);
glColor4f(.2,.2,.2,0.7);
// glColor3f(.5, 1,.5);
int z = - prim[0].Width;
for(int n = iii-area; n<=iii+area; n++)
for(int m = jjj-area; m<=jjj+area; m++)
{
// if(n >=0 && m>=0 && n<100 && m<100)
{
// if(prim[desc[n][m].num1].type != HYDRO)
// if(!researched[n][m])
{
PointF a = ToPointF(n*SIZE1,(100-m)*SIZE2);
PointF b = ToPointF(n*SIZE1+SIZE1,(100-m)*SIZE2);
PointF c = ToPointF(n*SIZE1,(100-m)*SIZE2+SIZE2);
PointF d = ToPointF(n*SIZE1+SIZE1,(100-m)*SIZE2+SIZE2);
tr2(a.x,a.y, z,
b.x,b.y, z,
c.x,c.y, z);
tr2(b.x,b.y, z,
d.x,d.y, z,
c.x,c.y, z);
float bmx = (a.x + d.x)*0.5;
float bmy = (a.y + d.y)*0.5;
tr2(b.x,b.y,z,
bmx,bmy,z+10,
a.x,a.y,z);
tr2(
c.x,c.y,z,
bmx,bmy,z+10,
d.x,d.y,z);
}
}
}
bloff
glEnd();
loff
blon
glBegin(GL_TRIANGLES);
glColor4f(1,1,1,0.1);
z = prim[0].Width+1;
for(int n = iii-area; n<=iii+area; n++)
for(int m = jjj-area; m<=jjj+area; m++)
{
// if(n >=0 && m>=0 && n<100 && m<100)
{
// if(prim[desc[n][m].num1].type != HYDRO)
if(!researched[n][m])
{
PointF a = ToPointF(n*SIZE1,(100-m)*SIZE2);
PointF b = ToPointF(n*SIZE1+SIZE1,(100-m)*SIZE2);
PointF c = ToPointF(n*SIZE1,(100-m)*SIZE2+SIZE2);
PointF d = ToPointF(n*SIZE1+SIZE1,(100-m)*SIZE2+SIZE2);
tr2(a.x,a.y, z,
b.x,b.y, z,
c.x,c.y, z);
tr2(b.x,b.y, z,
d.x,d.y, z,
c.x,c.y, z);
/* float bmx = (a.x + d.x)*0.5;
float bmy = (a.y + d.y)*0.5;
tr2(b.x,b.y,z,
bmx,bmy,z+10,
a.x,a.y,z);
tr2(
c.x,c.y,z,
bmx,bmy,z+10,
d.x,d.y,z);*/
}
}
}
glEnd();
bloff
lon
loff
glBegin(GL_TRIANGLES);
for(int n = iii-area; n<=iii+area; n++)
for(int m = jjj-area; m<=jjj+area; m++)
{
if(n >=0 && m>=0 && n<100 && m<100)
{
if( prim[desc[n][m].num1].type == FORBOMB)
ShowPrimitive(&prim[desc[n][m].num1]);
if(prim[desc[n][m].num2].type == FORBOMB)
ShowPrimitive(&prim[desc[n][m].num2]);
}
}
glEnd();
lon
pom
//doff
for(pBall=ball.begin(); pBall!=ball.end(); pBall++)
{
pBall->Show(0,0);
}
// don
}
if(console_mode)
{
loff;
// blon;
glColor3f(1,0,0);
scene.font.glDrawText(winH,10,500,"file> %s",command);
lon;// bloff;
}
pom
}
void MyPerspective ( double FOV,double nearz,int farz)
{
glMatrixMode ( GL_PROJECTION); // ะฒัะฑะพั ะผะฐััะธัั ะฟัะพะตะบัะธะน (ะบะฐะผะตัั)
glLoadIdentity ();
gluPerspective(FOV,
(double)(winW) / (double)winH,
nearz,
farz);
glMatrixMode ( GL_MODELVIEW); // ะฒัะฑะพั ะผะฐััะธัั ะผะพะดะตะปะธ
}
int tttt=0;
void myDisplay()
{
tttt++;
if(tttt==8) tttt=0;
// MyPerspective ( 60,10,10000) ;
// glScissor ( 0, winH/4, winW, winH-(winH/4));
int granY = winH/4;
PointF camHero = gish.medium();
camHero.y += 50;
if(!cameraHeroOrientation)
camHero = forbombPoint;
// glScissor ( 0, granY, winW, winH-granY);
// glViewport( 0, 0, winW, winH);
// if(tttt!=0)
// {
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
displayByCamera(camHero,0,12);
// }
/*
*/
// glViewport( 0, granY, winW, winH-granY);
// displayByCamera(camHero,0,12);
//
// if(tttt!=0)
// glScissor ( 0, 0, winW, granY-1);
// glViewport(0, 0, winW, granY-1);
// if(tttt==0)
{
/* glScissor (0, 0, winW/4, granY-1);
glViewport(0, 0, winW/4, granY-1);
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
*/
// glViewport(0, 0, winW, granY-1);
// glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// displayByCamera(camHero,0,12);
// displayByCamera(ToPointF(weapon[BOMB].x,weapon[BOMB].y+50),10,5);
// glutSwapBuffers();
/* glScissor ((winW>>2)+100, 0,winW-(winW>>2) , winH>>2);
glViewport((winW>>2)+100, 0,winW-(winW>>2) , winH>>2);
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();*/
pum
glTranslatef(0,0,10);
loff;
glColor3f(1,0,1);
/* scene.font.glDrawText(winH,200,20,"YROT %d",(int)YROT);
scene.font.glDrawText(winH,200,30,"XROT %d",(int)XROT);
scene.font.glDrawText(winH,200,40,"curDescI %d",(int)curDescI);
scene.font.glDrawText(winH,200,50,"curDescJ %d",(int)curDescJ);
*/
glColor3f(0,1,0);
// glColor3f(0,0,0);
// scene.font.glDrawText(winH,11,151,"ะะธัะปะพัะพะด %d", (int)gish.Ox);
// glColor3f(1,1,1);
// scene.font.glDrawText(winH,10,150,"ะะธัะปะพัะพะด %d", (int)gish.Ox);
lon
glColor3f(0,0,0);
lon
pom
/**/
loff
pum
if(gish.H>0)
{
glColor3f(0,0.75,0);
glTranslatef(0,3.4,-10);
pum
glScalef(gish.H*0.01,0.05,0.1);
glutSolidCube(1);
pom
}
else
{
glColor3f(1,1,1); scene.fontBig.glDrawText(winH,150,300,"DEMO from Useinov Evgeni");
}
pum
glScalef(1,0.01,0.01);
glutSolidCube(1);
pom
if(pauseMode) {
glColor3f(1,1,1);
scene.fontBig.glDrawText(winH,winW/2,winH/2,"PAUSE");
}
// scene.font.glDrawText(winH,10,22,"Hero health %d\%%", (int)gish.H);
pom
pum
if(weapon[BOMB].active)
{
glColor3f(1,1,0);
glTranslatef(0, 3.2,-10);
pum
glScalef(weapon[BOMB].health*0.01,0.05,0.1);
glutSolidCube(1);
pom
pum
glScalef(1,0.01,0.01);
glutSolidCube(1);
pom
// scene.font.glDrawText(winH,10,72,"Bomb health %d\%%",(int)weapon[BOMB].health);
/* scene.font.glDrawText(winH,50,150,"ะฃะฟัะฐะฒะปะตะฝะธะต:");
scene.font.glDrawText(winH,50,170,"Q - ะพัะดะฐัั 10\%% ะทะดะพัะพะฒัั ะฑะพะผะฑะต");
scene.font.glDrawText(winH,50,190,"E - ะฒะทััั 10\%% ะทะดะพัะพะฒัั ั ะฑะพะผะฑั");*/
}
pom
lon
// glutSwapBuffers();
}
// else
{
// glScissor (0, 0, 320, 240);
// glViewport(0, 0, 320, 240);
// glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glScissor ( 0, 0, winW, granY-1);
// displayByCamera(camHero,0,12);
}
//if(tttt==0)
glutSwapBuffers();
// glFlush();
// glutSwapBuffers();
}
|
d2328b45a2235ae55461d826124ebe68c84171c3 | 9a7002b81fc92b5d236b70c9b39d780b3169e56c | /DigitalPotmeterMCP413/DigitalPotmeterMCP413.h | 8ae2952d5a34d70fe2b02a4cffd5e9845559b993 | [] | no_license | jantje/ArduinoLibraries | 83eb674f271715f1eed690a6efdcaed11a6a9c0a | 2948767a3a8c0bd42976e86139b94381f61ff0e6 | refs/heads/master | 2023-08-31T13:03:04.706402 | 2023-08-17T23:30:34 | 2023-08-17T23:30:34 | 6,447,136 | 13 | 15 | null | null | null | null | UTF-8 | C++ | false | false | 712 | h | DigitalPotmeterMCP413.h | /*
* MCP413.h
* This is a library for a digital pot meter MCP413
*
* Created on: Jul 11, 2014
* Author: jan
*/
#ifndef MCP413_H_
#define MCP413_H_
#include "SPI.h"
#include "DigitalPotmeterInterface.h"
#include "SerialDataInterface.h"
class DigitalPotmeterMCP413 :public DigitalPotmeterInterface
{
uint8_t mySlavePin; //the slave pin used to communicate with the MCP413
uint8_t myActualSendValue; //The actual value send over SPI
bool myInverted;
public:
DigitalPotmeterMCP413(uint8_t myMaxPotValue,uint8_t slavePin,bool inverted);
virtual void setup();
virtual void loop();
void serialRegister(const __FlashStringHelper* Name);
};
#endif /* MCP413_H_ */
|
14c98c60719dfcacb9555e0d82df689e51f6fc37 | 87fc55495c5f2ab5ef969fa53e59a2d14f6a9ec7 | /Labs/Labs/Includes/task_8/task1.cpp | ce4f2b53ef700610b033b9537c584196eec479ae | [] | no_license | PetrashkoEV/Labs | 02809c9f9f5e31f0c8ba2917090ab958828bfcdd | 2cd6b20d5080d304aea5f78c32ff7c72e64a6322 | refs/heads/master | 2021-01-11T12:16:09.539871 | 2016-12-14T21:10:07 | 2016-12-14T21:10:07 | 76,495,021 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 3,720 | cpp | task1.cpp | #include <iostream>
#include <math.h>
using namespace std;
int main ()
{
int n;
double z[50]; // ะทะฐะฒะพะดะธะผ ะผะฐััะธะฒ
cout << " ะะฒะตะดะธัะต ะบะพะปะปะธัะตััะฒะพ ัะปะตะผะตะฝัะพะฒ ะผะฐััะธะฒะฐ ";
cin >> n;
if (n>50 || n<1)
{
cout << " ะะพะปะธัะตััะฒะพ ัะปะตะผะตะฝัะพะฒ ะผะฐััะธะฒะฐ ะฒะฒะตะดะตะฝะพ ะฝะต ะฟัะฐะฒะธะปัะฝะพ. ะะพะปะธัะตััะฒะพ ัะปะตะผะตะฝัะพะฒ ะผะฐัะธะฒะฐ ะฝะต ะดะพะปะถะฝะพ ะฑััั ะะะะฌะจะ 50 !!!!!!!!!!! " << endl;
system ("pause");
return 1;
}
cout << " ะะฒะตะดะธัะต ัะปะตะผะตะฝัั ะผะฐััะธะฒะฐ " << endl;
int i;
for (int i=1; i<=n; i++)
{
cout << " ะะฒะตะดะธัะต a ["<< i <<"]="; // ะะฒะพะดะธะผ ัะปะตะผะตะฝัั ะผะฐััะธะฒะฐ
cin >> z[i];
}
// ะทะฐะดะฐะฝะธะต โ1
int c=0, w=0;
double max=0, nomer=0, maxp=z[1], maxo=z[1];
for (int j=1; j<=n; j++) // ะฟัะธ ะฟะพะผะพัะธ ัะธะบะปะฐ ะพะฟัะตะดะตะปัะตะผ ะผะฐะบัะธะผะฐะปัะฝัะน ัะปะตะผะตะฝั ะผะฐัััะธะฒะฐ ะธ ะพะฟัะตะดะตะปัะตะผ ะตะณะพ ะฝะพะผะตั
{
if ( z[j]>=0)
{
if (maxp<=z[j])
{
maxp=z[j];
c=j;
}
}
else
{
if (maxo>=z[j])
{
maxo=(-1)*z[j];
w=j;
}
}
if (maxp>=maxo)
{
max=maxp;
nomer=c;
}
else
{
max=maxo;
nomer=w;
}
}
// ะะฐะดะฝะฐะต โ2
double sum=0;
int per=0;
for (int p=1; p<=n; p++) // ะฟัะธ ะฟะพะผะพัะธ ัะธะบะปะฐ ะฒััะธัะปัะตะผ ััะผะผั ัะธัะตะป ะฟะพัะปะต ะฟะตัะฒะพะณะพ ะฟะพะปะพะถะธัะตะปัะฝะพะณะพ ัะปะตะผะตะฝัะฐ ะผะฐััะธะฒะฐ
{
if (z[p]>=0 && per>0)
{
sum+=z[p];
}
else if (z[p]>=0)
{
per++;
}
else
{
if (sum!=0)
{
sum +=z[p];
}
}
}
cout << " 1) ะะพะผะตั ะผะฐะบัะธะผะฐะปัะฝะพะณะพ ะฟะพ ะผะพะดัะปั ัะปะตะผะตะฝัะฐ ะผะฐััะธะฒะฐ = " << nomer << endl; // ะฒัะฒะพะดะธะผ ะฝะฐ ัะบัะฐะฝ ะฝะพะผะตั ะผะฐะบัะธะผะฐะปัะฝะพะณะพ ะฟะพ ะผะพะดัะปั ัะปะตะผะตะฝัะฐ ะผะฐััะธะฒะฐ
cout << " 2) ะกัะผะผะฐ ัะปะตะผะตะฝัะพะฒ ะผะฐััะธะฒะฐ, ัะฐัะฟะพะปะพะถะตะฝะฝัั
ะฟะพัะปะต ะฟะตัะฒะพะณะพ ะฟะพะปะพะถะธัะตะปัะฝะพะณะพ ัะปะตะผะตะฝัะฐ ัะฐะฒะฝะฐ "<< sum << endl; // ะฒัะฒะพะดะธะผ ะฝะฐ ัะบัะฐะฝ ััะผะผั ัะปะตะผะตะฝัะพะฒ ะผะฐััะธะฒะฐ, ัะฐัะฟะพะปะพะถะตะฝะฝัั
ะฟะพัะปะต ะฟะตัะฒะพะณะพ ะฟะพะปะพะถะธัะตะปัะฝะพะณะพ ัะปะตะผะตะฝัะฐ
// ะพัะฝะพะฒะฝะพะต ะทะฐะดะฐะฝะธะต
double a=0, b=0;
cout << " ะะฒะตะดะธัะต ะธะฝัะตัะฒะฐะป [ะฐ,b], ัะตัะตะท ะฟัะพะฑะตะป "; // ะฒะฒะพะดะธะผ ะธะฝัะตัะฒะฐะป [a,b]
cin >> a >> b;
// ะฟัะธ ะฟะพะผะพัะธ ัะธะบะปะพะฒ ะฒัะฒะพะดะธะผ ะฝะฐ ัะบัะฐะฝ ะผะฐััะธะฒ ัะฐะบะธะผ ะพะฑัะฐะทะพะผ, ััะพะฑั ัะฝะฐัะฐะปะฐ ัะฐัะฟะพะปะฐะณะฐะปะธัั ะฒัะต ัะปะตะผะตะฝัั, ัะตะปะฐั ัะฐััั ะบะพัะพััั
ะปะตะถะธั ะฒ ะธะฝัะตัะฒะฐะปะต [ะฐ,b], ะฐ ะฟะพัะพะผ โ ะฒัะต ะพััะฐะปัะฝัะต.
for (int i=1; i<=n; i++) // ัะธะบะป ะดะปั ะฒััะธัะปะตะฝะธั ะทะฝะฐัะตะฝะธะธั i.
{
float x=trunc(z[i]);
if ((x<=b) && (x>=a) )
{
cout << z[i] << " ";
}
}
for (int i=1; i<=n; i++) // ัะธะบะป ะดะปั ะฒััะธัะปะตะฝะธั ะทะฝะฐัะตะฝะธะธั i.
{
float x=trunc(z[i]);
if ( x>b || x<a )
{
cout << z[i] << " ";
}
}
system ("pause");
return 0;
}
|
f410324919ab0d6fe63b42c966402bd42fefc9c2 | ff632878f47254912d921839bffde8a51d68043c | /Project/Combat/AttachToParent.cpp | 410a739d812d479cb75dabc641ee44a015b12741 | [] | no_license | UnknownFreak/OneFlower | d1eb55b3c227cdd130c8d3e8f4e256fd86bf624b | 15d8884a97f55049d7af346dab209a37c7ebf46f | refs/heads/master | 2023-08-31T03:32:59.450862 | 2022-05-04T19:23:02 | 2022-05-04T19:23:02 | 154,447,719 | 0 | 0 | null | 2019-06-02T19:08:50 | 2018-10-24T06:06:49 | C++ | UTF-8 | C++ | false | false | 690 | cpp | AttachToParent.cpp | #include "AttachToParent.hpp"
#include <Object/GameObject.hpp>
Enums::ComponentType Component::IBase<Component::AttachToParent>::typeID = Enums::ComponentType::AttachToParent;
Core::String Component::IBase<Component::AttachToParent>::componentName = "AttachToParent";
namespace Component
{
AttachToParent::AttachToParent(GameObject* objectToFollow) : objectToFollow(objectToFollow)
{
}
void AttachToParent::Update()
{
attachedOn->getComponent<Transform>()->pos = objectToFollow->getComponent<Transform>()->buffered;
}
void AttachToParent::Simulate(const float&)
{
}
void AttachToParent::onDeath()
{
}
void AttachToParent::onCollision(Interfaces::ICollider*)
{
}
};
|
b3fc3ef732b64a9b6bd7e954f6efb0a66ad22bc1 | 2b3f654cb0ab862291055d0969e1f180add3d420 | /LN.hpp | 00cfa733ba3e38d79cb04d240a28a30500fc0bc7 | [] | no_license | MaxFanCheak/BigInteger | 4a780893ea697c1ca79348dcb80b91e7c1210a5f | 923a4a74c2c8c62990f77ee0d063d76d99a09f1c | refs/heads/main | 2023-06-16T23:09:13.403036 | 2021-07-06T13:01:16 | 2021-07-06T13:01:16 | 383,469,926 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,554 | hpp | LN.hpp | #ifndef LN_LN_H
#define LN_LN_H
#include <string_view>
using namespace std;
class LN {
public:
explicit LN(long long number = 0);
LN(LN const ©);
LN(LN &©) noexcept;
explicit LN(bool number);
explicit LN(string_view number);
explicit LN(const char *number);
~LN();
LN &operator=(LN &©) noexcept;
LN &operator=(const LN ©);
LN operator+(const LN &number) const;
LN operator-(const LN &number) const;
LN operator*(const LN &number) const;
LN operator/(const LN &number) const;
LN operator%(const LN &number) const;
LN &operator+=(const LN &number);
LN &operator-=(const LN &number);
LN &operator*=(const LN &number);
LN &operator/=(const LN &number);
LN &operator%=(const LN &number);
LN operator~() const;
LN operator-() const;
bool operator>(const LN &number) const;
bool operator==(const LN &number) const;
bool operator<(const LN &number) const;
bool operator>=(const LN &number) const;
bool operator<=(const LN &number) const;
bool operator!=(const LN &number) const;
explicit operator std::string() const;
explicit operator long long() const;
explicit operator bool() const;
private:
int *digits_ = nullptr;
unsigned int cntDigits_;
bool NaN_;
bool notPositive_;
[[nodiscard]] int compare(const LN &number) const;
[[nodiscard]] int abstractCompare(const LN &number) const;
int *add(const LN &number);
int *sub(const LN &number);
void removeZeros();
};
#endif //LN_LN_H
|
1b90c9823566e5c4d98853b132255f6c8b1fded5 | 49270729758f95b53aea5c810db6f4a3a9ef09dd | /Game.cpp | 719ddc60334e31adefd1fadb63353f1efedfdb77 | [] | no_license | originpulses/Azul | 1c9b2403ad57ec92ecb63270467cac700a7fe011 | 88185d70c461e879bdfda100120188be5bc242dc | refs/heads/master | 2022-09-26T18:37:14.806943 | 2020-06-05T12:29:18 | 2020-06-05T12:29:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 45,117 | cpp | Game.cpp | #include "Game.h"
//Function to display the main menu and take user's input
int mainMenu() {
int choice = 0;
cout << "Menu\n";
cout << "----\n";
cout << "1. New Game\n";
cout << "2. Load Game\n";
cout << "3. Credits\n";
cout << "4. Quit\n\n> ";
string input;
getline(cin, input);
if (std::cin.eof()) {
return 4;
}
char temp = (char)input[0];
choice = static_cast<int>(temp) - 48;
while ((input.size() != 1) || !(choice >= 1 && choice <= 4)) {
cout << "Invalid Input, Enter again\n";
cout << "> ";
getline(cin, input);
if (std::cin.eof()) {
return 4;
}
char temp = (char)input[0];
choice = static_cast<int>(temp) - 48;
}
return choice;
}
// To Shuffle the box of tiles
void shuffle(vector<char>& box) {
char temp = '\0';
for (size_t i = 0; i < 500; ) {
int i1 = (rand() % box.size());
int i2 = (rand() % box.size());
if (i1 != i2) {
//Swapping ranks of 2 random cards
temp = box[i2];
box[i2] = box[i1];
box[i1] = temp;
i++;
}
}
}
int countRows(char filename[]) {
int count = 0;
ifstream fin;
fin.open(filename);
if (!fin) {
cout << "Error opening the file...\n";
}
else {
char tempp = '.';
while (!fin.eof()) {
if (tempp == '\n') {
count++;
}
fin.get(tempp);
}
}
fin.close();
return count + 1; // +1 because last line contains eof character instead of '\n'
}
bool areFilesEqual(char N1[], char N2[]) {
ifstream f1(N1);
bool equals = true;
if (!f1.is_open()) {
cout << "Error opening the files to be compared...\n";
return false;
}
else {
ifstream f2(N2);
if (f2.is_open()) {
if (countRows(N1) == countRows(N2)) {
char temp1 = '\0';
char temp2 = '\0';
while (!f1.eof() && !f2.eof() && equals) {
f1.get(temp1);
f2.get(temp2);
if ((temp1 != temp2)) {
if (temp1 != '\n')
equals = false;
else
f1.get(temp1);
}
}
if (!f1.eof() || !f2.eof()) {
equals = false;
}
}
else {
equals = false;
}
}
else {
cout << "Error opening the files to be compared...\n";
return false;
}
}
return equals;
}
bool newGame(vector<char>& box, vector<char>& lid, int n_player, const int Bsize) {
//Creating factories
vector<vector<char> >factories; // Vector to save the factories
box.clear();
// Placing 20 tiles of each design/color to initialize the box
for (size_t i = 0; i < 20; i++) {
box.push_back('R'); //Red Tiles
}
for (size_t i = 0; i < 20; i++) {
box.push_back('Y'); //Yellow tiles
}
for (size_t i = 0; i < 20; i++) {
box.push_back('B'); //Blue tiles
}
for (size_t i = 0; i < 20; i++) {
box.push_back('L'); //Light blue tiles
}
for (size_t i = 0; i < 20; i++) {
box.push_back('U'); //Black tiles
}
for (size_t i = 0; i < 20; i++) {
box.push_back('O'); // Orange tiles
}
//Shuffling the initialized box
shuffle(box);
initFactories(factories, box, lid); // initializing factories
// Initializing players
Player* players = new Player[n_player];
for (int x = 0; x < n_player; x++) {
cout << "Enter a name for player " << (x + 1) << "\n> ";
cin.getline(players[x].name, 30);
if (std::cin.eof()) {
return false;
}
//Declaring the pattern board of both players
/*
. ||
. . ||
. . . ||
. . . . ||
. . . . . ||
*/
//--------------------------------------------------------------------
players[x].pattern = new char* [Bsize];
for (int i = 0; i < Bsize; i++) {
players[x].pattern[i] = new char[i + 1];
for (int j = 0; j < i + 1; j++) {
players[x].pattern[i][j] = '.';
}
}
//--------------------------------------------------------------------
//Declaring and initializing the tile board
for (int i = 0; i < Bsize; i++) {
for (int j = 0; j < Bsize; j++) {
players[x].board[i][j] = '.';
}
}
}
cout << "\nLet's Play!\n\n";
bool ret;
ret = gamePlay(box, lid, players, factories, 1, n_player, Bsize);
if (players != nullptr) {
delete[]players;
players = nullptr;
}
return ret;
}
bool loadGame(vector<char>& box, vector<char>& lid, char* name, int n_player, const int Bsize) {
ifstream fin;
fin.open(name);
if (!fin) {
throw "Exception! Error opening the file";
}
else {
if (fin.peek() == std::ifstream::traits_type::eof()) {
throw "Exception! No saved Game found...\n";
}
else {
int turn = -1;
string toBeignored = "";
getline(fin, toBeignored); //To read the comment line
getline(fin, toBeignored); //To read the comment line
//--------------------------- Going to load bag
// Removing all already present tiles (if any) from the box
//so that new tiles can be placed
box.clear();
// At last, loading the remaining box of tiles in the txt file
char tempp = '\0';
getline(fin, toBeignored, '='); //To read the comment line till the "=" sign
fin.get(tempp);
while (tempp != '\n') {
box.push_back(tempp);
fin.get(tempp);
}
//box.pop_back();
//--------------------------- Going to load lid
// Removing all already present tiles (if any) from the lid
//so that new tiles can be placed
lid.clear();
getline(fin, toBeignored, '='); //To read the comment line till the "=" sign
// Loading the tiles on the top of lid (if any)
fin.get(tempp);
while (tempp != '\n') {
lid.push_back(tempp);
fin.get(tempp);
}
//lid.pop_back();
//--------------------------- Going to load the factories
vector<vector<char> >factories; // Vector to save the factories
tempp = '\0';
for (int i = 0; i < 6; i++) {
getline(fin, toBeignored, '='); //To read the comment line till "=" sign
vector<char> fac;
fin.get(tempp);
while (tempp != '\n') {
fac.push_back(tempp); // Randomly generated tiles
fin.get(tempp);
}
factories.push_back(fac);
}
//--------------------------- Going to load the Players
Player* players = new Player[n_player];
getline(fin, toBeignored); //To read the comment line
for (int w = 0; w < n_player; w++) {
getline(fin, toBeignored, '='); //To read the comment line till the "=" sign
//Loading the names of players
fin.getline(players[w].name, 30);
int g = 0;
while (players[w].name[g] != '\0') {
g++;
}
//players[w].name[g - 1] = '\0';
players[w].name[g] = '\0';
//Now going to read the score
getline(fin, toBeignored, '='); //To read the comment line till the "=" sign
fin >> players[w].score;
fin.get(tempp);
//Loading the factory display (Triangle)
players[w].pattern = new char* [Bsize];
for (int i = 0; i < Bsize; i++) {
getline(fin, toBeignored, '='); //To read the comment line till the "=" sign
players[w].pattern[i] = new char[i + 1];
fin.get(tempp);
//it means the row is empty
if (tempp == '\n' || tempp == '-') {
for (int j = 0; j < i + 1; j++) {
players[w].pattern[i][j] = '.';
}
}
else {
int j;
for (j = 0; j < i + 1 && tempp != '\n'; j++) {
players[w].pattern[i][j] = tempp;
fin.get(tempp);
}
if (j < (i + 1)) {
while (j < (i + 1)) {
players[w].pattern[i][j] = '.';
j++;
}
}
}
}
// Now going to read the penalty tiles(if any)
// Now loading the broken tiles of both players
tempp = '\0';
getline(fin, toBeignored, '='); //To read the comment line till the "=" sign
//Broken tiles of player 1
fin.get(tempp);
while (tempp != '\n') {
players[w].broken.insert(tempp);
fin.get(tempp);
}
//Loading the tile board
//Board of player
for (int i = 0; i < Bsize; i++) {
getline(fin, toBeignored, '='); //To read the comment line till the "=" sign
for (int j = 0; j < Bsize; j++) {
fin.get(tempp);
if (tempp == '-') {
players[w].board[i][j] = '.';
}
else{
players[w].board[i][j] = tempp;
}
}
fin.get(tempp); // To ignore the end of line character in file
}
}
//-----------------------------------------------------------
getline(fin, toBeignored, '='); //To read the comment line till the "=" sign
fin >> turn;
fin.close();
cout << "Azul game successfully loaded\n";
cout << "< game play continues from here > \n\n";
bool ret = true;
ret = gamePlay(box, lid, players, factories, turn, n_player, Bsize);
if (players != nullptr) {
delete[]players;
}
return ret;
}
return true;
}
}
void initFactories(vector<vector<char> >& factories, vector<char>& box, vector<char>& lid) {
//Removing any null element(if any) from the factories
for (size_t i = 0 ; i < factories.size() ; i++) {
for (size_t j = 0 ; j < factories[i].size() ; j++) {
factories[j].clear();
}
}
//If the box is empty/or have insufficient tiles then shift all tiles from the lid into the box
//according to the rules of AZUL
if (box.size() < 20) {
size_t lidSize = lid.size();
for (size_t i = 0; i < lidSize; i++) {
box.push_back(lid[i]);
}
//Removing those all tiles from the lid
lid.clear();
//Now shuffling the box once again as tiles from lid can in in order.
shuffle(box);
}
//The central Factory
vector<char> center;
center.push_back('F'); // First turn brick
factories.push_back(center);
center.clear();
size_t index = 1;
//Now going to place tiles in other 5 facctories
for (size_t i = 0; i < 5; i++) {
vector<char> fac;
for (int j = 0; j < 4; j++) {
if (box[box.size() - index] == 'F' || box[box.size() - index] == 'B' || box[box.size() - index] == 'Y' || box[box.size() - index] == 'R' || box[box.size() - index] == 'U' || box[box.size() - index] == 'L' || box[box.size() - index] == 'O') {
fac.push_back(box[box.size() - index]); // Adding last 4 tiles from the box in factories
}
else {
j--;
}
index++;
}
factories.push_back(fac);
fac.clear();
}
box.resize(box.size() - 20); // To remove the tiles from box which are moved in factory
}
void DisplayState(vector<vector<char> >factories, Player* player,int n_player,int turn, const int Bsize) {
cout << "TURN FOR PLAYER:" << player[turn-1].name << "\n";
cout << "Factories:\n";
for (size_t i = 0; i < factories.size(); i++) {
cout << i << ": ";
for (size_t j = 0; j < factories[i].size(); j++) {
if (factories[i][j] == 'F') {
cout << "\033[48;2;255;255;255;30m" << "F" << "\033[m "; // First player tile
}
else if (factories[i][j] == 'B') {
cout << "\033[48;2;0;9;255m" << "B" << "\033[m "; // Dark Blue
}
else if (factories[i][j] == 'L') {
cout << "\033[48;2;101;136;233m" << "L" << "\033[m ";//Light Blue
}
else if (factories[i][j] == 'R') {
cout << "\033[48;2;255;0;0m" << "R" << "\033[m "; //Red
}
else if (factories[i][j] == 'U') {
cout << "\033[48;2;0;0;0m" << "U" << "\033[m "; //Black
}
else if (factories[i][j] == 'O') {
cout << "\033[48;2;255;165;0;30m" << "O" << "\033[m "; // Orange
}
else if (factories[i][j] == 'Y') {
cout << "\033[48;2;255;255;0;30m" << "Y" << "\033[m "; // Yellow
}
}
cout << "\n";
}
int P2 = 0;
if (turn == 1) {
P2 = 1;
}
else if(turn == 2) {
P2 = 0;
}
int var = turn - 1;
cout << "\nMosaic for " << player[turn - 1].name << "\t\t\tMosaic for " << player[P2].name <<"\n";
for (int i = 0; i < Bsize; i++) {
cout << i + 1 << ": ";
var = turn - 1;
for (int g = 0; g < 2; g++) {
for (int j = 0; j < Bsize - 1 - i; j++){
cout << " ";
}
for (int j = 0; j < i + 1; j++) {
if (player[var].pattern[i][j] == 'B') {
cout << "\033[48;2;0;9;255m" << "B" << "\033[m "; // Dark Blue
}
else if (player[var].pattern[i][j] == 'L') {
cout << "\033[48;2;101;136;233m" << "L" << "\033[m ";//Light Blue
}
else if (player[var].pattern[i][j] == 'R') {
cout << "\033[48;2;255;0;0m" << "R" << "\033[m "; //Red
}
else if (player[var].pattern[i][j] == 'U') {
cout << "\033[48;2;0;0;0m" << "U" << "\033[m "; //Black
}
else if (player[var].pattern[i][j] == 'O') {
cout << "\033[48;2;255;165;0;30m" << "O" << "\033[m "; // Orange
}
else if (player[var].pattern[i][j] == 'Y') {
cout << "\033[48;2;255;255;0;30m" << "Y" << "\033[m "; // Yellow
}
else {
cout << ". ";
}
}
cout << " || ";
for (int j = 0; j < Bsize; j++) {
if (player[var].board[i][j] == 'B') {
cout << "\033[48;2;0;9;255m" << "B" << "\033[m "; // Dark Blue
}
else if (player[var].board[i][j] == 'L') {
cout << "\033[48;2;101;136;233m" << "L" << "\033[m ";//Light Blue
}
else if (player[var].board[i][j] == 'R') {
cout << "\033[48;2;255;0;0m" << "R" << "\033[m "; //Red
}
else if (player[var].board[i][j] == 'U') {
cout << "\033[48;2;0;0;0m" << "U" << "\033[m "; //Black
}
else if (player[var].board[i][j] == 'O') {
cout << "\033[48;2;255;165;0;30m" << "O" << "\033[m "; // Orange
}
else if (player[var].board[i][j] == 'Y') {
cout << "\033[48;2;255;255;0;30m" << "Y" << "\033[m "; // Yellow
}
else {
cout << ". ";
}
}
cout << "\t\t";
var = P2;
}
cout << "\n";
}
player[turn-1].broken.print();
cout << "\t\t\t\t";
player[P2].broken.print();
cout << "\n";
}
void saveGame(vector<char>& box, vector<char>& lid, Player* players, vector<vector<char> >& factories, int turn, char* filename, int n_player, const int Bsize) {
ofstream fout;
fout.open(filename, ios::out);
if (!fout) {
cout << "Error opening the file to save the game...\n";
}
else {
//Writing the factories
fout << "# This is a comment line, and is optional\n";
fout << "# Multiline comments are just multiple single line comments\n";
fout << "BAG=";
// Now writing the lid (tiles places on lid, if any) in tha txt file
for (size_t i = 0; i < box.size(); i++) {
if (box[i] == 'B') {
fout << "B";
}
else if (box[i] == 'L') {
fout << "L";
}
else if (box[i] == 'R') {
fout << "R";
}
else if (box[i] == 'U') {
fout << "U";
}
else if (box[i] == 'O') {
fout << "O";
}
else if (box[i] == 'Y') {
fout << "Y";
}
else if (box[i] == 'F') {
fout << "F";
}
}
fout << "\n";
fout << "LID=";
// At last, writing the remaining box of tiles in the txt file
for (size_t i = 0; i < lid.size(); i++) {
if (lid[i] == 'B') {
fout << "B";
}
else if (lid[i] == 'L') {
fout << "L";
}
else if (lid[i] == 'R') {
fout << "R";
}
else if (lid[i] == 'U') {
fout << "U";
}
else if (lid[i] == 'O') {
fout << "O";
}
else if (lid[i] == 'Y') {
fout << "Y";
}
else if (lid[i] == 'F') {
fout << "F";
}
}
fout << "\n";
for (size_t i = 0; i < factories.size(); i++) {
if (i == 0) {
fout << "FACTORY_CENTRE=";
}
else {
fout << "FACTORY_" << i << "=";
}
for (size_t j = 0; j < factories[i].size(); j++) {
fout << factories[i][j];
}
fout << "\n";
}
fout << "# Could use comments to separate sections\n";
//Writing the information of player 1
for (int x = 0; x < n_player; x++) {
fout << "PLAYER_" << (x + 1) << "_NAME=" << players[x].name << "\n";
fout << "PLAYER_" << (x + 1) << "_SCORE=" << players[x].score << "\n";
for (int i = 0; i < Bsize; i++) {
fout << "PLAYER_" << (x + 1) << "_PATTERN_LINE" << (i + 1) << "=";
for (int j = 0; j < i + 1; j++) {
fout << players[x].pattern[i][j];
}
fout << "\n";
}
fout << "PLAYER_" << (x + 1) << "_FLOOR_LINE=";
//writing broken tiles of both players
if (players[x].broken.Head() != nullptr) {
Node* cur = players[x].broken.Head();
while (cur != nullptr) {
if (cur->data == 'F' || cur->data == 'B' || cur->data == 'Y' || cur->data == 'R' || cur->data == 'U' || cur->data == 'L' || cur->data == 'O')
fout << cur->data;
cur = cur->next;
}
}
fout << "\n";
//Board of player 1
for (int i = 0; i < Bsize; i++) {
fout << "PLAYER_" << (x + 1) << "_MOSAIC_" << (i + 1) << "=";
for (int j = 0; j < Bsize; j++) {
fout << players[x].board[i][j];
}
fout << "\n";
}
}
//---------------------------------------------------------------------------
// The turn(which player will play first in next round)
fout << "CURRENT_PLAYER=" << turn;
cout << "Game successfully saved to \'" << filename << "\'\n";
cout << "< Gameplay continues until end - of - game > " << "\n\n";
//closing the txt file
fout.close();
}
}
bool isEmpty(vector<vector<char> >factories) {
bool empty = true;
size_t zero = 0;
if (factories.size() == zero) {
empty = false;
}
else {
for (size_t i = 0; i < factories.size() && empty; i++) {
for (size_t j = 0; j < factories[i].size(); j++) {
if (factories[i][j] != 'F' || factories[i][j] != 'B' || factories[i][j] != 'Y' || factories[i][j] != 'R' || factories[i][j] != 'U' || factories[i][j] != 'L' || factories[i][j] != 'O') {
empty = false;
}
}
}
}
return empty;
}
bool isColValid(char B[][6], const int Bsize, int row, char color) {
bool check = true;
for (int i = 0 ; i < Bsize && check ; i++) {
if (B[row][i] == color ) {
check = false;
}
}
return check;
}
bool charPossible(vector<vector<char> >factories, int index, char colour) {
bool check = false;
for (size_t i = 0; i < factories[index].size() && !check; i++) {
if (factories[index][i] == colour) {
check = true;
}
}
return check;
}
int giveIndexOfColour(char B[][6], const int Bsize, int index, char colour) {
char row[6] = { 'B','Y','R','U','L','O' };
for (int i = 0; i < index; i++) {
char temp = row[Bsize - 1];
for (int j = Bsize - 1; j > 0; j--) {
row[j] = row[j - 1];
}
row[0] = temp;
}
index = -1;
bool cond = true;
for (int i = 0; i < Bsize && cond; i++) {
if (row[i] == colour) {
index = i;
cond = false;
}
}
return index;
}
int askIndexOfColour(char B[][6], const int Bsize, int rows, char colour, bool& okay) {
int col = 0;
cout << "Enter the column number against row " << (rows+1) << " in which you wish to place tile ";
if (colour == 'B') {
cout << "\033[48;2;0;9;255m" << "B" << "\033[m "; // Dark Blue
}
else if (colour == 'L') {
cout << "\033[48;2;101;136;233m" << "L" << "\033[m ";//Light Blue
}
else if (colour == 'R') {
cout << "\033[48;2;255;0;0m" << "R" << "\033[m "; //Red
}
else if (colour == 'U') {
cout << "\033[48;2;0;0;0m" << "U" << "\033[m "; //Black
}
else if (colour == 'O') {
cout << "\033[48;2;255;165;0;30m" << "O" << "\033[m "; // Orange
}
else if (colour == 'Y') {
cout << "\033[48;2;255;255;0;30m" << "Y" << "\033[m "; // Yellow
}
cout << "\n";
cout << ">";
string input = "";
getline(cin,input);
char II = input[0];
col = static_cast<int>(II)-48;
if (std::cin.eof()) {
okay = false;
return -1;
}
while (!(col >= 1 && col <= 6) || (!isColValid(B, Bsize, rows, colour) && input.size() == 1)) {
if(col >= 1 && col <= 6)
cout << "Invalid column! The required place already has a tile, please enter again.\n>";
else
cout << "Invalid column! Valid Range is (1 - 6), please enter again.\n>";
getline(cin, input);
II = input[0];
col = static_cast<int>(II)-48;
if (std::cin.eof()) {
okay = false;
return -1;
}
}
col--;
return col;
}
bool calcPoint(char B[][6], const int Bsize, char**& pattern, LinkedList& broken, int& score, vector<char>& lid, string Pname) {
bool okay = true; // Just to handle the EOF character situation
int roundScore = 0;
bool complete = true;
cout << "Placing tiles in wall/board of player: " << Pname << "\n";
cout << "Wall/Board of player: " << Pname << "\n\n";
cout << " 1 2 3 4 5 6\n";
for (int i = 0 ; i < Bsize ; i++ ) {
cout << (i + 1) << " ";
for (int j = 0 ;j < Bsize ; j++) {
cout << B[i][j] << " ";
}
cout << "\n";
}
cout << "\n";
// First things first, moving all completed rows's tile colour to the right side row of mosaic
for (int rows = 0; rows < Bsize; rows++) {
complete = true;
//checking for completed line
char first = '.';
if (pattern[rows][0] != '.' && pattern[rows][0] != '\0' && pattern[rows][0] != '\n') {
first = pattern[rows][0]; //Placed the tile type contained by this current row
//The following loop checks either row is full with same tiles of not
bool cond = true;
for (int i = 0; i < rows + 1 && cond; i++) {
if (pattern[rows][i] != first) {
complete = false;
cond = false; // just to break the loop
}
}
//If row is full of same tiles then should move this tile to the right side
//of mosaic
if (complete) {
int col = -1;
col = askIndexOfColour(B, Bsize, rows, first, okay);
// Player entered EOF
if (!okay) {
return okay;
}
//shifting the colour to the corresponding block at right side of the mosaic
B[rows][col] = first;
//Now calculating the points of this tile
int count = 0;
bool check1 = false;
//Checking for adjacent tiles in the row
for (int i = col + 1; i < Bsize && B[rows][i] != '.'; i++) {
check1 = true;
count++;
}
for (int i = col - 1; i >= 0 && B[rows][i] != '.'; i--) {
check1 = true;
count++;
}
if (check1) {
count++;
}
//Checking for adjacent tiles in the row
bool check2 = false;
for (int i = rows + 1; i < Bsize && B[i][col] != '.'; i++) {
check2 = true;
count++;
}
for (int i = rows - 1; i >= 0 && B[i][col] != '.'; i--) {
check2 = true;
count++;
}
if (check2) {
count++;
}
// If the tile had no adjacent tiles
if (count == 0) {
roundScore++;
}
//If tile had adjacent tile(s) then adding score accordingly
else {
roundScore += count;
}
count = 0;
//moving all remaining tiles to the lid
int i;
for (i = 0; i < rows; i++) {
lid.push_back(first);
pattern[rows][i] = '.';
}
pattern[rows][i] = '.';
}
}
}
int count = 0;
int rate = -1;
int brokenTiles = broken.getSize();
Node* cur = broken.Head();
while (cur != nullptr) {
if (cur->data != 'F' && cur->data != 'B' && cur->data != 'Y' && cur->data != 'R' && cur->data != 'U' && cur->data != 'L')
brokenTiles--;
cur = cur->next;
}
for (int i = 1; i <= brokenTiles; i++) {
if (i == 3) {
rate = -2;
}
else if (i == 6) {
rate = -3;
}
else if (i == 8) {
rate = -4;
}
count += rate;
}
if (brokenTiles > 0) {
broken.removeAll(lid, true);
}
roundScore += count;
score += roundScore;
cout << "***** Score board of player " << Pname << "\n\n";
cout << "Total points deducted for broken tiles: " << count << ".\n";
cout << "Score of this round: " << roundScore << ".\n";
cout << "Total score after this round: " << score << ".\n\n";
return true;
}
bool checkForRow(char B[][6]) {
bool check = false;
//if check is true then it means we have found an incomplete row
for (size_t i = 0; i < 6 && !check; i++) {
size_t j = 0;
for (j = 0; j < 6 && !check; j++) {
if (B[i][j] == '.') {
check = true; //TO break the loop
}
}
// If above row had no vacant space, it means it is completed
if (j == 6 && !check) {
check = true; //a complete row is found
}
else {
check = false;
}
}
return check;
}
void finalScoring(char B[][6], int& score) {
bool cond = true; // This bool is just to break the the loops if some condition(s) are meet
//Checking for all complete rows
for (int i = 0; i < 6; i++) {
int j = 0;
cond = true;
for (j = 0; j < 6 && cond; j++) {
if (B[i][j] == '.') {
cond = false;
j--;
}
}
// If above row had no vacant space, it means it is complete
if (j == 6) {
score += 2; //So here are the extra 2 points for each complete row
}
}
cond = true;
//Checking for all complete columns
for (int i = 0; i < 6; i++) {
int j = 0;
for (j = 0; j < 6 && cond; j++) {
if (B[j][i] == '.') {
cond = false;
j--;
}
}
// If the current column had no vacant space, it means it is complete
if (j == 6) {
score += 7; //So here are the extra 7 points for each complete column
}
}
//now going to calculate that how many times this player
//managed to fill in all five tiles for one colour
//This array will contain the count of each colour tile in the final board
//at indiviual index
/*
[0] holds count for Red (R)
[1] holds count for Yellow (Y)
[2] holds count for Dark blue (B)
[3] holds count for Light Blue (L)
[4] holds count for Black (U)
*/
int colourCount[6] = { 0 };
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 6; j++) {
if (B[i][j] == 'R') {
colourCount[0]++;
}
else if (B[i][j] == 'Y') {
colourCount[1]++;
}
else if (B[i][j] == 'B') {
colourCount[2]++;
}
else if (B[i][j] == 'L') {
colourCount[3]++;
}
else if (B[i][j] == 'U') {
colourCount[4]++;
}
else if (B[i][j] == 'O') {
colourCount[5]++;
}
}
}
//At this point we have count of occurunces of each colour
// Now we will find the minimum number for which each colour occured
int min = 9999999;
// Finding the minimum number of occurence of a tile
for (int i = 0; i < 6; i++) {
if (colourCount[i] < min) {
min = colourCount[i];
}
}
//now going to check if all colours have occurred minimum for min times (Note: the min can be 0 so
// if a tiles has occurred not even once then even tat condition get covered under this)
int i;
cond = true;
// Finding the minimum number of occurence of a tile
for (i = 0; i < 6 && cond; i++) {
if (min > colourCount[i]) {
cond = false;
}
}
//this means that min contains the number of times for which all colours occurred at least
if (cond) {
//10 points for each time, all colours occureds.
//if all colours occured not even once then min will be 0, hence no effect on scoring
score += (min * 10);
}
}
void instructions() {
cout << "\t\t\t\t\t\t\033[48;2;0;255;34;30m *INSTRUCTIONS*\033[m\n\n";
cout << "\t\t\t\033[48;2;0;255;34;30mInput formats: <type> <factory> <colour> <storage row>\033[m\n\n";
cout << "\t\t\t\033[48;2;255;0;0m1.\033[48;2;0;9;255m First you will type the command name e.g. turn, save.\033[m\n";
cout << "\t\t\t\033[48;2;0;9;255m only these 2 are valid commands\033[m\n\n";
cout << "\t\t\t\033[48;2;255;0;0m2.\033[48;2;0;9;255m Then with a SPACE you will write the number of factory from which you\033[m\n";
cout << "\t\t\033[48;2;0;9;255m want to pick tiles. (This MUST be an integer (range 0 - 5) )\033[m\n\n";
cout << "\t\t\t\033[48;2;255;0;0m3.\033[48;2;0;9;255m Then with a SPACE you will write the colour of tile you want to pick\033[m\n";
cout << "\t\t\t\033[48;2;0;9;255m from that specified factory. (Valid colours: R, Y, B, L, U, O) all other inputs are invalid.\033[m\n\n";
cout << "\t\t\t\033[48;2;255;0;0m4.\033[48;2;0;9;255m Then at last, with a SPACE you will write the number of storage row.\033[m\n";
cout << "\t\t\t\033[48;2;0;9;255m (This MUST be an integer (range 1 - 6) )\033[m\n\n";
cout << "\t\t\t\033[48;2;255;0;0m5.\033[48;2;0;9;255m A player can enter \"turn n A F\" to move all tiles of nth factory (0 <= n <= 6)\033[m\n";
cout << "\t\t\t\033[48;2;0;9;255m to their floor.\033[m\n\n";
cout << "\t\t\t\033[48;2;255;0;0m6.\033[48;2;0;9;255m At any moment a player can enter EOF to exit the game and terminate\033[m\n";
cout << "\t\t\t\033[48;2;0;9;255m the program. (CAUTION: All unsaved progress will be lost)\033[m\n\n";
}
bool gamePlay(vector<char>& box, vector<char>& lid, Player*& players, vector<vector<char> >& factories, int turn, int n_player, const int Bsize) {
bool loop = true;
bool round = true;
bool endGame = true;
bool quit = false;
bool firstTileFirstCheck = false;
bool isShow = true;
// This loop controls the rounds
while (endGame && round) {
cout << "\t\033[48;2;0;255;34;30m=== Start Round ===\033[m\n\n";
string input = "";
bool check = true;
bool ifFirstTileGained = false;
bool isFirst = false;
// This loop is responsible for back to back turns of players in one round
while (loop && round) {
DisplayState(factories, players ,n_player,turn, Bsize);
check = true;
while (check) {
cout << "> ";
getline(cin, input);
isShow = true;
if (input.substr(0, 5) == "turn " && input.size() == 10) {
char _f_ = input[5];
int _f = static_cast<int>(_f_) - 48;
char _colour = (char)input[7];
char _row = input[9];
int _r = static_cast<int>(_row) - 48;
//just checking if input command is valid or not
if ((_f >= 0 && _f <= 5) && (_colour == 'R' || _colour == 'Y' || _colour == 'B' || _colour == 'L' || _colour == 'U' || _colour == 'O' || _colour == 'A') && ((_r >= 1 && _r <= Bsize) || _r == 22 )) {
// if player wants to move all tiles from selected factory into his/her floor
if (_r == 22 && _colour == 'A' ) {
if (factories[_f].size() > 0) {
//checking for First-turn tile in central factory
if (!isFirst && _f == 0) {
bool _cond = true; // Just to break the loop if specific condition meets
for (size_t i = 0; i < factories[_f].size() && _cond; i++) {
if (factories[_f][i] == 'F') {
isFirst = true;
_cond = false;
}
}
if (isFirst && !firstTileFirstCheck) {
firstTileFirstCheck = true;
cout << "\033[48;2;0;255;34;30m" << players[turn - 1].name << " got the first player tile.\033[m\n\n";
}
}
//Moving all tiles from the selected factory to the floor of current player
for (size_t i = 0; i < factories[_f].size(); i++) {
if (factories[_f][i] == 'F' || factories[_f][i] == 'B' || factories[_f][i] == 'Y' || factories[_f][i] == 'R' || factories[_f][i] == 'U' || factories[_f][i] == 'L' || factories[_f][i] == 'O') {
players[turn - 1].broken.insert(factories[_f][i]);
}
}
factories[_f].clear();
cout << "\033[48;2;0;255;34;30mTurn Successful.\033[m\n\n";
if (turn == 1) {
turn = 2;
}
else if (turn == 2) {
turn = 1;
}
check = false;
if (isEmpty(factories)) {
factories[0].clear();
round = false;
}
}
else {
cout << "\033[48;2;0;255;0;0mThe required factory is empty!, please enter a Valid turn.\033[m\n\n";
}
}
//if player does not want to move all tiles from selected factory to his/her floor
else {
_r--; //As rows in array start from 0 not 1
bool justDoIt = true;
if (_r == 21 || _colour == 'A') {
justDoIt = false;
}
if (charPossible(factories, _f, _colour) && justDoIt) {
//Checking if the corresponding tiles board already have the required colour or not
bool valid = isColValid(players[turn - 1].board, Bsize, _r, _colour);
//Now going to check if the required row of mosaic pattern board can hold the required colour
int possibleTiles = 0;
if (valid) {
bool _cond = true; // Just to break the loop if specific condition meets
for (int i = 0; i < _r + 1 && _cond; i++) {
if (players[turn - 1].pattern[_r][i] != '.' && players[turn - 1].pattern[_r][i] != _colour) {
valid = false;
_cond = false;
}
else {
if (players[turn - 1].pattern[_r][i] == '.')
possibleTiles++;
}
}
}
if (valid && possibleTiles == 0) {
cout << "\033[48;2;0;255;0;0mRequired row is full, can not place more tiles in it.\033[m\n\n";
valid = false;
isShow = false;
}
//At this moment we know that the location is alright to place the tiles in mosaic
if (valid) {
//checking for First turn tile in central factory
if (!isFirst && _f == 0) {
bool _cond = true; // Just to break the loop if specific condition meets
for (size_t i = 0; i < factories[_f].size() && _cond; i++) {
if (factories[_f][i] == 'F') {
isFirst = true;
_cond = false;
}
}
if (isFirst && !firstTileFirstCheck) {
firstTileFirstCheck = true;
cout << "\033[48;2;0;255;34;30m" << players[turn - 1].name << " got the first player tile.\033[m\n\n";
}
}
int actual = 0;
vector<char> temp_central_F;
vector<char> temp_central_F0;
ifFirstTileGained = false;
for (size_t i = 0; i < factories[_f].size(); i++) {
// if we are in central factory and firstplayer tile is still there
if (factories[_f][i] == 'F') {
// then it moves to the broken tiles of respective player
if (factories[_f][i] == 'F' || factories[_f][i] == 'B' || factories[_f][i] == 'Y' || factories[_f][i] == 'R' || factories[_f][i] == 'U' || factories[_f][i] == 'L' || factories[_f][i] == 'O') {
players[turn - 1].broken.insert(factories[_f][i]);
ifFirstTileGained = true;
}
}
//counting the same colur tiles
else if (factories[_f][i] == _colour) {
actual++;
}
//All other tiles will be moved to the central factory
else {
if (factories[_f][i] == 'F' || factories[_f][i] == 'B' || factories[_f][i] == 'Y' || factories[_f][i] == 'R' || factories[_f][i] == 'U' || factories[_f][i] == 'L' || factories[_f][i] == 'O')
temp_central_F.push_back(factories[_f][i]);
}
}
if (_f != 0) {
if (!ifFirstTileGained) {
for (size_t i = 0; i < factories[0].size(); i++) {
if (factories[0][i] == 'F' || factories[0][i] == 'B' || factories[0][i] == 'Y' || factories[0][i] == 'R' || factories[0][i] == 'U' || factories[0][i] == 'L' || factories[_f][i] == 'O')
temp_central_F0.push_back(factories[0][i]);
}
}
else {
// Skipping the first player tile
for (size_t i = 1; i < factories[0].size(); i++) {
if (factories[0][i] == 'F' || factories[0][i] == 'B' || factories[0][i] == 'Y' || factories[0][i] == 'R' || factories[0][i] == 'U' || factories[0][i] == 'L' || factories[_f][i] == 'O')
temp_central_F0.push_back(factories[0][i]);
}
}
}
//This process is to update the central factory
factories[0].clear();
for (size_t i = 0; i < temp_central_F0.size(); i++) {
factories[0].push_back(temp_central_F0[i]);
}
for (size_t i = 0; i < temp_central_F.size(); i++) {
factories[0].push_back(temp_central_F[i]);
}
// Now "possibleTiles" shows the number of tiles we can place in out left mosaic's selected row
// and "actual" shows the actual number of tiles we have
// So now we can remmove all tiles from the factory
if (_f != 0)
factories[_f].clear();
//Now placing the tiles in left side of mosaic
int i = 0;
while (players[turn - 1].pattern[_r][i] != '.' && i < (_r + 1))
i++;
int j;
for (j = 0; j < actual && i < (_r + 1) && players[turn - 1].pattern[_r][i] == '.'; j++, i++) {
players[turn - 1].pattern[_r][i] = _colour;
}
int x = 0;
if (actual - possibleTiles >= 0) {
// Adding the remaining tiles(if any) to the bottom of the mat
for (x = 0; x < actual - possibleTiles; x++) {
if (_colour == 'F' || _colour == 'B' || _colour == 'Y' || _colour == 'R' || _colour == 'U' || _colour == 'L' || _colour == 'O')
players[turn - 1].broken.insert(_colour);
}
}
cout << "\033[48;2;0;255;34;30mTurn Successful.\033[m\n\n";
if (turn == 1) {
turn = 2;
}
else if (turn == 2) {
turn = 1;
}
check = false;
if (isEmpty(factories)) {
factories[0].clear();
round = false;
}
}
else {
if (isShow)
cout << "\033[1;37;41m The required row cannot hold " << _colour << " colour.\033[m\n\n";
}
}
else if(justDoIt) {
cout << "\033[1;37;41mThe Required Factory is Empty Or do not have the required colour. Please enter turn again.\033[m\n\n";
}
else {
cout << "\033[1;37;41mInvalid turn, please input again.\033[m\n\n";
}
}
}
else {
cout << "\033[1;37;41mInvalid turn, please input again.\033[m\n\n";
}
}
else if (input.substr(0, 5) == "save ") {
char* name = new char[30];
size_t i = 0;
for (size_t j = 5; j < input.size(); i++, j++) {
name[i] = (char)input[j];
}
name[i] = '\0';
//Now going to remove some unwanted friends from the vector
int v_size = static_cast<int>(lid.size());
for (int i = 0; i < v_size; i++) {
if (lid[i] != 'F' && lid[i] != 'B' && lid[i] != 'Y' && lid[i] != 'R' && lid[i] != 'U' && lid[i] != 'L' && lid[i] != 'O') {
lid.erase(lid.begin() + i);
i--;
v_size--;
}
}
//Saving the present state of game
saveGame(box, lid, players, factories, turn, name, n_player, Bsize);
delete[] name;
cout << "Now Enter you turn:\n";
}
else if (input == "help") {
instructions();
}
else if (std::cin.eof()) {
quit = true;
check = false;
endGame = false;
loop = false;
round = false;
}
else {
cout << "\t\033[1;37;41mInvalid command! please input again.\033[m\n\n";
}
}
}
//------------------------------------------------------------
if (!quit) {
cout << "\t\033[1;37;41m=== END OF ROUND ===\033[m\n\n";
// Refilling the factories
factories.clear();
initFactories(factories, box, lid);
//Setting the turn according to the first tile position
if (players[0].broken.Head() != nullptr) {
Node* cur = players[0].broken.Head();
bool cond = true;
while (cur != nullptr && cond) {
if (cur->data == 'F') {
turn = 1;
cond = false;
}
cur = cur->next;
}
//If 'F' tile is not present in floor of player 1
if (cond) {
turn = 2;
}
}
//If player 1 does not have the F tile then player 2 must have
else {
turn = 2;
}
//Now going to remove some unwanted friends from the vector
int v_size = static_cast<int>(lid.size());
for (int i = 0; i < v_size; i++) {
if (lid[i] != 'F' && lid[i] != 'B' && lid[i] != 'Y' && lid[i] != 'R' && lid[i] != 'U' && lid[i] != 'L' && lid[i] != 'O') {
lid.erase(lid.begin() + i);
i--;
v_size--;
}
}
/* Implement score calculations and end of game logic here */
//Calculating the scores by shifting the tiles from left side of mosaic to right side (if all conditions meet)
bool o = true;
for (int i = 0; i < n_player && o ; i++) {
if (!calcPoint(players[i].board, Bsize, players[i].pattern, players[i].broken, players[i].score, lid, players[i].name)) {
quit = true;
endGame = false;
round = false;
o = false;
}
}
//Checking end of the Match condition (a row has completed of any player)
if (checkForRow(players[0].board) || checkForRow(players[1].board)) {
endGame = false;
}
else {
round = true;
}
}
}
/* implementing the logics for final bounus scoring and declare the winner */
if (!quit) {
//Now going to remove some unwanted friends from the vector
int v_size = static_cast<int>(lid.size());
for (int i = 0; i < v_size; i++) {
if (lid[i] != 'F' && lid[i] != 'B' && lid[i] != 'Y' && lid[i] != 'R' && lid[i] != 'U' && lid[i] != 'L' && lid[i] != 'O') {
lid.erase(lid.begin() + i);
i--;
v_size--;
}
}
//Calculating the end-of-the-game-final-scoring
for (int i = 0; i < n_player; i++) {
finalScoring(players[i].board, players[i].score);
}
cout << "\t\033[1;37;41m=== GAME OVER ===\033[m\n\n";
//Now announcing the winner;
//Player1 has won
if (players[0].score > players[1].score) {
cout << "\nPlayer " << players[0].name << " Wins!\n\n";
for (int i = 0; i < n_player; i++) {
cout << "Score of " << players[i].name << " = " << players[i].score << "\n";
}
}
// Player2 has won
else if (players[0].score < players[1].score) {
cout << "\nPlayer " << players[1].name << " Wins!\n\n";
for (int i = 0; i < n_player; i++) {
cout << "Score of " << players[i].name << " = " << players[i].score << "\n";
}
}
// The match is draw
else {
cout << "It's a draw\n\n";
for (int i = 0; i < n_player; i++) {
cout << "Score of " << players[i].name << " = " << players[i].score << "\n";
}
}
cout << "\nMosaic for " << players[0].name << "\t\t\tMosaic for " << players[1].name << "\n";
for (int i = 0; i < Bsize; i++) {
cout << i + 1 << ": ";
for (int g = 0; g < n_player; g++) {
for (int j = 0; j < Bsize - 1 - i; j++) {
cout << " ";
}
for (int j = 0; j < i + 1; j++) {
if (players[g].pattern[i][j] == 'B') {
cout << "\033[48;2;0;9;255m" << "B" << "\033[m "; // Dark Blue
}
else if (players[g].pattern[i][j] == 'L') {
cout << "\033[48;2;101;136;233m" << "L" << "\033[m "; // Light Blue
}
else if (players[g].pattern[i][j] == 'R') {
cout << "\033[48;2;255;0;0m" << "R" << "\033[m "; // Red
}
else if (players[g].pattern[i][j] == 'U') {
cout << "\033[48;2;0;0;0m" << "U" << "\033[m "; // Black
}
else if (players[g].pattern[i][j] == 'O') {
cout << "\033[48;2;255;165;0;30m" << "O" << "\033[m "; // Orange
}
else if (players[g].pattern[i][j] == 'Y') {
cout << "\033[48;2;255;255;0;30m" << "Y" << "\033[m "; // Yellow
}
else {
cout << ". ";
}
}
cout << " || ";
for (int j = 0; j < Bsize; j++) {
if (players[g].board[i][j] == 'B') {
cout << "\033[48;2;0;9;255m" << "B" << "\033[m "; // Dark Blue
}
else if (players[g].board[i][j] == 'L') {
cout << "\033[48;2;101;136;233m" << "L" << "\033[m ";//Light Blue
}
else if (players[g].board[i][j] == 'R') {
cout << "\033[48;2;255;0;0m" << "R" << "\033[m "; //Red
}
else if (players[g].board[i][j] == 'U') {
cout << "\033[48;2;0;0;0m" << "U" << "\033[m "; //Black
}
else if (players[g].board[i][j] == 'O') {
cout << "\033[48;2;255;165;0;30m" << "O" << "\033[m "; // Orange
}
else if (players[g].board[i][j] == 'Y') {
cout << "\033[48;2;255;255;0;30m" << "Y" << "\033[m "; // Yellow
}
else {
cout << ". ";
}
}
cout << "\t\t";
}
cout << "\n";
}
delete[]players;
players = nullptr;
cout << "\n ***** Moving towards the main menu *****\n";
return true;
}
else {
return false;
}
} |
2e6ce86d531bd7f73f475c0af27e60e607a2c900 | 9d6b7fd81bcd26d68d855a8ed8e4014e27cda169 | /include/Dxx/VertexBuffer.h | 2e35c7e175ec870e60a9a0cfbe562bd90b759db0 | [] | no_license | jambolo/Dxx | 0e5fee662c0a092d16e3a925bdb19654778d49ef | 01a7dfcf0e7ecdc06193696db7c4b41573a552ae | refs/heads/master | 2021-01-13T15:55:16.319074 | 2019-02-06T07:42:02 | 2019-02-06T07:42:02 | 76,817,875 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 940 | h | VertexBuffer.h | #pragma once
#if !defined(DXX_VERTEXBUFFER_H)
#define DXX_VERTEXBUFFER_H
#include <windows.h>
#include <d3d11.h>
#include <dxgi.h>
namespace Dxx
{
//! @name Vertex Buffer Functions
//! @ingroup D3dx
//@{
//! Creates a static vertex buffer.
HRESULT CreateStaticVertexBuffer(ID3D11Device * pDevice,
void const * pData,
size_t size,
ID3D11Buffer ** ppVB);
//! Creates a static index buffer.
HRESULT CreateStaticIndexBuffer(ID3D11Device * pDevice,
ID3D11DeviceContext * pContext,
void const * pData,
size_t size,
DXGI_FORMAT format,
ID3D11Buffer ** ppIB);
//@}
} // namespace Dxx
#endif // !defined(DXX_VERTEXBUFFER_H)
|
0bd1ff1596cef67562d5d0ddb6dc926274159ff2 | fa8d6d7d2c30de360c4f0bbcaa59167fcd582a03 | /TOI/TOI10_crazyadmin.cpp | c2703d117b23195f42abe1ec9b279e21e6dad8ad | [] | no_license | JodsintZ/roadtotoi | 0a699b5cbafa577696d0d20b3f7c977914c6b751 | e336227d34392af379632cb40d449727539976d5 | refs/heads/master | 2023-07-16T12:23:06.194672 | 2021-08-31T11:35:16 | 2021-08-31T11:35:16 | 212,324,761 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 768 | cpp | TOI10_crazyadmin.cpp | #include <bits/stdc++.h>
using namespace std;
int m, o, temp, sum, group, ans, mid, tans;
int a[105];
int main() {
scanf("%d %d", &m, &o);
for(int i = 0; i < o; i++) {
scanf("%d", a + i);
sum += a[i];
}
int l = 0, r = sum;
while(l <= r) {
mid = (l + r) >> 1;
group = 1;
temp = 0;
for(int i = 0; i < o; i++) {
if(a[i] > mid) {
group = 2000;
break;
}
if(temp + a[i] > mid) {
group++;
temp = 0;
}
temp += a[i];
}
if(group <= m) {
r = mid - 1;
ans = mid;
}
else l = mid + 1;
}
printf("%d", ans);
return 0;
}
|
5868727c3a3c339eb7829458e2025fdf527f77d5 | 0d23a2a3742108c94bdc940b90378aa5b1c90c5c | /stack/LongestValidParenthese32.cpp | 78d971539baccb8ed26142733a8e1f12d68f50fd | [] | no_license | lilelr/LeecodeProblemsSolutionsByC- | 108e7083185d3e41dbedf26a46986bc99928b435 | c17a64768672cf347fd64843317127c1ca56ad55 | refs/heads/master | 2021-01-19T04:50:19.710880 | 2019-06-11T07:13:00 | 2019-06-11T07:13:00 | 54,770,299 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,531 | cpp | LongestValidParenthese32.cpp |
#include <string>
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <map>
#include <stack>
#include <algorithm>
using namespace std;
// https://leetcode.com/problems/longest-valid-parentheses/description/
class Solution {
public:
/**
* ๆ้ฟๆๆ็ๆฌๅท้ฟๅบฆ
* @param s
* @return
*/
int longestValidParentheses(string s) {
int len = s.length();
if (len == 0 || len == 1) { return 0; }
stack<int> mystack;
int ans = 0;
for (int i = 0; i < len; i++) {
if (s[i] == '(') {
mystack.push(i); // stack ไธญ่ฎฐๅฝ็ๆฏไธๆ
} else { // s[i] = ')'
if (mystack.empty()) {
// ไธบ็ฉบ๏ผๅ ๅ
ฅ
mystack.push(i);
continue;
}
// ไธไธบ็ฉบ
// ๅคๆญๆ ้กถๅ
็ด ๆฏๅฆๆฏๅทฆๆฌๅท
char cur = s[mystack.top()];
if (cur == '(') { // ไป28่กๅฏ็ฅ๏ผๆๆไธๅฏนๆๆๅฏน
mystack.pop();
int peek_val = mystack.empty() ? -1 : mystack.top();
ans = max(ans, i - peek_val);
} else {
mystack.push(i);
}
}
}
return ans;
// cout<<ans<<endl;
}
};
int main() {
Solution s;
string str = "(()";
// string str = ")()())";
int ans = s.longestValidParentheses(str);
cout << ans << endl;
} |
79345a33d0bae4b1a5de9c6f3909799753c11165 | fe22b7a0f9ab10170c513afb062d69cfba128ec2 | /src/tools/cali-query/query_common.h | abb3fd2c6ab2c5b40fd06a1ba45a0ae08b2de134 | [
"BSD-3-Clause"
] | permissive | LLNL/Caliper | ef5e9a6f408610dab404b58d29b53ddff2ce9708 | 764e5b692b2569f3ba4405f8e75126a0c35c3fab | refs/heads/master | 2023-09-04T00:11:12.741726 | 2023-08-30T14:10:20 | 2023-08-30T14:10:20 | 45,953,649 | 283 | 55 | BSD-3-Clause | 2023-09-14T01:34:46 | 2015-11-11T02:02:00 | C++ | UTF-8 | C++ | false | false | 1,781 | h | query_common.h | // Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC.
// See top-level LICENSE file for details.
/// \file query_common.h
/// \brief Common functionality for cali-query and mpi-caliquery
#pragma once
#include "caliper/reader/QuerySpec.h"
#include "caliper/reader/RecordProcessor.h"
namespace util
{
class Args;
}
namespace cali
{
class CaliperMetadataAccessInterface;
class ConfigManager;
/// \brief Create QuerySpec from command-line arguments
class QueryArgsParser {
bool m_error;
std::string m_error_msg;
QuerySpec m_spec;
public:
QueryArgsParser()
: m_error(true),
m_error_msg("query not read")
{ }
/// \brief Get query spec from cali-query command-line arguments.
/// \return Returns \a true if successful, `false` in case of error.
bool parse_args(const util::Args& args);
bool error() const { return m_error; }
std::string error_msg() const { return m_error_msg; }
QuerySpec spec() const { return m_spec; }
};
/// \class SnapshotFilterStep
/// \brief Basically the chain link in the processing chain.
/// Passes result of \a m_filter_fn to \a m_push_fn.
struct SnapshotFilterStep {
SnapshotFilterFn m_filter_fn; ///< This processing step
SnapshotProcessFn m_push_fn; ///< Next processing step
SnapshotFilterStep(SnapshotFilterFn filter_fn, SnapshotProcessFn push_fn)
: m_filter_fn { filter_fn }, m_push_fn { push_fn }
{ }
void operator ()(CaliperMetadataAccessInterface& db, const EntryList& list) {
m_filter_fn(db, list, m_push_fn);
}
};
/// \brief Process --help for cali-query and mpi-caliquery
void print_caliquery_help(const util::Args& args, const char* usage, const ConfigManager&);
}
|
1bc92129fddd3c671ea619e749dbb865ed03f372 | a4d3dba301087a6ac8d72a43e952e21e6906a402 | /Task1/camelCase/ekam.cpp | a17a4d6b0fb74b5fe1ee598169a087e82c3ab15f | [] | no_license | knakul853/winter-resources | 0654b4409eab22a9c664148264497c76497d12d3 | a44494e52d918cb3436d3a1809a7e3cf9d41ecba | refs/heads/master | 2020-03-31T03:37:58.934185 | 2017-12-12T17:00:44 | 2017-12-12T17:00:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 538 | cpp | ekam.cpp | #include<bits/stdc++.h>
typedef long long int lld;
using namespace std;
int main()
{
string s;
cin>>s;
int n = s.length();
string out = "";
for(int i=0; i< n-1 ; i++)
{
if(i == 0)
out += tolower(s[i]);
else if(s[i] == '_' && s[i+1] == '_')
continue;
else if(s[i] == '_')
{
out += toupper(s[i+1]);
i++;
}
else
out += tolower(s[i]);
}
out += tolower(s[n-1]);
cout<<out<<endl;
return 0;
}
|
ade4af31697fbc59e21adf53921d87844d7c96c3 | d7dcf7f65e259b597c46e1614da743ba9dad5d7c | /app/src/main/cpp/Student.h | 9dc2fdbf392ff045b56ac2ca9d2f8641e4e6ba6b | [] | no_license | oliver-austin/QutieTutee | 28b02aa1293eaeea623b04b874897d1f5aa4f0bf | c325a5e134ff430a22ce4b0e7e1f3986aac47d02 | refs/heads/master | 2020-07-10T20:03:15.696394 | 2018-11-26T22:31:48 | 2018-11-26T22:31:48 | 204,357,337 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 190 | h | Student.h | //
// Created by Poe on 10/28/2018.
//
#pragma once
#include "User.h"
#include "Tutor.h"
class Student : public User{
public:
void rateTutor(Tutor tutor, int rating);
private:
};
|
fe4c904c1a29ae1684b11cf849cd0871e5a69fba | d18c4464af78f715ffc5d5addb1e005d018ca68d | /Voj/LsuACM 2018่ฎญ็ป่ต10โโ2015 CCPCๅ้ณ/H.cpp | b556060b5043e09a78501f9342b278010a8849ac | [] | no_license | xiaoshidefeng/ACM | 508f71ba7da6e603e8c6fbbccfa9d68d497f15a9 | b646ae0a624fc5db2d7ac46b7baef9a2779fef7b | refs/heads/master | 2021-01-19T22:05:47.518409 | 2018-05-14T14:09:51 | 2018-05-14T14:09:51 | 82,564,505 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,318 | cpp | H.cpp | #include<bits/stdc++.h>
using namespace std;
#define MID(x,y) ((x+y)>>1)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int N=2e5+7;
int n , counts, now;
char mp[7][7], mpcp[7][7];
bool vis[7][7];
bool isok ;
int zu;
struct nodes{
int x, y;
};
vector<nodes> v;
void pri() {
printf("Case #%d:\n", zu);
for (int i = 1; i <= 4; i ++) {
for (int j = 1; j <=4; j ++) {
printf("%c", mp[i][j]);
// cout<<mp[i][j];
}
printf("\n");
}
}
bool check() {
int visd1[7], visd2[7];
CLR(visd1, 0);
CLR(visd2, 0);
// pri();
for (int i = 1; i <= 4; i ++) {
for (int j = 1; j <= 4; j ++) {
if (mp[i][j] == '1') ++visd1[1];
else if (mp[i][j] == '2') ++visd1[2];
else if (mp[i][j] == '3') ++visd1[3];
else if (mp[i][j] == '4') ++visd1[4];
if (mp[j][i] == '1') ++visd2[1];
else if (mp[j][i] == '2') ++visd2[2];
else if (mp[j][i] == '3') ++visd2[3];
else if (mp[j][i] == '4') ++visd2[4];
}
for (int q = 1; q <= 4; q ++) {
if (visd1[q] != i || visd2[q] != i) {
return false;
}
}
}
for (int i = 0; i < 4; i = i + 2) {
for (int j = 0; j < 4; j = j + 2) {
CLR(visd1, 0);
visd1[mp[1 + i][1 + j] - '0'] += 1;
visd1[mp[1 + i][2 + j] - '0'] += 1;
visd1[mp[2 + i][1 + j] - '0'] += 1;
visd1[mp[2 + i][2 + j] - '0'] += 1;
if (visd1[1] == 1 && visd1[2] == 1 && visd1[3] == 1 && visd1[4] == 1) {
continue;
} else {
return false;
}
}
}
return true;
}
bool check2() {
}
void dfs(int no, int x, int y ) {
bool visn[7];
if (isok) return ;
if (no >= counts - 1) {
for (int i = 1; i <= 4; i++) {
mp[x][y] = '0' + i;
if (check()) {
pri();
isok = true;
return ;
}
}
return ;
}
CLR(visn, 0);
for (int i = 1; i <= 4; i ++) {
if (mp[i][y] == '1') {
visn[1] = 1;
} else if (mp[i][y] == '2') {
visn[2] = 1;
} else if (mp[i][y] == '3') {
visn[3] = 1;
} else if (mp[i][y] == '4') {
visn[4] = 1;
}
if (mp[x][i] == '1') {
visn[1] = 1;
} else if (mp[x][i] == '2') {
visn[2] = 1;
} else if (mp[x][i] == '3') {
visn[3] = 1;
} else if (mp[x][i] == '4') {
visn[4] = 1;
}
}
if (isok) return;
++no;
for (int i = 1; i <= 4 && !isok; i++) {
if (!visn[i]) {
mp[x][y] = i + '0';
vis[x][y] = 1;
int xx = v[no].x;
int yy = v[no].y;
// cout<<"i = "<<i<<endl;
// pri();
// cout<<endl;
dfs(no, xx, yy);
if (isok) return;
mp[x][y] = '*';
vis[x][y] = 0;
// cout<<endl;
// pri();
// cout<<endl;
}
}
--no;
}
int main()
{
// freopen("f:/input.txt", "r", stdin);
int i , j , k;
scanf("%d", &n);
for (zu = 1; zu <= n ; zu ++) {
scanf("%s",mp[1] + 1);
scanf("%s",mp[2] + 1);
scanf("%s",mp[3] + 1);
scanf("%s",mp[4] + 1);
v.clear();
CLR(vis, 0);
counts = 0;
for (i = 1 ; i <= 4; i ++) {
for (j = 1; j <= 4; j ++) {
if (mp[i][j] == '*') {
++counts;
nodes nd;
nd.x = i;
nd.y = j;
v.push_back(nd);
}
}
}
if (counts == 0) {
pri();
continue;
}
now = 0;
isok = false;
int xx = v[0].x;
int yy = v[0].y;
dfs(0, xx, yy);
if (!isok) pri();
}
}
|
900764681e0bba5a62dc150842a20d53bdecfe4b | 51f2492a5c207e3664de8f6b2d54bb93e313ca63 | /codechef/oct17/chefgp.cc | 59c37c614f7917885ee969e2d79c71e74554394a | [
"WTFPL",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | abeaumont/competitive-programming | 23c5aabd587d7bb15a61efd3428838cb934233dd | a24c9b89941a59d344b51dc1010de66522b1a0dd | refs/heads/master | 2023-09-01T09:50:58.267361 | 2023-07-31T18:00:10 | 2023-07-31T18:00:10 | 117,589,708 | 618 | 262 | WTFPL | 2023-07-12T17:36:20 | 2018-01-15T20:00:56 | C++ | UTF-8 | C++ | false | false | 1,963 | cc | chefgp.cc | // https://www.codechef.com/OCT17/problems/CHEFGP/
#include <iostream>
using namespace std;
void f() {
string s;
int x, y;
cin >> s >> x >> y;
int a = 0;
int b = 0;
for (int j = 0; j < s.size(); j++) {
if (s[j] == 'a') a++;
else b++;
}
int ca = (a + x - 1) / x;
int cb = (b + y - 1) / y;
if (ca == cb) {
while (a >= x && b >= y) {
for (int k = 0; k < x; k++) cout << 'a';
a -= x;
for (int k = 0; k < y; k++) cout << 'b';
b -= y;
}
for (int k = 0; k < a; k++) cout << 'a';
for (int k = 0; k < b; k++) cout << 'b';
cout << endl;
return;
}
if (ca > cb && b >= ca) {
int kb = b / ca;
int mb = b % ca;
while (a >= x) {
for (int k = 0; k < x; k++) cout << 'a';
a -= x;
int l = kb + (mb ? 1 : 0);
for (int k = 0; k < l; k++) cout << 'b';
b -= l;
if (mb) mb--;
}
for (int k = 0; k < a; k++) cout << 'a';
for (int k = 0; k < b; k++) cout << 'b';
cout << endl;
return;
}
if (ca > cb) {
while (b > 0) {
for (int k = 0; k < x; k++) cout << 'a';
a -= x;
cout << 'b';
b--;
}
while (a > 0) {
int l = min(a, x);
for (int k = 0; k < l; k++) cout << 'a';
a -= l;
if (a) cout << '*';
}
cout << endl;
return;
}
if (ca < cb && a >= cb) {
int ka = a / cb;
int ma = a % cb;
while (b >= y) {
for (int k = 0; k < y; k++) cout << 'b';
b -= y;
int l = ka + (ma ? 1 : 0);
for (int k = 0; k < l; k++) cout << 'a';
a -= l;
if (ma) ma--;
}
for (int k = 0; k < b; k++) cout << 'b';
for (int k = 0; k < a; k++) cout << 'a';
cout << endl;
return;
}
while (a > 0) {
for (int k = 0; k < y; k++) cout << 'b';
b -= y;
cout << 'a';
a--;
}
while (b > 0) {
int l = min(b, y);
for (int k = 0; k < l; k++) cout << 'b';
b -= l;
if (b) cout << '*';
}
cout << endl;
return;
}
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
f();
}
}
|
8c829ed2c381e8c3efba198db72b05ac6122fb6b | 54401a1847774e176acc87b177f39f2e9da38849 | /src/strap/mmkp/algorithm/lmck_base_solution.cpp | 2bfdad1bb1d7bbb1f2909dba9c7c22daf4b0e84b | [
"MIT"
] | permissive | likr/strap | 5c77274ab76ac0aff051af473d1e786b07d2ac5c | 387162116bab2031e8855f8c686560d7e656b417 | refs/heads/master | 2016-09-10T16:25:58.712659 | 2015-05-18T05:12:01 | 2015-05-18T05:12:01 | 35,797,991 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,281 | cpp | lmck_base_solution.cpp | #include <memory>
#include <strap/common/core/class_indexed_data.hpp>
#include <strap/common/core/index.hpp>
#include <strap/mckp/core/problem.hpp>
#include <strap/mckp/algorithm/lp_relaxation.hpp>
#include <strap/mmkp/core/problem.hpp>
#include <strap/mmkp/algorithm/lmck_base_solution.hpp>
#include <strap/mmkp/algorithm/surrogate_constraints.hpp>
namespace strap {
namespace mmkp {
namespace algorithm {
template<typename PType, typename WType>
ClassIndexedData<int>* lmck_base_solution(
const Problem<PType, WType>& problem)
{
std::unique_ptr<mckp::Problem<PType, double> > mck_problem(surrogate_constraints(problem));
std::unique_ptr<mckp::algorithm::LpRelaxationProblem<PType, double> >
lmck_problem(new mckp::algorithm::LpRelaxationProblem<PType, double>(*mck_problem, problem.index()));
return lmck_problem->solve_with_solution();
}
template ClassIndexedData<int>* lmck_base_solution(const Problem<int, int>& problem);
template ClassIndexedData<int>* lmck_base_solution(const Problem<int, double>& problem);
template ClassIndexedData<int>* lmck_base_solution(const Problem<double, int>& problem);
template ClassIndexedData<int>* lmck_base_solution(const Problem<double, double>& problem);
} // namespace algorithm
} // namespace mmkp
} // namespace strap
|
6b1e518b6424850eb7622320648088579a91c557 | 14853c830eb736c3f103f252fbfd2b7fab866601 | /Win32Project5/Win32Project5/Source.cpp | 219b6ee9f6f8b9fe2661982507640c0b5b3292a2 | [] | no_license | PoorLissa/DirX9 | d069fec08fac1961898f77f7ef119d0c80345af1 | 89cebb7fdd4093701f428f72621309c3d82dc0a7 | refs/heads/master | 2020-12-24T09:56:14.969243 | 2016-11-09T06:19:45 | 2016-11-09T06:19:45 | 73,256,658 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 4,962 | cpp | Source.cpp | // define the screen resolution
#define SCREEN_WIDTH 1600
#define SCREEN_HEIGHT 900
#define fullScreen
#undef fullScreen
// include the basic windows header file
#include <windows.h>
#include <string>
#include <windowsx.h>
#include "__d3d.h"
// mouse coordinates
int xPos = 0, yPos = 0, xPos0, yPos0, zPos = 0;
// the WindowProc function prototype
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int func() {
return 1, 2, 3, 4, 5;
}
// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// the handle for the window, filled by a function
HWND hWnd;
// this struct holds information for the window class
WNDCLASSEX wc;
// clear out the window class for use
ZeroMemory(&wc, sizeof(WNDCLASSEX));
// fill in the struct with the needed information
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_CROSS);
//wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszClassName = L"WindowClass1";
// register the window class
RegisterClassEx(&wc);
// create the window and use the result as the handle
hWnd = CreateWindowEx(NULL,
L"WindowClass1", // name of the window class
L"Our First Windowed Program", // title of the window
#if defined fullScreen
WS_OVERLAPPEDWINDOW, // window style
#else
WS_EX_TOPMOST | WS_POPUP, // fullscreen values
#endif
10, // x-position of the window
10, // y-position of the window
#if defined fullScreen
SCREEN_WIDTH, // width of the window
SCREEN_HEIGHT, // height of the window
#else
800,
500,
#endif
NULL, // we have no parent window, NULL
NULL, // we aren't using menus, NULL
hInstance, // application handle
NULL); // used with multiple windows, NULL
// display the window on the screen
ShowWindow(hWnd, nCmdShow);
#if defined fullScreen
initD3D(hWnd, SCREEN_WIDTH, SCREEN_HEIGHT);
#else
initD3D(hWnd, 800, 500);
#endif
// enter the main loop:
// this struct holds Windows event messages
MSG msg;
unsigned long Counter = 0;
// Enter the infinite message loop
while(TRUE)
{
// Check to see if any messages are waiting in the queue
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// translate keystroke messages into the right format
TranslateMessage(&msg);
// send the message to the WindowProc function
DispatchMessage(&msg);
}
// If the message is WM_QUIT, exit the while loop
if(msg.message == WM_QUIT)
break;
// Run game code here
Counter++;
render_frame3();
// ...
// ...
}
TCHAR buffer[65];
_itow_s(Counter, buffer, 10);
//MessageBox(NULL, buffer, L"huyets", 0);
cleanD3D();
// return this part of the WM_QUIT message to Windows
return msg.wParam;
}
// this is the main message handler for the program
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// sort through and find what code to run for the message given
switch(message)
{
// this message is read when the window is closed
case WM_DESTROY: {
// close the application entirely
PostQuitMessage(0);
return 0;
} break;
// onKeyDown
case WM_KEYDOWN: {
switch( LOWORD(wParam) )
{
case VK_ESCAPE:
PostQuitMessage(0);
return 0;
break;
}
} break;
// onMouseButtonDown
case WM_RBUTTONDOWN: {
// ะทะฐะฟะพะผะธะฝะฐะตะผ ะบะพะพัะดะธะฝะฐัั, ะณะดะต ะฝะฐะถะฐะปะธ ะบะฝะพะฟะบั ะผััะธ
xPos0 = GET_X_LPARAM(lParam);
yPos0 = GET_Y_LPARAM(lParam);
} break;
// onMouseButtonUp
case WM_MBUTTONUP: {
} break;
// onMouseMove
case WM_MOUSEMOVE: {
if (LOWORD(wParam) == MK_RBUTTON) {
int x = GET_X_LPARAM(lParam);
xPos += xPos0 - x;
xPos0 = x;
int y = GET_Y_LPARAM(lParam);
yPos += y - yPos0;
yPos0 = y;
}
} break;
case WM_MOUSEWHEEL: {
zPos -= GET_WHEEL_DELTA_WPARAM(wParam);
} break;
}
// Handle any messages the switch statement didn't
return DefWindowProc(hWnd, message, wParam, lParam);
} |
49acc9122b849975df191b0bbb74fb1e78adb52a | 2e96b02aeba1815cfca601f8d3290af11df767b9 | /RegularMachine/Grammar.cpp | 08ad8c2b508d91785de8e29b98ea363a0688ef87 | [] | no_license | Comcx/Siftor | 1cef9fa9d0d6d84d332a5e4c8f7c2d1bc54591d8 | 912cd9b3bfa2307499b8dcaa44b8be0bc0bfd7f7 | refs/heads/master | 2020-04-20T20:03:46.356231 | 2019-05-03T22:04:05 | 2019-05-03T22:04:05 | 169,066,214 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,633 | cpp | Grammar.cpp | #include "Grammar.h"
#include <iostream>
#include <algorithm>
Symbol
symbol(SymbolType t, String v) {
Symbol ans = {t, v};
return ans;
}
Symbol
symbol(String s) {
return seq(s).front();
}
Seq
seq(String raw) {
Seq ans;
Bool literalMode(false);
Bool V_NMode(false);
var it = raw.begin();
String cur("");
while(it != raw.end()) {
Char c(*it);
switch(c) {
case '[':
V_NMode = true;
it++;
break;
case ']':
V_NMode = false;
if(cur == "") ans.push_back(symbol(V_T, cur));
else ans.push_back(symbol(V_N, cur));
it++;
cur = "";
break;
case '<':
literalMode = true;
it++;
break;
case '>':
literalMode = false;
ans.push_back(symbol(V_T, cur));
it++;
cur = "";
break;
default:
if(V_NMode) {
cur += c;
it++;
}
else if(literalMode) {
cur += c;
it++;
}
else {
ans.push_back(symbol(V_T, String(1, c)));
it++;
}
}//end seitch
}//end while
return ans;
}
Rule
rule(Seq l, Seq r) {
Rule ans = {l, r};
return ans;
}
Rule
rule(String s) {
String l("");
String r("");
//-> to blanks
for(var it = s.begin(); it != s.end(); it++) {
if(*it == '-')
if(*(++it) == '>') {
*it = ' ';
*(--it) = ' ';
}
}
var it = s.begin();
for(;it != s.end() && *it != ' ';
it++) {
l.push_back(*it);
}//end for left
//skip blanks
for(; it != s.end() && *it == ' ';
it++);
for(;it != s.end() && *it != ' ';
it++) {
r.push_back(*it);
}//end for right
return rule(seq(l), seq(r));
}
mix<Set T> static Bool
contain(const Vector<T> &v, const T &e) {
for(val &x : v) {
if(x == e) return true;
}
return false;
}
static Bool containV_N(const Seq &s) {
Bool ans(false);
for(val &c : s)
if(c.type == V_N) {
ans = true;
break;
}
return ans;
}
static Bool containV_T(const Seq &s) {
Bool ans(false);
for(val &c : s)
if(c.type == V_T) {
ans = true;
break;
}
return ans;
}
static Bool existLeft(const Seq &s, const Grammar &g) {
for(val &r : g) {
if(r.left == s) return true;
}
return false;
}
RuleType
ruleType(const Rule &r) {
RuleType ans(TURING);
//1 type?
if(r.left.size() <= r.right.size()) {
ans = CONTEXT;
//2 type?
if(r.left.size() == 1) {
ans = CONTEXT_FREE;
//3 type?
if(r.right.size() == 1 &&
r.right.front().type == V_T
||
r.right.size() == 2 &&
r.right.front().type == V_T &&
(++r.right.cbegin())->type == V_N) ans = REGULAR;
}
}
return ans;
}
String
show(const SymbolType &t) {
String ans("NONE");
switch(t) {
case V_T: ans = "V_T"; break;
case V_N: ans = "V_N"; break;
default: ;
}
return ans;
}
String
show(const Symbol &s) {
return s.type == V_N ?
"[" + s.value + "]" :
s.value == "" ?
"[]" : s.value;
}
String
show(const Seq &s) {
String ans("");
for(val &e : s) ans += show(e);
return ans;
}
String
show(const Rule &r) {
return show(r.left) + "\t->\t" + show(r.right);
}
String
show(const Grammar &g) {
String ans("");
for(val &r : g) ans += show(r) + "\n";
return ans;
}
static Int
getLeftMost(const Seq &s) {
Int ans(0);
var it(s.begin());
for(; ans < s.size()
&& it->type != V_N; ++ans, ++it);
return ans;
}
static Int
getRightMost(const Seq &s) {
Int ans(s.size());
var it(--s.end());
for(; ans >= 0
&& it->type != V_N; --ans, --it);
return ans;
}
Seq
infer2l(const Seq &s, const Rule &r) {
Seq ans(s);
var it = ans.begin();
it = next(it, getLeftMost(ans));
if(r.left.size() == 1 && r.left.front() == *it) {
it = ans.erase(it);
it = ans.insert(it, r.right.begin(), r.right.end());
}
return ans;
}
Seq
infer2r(const Seq &s, const Rule &r) {
Seq ans(s);
var it = ans.begin();
it = next(it, getRightMost(ans));
if(r.left.size() == 1 && r.left.front() == *it) {
it = ans.erase(it);
it = ans.insert(it, r.right.begin(), r.right.end());
}
return ans;
}
static Rules
gatherSame(const Seq &s, const Grammar &g) {
Rules ans {};
for(val &r : g) {
if(r.left == s) ans.push_back(r);
}
return ans;
}
mix<Set T> static Vector<T>&
merge(Vector<T> &v, const T &e) {
for(val &x : v) {
if(e == x) return v;
}
v.push_back(e);
return v;
}
mix<Set T> static Vector<T>&
merge(Vector<T> &a, const Vector<T> &b) {//can be optimized, but left to do later!
for(val &e : b) {
merge(a, e);
}
return a;
}
static Vector<Symbol>&
washEmpty(Vector<Symbol> &v) {
for(var it = v.begin(); it != v.end();) {
if(it->value == "") it = v.erase(it);
else ++it;
}
return v;
}
Symbols getV_Ns(const Grammar &g) {
Symbols ans {};
for(val &r : g) {
if(!contain(ans, r.left.front()))
ans.push_back(r.left.front());
}
return ans;
}
Symbols getV_Ts(const Grammar &g) {
Symbols ans {};
for(val &r : g) {
var s = r.left;
s.insert(s.end(), r.right.begin(), r.right.end());
for(val &c : s) {
if(!contain(ans, c))
ans.push_back(c);
}
}
return ans;
}
//enum ThreeLogic
//{ OK, NO, UN };
static ThreeLogic
canBeEmpty(const Seq &s, Map<Symbol, ThreeLogic> &m) {
ThreeLogic ans(UN);
//can be empty directly
if(s.size() == 1 && s.front().value == "") ans = OK;
//can not be empty
else if(containV_T(s)) ans = NO;
else {// test
Int counter(0);
for(val &c : s) {
if(m.count(c) > 0 && m[c] == NO) {
ans = NO;
break;
}
else if(m.count(c) > 0 && m[c] == OK) {
counter++;
}
}//end for
if(counter == s.size()) ans = OK;
}
/*
std::cout << ">>" << show(s) << "\t" << ans << std::endl;
for(val &e : m) {
std::cout << show(e.first) << " " << e.second << std::endl << std::endl;;
}*/
return ans;
}
Map<Symbol, ThreeLogic>
emptyTable(const Grammar &g) {
Map<Symbol, ThreeLogic> ans {};
Grammar gg(g);
Int counter(gg.size());
while(!gg.empty()) {//std::cout << show(gg) << std::endl << std::endl;
for(var it = gg.begin(); it!= gg.end();) {
assert(it->left.size() == 1);
val cur = it->left;
val res = canBeEmpty(it->right, ans);
if(res != UN) {
it = gg.erase(it);
if(res == OK) ans[cur.front()] = OK;
if(res == NO && !existLeft(cur, gg))
if(ans.count(cur.front()) > 0 &&
ans[cur.front()] == OK);
else ans[cur.front()] = NO;
}
else ++it;
}
if(counter == gg.size()) break;
else counter = gg.size();
}
return ans;
}
static Symbols
firstOf(const Seqs &ss, const Grammar &g) {
Symbols ans {};
val empty_table = emptyTable(g);
Map<Symbol, Bool> ifEmpty {};
for(val &e : empty_table) {
switch(e.second) {
case OK: ifEmpty[e.first] = true; break;
default: ifEmpty[e.first] = false;
}
}
for(val &s : ss) {
if(s.front().type == V_T) merge(ans, s.front());
else {
if(s.size() == 1) {//is single V_N
val e = s.front();
if(e.type == V_T) merge(ans, e);
else {
const Seq tar {e};
Rules rules = gatherSame(tar, g);
for(val &r : rules) {//for every related rule
//start from V_T
if(r.right.front().type == V_T
||
!ifEmpty[r.right.front()]) {
Seq sss {r.right.front()};
val res = first(sss, g);
merge(ans, res);
}
else {//start from V_N
Int allEmptyCounter(0);
for(val &c : r.right) {
if(c.type == V_T) {
merge(ans, c);
break;//found first
}
else if(!ifEmpty[c]) {
const Seq tar {c};
Symbols res = first(tar, g);
merge(ans, res);
//ans.insert(ans.end(), res.begin(), res.end());
break;//found first
}
else {//can be empty
const Seq tar {c};
Symbols res = first(tar, g);
washEmpty(res);
merge(ans, res);
//ans.insert(ans.end(), res.begin(), res.end());
allEmptyCounter++;
}
}//end for r.right
if(allEmptyCounter == r.right.size()) merge(ans, symbol(V_T, ""));
}
}//end for rules
}
}
else {//is seq
val e = s.front();
if(e.type == V_T
||
e.type == V_N &&
ifEmpty.count(e) > 0 &&
!ifEmpty[e]) {
Seq tar {e};
val firstOfe = first(tar, g);
merge(ans, firstOfe);
break;
}
else {
Int allEmptyCounter(0);
for(val &c : s) {
if(c.type == V_T) {
merge(ans, c);
break;//found first
}
else if(!ifEmpty[c]) {
const Seq tar {c};
Symbols res = first(tar, g);
merge(ans, res);
//ans.insert(ans.end(), res.begin(), res.end());
break;//found first
}
else {//can be empty
const Seq tar {c};
Symbols res = first(tar, g);
//std::cout << ">> " << show(c) << std::endl;
washEmpty(res);
merge(ans, res);
//ans.insert(ans.end(), res.begin(), res.end());
allEmptyCounter++;
}
}//end for s
if(allEmptyCounter == s.size()) merge(ans, symbol(V_T, ""));
//underwork! can't firstof(seqs), only symbols
}
}//end if size
}//end if
}//end for ss
return ans;
}
Symbols
first(const Seq &s, const Grammar &g) {
Seqs ss {s};
return firstOf(ss, g);
}
Symbols
follow(const Symbol &s, const Grammar &g) {
//std::cout << show(s) << std::endl;
Symbols ans {};
val empty_table = emptyTable(g);
Map<Symbol, Bool> ifEmpty {};
for(val &e : empty_table) {
switch(e.second) {
case OK: ifEmpty[e.first] = true; break;
default: ifEmpty[e.first] = false;
}
}
for(val &r : g) {
Bool found(false);
for(var it = r.right.begin(); it != r.right.end(); ++it) {
if(found) {
assert(*it != s);
if(ifEmpty[*it]) {
val next = follow(r.left.front(), g);
merge(ans, next);
//ans.insert(ans.end(), next.begin(), next.end());
}
Seq ss;
ss.insert(ss.end(), it, r.right.end());
var next = first(ss, g);
next = washEmpty(next);
merge(ans, next);
//ans.insert(ans.end(), next.begin(), next.end());
found = false;
}
if(*it == s) {
found = true;
}
}//end for r.right
if(found) {//std::cout << "hello" << show(r) << std::endl;
//std::cout << show(r.left.front()) << std::endl;
if(//r.left.front() != symbol(V_N, "S") && //CAN NOT SOLVE !!!! STH WRONG :(
r.left.front() != r.right.back()) {
val next = follow(r.left.front(), g);
merge(ans, next);
//ans.insert(ans.end(), next.begin(), next.end());
}
else merge(ans, symbol(V_T, "#"));
}
}//end for g
if(s == symbol(V_N, "S")) merge(ans, symbol(V_T, "#"));
return ans;
}
Symbols
select(const Rule &r, const Grammar &g) {
Symbols ans {};
var rightFirst = first(r.right, g);
Bool canBeEmpty(true);
for(val &c : r.right) {
Seq tar {c};
val sss = first(tar, g);
if(!contain(sss, symbol(V_T, ""))) {
canBeEmpty = false;
break;
}
}
if(canBeEmpty) {
washEmpty(rightFirst);
ans = merge(rightFirst, follow(r.left.front(), g));
}
else {
ans = rightFirst;
}
return ans;
}
Bool
isLL1(const Grammar &g) {
Bool ans(true);
Seqs found {};
for(val &r : g) {
if(contain(found, r.left)) continue;
else found.push_back(r.left);
Rules same = gatherSame(r.left, g);
Symbols fst {};
for(val &r_ : same) {
val cur = select(r_, g);
val len = fst.size();
merge(fst, cur);
if(fst.size() < len + cur.size()) {
ans = false;
break;
}
}
}
return ans;
}
Bool
testGrammar(const Grammar &g) {
std::cout << "SELECT:" << std::endl;
for(val &r : g) {
val res = select(r, g);
std::cout << show(r) << "\t: ";
for(val &e : res)
std::cout << show(e) << " ";
std::cout << std::endl;
}
return isLL1(g);
}
static Map<Symbol, Map<Symbol, Seq>>
predictTable(const Grammar &g) {
Map<Symbol, Map<Symbol, Seq>> ans {};
Symbols V_Ns = getV_Ns(g);
Symbols V_Ts = getV_Ts(g);
for(val &r : g) {
Symbols res = select(r, g);
for(val &c : res) {
ans[r.left.front()][c] = r.right;
}
}
return ans;
}
Bool match(const Seq &raw, const Grammar &g) {
if(!isLL1(g)) return false;
Bool ans(true);
Seq s(raw);
Stack<Symbol> stk;
stk.push(symbol("#"));
stk.push(symbol("[S]"));
var predict = predictTable(g);
/*
for(val &m : predict)
for(val &n : m.second)
std::cout << show(m.first) << " " << show(n.first) << " ==> "
<< show(n.second) << std::endl;
*/
while(stk.size() != 1 || stk.top() != symbol("#") ||
s.size() != 1 || s.front() != symbol("#")) {
if(stk.top().type == V_T) {
if(stk.top() == s.front()) {
stk.pop();
s.erase(s.begin());
}
else {//std::cout << "hello" << show(stk.top()) << std::endl;
ans = false;
break;
}
}
else if(predict.count(stk.top()) > 0 &&
predict[stk.top()].count(s.front()) > 0) {
val pre = stk.top();
stk.pop();
val cur = predict[pre][s.front()];
for(var it = cur.rbegin(); it != cur.rend(); ++it) {
if(*it != symbol("[]")) stk.push(*it);
//std::cout << show(*it);
}
//std::cout << "\t=<>=\t" << show(s) << std::endl;
}
else {
//std::cout << "hello" << show(stk.top()) << std::endl;
ans = false;
break;
}
}
return ans;
}
Bool testMatch(const Grammar &g, const Seq &s) {
Bool ans = match(s, g);
std::cout << show(g) << std::endl
<< "test(" << "\"" << show(s) << "\"" << ")"
<< " ==> " << (ans ? "OK:)" : "NO:(") << std::endl;
return ans;
}
|
539c8af86add67203c6ed8f957a8a1c1bf21ff0f | 9f8a43fa3d1c2b266de1d75b154c3f13470c1661 | /Vector.cpp | 421b62f5d39fc2c5c893101c5649167c1e7f8fa9 | [] | no_license | wonderly321/SIFT_Feature_Extraction | fa63cb59aa6b5e2b249115fa04b06f2a2de8a8d9 | 53a626868330b933835e27cf4e0008f9a41728cf | refs/heads/master | 2020-05-07T01:12:48.347964 | 2019-04-11T08:27:05 | 2019-04-11T08:27:05 | 180,264,110 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,060 | cpp | Vector.cpp | /*----------------------------------
updated by wonderly321 on 4/11/19.
-----------------------------------*/
#include "Vector.h"
int vector_setup(Vector *vector, size_t capacity, size_t element_size)
{
assert(vector != NULL);
vector->size = 0;
vector->capacity = MAX(VECTOR_MINIMUM_CAPACITY, capacity);
vector->element_size = element_size;
vector->data = malloc(vector->capacity * element_size);
return vector->data == NULL ? VECTOR_ERROR : VECTOR_SUCCESS;
}
size_t vector_byte_size(const Vector *vector)
{
return vector->size * vector->element_size;
}
bool _vector_should_grow(Vector *vector)
{
assert(vector->size <= vector->capacity);
return vector->size == vector->capacity;
}
int _vector_reallocate(Vector *vector, size_t new_capacity)
{
size_t new_capacity_in_bytes;
void *old;
assert(vector != NULL);
if (new_capacity < VECTOR_MINIMUM_CAPACITY)
{
if (vector->capacity > VECTOR_MINIMUM_CAPACITY)
{
new_capacity = VECTOR_MINIMUM_CAPACITY;
}
else
{
/* NO-OP */
return VECTOR_SUCCESS;
}
}
new_capacity_in_bytes = new_capacity * vector->element_size;
old = vector->data;
if ((vector->data = malloc(new_capacity_in_bytes)) == NULL)
{
return VECTOR_ERROR;
}
#ifdef __STDC_LIB_EXT1__
/* clang-format off */
if (memcpy_s(vector->data,
new_capacity_in_bytes,
old,
vector_byte_size(vector)) != 0) {
return VECTOR_ERROR;
}
/* clang-format on */
#else
memcpy(vector->data, old, vector_byte_size(vector));
#endif
vector->capacity = new_capacity;
free(old);
return VECTOR_SUCCESS;
}
int _vector_adjust_capacity(Vector *vector)
{
return _vector_reallocate(vector,
MAX(1, vector->size * VECTOR_GROWTH_FACTOR));
}
int vector_resize(Vector *vector, size_t new_size)
{
if (new_size <= vector->capacity * VECTOR_SHRINK_THRESHOLD)
{
vector->size = new_size;
if (_vector_reallocate(vector, new_size * VECTOR_GROWTH_FACTOR) == -1)
{
return VECTOR_ERROR;
}
}
else if (new_size > vector->capacity)
{
if (_vector_reallocate(vector, new_size * VECTOR_GROWTH_FACTOR) == -1)
{
return VECTOR_ERROR;
}
}
vector->size = new_size;
return VECTOR_SUCCESS;
}
int vector_clear(Vector *vector)
{
return vector_resize(vector, 0);
}
void *_vector_offset_float(Vector *vector, size_t index)
{
//printf("----------%x", vector->data);
return ((char *)vector->data + (index * vector->element_size));
//return (float *)vector->data + (index * vector->element_size);
}
void _vector_assign_float(Vector *vector, size_t index, void *element)
{
/* Insert the element */
void *offset = _vector_offset_float(vector, index);
memcpy(offset, element, vector->element_size);
}
int vector_push_back_float(Vector *vector, void *element)
{
assert(vector != NULL);
assert(element != NULL);
if (_vector_should_grow(vector))
{
if (_vector_adjust_capacity(vector) == VECTOR_ERROR)
{
return VECTOR_ERROR;
}
}
_vector_assign_float(vector, vector->size, element);
++vector->size;
return VECTOR_SUCCESS;
}
void *vector_get_float(Vector *vector, size_t index) {
assert(vector != NULL);
assert(index < vector->size);
if (vector == NULL)
return NULL;
if (vector->element_size == 0)
return NULL;
if (index >= vector->size)
return NULL;
return _vector_offset_float(vector, index);
}
int vector_init_float(Vector *vector)
{
float tmp_float = 1024.0;
int tmp_size = vector->capacity;
for (int i = 0; i < tmp_size; ++i)
{
_vector_assign_float(vector, i, &tmp_float);
++(vector->size);
}
return 0;
}
int vector_init_float2(Vector *vector)
{
int tmp_cnt = 25;
for (int j = 0; j < tmp_cnt; ++j)
{
Vector *tmp_vector_float = (Vector *)malloc(sizeof(Vector));
vector_setup(tmp_vector_float, 1024, sizeof(float));
vector_push_back_float(vector, tmp_vector_float);
free(tmp_vector_float);
}
return 0;
}
int vector_assign_float(Vector *vector, size_t index, float *element)
{
assert(vector != NULL);
assert(element != NULL);
assert(index < vector->size);
if (vector == NULL)
return VECTOR_ERROR;
if (element == NULL)
return VECTOR_ERROR;
if (vector->element_size == 0)
return VECTOR_ERROR;
if (index >= vector->size)
return VECTOR_ERROR;
_vector_assign_float(vector, index, element);
return VECTOR_SUCCESS;
}
void *_vector_offset_imagefloat(Vector *vector, size_t index)
{
return (ImageObj_float *)((char *)vector->data + (index * vector->element_size));
//return (ImageObj_float *)vector->data + (index * vector->element_size);
}
void _vector_assign_imagefloat(Vector *vector, size_t index, void *element)
{
/* Insert the element */
void *offset = _vector_offset_imagefloat(vector, index);
memcpy(offset, element, vector->element_size);
}
void *vector_get_imagefloat(Vector *vector, size_t index) {
assert(vector != NULL);
assert(index < vector->size);
if (vector == NULL)
return NULL;
if (vector->element_size == 0)
return NULL;
if (index >= vector->size)
return NULL;
return _vector_offset_imagefloat(vector, index);
}
int vector_init_imagefloat(Vector *vector)
{
int tmp_size = vector->capacity;
for (int i = 0; i < tmp_size; ++i)
{
ImageObj_float *tmp_float = (ImageObj_float *)malloc(sizeof(ImageObj_float));
//printf("------dubug-----address-------%x\n",tmp_float);
init_float_imageobj(tmp_float, 1024, 1024);
_vector_assign_imagefloat(vector, i, tmp_float);
++vector->size;
free(tmp_float);
}
return 0;
}
int vector_init_imagefloat_allzero(Vector *vector)
{
int tmp_size = vector->capacity;
for (int i = 0; i < tmp_size; ++i)
{
ImageObj_float *tmp_float = (ImageObj_float *)malloc(sizeof(ImageObj_float));
//printf("------dubug-----address-------%x\n",tmp_float);
init_float_imageobj(tmp_float, 0, 0);
_vector_assign_imagefloat(vector, i, tmp_float);
++vector->size;
free(tmp_float);
}
return 0;
}
void *_vector_offset_imageuch(Vector *vector, size_t index)
{
return (ImageObj_uch *)((char *)vector->data + (index * vector->element_size));
}
void _vector_assign_imageuch(Vector *vector, size_t index, void *element)
{
/* Insert the element */
void *offset = _vector_offset_imageuch(vector, index);
//printf("#%d\n",((ImageObj_uch*)element)->w);
memcpy(offset, element, vector->element_size);
//printf("!%d %d\n",((ImageObj_uch*)offset)->w, index);
}
int vector_push_back_imageuch(Vector *vector, void *element)
{
assert(vector != NULL);
assert(element != NULL);
if (_vector_should_grow(vector))
{
if (_vector_adjust_capacity(vector) == VECTOR_ERROR)
{
return VECTOR_ERROR;
}
}
_vector_assign_imageuch(vector, vector->size, element);
++(vector->size);
return VECTOR_SUCCESS;
}
void *vector_get_imageuch(Vector *vector, size_t index) {
assert(vector != NULL);
assert(index < vector->size);
if (vector == NULL)
return NULL;
if (vector->element_size == 0)
return NULL;
if (index >= vector->size)
return NULL;
return _vector_offset_imageuch(vector, index);
}
void *_vector_offset_keypoint(Vector *vector, size_t index)
{
return (SiftKeypoint *)((char *)vector->data + (index * vector->element_size));
//return (ImageObj_uch *)((char *)vector->data + (index * vector->element_size));
}
void _vector_assign_keypoint(Vector *vector, size_t index, void *element)
{
/* Insert the element */
void *offset = _vector_offset_keypoint(vector, index);
memcpy(offset, element, vector->element_size);
}
int vector_push_back_keypoint(Vector *vector, void *element)
{
assert(vector != NULL);
assert(element != NULL);
if (_vector_should_grow(vector))
{
if (_vector_adjust_capacity(vector) == VECTOR_ERROR)
{
return VECTOR_ERROR;
}
}
_vector_assign_keypoint(vector, vector->size, element);
++vector->size;
return VECTOR_SUCCESS;
}
void *vector_get_keypoint(Vector *vector, size_t index) {
assert(vector != NULL);
assert(index < vector->size);
if (vector == NULL)
return NULL;
if (vector->element_size == 0)
return NULL;
if (index >= vector->size)
return NULL;
return _vector_offset_keypoint(vector, index);
}
void *_vector_offset_matchpair(Vector *vector, size_t index)
{
return (MatchPair *)((char *)vector->data + (index * vector->element_size));
//return (ImageObj_uch *)((char *)vector->data + (index * vector->element_size));
}
void _vector_assign_matchpair(Vector *vector, size_t index, void *element)
{
/* Insert the element */
void *offset = _vector_offset_matchpair(vector, index);
memcpy(offset, element, vector->element_size);
}
int vector_push_back_matchpair(Vector *vector, void *element)
{
assert(vector != NULL);
assert(element != NULL);
if (_vector_should_grow(vector))
{
if (_vector_adjust_capacity(vector) == VECTOR_ERROR)
{
return VECTOR_ERROR;
}
}
_vector_assign_matchpair(vector, vector->size, element);
++vector->size;
return VECTOR_SUCCESS;
}
void *vector_get_matchpair(Vector *vector, size_t index) {
assert(vector != NULL);
assert(index < vector->size);
if (vector == NULL)
return NULL;
if (vector->element_size == 0)
return NULL;
if (index >= vector->size)
return NULL;
return _vector_offset_matchpair(vector, index);
}
|
165c5afa6681ff171ff125aa333d9979d821e04c | 9f35c04628527375167b013b12e9e9abbb1f7f5f | /Data Structures & Algorithms/Order Statistics & Sorting/ReadInput.h | bf5c7cf0d11f95a3310aaacd0b5ab6a4effdcfd6 | [] | no_license | codevic/Important_Projects | 8d7d3ae89da697d9b4ca98e05f732b465387ebb1 | d1b7484c4aa5229711984282958e8bb5a3d860e8 | refs/heads/master | 2020-04-18T14:55:06.301650 | 2019-01-25T19:19:22 | 2019-01-25T19:19:22 | 167,600,865 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 465 | h | ReadInput.h | //
// Created by kavya on 5/3/2018.
//
#ifndef MENU_READINPUT_H
#define MENU_READINPUT_H
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>
#include "GenerateInput.h"
using namespace std;
class ReadInput {
public:
static void read_from_input(int choice_of_file, int choice_of_distribution, float array[], int n, int k, string timestamp);
};
#endif //MENU_READINPUT_H
|
6d55c9ebabab8a32cfb98219846e8a62edf406fa | 271a57344dcb49a80feae682ecc1d39f991eec81 | /src/wql/OW_WQLAst.hpp | fa21471563b53519fc8bd5fa67b6d4c3af997563 | [
"BSD-3-Clause"
] | permissive | kkaempf/openwbem | b16f7b8f0db6c1dbe1ee0467f7ab1b543253ea35 | b923c1fffd0e7f5489843c8c3b3850c50880ab9b | refs/heads/main | 2023-03-16T00:41:34.967003 | 2023-02-21T06:59:50 | 2023-02-21T06:59:50 | 5,981,070 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 92,889 | hpp | OW_WQLAst.hpp | /*******************************************************************************
* Copyright (C) 2003-2004 Quest Software, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of Quest Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Quest Software, Inc. OR THE CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
/**
* @author Dan Nuffer
*/
#ifndef OW_WQLAST_HPP_HPP_GUARD_
#define OW_WQLAST_HPP_HPP_GUARD_
#include "OW_config.h"
#include "blocxx/String.hpp"
#include "blocxx/Format.hpp"
#include "blocxx/List.hpp"
#include "OW_WQLVisitor.hpp"
#include <typeinfo>
#define OW_WQL_LOG_DEBUG(message) //nothing - until we create a way to get a logger
// The classes and functions defined in this file are not meant for general
// use, they are internal implementation details. They may change at any time.
namespace OW_NAMESPACE
{
namespace WQL
{
class OW_WQL_API node
{
public:
virtual ~node() {}
void acceptInterface( WQLVisitor * v)
{
OW_WQL_LOG_DEBUG(Format("About to accept node of type: %1 , using visitor : %2", typeid(*this).name(), typeid(*v).name()));
accept(v);
OW_WQL_LOG_DEBUG(Format("Finished accepting node of type: %1 , using visitor : %2", typeid(*this).name(), typeid(*v).name()));
}
private:
virtual void accept( WQLVisitor * ) const = 0;
};
class OW_WQL_API stmt: public node
{
public:
stmt()
{}
virtual ~stmt() {}
};
class OW_WQL_API stmt_selectStmt_optSemicolon : public stmt
{
public:
stmt_selectStmt_optSemicolon(
selectStmt* pNewselectStmt1,
optSemicolon* pNewoptSemicolon2
)
: stmt()
, m_pselectStmt1(pNewselectStmt1)
, m_poptSemicolon2(pNewoptSemicolon2)
{}
virtual ~stmt_selectStmt_optSemicolon();
void accept( WQLVisitor* v ) const
{
v->visit_stmt_selectStmt_optSemicolon( this );
}
selectStmt* m_pselectStmt1;
optSemicolon* m_poptSemicolon2;
};
class OW_WQL_API stmt_updateStmt_optSemicolon : public stmt
{
public:
stmt_updateStmt_optSemicolon(
updateStmt* pNewupdateStmt1,
optSemicolon* pNewoptSemicolon2
)
: stmt()
, m_pupdateStmt1(pNewupdateStmt1)
, m_poptSemicolon2(pNewoptSemicolon2)
{}
virtual ~stmt_updateStmt_optSemicolon();
void accept( WQLVisitor* v ) const
{
v->visit_stmt_updateStmt_optSemicolon( this );
}
updateStmt* m_pupdateStmt1;
optSemicolon* m_poptSemicolon2;
};
class OW_WQL_API stmt_insertStmt_optSemicolon : public stmt
{
public:
stmt_insertStmt_optSemicolon(
insertStmt* pNewinsertStmt1,
optSemicolon* pNewoptSemicolon2
)
: stmt()
, m_pinsertStmt1(pNewinsertStmt1)
, m_poptSemicolon2(pNewoptSemicolon2)
{}
virtual ~stmt_insertStmt_optSemicolon();
void accept( WQLVisitor* v ) const
{
v->visit_stmt_insertStmt_optSemicolon( this );
}
insertStmt* m_pinsertStmt1;
optSemicolon* m_poptSemicolon2;
};
class OW_WQL_API stmt_deleteStmt_optSemicolon : public stmt
{
public:
stmt_deleteStmt_optSemicolon(
deleteStmt* pNewdeleteStmt1,
optSemicolon* pNewoptSemicolon2
)
: stmt()
, m_pdeleteStmt1(pNewdeleteStmt1)
, m_poptSemicolon2(pNewoptSemicolon2)
{}
virtual ~stmt_deleteStmt_optSemicolon();
void accept( WQLVisitor* v ) const
{
v->visit_stmt_deleteStmt_optSemicolon( this );
}
deleteStmt* m_pdeleteStmt1;
optSemicolon* m_poptSemicolon2;
};
class OW_WQL_API optSemicolon: public node
{
public:
optSemicolon()
{}
virtual ~optSemicolon() {}
};
class OW_WQL_API optSemicolon_empty : public optSemicolon
{
public:
optSemicolon_empty(
)
: optSemicolon()
{}
virtual ~optSemicolon_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optSemicolon_empty( this );
}
};
class OW_WQL_API optSemicolon_SEMICOLON : public optSemicolon
{
public:
optSemicolon_SEMICOLON(
blocxx::String* pNewSEMICOLON1
)
: optSemicolon()
, m_pSEMICOLON1(pNewSEMICOLON1)
{}
virtual ~optSemicolon_SEMICOLON();
void accept( WQLVisitor* v ) const
{
v->visit_optSemicolon_SEMICOLON( this );
}
blocxx::String* m_pSEMICOLON1;
};
class OW_WQL_API insertStmt : public node
{
public:
insertStmt(
blocxx::String* pNewINSERT1,
blocxx::String* pNewINTO2,
blocxx::String* pNewstrRelationName3,
insertRest* pNewinsertRest4
)
: m_pINSERT1(pNewINSERT1)
, m_pINTO2(pNewINTO2)
, m_pstrRelationName3(pNewstrRelationName3)
, m_pinsertRest4(pNewinsertRest4)
{}
virtual ~insertStmt();
void accept( WQLVisitor* v ) const
{
v->visit_insertStmt( this );
}
blocxx::String* m_pINSERT1;
blocxx::String* m_pINTO2;
blocxx::String* m_pstrRelationName3;
insertRest* m_pinsertRest4;
};
class OW_WQL_API insertRest: public node
{
public:
insertRest()
{}
virtual ~insertRest() {}
};
class OW_WQL_API insertRest_VALUES_LEFTPAREN_targetList_RIGHTPAREN : public insertRest
{
public:
insertRest_VALUES_LEFTPAREN_targetList_RIGHTPAREN(
blocxx::String* pNewVALUES1,
blocxx::String* pNewLEFTPAREN2,
blocxx::List< targetEl* >* pNewtargetList3,
blocxx::String* pNewRIGHTPAREN4
)
: insertRest()
, m_pVALUES1(pNewVALUES1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_ptargetList3(pNewtargetList3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~insertRest_VALUES_LEFTPAREN_targetList_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_insertRest_VALUES_LEFTPAREN_targetList_RIGHTPAREN( this );
}
blocxx::String* m_pVALUES1;
blocxx::String* m_pLEFTPAREN2;
blocxx::List< targetEl* >* m_ptargetList3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API insertRest_DEFAULT_VALUES : public insertRest
{
public:
insertRest_DEFAULT_VALUES(
blocxx::String* pNewDEFAULT1,
blocxx::String* pNewVALUES2
)
: insertRest()
, m_pDEFAULT1(pNewDEFAULT1)
, m_pVALUES2(pNewVALUES2)
{}
virtual ~insertRest_DEFAULT_VALUES();
void accept( WQLVisitor* v ) const
{
v->visit_insertRest_DEFAULT_VALUES( this );
}
blocxx::String* m_pDEFAULT1;
blocxx::String* m_pVALUES2;
};
class OW_WQL_API insertRest_LEFTPAREN_columnList_RIGHTPAREN_VALUES_LEFTPAREN_targetList_RIGHTPAREN : public insertRest
{
public:
insertRest_LEFTPAREN_columnList_RIGHTPAREN_VALUES_LEFTPAREN_targetList_RIGHTPAREN(
blocxx::String* pNewLEFTPAREN1,
blocxx::List< blocxx::String* >* pNewcolumnList2,
blocxx::String* pNewRIGHTPAREN3,
blocxx::String* pNewVALUES4,
blocxx::String* pNewLEFTPAREN5,
blocxx::List< targetEl* >* pNewtargetList6,
blocxx::String* pNewRIGHTPAREN7
)
: insertRest()
, m_pLEFTPAREN1(pNewLEFTPAREN1)
, m_pcolumnList2(pNewcolumnList2)
, m_pRIGHTPAREN3(pNewRIGHTPAREN3)
, m_pVALUES4(pNewVALUES4)
, m_pLEFTPAREN5(pNewLEFTPAREN5)
, m_ptargetList6(pNewtargetList6)
, m_pRIGHTPAREN7(pNewRIGHTPAREN7)
{}
virtual ~insertRest_LEFTPAREN_columnList_RIGHTPAREN_VALUES_LEFTPAREN_targetList_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_insertRest_LEFTPAREN_columnList_RIGHTPAREN_VALUES_LEFTPAREN_targetList_RIGHTPAREN( this );
}
blocxx::String* m_pLEFTPAREN1;
blocxx::List< blocxx::String* >* m_pcolumnList2;
blocxx::String* m_pRIGHTPAREN3;
blocxx::String* m_pVALUES4;
blocxx::String* m_pLEFTPAREN5;
blocxx::List< targetEl* >* m_ptargetList6;
blocxx::String* m_pRIGHTPAREN7;
};
class OW_WQL_API deleteStmt : public node
{
public:
deleteStmt(
blocxx::String* pNewDELETE1,
blocxx::String* pNewFROM2,
blocxx::String* pNewstrRelationName3,
optWhereClause* pNewoptWhereClause4
)
: m_pDELETE1(pNewDELETE1)
, m_pFROM2(pNewFROM2)
, m_pstrRelationName3(pNewstrRelationName3)
, m_poptWhereClause4(pNewoptWhereClause4)
{}
virtual ~deleteStmt();
void accept( WQLVisitor* v ) const
{
v->visit_deleteStmt( this );
}
blocxx::String* m_pDELETE1;
blocxx::String* m_pFROM2;
blocxx::String* m_pstrRelationName3;
optWhereClause* m_poptWhereClause4;
};
class OW_WQL_API updateStmt : public node
{
public:
updateStmt(
blocxx::String* pNewUPDATE1,
blocxx::String* pNewstrRelationName2,
blocxx::String* pNewSET3,
blocxx::List< updateTargetEl* >* pNewupdateTargetList4,
optWhereClause* pNewoptWhereClause5
)
: m_pUPDATE1(pNewUPDATE1)
, m_pstrRelationName2(pNewstrRelationName2)
, m_pSET3(pNewSET3)
, m_pupdateTargetList4(pNewupdateTargetList4)
, m_poptWhereClause5(pNewoptWhereClause5)
{}
virtual ~updateStmt();
void accept( WQLVisitor* v ) const
{
v->visit_updateStmt( this );
}
blocxx::String* m_pUPDATE1;
blocxx::String* m_pstrRelationName2;
blocxx::String* m_pSET3;
blocxx::List< updateTargetEl* >* m_pupdateTargetList4;
optWhereClause* m_poptWhereClause5;
};
class OW_WQL_API selectStmt : public node
{
public:
selectStmt(
blocxx::String* pNewSELECT1,
optDistinct* pNewoptDistinct2,
blocxx::List< targetEl* >* pNewtargetList3,
optFromClause* pNewoptFromClause4,
optWhereClause* pNewoptWhereClause5,
optGroupClause* pNewoptGroupClause6,
optHavingClause* pNewoptHavingClause7,
optSortClause* pNewoptSortClause8
)
: m_pSELECT1(pNewSELECT1)
, m_poptDistinct2(pNewoptDistinct2)
, m_ptargetList3(pNewtargetList3)
, m_poptFromClause4(pNewoptFromClause4)
, m_poptWhereClause5(pNewoptWhereClause5)
, m_poptGroupClause6(pNewoptGroupClause6)
, m_poptHavingClause7(pNewoptHavingClause7)
, m_poptSortClause8(pNewoptSortClause8)
{}
virtual ~selectStmt();
void accept( WQLVisitor* v ) const
{
v->visit_selectStmt( this );
}
blocxx::String* m_pSELECT1;
optDistinct* m_poptDistinct2;
blocxx::List< targetEl* >* m_ptargetList3;
optFromClause* m_poptFromClause4;
optWhereClause* m_poptWhereClause5;
optGroupClause* m_poptGroupClause6;
optHavingClause* m_poptHavingClause7;
optSortClause* m_poptSortClause8;
};
class OW_WQL_API exprSeq: public node
{
public:
exprSeq()
{}
virtual ~exprSeq() {}
};
class OW_WQL_API exprSeq_aExpr : public exprSeq
{
public:
exprSeq_aExpr(
aExpr* pNewaExpr1
)
: exprSeq()
, m_paExpr1(pNewaExpr1)
{}
virtual ~exprSeq_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_exprSeq_aExpr( this );
}
aExpr* m_paExpr1;
};
class OW_WQL_API exprSeq_exprSeq_COMMA_aExpr : public exprSeq
{
public:
exprSeq_exprSeq_COMMA_aExpr(
exprSeq* pNewexprSeq1,
blocxx::String* pNewCOMMA2,
aExpr* pNewaExpr3
)
: exprSeq()
, m_pexprSeq1(pNewexprSeq1)
, m_pCOMMA2(pNewCOMMA2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~exprSeq_exprSeq_COMMA_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_exprSeq_exprSeq_COMMA_aExpr( this );
}
exprSeq* m_pexprSeq1;
blocxx::String* m_pCOMMA2;
aExpr* m_paExpr3;
};
class OW_WQL_API exprSeq_exprSeq_USING_aExpr : public exprSeq
{
public:
exprSeq_exprSeq_USING_aExpr(
exprSeq* pNewexprSeq1,
blocxx::String* pNewUSING2,
aExpr* pNewaExpr3
)
: exprSeq()
, m_pexprSeq1(pNewexprSeq1)
, m_pUSING2(pNewUSING2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~exprSeq_exprSeq_USING_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_exprSeq_exprSeq_USING_aExpr( this );
}
exprSeq* m_pexprSeq1;
blocxx::String* m_pUSING2;
aExpr* m_paExpr3;
};
class OW_WQL_API optDistinct: public node
{
public:
optDistinct()
{}
virtual ~optDistinct() {}
};
class OW_WQL_API optDistinct_empty : public optDistinct
{
public:
optDistinct_empty(
)
: optDistinct()
{}
virtual ~optDistinct_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optDistinct_empty( this );
}
};
class OW_WQL_API optDistinct_DISTINCT : public optDistinct
{
public:
optDistinct_DISTINCT(
blocxx::String* pNewDISTINCT1
)
: optDistinct()
, m_pDISTINCT1(pNewDISTINCT1)
{}
virtual ~optDistinct_DISTINCT();
void accept( WQLVisitor* v ) const
{
v->visit_optDistinct_DISTINCT( this );
}
blocxx::String* m_pDISTINCT1;
};
class OW_WQL_API optDistinct_DISTINCT_ON_LEFTPAREN_exprSeq_RIGHTPAREN : public optDistinct
{
public:
optDistinct_DISTINCT_ON_LEFTPAREN_exprSeq_RIGHTPAREN(
blocxx::String* pNewDISTINCT1,
blocxx::String* pNewON2,
blocxx::String* pNewLEFTPAREN3,
exprSeq* pNewexprSeq4,
blocxx::String* pNewRIGHTPAREN5
)
: optDistinct()
, m_pDISTINCT1(pNewDISTINCT1)
, m_pON2(pNewON2)
, m_pLEFTPAREN3(pNewLEFTPAREN3)
, m_pexprSeq4(pNewexprSeq4)
, m_pRIGHTPAREN5(pNewRIGHTPAREN5)
{}
virtual ~optDistinct_DISTINCT_ON_LEFTPAREN_exprSeq_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_optDistinct_DISTINCT_ON_LEFTPAREN_exprSeq_RIGHTPAREN( this );
}
blocxx::String* m_pDISTINCT1;
blocxx::String* m_pON2;
blocxx::String* m_pLEFTPAREN3;
exprSeq* m_pexprSeq4;
blocxx::String* m_pRIGHTPAREN5;
};
class OW_WQL_API optDistinct_ALL : public optDistinct
{
public:
optDistinct_ALL(
blocxx::String* pNewALL1
)
: optDistinct()
, m_pALL1(pNewALL1)
{}
virtual ~optDistinct_ALL();
void accept( WQLVisitor* v ) const
{
v->visit_optDistinct_ALL( this );
}
blocxx::String* m_pALL1;
};
class OW_WQL_API sortClause : public node
{
public:
sortClause(
blocxx::String* pNewORDER1,
blocxx::String* pNewBY2,
blocxx::List< sortby* >* pNewsortbyList3
)
: m_pORDER1(pNewORDER1)
, m_pBY2(pNewBY2)
, m_psortbyList3(pNewsortbyList3)
{}
virtual ~sortClause();
void accept( WQLVisitor* v ) const
{
v->visit_sortClause( this );
}
blocxx::String* m_pORDER1;
blocxx::String* m_pBY2;
blocxx::List< sortby* >* m_psortbyList3;
};
class OW_WQL_API optSortClause: public node
{
public:
optSortClause()
{}
virtual ~optSortClause() {}
};
class OW_WQL_API optSortClause_empty : public optSortClause
{
public:
optSortClause_empty(
)
: optSortClause()
{}
virtual ~optSortClause_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optSortClause_empty( this );
}
};
class OW_WQL_API optSortClause_sortClause : public optSortClause
{
public:
optSortClause_sortClause(
sortClause* pNewsortClause1
)
: optSortClause()
, m_psortClause1(pNewsortClause1)
{}
virtual ~optSortClause_sortClause();
void accept( WQLVisitor* v ) const
{
v->visit_optSortClause_sortClause( this );
}
sortClause* m_psortClause1;
};
class OW_WQL_API sortby : public node
{
public:
sortby(
aExpr* pNewaExpr1,
blocxx::String* pNewstrOptOrderSpecification2
)
: m_paExpr1(pNewaExpr1)
, m_pstrOptOrderSpecification2(pNewstrOptOrderSpecification2)
{}
virtual ~sortby();
void accept( WQLVisitor* v ) const
{
v->visit_sortby( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pstrOptOrderSpecification2;
};
class OW_WQL_API optGroupClause: public node
{
public:
optGroupClause()
{}
virtual ~optGroupClause() {}
};
class OW_WQL_API optGroupClause_empty : public optGroupClause
{
public:
optGroupClause_empty(
)
: optGroupClause()
{}
virtual ~optGroupClause_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optGroupClause_empty( this );
}
};
class OW_WQL_API optGroupClause_GROUP_BY_exprSeq : public optGroupClause
{
public:
optGroupClause_GROUP_BY_exprSeq(
blocxx::String* pNewGROUP1,
blocxx::String* pNewBY2,
exprSeq* pNewexprSeq3
)
: optGroupClause()
, m_pGROUP1(pNewGROUP1)
, m_pBY2(pNewBY2)
, m_pexprSeq3(pNewexprSeq3)
{}
virtual ~optGroupClause_GROUP_BY_exprSeq();
void accept( WQLVisitor* v ) const
{
v->visit_optGroupClause_GROUP_BY_exprSeq( this );
}
blocxx::String* m_pGROUP1;
blocxx::String* m_pBY2;
exprSeq* m_pexprSeq3;
};
class OW_WQL_API optHavingClause: public node
{
public:
optHavingClause()
{}
virtual ~optHavingClause() {}
};
class OW_WQL_API optHavingClause_empty : public optHavingClause
{
public:
optHavingClause_empty(
)
: optHavingClause()
{}
virtual ~optHavingClause_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optHavingClause_empty( this );
}
};
class OW_WQL_API optHavingClause_HAVING_aExpr : public optHavingClause
{
public:
optHavingClause_HAVING_aExpr(
blocxx::String* pNewHAVING1,
aExpr* pNewaExpr2
)
: optHavingClause()
, m_pHAVING1(pNewHAVING1)
, m_paExpr2(pNewaExpr2)
{}
virtual ~optHavingClause_HAVING_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_optHavingClause_HAVING_aExpr( this );
}
blocxx::String* m_pHAVING1;
aExpr* m_paExpr2;
};
class OW_WQL_API optFromClause: public node
{
public:
optFromClause()
{}
virtual ~optFromClause() {}
};
class OW_WQL_API optFromClause_empty : public optFromClause
{
public:
optFromClause_empty(
)
: optFromClause()
{}
virtual ~optFromClause_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optFromClause_empty( this );
}
};
class OW_WQL_API optFromClause_FROM_fromList : public optFromClause
{
public:
optFromClause_FROM_fromList(
blocxx::String* pNewFROM1,
blocxx::List< tableRef* >* pNewfromList2
)
: optFromClause()
, m_pFROM1(pNewFROM1)
, m_pfromList2(pNewfromList2)
{}
virtual ~optFromClause_FROM_fromList();
void accept( WQLVisitor* v ) const
{
v->visit_optFromClause_FROM_fromList( this );
}
blocxx::String* m_pFROM1;
blocxx::List< tableRef* >* m_pfromList2;
};
class OW_WQL_API tableRef: public node
{
public:
tableRef()
{}
virtual ~tableRef() {}
};
class OW_WQL_API tableRef_relationExpr : public tableRef
{
public:
tableRef_relationExpr(
relationExpr* pNewrelationExpr1
)
: tableRef()
, m_prelationExpr1(pNewrelationExpr1)
{}
virtual ~tableRef_relationExpr();
void accept( WQLVisitor* v ) const
{
v->visit_tableRef_relationExpr( this );
}
relationExpr* m_prelationExpr1;
};
class OW_WQL_API tableRef_relationExpr_aliasClause : public tableRef
{
public:
tableRef_relationExpr_aliasClause(
relationExpr* pNewrelationExpr1,
aliasClause* pNewaliasClause2
)
: tableRef()
, m_prelationExpr1(pNewrelationExpr1)
, m_paliasClause2(pNewaliasClause2)
{}
virtual ~tableRef_relationExpr_aliasClause();
void accept( WQLVisitor* v ) const
{
v->visit_tableRef_relationExpr_aliasClause( this );
}
relationExpr* m_prelationExpr1;
aliasClause* m_paliasClause2;
};
class OW_WQL_API tableRef_joinedTable : public tableRef
{
public:
tableRef_joinedTable(
joinedTable* pNewjoinedTable1
)
: tableRef()
, m_pjoinedTable1(pNewjoinedTable1)
{}
virtual ~tableRef_joinedTable();
void accept( WQLVisitor* v ) const
{
v->visit_tableRef_joinedTable( this );
}
joinedTable* m_pjoinedTable1;
};
class OW_WQL_API tableRef_LEFTPAREN_joinedTable_RIGHTPAREN_aliasClause : public tableRef
{
public:
tableRef_LEFTPAREN_joinedTable_RIGHTPAREN_aliasClause(
blocxx::String* pNewLEFTPAREN1,
joinedTable* pNewjoinedTable2,
blocxx::String* pNewRIGHTPAREN3,
aliasClause* pNewaliasClause4
)
: tableRef()
, m_pLEFTPAREN1(pNewLEFTPAREN1)
, m_pjoinedTable2(pNewjoinedTable2)
, m_pRIGHTPAREN3(pNewRIGHTPAREN3)
, m_paliasClause4(pNewaliasClause4)
{}
virtual ~tableRef_LEFTPAREN_joinedTable_RIGHTPAREN_aliasClause();
void accept( WQLVisitor* v ) const
{
v->visit_tableRef_LEFTPAREN_joinedTable_RIGHTPAREN_aliasClause( this );
}
blocxx::String* m_pLEFTPAREN1;
joinedTable* m_pjoinedTable2;
blocxx::String* m_pRIGHTPAREN3;
aliasClause* m_paliasClause4;
};
class OW_WQL_API joinedTable: public node
{
public:
joinedTable()
{}
virtual ~joinedTable() {}
};
class OW_WQL_API joinedTable_LEFTPAREN_joinedTable_RIGHTPAREN : public joinedTable
{
public:
joinedTable_LEFTPAREN_joinedTable_RIGHTPAREN(
blocxx::String* pNewLEFTPAREN1,
joinedTable* pNewjoinedTable2,
blocxx::String* pNewRIGHTPAREN3
)
: joinedTable()
, m_pLEFTPAREN1(pNewLEFTPAREN1)
, m_pjoinedTable2(pNewjoinedTable2)
, m_pRIGHTPAREN3(pNewRIGHTPAREN3)
{}
virtual ~joinedTable_LEFTPAREN_joinedTable_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_joinedTable_LEFTPAREN_joinedTable_RIGHTPAREN( this );
}
blocxx::String* m_pLEFTPAREN1;
joinedTable* m_pjoinedTable2;
blocxx::String* m_pRIGHTPAREN3;
};
class OW_WQL_API joinedTable_tableRef_CROSS_JOIN_tableRef : public joinedTable
{
public:
joinedTable_tableRef_CROSS_JOIN_tableRef(
tableRef* pNewtableRef1,
blocxx::String* pNewCROSS2,
blocxx::String* pNewJOIN3,
tableRef* pNewtableRef4
)
: joinedTable()
, m_ptableRef1(pNewtableRef1)
, m_pCROSS2(pNewCROSS2)
, m_pJOIN3(pNewJOIN3)
, m_ptableRef4(pNewtableRef4)
{}
virtual ~joinedTable_tableRef_CROSS_JOIN_tableRef();
void accept( WQLVisitor* v ) const
{
v->visit_joinedTable_tableRef_CROSS_JOIN_tableRef( this );
}
tableRef* m_ptableRef1;
blocxx::String* m_pCROSS2;
blocxx::String* m_pJOIN3;
tableRef* m_ptableRef4;
};
class OW_WQL_API joinedTable_tableRef_UNIONJOIN_tableRef : public joinedTable
{
public:
joinedTable_tableRef_UNIONJOIN_tableRef(
tableRef* pNewtableRef1,
blocxx::String* pNewUNIONJOIN2,
tableRef* pNewtableRef3
)
: joinedTable()
, m_ptableRef1(pNewtableRef1)
, m_pUNIONJOIN2(pNewUNIONJOIN2)
, m_ptableRef3(pNewtableRef3)
{}
virtual ~joinedTable_tableRef_UNIONJOIN_tableRef();
void accept( WQLVisitor* v ) const
{
v->visit_joinedTable_tableRef_UNIONJOIN_tableRef( this );
}
tableRef* m_ptableRef1;
blocxx::String* m_pUNIONJOIN2;
tableRef* m_ptableRef3;
};
class OW_WQL_API joinedTable_tableRef_joinType_JOIN_tableRef_joinQual : public joinedTable
{
public:
joinedTable_tableRef_joinType_JOIN_tableRef_joinQual(
tableRef* pNewtableRef1,
joinType* pNewjoinType2,
blocxx::String* pNewJOIN3,
tableRef* pNewtableRef4,
joinQual* pNewjoinQual5
)
: joinedTable()
, m_ptableRef1(pNewtableRef1)
, m_pjoinType2(pNewjoinType2)
, m_pJOIN3(pNewJOIN3)
, m_ptableRef4(pNewtableRef4)
, m_pjoinQual5(pNewjoinQual5)
{}
virtual ~joinedTable_tableRef_joinType_JOIN_tableRef_joinQual();
void accept( WQLVisitor* v ) const
{
v->visit_joinedTable_tableRef_joinType_JOIN_tableRef_joinQual( this );
}
tableRef* m_ptableRef1;
joinType* m_pjoinType2;
blocxx::String* m_pJOIN3;
tableRef* m_ptableRef4;
joinQual* m_pjoinQual5;
};
class OW_WQL_API joinedTable_tableRef_JOIN_tableRef_joinQual : public joinedTable
{
public:
joinedTable_tableRef_JOIN_tableRef_joinQual(
tableRef* pNewtableRef1,
blocxx::String* pNewJOIN2,
tableRef* pNewtableRef3,
joinQual* pNewjoinQual4
)
: joinedTable()
, m_ptableRef1(pNewtableRef1)
, m_pJOIN2(pNewJOIN2)
, m_ptableRef3(pNewtableRef3)
, m_pjoinQual4(pNewjoinQual4)
{}
virtual ~joinedTable_tableRef_JOIN_tableRef_joinQual();
void accept( WQLVisitor* v ) const
{
v->visit_joinedTable_tableRef_JOIN_tableRef_joinQual( this );
}
tableRef* m_ptableRef1;
blocxx::String* m_pJOIN2;
tableRef* m_ptableRef3;
joinQual* m_pjoinQual4;
};
class OW_WQL_API joinedTable_tableRef_NATURAL_joinType_JOIN_tableRef : public joinedTable
{
public:
joinedTable_tableRef_NATURAL_joinType_JOIN_tableRef(
tableRef* pNewtableRef1,
blocxx::String* pNewNATURAL2,
joinType* pNewjoinType3,
blocxx::String* pNewJOIN4,
tableRef* pNewtableRef5
)
: joinedTable()
, m_ptableRef1(pNewtableRef1)
, m_pNATURAL2(pNewNATURAL2)
, m_pjoinType3(pNewjoinType3)
, m_pJOIN4(pNewJOIN4)
, m_ptableRef5(pNewtableRef5)
{}
virtual ~joinedTable_tableRef_NATURAL_joinType_JOIN_tableRef();
void accept( WQLVisitor* v ) const
{
v->visit_joinedTable_tableRef_NATURAL_joinType_JOIN_tableRef( this );
}
tableRef* m_ptableRef1;
blocxx::String* m_pNATURAL2;
joinType* m_pjoinType3;
blocxx::String* m_pJOIN4;
tableRef* m_ptableRef5;
};
class OW_WQL_API joinedTable_tableRef_NATURAL_JOIN_tableRef : public joinedTable
{
public:
joinedTable_tableRef_NATURAL_JOIN_tableRef(
tableRef* pNewtableRef1,
blocxx::String* pNewNATURAL2,
blocxx::String* pNewJOIN3,
tableRef* pNewtableRef4
)
: joinedTable()
, m_ptableRef1(pNewtableRef1)
, m_pNATURAL2(pNewNATURAL2)
, m_pJOIN3(pNewJOIN3)
, m_ptableRef4(pNewtableRef4)
{}
virtual ~joinedTable_tableRef_NATURAL_JOIN_tableRef();
void accept( WQLVisitor* v ) const
{
v->visit_joinedTable_tableRef_NATURAL_JOIN_tableRef( this );
}
tableRef* m_ptableRef1;
blocxx::String* m_pNATURAL2;
blocxx::String* m_pJOIN3;
tableRef* m_ptableRef4;
};
class OW_WQL_API aliasClause: public node
{
public:
aliasClause()
{}
virtual ~aliasClause() {}
};
class OW_WQL_API aliasClause_AS_strColId_LEFTPAREN_nameList_RIGHTPAREN : public aliasClause
{
public:
aliasClause_AS_strColId_LEFTPAREN_nameList_RIGHTPAREN(
blocxx::String* pNewAS1,
blocxx::String* pNewstrColId2,
blocxx::String* pNewLEFTPAREN3,
blocxx::List< blocxx::String* >* pNewnameList4,
blocxx::String* pNewRIGHTPAREN5
)
: aliasClause()
, m_pAS1(pNewAS1)
, m_pstrColId2(pNewstrColId2)
, m_pLEFTPAREN3(pNewLEFTPAREN3)
, m_pnameList4(pNewnameList4)
, m_pRIGHTPAREN5(pNewRIGHTPAREN5)
{}
virtual ~aliasClause_AS_strColId_LEFTPAREN_nameList_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_aliasClause_AS_strColId_LEFTPAREN_nameList_RIGHTPAREN( this );
}
blocxx::String* m_pAS1;
blocxx::String* m_pstrColId2;
blocxx::String* m_pLEFTPAREN3;
blocxx::List< blocxx::String* >* m_pnameList4;
blocxx::String* m_pRIGHTPAREN5;
};
class OW_WQL_API aliasClause_AS_strColId : public aliasClause
{
public:
aliasClause_AS_strColId(
blocxx::String* pNewAS1,
blocxx::String* pNewstrColId2
)
: aliasClause()
, m_pAS1(pNewAS1)
, m_pstrColId2(pNewstrColId2)
{}
virtual ~aliasClause_AS_strColId();
void accept( WQLVisitor* v ) const
{
v->visit_aliasClause_AS_strColId( this );
}
blocxx::String* m_pAS1;
blocxx::String* m_pstrColId2;
};
class OW_WQL_API aliasClause_strColId_LEFTPAREN_nameList_RIGHTPAREN : public aliasClause
{
public:
aliasClause_strColId_LEFTPAREN_nameList_RIGHTPAREN(
blocxx::String* pNewstrColId1,
blocxx::String* pNewLEFTPAREN2,
blocxx::List< blocxx::String* >* pNewnameList3,
blocxx::String* pNewRIGHTPAREN4
)
: aliasClause()
, m_pstrColId1(pNewstrColId1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pnameList3(pNewnameList3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~aliasClause_strColId_LEFTPAREN_nameList_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_aliasClause_strColId_LEFTPAREN_nameList_RIGHTPAREN( this );
}
blocxx::String* m_pstrColId1;
blocxx::String* m_pLEFTPAREN2;
blocxx::List< blocxx::String* >* m_pnameList3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API aliasClause_strColId : public aliasClause
{
public:
aliasClause_strColId(
blocxx::String* pNewstrColId1
)
: aliasClause()
, m_pstrColId1(pNewstrColId1)
{}
virtual ~aliasClause_strColId();
void accept( WQLVisitor* v ) const
{
v->visit_aliasClause_strColId( this );
}
blocxx::String* m_pstrColId1;
};
class OW_WQL_API joinType: public node
{
public:
joinType()
{}
virtual ~joinType() {}
};
class OW_WQL_API joinType_FULL_strOptJoinOuter : public joinType
{
public:
joinType_FULL_strOptJoinOuter(
blocxx::String* pNewFULL1,
blocxx::String* pNewstrOptJoinOuter2
)
: joinType()
, m_pFULL1(pNewFULL1)
, m_pstrOptJoinOuter2(pNewstrOptJoinOuter2)
{}
virtual ~joinType_FULL_strOptJoinOuter();
void accept( WQLVisitor* v ) const
{
v->visit_joinType_FULL_strOptJoinOuter( this );
}
blocxx::String* m_pFULL1;
blocxx::String* m_pstrOptJoinOuter2;
};
class OW_WQL_API joinType_LEFT_strOptJoinOuter : public joinType
{
public:
joinType_LEFT_strOptJoinOuter(
blocxx::String* pNewLEFT1,
blocxx::String* pNewstrOptJoinOuter2
)
: joinType()
, m_pLEFT1(pNewLEFT1)
, m_pstrOptJoinOuter2(pNewstrOptJoinOuter2)
{}
virtual ~joinType_LEFT_strOptJoinOuter();
void accept( WQLVisitor* v ) const
{
v->visit_joinType_LEFT_strOptJoinOuter( this );
}
blocxx::String* m_pLEFT1;
blocxx::String* m_pstrOptJoinOuter2;
};
class OW_WQL_API joinType_RIGHT_strOptJoinOuter : public joinType
{
public:
joinType_RIGHT_strOptJoinOuter(
blocxx::String* pNewRIGHT1,
blocxx::String* pNewstrOptJoinOuter2
)
: joinType()
, m_pRIGHT1(pNewRIGHT1)
, m_pstrOptJoinOuter2(pNewstrOptJoinOuter2)
{}
virtual ~joinType_RIGHT_strOptJoinOuter();
void accept( WQLVisitor* v ) const
{
v->visit_joinType_RIGHT_strOptJoinOuter( this );
}
blocxx::String* m_pRIGHT1;
blocxx::String* m_pstrOptJoinOuter2;
};
class OW_WQL_API joinType_INNERP : public joinType
{
public:
joinType_INNERP(
blocxx::String* pNewINNERP1
)
: joinType()
, m_pINNERP1(pNewINNERP1)
{}
virtual ~joinType_INNERP();
void accept( WQLVisitor* v ) const
{
v->visit_joinType_INNERP( this );
}
blocxx::String* m_pINNERP1;
};
class OW_WQL_API joinQual: public node
{
public:
joinQual()
{}
virtual ~joinQual() {}
};
class OW_WQL_API joinQual_USING_LEFTPAREN_nameList_RIGHTPAREN : public joinQual
{
public:
joinQual_USING_LEFTPAREN_nameList_RIGHTPAREN(
blocxx::String* pNewUSING1,
blocxx::String* pNewLEFTPAREN2,
blocxx::List< blocxx::String* >* pNewnameList3,
blocxx::String* pNewRIGHTPAREN4
)
: joinQual()
, m_pUSING1(pNewUSING1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pnameList3(pNewnameList3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~joinQual_USING_LEFTPAREN_nameList_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_joinQual_USING_LEFTPAREN_nameList_RIGHTPAREN( this );
}
blocxx::String* m_pUSING1;
blocxx::String* m_pLEFTPAREN2;
blocxx::List< blocxx::String* >* m_pnameList3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API joinQual_ON_aExpr : public joinQual
{
public:
joinQual_ON_aExpr(
blocxx::String* pNewON1,
aExpr* pNewaExpr2
)
: joinQual()
, m_pON1(pNewON1)
, m_paExpr2(pNewaExpr2)
{}
virtual ~joinQual_ON_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_joinQual_ON_aExpr( this );
}
blocxx::String* m_pON1;
aExpr* m_paExpr2;
};
class OW_WQL_API relationExpr: public node
{
public:
relationExpr()
{}
virtual ~relationExpr() {}
};
class OW_WQL_API relationExpr_strRelationName : public relationExpr
{
public:
relationExpr_strRelationName(
blocxx::String* pNewstrRelationName1
)
: relationExpr()
, m_pstrRelationName1(pNewstrRelationName1)
{}
virtual ~relationExpr_strRelationName();
void accept( WQLVisitor* v ) const
{
v->visit_relationExpr_strRelationName( this );
}
blocxx::String* m_pstrRelationName1;
};
class OW_WQL_API relationExpr_strRelationName_ASTERISK : public relationExpr
{
public:
relationExpr_strRelationName_ASTERISK(
blocxx::String* pNewstrRelationName1,
blocxx::String* pNewASTERISK2
)
: relationExpr()
, m_pstrRelationName1(pNewstrRelationName1)
, m_pASTERISK2(pNewASTERISK2)
{}
virtual ~relationExpr_strRelationName_ASTERISK();
void accept( WQLVisitor* v ) const
{
v->visit_relationExpr_strRelationName_ASTERISK( this );
}
blocxx::String* m_pstrRelationName1;
blocxx::String* m_pASTERISK2;
};
class OW_WQL_API relationExpr_ONLY_strRelationName : public relationExpr
{
public:
relationExpr_ONLY_strRelationName(
blocxx::String* pNewONLY1,
blocxx::String* pNewstrRelationName2
)
: relationExpr()
, m_pONLY1(pNewONLY1)
, m_pstrRelationName2(pNewstrRelationName2)
{}
virtual ~relationExpr_ONLY_strRelationName();
void accept( WQLVisitor* v ) const
{
v->visit_relationExpr_ONLY_strRelationName( this );
}
blocxx::String* m_pONLY1;
blocxx::String* m_pstrRelationName2;
};
class OW_WQL_API optWhereClause: public node
{
public:
optWhereClause()
{}
virtual ~optWhereClause() {}
};
class OW_WQL_API optWhereClause_empty : public optWhereClause
{
public:
optWhereClause_empty(
)
: optWhereClause()
{}
virtual ~optWhereClause_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optWhereClause_empty( this );
}
};
class OW_WQL_API optWhereClause_WHERE_aExpr : public optWhereClause
{
public:
optWhereClause_WHERE_aExpr(
blocxx::String* pNewWHERE1,
aExpr* pNewaExpr2
)
: optWhereClause()
, m_pWHERE1(pNewWHERE1)
, m_paExpr2(pNewaExpr2)
{}
virtual ~optWhereClause_WHERE_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_optWhereClause_WHERE_aExpr( this );
}
blocxx::String* m_pWHERE1;
aExpr* m_paExpr2;
};
class OW_WQL_API rowExpr : public node
{
public:
rowExpr(
blocxx::String* pNewLEFTPAREN1,
rowDescriptor* pNewrowDescriptor2,
blocxx::String* pNewRIGHTPAREN3,
blocxx::String* pNewstrAllOp4,
blocxx::String* pNewLEFTPAREN5,
rowDescriptor* pNewrowDescriptor6,
blocxx::String* pNewRIGHTPAREN7
)
: m_pLEFTPAREN1(pNewLEFTPAREN1)
, m_prowDescriptor2(pNewrowDescriptor2)
, m_pRIGHTPAREN3(pNewRIGHTPAREN3)
, m_pstrAllOp4(pNewstrAllOp4)
, m_pLEFTPAREN5(pNewLEFTPAREN5)
, m_prowDescriptor6(pNewrowDescriptor6)
, m_pRIGHTPAREN7(pNewRIGHTPAREN7)
{}
virtual ~rowExpr();
void accept( WQLVisitor* v ) const
{
v->visit_rowExpr( this );
}
blocxx::String* m_pLEFTPAREN1;
rowDescriptor* m_prowDescriptor2;
blocxx::String* m_pRIGHTPAREN3;
blocxx::String* m_pstrAllOp4;
blocxx::String* m_pLEFTPAREN5;
rowDescriptor* m_prowDescriptor6;
blocxx::String* m_pRIGHTPAREN7;
};
class OW_WQL_API rowDescriptor : public node
{
public:
rowDescriptor(
blocxx::List< aExpr* >* pNewrowList1,
blocxx::String* pNewCOMMA2,
aExpr* pNewaExpr3
)
: m_prowList1(pNewrowList1)
, m_pCOMMA2(pNewCOMMA2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~rowDescriptor();
void accept( WQLVisitor* v ) const
{
v->visit_rowDescriptor( this );
}
blocxx::List< aExpr* >* m_prowList1;
blocxx::String* m_pCOMMA2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr: public node
{
public:
aExpr()
{}
virtual ~aExpr() {}
};
class OW_WQL_API aExpr_cExpr : public aExpr
{
public:
aExpr_cExpr(
cExpr* pNewcExpr1
)
: aExpr()
, m_pcExpr1(pNewcExpr1)
{}
virtual ~aExpr_cExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_cExpr( this );
}
cExpr* m_pcExpr1;
};
class OW_WQL_API aExpr_aExpr_AT_TIME_ZONE_cExpr : public aExpr
{
public:
aExpr_aExpr_AT_TIME_ZONE_cExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewAT2,
blocxx::String* pNewTIME3,
blocxx::String* pNewZONE4,
cExpr* pNewcExpr5
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pAT2(pNewAT2)
, m_pTIME3(pNewTIME3)
, m_pZONE4(pNewZONE4)
, m_pcExpr5(pNewcExpr5)
{}
virtual ~aExpr_aExpr_AT_TIME_ZONE_cExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_AT_TIME_ZONE_cExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pAT2;
blocxx::String* m_pTIME3;
blocxx::String* m_pZONE4;
cExpr* m_pcExpr5;
};
class OW_WQL_API aExpr_PLUS_aExpr : public aExpr
{
public:
aExpr_PLUS_aExpr(
blocxx::String* pNewPLUS1,
aExpr* pNewaExpr2
)
: aExpr()
, m_pPLUS1(pNewPLUS1)
, m_paExpr2(pNewaExpr2)
{}
virtual ~aExpr_PLUS_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_PLUS_aExpr( this );
}
blocxx::String* m_pPLUS1;
aExpr* m_paExpr2;
};
class OW_WQL_API aExpr_MINUS_aExpr : public aExpr
{
public:
aExpr_MINUS_aExpr(
blocxx::String* pNewMINUS1,
aExpr* pNewaExpr2
)
: aExpr()
, m_pMINUS1(pNewMINUS1)
, m_paExpr2(pNewaExpr2)
{}
virtual ~aExpr_MINUS_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_MINUS_aExpr( this );
}
blocxx::String* m_pMINUS1;
aExpr* m_paExpr2;
};
class OW_WQL_API aExpr_BITINVERT_aExpr : public aExpr
{
public:
aExpr_BITINVERT_aExpr(
blocxx::String* pNewBITINVERT1,
aExpr* pNewaExpr2
)
: aExpr()
, m_pBITINVERT1(pNewBITINVERT1)
, m_paExpr2(pNewaExpr2)
{}
virtual ~aExpr_BITINVERT_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_BITINVERT_aExpr( this );
}
blocxx::String* m_pBITINVERT1;
aExpr* m_paExpr2;
};
class OW_WQL_API aExpr_aExpr_PLUS_aExpr : public aExpr
{
public:
aExpr_aExpr_PLUS_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewPLUS2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pPLUS2(pNewPLUS2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_PLUS_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_PLUS_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pPLUS2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_MINUS_aExpr : public aExpr
{
public:
aExpr_aExpr_MINUS_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewMINUS2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pMINUS2(pNewMINUS2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_MINUS_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_MINUS_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pMINUS2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_ASTERISK_aExpr : public aExpr
{
public:
aExpr_aExpr_ASTERISK_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewASTERISK2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pASTERISK2(pNewASTERISK2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_ASTERISK_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_ASTERISK_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pASTERISK2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_SOLIDUS_aExpr : public aExpr
{
public:
aExpr_aExpr_SOLIDUS_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewSOLIDUS2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pSOLIDUS2(pNewSOLIDUS2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_SOLIDUS_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_SOLIDUS_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pSOLIDUS2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_PERCENT_aExpr : public aExpr
{
public:
aExpr_aExpr_PERCENT_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewPERCENT2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pPERCENT2(pNewPERCENT2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_PERCENT_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_PERCENT_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pPERCENT2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_BITAND_aExpr : public aExpr
{
public:
aExpr_aExpr_BITAND_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewBITAND2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pBITAND2(pNewBITAND2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_BITAND_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_BITAND_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pBITAND2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_BITOR_aExpr : public aExpr
{
public:
aExpr_aExpr_BITOR_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewBITOR2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pBITOR2(pNewBITOR2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_BITOR_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_BITOR_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pBITOR2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_BITSHIFTLEFT_aExpr : public aExpr
{
public:
aExpr_aExpr_BITSHIFTLEFT_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewBITSHIFTLEFT2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pBITSHIFTLEFT2(pNewBITSHIFTLEFT2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_BITSHIFTLEFT_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_BITSHIFTLEFT_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pBITSHIFTLEFT2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_BITSHIFTRIGHT_aExpr : public aExpr
{
public:
aExpr_aExpr_BITSHIFTRIGHT_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewBITSHIFTRIGHT2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pBITSHIFTRIGHT2(pNewBITSHIFTRIGHT2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_BITSHIFTRIGHT_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_BITSHIFTRIGHT_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pBITSHIFTRIGHT2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_LESSTHAN_aExpr : public aExpr
{
public:
aExpr_aExpr_LESSTHAN_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewLESSTHAN2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pLESSTHAN2(pNewLESSTHAN2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_LESSTHAN_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_LESSTHAN_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pLESSTHAN2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_LESSTHANOREQUALS_aExpr : public aExpr
{
public:
aExpr_aExpr_LESSTHANOREQUALS_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewLESSTHANOREQUALS2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pLESSTHANOREQUALS2(pNewLESSTHANOREQUALS2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_LESSTHANOREQUALS_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_LESSTHANOREQUALS_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pLESSTHANOREQUALS2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_GREATERTHAN_aExpr : public aExpr
{
public:
aExpr_aExpr_GREATERTHAN_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewGREATERTHAN2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pGREATERTHAN2(pNewGREATERTHAN2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_GREATERTHAN_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_GREATERTHAN_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pGREATERTHAN2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_GREATERTHANOREQUALS_aExpr : public aExpr
{
public:
aExpr_aExpr_GREATERTHANOREQUALS_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewGREATERTHANOREQUALS2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pGREATERTHANOREQUALS2(pNewGREATERTHANOREQUALS2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_GREATERTHANOREQUALS_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_GREATERTHANOREQUALS_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pGREATERTHANOREQUALS2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_EQUALS_aExpr : public aExpr
{
public:
aExpr_aExpr_EQUALS_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewEQUALS2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pEQUALS2(pNewEQUALS2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_EQUALS_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_EQUALS_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pEQUALS2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_NOTEQUALS_aExpr : public aExpr
{
public:
aExpr_aExpr_NOTEQUALS_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewNOTEQUALS2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pNOTEQUALS2(pNewNOTEQUALS2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_NOTEQUALS_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_NOTEQUALS_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pNOTEQUALS2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_AND_aExpr : public aExpr
{
public:
aExpr_aExpr_AND_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewAND2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pAND2(pNewAND2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_AND_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_AND_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pAND2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_OR_aExpr : public aExpr
{
public:
aExpr_aExpr_OR_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewOR2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pOR2(pNewOR2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_OR_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_OR_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pOR2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_NOT_aExpr : public aExpr
{
public:
aExpr_NOT_aExpr(
blocxx::String* pNewNOT1,
aExpr* pNewaExpr2
)
: aExpr()
, m_pNOT1(pNewNOT1)
, m_paExpr2(pNewaExpr2)
{}
virtual ~aExpr_NOT_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_NOT_aExpr( this );
}
blocxx::String* m_pNOT1;
aExpr* m_paExpr2;
};
class OW_WQL_API aExpr_aExpr_CONCATENATION_aExpr : public aExpr
{
public:
aExpr_aExpr_CONCATENATION_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewCONCATENATION2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pCONCATENATION2(pNewCONCATENATION2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_CONCATENATION_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_CONCATENATION_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pCONCATENATION2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_LIKE_aExpr : public aExpr
{
public:
aExpr_aExpr_LIKE_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewLIKE2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pLIKE2(pNewLIKE2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_LIKE_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_LIKE_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pLIKE2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_aExpr_LIKE_aExpr_ESCAPE_aExpr : public aExpr
{
public:
aExpr_aExpr_LIKE_aExpr_ESCAPE_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewLIKE2,
aExpr* pNewaExpr3,
blocxx::String* pNewESCAPE4,
aExpr* pNewaExpr5
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pLIKE2(pNewLIKE2)
, m_paExpr3(pNewaExpr3)
, m_pESCAPE4(pNewESCAPE4)
, m_paExpr5(pNewaExpr5)
{}
virtual ~aExpr_aExpr_LIKE_aExpr_ESCAPE_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_LIKE_aExpr_ESCAPE_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pLIKE2;
aExpr* m_paExpr3;
blocxx::String* m_pESCAPE4;
aExpr* m_paExpr5;
};
class OW_WQL_API aExpr_aExpr_NOT_LIKE_aExpr : public aExpr
{
public:
aExpr_aExpr_NOT_LIKE_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewNOT2,
blocxx::String* pNewLIKE3,
aExpr* pNewaExpr4
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pNOT2(pNewNOT2)
, m_pLIKE3(pNewLIKE3)
, m_paExpr4(pNewaExpr4)
{}
virtual ~aExpr_aExpr_NOT_LIKE_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_NOT_LIKE_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pNOT2;
blocxx::String* m_pLIKE3;
aExpr* m_paExpr4;
};
class OW_WQL_API aExpr_aExpr_NOT_LIKE_aExpr_ESCAPE_aExpr : public aExpr
{
public:
aExpr_aExpr_NOT_LIKE_aExpr_ESCAPE_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewNOT2,
blocxx::String* pNewLIKE3,
aExpr* pNewaExpr4,
blocxx::String* pNewESCAPE5,
aExpr* pNewaExpr6
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pNOT2(pNewNOT2)
, m_pLIKE3(pNewLIKE3)
, m_paExpr4(pNewaExpr4)
, m_pESCAPE5(pNewESCAPE5)
, m_paExpr6(pNewaExpr6)
{}
virtual ~aExpr_aExpr_NOT_LIKE_aExpr_ESCAPE_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_NOT_LIKE_aExpr_ESCAPE_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pNOT2;
blocxx::String* m_pLIKE3;
aExpr* m_paExpr4;
blocxx::String* m_pESCAPE5;
aExpr* m_paExpr6;
};
class OW_WQL_API aExpr_aExpr_ISNULL : public aExpr
{
public:
aExpr_aExpr_ISNULL(
aExpr* pNewaExpr1,
blocxx::String* pNewISNULL2
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pISNULL2(pNewISNULL2)
{}
virtual ~aExpr_aExpr_ISNULL();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_ISNULL( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pISNULL2;
};
class OW_WQL_API aExpr_aExpr_IS_NULLP : public aExpr
{
public:
aExpr_aExpr_IS_NULLP(
aExpr* pNewaExpr1,
blocxx::String* pNewIS2,
blocxx::String* pNewNULLP3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pIS2(pNewIS2)
, m_pNULLP3(pNewNULLP3)
{}
virtual ~aExpr_aExpr_IS_NULLP();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_IS_NULLP( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pIS2;
blocxx::String* m_pNULLP3;
};
class OW_WQL_API aExpr_aExpr_NOTNULL : public aExpr
{
public:
aExpr_aExpr_NOTNULL(
aExpr* pNewaExpr1,
blocxx::String* pNewNOTNULL2
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pNOTNULL2(pNewNOTNULL2)
{}
virtual ~aExpr_aExpr_NOTNULL();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_NOTNULL( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pNOTNULL2;
};
class OW_WQL_API aExpr_aExpr_IS_NOT_NULLP : public aExpr
{
public:
aExpr_aExpr_IS_NOT_NULLP(
aExpr* pNewaExpr1,
blocxx::String* pNewIS2,
blocxx::String* pNewNOT3,
blocxx::String* pNewNULLP4
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pIS2(pNewIS2)
, m_pNOT3(pNewNOT3)
, m_pNULLP4(pNewNULLP4)
{}
virtual ~aExpr_aExpr_IS_NOT_NULLP();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_IS_NOT_NULLP( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pIS2;
blocxx::String* m_pNOT3;
blocxx::String* m_pNULLP4;
};
class OW_WQL_API aExpr_aExpr_IS_TRUEP : public aExpr
{
public:
aExpr_aExpr_IS_TRUEP(
aExpr* pNewaExpr1,
blocxx::String* pNewIS2,
blocxx::String* pNewTRUEP3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pIS2(pNewIS2)
, m_pTRUEP3(pNewTRUEP3)
{}
virtual ~aExpr_aExpr_IS_TRUEP();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_IS_TRUEP( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pIS2;
blocxx::String* m_pTRUEP3;
};
class OW_WQL_API aExpr_aExpr_IS_NOT_FALSEP : public aExpr
{
public:
aExpr_aExpr_IS_NOT_FALSEP(
aExpr* pNewaExpr1,
blocxx::String* pNewIS2,
blocxx::String* pNewNOT3,
blocxx::String* pNewFALSEP4
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pIS2(pNewIS2)
, m_pNOT3(pNewNOT3)
, m_pFALSEP4(pNewFALSEP4)
{}
virtual ~aExpr_aExpr_IS_NOT_FALSEP();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_IS_NOT_FALSEP( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pIS2;
blocxx::String* m_pNOT3;
blocxx::String* m_pFALSEP4;
};
class OW_WQL_API aExpr_aExpr_IS_FALSEP : public aExpr
{
public:
aExpr_aExpr_IS_FALSEP(
aExpr* pNewaExpr1,
blocxx::String* pNewIS2,
blocxx::String* pNewFALSEP3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pIS2(pNewIS2)
, m_pFALSEP3(pNewFALSEP3)
{}
virtual ~aExpr_aExpr_IS_FALSEP();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_IS_FALSEP( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pIS2;
blocxx::String* m_pFALSEP3;
};
class OW_WQL_API aExpr_aExpr_IS_NOT_TRUEP : public aExpr
{
public:
aExpr_aExpr_IS_NOT_TRUEP(
aExpr* pNewaExpr1,
blocxx::String* pNewIS2,
blocxx::String* pNewNOT3,
blocxx::String* pNewTRUEP4
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pIS2(pNewIS2)
, m_pNOT3(pNewNOT3)
, m_pTRUEP4(pNewTRUEP4)
{}
virtual ~aExpr_aExpr_IS_NOT_TRUEP();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_IS_NOT_TRUEP( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pIS2;
blocxx::String* m_pNOT3;
blocxx::String* m_pTRUEP4;
};
class OW_WQL_API aExpr_aExpr_ISA_aExpr : public aExpr
{
public:
aExpr_aExpr_ISA_aExpr(
aExpr* pNewaExpr1,
blocxx::String* pNewISA2,
aExpr* pNewaExpr3
)
: aExpr()
, m_paExpr1(pNewaExpr1)
, m_pISA2(pNewISA2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~aExpr_aExpr_ISA_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_aExpr_ISA_aExpr( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pISA2;
aExpr* m_paExpr3;
};
class OW_WQL_API aExpr_rowExpr : public aExpr
{
public:
aExpr_rowExpr(
rowExpr* pNewrowExpr1
)
: aExpr()
, m_prowExpr1(pNewrowExpr1)
{}
virtual ~aExpr_rowExpr();
void accept( WQLVisitor* v ) const
{
v->visit_aExpr_rowExpr( this );
}
rowExpr* m_prowExpr1;
};
class OW_WQL_API bExpr: public node
{
public:
bExpr()
{}
virtual ~bExpr() {}
};
class OW_WQL_API bExpr_cExpr : public bExpr
{
public:
bExpr_cExpr(
cExpr* pNewcExpr1
)
: bExpr()
, m_pcExpr1(pNewcExpr1)
{}
virtual ~bExpr_cExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_cExpr( this );
}
cExpr* m_pcExpr1;
};
class OW_WQL_API bExpr_PLUS_bExpr : public bExpr
{
public:
bExpr_PLUS_bExpr(
blocxx::String* pNewPLUS1,
bExpr* pNewbExpr2
)
: bExpr()
, m_pPLUS1(pNewPLUS1)
, m_pbExpr2(pNewbExpr2)
{}
virtual ~bExpr_PLUS_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_PLUS_bExpr( this );
}
blocxx::String* m_pPLUS1;
bExpr* m_pbExpr2;
};
class OW_WQL_API bExpr_MINUS_bExpr : public bExpr
{
public:
bExpr_MINUS_bExpr(
blocxx::String* pNewMINUS1,
bExpr* pNewbExpr2
)
: bExpr()
, m_pMINUS1(pNewMINUS1)
, m_pbExpr2(pNewbExpr2)
{}
virtual ~bExpr_MINUS_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_MINUS_bExpr( this );
}
blocxx::String* m_pMINUS1;
bExpr* m_pbExpr2;
};
class OW_WQL_API bExpr_BITINVERT_bExpr : public bExpr
{
public:
bExpr_BITINVERT_bExpr(
blocxx::String* pNewBITINVERT1,
bExpr* pNewbExpr2
)
: bExpr()
, m_pBITINVERT1(pNewBITINVERT1)
, m_pbExpr2(pNewbExpr2)
{}
virtual ~bExpr_BITINVERT_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_BITINVERT_bExpr( this );
}
blocxx::String* m_pBITINVERT1;
bExpr* m_pbExpr2;
};
class OW_WQL_API bExpr_bExpr_PLUS_bExpr : public bExpr
{
public:
bExpr_bExpr_PLUS_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewPLUS2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pPLUS2(pNewPLUS2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_PLUS_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_PLUS_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pPLUS2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_MINUS_bExpr : public bExpr
{
public:
bExpr_bExpr_MINUS_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewMINUS2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pMINUS2(pNewMINUS2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_MINUS_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_MINUS_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pMINUS2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_ASTERISK_bExpr : public bExpr
{
public:
bExpr_bExpr_ASTERISK_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewASTERISK2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pASTERISK2(pNewASTERISK2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_ASTERISK_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_ASTERISK_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pASTERISK2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_SOLIDUS_bExpr : public bExpr
{
public:
bExpr_bExpr_SOLIDUS_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewSOLIDUS2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pSOLIDUS2(pNewSOLIDUS2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_SOLIDUS_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_SOLIDUS_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pSOLIDUS2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_PERCENT_bExpr : public bExpr
{
public:
bExpr_bExpr_PERCENT_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewPERCENT2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pPERCENT2(pNewPERCENT2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_PERCENT_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_PERCENT_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pPERCENT2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_BITAND_bExpr : public bExpr
{
public:
bExpr_bExpr_BITAND_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewBITAND2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pBITAND2(pNewBITAND2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_BITAND_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_BITAND_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pBITAND2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_BITOR_bExpr : public bExpr
{
public:
bExpr_bExpr_BITOR_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewBITOR2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pBITOR2(pNewBITOR2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_BITOR_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_BITOR_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pBITOR2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_BITSHIFTLEFT_bExpr : public bExpr
{
public:
bExpr_bExpr_BITSHIFTLEFT_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewBITSHIFTLEFT2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pBITSHIFTLEFT2(pNewBITSHIFTLEFT2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_BITSHIFTLEFT_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_BITSHIFTLEFT_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pBITSHIFTLEFT2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_BITSHIFTRIGHT_bExpr : public bExpr
{
public:
bExpr_bExpr_BITSHIFTRIGHT_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewBITSHIFTRIGHT2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pBITSHIFTRIGHT2(pNewBITSHIFTRIGHT2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_BITSHIFTRIGHT_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_BITSHIFTRIGHT_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pBITSHIFTRIGHT2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_LESSTHAN_bExpr : public bExpr
{
public:
bExpr_bExpr_LESSTHAN_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewLESSTHAN2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pLESSTHAN2(pNewLESSTHAN2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_LESSTHAN_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_LESSTHAN_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pLESSTHAN2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_LESSTHANOREQUALS_bExpr : public bExpr
{
public:
bExpr_bExpr_LESSTHANOREQUALS_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewLESSTHANOREQUALS2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pLESSTHANOREQUALS2(pNewLESSTHANOREQUALS2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_LESSTHANOREQUALS_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_LESSTHANOREQUALS_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pLESSTHANOREQUALS2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_GREATERTHAN_bExpr : public bExpr
{
public:
bExpr_bExpr_GREATERTHAN_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewGREATERTHAN2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pGREATERTHAN2(pNewGREATERTHAN2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_GREATERTHAN_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_GREATERTHAN_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pGREATERTHAN2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_GREATERTHANOREQUALS_bExpr : public bExpr
{
public:
bExpr_bExpr_GREATERTHANOREQUALS_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewGREATERTHANOREQUALS2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pGREATERTHANOREQUALS2(pNewGREATERTHANOREQUALS2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_GREATERTHANOREQUALS_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_GREATERTHANOREQUALS_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pGREATERTHANOREQUALS2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_EQUALS_bExpr : public bExpr
{
public:
bExpr_bExpr_EQUALS_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewEQUALS2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pEQUALS2(pNewEQUALS2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_EQUALS_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_EQUALS_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pEQUALS2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_NOTEQUALS_bExpr : public bExpr
{
public:
bExpr_bExpr_NOTEQUALS_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewNOTEQUALS2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pNOTEQUALS2(pNewNOTEQUALS2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_NOTEQUALS_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_NOTEQUALS_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pNOTEQUALS2;
bExpr* m_pbExpr3;
};
class OW_WQL_API bExpr_bExpr_CONCATENATION_bExpr : public bExpr
{
public:
bExpr_bExpr_CONCATENATION_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewCONCATENATION2,
bExpr* pNewbExpr3
)
: bExpr()
, m_pbExpr1(pNewbExpr1)
, m_pCONCATENATION2(pNewCONCATENATION2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~bExpr_bExpr_CONCATENATION_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_bExpr_bExpr_CONCATENATION_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pCONCATENATION2;
bExpr* m_pbExpr3;
};
class OW_WQL_API cExpr: public node
{
public:
cExpr()
{}
virtual ~cExpr() {}
};
class OW_WQL_API cExpr_attr : public cExpr
{
public:
cExpr_attr(
attr* pNewattr1
)
: cExpr()
, m_pattr1(pNewattr1)
{}
virtual ~cExpr_attr();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_attr( this );
}
attr* m_pattr1;
};
class OW_WQL_API cExpr_strColId_optIndirection : public cExpr
{
public:
cExpr_strColId_optIndirection(
blocxx::String* pNewstrColId1,
optIndirection* pNewoptIndirection2
)
: cExpr()
, m_pstrColId1(pNewstrColId1)
, m_poptIndirection2(pNewoptIndirection2)
{}
virtual ~cExpr_strColId_optIndirection();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_strColId_optIndirection( this );
}
blocxx::String* m_pstrColId1;
optIndirection* m_poptIndirection2;
};
class OW_WQL_API cExpr_aExprConst : public cExpr
{
public:
cExpr_aExprConst(
aExprConst* pNewaExprConst1
)
: cExpr()
, m_paExprConst1(pNewaExprConst1)
{}
virtual ~cExpr_aExprConst();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_aExprConst( this );
}
aExprConst* m_paExprConst1;
};
class OW_WQL_API cExpr_LEFTPAREN_aExpr_RIGHTPAREN : public cExpr
{
public:
cExpr_LEFTPAREN_aExpr_RIGHTPAREN(
blocxx::String* pNewLEFTPAREN1,
aExpr* pNewaExpr2,
blocxx::String* pNewRIGHTPAREN3
)
: cExpr()
, m_pLEFTPAREN1(pNewLEFTPAREN1)
, m_paExpr2(pNewaExpr2)
, m_pRIGHTPAREN3(pNewRIGHTPAREN3)
{}
virtual ~cExpr_LEFTPAREN_aExpr_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_LEFTPAREN_aExpr_RIGHTPAREN( this );
}
blocxx::String* m_pLEFTPAREN1;
aExpr* m_paExpr2;
blocxx::String* m_pRIGHTPAREN3;
};
class OW_WQL_API cExpr_strFuncName_LEFTPAREN_RIGHTPAREN : public cExpr
{
public:
cExpr_strFuncName_LEFTPAREN_RIGHTPAREN(
blocxx::String* pNewstrFuncName1,
blocxx::String* pNewLEFTPAREN2,
blocxx::String* pNewRIGHTPAREN3
)
: cExpr()
, m_pstrFuncName1(pNewstrFuncName1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pRIGHTPAREN3(pNewRIGHTPAREN3)
{}
virtual ~cExpr_strFuncName_LEFTPAREN_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_strFuncName_LEFTPAREN_RIGHTPAREN( this );
}
blocxx::String* m_pstrFuncName1;
blocxx::String* m_pLEFTPAREN2;
blocxx::String* m_pRIGHTPAREN3;
};
class OW_WQL_API cExpr_strFuncName_LEFTPAREN_exprSeq_RIGHTPAREN : public cExpr
{
public:
cExpr_strFuncName_LEFTPAREN_exprSeq_RIGHTPAREN(
blocxx::String* pNewstrFuncName1,
blocxx::String* pNewLEFTPAREN2,
exprSeq* pNewexprSeq3,
blocxx::String* pNewRIGHTPAREN4
)
: cExpr()
, m_pstrFuncName1(pNewstrFuncName1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pexprSeq3(pNewexprSeq3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~cExpr_strFuncName_LEFTPAREN_exprSeq_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_strFuncName_LEFTPAREN_exprSeq_RIGHTPAREN( this );
}
blocxx::String* m_pstrFuncName1;
blocxx::String* m_pLEFTPAREN2;
exprSeq* m_pexprSeq3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API cExpr_strFuncName_LEFTPAREN_ALL_exprSeq_RIGHTPAREN : public cExpr
{
public:
cExpr_strFuncName_LEFTPAREN_ALL_exprSeq_RIGHTPAREN(
blocxx::String* pNewstrFuncName1,
blocxx::String* pNewLEFTPAREN2,
blocxx::String* pNewALL3,
exprSeq* pNewexprSeq4,
blocxx::String* pNewRIGHTPAREN5
)
: cExpr()
, m_pstrFuncName1(pNewstrFuncName1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pALL3(pNewALL3)
, m_pexprSeq4(pNewexprSeq4)
, m_pRIGHTPAREN5(pNewRIGHTPAREN5)
{}
virtual ~cExpr_strFuncName_LEFTPAREN_ALL_exprSeq_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_strFuncName_LEFTPAREN_ALL_exprSeq_RIGHTPAREN( this );
}
blocxx::String* m_pstrFuncName1;
blocxx::String* m_pLEFTPAREN2;
blocxx::String* m_pALL3;
exprSeq* m_pexprSeq4;
blocxx::String* m_pRIGHTPAREN5;
};
class OW_WQL_API cExpr_strFuncName_LEFTPAREN_DISTINCT_exprSeq_RIGHTPAREN : public cExpr
{
public:
cExpr_strFuncName_LEFTPAREN_DISTINCT_exprSeq_RIGHTPAREN(
blocxx::String* pNewstrFuncName1,
blocxx::String* pNewLEFTPAREN2,
blocxx::String* pNewDISTINCT3,
exprSeq* pNewexprSeq4,
blocxx::String* pNewRIGHTPAREN5
)
: cExpr()
, m_pstrFuncName1(pNewstrFuncName1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pDISTINCT3(pNewDISTINCT3)
, m_pexprSeq4(pNewexprSeq4)
, m_pRIGHTPAREN5(pNewRIGHTPAREN5)
{}
virtual ~cExpr_strFuncName_LEFTPAREN_DISTINCT_exprSeq_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_strFuncName_LEFTPAREN_DISTINCT_exprSeq_RIGHTPAREN( this );
}
blocxx::String* m_pstrFuncName1;
blocxx::String* m_pLEFTPAREN2;
blocxx::String* m_pDISTINCT3;
exprSeq* m_pexprSeq4;
blocxx::String* m_pRIGHTPAREN5;
};
class OW_WQL_API cExpr_strFuncName_LEFTPAREN_ASTERISK_RIGHTPAREN : public cExpr
{
public:
cExpr_strFuncName_LEFTPAREN_ASTERISK_RIGHTPAREN(
blocxx::String* pNewstrFuncName1,
blocxx::String* pNewLEFTPAREN2,
blocxx::String* pNewASTERISK3,
blocxx::String* pNewRIGHTPAREN4
)
: cExpr()
, m_pstrFuncName1(pNewstrFuncName1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pASTERISK3(pNewASTERISK3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~cExpr_strFuncName_LEFTPAREN_ASTERISK_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_strFuncName_LEFTPAREN_ASTERISK_RIGHTPAREN( this );
}
blocxx::String* m_pstrFuncName1;
blocxx::String* m_pLEFTPAREN2;
blocxx::String* m_pASTERISK3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API cExpr_CURRENTDATE : public cExpr
{
public:
cExpr_CURRENTDATE(
blocxx::String* pNewCURRENTDATE1
)
: cExpr()
, m_pCURRENTDATE1(pNewCURRENTDATE1)
{}
virtual ~cExpr_CURRENTDATE();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_CURRENTDATE( this );
}
blocxx::String* m_pCURRENTDATE1;
};
class OW_WQL_API cExpr_CURRENTTIME : public cExpr
{
public:
cExpr_CURRENTTIME(
blocxx::String* pNewCURRENTTIME1
)
: cExpr()
, m_pCURRENTTIME1(pNewCURRENTTIME1)
{}
virtual ~cExpr_CURRENTTIME();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_CURRENTTIME( this );
}
blocxx::String* m_pCURRENTTIME1;
};
class OW_WQL_API cExpr_CURRENTTIME_LEFTPAREN_ICONST_RIGHTPAREN : public cExpr
{
public:
cExpr_CURRENTTIME_LEFTPAREN_ICONST_RIGHTPAREN(
blocxx::String* pNewCURRENTTIME1,
blocxx::String* pNewLEFTPAREN2,
blocxx::String* pNewICONST3,
blocxx::String* pNewRIGHTPAREN4
)
: cExpr()
, m_pCURRENTTIME1(pNewCURRENTTIME1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pICONST3(pNewICONST3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~cExpr_CURRENTTIME_LEFTPAREN_ICONST_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_CURRENTTIME_LEFTPAREN_ICONST_RIGHTPAREN( this );
}
blocxx::String* m_pCURRENTTIME1;
blocxx::String* m_pLEFTPAREN2;
blocxx::String* m_pICONST3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API cExpr_CURRENTTIMESTAMP : public cExpr
{
public:
cExpr_CURRENTTIMESTAMP(
blocxx::String* pNewCURRENTTIMESTAMP1
)
: cExpr()
, m_pCURRENTTIMESTAMP1(pNewCURRENTTIMESTAMP1)
{}
virtual ~cExpr_CURRENTTIMESTAMP();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_CURRENTTIMESTAMP( this );
}
blocxx::String* m_pCURRENTTIMESTAMP1;
};
class OW_WQL_API cExpr_CURRENTTIMESTAMP_LEFTPAREN_ICONST_RIGHTPAREN : public cExpr
{
public:
cExpr_CURRENTTIMESTAMP_LEFTPAREN_ICONST_RIGHTPAREN(
blocxx::String* pNewCURRENTTIMESTAMP1,
blocxx::String* pNewLEFTPAREN2,
blocxx::String* pNewICONST3,
blocxx::String* pNewRIGHTPAREN4
)
: cExpr()
, m_pCURRENTTIMESTAMP1(pNewCURRENTTIMESTAMP1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pICONST3(pNewICONST3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~cExpr_CURRENTTIMESTAMP_LEFTPAREN_ICONST_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_CURRENTTIMESTAMP_LEFTPAREN_ICONST_RIGHTPAREN( this );
}
blocxx::String* m_pCURRENTTIMESTAMP1;
blocxx::String* m_pLEFTPAREN2;
blocxx::String* m_pICONST3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API cExpr_CURRENTUSER : public cExpr
{
public:
cExpr_CURRENTUSER(
blocxx::String* pNewCURRENTUSER1
)
: cExpr()
, m_pCURRENTUSER1(pNewCURRENTUSER1)
{}
virtual ~cExpr_CURRENTUSER();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_CURRENTUSER( this );
}
blocxx::String* m_pCURRENTUSER1;
};
class OW_WQL_API cExpr_SESSIONUSER : public cExpr
{
public:
cExpr_SESSIONUSER(
blocxx::String* pNewSESSIONUSER1
)
: cExpr()
, m_pSESSIONUSER1(pNewSESSIONUSER1)
{}
virtual ~cExpr_SESSIONUSER();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_SESSIONUSER( this );
}
blocxx::String* m_pSESSIONUSER1;
};
class OW_WQL_API cExpr_USER : public cExpr
{
public:
cExpr_USER(
blocxx::String* pNewUSER1
)
: cExpr()
, m_pUSER1(pNewUSER1)
{}
virtual ~cExpr_USER();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_USER( this );
}
blocxx::String* m_pUSER1;
};
class OW_WQL_API cExpr_EXTRACT_LEFTPAREN_optExtract_RIGHTPAREN : public cExpr
{
public:
cExpr_EXTRACT_LEFTPAREN_optExtract_RIGHTPAREN(
blocxx::String* pNewEXTRACT1,
blocxx::String* pNewLEFTPAREN2,
optExtract* pNewoptExtract3,
blocxx::String* pNewRIGHTPAREN4
)
: cExpr()
, m_pEXTRACT1(pNewEXTRACT1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_poptExtract3(pNewoptExtract3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~cExpr_EXTRACT_LEFTPAREN_optExtract_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_EXTRACT_LEFTPAREN_optExtract_RIGHTPAREN( this );
}
blocxx::String* m_pEXTRACT1;
blocxx::String* m_pLEFTPAREN2;
optExtract* m_poptExtract3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API cExpr_POSITION_LEFTPAREN_positionExpr_RIGHTPAREN : public cExpr
{
public:
cExpr_POSITION_LEFTPAREN_positionExpr_RIGHTPAREN(
blocxx::String* pNewPOSITION1,
blocxx::String* pNewLEFTPAREN2,
positionExpr* pNewpositionExpr3,
blocxx::String* pNewRIGHTPAREN4
)
: cExpr()
, m_pPOSITION1(pNewPOSITION1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_ppositionExpr3(pNewpositionExpr3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~cExpr_POSITION_LEFTPAREN_positionExpr_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_POSITION_LEFTPAREN_positionExpr_RIGHTPAREN( this );
}
blocxx::String* m_pPOSITION1;
blocxx::String* m_pLEFTPAREN2;
positionExpr* m_ppositionExpr3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API cExpr_SUBSTRING_LEFTPAREN_optSubstrExpr_RIGHTPAREN : public cExpr
{
public:
cExpr_SUBSTRING_LEFTPAREN_optSubstrExpr_RIGHTPAREN(
blocxx::String* pNewSUBSTRING1,
blocxx::String* pNewLEFTPAREN2,
optSubstrExpr* pNewoptSubstrExpr3,
blocxx::String* pNewRIGHTPAREN4
)
: cExpr()
, m_pSUBSTRING1(pNewSUBSTRING1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_poptSubstrExpr3(pNewoptSubstrExpr3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~cExpr_SUBSTRING_LEFTPAREN_optSubstrExpr_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_SUBSTRING_LEFTPAREN_optSubstrExpr_RIGHTPAREN( this );
}
blocxx::String* m_pSUBSTRING1;
blocxx::String* m_pLEFTPAREN2;
optSubstrExpr* m_poptSubstrExpr3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API cExpr_TRIM_LEFTPAREN_LEADING_trimExpr_RIGHTPAREN : public cExpr
{
public:
cExpr_TRIM_LEFTPAREN_LEADING_trimExpr_RIGHTPAREN(
blocxx::String* pNewTRIM1,
blocxx::String* pNewLEFTPAREN2,
blocxx::String* pNewLEADING3,
trimExpr* pNewtrimExpr4,
blocxx::String* pNewRIGHTPAREN5
)
: cExpr()
, m_pTRIM1(pNewTRIM1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pLEADING3(pNewLEADING3)
, m_ptrimExpr4(pNewtrimExpr4)
, m_pRIGHTPAREN5(pNewRIGHTPAREN5)
{}
virtual ~cExpr_TRIM_LEFTPAREN_LEADING_trimExpr_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_TRIM_LEFTPAREN_LEADING_trimExpr_RIGHTPAREN( this );
}
blocxx::String* m_pTRIM1;
blocxx::String* m_pLEFTPAREN2;
blocxx::String* m_pLEADING3;
trimExpr* m_ptrimExpr4;
blocxx::String* m_pRIGHTPAREN5;
};
class OW_WQL_API cExpr_TRIM_LEFTPAREN_TRAILING_trimExpr_RIGHTPAREN : public cExpr
{
public:
cExpr_TRIM_LEFTPAREN_TRAILING_trimExpr_RIGHTPAREN(
blocxx::String* pNewTRIM1,
blocxx::String* pNewLEFTPAREN2,
blocxx::String* pNewTRAILING3,
trimExpr* pNewtrimExpr4,
blocxx::String* pNewRIGHTPAREN5
)
: cExpr()
, m_pTRIM1(pNewTRIM1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_pTRAILING3(pNewTRAILING3)
, m_ptrimExpr4(pNewtrimExpr4)
, m_pRIGHTPAREN5(pNewRIGHTPAREN5)
{}
virtual ~cExpr_TRIM_LEFTPAREN_TRAILING_trimExpr_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_TRIM_LEFTPAREN_TRAILING_trimExpr_RIGHTPAREN( this );
}
blocxx::String* m_pTRIM1;
blocxx::String* m_pLEFTPAREN2;
blocxx::String* m_pTRAILING3;
trimExpr* m_ptrimExpr4;
blocxx::String* m_pRIGHTPAREN5;
};
class OW_WQL_API cExpr_TRIM_LEFTPAREN_trimExpr_RIGHTPAREN : public cExpr
{
public:
cExpr_TRIM_LEFTPAREN_trimExpr_RIGHTPAREN(
blocxx::String* pNewTRIM1,
blocxx::String* pNewLEFTPAREN2,
trimExpr* pNewtrimExpr3,
blocxx::String* pNewRIGHTPAREN4
)
: cExpr()
, m_pTRIM1(pNewTRIM1)
, m_pLEFTPAREN2(pNewLEFTPAREN2)
, m_ptrimExpr3(pNewtrimExpr3)
, m_pRIGHTPAREN4(pNewRIGHTPAREN4)
{}
virtual ~cExpr_TRIM_LEFTPAREN_trimExpr_RIGHTPAREN();
void accept( WQLVisitor* v ) const
{
v->visit_cExpr_TRIM_LEFTPAREN_trimExpr_RIGHTPAREN( this );
}
blocxx::String* m_pTRIM1;
blocxx::String* m_pLEFTPAREN2;
trimExpr* m_ptrimExpr3;
blocxx::String* m_pRIGHTPAREN4;
};
class OW_WQL_API optIndirection: public node
{
public:
optIndirection()
{}
virtual ~optIndirection() {}
};
class OW_WQL_API optIndirection_empty : public optIndirection
{
public:
optIndirection_empty(
)
: optIndirection()
{}
virtual ~optIndirection_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optIndirection_empty( this );
}
};
class OW_WQL_API optIndirection_optIndirection_LEFTBRACKET_aExpr_RIGHTBRACKET : public optIndirection
{
public:
optIndirection_optIndirection_LEFTBRACKET_aExpr_RIGHTBRACKET(
optIndirection* pNewoptIndirection1,
blocxx::String* pNewLEFTBRACKET2,
aExpr* pNewaExpr3,
blocxx::String* pNewRIGHTBRACKET4
)
: optIndirection()
, m_poptIndirection1(pNewoptIndirection1)
, m_pLEFTBRACKET2(pNewLEFTBRACKET2)
, m_paExpr3(pNewaExpr3)
, m_pRIGHTBRACKET4(pNewRIGHTBRACKET4)
{}
virtual ~optIndirection_optIndirection_LEFTBRACKET_aExpr_RIGHTBRACKET();
void accept( WQLVisitor* v ) const
{
v->visit_optIndirection_optIndirection_LEFTBRACKET_aExpr_RIGHTBRACKET( this );
}
optIndirection* m_poptIndirection1;
blocxx::String* m_pLEFTBRACKET2;
aExpr* m_paExpr3;
blocxx::String* m_pRIGHTBRACKET4;
};
class OW_WQL_API optIndirection_optIndirection_LEFTBRACKET_aExpr_COLON_aExpr_RIGHTBRACKET : public optIndirection
{
public:
optIndirection_optIndirection_LEFTBRACKET_aExpr_COLON_aExpr_RIGHTBRACKET(
optIndirection* pNewoptIndirection1,
blocxx::String* pNewLEFTBRACKET2,
aExpr* pNewaExpr3,
blocxx::String* pNewCOLON4,
aExpr* pNewaExpr5,
blocxx::String* pNewRIGHTBRACKET6
)
: optIndirection()
, m_poptIndirection1(pNewoptIndirection1)
, m_pLEFTBRACKET2(pNewLEFTBRACKET2)
, m_paExpr3(pNewaExpr3)
, m_pCOLON4(pNewCOLON4)
, m_paExpr5(pNewaExpr5)
, m_pRIGHTBRACKET6(pNewRIGHTBRACKET6)
{}
virtual ~optIndirection_optIndirection_LEFTBRACKET_aExpr_COLON_aExpr_RIGHTBRACKET();
void accept( WQLVisitor* v ) const
{
v->visit_optIndirection_optIndirection_LEFTBRACKET_aExpr_COLON_aExpr_RIGHTBRACKET( this );
}
optIndirection* m_poptIndirection1;
blocxx::String* m_pLEFTBRACKET2;
aExpr* m_paExpr3;
blocxx::String* m_pCOLON4;
aExpr* m_paExpr5;
blocxx::String* m_pRIGHTBRACKET6;
};
class OW_WQL_API optExtract: public node
{
public:
optExtract()
{}
virtual ~optExtract() {}
};
class OW_WQL_API optExtract_empty : public optExtract
{
public:
optExtract_empty(
)
: optExtract()
{}
virtual ~optExtract_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optExtract_empty( this );
}
};
class OW_WQL_API optExtract_strExtractArg_FROM_aExpr : public optExtract
{
public:
optExtract_strExtractArg_FROM_aExpr(
blocxx::String* pNewstrExtractArg1,
blocxx::String* pNewFROM2,
aExpr* pNewaExpr3
)
: optExtract()
, m_pstrExtractArg1(pNewstrExtractArg1)
, m_pFROM2(pNewFROM2)
, m_paExpr3(pNewaExpr3)
{}
virtual ~optExtract_strExtractArg_FROM_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_optExtract_strExtractArg_FROM_aExpr( this );
}
blocxx::String* m_pstrExtractArg1;
blocxx::String* m_pFROM2;
aExpr* m_paExpr3;
};
class OW_WQL_API positionExpr: public node
{
public:
positionExpr()
{}
virtual ~positionExpr() {}
};
class OW_WQL_API positionExpr_bExpr_IN_bExpr : public positionExpr
{
public:
positionExpr_bExpr_IN_bExpr(
bExpr* pNewbExpr1,
blocxx::String* pNewIN2,
bExpr* pNewbExpr3
)
: positionExpr()
, m_pbExpr1(pNewbExpr1)
, m_pIN2(pNewIN2)
, m_pbExpr3(pNewbExpr3)
{}
virtual ~positionExpr_bExpr_IN_bExpr();
void accept( WQLVisitor* v ) const
{
v->visit_positionExpr_bExpr_IN_bExpr( this );
}
bExpr* m_pbExpr1;
blocxx::String* m_pIN2;
bExpr* m_pbExpr3;
};
class OW_WQL_API positionExpr_empty : public positionExpr
{
public:
positionExpr_empty(
)
: positionExpr()
{}
virtual ~positionExpr_empty();
void accept( WQLVisitor* v ) const
{
v->visit_positionExpr_empty( this );
}
};
class OW_WQL_API optSubstrExpr: public node
{
public:
optSubstrExpr()
{}
virtual ~optSubstrExpr() {}
};
class OW_WQL_API optSubstrExpr_empty : public optSubstrExpr
{
public:
optSubstrExpr_empty(
)
: optSubstrExpr()
{}
virtual ~optSubstrExpr_empty();
void accept( WQLVisitor* v ) const
{
v->visit_optSubstrExpr_empty( this );
}
};
class OW_WQL_API optSubstrExpr_aExpr_substrFrom_substrFor : public optSubstrExpr
{
public:
optSubstrExpr_aExpr_substrFrom_substrFor(
aExpr* pNewaExpr1,
substrFrom* pNewsubstrFrom2,
substrFor* pNewsubstrFor3
)
: optSubstrExpr()
, m_paExpr1(pNewaExpr1)
, m_psubstrFrom2(pNewsubstrFrom2)
, m_psubstrFor3(pNewsubstrFor3)
{}
virtual ~optSubstrExpr_aExpr_substrFrom_substrFor();
void accept( WQLVisitor* v ) const
{
v->visit_optSubstrExpr_aExpr_substrFrom_substrFor( this );
}
aExpr* m_paExpr1;
substrFrom* m_psubstrFrom2;
substrFor* m_psubstrFor3;
};
class OW_WQL_API optSubstrExpr_aExpr_substrFor_substrFrom : public optSubstrExpr
{
public:
optSubstrExpr_aExpr_substrFor_substrFrom(
aExpr* pNewaExpr1,
substrFor* pNewsubstrFor2,
substrFrom* pNewsubstrFrom3
)
: optSubstrExpr()
, m_paExpr1(pNewaExpr1)
, m_psubstrFor2(pNewsubstrFor2)
, m_psubstrFrom3(pNewsubstrFrom3)
{}
virtual ~optSubstrExpr_aExpr_substrFor_substrFrom();
void accept( WQLVisitor* v ) const
{
v->visit_optSubstrExpr_aExpr_substrFor_substrFrom( this );
}
aExpr* m_paExpr1;
substrFor* m_psubstrFor2;
substrFrom* m_psubstrFrom3;
};
class OW_WQL_API optSubstrExpr_aExpr_substrFrom : public optSubstrExpr
{
public:
optSubstrExpr_aExpr_substrFrom(
aExpr* pNewaExpr1,
substrFrom* pNewsubstrFrom2
)
: optSubstrExpr()
, m_paExpr1(pNewaExpr1)
, m_psubstrFrom2(pNewsubstrFrom2)
{}
virtual ~optSubstrExpr_aExpr_substrFrom();
void accept( WQLVisitor* v ) const
{
v->visit_optSubstrExpr_aExpr_substrFrom( this );
}
aExpr* m_paExpr1;
substrFrom* m_psubstrFrom2;
};
class OW_WQL_API optSubstrExpr_aExpr_substrFor : public optSubstrExpr
{
public:
optSubstrExpr_aExpr_substrFor(
aExpr* pNewaExpr1,
substrFor* pNewsubstrFor2
)
: optSubstrExpr()
, m_paExpr1(pNewaExpr1)
, m_psubstrFor2(pNewsubstrFor2)
{}
virtual ~optSubstrExpr_aExpr_substrFor();
void accept( WQLVisitor* v ) const
{
v->visit_optSubstrExpr_aExpr_substrFor( this );
}
aExpr* m_paExpr1;
substrFor* m_psubstrFor2;
};
class OW_WQL_API optSubstrExpr_exprSeq : public optSubstrExpr
{
public:
optSubstrExpr_exprSeq(
exprSeq* pNewexprSeq1
)
: optSubstrExpr()
, m_pexprSeq1(pNewexprSeq1)
{}
virtual ~optSubstrExpr_exprSeq();
void accept( WQLVisitor* v ) const
{
v->visit_optSubstrExpr_exprSeq( this );
}
exprSeq* m_pexprSeq1;
};
class OW_WQL_API substrFrom : public node
{
public:
substrFrom(
blocxx::String* pNewFROM1,
aExpr* pNewaExpr2
)
: m_pFROM1(pNewFROM1)
, m_paExpr2(pNewaExpr2)
{}
virtual ~substrFrom();
void accept( WQLVisitor* v ) const
{
v->visit_substrFrom( this );
}
blocxx::String* m_pFROM1;
aExpr* m_paExpr2;
};
class OW_WQL_API substrFor : public node
{
public:
substrFor(
blocxx::String* pNewFOR1,
aExpr* pNewaExpr2
)
: m_pFOR1(pNewFOR1)
, m_paExpr2(pNewaExpr2)
{}
virtual ~substrFor();
void accept( WQLVisitor* v ) const
{
v->visit_substrFor( this );
}
blocxx::String* m_pFOR1;
aExpr* m_paExpr2;
};
class OW_WQL_API trimExpr: public node
{
public:
trimExpr()
{}
virtual ~trimExpr() {}
};
class OW_WQL_API trimExpr_aExpr_FROM_exprSeq : public trimExpr
{
public:
trimExpr_aExpr_FROM_exprSeq(
aExpr* pNewaExpr1,
blocxx::String* pNewFROM2,
exprSeq* pNewexprSeq3
)
: trimExpr()
, m_paExpr1(pNewaExpr1)
, m_pFROM2(pNewFROM2)
, m_pexprSeq3(pNewexprSeq3)
{}
virtual ~trimExpr_aExpr_FROM_exprSeq();
void accept( WQLVisitor* v ) const
{
v->visit_trimExpr_aExpr_FROM_exprSeq( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pFROM2;
exprSeq* m_pexprSeq3;
};
class OW_WQL_API trimExpr_FROM_exprSeq : public trimExpr
{
public:
trimExpr_FROM_exprSeq(
blocxx::String* pNewFROM1,
exprSeq* pNewexprSeq2
)
: trimExpr()
, m_pFROM1(pNewFROM1)
, m_pexprSeq2(pNewexprSeq2)
{}
virtual ~trimExpr_FROM_exprSeq();
void accept( WQLVisitor* v ) const
{
v->visit_trimExpr_FROM_exprSeq( this );
}
blocxx::String* m_pFROM1;
exprSeq* m_pexprSeq2;
};
class OW_WQL_API trimExpr_exprSeq : public trimExpr
{
public:
trimExpr_exprSeq(
exprSeq* pNewexprSeq1
)
: trimExpr()
, m_pexprSeq1(pNewexprSeq1)
{}
virtual ~trimExpr_exprSeq();
void accept( WQLVisitor* v ) const
{
v->visit_trimExpr_exprSeq( this );
}
exprSeq* m_pexprSeq1;
};
class OW_WQL_API attr : public node
{
public:
attr(
blocxx::String* pNewstrRelationName1,
blocxx::String* pNewPERIOD2,
attrs* pNewattrs3,
optIndirection* pNewoptIndirection4
)
: m_pstrRelationName1(pNewstrRelationName1)
, m_pPERIOD2(pNewPERIOD2)
, m_pattrs3(pNewattrs3)
, m_poptIndirection4(pNewoptIndirection4)
{}
virtual ~attr();
void accept( WQLVisitor* v ) const
{
v->visit_attr( this );
}
blocxx::String* m_pstrRelationName1;
blocxx::String* m_pPERIOD2;
attrs* m_pattrs3;
optIndirection* m_poptIndirection4;
};
class OW_WQL_API attrs: public node
{
public:
attrs()
{}
virtual ~attrs() {}
};
class OW_WQL_API attrs_strAttrName : public attrs
{
public:
attrs_strAttrName(
blocxx::String* pNewstrAttrName1
)
: attrs()
, m_pstrAttrName1(pNewstrAttrName1)
{}
virtual ~attrs_strAttrName();
void accept( WQLVisitor* v ) const
{
v->visit_attrs_strAttrName( this );
}
blocxx::String* m_pstrAttrName1;
};
class OW_WQL_API attrs_attrs_PERIOD_strAttrName : public attrs
{
public:
attrs_attrs_PERIOD_strAttrName(
attrs* pNewattrs1,
blocxx::String* pNewPERIOD2,
blocxx::String* pNewstrAttrName3
)
: attrs()
, m_pattrs1(pNewattrs1)
, m_pPERIOD2(pNewPERIOD2)
, m_pstrAttrName3(pNewstrAttrName3)
{}
virtual ~attrs_attrs_PERIOD_strAttrName();
void accept( WQLVisitor* v ) const
{
v->visit_attrs_attrs_PERIOD_strAttrName( this );
}
attrs* m_pattrs1;
blocxx::String* m_pPERIOD2;
blocxx::String* m_pstrAttrName3;
};
class OW_WQL_API attrs_attrs_PERIOD_ASTERISK : public attrs
{
public:
attrs_attrs_PERIOD_ASTERISK(
attrs* pNewattrs1,
blocxx::String* pNewPERIOD2,
blocxx::String* pNewASTERISK3
)
: attrs()
, m_pattrs1(pNewattrs1)
, m_pPERIOD2(pNewPERIOD2)
, m_pASTERISK3(pNewASTERISK3)
{}
virtual ~attrs_attrs_PERIOD_ASTERISK();
void accept( WQLVisitor* v ) const
{
v->visit_attrs_attrs_PERIOD_ASTERISK( this );
}
attrs* m_pattrs1;
blocxx::String* m_pPERIOD2;
blocxx::String* m_pASTERISK3;
};
class OW_WQL_API targetEl: public node
{
public:
targetEl()
{}
virtual ~targetEl() {}
};
class OW_WQL_API targetEl_aExpr_AS_strColLabel : public targetEl
{
public:
targetEl_aExpr_AS_strColLabel(
aExpr* pNewaExpr1,
blocxx::String* pNewAS2,
blocxx::String* pNewstrColLabel3
)
: targetEl()
, m_paExpr1(pNewaExpr1)
, m_pAS2(pNewAS2)
, m_pstrColLabel3(pNewstrColLabel3)
{}
virtual ~targetEl_aExpr_AS_strColLabel();
void accept( WQLVisitor* v ) const
{
v->visit_targetEl_aExpr_AS_strColLabel( this );
}
aExpr* m_paExpr1;
blocxx::String* m_pAS2;
blocxx::String* m_pstrColLabel3;
};
class OW_WQL_API targetEl_aExpr : public targetEl
{
public:
targetEl_aExpr(
aExpr* pNewaExpr1
)
: targetEl()
, m_paExpr1(pNewaExpr1)
{}
virtual ~targetEl_aExpr();
void accept( WQLVisitor* v ) const
{
v->visit_targetEl_aExpr( this );
}
aExpr* m_paExpr1;
};
class OW_WQL_API targetEl_strRelationName_PERIOD_ASTERISK : public targetEl
{
public:
targetEl_strRelationName_PERIOD_ASTERISK(
blocxx::String* pNewstrRelationName1,
blocxx::String* pNewPERIOD2,
blocxx::String* pNewASTERISK3
)
: targetEl()
, m_pstrRelationName1(pNewstrRelationName1)
, m_pPERIOD2(pNewPERIOD2)
, m_pASTERISK3(pNewASTERISK3)
{}
virtual ~targetEl_strRelationName_PERIOD_ASTERISK();
void accept( WQLVisitor* v ) const
{
v->visit_targetEl_strRelationName_PERIOD_ASTERISK( this );
}
blocxx::String* m_pstrRelationName1;
blocxx::String* m_pPERIOD2;
blocxx::String* m_pASTERISK3;
};
class OW_WQL_API targetEl_ASTERISK : public targetEl
{
public:
targetEl_ASTERISK(
blocxx::String* pNewASTERISK1
)
: targetEl()
, m_pASTERISK1(pNewASTERISK1)
{}
virtual ~targetEl_ASTERISK();
void accept( WQLVisitor* v ) const
{
v->visit_targetEl_ASTERISK( this );
}
blocxx::String* m_pASTERISK1;
};
class OW_WQL_API updateTargetEl : public node
{
public:
updateTargetEl(
blocxx::String* pNewstrColId1,
optIndirection* pNewoptIndirection2,
blocxx::String* pNewEQUALS3,
aExpr* pNewaExpr4
)
: m_pstrColId1(pNewstrColId1)
, m_poptIndirection2(pNewoptIndirection2)
, m_pEQUALS3(pNewEQUALS3)
, m_paExpr4(pNewaExpr4)
{}
virtual ~updateTargetEl();
void accept( WQLVisitor* v ) const
{
v->visit_updateTargetEl( this );
}
blocxx::String* m_pstrColId1;
optIndirection* m_poptIndirection2;
blocxx::String* m_pEQUALS3;
aExpr* m_paExpr4;
};
class OW_WQL_API aExprConst: public node
{
public:
aExprConst()
{}
virtual ~aExprConst() {}
};
class OW_WQL_API aExprConst_ICONST : public aExprConst
{
public:
aExprConst_ICONST(
blocxx::String* pNewICONST1
)
: aExprConst()
, m_pICONST1(pNewICONST1)
{}
virtual ~aExprConst_ICONST();
void accept( WQLVisitor* v ) const
{
v->visit_aExprConst_ICONST( this );
}
blocxx::String* m_pICONST1;
};
class OW_WQL_API aExprConst_FCONST : public aExprConst
{
public:
aExprConst_FCONST(
blocxx::String* pNewFCONST1
)
: aExprConst()
, m_pFCONST1(pNewFCONST1)
{}
virtual ~aExprConst_FCONST();
void accept( WQLVisitor* v ) const
{
v->visit_aExprConst_FCONST( this );
}
blocxx::String* m_pFCONST1;
};
class OW_WQL_API aExprConst_SCONST : public aExprConst
{
public:
aExprConst_SCONST(
blocxx::String* pNewSCONST1
)
: aExprConst()
, m_pSCONST1(pNewSCONST1)
{}
virtual ~aExprConst_SCONST();
void accept( WQLVisitor* v ) const
{
v->visit_aExprConst_SCONST( this );
}
blocxx::String* m_pSCONST1;
};
class OW_WQL_API aExprConst_BITCONST : public aExprConst
{
public:
aExprConst_BITCONST(
blocxx::String* pNewBITCONST1
)
: aExprConst()
, m_pBITCONST1(pNewBITCONST1)
{}
virtual ~aExprConst_BITCONST();
void accept( WQLVisitor* v ) const
{
v->visit_aExprConst_BITCONST( this );
}
blocxx::String* m_pBITCONST1;
};
class OW_WQL_API aExprConst_HEXCONST : public aExprConst
{
public:
aExprConst_HEXCONST(
blocxx::String* pNewHEXCONST1
)
: aExprConst()
, m_pHEXCONST1(pNewHEXCONST1)
{}
virtual ~aExprConst_HEXCONST();
void accept( WQLVisitor* v ) const
{
v->visit_aExprConst_HEXCONST( this );
}
blocxx::String* m_pHEXCONST1;
};
class OW_WQL_API aExprConst_TRUEP : public aExprConst
{
public:
aExprConst_TRUEP(
blocxx::String* pNewTRUEP1
)
: aExprConst()
, m_pTRUEP1(pNewTRUEP1)
{}
virtual ~aExprConst_TRUEP();
void accept( WQLVisitor* v ) const
{
v->visit_aExprConst_TRUEP( this );
}
blocxx::String* m_pTRUEP1;
};
class OW_WQL_API aExprConst_FALSEP : public aExprConst
{
public:
aExprConst_FALSEP(
blocxx::String* pNewFALSEP1
)
: aExprConst()
, m_pFALSEP1(pNewFALSEP1)
{}
virtual ~aExprConst_FALSEP();
void accept( WQLVisitor* v ) const
{
v->visit_aExprConst_FALSEP( this );
}
blocxx::String* m_pFALSEP1;
};
class OW_WQL_API aExprConst_NULLP : public aExprConst
{
public:
aExprConst_NULLP(
blocxx::String* pNewNULLP1
)
: aExprConst()
, m_pNULLP1(pNewNULLP1)
{}
virtual ~aExprConst_NULLP();
void accept( WQLVisitor* v ) const
{
v->visit_aExprConst_NULLP( this );
}
blocxx::String* m_pNULLP1;
};
} // end namespace WQL
} // end namespace OW_NAMESPACE
#endif
|
1f3c349d87bacc8fe8966589d769f15b5ddd46b5 | 90ea35a0e20c99f80f3826aa247e36f4270eadf8 | /Partition_labels.cpp | b3153ac14157e1853aae409638a577b30baa9021 | [] | no_license | Kiranchawla09/Leet | 154444b2c43214533dd11612a79c177aa5a218ed | 58b319b5e88062f811028c891b56a50367c2a9be | refs/heads/master | 2022-11-28T15:21:19.099087 | 2020-08-09T13:12:54 | 2020-08-09T13:12:54 | 239,078,024 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 588 | cpp | Partition_labels.cpp | class Solution {
public:
vector<int> partitionLabels(string S) {
vector <int> result;
unordered_map<char,int>mp;
for (int i=0;i<S.size();i++)
{
mp[S[i]]=i; //storing the last occurance of each letter
}
int start=0;
int end= 0;
for (int i=0;i<S.size();i++)
{
end= max(end,mp[S[i]]);
if (i==end)
{
result.push_back(end-start+1);
start=end+1;
}
}
return result;
}
}; |
45d9df167080dab6b8da37ae7e5bcf682f1f2c4e | c3a8a8ec04550a14d88e1df1175680ac0817c302 | /src/flame/graphics/WIP/texture.cpp | 4c5e7e42d964fb8b6918c668326eae5a0f249fac | [
"MIT"
] | permissive | coder965/flame | c0c0a27bf6f5b88d2e10a564528dafc4f8c83553 | 8de5beb7d15c400076cdb6fc29387295c0b24f51 | refs/heads/master | 2020-03-19T03:02:27.331192 | 2018-05-31T13:41:01 | 2018-05-31T13:41:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,181 | cpp | texture.cpp | #include <assert.h>
#include <filesystem>
#include <map>
#include <gli/gli.hpp>
#include <flame/string.h>
#include <flame/filesystem.h>
#include <flame/engine/graphics/buffer.h>
#include <flame/engine/graphics/texture.h>
#include <flame/engine/graphics/command_buffer.h>
#include <flame/engine/ui/ui.h>
namespace flame
{
Texture::Texture(TextureType _type, int _cx, int _cy, VkFormat _format, VkImageUsageFlags extra_usage, int _level, int _layer, bool _cube) :
type(_type),
format(_format),
layer_count(_layer),
cube(_cube),
sRGB(false),
material_index(-1),
ui_index(-1),
ui_ref_count(0)
{
}
Texture::~Texture()
{
if (ui_index != -1)
ui::unregister_texture(this);
}
int Texture::get_cx(int level) const
{
return levels[level].cx;
}
int Texture::get_cy(int level) const
{
return levels[level].cy;
}
int Texture::get_linear_offset(int x, int y, int level, int layer) const
{
auto offset = 0;
for (auto i = 0; i < level - 1; i++)
offset += levels[i].size_per_layer * layer_count;
offset += levels[level].size_per_layer * layer;
return offset + levels[level].pitch * y + x * (bpp / 8);
}
VkImageView Texture::get_view(VkImageViewType view_type, int base_level, int level_count, int base_layer, int layer_count)
{
for (auto &view : views)
{
if (view->view_type == view_type && view->base_level == base_level && view->level_count == level_count &&
view->base_layer == base_layer && view->layer_count == layer_count)
return view->v;
}
auto view = new TextureView(v, format, get_aspect(), view_type, base_level, level_count, base_layer, layer_count);
views.emplace_back(view);
return view->v;
}
static std::map<unsigned int, std::weak_ptr<Texture>> _images;
std::shared_ptr<Texture> get_texture(const std::string &filename)
{
auto hash = HASH(filename.c_str());
auto it = _images.find(hash);
if (it != _images.end())
{
auto s = it->second.lock();
if (s)
return s;
}
auto sRGB = false, cube = false;
{
std::ifstream ext(filename + ".ext");
if (ext.good())
{
std::string line;
while (!ext.eof())
{
std::getline(ext, line);
if (line == "srgb")
sRGB = true;
else if (line == "cube")
cube = true;
}
}
}
auto ext = path.extension().string();
if (ext == ".ktx" || ext == ".dds")
{
if (cube)
{
gli::texture_cube gli_texture_cube(gli_texture);
auto offset = 0;
for (auto j = 0; j < 6; j++)
{
for (auto i = 0; i < level; i++)
{
VkBufferImageCopy r = {};
r.bufferOffset = offset;
r.imageExtent.width = gli_texture_cube[j][i].extent().x;
r.imageExtent.height = gli_texture_cube[j][i].extent().y;
r.imageExtent.depth = 1;
r.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
r.imageSubresource.mipLevel = i;
r.imageSubresource.baseArrayLayer = j;
r.imageSubresource.layerCount = 1;
buffer_copy_regions.push_back(r);
offset += gli_texture_cube[j][i].size();
}
}
}
else
{
}
}
auto format = get_texture_format(channel, bpp, sRGB);
assert(format != VK_FORMAT_UNDEFINED);
auto t = std::make_shared<Texture>(TextureTypeImage, width, height,
format, 0, level, layer, cube);
t->filename = filename;
_images[hash] = t;
return t;
}
std::shared_ptr<Texture> default_color_texture;
std::shared_ptr<Texture> default_normal_texture;
std::shared_ptr<Texture> default_height_texture;
std::shared_ptr<Texture> default_blend_texture;
void init_texture()
{
auto cb = begin_once_command_buffer();
auto init_with_color = [&](Texture *t, const glm::vec4 &color){
t->transition_layout(cb, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
VkClearColorValue clear_value = { color.x, color.y, color.z, color.a };
VkImageSubresourceRange range = {
VK_IMAGE_ASPECT_COLOR_BIT,
0, t->levels.size(),
0, t->layer_count
};
vkCmdClearColorImage(cb->v, t->v, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_value, 1, &range);
t->transition_layout(cb, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
};
default_color_texture = std::make_shared<Texture>(TextureTypeImage, 4, 4, VK_FORMAT_R8G8B8A8_UNORM, 0);
default_color_texture->filename = "[default_color_texture]";
init_with_color(default_color_texture.get(), glm::vec4(0.f));
default_normal_texture = std::make_shared<Texture>(TextureTypeImage, 4, 4, VK_FORMAT_R8G8B8A8_UNORM, 0);
default_normal_texture->filename = "[default_normal_texture]";
init_with_color(default_normal_texture.get(), glm::vec4(0.f, 0.f, 1.f, 0.f));
default_blend_texture = std::make_shared<Texture>(TextureTypeImage, 4, 4, VK_FORMAT_R8G8B8A8_UNORM, 0);
default_blend_texture->filename = "[default_blend_texture]";
init_with_color(default_blend_texture.get(), glm::vec4(1.f, 0.f, 0.f, 0.f));
default_height_texture = std::make_shared<Texture>(TextureTypeImage, 4, 4, VK_FORMAT_R8_UNORM, 0);
default_height_texture->filename = "[default_height_texture]";
init_with_color(default_height_texture.get(), glm::vec4(1.f, 0.f, 0.f, 0.f));
end_once_command_buffer(cb);
}
}
|
fe21445df628f89969cb13bd3979b5535f6d1da9 | a4bd55c739a266d48051809405d3cc16bac04195 | /src/signAChart/QwtPlotItemDataModel.h | ae93e5c0c15119e95cdc1635d55b9165a0567352 | [] | no_license | zcatt/sa | 4def001dcfb1dfaf1f0a91f5f6538ac7491e904d | cb2a8c7ec42c38b8890e8eccc2227ebefc21a1e4 | refs/heads/master | 2021-05-05T23:10:00.320318 | 2018-01-03T08:42:52 | 2018-01-03T08:42:52 | 116,634,216 | 1 | 0 | null | 2018-01-08T05:32:59 | 2018-01-08T05:32:57 | null | UTF-8 | C++ | false | false | 1,489 | h | QwtPlotItemDataModel.h | #ifndef QWTPLOTITEMDATAMODEL_H
#define QWTPLOTITEMDATAMODEL_H
#include "SAChartGlobals.h"
#include <QAbstractTableModel>
#include <QList>
#include <algorithm>
#include <vector>
#include <qwt_plot_item.h>
class SA_CHART_EXPORT QwtPlotItemDataModel : public QAbstractTableModel
{
public:
QwtPlotItemDataModel(QObject *parent = 0);
void setQwtPlotItems(const QList<QwtPlotItem*>& items);
void addQwtPlotItems(QwtPlotItem* item);
void clear();
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QVariant data(const QModelIndex &index, int role) const;
void enableBackgroundColor(bool enable, int alpha = 30);
private:
void updateMaxRow(const QList<QwtPlotItem*>& items);
int toIndex(int col) const;
QwtPlotItem* getItemFromCol(int col) const;
QString getItemNameFromCol(int col) const;
public:
static int getItemDataCount(QwtPlotItem* item);
static QVariant getItemDataX(QwtPlotItem* item,int index);
static QVariant getItemDataY(QwtPlotItem* item,int index);
static QColor getItemColor(QwtPlotItem* item);
static bool isIntervalType(QwtPlotItem* item);
private:
QList<QwtPlotItem*> m_items;
int m_max_row;
int m_columnCount;
bool m_enableBkColor;///< ๆฏๅฆๅ
่ฎธ่ๆฏ่ฒ
int m_bkAlpha;///< ่ๆฏ้ๆๅบฆ
};
#endif // QWTPLOTITEMDATAMODEL_H
|
205012603c92ae8a3cf3114fee115047aaf3481b | 1cd106007557ddc432ed5a05c3609d901434bf76 | /src/NodeCaffe/Layer.cpp | 0ece2c2b9b6f6f4da0d2edb71d8111bf6b0f85d4 | [] | no_license | buddeep/node-caffe | 53b8245232b519d917627013ed9679ab680b9491 | 3cafd4e869fb2a99cc9eaf9752a72340947c4d07 | refs/heads/master | 2020-04-15T01:41:21.554225 | 2015-08-10T04:13:34 | 2015-08-10T04:13:51 | 40,385,837 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 910 | cpp | Layer.cpp | #include "Layer.h"
namespace NodeCaffe {
Nan::Persistent<v8::Function> Layer::constructor;
Layer::Layer() {}
Layer::~Layer() {}
NAN_MODULE_INIT(Layer::Init) {
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
tpl->SetClassName(Nan::New("Layer").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
//v8::Local<v8::ObjectTemplate> proto = tpl->PrototypeTemplate();
constructor.Reset(tpl->GetFunction());
Nan::Set(target, Nan::New("Layer").ToLocalChecked(),tpl->GetFunction());
}
NAN_METHOD(Layer::New) {
if (info.IsConstructCall()) {
Layer *obj = new Layer();
obj->Wrap(info.This());
info.GetReturnValue().Set(info.This());
} else {
const int argc = 1;
v8::Local<v8::Value> argv[argc] = {info[0]};
v8::Local<v8::Function> cons = Nan::New(constructor);
info.GetReturnValue().Set(cons->NewInstance(argc,argv));
}
}
}
|
33753774c88746ddd6d16ee1118bd94dac356596 | 2f10f807d3307b83293a521da600c02623cdda82 | /deps/boost/win/debug/include/boost/thread/thread_functors.hpp | 762fe95bf0752b293952283983886444a5b3e6d3 | [] | no_license | xpierrohk/dpt-rp1-cpp | 2ca4e377628363c3e9d41f88c8cbccc0fc2f1a1e | 643d053983fce3e6b099e2d3c9ab8387d0ea5a75 | refs/heads/master | 2021-05-23T08:19:48.823198 | 2019-07-26T17:35:28 | 2019-07-26T17:35:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 129 | hpp | thread_functors.hpp | version https://git-lfs.github.com/spec/v1
oid sha256:1a099200915cdaede674d18e9ea21f122a001dd2f1ba2f5d0b755d2591804e44
size 1366
|
0358daf0e9a89e6a349658c14ab4f81e9d63a352 | 52f02f0f6801278b70bfbf1ffd4a2ef570375487 | /src/visual.cpp | 641b00bcd8992b2666971032c5272cc347d051ba | [] | no_license | lukeyes/CCSR | c311b0338078a25265b2a30c3e9a440275a14c16 | 4145ae2240851d38ad47335e74dd57bc32b3287c | refs/heads/master | 2020-12-31T02:01:10.383260 | 2015-02-18T05:39:19 | 2015-02-18T05:39:19 | 28,166,320 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,567 | cpp | visual.cpp | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include "ccsr.h"
#include "lcdDisp.h"
#include "utils.h"
#include "servoCtrl.h"
#include "visual.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace std;
extern ccsrStateType ccsrState;
extern "C" {
// Set CCSR's active target color range in HSV values. CCSR will track this color if enabled
void setTargetColorRange(int iLowH, int iHighH, int iLowS, int iHighS, int iLowV, int iHighV) {
ccsrState.targetColor_iLowH = iLowH;
ccsrState.targetColor_iHighH = iHighH;
ccsrState.targetColor_iLowS = iLowS;
ccsrState.targetColor_iHighS = iHighS;
ccsrState.targetColor_iLowV = iLowV;
ccsrState.targetColor_iHighV = iHighV;
}
// Set CCSR's active target volume. CCSR will assume it arrived at the active target object if the
// volume (area) of the tracked color blob is more than this value
void setTargetColorVolume(int vol) {
ccsrState.targetColorVolume = vol;
}
// pthread process processing images from USB camera
void *visual () {
VideoCapture cap(0); //capture the video from webcam
// We capture 640x480 image by default
if ( !cap.isOpened() ) // if not success, exit program
{
cout << "Cannot open the web cam" << endl;
}
int roiHeight = ROI_HEIGHT;
int roiWidth = ROI_WIDTH;
int roiX = IMAGE_WIDTH/2 - ROI_WIDTH/2;
int roiY = IMAGE_HEIGHT/2 - ROI_HEIGHT/2;
// Adjust ROI from center to spot covering the grabber.
roiX = roiX - 65 ;
roiY = roiY + 130;
double fps = cap.get(CV_CAP_PROP_FPS);
// cout << "fps: " << fps << endl;
// cout << "width: " << cap.get(CV_CAP_PROP_FRAME_WIDTH) << endl;
// cout << "set: " << cap.set(CV_CAP_PROP_FPS, 6) << endl;
int iLowH = ccsrState.targetColor_iLowH;
int iHighH = ccsrState.targetColor_iHighH;
int iLowS = ccsrState.targetColor_iLowS;
int iHighS = ccsrState.targetColor_iHighS;
int iLowV = ccsrState.targetColor_iLowV;
int iHighV = ccsrState.targetColor_iHighV;
//Capture a temporary image from the camera
Mat imgTmp;
cap.read(imgTmp);
//Create a black image with the size as the camera output
Mat imgLines = Mat::zeros( imgTmp.size(), CV_8UC3 );;
Mat imgOriginal;
Mat imgHSV;
Mat imgThresholded;
Moments oMoments;
while (true)
{
iLowH = ccsrState.targetColor_iLowH;
iHighH = ccsrState.targetColor_iHighH;
iLowS = ccsrState.targetColor_iLowS;
iHighS = ccsrState.targetColor_iHighS;
iLowV = ccsrState.targetColor_iLowV;
iHighV = ccsrState.targetColor_iHighV;
bool bSuccess = cap.read(imgOriginal); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read a frame from video stream" << endl;
break;
}
cvtColor(imgOriginal, imgHSV, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV
// If asked to analyze an object held up by arm, calculate and capture avarage color values of object.
// Object is assumed to be held by arm exactly at square region of interrest (roi) in middle of image
// This is a one-shot operation. analyzeObject in actions.c sets ccsrState.analyzeObject to 1
// visual handshakes by resetting:
if(ccsrState.analyzeObject) {
Mat roi(imgHSV, Rect(roiX,roiY,roiWidth,roiHeight)); // extract small roi of image
Scalar meanRoi = mean(roi); // calculate mean HSV color value of roi
ccsrState.analyzedObjectH = meanRoi.val[0];
ccsrState.analyzedObjectS = meanRoi.val[1];
ccsrState.analyzedObjectV = meanRoi.val[2];
ccsrState.analyzeObject = 0;
cout << "analysed HSV:" << ccsrState.analyzedObjectH << " " << ccsrState.analyzedObjectS << " " << ccsrState.analyzedObjectV << endl;
}
inRange(imgHSV, Scalar(iLowH, iLowS, iLowV), Scalar(iHighH, iHighS, iHighV), imgThresholded); //Threshold the image
//morphological opening (removes small objects from the foreground)
erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
dilate( imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
//morphological closing (removes small holes from the foreground)
dilate( imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
//Calculate the moments of the thresholded image
oMoments = moments(imgThresholded);
double dM01 = oMoments.m01;
double dM10 = oMoments.m10;
double dArea = oMoments.m00;
// cout << " area " << dArea << endl;
// if the area < MIN_TRACKED_OBJECT_VOLUME, I consider that the there are no object in the image and it's
// because of the noise, the area is not zero
if (dArea > MIN_TRACKED_OBJECT_VOLUME)
{
ccsrState.objectTracked = 1;
//calculate the position of the ball
int posX = dM10 / dArea;
int posY = dM01 / dArea;
ccsrState.targetVisualObject_X = posX;
ccsrState.targetVisualObject_Y = posY;
ccsrState.targetVisualObject_Vol = dArea;
// cout << posX << " " << posY << " " << dArea << endl;
}
else {
ccsrState.objectTracked = 0;
}
// usleep(10000);
}
}
} // extern 'C'
|
162732bf73e8f1b257db27d76ba94886011dee3e | 30f79d4aa268643e9a49f4d9b7ea5e85d4d792ec | /golang/so/testso/test.cpp | a14e0a7ff1c76b3fd3dba6cf40b68c591ce8a13a | [] | no_license | cheseremtitus24/coovaOpenwrt | b2bcbcdfcffb59226cb1e7af9d418dea99b7d8c6 | f14ea4fad9a0d26dc54446268454277b4d4403da | refs/heads/master | 2023-08-19T11:20:55.379679 | 2021-09-19T06:21:20 | 2021-09-19T06:21:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 203 | cpp | test.cpp | #include "libtestso.h"
#include <iostream>
int main() {
std::cout << "This is a Cpp Application." << std::endl;
GoString name = {"Jack", 4};
SayHello(name);
SayBye();
return 0;
} |
947d2c67a71370b383006205d7eb43aa1c9791c6 | 3d20968b9a5569884521617559811fcd8967064c | /KncWX2Server/GameClient/KRobotPatternManager.cpp | 2289b6fed381c1492706a28f3f0dbab898c13c71 | [
"MIT"
] | permissive | seongwon-kang/Elsword-Source-2014 | b5252a97bdf7887f1079887908670ce8d20001ca | 5b4c1c040314e90ec3e541f2d75bf31b5062da91 | refs/heads/master | 2023-01-19T07:19:21.181215 | 2020-11-10T04:32:58 | 2020-11-10T04:32:58 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 4,397 | cpp | KRobotPatternManager.cpp | #include "KncRobotManager.h"
#include "KRobotPatternManager.h"
#include "../Common/X2Data/XSLMapData.h"
ImplementSingleton( KRobotPatternManager );
KRobotPatternManager::KRobotPatternManager(void)
{
boost::shared_ptr<lua_State> spLua = SiKncRobotManager()->GetLuaState();
lua_tinker::class_add<KRobotPatternManager>( spLua.get(), "KRobotPatternManager" );
lua_tinker::class_def<KRobotPatternManager>( spLua.get(), "AddRobotPattern", &KRobotPatternManager::AddRobotPattern_LUA );
lua_tinker::decl( spLua.get(), "RobotManager", this );
}
KRobotPatternManager::~KRobotPatternManager(void)
{
}
bool KRobotPatternManager::OpenScriptFile( const char* pFileName )
{
boost::shared_ptr<lua_State> spLua = SiKncRobotManager()->GetLuaState();
if( 0 != luaL_dofile( spLua.get(), pFileName ) ) return false;
return true;
}
bool KRobotPatternManager::AddRobotPattern_LUA()
{
boost::shared_ptr<lua_State> spLua = SiKncRobotManager()->GetLuaState();
KLuaManager kLuamanager( spLua.get() );
int iPatternIndex = 0;
KRobotPattern kRobotPattern;
LUA_GET_VALUE_RETURN( kLuamanager, L"m_iMapID", kRobotPattern.m_MapID, 0, return false; );
LUA_GET_VALUE( kLuamanager, L"m_iPatternIndex", iPatternIndex, 0 );
std::map< int, KPatternList >::iterator mit;
mit = m_mapFieldPatternList.find( kRobotPattern.m_MapID );
if( mit == m_mapFieldPatternList.end() )
{
KPatternList kPatternList;
kPatternList.push_back( iPatternIndex );
m_mapFieldPatternList.insert( std::make_pair( kRobotPattern.m_MapID, kPatternList ) );
}
else
{
mit->second.push_back( iPatternIndex );
}
LUA_GET_VALUE( kLuamanager, L"m_bIsRight", kRobotPattern.m_bIsRight, false );
LUA_GET_VALUE( kLuamanager, L"m_vPos_X", kRobotPattern.m_vPos.x, 0.0f );
LUA_GET_VALUE( kLuamanager, L"m_vPos_Y", kRobotPattern.m_vPos.y, 0.0f );
LUA_GET_VALUE( kLuamanager, L"m_vPos_Z", kRobotPattern.m_vPos.z, 0.0f );
if( kLuamanager.BeginTable( "FrameTable" ) == S_OK )
{
int index = 1;
int startPosId = 0;
while( kLuamanager.BeginTable( index ) == S_OK )
{
int iFrameCount = 0;
int iStateID = 0;
KFieldFrameInfo kFrameInfo;
LUA_GET_VALUE( kLuamanager, L"m_FrameCount", iFrameCount, 0 );
LUA_GET_VALUE( kLuamanager, L"m_StateID", iStateID, 0 );
kFrameInfo.m_FrameCount = iFrameCount;
kFrameInfo.m_StateID = iStateID;
kLuamanager.EndTable();
++index;
kRobotPattern.m_vecFieldFrame.push_back( kFrameInfo );
}
kLuamanager.EndTable();
}
std::map< int, std::vector< KRobotPattern > >::iterator mitPT;
mitPT = m_mapPattern.find( iPatternIndex );
if( mitPT == m_mapPattern.end() )
{
std::vector< KRobotPattern > vecPatternVector;
vecPatternVector.push_back( kRobotPattern );
m_mapPattern.insert( std::make_pair( iPatternIndex, vecPatternVector ) );
}
else
{
mitPT->second.push_back( kRobotPattern );
}
return true;
}
bool KRobotPatternManager::GetRandomFieldRobotPattern( IN int iMapID, OUT std::list< KRobotPattern >& listPattern )
{
listPattern.clear();
std::map< int, KPatternList >::const_iterator mit;
mit = m_mapFieldPatternList.find( iMapID );
if( mit == m_mapFieldPatternList.end() )
{
START_LOG( cerr, L"๋๋ค์ผ๋ก ๋ก๋ดํจํด ์ป๊ธฐ ์คํจ!" )
<< END_LOG;
return false;
}
const KPatternList& kPatternList = mit->second;
if( kPatternList.size() <= 0 )
{
START_LOG( cerr, L"ํจํด๋ฆฌ์คํธ๊ฐ ์ด์ํ๋ค!" )
<< BUILD_LOG( iMapID )
<< BUILD_LOG( kPatternList.size() )
<< END_LOG;
return false;
}
int iPatternIndex = rand() % kPatternList.size();
// ํจํด ์ป๊ธฐ
std::map< int, std::vector< KRobotPattern > >::const_iterator mitPT;
mitPT = m_mapPattern.find( kPatternList[iPatternIndex] );
if( mitPT == m_mapPattern.end() )
{
START_LOG( cerr, L"์กด์ฌํ์ง์๋ Pattern Index๋ค!" )
<< BUILD_LOG( kPatternList[iPatternIndex] )
<< END_LOG;
return false;
}
std::vector< KRobotPattern >::const_iterator vit;
for( vit = mitPT->second.begin(); vit != mitPT->second.end(); ++vit )
{
listPattern.push_back( *vit );
}
// ๋๋ถ๋ถ ์๋ผ๋จน๊ธฐ
int iDelCnt = rand() & 3;
for( int i = 0; i < iDelCnt; ++i )
{
listPattern.pop_back();
}
return true;
}
int KRobotPatternManager::GetRandomMapID()
{
int iMapID = m_kMapLottery.Decision();
if( iMapID == KLottery::CASE_BLANK )
iMapID = CXSLMapData::MI_RUBEN;
return iMapID;
}
|
949daec8f7c72e769ea7def4349bc21a3c46a89d | 39cf008356c868b1163d95aa37eba05b8a2130ae | /basicButton.cpp | b9a4d7900ec595b6b011ad5b6450de57abb06bdf | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | mynameisdesmond/msbOFCore | 12f9550446dc16d000f6920fda546b22ab56c123 | 1e0fb5919c1fdbd7aa99fe7c31f53fe94958270a | refs/heads/master | 2020-04-05T19:03:07.361458 | 2014-04-21T16:29:16 | 2014-04-21T16:29:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,375 | cpp | basicButton.cpp | #include "basicButton.h"
#include "input.h"
BasicButton::BasicButton(){
scale=Vector3f(30.0f,30.0f,30.0f);
name="BasicButton";
textureID="icon_base";
bComputeLight=false;
bOver=false;
bDrawName=false;
bAlwaysUpdate=false;
bPermanent=false;
bScreenOverlay=false;
bMessageWindow=false;
bDrawOrientation=false;
bDragable=false;
bConfineDragX=false;
bConfineDragY=false;
bResetAfterDrag=true;
bTriggerWhileDragging=false;
tooltip="";
tooltipOffset=Vector2f(0,0);
parent=NULL;
buttonProperty="NULL";
level=0;
sceneShaderID="texture";
drawType=DRAW_PLANE;
bTextured=true;
bUseShader=true;
registerProperties();
}
BasicButton::~BasicButton(){
}
//setup functions
void BasicButton::registerProperties(){
createMemberID("LEVEL",&level,this);
createMemberID("PARENT",&parent,this);
createMemberID("BUTTONPROPERTY",&buttonProperty,this);
Actor::registerProperties();
}
void BasicButton::setup(){
tooltipOffset=Vector2f(scale.x+2,scale.y/2 +2);
Actor::setup();
}
void BasicButton::update(double deltaTime){
Actor::update(deltaTime);
}
void BasicButton::drawTooltip(){
//tooltip rendering
if (bOver)
{
if(tooltip=="" && !bDrawName)
input->drawText(name, location.x + tooltipOffset.x , location.y + tooltipOffset.y);
else
input->drawText(tooltip, location.x + tooltipOffset.x , location.y + tooltipOffset.y);
}
//drawname is not a tooltip! So no tooltipOffset here!
if (bDrawName)
input->drawText((char*)name.c_str(), location.x+2,location.y+scale.y/2+2.0);
bOver=false;
}
void BasicButton::drawPlane(){
if (bMessageWindow){
renderer->setupShading("color");
renderer->drawPlane(-20.0, -20.0, -20.0+400, 100, Vector4f(0.2,0.2,0.2,1.0));
}
renderer->drawPlane(0.0,0.0,scale.x,scale.y, color );
}
void BasicButton::mouseOver(){
bOver=true; // for later rendering of tooltip!
}
void BasicButton::mouseDrag(){
}
void BasicButton::finishDrag(){}
void BasicButton::clickedLeft(){
}
void BasicButton::focusClick(){
input->focusButton=NULL;
//destroy message window after input
if (bMessageWindow && level>0)
input->deselectButtons(0);
}
void BasicButton::clickedRight(){
}
void BasicButton::remove(){
for (uint i=0;i<renderer->buttonList.size();i++){
if (renderer->buttonList[i]==this)
renderer->buttonList.erase(renderer->buttonList.begin()+i);
}
if (bPermanent){
for (uint i=0;i<renderer->saveableButtonList.size();i++){
if (renderer->saveableButtonList[i]==this)
renderer->saveableButtonList.erase(renderer->saveableButtonList.begin()+i);
}
}
delete(this);
}
void BasicButton::deselect(int depth){
if (level>depth && !bPermanent)
remove();
}
void BasicButton::create(){
renderer->addButton(this);
std::cout << "creating a button!";
}
TiXmlElement* BasicButton::save(TiXmlElement *root){
TiXmlElement * element = new TiXmlElement( "Button" );
element->SetAttribute("name", name);
TiXmlText * text = new TiXmlText( typeid(*this).name() );
element->LinkEndChild( text );
std::map <std::string, memberID>::iterator it;
for ( it=property.begin() ; it != property.end(); it++ )
{
TiXmlElement * property=new TiXmlElement(it->first);
string value = memberToString(&it->second);
property->LinkEndChild ( new TiXmlText( value));
element->LinkEndChild( property );
}
return element;
}
|
dd856e60367c590bbed8b15138cff8857efeaec0 | b1d8e2993720ccef6c172148297231f8953faa33 | /source/string.hpp | 3db3c883c109e922286a954fadf4091d144c64d7 | [] | no_license | cai-pi-rinha/DHBW | 1284da7a24e026a73a5956fec9d20ecfd641f824 | e1b3aedc1fd0ef099b03554cfd4ed09ffccfd0fc | refs/heads/master | 2020-04-21T09:21:21.065395 | 2019-03-20T10:53:23 | 2019-03-20T10:53:23 | 169,445,815 | 0 | 0 | null | 2019-02-14T12:33:06 | 2019-02-06T17:24:46 | C++ | UTF-8 | C++ | false | false | 3,692 | hpp | string.hpp | // Headerfile "string.hpp"
#ifndef STRING_HPP
#define STRING_HPP
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
class String
{
private:
char* m_pszStr;
int m_ilength;
void setLength();
public:
String();
String(char* pcszStr);
String(const char* pcszStr);
String(const String& rccoObj);
~String();
int Length() const;
/*
gibt lรคnge des strings zurรผck
*/
int FindChar(char cSearch, int iStartIndex=0) const;
/*
sucht nach char, gibt index zurรผck, an dem char ist. wenn nicht gefunden rรผckgabe -1
*/
int FindString(const char* pszSearchString, int iStartIndex=0) const;
/*
sucht nach string, gibt index zurรผck, an dem string startet. wenn nicht gefunden rรผckgabe -1
*/
const char* GetStr() const; //gibt string aus
/*
Ausgabe des Strings
*/
operator const char*() const;
operator char*();
operator int() const; //wandelt string in zahl um
/*
wandelt String in Zahl um. BSP: "1234" wird zu Zahl 1234
*/
String& Normalise(const char* pszParameters);
/*
String von kriterien die nicht am anfang oder ende stehen sollen wird eingegeben -> zeichen am ende und anfang werden gelรถscht
*/
String& Cut(int iStartIndex, int iStopIndex);
/*
legt dynamisch string an und liefert ausgeschnittenen teil zurรผck, รผbriggebliebener teil wird in ursprungsstring gespeichert
bei nichteinhaltung der grenzen wird string mit "NULL" zurรผckgeliefert
*/
String& PartCopy(int iStartIndex, int iStopIndex) const;
/*
partialcopy, kopiert von start bis stop den string und gibt string obj zurรผck
*/
char operator[](int i) const;
/*
Zugriffsoperator, liefert Zeichen an angegebenem Index zurรผck
*/
bool Replace(int i, char cNew);
/*
ersetzt den char an stelle i durch cNew, wenn es geklappt hat wird true zurรผckgegeben, sonst false
*/
String& operator=(const char* pszBuf);
String& operator=(const String& rccoObj);
/*
Zuweisung
*/
bool operator==(const String& rccoObj);
/*
Vergleichsoperatoren, selbsterklรคrend...
*/
bool operator!=(const String& rccoObj);
/*ungleich -> true*/
bool operator>=(const String& rccoObj);
/*true wenn grรถรergleich*/
bool operator<=(const String& rccoObj);
bool operator>(const String& rccoObj);
bool operator<(const String& rccoObj);
String& operator+=(const String& rccoObj);
String& operator+=(char* rccoObj);
/*
String an jetzigen String anhรคngen. Bsp: Gustav += Gans --> GustavGans
*/
};
// Berechnet die Laenge des uebergebenen Strings in Zeichen
// (ohne das abschliessende 0-Byte)
extern int Strlen(const char* pcszStr);
// Vergleicht die beiden uebergebenen Strings zeichenweise miteinander
// und liefert den ASCII-Unterschied des ersten nicht mehr uebereinstimmenden
// Zeichens zurueck.
// Sind beide Strings identisch, dann liefert die Funktion den Wert 0.
//
// "Hans", "Heiner" => Differenz: 'a' - 'e'
// "Hein", "Heiner" => Differenz: '\0' - 'e'
// "", "Hans" => Differenz: '\0' - 'H'
// NULL, "Hans" => Differenz: '\0' - 'H'
extern int Strcmp(const char* pcszStr1, const char* pcszStr2);
// Kopiert den String aus pcszSrc zeichenweise in den bereitgestellten
// Puffer, der ueber pszBuf addressiert wird.
extern char* Strcpy(char* pszBuf, const char* pcszSrc);
// Erzeugt eine Kopie des uebergebenen Strings auf dem dynamischen Heap.
//
// Zu beachten:
// Allokiert wird mit array-new: char* psz = new char[count];
// Die Freigabe erfolgt mit array-delete: delete[] psz;
//
extern char* Strdup(const char* pcszStr);
#endif // STRING_HPP
|
0c7776be73f2f04c8056666b5181b3e25bc6392a | 2b258984f00a8aa8a07a437197538651b369423e | /main.cpp | cdb55828feb3518f324060cff1da609d959dbf81 | [] | no_license | gmorleo/p2pDDSketch | 6a53bd7956d593aef717e6085a881cf7f376a479 | 26e19c220ab582a223c1f93521ff1b0a61994117 | refs/heads/master | 2020-09-04T17:08:32.790855 | 2020-02-01T17:12:11 | 2020-02-01T17:12:11 | 219,826,299 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 35,556 | cpp | main.cpp | /********************************************************************
DDSketch
An algorithm for tracking quantiles in data streams
Charles Masson, Jee E. Rim, and Homin K. Lee. 2019. DDSketch: a fast and fully-mergeable quantile sketch with relative-error guarantees. Proc. VLDB Endow. 12, 12 (August 2019), 2195-2205. DOI: https://doi.org/10.14778/3352063.3352135
This implementation by
by Giuseppe Morleo
University of Salento, Italy
*********************************************************************/
/// \file
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <igraph/igraph.h>
#include <cstring>
#include <random>
#include <chrono>
#include <fstream>
#include <iomanip>
#include <codecvt>
#include "boost/program_options.hpp"
#include "ddsketch.h"
#include "graph.h"
#define BOLDMAGENTA "\033[1m\033[35m"
#define BOLDRED "\033[1m\033[31m" /* Bold Red */
#define GREEN "\x1B[32m"
#define RESET "\033[0m"
using namespace std;
using namespace std::chrono;
namespace po = boost::program_options;
const int DEFAULT_DISTRIBUTION_TYPE = 1;
const double DEFAULT_MEAN = 1;
const double DEFAULT_STDDEV = 3;
const long DEFAULT_NI = 508;
const uint32_t DEFAULT_DOMAIN_SIZE = 1048575;
const int DEFAULT_GRAPH_TYPE = 2;
const int DEFAULT_PEERS = 10;
const int DEFAULT_FAN_OUT = 1;
const double DEFAULT_CONVERGENCE_THRESHOLD = 0.0001;
const int DEFAULT_CONVERGENCE_LIMIT = 3;
const int DEFAULT_ROUND_TO_EXECUTE = 10;
const int DEFAULT_OFFSET = 1073741824; //2^30
const int DEFAULT_BIN_LIMIT = 500;
const float DEFAULT_ALPHA = 0.000161167;
// 0.000322334
// 0.000161167
typedef struct Params {
/// Number of elements
long ni;
/// Distribution type
int distrType;
/// Normal distribution Mean
double mean;
/// Normal distribution Stddev
double stddev;
/// Exponential distribution lambda
double lambda;
/// Uniform real distribution a
double a;
/// Uniform real distribution b
double b;
/// Random number generator seed
double seed;
/// Name of dataset
string datasetName;
/// Number of possible distinct items
uint32_t domainSize;
/// Graph distribution: 1 geometric 2 Barabasi-Albert 3 Erdos-Renyi 4 regular (clique)
int graphType;
/// Number of peers in the net
int peers;
/// Fan-out
int fanOut;
/// Threshold to check the peer's convergence
double convThreshold;
/// Number of consecutive rounds in which a peer must locally converge
int convLimit;
/// Fixed number of round to execute
int roundsToExecute;
/// Output file
bool outputOnFile;
/// Output file to redirect stdout
string outputFilename;
/// Used to allow the skecth storing both positive, 0 and negative values
int offset;
/// Maximum number of bins
int binLimit;
/// This parameter defines alpha-accuracy of a q-quantile
double alpha;
/// Vector of desired quantiles
vector<double> q;
} Params;
/**
* @brief This function sets the start time
*/
void startTheClock();
/**
* @brief This function returns the time between the start time and the end time
* @return Total elapsed time (difference between end and start times)
*/
double stopTheClock();
/**
* @brief Params constructor
* @return An allocated Params data structure with default parameters
*/
Params* init();
/**
* @brief This function parses the command-line arguments
* @param argc Count of command line arguments
* @param argv Command line arguments
* @param params Params data structure
* @return 0 success, -13 usage error
*/
int parse(int argc, char** argv, Params* params);
/**
* @brief This function computes the dimension of the dataset
* @param nameFile Name of the dataset
* @param row Where the number of rows will be stored
* @return 0 success, -3 file error
*/
int getDatasetSize(const string &nameFile, long &rows);
/**
* @brief This function loads the dataset into an array
* @param nameFile Name of the dataset
* @param dataset Array where the dataset will be stored
* @return 0 success, -3 file error, -9 null pointer error
*/
int loadDataset(const string &nameFile, double *dataset);
/**
* @brief This function generate a dataset according to the input distribution
* @param Params data structure
* @param dataset Array where the dataset will be stored
* @return 0 success, -9 null pointer error, -12 param data structure error
*/
int generateDataset(Params* params, double *dataset);
/**
* @brief This function computes the last item of the dataset for each peer. Peer i will obtain all data from peerLastItem[i-1] and peerLastItem[i]
* @param params Params data structure
* @param peerLastItem Data structure where the result will be stored
* @return 0 success, -14 dataset division error
*/
int computeLastItem(Params* params, long* peerLastItem);
/**
* @brief This function generates a formatted string with all parameters of the algorithm
* @param params Params data structure
* @return Formatted string with all parameters
*/
string printParameters(Params* params);
/**
* @brief This function initializes the sketch for each peer
* @param params Params data structure
* @param dds Array of sketch structures
* @return 0 success, -2 memory error
*/
int distributedInitializeSketch(Params* params, DDS_type** dds);
/**
* @brief This function simulates a distributed computation, Each peer adds its part of elements to its sketch.
* @param params Params data structure
* @param dds Array of sketch structures
* @param dataset Dataset
* @param peerLastItem Array of the last dataset element for each peer
* @return 0 success, -2 memory error, -4 sketch error, -9 null pointer error
*/
int distributedAdd(Params* params, DDS_type** dds, double* dataset, const long* peerLastItem);
/**
* @brief This function simulates a distributed communication
* @param params Params data structure
* @param dds Array of sketch structures
* @param graph Network graph
* @return 0 success, -2 memory error, -4 sketch error, -9 null pointer error
*/
int distributedCommunication(Params* params, DDS_type** dds, igraph_t *graph);
/**
* @brief This function finalize the simulation of the distributed communication
* @param params Params data structure
* @param dds Array of sketch structures
* @param weight Array of peer weights
* @return 0 success, -4 sketch error, -9 null pointer error
*/
int distributedFinalizeCommunication(Params* params, DDS_type** dds, double* weight);
/**
* @brief This function computes the quantiles
* @param dds Parameters of the sketch
* @param stream Vector that contains all the real values inserted
* @param numberElements Number of elements
* @param result Result of the test
* @return 0 success, -4 bad sketch data structure, -6 q is not in the [0,1] range -9 null pointer error
*/
int testQuantile(DDS_type *dds, double* stream, long numberElements, stringstream &result, const vector<double>& q) ;
high_resolution_clock::time_point t1, t2;
int main(int argc, char **argv) {
int returnValue = -1;
ofstream out;
stringstream result;
Params *params = nullptr;
DDS_type** dds = nullptr;
double* dataset = nullptr;
long* peerLastItem = nullptr;
igraph_t* graph = nullptr;
/*** Initialize the algorithm based on default parameters ***/
params = init();
if (!params) {
printError(PARAM_ERROR, __FUNCTION__);
returnValue = PARAM_ERROR;
goto ON_EXIT;
}
/*** Parse user-supplied parameters ***/
if ( argc > 1) {
returnValue = parse(argc, argv, params);
if (returnValue) {
goto ON_EXIT;
}
}
/*** Open file for output ***/
if (params->outputOnFile) {
out.open(params->outputFilename);
if (!out.is_open()) {
printError(FILE_ERROR, __FUNCTION__);
returnValue = FILE_ERROR;
goto ON_EXIT;
}
}
/*** Print algorithm parameters ***/
if(!params->outputOnFile) {
cout << BOLDRED << "\nPARAMETERS:\n" << RESET;
cout << printParameters(params);
} else {
out << printParameters(params);
}
/*** Initialize dataset array ***/
dataset = new (nothrow) double[params->ni];
if (!dataset) {
printError(MEMORY_ERROR, __FUNCTION__);
returnValue = MEMORY_ERROR;
goto ON_EXIT;
}
/*** Load or generate Dataset ***/
if ( !params->datasetName.empty()) {
returnValue = loadDataset(params->datasetName, dataset);
if (returnValue) {
goto ON_EXIT;
}
} else {
returnValue = generateDataset(params, dataset);
if (returnValue) {
goto ON_EXIT;
}
}
sort(dataset,dataset+params->ni);
/*** Compute last item for each peer ***/
peerLastItem = new (nothrow) long[params->peers]();
if (!peerLastItem) {
printError(MEMORY_ERROR, __FUNCTION__);
returnValue = MEMORY_ERROR;
goto ON_EXIT;;
}
returnValue = computeLastItem(params, peerLastItem);
if (returnValue) {
goto ON_EXIT;
}
/*** Generate random Graph ***/
graph = generateGraph(params->peers, params->graphType);
if (!graph) {
goto ON_EXIT;
}
if(!params->outputOnFile) {
cout << printGraphProperties(graph);
} else {
out << printGraphProperties(graph);
}
/*** Declaration of peer sketches ***/
dds = new (nothrow) DDS_type* [params->peers];
if (!dds) {
printError(MEMORY_ERROR, __FUNCTION__);
returnValue = MEMORY_ERROR;
goto ON_EXIT;
}
/*** Distributed computation ***/
returnValue = distributedInitializeSketch(params, dds);
if (returnValue) {
cout << BOLDMAGENTA << "Error initializing sketch" << RESET << endl;
goto ON_EXIT;
}
/*** Distributed computation ***/
returnValue = distributedAdd(params, dds, dataset, peerLastItem);
if (returnValue) {
cout << BOLDMAGENTA << "Error adding items" << RESET << endl;
goto ON_EXIT;
}
/* for ( int peerID = 0; peerID < 10; peerID++) {
DDS_PrintCSV(dds[peerID], "bins-peer-"+to_string(peerID)+".csv");
}*/
/*** Distributed communication ***/
returnValue = distributedCommunication(params, dds, graph);
if ( returnValue < 0 ) {
cout << BOLDMAGENTA << "Error distributed communication" << RESET << endl;
goto ON_EXIT;
}
DDS_PrintCSV(dds[0], "prova-nuova-non-ordinati.csv");
/*** Computing the quantiles ***/
result.str("");
returnValue = testQuantile(dds[0], dataset, params->ni, result, params->q);
if ( returnValue < 0 ) {
cout << BOLDMAGENTA << "Error during the quantiles computation" << RESET << endl;
goto ON_EXIT;
}
nth_element(dataset, dataset + (params->ni-1), dataset + params->ni);
cout << dataset[params->ni-1] << endl;
if(!params->outputOnFile) {
cout << result.str();
} else {
out << result.str();
}
ON_EXIT:
if(dataset != nullptr) {
delete[] dataset, dataset = nullptr;
}
if(peerLastItem != nullptr) {
delete[] peerLastItem, peerLastItem = nullptr;
}
if(dds != nullptr) {
for (int i = 0; i < params->peers; ++i) {
DDS_Destroy(dds[i]), dds[i] = nullptr;
}
delete dds, dds = nullptr;
}
if(params != nullptr) {
delete params, params = nullptr;
}
if ( graph != nullptr ) {
igraph_destroy(graph), graph = nullptr;
}
if (out.is_open()) {
out.close();
}
return returnValue;
}
int distributedInitializeSketch(Params* params, DDS_type** dds) {
if (!params) {
printError(PARAM_ERROR, __FUNCTION__);
return PARAM_ERROR;
}
if (!dds) {
printError(SKETCH_ERROR, __FUNCTION__);
return SKETCH_ERROR;
}
cout << BOLDRED << "\nStart distributed initialization.." << RESET << endl;
startTheClock();
for(int peerID = 0; peerID < params->peers; peerID++) {
// Initialization peers sketches
dds[peerID] = DDS_Init(params->offset, params->binLimit, params->alpha);
if (!dds[peerID]) {
return MEMORY_ERROR;
}
}
double distributedTime = stopTheClock();
cout << "Time (seconds) required to initialize all sketch for all the peers: " << distributedTime << "\n";
return SUCCESS;
}
int distributedAdd(Params* params, DDS_type** dds, double* dataset, const long* peerLastItem) {
if (!params) {
printError(PARAM_ERROR, __FUNCTION__);
return PARAM_ERROR;
}
if (!dds) {
printError(SKETCH_ERROR, __FUNCTION__);
return SKETCH_ERROR;
}
if (!dataset || !peerLastItem) {
printError(NULL_POINTER_ERROR, __FUNCTION__);
return NULL_POINTER_ERROR;
}
cout << BOLDRED << "\nStart distributed computation.." << RESET << endl;
int returnValue = -1;
startTheClock();
long start = 0;
for(int peerID = 0; peerID < params->peers; peerID++){
// Adding elements to the sketch
for ( long i = start; i <= peerLastItem[peerID]; i++ ) {
returnValue = DDS_AddCollapse(dds[peerID], dataset[i]);
if (returnValue) {
return returnValue;
}
}
start = peerLastItem[peerID] + 1;
}
double distributedTime = stopTheClock();
cout << "Time (seconds) required to add all elements for all the peers: " << distributedTime << "\n";
return returnValue;
}
int distributedCommunication(Params* params, DDS_type** dds, igraph_t *graph) {
if (!params) {
printError(PARAM_ERROR, __FUNCTION__);
return PARAM_ERROR;
}
if (!dds) {
printError(SKETCH_ERROR, __FUNCTION__);
return SKETCH_ERROR;
}
if (!graph) {
printError(NULL_POINTER_ERROR, __FUNCTION__);
return NULL_POINTER_ERROR;
}
cout << BOLDRED << "\nStart distributed communication.." << RESET << endl;
int returnValue = -1;
double* weight = nullptr;
double* prevWeight = nullptr;
bool* converged = nullptr;
int* convRounds = nullptr;
double comunicationTime;
int rounds = 0;
int activePeers = params->peers;
// Weight for sum only one peer is set to 1
weight = new (nothrow) double[params->peers]();
if(!weight) {
printError(MEMORY_ERROR, __FUNCTION__);
returnValue = MEMORY_ERROR;
goto ON_EXIT;
}
weight[0] = 1;
// Values at round t-1
prevWeight = new (nothrow) double[params->peers]();
if(!prevWeight) {
printError(MEMORY_ERROR, __FUNCTION__);
returnValue = MEMORY_ERROR;
goto ON_EXIT;
}
// Converged peers
converged = new (nothrow) bool[params->peers]();
if(!converged) {
printError(MEMORY_ERROR, __FUNCTION__);
returnValue = MEMORY_ERROR;
goto ON_EXIT;
}
for(int i = 0; i < params->peers; i++) {
converged[i] = false;
}
// Local convergence tolerance
convRounds = new (nothrow) int[params->peers]();
if(!convRounds) {
printError(MEMORY_ERROR, __FUNCTION__);
returnValue = MEMORY_ERROR;
goto ON_EXIT;
}
if (!params->outputOnFile) {
cout <<"Starting distributed agglomeration merge..." << endl;
}
startTheClock();
/*** Merge information about agglomeration ***/
while((params->roundsToExecute < 0 && activePeers) || params->roundsToExecute > 0) {
memcpy(prevWeight, weight, params->peers * sizeof(double));
for (int peerID = 0; peerID < params->peers; peerID++) {
// determine peer neighbors
igraph_vector_t neighbors;
igraph_vector_init(&neighbors, 0);
igraph_neighbors(graph, &neighbors, peerID, IGRAPH_ALL);
long neighborsSize = igraph_vector_size(&neighbors);
if (params->fanOut < neighborsSize && params->fanOut != -1) {
// randomly sample fan-out adjacent vertices
igraph_vector_shuffle(&neighbors);
igraph_vector_remove_section(&neighbors, params->fanOut, neighborsSize);
}
neighborsSize = igraph_vector_size(&neighbors);
for (long i = 0; i < neighborsSize; i++) {
int neighborID = (int) VECTOR(neighbors)[i];
igraph_integer_t edgeID;
igraph_get_eid(graph, &edgeID, peerID, neighborID, IGRAPH_UNDIRECTED, 1);
//DDS_PrintCSV(dds, "prima.csv");
// Merge the sketches
returnValue = DDS_MergeCollapse(dds[peerID], dds[neighborID]);
if (returnValue) {
goto ON_EXIT;
}
// Replace the sketch dds[neighborID] with the new merged sketch, i.e., dds[peerID]
returnValue = DDS_replaceSketch(dds[peerID], dds[neighborID]);
if (returnValue) {
goto ON_EXIT;
}
double mean = (weight[peerID] + weight[neighborID]) / 2;
weight[peerID] = mean;
weight[neighborID] = mean;
}
igraph_vector_destroy(&neighbors);
}
// check local convergence, if roundsToExecute is less than 0, the algorithm will be running until convergence
if (params->roundsToExecute < 0) {
for(int peerID = 0; peerID < params->peers; peerID++){
if(converged[peerID])
continue;
// Check local convergence
bool weightConv;
if(prevWeight[peerID])
weightConv = fabs((prevWeight[peerID] - weight[peerID]) / prevWeight[peerID]) < params->convThreshold;
else
weightConv = false;
// Increase rounds of convergence
if(weightConv)
convRounds[peerID]++;
else
convRounds[peerID] = 0;
//printf ("PeerID %d, round %d, convRound %d\n", peerID, rounds, convRounds[peerID]);
// If a peer reaches convergence, decrease by one the number of peers that have reached the convergence
converged[peerID] = (convRounds[peerID] >= params->convLimit);
if(converged[peerID]){
//printf("peer %d rounds before convergence: %d\n", peerID, rounds + 1);
activePeers --;
}
}
}
rounds++;
cout << GREEN << " Active peers: " << setw(6) << activePeers << " - Rounds: " << setw(2) << rounds << RESET << endl;
params->roundsToExecute--;
}
comunicationTime = stopTheClock();
cout << "\nTime (seconds) required to reach convergence: " << comunicationTime << "\n";
returnValue = distributedFinalizeCommunication(params, dds, weight);
if (returnValue) {
goto ON_EXIT;
}
cout << "Estimate of peers number: " << 1/weight[0] << endl;
ON_EXIT:
if (weight != nullptr) {
delete[] weight, weight = nullptr;
}
if (prevWeight != nullptr ) {
delete[] prevWeight, prevWeight = nullptr;
}
if ( converged != nullptr ) {
delete[] converged, converged = nullptr;
}
if (convRounds != nullptr ) {
delete[] convRounds, convRounds = nullptr;
}
return returnValue;
}
int distributedFinalizeCommunication(Params* params, DDS_type** dds, double* weight) {
if (!params) {
printError(PARAM_ERROR, __FUNCTION__);
return PARAM_ERROR;
}
if (!dds) {
printError(SKETCH_ERROR, __FUNCTION__);
return SKETCH_ERROR;
}
if (!weight) {
printError(NULL_POINTER_ERROR, __FUNCTION__);
return NULL_POINTER_ERROR;
}
int returnValue = -1;
// Finalize the sum by dividing each value by weight[peerID]
for(int peerID = 0; peerID < params->peers; peerID++){
// Finalize gossip communication
returnValue = DDS_finalizeGossip(dds[peerID], weight[peerID]);
if (returnValue) {
return returnValue;
}
}
return returnValue;
}
int computeLastItem(Params* params, long* peerLastItem) {
if (!params) {
printError(PARAM_ERROR, __FUNCTION__);
return PARAM_ERROR;
}
if (!peerLastItem) {
printError(NULL_POINTER_ERROR, __FUNCTION__);
return NULL_POINTER_ERROR;
}
random_device rd; // obtain a random number from hardware
mt19937 eng(rd()); // seed the generator
uniform_real_distribution<> distr(-1, 1); // define the range
for(int i = 0; i < params->peers - 1; i++){
float rnd = distr(eng);
//cerr << "rnd: " << rnd << "\n";
long last_item = rnd * ((float)params->ni/(float)params->peers) * 0.1 + (float) (i+1) * ((float)params->ni/(float)params->peers) - 1;
peerLastItem[i] = last_item;
}
peerLastItem[params->peers - 1] = params->ni-1;
/*** check the partitioning correctness ***/
int lastNotNull=0;
long sum = peerLastItem[0] + 1;
//cerr << "peer 0:" << sum << "\n";
for(int i = 1; i < params->peers; i++) {
if (!peerLastItem[i] && peerLastItem[i] != peerLastItem[i-1]) {
lastNotNull = i-1;
//cerr << "peer " << i << ":" << 0 << "\n";
} else {
if (peerLastItem[i-1] != 0) {
sum += peerLastItem[i] - peerLastItem[i-1];
//cerr << "peer " << i << ":" << peerLastItem[i] - peerLastItem[i-1] << "\n";
}
else if (peerLastItem[i]){
sum += peerLastItem[i] - peerLastItem[lastNotNull];
//cerr << "peer " << lastNotNull+1 << ":" << peerLastItem[i] - peerLastItem[lastNotNull] << "\n";
}
}
}
//cout<< "sum: " << sum << endl;
if(sum != params->ni) {
cerr << "ERROR: ni = "<< params->ni << "!= sum = " << sum << endl;
printError(DATASET_DIVISION_ERROR, __FUNCTION__);
return DATASET_DIVISION_ERROR;
}
//cout.flush();
return SUCCESS;
}
Params* init() {
// Initialize the sketch based on user-supplied parameters
Params *params = nullptr;
params = new (nothrow) Params;
if(!params){
fprintf(stdout,"Memory allocation of params data structure failed\n");
return nullptr;
}
params->distrType = DEFAULT_DISTRIBUTION_TYPE;
params->mean = DEFAULT_MEAN;
params->stddev = DEFAULT_STDDEV;
params->ni = DEFAULT_NI;
params->domainSize = DEFAULT_DOMAIN_SIZE;
params->graphType = DEFAULT_GRAPH_TYPE;
params->peers = DEFAULT_PEERS;
params->fanOut = DEFAULT_FAN_OUT;
params->convThreshold = DEFAULT_CONVERGENCE_THRESHOLD;
params->convLimit = DEFAULT_CONVERGENCE_LIMIT;
params->roundsToExecute = DEFAULT_ROUND_TO_EXECUTE;
params->outputOnFile = !params->outputFilename.empty();
params->offset = DEFAULT_OFFSET;
params->binLimit = DEFAULT_BIN_LIMIT;
params->alpha = DEFAULT_ALPHA;
params->q.insert( params->q.begin(),{0.01, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.99});
return params;
}
int conflicting_options(const po::variables_map& vm, const char* opt1, const char* opt2)
{
if (vm.count(opt1) && !vm[opt1].defaulted() && vm.count(opt2) && !vm[opt2].defaulted()) {
cout << "Conflicting options '" << opt1 << "' and '" << opt2 << "'." << endl;
return CONFLICTING_OPTIONS;
} else {
return SUCCESS;
}
}
int parse(int argc, char **argv, Params* params) {
int returnvalue = -1;
po::options_description desc{"Options"};
try
{
desc.add_options()
("help", "produce help message")
("peer", po::value<int>(¶ms->peers), "number of peers")
("f", po::value<int>(¶ms->fanOut),"fan-out of peers")
("graph", po::value<int>(¶ms->graphType), "graph type: 1 geometric 2 Barabasi-Albert 3 Erdos-Renyi 4 regular")
("ct", po::value<double>(¶ms->convThreshold), "convergence tolerance")
("cr", po::value<int>(¶ms->convLimit), "number of consecutive rounds in which convergence must be satisfied")
("out", po::value<string>(¶ms->outputFilename), "output filename, if specified a file with this name containing all of the peers stats is written")
("re", po::value<int>(¶ms->roundsToExecute), "number of rounds to execute")
("alpha", po::value<double>(¶ms->alpha), "accuracy for DDSketch")
("off", po::value<int>(¶ms->offset), "offset for DDSketch")
("bl", po::value<int>(¶ms->binLimit), "bins limit for DDSketch")
("dataset", po::value<string>(¶ms->datasetName), "input (only one can be selected): dataset name")
("normal",po::value<vector<double>>()->multitoken()->zero_tokens(), "input (only one can be selected): normal distribution, required mean and stdev: --normal mean stddev")
("exponential",po::value<double>(¶ms->lambda), "input (only one can be selected): exponential distribution, required lambda: --exponential lambda")
("uniform",po::value<vector<double>>()->multitoken()->zero_tokens(), "input (only one can be selected): uniform real distribution, required a and b: --normal a b")
("seed",po::value<double>(¶ms->seed), "random number generator seed")
("q",po::value<vector<double>>()->multitoken()->zero_tokens(), "quantile list, value between [0,1]");
po::variables_map vm;
po::command_line_parser parser{argc, argv};
parser.options(desc).allow_unregistered().style(po::command_line_style::allow_long | po::command_line_style::long_allow_next);
po::parsed_options parsed_options = parser.run();
store(parsed_options, vm);
notify(vm);
if (vm.count("help")) {
std::cout << desc << '\n';
return EXIT;
}
if (vm.count("out"))
params->outputOnFile = true;
returnvalue = conflicting_options(vm, "normal", "exponential");
if (returnvalue) {
printError(CONFLICTING_OPTIONS,__FUNCTION__);
return returnvalue;
}
returnvalue = conflicting_options(vm, "normal", "uniform");
if (returnvalue) {
printError(CONFLICTING_OPTIONS,__FUNCTION__);
return returnvalue;
}
returnvalue = conflicting_options(vm, "exponential", "uniform");
if (returnvalue) {
printError(CONFLICTING_OPTIONS,__FUNCTION__);
return returnvalue;
}
returnvalue = conflicting_options(vm, "dataset", "normal");
if (returnvalue) {
printError(CONFLICTING_OPTIONS,__FUNCTION__);
return returnvalue;
}
returnvalue = conflicting_options(vm, "dataset", "exponential");
if (returnvalue) {
printError(CONFLICTING_OPTIONS,__FUNCTION__);
return returnvalue;
}
returnvalue = conflicting_options(vm, "dataset", "uniform");
if (returnvalue) {
printError(CONFLICTING_OPTIONS,__FUNCTION__);
return returnvalue;
}
if (vm.count("dataset")) {
int returnValue = getDatasetSize(params->datasetName, params->ni);
if (returnValue) {
return returnValue;
}
}
if (vm.count("normal")) {
params->distrType = 1;
vector<double> opt = vm["normal"].as<vector<double>>();
if (opt.size() == 2) {
params->mean = opt[0];
params->stddev = opt[1];
} else {
cerr << "missing normal distribution parameter";
return USAGE_ERROR;
}
}
if (vm.count("exponential")) {
params->distrType = 2;
}
if (vm.count("uniform")) {
params->distrType = 3;
vector<double> opt = vm["uniform"].as<vector<double>>();
if (opt.size() == 2) {
params->a = opt[0];
params->b = opt[1];
} else {
cerr << "missing uniform real distribution parameter";
return USAGE_ERROR;
}
}
if (vm.count("q")) {
params->q.clear();
vector<double> opt = vm["q"].as<vector<double>>();
for (double q: opt) {
if (q < 0 || q > 1 ) {
printError(QUANTILE_ERROR, __FUNCTION__);
return QUANTILE_ERROR;
} else {
params->q.insert(params->q.end(), q);
}
}
}
}
catch (const po::error &ex)
{
std::cerr << ex.what() << '\n';
std::cout << desc << '\n';
return USAGE_ERROR;
}
return SUCCESS;
}
void startTheClock(){
t1 = high_resolution_clock::now();
}
double stopTheClock() {
t2 = high_resolution_clock::now();
duration<double> time_span = duration_cast<duration<double>>(t2 - t1);
return time_span.count();
}
int getDatasetSize(const string &nameFile, long &rows) {
rows = 0;
ifstream inputFile(nameFile);
string line;
if(inputFile.is_open()){
while (getline(inputFile, line))
rows++;
} else {
printError(FILE_ERROR, __FUNCTION__);
return FILE_ERROR;
}
return SUCCESS;
}
int loadDataset(const string &nameFile, double *dataset) {
if (!dataset) {
printError(NULL_POINTER_ERROR, __FUNCTION__);
return NULL_POINTER_ERROR;
}
ifstream inputFile(nameFile);
string line;
int row = 0;
if(inputFile.is_open()){
while (getline(inputFile, line)) {
try {
dataset[row] = stod(line);
}
catch (int e) {
printError(FILE_ERROR, __FUNCTION__);
inputFile.close();
return FILE_ERROR;
}
row++;
}
} else {
printError(FILE_ERROR, __FUNCTION__);
return FILE_ERROR;
}
inputFile.close();
return SUCCESS;
}
int generateDataset(Params* params, double *dataset) {
if (!params) {
printError(PARAM_ERROR, __FUNCTION__);
return PARAM_ERROR;
}
if (!dataset) {
printError(NULL_POINTER_ERROR, __FUNCTION__);
return NULL_POINTER_ERROR;
}
default_random_engine generator;
if (params->seed) {
generator.seed(params->seed);
}
if (params->distrType == 1 ) {
normal_distribution<double> normal(params->mean,params->stddev);
for (long i = 0; i < params->ni; i++) {
dataset[i] = normal(generator);
}
} else if (params->distrType == 2 ) {
exponential_distribution<double> exponential(params->lambda);
for (long i = 0; i < params->ni; i++) {
dataset[i] = exponential(generator);
}
} else if (params->distrType == 3 ) {
uniform_real_distribution<double> uniform_real(params->a, params->b);
for (long i = 0; i < params->ni; i++) {
dataset[i] = uniform_real(generator);
}
}
return SUCCESS;
}
int testQuantile(DDS_type *dds, double* stream, long numberElements, stringstream &result, const vector<double>& quantileList) {
result << "\nTest quantiles with alpha=" << dds->alpha << endl << endl;
if(!dds){
printError(SKETCH_ERROR, __FUNCTION__);
return SKETCH_ERROR;
}
if (!stream) {
printError(NULL_POINTER_ERROR, __FUNCTION__);
return NULL_POINTER_ERROR;
}
int returnValue = -1;
result << string(60, '-') << endl
<< "|" << setw(10) << "quantile" << "|" << setw(15) << "estimate" << "|" << setw(15) << "real" << "|" << setw(15)<< "error" << "|" << endl
<< string(60, '-') << endl;
for(double q : quantileList) {
int idx = floor(1+q*double(numberElements - 1));
// determine the correct answer
// i.e., the number stored at the index (idx-1) in the sorted permutation of the vector
// note that we are not sorting the vector, we are using the quickselect() algorithm
// which in C++ is available as std::nth_element
nth_element(stream, stream + (idx-1), stream + numberElements);
double quantile;
returnValue = DDS_GetQuantile(dds, q, quantile);
if (returnValue < 0 ) {
return returnValue;
}
double error = abs((quantile-stream[idx-1])/stream[idx-1]);
result << "|" << setw(10) << q<< "|" << setw(15) << quantile << "|" << setw(15) << stream[idx-1] << "|" << setw(15)<< error << "|" << endl;
}
result << string(60, '-') << endl;
return returnValue;
}
string printParameters(Params* params){
stringstream parameters;
if (!params->datasetName.empty()) {
parameters << "dataset = " << params->datasetName << endl;
} else if (params->distrType == 1 ) {
parameters << "distribution type = normal with mean = " << params->mean << " and stddev = " << params->stddev << endl;
} else if (params->distrType == 2 ) {
parameters << "distribution type = exponential with lambda = " << params->lambda<< endl;
} else if (params->distrType == 3 ) {
parameters << "distribution type = uniform real with a = " << params->a << " and b = " << params->b << endl;
}
parameters << "nยฐ points = " << params->ni << endl
<< "graph type = " << printGraphType(params->graphType) << endl
<< "peers = " << params->peers << endl
<< "fan-out = " << params->fanOut << endl
<< "local convergence tolerance = " << params->convThreshold << endl
<< "number of consecutive rounds in which a peer must locally converge = " << params->convLimit << endl
<< "alpha = " << params->alpha << endl
<< "offset = " << params->offset << endl
<< "binLimit = " << params->binLimit << endl;
return parameters.str();
} |
51c3906ee2d10bc101e9da990d9b8be8c8167aba | 9bee44003d0341bf19fb7c3b2b49380fb8761dd0 | /src/main_6_1.cpp | ccd617b9be302197390b43abe56c27ada016cac7 | [] | no_license | JN426206/Projekt-GRK | 3005e7c16775bac037cc0836337cbbf2579ee0ad | 53de138c53851a5c8c5c6842d9fe9ef61331573a | refs/heads/master | 2020-03-21T00:24:39.422522 | 2018-06-19T20:13:20 | 2018-06-19T20:13:20 | 137,891,908 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,838 | cpp | main_6_1.cpp | #include "glew.h"
#include "freeglut.h"
#include "glm.hpp"
#include "ext.hpp"
#include <iostream>
#include <cmath>
#include "Shader_Loader.h"
#include "Render_Utils.h"
#include "Camera.h"
#include "Texture.h"
GLuint programColor; // Identyfikator shadera uzywanego do rysowania
GLuint programTexture; // Identyfikator shadera uzywanego do rysowania
GLuint mainTexture; // Identyfikator shadera uzywanego do rysowania
Core::Shader_Loader shaderLoader;
float appLoadingTime;
obj::Model sharkModel;
obj::Model fishModel;
obj::Model rockModel;
obj::Model backgModel;
float cameraAngle = 0;
glm::vec3 cameraPos = glm::vec3(-5, 0, 0);
glm::vec3 cameraDir;
glm::mat4 cameraMatrix, perspectiveMatrix;
glm::vec3 lightDir = glm::normalize(glm::vec3(1.0f, -0.9f, -1.0f));
GLuint textureFish;
GLuint textureRock;
GLuint waterTexture;
GLuint sharkTexture;
static const int NUM_FISHES = 40;
glm::mat4 fish[NUM_FISHES];
void keyboard(unsigned char key, int x, int y)
{
float angleSpeed = 0.1f;
float moveSpeed = 0.1f;
switch(key)
{
case 'z': cameraAngle -= angleSpeed; break;
case 'x': cameraAngle += angleSpeed; break;
case 'w': cameraPos += cameraDir * moveSpeed; break;
case 's': cameraPos -= cameraDir * moveSpeed; break;
case 'd': cameraPos += glm::cross(cameraDir, glm::vec3(0,1,0)) * moveSpeed; break;
case 'a': cameraPos -= glm::cross(cameraDir, glm::vec3(0,1,0)) * moveSpeed; break;
}
}
glm::mat4 createCameraMatrix()
{
// Skoro chcemy patrzec na obiekty lezace w poczatku ukladu wspolrzednych, wektor patrzenia "fwd" powinien byc caly czas przeciwny do wektora pozycji kamery.
// Wektor "up" jest skierowany do gory.
// Obliczanie kierunku patrzenia kamery (w plaszczyznie x-z) przy uzyciu zmiennej cameraAngle kontrolowanej przez klawisze.
cameraDir = glm::vec3(cosf(cameraAngle), 0.0f, sinf(cameraAngle)); //fwd
glm::vec3 up = glm::vec3(0,1,0);
return Core::createViewMatrix(cameraPos, cameraDir, up);
}
//Funkcja umoลผliwia rysowanie obiektรณw oteksturowanych
//drawObjectTextureMain shader bez ลwitลa
void drawObjectTextureMain(obj::Model * model, glm::mat4 modelMatrix, GLuint textureID)
{
GLuint program = mainTexture;
// Aktywowanie shadera
glUseProgram(program);
//Obliczanie oลwietlenia obiektu, natฤลผenia ลwiatลa za pomocฤ
danego shadera
//Odwoลanie do zmiennej "sampler2dtype" w shader_tex1.frag
//Ustawianie zmiennej sampler2D na wczytanฤ
wczeลniej teksturฤ przekazanฤ
jako parametr
Core::SetActiveTexture(textureID, "sampler2dtype", 1, 0);
glUniform3f(glGetUniformLocation(program, "lightDir"), lightDir.x, lightDir.y, lightDir.z);
// "transformation" jest automatycznie inicjalizowane macierza jednostkowa 4 x 4
glm::mat4 transformation = perspectiveMatrix * cameraMatrix * modelMatrix;
// Polecenie glUniformMatrix4fv wysyla zmienna "transformation" do GPU i przypisuje ja do zmiennej typu mat4 o nazwie "modelViewProjectionMatrix" w shaderze.
// Shader uzyje tej macierzy do transformacji wierzcholkow podczas rysowania.
glUniformMatrix4fv(glGetUniformLocation(program, "modelViewProjectionMatrix"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
Core::DrawModel(model);
// Wylaczenie shadera
glUseProgram(0);
}
void drawObjectTexture(obj::Model * model, glm::mat4 modelMatrix, GLuint textureId)
{
GLuint program = programTexture;
glUseProgram(program);
Core::SetActiveTexture(textureId, "textureSampler", 1, 0);
glUniform3f(glGetUniformLocation(program, "lightDir"), lightDir.x, lightDir.y, lightDir.z);
//Core::SetActiveTexture(textureId, "textureSampler", program, 0);
glm::mat4 transformation = perspectiveMatrix * cameraMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(program, "modelViewProjectionMatrix"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
Core::DrawModel(model);
glUseProgram(0);
}
void renderScene()
{
//Tworzenie macierzy perspektywy za pomoca createPerspectiveMatrix(), uzyskujemy obraz 3D
// Aktualizacja macierzy widoku i rzutowania. Macierze sa przechowywane w zmiennych globalnych, bo uzywa ich funkcja drawObject.
// Jest to mozliwe dzieki temu, ze macierze widoku i rzutowania sa takie same dla wszystkich obiektow!)
cameraMatrix = createCameraMatrix();
perspectiveMatrix = Core::createPerspectiveMatrix();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
// Zmienna "time" po wykonaniu tej linii kodu zawiera liczbe sekund od uruchomienia programu
float time = glutGet(GLUT_ELAPSED_TIME) / 1000.0f - appLoadingTime;
//"Przyczepianie" modelu rekina do kamery, uzaleznienie jego macierzy modelu od pozycji i orientacji kamery tak, aby wygladalo jakby uลผytkownik poruszal sie drapieลผnikiem.
//Model w trakcie poruszania (dzieki zmianie zmiennych pozycji kamery) animuje ruch poruszania siฤ.
glm::mat4 sharkModelMatrix = glm::translate(cameraPos + cameraDir * 1.9f + glm::vec3(0,-0.75f,0)) * glm::rotate(-cameraAngle + glm::radians(90.0f), glm::vec3(0,1,0)) * glm::scale(glm::vec3(0.01f));
sharkModelMatrix *= glm::rotate(sin(cameraPos[0] + cameraPos[1] + cameraPos[2] + cameraAngle) / 4, glm::vec3(0, 1, 0));
drawObjectTexture(&sharkModel, sharkModelMatrix, sharkTexture);
//drawObjectColor(&sharkModel, sharkModelMatrix, glm::vec3(0.6f));
glm::mat4 rotation;
glm::mat4 fishb[NUM_FISHES];
//Ustalenie macierzy rotacji
rotation[0][0] = cos(time);
rotation[2][0] = sin(time);
rotation[0][2] = -sin(time);
rotation[2][2] = cos(time);
for (int i = 0; i < NUM_FISHES; ++i)
{
fishb[i][3][0] = fish[i][3][0] * sin(time);
fishb[i][3][2] = fish[i][3][2] * cos(time);
drawObjectTexture(&fishModel, glm::translate(glm::vec3(fish[i][0][0], fish[i][0][1], fish[i][0][2]))*fishb[i]*rotation*glm::rotate((sin(time * 10) / 4), glm::vec3(0, 1, 0))*glm::scale(glm::vec3(0.01f)), textureFish);
}
drawObjectTextureMain(&backgModel, glm::translate(glm::vec3(0, 0, 0))* glm::scale(glm::vec3(70.0f)), waterTexture);
drawObjectTexture(&rockModel, glm::translate(glm::vec3(3, -2, 2)) * glm::scale(glm::vec3(0.005f)), textureRock);
// Nalezy wywolac na koncu rysowania aktualnej klatki obrazu
glutSwapBuffers();
}
void init()
{
glEnable(GL_DEPTH_TEST);
// Wektor normalny wierzcholka dostepny jest w vertex shaderze (plik z rozszerzeniem .vert). Kolor powierzchni (piksela) ustala sie jednak we fragment shaderze (.frag).
programColor = shaderLoader.CreateProgram("shaders/shader_color.vert", "shaders/shader_color.frag");
programTexture = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
mainTexture = shaderLoader.CreateProgram("shaders/shader_tex1.vert", "shaders/shader_tex1.frag");
//Wczytanie modeli z plikรณw
fishModel = obj::loadModelFromFile("models/fish.obj");
rockModel = obj::loadModelFromFile("models/rocks.obj");
sharkModel = obj::loadModelFromFile("models/shark.obj");
backgModel = obj::loadModelFromFile("models/backg.obj");
//Wczytywanie tekstur z plikรณw
textureFish = Core::LoadTexture("textures/fish.png");
textureRock = Core::LoadTexture("textures/rock.png");
waterTexture = Core::LoadTexture("textures/water.png");
sharkTexture = Core::LoadTexture("textures/shark.png");
//Generowanie losowych pozycji dla pลywajฤ
cych rybek
for (int i = 0; i < NUM_FISHES; ++i)
{
fish[i][0][0] = ((rand() % 3) + 1);
fish[i][0][1] = ((rand() % 18) % 3);
fish[i][0][2] = ((rand() % 3) + 1);
fish[i][3][0] = ((rand() % 3) + 6);
fish[i][3][2] = ((rand() % 3) + 6);
}
//Zapisanie czasu zaลadowania siฤ programu
appLoadingTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f;
}
void shutdown()
{
//Usuwanie zaลadowanych shaderรณw z pamiฤci
shaderLoader.DeleteProgram(programColor);
shaderLoader.DeleteProgram(programTexture);
shaderLoader.DeleteProgram(mainTexture);
}
void idle()
{
// Ta funkcja informuje freegluta, ze nalezy odzwiezyc zawartosc okna przy uzyciu funkcji podanej w glutDisplayFunc
glutPostRedisplay();
}
int main(int argc, char ** argv)
{
// Stworzenie okna przy uลผyciu biblioteki freeglut
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(200, 200);
glutInitWindowSize(600, 600);
glutCreateWindow("Podwodny raj");
// Inicjalizacja rozszerzen OpenGL
glewInit();
// Inicjalizacja programu (ladowanie shaderow, tekstur itp)
init();
glutKeyboardFunc(keyboard);
// Poinformowanie freegluta jaka funkcja bedzie sluzyc do odswiezania obrazu
glutDisplayFunc(renderScene);
// Poinformowanie freegluta jaka funkcja bedzie wywolywana w glownej petli programu
glutIdleFunc(idle);
// Uruchomienie glownej petli
glutMainLoop();
// Sprzatanie (usuwanie shaderow itp)
shutdown();
return 0;
}
|
6aacb6b149d4b433b1d50a037ad9aabb851dc921 | f1ee65fbe1ffc43c2aac45e41515f1987eb534a4 | /src/net/third_party/quiche/src/quiche/http2/hpack/decoder/hpack_decoder.h | 9e4b68bc927d7e4a5fd621ff02650656cab5b7a6 | [
"BSD-3-Clause"
] | permissive | klzgrad/naiveproxy | 6e0d206b6f065b9311d1e12b363109f2d35cc058 | 8ef1cecadfd4e2b5d57e7ea2fa42d05717e51c2e | refs/heads/master | 2023-08-20T22:42:12.511091 | 2023-06-04T03:54:34 | 2023-08-16T23:30:19 | 119,178,893 | 5,710 | 976 | BSD-3-Clause | 2023-08-05T10:59:59 | 2018-01-27T16:02:33 | C++ | UTF-8 | C++ | false | false | 5,774 | h | hpack_decoder.h | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef QUICHE_HTTP2_HPACK_DECODER_HPACK_DECODER_H_
#define QUICHE_HTTP2_HPACK_DECODER_HPACK_DECODER_H_
// Decodes HPACK blocks, calls an HpackDecoderListener with the decoded header
// entries. Also notifies the listener of errors and of the boundaries of the
// HPACK blocks.
// TODO(jamessynge): Add feature allowing an HpackEntryDecoderListener
// sub-class (and possibly others) to be passed in for counting events,
// so that deciding whether to count is not done by having lots of if
// statements, but instead by inserting an indirection only when needed.
// TODO(jamessynge): Consider whether to return false from methods below
// when an error has been previously detected. It protects calling code
// from its failure to pay attention to previous errors, but should we
// spend time to do that?
#include <stddef.h>
#include <cstdint>
#include "quiche/http2/decoder/decode_buffer.h"
#include "quiche/http2/hpack/decoder/hpack_block_decoder.h"
#include "quiche/http2/hpack/decoder/hpack_decoder_listener.h"
#include "quiche/http2/hpack/decoder/hpack_decoder_state.h"
#include "quiche/http2/hpack/decoder/hpack_decoder_tables.h"
#include "quiche/http2/hpack/decoder/hpack_decoding_error.h"
#include "quiche/http2/hpack/decoder/hpack_whole_entry_buffer.h"
#include "quiche/common/platform/api/quiche_export.h"
namespace http2 {
namespace test {
class HpackDecoderPeer;
} // namespace test
class QUICHE_EXPORT HpackDecoder {
public:
HpackDecoder(HpackDecoderListener* listener, size_t max_string_size);
virtual ~HpackDecoder();
HpackDecoder(const HpackDecoder&) = delete;
HpackDecoder& operator=(const HpackDecoder&) = delete;
// max_string_size specifies the maximum size of an on-the-wire string (name
// or value, plain or Huffman encoded) that will be accepted. See sections
// 5.1 and 5.2 of RFC 7541. This is a defense against OOM attacks; HTTP/2
// allows a decoder to enforce any limit of the size of the header lists
// that it is willing to decode, including less than the MAX_HEADER_LIST_SIZE
// setting, a setting that is initially unlimited. For example, we might
// choose to send a MAX_HEADER_LIST_SIZE of 64KB, and to use that same value
// as the upper bound for individual strings.
void set_max_string_size_bytes(size_t max_string_size_bytes);
// ApplyHeaderTableSizeSetting notifies this object that this endpoint has
// received a SETTINGS ACK frame acknowledging an earlier SETTINGS frame from
// this endpoint specifying a new value for SETTINGS_HEADER_TABLE_SIZE (the
// maximum size of the dynamic table that this endpoint will use to decode
// HPACK blocks).
// Because a SETTINGS frame can contain SETTINGS_HEADER_TABLE_SIZE values,
// the caller must keep track of those multiple changes, and make
// corresponding calls to this method. In particular, a call must be made
// with the lowest value acknowledged by the peer, and a call must be made
// with the final value acknowledged, in that order; additional calls may
// be made if additional values were sent. These calls must be made between
// decoding the SETTINGS ACK, and before the next HPACK block is decoded.
void ApplyHeaderTableSizeSetting(uint32_t max_header_table_size);
// Returns the most recently applied value of SETTINGS_HEADER_TABLE_SIZE.
size_t GetCurrentHeaderTableSizeSetting() const {
return decoder_state_.GetCurrentHeaderTableSizeSetting();
}
// Prepares the decoder for decoding a new HPACK block, and announces this to
// its listener. Returns true if OK to continue with decoding, false if an
// error has been detected, which for StartDecodingBlock means the error was
// detected while decoding a previous HPACK block.
bool StartDecodingBlock();
// Decodes a fragment (some or all of the remainder) of an HPACK block,
// reporting header entries (name & value pairs) that it completely decodes
// in the process to the listener. Returns true successfully decoded, false if
// an error has been detected, either during decoding of the fragment, or
// prior to this call.
bool DecodeFragment(DecodeBuffer* db);
// Completes the process of decoding an HPACK block: if the HPACK block was
// properly terminated, announces the end of the header list to the listener
// and returns true; else returns false.
bool EndDecodingBlock();
// If no error has been detected so far, query |decoder_state_| for errors and
// set |error_| if necessary. Returns true if an error has ever been
// detected.
bool DetectError();
size_t GetDynamicTableSize() const {
return decoder_state_.GetDynamicTableSize();
}
// Error code if an error has occurred, HpackDecodingError::kOk otherwise.
HpackDecodingError error() const { return error_; }
std::string detailed_error() const { return detailed_error_; }
private:
friend class test::HpackDecoderPeer;
// Reports an error to the listener IF this is the first error detected.
void ReportError(HpackDecodingError error, std::string detailed_error);
// The decompressor state, as defined by HPACK (i.e. the static and dynamic
// tables).
HpackDecoderState decoder_state_;
// Assembles the various parts of a header entry into whole entries.
HpackWholeEntryBuffer entry_buffer_;
// The decoder of HPACK blocks into entry parts, passed to entry_buffer_.
HpackBlockDecoder block_decoder_;
// Error code if an error has occurred, HpackDecodingError::kOk otherwise.
HpackDecodingError error_;
std::string detailed_error_;
};
} // namespace http2
#endif // QUICHE_HTTP2_HPACK_DECODER_HPACK_DECODER_H_
|
6ff164eb5133aa7461f35f8f215e3d0ccd7297cb | b776212295f64b4734440acae88b098918ce8a69 | /uva/uva167.cpp | d60fc01881373416d0e909fb558767ba8b1570ce | [] | no_license | tommy5198/acm | 7635147f18e2e1c54fc87813cccd14fddcac5897 | d65cef14286141684013c3425cca7ad3250867de | refs/heads/master | 2016-08-06T00:53:13.140150 | 2015-05-27T10:52:49 | 2015-05-27T10:52:49 | 7,730,894 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 920 | cpp | uva167.cpp | //back tracking
#include<cstdio>
int sum;
int num[8][8];
bool chess[8][8];
void queen(int tsum, int d){
if(d == 8){
sum = sum > tsum ? sum : tsum;
return ;
}
for(int i=0; i<8; i++){
int j, x;
for(j=d-1, x=1; j>=0; j--, x++){
if(chess[j][i])
break;
if(i+x < 8 && chess[j][i+x])
break;
if(i-x >= 0 && chess[j][i-x])
break;
}
if(j == -1){
chess[d][i] = true;
queen(tsum+num[d][i], d+1);
chess[d][i] = false;
}
}
}
int main(){
int k;
scanf("%d", &k);
while(k--){
sum = -1;
for(int i=0; i<8; i++)
for(int j=0; j<8; j++){
scanf("%d", &num[i][j]);
chess[i][j] = false;
}
queen(0, 0);
printf("%5d\n", sum);
}
return 0;
}
|
ab8ed6b7c761f3cd3e9cd69cf68568a34430f256 | b8c5c4f8ab1d196bc4f2ed17d6a5cbaa4bf77bf4 | /model/internal/UnitImpl.h | 8831e767112391baa45f6160b0e682fcf278786f | [] | no_license | Verdagon/battlefieldrl | e84eb25b3baa02fcf2886e54b217083e0035cfa9 | f0900626084750a5eb7a85e20468036e2239d00b | refs/heads/master | 2020-04-01T21:13:39.067115 | 2014-11-03T02:09:00 | 2014-11-03T02:09:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 457 | h | UnitImpl.h | #pragma once
#include "../Unit.h"
#include "../../utils.h"
class UnitImpl : public virtual Unit {
Coord mLocation;
public:
UnitImpl() :
mLocation(0, 0) {
}
virtual Coord location() const override {
return mLocation;
}
void setLocation(Coord location) {
mLocation = location;
}
};
class PlayerImpl : public virtual UnitImpl, public virtual Player {
};
class GoblinImpl : public virtual UnitImpl, public virtual Goblin {
};
|
4bec36ab63741b45af0674442ffd7f8c57c06b4b | afaef754bd94eff82824fbf8ede2457fbe027556 | /Reactor/src/tests/TcpClient1_test.cpp | f32941a1d4f9b4ec589b59aae522c2e71240123c | [] | no_license | baiqiubai/baiqiubai | bd88eae3f5f440c2f9eee2824f6d91c8f87380e8 | cc051016b922d37fa9c13d73841ae93a36940e7c | refs/heads/master | 2023-06-19T04:58:49.918292 | 2021-07-17T08:41:05 | 2021-07-17T08:41:05 | 355,005,752 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 803 | cpp | TcpClient1_test.cpp |
#include "CurrentThread.h"
#include "EventLoop.h"
#include "InetAddress.h"
#include "Logger.h"
#include "TcpClient.h"
using namespace net;
using namespace base;
EventLoop *g_loop;
TcpClient *g_client;
void QuitLoop()
{
LOG_INFO << "Quit TcpClient";
g_client->stop();
}
void debug() { Logger::setLogLevel(Logger::LogLevel::DEBUG); }
int main(int argc, char **argv)
{
{
InetAddress address(argv[1], atoi(argv[2]));
EventLoop loop;
g_loop = &loop;
TcpClient client(&loop, address);
g_client = &client;
if (argc > 3) debug();
loop.runAfter(std::bind(&QuitLoop), 1);
loop.runAfter(std::bind(&EventLoop::stop, &loop), 2);
client.start();
base::CurrentThread::sleepUsec(100 * 1000);
loop.loop();
}
}
|
9cd04a30327c4ae7a619cfbc55de10ba3bc7d699 | 6d523e0652d59347fa9ce7a7ec09b62219bac827 | /15686-์นํจ ๋ฐฐ๋ฌ.cpp | 5edb12ff57a88bd2aac0593f3e166567440bffec | [] | no_license | rollrolli/2019-1-Algorithm-Study | 7866ac75f0cce6a6e9ed187ec232ddddb5e89245 | 6314c95c88db2ecdeb265f8584a43bb124e5fc34 | refs/heads/master | 2020-05-04T22:34:20.069751 | 2019-05-29T05:06:40 | 2019-05-29T05:06:40 | 179,511,715 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 1,715 | cpp | 15686-์นํจ ๋ฐฐ๋ฌ.cpp | #include <iostream>
#include <queue>
#include <algorithm>
#include <string.h>
using namespace std;
int city[51][51];
int visited[51][51] = { 0, }; // ๋งค ์์นญ๋ง๋ค ์ด๊ธฐํ ํ์
int comb[15] = { 0, };
typedef struct loc {
int r;
int s;
};
loc store[15];
loc house[101];
int store_num = 0; // ์นํจ์ง ๊ฐ์
int house_num = 0; // ๊ฐ์ ์ง ๊ฐ์
int N, M;
queue<loc> house_q;
queue<loc> q;
int getDistance(loc a, loc b) {
return (a.r - b.r >= 0 ? a.r - b.r : b.r - a.r) +
(a.s - b.s >= 0 ? a.s - b.s : b.s - a.s);
}
int getChickenDistance(int* comb) {
int min = 100000;
int sum = 0;
int temp = 0;
for (int i = 0; i < house_num; i++) {
min = 100000;
for (int j = 0; j < store_num; j++) {
if (comb[j] == 1) {
temp = getDistance(house[i], store[j]);
if (min > temp) min = temp;
}
}
sum += min;
}
return sum;
}
int main() {
cin >> N >> M;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cin >> city[i][j];
if (city[i][j] == 2) {
store[store_num].r = i;
store[store_num++].s = j;
}
else if (city[i][j] == 1) {
house[house_num].r = i;
house[house_num++].s = j;
}
}
}
//////////////////////////////////////////////////////
for (int i = store_num - 1; i >= 0 ; i--) {
if (i < M) comb[i] = 1;
else comb[i] = 0;
}
sort(comb, comb + store_num);
//////////////////////////////////////////////////////
// ์กฐํฉ ์ฌ์ฉ์ ์ํ ๋ฐ์์
int min = 10000;
int temp = 0;
do {
temp = getChickenDistance(comb);
// ์๋ก์ด ์นํจ์ง ์กฐํฉ์ ์นํจ ๊ฑฐ๋ฆฌ ๊ตฌํ๊ธฐ
if (min > temp) min = temp;
} while (next_permutation(comb, comb + store_num));
cout << min;
system("pause");
} |
e65ba08b418f6f6c49d6fb8ce689e7dc6c5813b8 | b3960efcf7b3d22b1f175e642e0a672166d88eb1 | /Opocio.h | 6cb42b22abf98707140204f155789cec4f22673c | [] | no_license | LucaPizzagalli/chemotaxis-pathfinding | 170c03e67276f4a116310e4c12cedc13c11a8630 | 462bed4192f22eb2f1fe1a4330d7b8aed64f0557 | refs/heads/master | 2020-05-03T04:27:42.872482 | 2019-03-29T16:32:05 | 2019-03-29T16:32:05 | 178,422,128 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,600 | h | Opocio.h | #define attack_opocio -1
#define eat_food 0
#define eat_opocio 1
#define find_cantiere 2
#define find_pietra 3
#define ask_pietra 4
#define ask_cantiere 5
#define N_priority 6
class Opocio : public Oggetto
{
protected:
double dim, speed;
int energia;
int vita;
int carne;
int gravidanza;
float cantiere_proximity;
float pietra_proximity;
int color[3];
double posx, posy;
double velx, vely, vel_angle;
int left_steps;
//bool extra_step;
float last_smell;
int esitazioni;
Oggetto *calpestato;
Object_type carried;
Oggetto *enemy;
Object_type priority[N_priority];
Mappa *mappa;
public:
static int color_type;
Opocio(Mappa *in_mappa, float in_posx, float in_posy);
Object_type get_type();
void generate_meta(int coherence);
Oggetto* live();
int what_nearby(Oggetto **vicino);
void injured(Oggetto *in_enemy, int damage);
int lose_weight(int morso);
void bite(Oggetto *prey);
Oggetto* move();
void update_information(float other_cantiere, float other_pietra);
bool is_searching_cantiere();
bool is_searching_pietra();
float get_cantiere_prox();
float get_pietra_prox();
void set_cantiere_prox(float in_cantiere_proximity);
void set_pietra_prox(float in_pietra_proximity);
void draw_1(unsigned char screen_color[SCREEN_HEIGHT][SCREEN_WIDTH][4], int player_posx, int player_posy);
void draw(unsigned char screen_color[SCREEN_HEIGHT][SCREEN_WIDTH][4], float zoom_level, float player_posx, float player_posy);
void print();
virtual ~Opocio();
};
|
533aabc655759cb95f5499f1d3c1a836ce2ba74e | 6ecbf084f558b37f0cee51c7226c1e116b5aa7bf | /SIR/.SIR/build_openmp_sse/src/bi/math/constant.hpp | 2a5ee50a9e01d72a400a4ba9c737eafcac221e59 | [] | no_license | reichlab/bayesian_non_parametric | 364b12ad07b09e9a4386572bd47c709ad7629497 | c8d7eb7493addb919b8f7159768dc732ce1a1f35 | refs/heads/master | 2021-01-01T06:43:10.176687 | 2018-03-25T14:33:32 | 2018-03-25T14:33:32 | 97,492,688 | 2 | 0 | null | 2018-01-02T15:23:21 | 2017-07-17T15:38:01 | Python | UTF-8 | C++ | false | false | 1,003 | hpp | constant.hpp | /**
* @file
*
* Common \f$\pi\f$ pre-calculations using big-decimal. We should note that,
* actually, these are no more accurate than using double precision, but they
* do at least ensure decent accuracy before casting to single precision.
*
* @author Lawrence Murray <lawrence.murray@csiro.au>
* $Rev$
* $Date$
*/
#ifndef BI_MATH_CONSTANT_HPP
#define BI_MATH_CONSTANT_HPP
#include <limits>
/**
* @def BI_PI
*
* Value of \f$\pi\f$
*/
#define BI_PI 3.1415926535897932384626433832795
/**
* @def BI_TWO_PI
*
* Value of \f$2\pi\f$
*/
#define BI_TWO_PI 6.2831853071795864769252867665590
/**
* @def BI_SQRT_TWO_PI
*
* Value of \f$\sqrt{2\pi}\f$
*/
#define BI_SQRT_TWO_PI 2.5066282746310005024157652848110
/**
* @def BI_HALF_LOG_TWO_PI
*
* Value of \f$\frac{1}{2}\ln 2\pi = \ln \sqrt{2\pi}\f$
*/
#define BI_HALF_LOG_TWO_PI 0.91893853320467274178032973640562
/**
* @def BI_INF
*
* Value of inf for real type.
*/
#define BI_INF std::numeric_limits<double>::infinity()
#endif
|
311af8877185200d278104ff18c3f00c3669fd48 | ce815e4a0fae69b6e20bef664f3380063a9a4286 | /include/nn/gfx/detail/bufferimpl.h | 42ae4b14842a5a0b8584a213d3d41aef3387d709 | [
"MIT"
] | permissive | CrustySean/skyline | a8719c34696b18a0afffdefdcc24f1e592351e74 | 8037c94df70cb59c8e8fb7c5723bfd33bbe6710e | refs/heads/master | 2023-02-06T13:56:59.809694 | 2020-12-03T17:56:47 | 2020-12-03T17:56:47 | 325,289,820 | 1 | 0 | MIT | 2020-12-29T13:09:28 | 2020-12-29T13:09:28 | null | UTF-8 | C++ | false | false | 1,447 | h | bufferimpl.h | /**
* @file bufferimpl.h
* @brief Buffer implementation for GFX.
*/
#pragma once
#include "nn/gfx/api.h"
#include "nn/gfx/buffer.h"
namespace nn {
namespace gfx {
class GpuAddress;
namespace detail {
template <typename T>
class BufferImpl {
public:
BufferImpl();
~BufferImpl();
void Initialize(
nn::gfx::detail::DeviceImpl<nn::gfx::ApiVariation<nn::gfx::ApiType<4>, nn::gfx::ApiVersion<8>>>*,
nn::gfx::BufferInfo const&,
nn::gfx::detail::MemoryPoolImpl<nn::gfx::ApiVariation<nn::gfx::ApiType<4>, nn::gfx::ApiVersion<8>>>*,
s64, u64);
void Finalize(
nn::gfx::detail::DeviceImpl<nn::gfx::ApiVariation<nn::gfx::ApiType<4>, nn::gfx::ApiVersion<8>>>*);
void* Map() const;
void Unmap() const;
void FlushMappedRange(s64, u64) const;
void InvalidateMappedRange(s64, u64) const;
void GetGpuAddress(nn::gfx::GpuAddress*) const;
T* mBuff; // _0
};
template <typename T>
class CommandBufferImpl {
public:
CommandBufferImpl();
~CommandBufferImpl();
void Reset();
void Begin();
void End();
void Dispatch(s32, s32, s32);
};
}; // namespace detail
}; // namespace gfx
}; // namespace nn |
3cf976d87717827307b94d331515b4596cf5f44c | b50a2a9d9782febeb9a919dccd0edafdfa1f41eb | /berkley.cpp | 3c1f76b3e8101d967e1c2964d2038e9011d80c63 | [] | no_license | suyashtrivedi99/distributed-clock-synchronization-algorithms | 323f6aa851ce0bb90650c226e1417b147a0a1e66 | 3a34df11be97788402c5ab7dff0bb54e1e1c89e3 | refs/heads/main | 2023-08-02T11:11:56.218815 | 2021-10-10T16:34:09 | 2021-10-10T16:34:09 | 415,637,654 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,707 | cpp | berkley.cpp | #include <bits/stdc++.h>
#include<cstdlib>
#include<ctime>
using namespace std;
pair<int,int> nodes[100];
int store[100];
pair<int,int> generateTime()
{
int hr = rand()%24;
int min = rand()%60;
return make_pair(hr,min);
}
void printTime(pair<int,int> t)
{
if(t.first < 10)cout<<0;
cout<<t.first<<":";
if(t.second < 10)cout<<0;
cout<<t.second<<'\n';
}
int convFromTime(pair<int,int> t)
{
return ((t.first*60) + t.second);
}
pair<int,int> convToTime(int t)
{
int hr = t/60;
int min = t%60;
return make_pair(hr,min);
}
int main()
{
srand(time(0));
cout<<"Enter number of nodes\n";
int n; cin>>n;
for(int i = 0; i < n; i++)
{
auto p = generateTime();
nodes[i] = p;
store[i] = convFromTime(nodes[i]);
cout<<"Time at Node #"<<i<<": ";
printTime(nodes[i]);
}
cout<<"\nChoose ID of master node\n";
int id; cin>>id;
int sum = 0;
cout<<'\n';
// Calculating offsets of all times with respect to master node
for(int i = 0; i < n; i++)
{
int cur = store[i] - convFromTime(nodes[id]);
auto curTime = convToTime(abs(cur));
cout<<"Time Offset of Node #"<<i<<" from Master Node: ";
if(cur < 0)cout<<"-";
printTime(curTime);
sum += store[i];
}
// Calculating average time
int avg = sum/n;
auto avgTime = convToTime(abs(avg));
cout<<"\nAverage Time of all nodes: ";
printTime(avgTime);
cout<<'\n';
// Calculating all synchronization values
for(int i = 0; i < n; i++)
{
int cur = avg - store[i];
bool sign = (cur >= 0)?1:0;
cur = abs(cur);
auto curTime = convToTime(cur);
cout<<"Node #"<<i<<" needs to ";
if(sign) cout<<"increase its time by ";
else cout<<"decrease its time by ";
printTime(curTime);
}
return 0;
}
|
fbec250e0dcf9420fb83f1d8cdad9b7d2517fd58 | e922194607bde0ab22b25a1a42878fea5c614a55 | /test/00/pointer_to_class_members/main.cpp | cc51eb25d578a7e91ae339236e416d88bbe716a8 | [] | no_license | queenieho/Cpp | fd3c309121ba99d977383ef332c47ab94b37299c | e62d2bf7e764f3cb6141c7aecfa8a05f488062f6 | refs/heads/master | 2020-12-02T22:29:03.717437 | 2017-07-05T05:24:06 | 2017-07-05T05:24:06 | 96,139,223 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,521 | cpp | main.cpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qho <qho@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/03 16:30:05 by qho #+# #+# */
/* Updated: 2017/07/03 17:51:00 by qho ### ########.fr */
/* */
/* ************************************************************************** */
#include <iostream>
#include "Sample1.hpp"
int main() {
Sample instance;
Sample *instancep = &instance;
int Sample::*p = NULL; //pointer to foo variable in Sample class
void (Sample::*f)(void) const; // pointer for a function in Sample class
p = &Sample::foo;
std::cout << "value of member foo: " << instance.foo << std::endl;
instance.*p = 21;
std::cout << "value of member foo: " << instance.foo << std::endl;
instancep->*p = 42;
std::cout << "value of member foo: " << instance.foo << std::endl;
f = &Sample::bar; // point to bar function in Sample class
(instance.*f)();
(instancep->*f)();
return 0;
}
|
8f93d8ad10a70e96cfa074c73181f89ff5d1980c | 67fe05d738dd029a6777cc98e6b93baa146f5ee8 | /prob89_ๅฟซ้ๅนๆจก่ดจๆฐ.cpp | 887072b377c66515278888dbfcd1cdc06e584635 | [] | no_license | FennelDumplings/acwing | b4d606ee7f71cf2b49fecb25a1401c6c467dd282 | ec7f17416d13a9f5a48d537eb21b787b519c2ed0 | refs/heads/master | 2023-05-11T22:15:24.953071 | 2023-05-06T17:45:35 | 2023-05-06T17:45:35 | 238,383,202 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 355 | cpp | prob89_ๅฟซ้ๅนๆจก่ดจๆฐ.cpp | #include <iostream>
using namespace std;
using ll = long long;
int quickpower2(int a, int b, int p)
{
int ans = 1;
while(b)
{
if(b & 1) ans = ((ll)ans * a) % p;
a = (ll)a * a % p;
b >>= 1;
}
return ans % p;
}
int main()
{
int a, b, p;
cin >> a >> b >> p;
cout << quickpower2(a, b, p) << endl;
}
|
8812523fd3a03dee4a8ec38ad4519a67203e0b2d | df2b801fbcbfe88e64502c498bc044b437f5a2f7 | /FakeWalk.cpp | 71f49fdb56462adbdb0c20b83be703279860b19f | [] | no_license | vindeckyy/yeti | 08051e43e45e2a3c73b41a91f464d627e84ad3eb | 0acec1e281d7e9b91ebe8f7631b51566a04ec198 | refs/heads/master | 2023-05-14T14:51:18.562360 | 2023-05-08T23:41:37 | 2023-05-08T23:41:37 | 117,345,972 | 15 | 13 | null | 2018-04-10T11:27:16 | 2018-01-13T13:33:01 | C++ | UTF-8 | C++ | false | false | 599 | cpp | FakeWalk.cpp | #include "FakeWalk.h"
FakeWalk fakewalk;
void FakeWalk::run(CUserCmd* m_pcmd, bool& _packet)
{
auto m_local = game::localdata.localplayer();
if (m_local->GetFlags() & FL_ONGROUND) {
if (!(m_local->GetFlags() & (int)FL_INWATER)) {
int movetype = m_local->GetMoveType();
if (!(movetype == 8 || movetype == 9)) {
if (miscconfig.bFakeWalk && GetAsyncKeyState(miscconfig.iFakeWalkKey)) {
auto clientstate = m_ClientState;
auto netchannelinfo = m_pEngine->GetNetChannelInfo();
//auto netchannelhandler = g_csgo.m_nch;
//auto netclient = g_csgo.m_nc;
}
}
}
}
} |
5fa33b1d88447a8c8eef5417934d17118b6bc198 | b530e1cb11ba57ba5ac955f423f451d88d6e16fb | /include/WorldController.hh | 8989a8b8dc8d9f6a4ce208526cf8f9773626679d | [] | no_license | Lunderberg/midgard | ac2efc32c23f7bb61e86f91cc4ab359b9693fd13 | 9cd5504d1d0eeab9ff1c904173cbf018672c702c | refs/heads/master | 2020-12-03T10:44:37.328008 | 2020-02-27T15:39:29 | 2020-02-27T15:39:29 | 231,286,864 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,204 | hh | WorldController.hh | #pragma once
#include <atomic>
#include <condition_variable>
#include <memory>
#include <mutex>
#include <queue>
#include <string>
#include <thread>
#include "nlohmann/json.hpp"
using nlohmann::json;
class WorldSim;
struct ServerResponse {
std::string response;
std::string broadcast;
std::weak_ptr<void> respond_to;
};
class WorldController {
struct Request {
std::string command;
std::weak_ptr<void> requested_by;
};
public:
WorldController(WorldSim& sim);
~WorldController();
ServerResponse request(const std::string& command, std::weak_ptr<void> hdl);
ServerResponse update_check();
private:
ServerResponse request_maythrow(const std::string& command, std::weak_ptr<void> hdl);
void worker_thread();
void worker_thread_iter(Request& req);
// To be called only from worker thread
void broadcast_map_update();
json get_food_dist() const;
json get_creature_info() const;
void reset_world();
WorldSim& sim;
std::atomic_bool worker_running;
std::thread sim_thread;
std::mutex command_mutex;
std::condition_variable command_cv;
std::queue<Request> worker_commands;
std::mutex response_mutex;
std::queue<ServerResponse> responses;
};
|
9c3ca6d56dc72c93dd6b7c48aa5e2f278f0a9f75 | 84af27f34645237a12faa2e276bacb5a03453c8f | /include/TArrayTable.h | e4ab0c4c7a82d447b0bdfbdf9d7ae1f178797849 | [] | no_license | left841/mp2-lab7-tables | 7363272f9778a24ef97bdf3044e897ed72b8006a | a8e96ccf1683d4df4a778c5bb0873ad7bade0953 | refs/heads/master | 2020-05-05T08:46:12.653067 | 2019-06-01T15:50:19 | 2019-06-01T15:50:19 | 179,877,054 | 0 | 0 | null | 2019-04-06T19:24:58 | 2019-04-06T19:24:57 | null | WINDOWS-1251 | C++ | false | false | 1,872 | h | TArrayTable.h | #ifndef __TARRAY_TABLE_H__
#define __TARRAY_TABLE_H__
#include "TTable.h"
#define TabMaxSize 25
enum TDataPos {FIRST_POS, CURRENT_POS, LAST_POS};
class TArrayTable : public TTable {
protected:
PTTabRecord *pRecs; // ะฟะฐะผััั ะดะปั ะทะฐะฟะธัะตะน ัะฐะฑะปะธัั
int TabSize; // ะผะฐะบั. ะฒะพะทะผ.ะบะพะปะธัะตััะฒะพ ะทะฐะฟะธัะตะน ะฒ ัะฐะฑะปะธัะต
int CurrPos; // ะฝะพะผะตั ัะตะบััะตะน ะทะฐะฟะธัะธ (ะฝัะผะตัะฐัะธั ั 0)
public:
TArrayTable(int Size=TabMaxSize); // ะบะพะฝััััะบัะพั
~TArrayTable( ); // ะดะตััััะบัะพั
// ะธะฝัะพัะผะฐัะธะพะฝะฝัะต ะผะตัะพะดั
virtual int IsFull ( ) const ; // ะทะฐะฟะพะปะฝะตะฝะฐ?
int GetTabSize( ) const ; // ะบ-ะฒะพ ะทะฐะฟะธัะตะน
// ะดะพัััะฟ
virtual TKey GetKey (void) const;
virtual PTDatValue GetValuePTR (void) const;
virtual TKey GetKey (TDataPos mode) const;
virtual PTDatValue GetValuePTR (TDataPos mode) const;
// ะพัะฝะพะฒะฝัะต ะผะตัะพะดั
virtual PTDatValue FindRecord (TKey k) =0; // ะฝะฐะนัะธ ะทะฐะฟะธัั
virtual void InsRecord (TKey k, PTDatValue pVal ) =0; // ะฒััะฐะฒะธัั
virtual void DelRecord (TKey k) =0; // ัะดะฐะปะธัั ะทะฐะฟะธัั
//ะฝะฐะฒะธะณะฐัะธั
virtual int Reset (void); // ัััะฐะฝะพะฒะธัั ะฝะฐ ะฟะตัะฒัั ะทะฐะฟะธัั
virtual int IsTabEnded (void) const; // ัะฐะฑะปะธัะฐ ะทะฐะฒะตััะตะฝะฐ?
virtual int GoNext (void) ; // ะฟะตัะตั
ะพะด ะบ ัะปะตะดัััะตะน ะทะฐะฟะธัะธ
//(=1 ะฟะพัะปะต ะฟัะธะผะตะฝะตะฝะธั ะดะปั ะฟะพัะปะตะดะฝะตะน ะทะฐะฟะธัะธ ัะฐะฑะปะธัั)
virtual int SetCurrentPos (int pos);// ัััะฐะฝะพะฒะธัั ัะตะบัััั ะทะฐะฟะธัั
int GetCurrentPos (void) const; //ะฟะพะปััะธัั ะฝะพะผะตั ัะตะบััะตะน ะทะฐะฟะธัะธ
friend class TSortTable;
};
#endif // __TARRAY_TABLE_H__
|
cb4d7a92a9aab0e31bcf6aff8daebf24001e6dbb | 0afb5ac204c59380f3ba3e88ddacea26b7f93d3c | /lab 13/lab 13/driver.cpp | 94b3ab746e9891a4d4129de51db6c1955c1f64af | [] | no_license | jordano1/cs1410 | fba4d2e3f17dfce8f359ea73be2cb8f66825eda2 | eea6d7092b9ca1d1db87796df9f3b5f4299604e0 | refs/heads/master | 2020-03-26T15:15:37.003440 | 2018-08-16T19:33:37 | 2018-08-16T19:33:37 | 145,018,425 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 240 | cpp | driver.cpp | #include "driver.h"
int main()
{
Pair<char> letters('a', 'd');
cout << "\nThe first letter is: " << letters.get_first();
cout << "\nThe second letter is: " << letters.get_second();
cout << endl;
system("Pause");
return 0;
} |
0c5dd46eba21165d5ad82a1340c433dd705e2500 | 63435fba588bc64bf3a16ac2fe6fc9ea740a97aa | /Algoritimos e Programaรงรฃo 1/Exercรญcio 04 - Estrutura For/exercicio01 - for.cpp | b0c0341e42d6a079f78ac1bade187f4a91467c4b | [
"MIT"
] | permissive | Showbiztable/Faculdade_Unisociesc | 889a7264585d2f18051149710b4a7859c81be40e | 02b67cfd3c960e8dfb50ad812bbfd773577dacf7 | refs/heads/master | 2020-08-01T12:19:27.661243 | 2019-12-04T22:13:34 | 2019-12-04T22:13:34 | 210,994,630 | 1 | 1 | MIT | 2019-12-01T23:49:18 | 2019-09-26T03:48:28 | C++ | ISO-8859-1 | C++ | false | false | 790 | cpp | exercicio01 - for.cpp | /*
Lucas Trevizan e Doglas E E Cattoni
1. Faรงa um programa que receba dois nรบmeros inteiros e gere os nรบmeros inteiros que estรฃo no intervalo compreendido por eles.
*/
#include<iostream>
#include<locale.h>
#include<stdio.h>
#include<math.h>
using namespace std;
main()
{
int n1,n2,cont;
setlocale(LC_ALL,"Portuguese");
cout<<"Informe dois nรบmeros:\n";
cin>>n1>>n2;
if(n1>n2)
{
cout<<"O intervalo entre o nรบmero "<<n1<<" e "<<n2<<":\n";
for(cont=n1-1;cont>n2;cont--)
{
cout<<cont<<"\n";
}
}
else if(n1<n2)
{
cout<<"O intervalo entre o nรบmero "<<n1<<" e "<<n2<<":\n";
for(cont=n1+1;cont<n2;cont++)
{
cout<<cont<<"\n";
}
}
else
cout<<"Os nรบmeros sรฃo iguais, nรฃo existe intervalo.\n";
system("Pause>>null");
}
|
a9a1ca326a6044a204bad55acc9e59e49a1d8298 | 0290c8cb8b9eff9349dd07644c6d1a1fc4cec142 | /Latest Stable Models/modelling/main.cpp | 5ec08cb4ccada1ad5a8919d7bfe8c2201b6f3fe8 | [] | no_license | ivanliu1989/Helping-Santas-Helpers | c03799023952651be0e950fe77c4a31cd4303215 | 4287946489d2faa7d44297f6169d312b9a548f01 | refs/heads/master | 2021-01-02T09:33:26.783676 | 2015-01-03T23:41:37 | 2015-01-03T23:41:37 | 27,221,218 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,313 | cpp | main.cpp | #include <Rcpp.h>
#include <algorithm> // std::max
using namespace Rcpp;
// [[Rcpp::export]]
int updateNextAvailableMinute(int start_minute, int work_duration){
int next_available_time = 0;
int S = 0;
int U = 0;
int full_days = work_duration / (60*24);
S = full_days * (10*60);
U = full_days * (14*60);
int remainder = start_minute + full_days * (60*24);
for (int i = remainder; i < (start_minute+work_duration); ++i) {
bool isSanctionedTime = ((i - 540) % (60*24)) < 600;
if (isSanctionedTime) S += 1;
else U += 1;
}
int end_minute = start_minute + work_duration;
if(U == 0) {
if(((end_minute - 540) % (60*24)) < 600) {
next_available_time = end_minute;
} else {
bool isSanctionedTime = ((end_minute - 540) % (60*24)) < 600;
bool isSanctionedTime_1 = ((end_minute - 539) % (60*24)) < 600;
int next_min = 0;
if(isSanctionedTime && isSanctionedTime_1) next_min = end_minute + 1;
else {
int num_days = end_minute / (60*24);
int am_or_pm = (end_minute % (60*24))/ 540;
next_min = 540 + (num_days + am_or_pm / 2) * (60*24);
}
next_available_time = next_min;
}
} else {
if (U == 0) {
bool isSanctionedTime = ((end_minute - 540) % (60*24)) < 600;
if (isSanctionedTime) next_available_time = end_minute;
else{
bool isSanctionedTime = ((end_minute - 540) % (60*24)) < 600;
bool isSanctionedTime_1 = ((end_minute - 539) % (60*24)) < 600;
int next_min = 0;
if(isSanctionedTime && isSanctionedTime_1) next_min = end_minute + 1;
else {
int num_days = end_minute / (60*24);
int am_or_pm = (end_minute % (60*24))/ 540;
next_min = 540 + (num_days + am_or_pm / 2) * (60*24);
}
next_available_time = next_min;
}
}
int num_days_since_jan1 = end_minute / (60 * 24);
int rest_time = U;
int rest_time_in_working_days = rest_time / 600;
int rest_time_remaining_minutes = rest_time % 600;
int local_start = end_minute % (60 * 24);
if (local_start < 540) local_start = 540;
else if (local_start > 1140) {
num_days_since_jan1 += 1;
local_start = 540;
}
if (local_start + rest_time_remaining_minutes >= 1140) {
num_days_since_jan1 += 1;
rest_time_remaining_minutes -= (1140 - local_start);
local_start = 540;
}
int total_days = num_days_since_jan1 + rest_time_in_working_days;
next_available_time = total_days * (60*24) + local_start + rest_time_remaining_minutes;
}
return next_available_time;
}
// [[Rcpp::export]]
double updateProductivity(int start_minute, int work_duration, double current_rating){
NumericVector out(2);
int S = 0;
int U = 0;
int full_days = work_duration / (60*24);
S = full_days * (10*60);
U = full_days * (14*60);
int remainder = start_minute + full_days * (60*24);
for (int i = remainder; i < (start_minute+work_duration); ++i) {
bool isSanctionedTime = ((i - 540) % (60*24)) < 600;
if (isSanctionedTime) S += 1;
else U += 1;
}
double new_rating = std::max(0.25, std::min(4.0, current_rating * pow(1.02, S / 60.0) * pow(0.90, U / 60.0)));
return new_rating;
}
// [[Rcpp::export]]
NumericMatrix solution_Elf(NumericMatrix myToys_1,NumericMatrix myToys_2,NumericMatrix myToys_3, NumericMatrix myelves){
NumericMatrix outcomes(10,4); //ToyId, Arrival_time, Duration, Size, r_duration, start_time, finish, rate_f, refresh, evaluate
for(int i=0; i<10; ++i){
int min_val = myelves(0,2);
int min_row = 0;
for(int e=0; e<myelves.nrow(); e++){
if (min_val > myelves(e,2)){
min_val = myelves(e,2);
min_row = e;
}
}
//elf_id, current_rating, next_available_time, score
//min_element => for loop == i (row number)
int c_elf_id = myelves(min_row,0);
int c_elf_start_time = myelves(min_row,2);
int c_elf_rating = myelves(min_row,1);
NumericMatrix Toys;
if(c_elf_rating == 4.0){
Toys = myToys_3;
}
else if(c_elf_rating > 3){
Toys = myToys_2;
}else{
Toys = myToys_1;
}
//double mean_rate, mean_refresh, mean_finish;
double min_rate = Toys(0,7);
double max_rate = Toys(0,7);
double min_refresh = Toys(0,8);
double max_refresh = Toys(0,8);
double min_finish = Toys(0,6);
double max_finish = Toys(0,6);
// (e - Emin)/(Emax - Emin)
for(int j = 0; j < Toys.nrow(); j++){
Toys(j,4) = ceil(Toys(j,2)/c_elf_rating); //duration
Toys(j,5) = std::max((int)c_elf_start_time, (int)Toys(j, 1)); //start_time
Toys(j,7) = updateProductivity(Toys(j,7), Toys(j,4), c_elf_rating); //rate_f
Toys(j,8) = updateNextAvailableMinute(Toys(j,5), Toys(j,4)); //refresh
Toys(j,6) = Toys(j,4)+ Toys(j,5); //finish
//mean_rate = (Toys(j,7) + mean_rate)/(j+1);
//mean_refresh = (Toys(j,8) + mean_refresh)/(j+1);
//mean_finish = (Toys(j,6) + mean_finish)/(j+1);
if (min_rate > Toys(j,7)) min_rate = Toys(j,7);
if (max_rate < Toys(j,7)) max_rate = Toys(j,7);
if (min_refresh > Toys(j,8)) min_refresh = Toys(j,8);
if (max_refresh < Toys(j,8)) max_refresh = Toys(j,8);
if (min_finish > Toys(j,6)) min_finish = Toys(j,6);
if (max_finish < Toys(j,6)) max_finish = Toys(j,6);
}
Toys( _, 9) = ((Toys( _, 7) - min_rate)/(max_rate - min_rate) + (Toys( _, 8) - min_refresh)/(max_refresh - min_refresh) + (Toys( _, 6) - min_finish)/(max_finish - min_finish))/3;
double min_toy_val = Toys(0,9);
int min_toy_row = 0;
for(int v=0; v<Toys.nrow(); v++){
if(Toys(v,0)<10000001){
if (min_toy_val > Toys(v,9)){
min_toy_val = Toys(v,9);
min_toy_row = v;
}
}
}
// (e - Emin)/(Emax - Emin)
int c_toy_id = Toys(min_row,0);
c_elf_start_time = (int)Toys(min_row,5);
int work_duration = Toys(min_row,4);
myelves(c_elf_id-1, 2) = Toys(min_row,8); //next_available_time
myelves(c_elf_id-1, 1) = Toys(min_row,7); //current_rating
outcomes(i,0) = c_toy_id;
outcomes(i,1) = c_elf_id;
outcomes(i,2) = c_elf_start_time;
outcomes(i,3) = work_duration;
if(c_elf_rating == 4.0){
myToys_3(min_row, 0) = 10000001; // #################
}
else if(c_elf_rating > 3){
myToys_2(min_row, 0) = 10000001; // #################
}else{
myToys_1(min_row, 0) = 10000001; // #################
}
//if(i % 100000 == 0)
Rcpp::Rcout << '\n' << i;
}
return outcomes;
} |
24ed115db2ed3bc5548ae3c044ab22295f16afec | 056bc9b522a37d9829caa5b4eacd4c19d9fb2ebc | /Win32_OculusRoomTiny.cpp | ef3ea037be822c1e3f9f2241245cd2818542081e | [] | no_license | jredmond/OculusRoom3Space | 3cceb5ef839a7a5b2b0b09ef211656f21eae1bcc | 7c77c6208ec62366132c54419aa8ac19ddba73e2 | refs/heads/master | 2020-05-31T13:26:29.932242 | 2013-06-15T13:56:03 | 2013-06-15T13:56:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,850 | cpp | Win32_OculusRoomTiny.cpp | /************************************************************************************
Filename : Win32_OculusRoomTiny.cpp
Content : First-person view test application for Oculus Rift
Created : October 4, 2012
Authors : Michael Antonov, Andrew Reisse
Copyright : Copyright 2012 Oculus, Inc. All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*************************************************************************************/
#include "Win32_OculusRoomTiny.h"
#include "RenderTiny_D3D1X_Device.h"
//-------------------------------------------------------------------------------------
//ThreeSpace Stuff
//header file
#include "ThreeSpaceAPI/yei_threespace_api.h"
//When getting stream data use a packed structure
#pragma pack(push,1)
typedef struct {
float quat[4];
} tss_stream_packet;
#pragma pack(pop)
//The device id
TSS_Device_Id tss_device;
bool tss_isStreaming = false;
tss_stream_packet tss_packet;
unsigned int tss_timestamp;
//-------------------------------------------------------------------------------------
// ***** OculusRoomTiny Class
// Static pApp simplifies routing the window function.
OculusRoomTinyApp* OculusRoomTinyApp::pApp = 0;
OculusRoomTinyApp::OculusRoomTinyApp(HINSTANCE hinst)
: pRender(0),
LastUpdate(0),
// Win32
hWnd(NULL),
hInstance(hinst), Quit(0), MouseCaptured(true),
hXInputModule(0), pXInputGetState(0),
// Initial location
EyePos(0.0f, 1.6f, -5.0f),
EyeYaw(YawInitial), EyePitch(0), EyeRoll(0),
LastSensorYaw(0),
SConfig(),
PostProcess(PostProcess_Distortion),
ShiftDown(false),
ControlDown(false)
{
pApp = this;
Width = 1280;
Height = 800;
StartupTicks = OVR::Timer::GetTicks();
LastPadPacketNo = 0;
MoveForward = MoveBack = MoveLeft = MoveRight = 0;
GamepadMove = Vector3f(0);
GamepadRotate = Vector3f(0);
}
OculusRoomTinyApp::~OculusRoomTinyApp()
{
RemoveHandlerFromDevices();
pSensor.Clear();
pHMD.Clear();
destroyWindow();
pApp = 0;
}
int OculusRoomTinyApp::OnStartup(const char* args)
{
OVR_UNUSED(args);
// *** ThreeSpace initialisation
//TSS_Error tss_error;
TSS_ComPort tss_comport;
LARGE_INTEGER tss_frequency; //ticks per second
LARGE_INTEGER tss_t1, tss_t2; //ticks
QueryPerformanceFrequency(&tss_frequency);
QueryPerformanceCounter(&tss_t1);
QueryPerformanceCounter(&tss_t2);
unsigned int tss_serial;
if(tss_getComPorts(&tss_comport,1,0,TSS_FIND_ALL_KNOWN^TSS_FIND_DNG))
{
tss_device = tss_createTSDeviceStr(tss_comport.com_port, TSS_TIMESTAMP_SENSOR);
if(tss_device == TSS_NO_DEVICE_ID)
{
LogText("Failed to create a sensor on %s\n", tss_comport.com_port);
}
else
{
if(tss_getSerialNumber(tss_device, &tss_serial, NULL) == TSS_NO_ERROR)
LogText("Connected to ThreeSpace sensor!! Port: %s Serial: %x\n",
tss_comport.com_port, tss_serial);
}
}
else
{
LogText("No sensors found\n");
}
// ***
// *** Set ThreeSpace axis directions SetTSAxisDirections()
TSS_Axis_Direction axis_order = TSS_XZY;
char neg_x = 1;
char neg_y = 1;
char neg_z = 0;
unsigned char axis_dir_byte = tss_generateAxisDirections(axis_order, neg_x, neg_y, neg_z);
if( tss_setAxisDirections(tss_device, axis_dir_byte, &tss_timestamp) == 0 )
LogText("TSS: Set axis complete!\n");
else
LogText("TSS: Set axis failed!\n");
// ***
/*
// *** Get the quat for debug information GetTSQuat()
TSS_Error tss_error_id;
float quat[4];
tss_error_id = tss_getTaredOrientationAsQuaternion(tss_device, quat, &tss_timestamp);
LogText("Quaternion: %f, %f, %f, %f Timestamp=%u\n", quat[0], quat[1], quat[2] ,quat[3], tss_timestamp);
// ***
// *** Get the colour of the headtrackers LED
LogText("Getting the LED colour of the device\n");
float tss_color[3];
tss_error_id = tss_getLEDColor(tss_device, tss_color, NULL);
LogText("Color: %f, %f, %f\n", tss_color[0], tss_color[1], tss_color[2]);
//Try setting the colour
for(int i = 0; i <= 100; i++)
{
tss_color[i%3] = (float)i/100;
tss_color[(i+1)%3] = 0;
tss_color[(i+2)%3] = 0;
tss_error_id = tss_setLEDColor(tss_device, tss_color, NULL);
Sleep(100);
}
// ***
*/
// *** StartStreaming
TSS_Stream_Command tss_stream_slots[8] = { TSS_GET_TARED_ORIENTATION_AS_QUATERNION, TSS_NULL,
TSS_NULL, TSS_NULL,
TSS_NULL, TSS_NULL,
TSS_NULL, TSS_NULL};
int count = 0;
if(!tss_isStreaming)
{
//3 Attempts
while( count < 3)
{
if(tss_setStreamingTiming(tss_device,0, TSS_INFINITE_DURATION, 0, NULL) == 0)
{
if(tss_setStreamingSlots(tss_device, tss_stream_slots, NULL) == 0)
{
if(tss_startStreaming(tss_device, NULL) == 0)
{
tss_isStreaming = true;
LogText("TSS: Start streaming success!\n");
break;
}
}
}
count++;
}
}
if(!tss_isStreaming)
{
LogText("TSS: Start streaming failed!\n");
}
// ***
// *** tareSensor
tss_tareWithCurrentOrientation(tss_device,NULL);
/*
float forward[3];
float down[3];
float filt_orient_quat[4];
float gravity[3];
gravity[0] = 0;
gravity[1] = 0;
gravity[2] = -1;
tss_getUntaredTwoVectorInSensorFrame(tss_device, forward, down);
tss_getUntaredOrientationAsQuaternion(tss_device, filt_orient_quat);
*/
// ***
/*
// *** GetData
tss_getLatestStreamData(tss_device,(char*)&tss_packet,sizeof(tss_packet),1000,&tss_timestamp);
LogText("t:%8u Euler: %f, %f, %f, \n", tss_timestamp,
tss_packet.euler[0],
tss_packet.euler[1],
tss_packet.euler[2]);
// ***
*/
// *** Oculus HMD & Sensor Initialization
// Create DeviceManager and first available HMDDevice from it.
// Sensor object is created from the HMD, to ensure that it is on the
// correct device.
pManager = *DeviceManager::Create();
// We'll handle it's messages in this case.
pManager->SetMessageHandler(this);
int detectionResult = IDCONTINUE;
const char* detectionMessage;
do
{
// Release Sensor/HMD in case this is a retry.
pSensor.Clear();
pHMD.Clear();
RenderParams.MonitorName.Clear();
pHMD = *pManager->EnumerateDevices<HMDDevice>().CreateDevice();
if (pHMD)
{
pSensor = *pHMD->GetSensor();
// This will initialize HMDInfo with information about configured IPD,
// screen size and other variables needed for correct projection.
// We pass HMD DisplayDeviceName into the renderer to select the
// correct monitor in full-screen mode.
if (pHMD->GetDeviceInfo(&HMDInfo))
{
RenderParams.MonitorName = HMDInfo.DisplayDeviceName;
RenderParams.DisplayId = HMDInfo.DisplayId;
SConfig.SetHMDInfo(HMDInfo);
}
}
else
{
// If we didn't detect an HMD, try to create the sensor directly.
// This is useful for debugging sensor interaction; it is not needed in
// a shipping app.
pSensor = *pManager->EnumerateDevices<SensorDevice>().CreateDevice();
}
// If there was a problem detecting the Rift, display appropriate message.
detectionResult = IDCONTINUE;
if (!pHMD && !pSensor)
detectionMessage = "Oculus Rift not detected.";
else if (!pHMD)
detectionMessage = "Oculus Sensor detected; HMD Display not detected.";
else if (!pSensor)
detectionMessage = "Oculus HMD Display detected; Sensor not detected.";
else if (HMDInfo.DisplayDeviceName[0] == '\0')
detectionMessage = "Oculus Sensor detected; HMD display EDID not detected.";
else
detectionMessage = 0;
if (detectionMessage)
{
String messageText(detectionMessage);
messageText += "\n\n"
"Press 'Try Again' to run retry detection.\n"
"Press 'Continue' to run full-screen anyway.";
detectionResult = ::MessageBoxA(0, messageText.ToCStr(), "Oculus Rift Detection",
MB_CANCELTRYCONTINUE|MB_ICONWARNING);
if (detectionResult == IDCANCEL)
return 1;
}
} while (detectionResult != IDCONTINUE);
if (HMDInfo.HResolution > 0)
{
Width = HMDInfo.HResolution;
Height = HMDInfo.VResolution;
}
if (!setupWindow())
return 1;
if (pSensor)
{
// We need to attach sensor to SensorFusion object for it to receive
// body frame messages and update orientation. SFusion.GetOrientation()
// is used in OnIdle() to orient the view.
SFusion.AttachToSensor(pSensor);
SFusion.SetDelegateMessageHandler(this);
SFusion.SetPredictionEnabled(true);
}
// *** Initialize Rendering
// Enable multi-sampling by default.
RenderParams.Multisample = 4;
RenderParams.Fullscreen = true;
// Setup Graphics.
pRender = *RenderTiny::D3D10::RenderDevice::CreateDevice(RenderParams, (void*)hWnd);
if (!pRender)
return 1;
// *** Configure Stereo settings.
SConfig.SetFullViewport(Viewport(0,0, Width, Height));
SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
// Configure proper Distortion Fit.
// For 7" screen, fit to touch left side of the view, leaving a bit of invisible
// screen on the top (saves on rendering cost).
// For smaller screens (5.5"), fit to the top.
if (HMDInfo.HScreenSize > 0.0f)
{
if (HMDInfo.HScreenSize > 0.140f) // 7"
SConfig.SetDistortionFitPointVP(-1.0f, 0.0f);
else
SConfig.SetDistortionFitPointVP(0.0f, 1.0f);
}
pRender->SetSceneRenderScale(SConfig.GetDistortionScale());
SConfig.Set2DAreaFov(DegreeToRad(85.0f));
// *** Populate Room Scene
// This creates lights and models.
PopulateRoomScene(&Scene, pRender);
LastUpdate = GetAppTime();
return 0;
}
void OculusRoomTinyApp::OnMessage(const Message& msg)
{
if (msg.Type == Message_DeviceAdded && msg.pDevice == pManager)
{
LogText("DeviceManager reported device added.\n");
}
else if (msg.Type == Message_DeviceRemoved && msg.pDevice == pManager)
{
LogText("DeviceManager reported device removed.\n");
}
else if (msg.Type == Message_DeviceAdded && msg.pDevice == pSensor)
{
LogText("Sensor reported device added.\n");
}
else if (msg.Type == Message_DeviceRemoved && msg.pDevice == pSensor)
{
LogText("Sensor reported device removed.\n");
}
}
void OculusRoomTinyApp::OnGamepad(float padLx, float padLy, float padRx, float padRy)
{
GamepadMove = Vector3f(padLx * padLx * (padLx > 0 ? 1 : -1),
0,
padLy * padLy * (padLy > 0 ? -1 : 1));
GamepadRotate = Vector3f(2 * padRx, -2 * padRy, 0);
}
void OculusRoomTinyApp::OnMouseMove(int x, int y, int modifiers)
{
OVR_UNUSED(modifiers);
// Mouse motion here is always relative.
int dx = x, dy = y;
const float maxPitch = ((3.1415f/2)*0.98f);
// Apply to rotation. Subtract for right body frame rotation,
// since yaw rotation is positive CCW when looking down on XZ plane.
EyeYaw -= (Sensitivity * dx)/ 360.0f;
if (!pSensor)
{
EyePitch -= (Sensitivity * dy)/ 360.0f;
if (EyePitch > maxPitch)
EyePitch = maxPitch;
if (EyePitch < -maxPitch)
EyePitch = -maxPitch;
}
}
void OculusRoomTinyApp::OnKey(unsigned vk, bool down)
{
switch (vk)
{
case 'Q':
if (down && ControlDown)
Quit = true;
break;
case VK_ESCAPE:
if (!down)
Quit = true;
break;
// Handle player movement keys.
// We just update movement state here, while the actual translation is done in OnIdle()
// based on time.
case 'W': MoveForward = down ? (MoveForward | 1) : (MoveForward & ~1); break;
case 'S': MoveBack = down ? (MoveBack | 1) : (MoveBack & ~1); break;
case 'A': MoveLeft = down ? (MoveLeft | 1) : (MoveLeft & ~1); break;
case 'D': MoveRight = down ? (MoveRight | 1) : (MoveRight & ~1); break;
case VK_UP: MoveForward = down ? (MoveForward | 2) : (MoveForward & ~2); break;
case VK_DOWN: MoveBack = down ? (MoveBack | 2) : (MoveBack & ~2); break;
case 'R':
SFusion.Reset();
break;
case 'P':
if (down)
{
// Toggle chromatic aberration correction on/off.
RenderDevice::PostProcessShader shader = pRender->GetPostProcessShader();
if (shader == RenderDevice::PostProcessShader_Distortion)
{
pRender->SetPostProcessShader(RenderDevice::PostProcessShader_DistortionAndChromAb);
}
else if (shader == RenderDevice::PostProcessShader_DistortionAndChromAb)
{
pRender->SetPostProcessShader(RenderDevice::PostProcessShader_Distortion);
}
else
OVR_ASSERT(false);
}
break;
// Switch rendering modes/distortion.
case VK_F1:
SConfig.SetStereoMode(Stereo_None);
PostProcess = PostProcess_None;
break;
case VK_F2:
SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
PostProcess = PostProcess_None;
break;
case VK_F3:
SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
PostProcess = PostProcess_Distortion;
break;
// Stereo IPD adjustments, in meter (default IPD is 64mm).
case VK_OEM_PLUS:
case VK_INSERT:
if (down)
SConfig.SetIPD(SConfig.GetIPD() + 0.0005f * (ShiftDown ? 5.0f : 1.0f));
break;
case VK_OEM_MINUS:
case VK_DELETE:
if (down)
SConfig.SetIPD(SConfig.GetIPD() - 0.0005f * (ShiftDown ? 5.0f : 1.0f));
break;
// Holding down Shift key accelerates adjustment velocity.
case VK_SHIFT:
ShiftDown = down;
break;
case VK_CONTROL:
ControlDown = down;
break;
}
}
void OculusRoomTinyApp::OnIdle()
{
double curtime = GetAppTime();
float dt = float(curtime - LastUpdate);
LastUpdate = curtime;
// Handle Sensor motion.
// We extract Yaw, Pitch, Roll instead of directly using the orientation
// to allow "additional" yaw manipulation with mouse/controller.
if (pSensor)
{
Quatf hmdOrient = SFusion.GetOrientation();
float yaw = 0.0f;
hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &EyePitch, &EyeRoll);
EyeYaw += (yaw - LastSensorYaw);
LastSensorYaw = yaw;
}
//Threespace sensor integration
if(tss_isStreaming)
{
int error = tss_getLatestStreamData(tss_device,(char*)&tss_packet,sizeof(tss_packet),1000,&tss_timestamp);
if(error != 0)
{
LogText("TSS: getLatestStreamData error\n");
}
const float PI_F = 3.14159265358979f;
float x, y, z, w, s;
float rotator[3];
x = tss_packet.quat[0];
y = tss_packet.quat[1];
z = tss_packet.quat[2];
w = tss_packet.quat[3];
s = 2.0f * (w * y - x * z);
//it is invalid to pass values outside of the range -1,1 to asin()
if( s < 1.0 )
{
if( -1.0 < s)
{
rotator[0] = atan2( 2.0f*(x*y+w*z), 1.0f-2.0f*(y*y+z*z) );
rotator[1] = asin( s );
rotator[2] = atan2( 2.0f*(y*z+w*x), 1.0f-2.0f*(x*x+y*y) );
}
else
{
rotator[0] = 0;
rotator[1] = -PI_F / 2;
rotator[2] = -atan2( 2.0f*(x*y-w*z), 1.0f-2.0f*(x*x+z*z) );
}
}
else
{
rotator[0] = 0;
rotator[1] = PI_F / 2;
rotator[2] = atan2( 2.0f*(x*y-w*z), 1.0f-2.0f*(x*x+z*z) );
}
float yaw = 0.0;
yaw = rotator[0];
EyePitch = rotator[1];
EyeRoll = rotator[2];
//we are allowing combination of gamepad yaw and headtracker yaw therefore
EyeYaw += (yaw - LastSensorYaw);
LastSensorYaw = yaw;
/*
float yaw = 0.0f;
yaw = tss_packet.euler[0];
EyePitch = tss_packet.euler[1];
EyeRoll = tss_packet.euler[2];
//we are allowing combination of gamepad yaw and headtracker yaw therefore
EyeYaw += (yaw - LastSensorYaw);
LastSensorYaw = yaw;
*/
}
// Gamepad rotation.
EyeYaw -= GamepadRotate.x * dt;
if (!pSensor && !tss_isStreaming)
{
// Allow gamepad to look up/down, but only if there is no Rift sensor.
EyePitch -= GamepadRotate.y * dt;
const float maxPitch = ((3.1415f/2)*0.98f);
if (EyePitch > maxPitch)
EyePitch = maxPitch;
if (EyePitch < -maxPitch)
EyePitch = -maxPitch;
}
// Handle keyboard movement.
// This translates EyePos based on Yaw vector direction and keys pressed.
// Note that Pitch and Roll do not affect movement (they only affect view).
if (MoveForward || MoveBack || MoveLeft || MoveRight)
{
Vector3f localMoveVector(0,0,0);
Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw);
if (MoveForward)
localMoveVector = ForwardVector;
else if (MoveBack)
localMoveVector = -ForwardVector;
if (MoveRight)
localMoveVector += RightVector;
else if (MoveLeft)
localMoveVector -= RightVector;
// Normalize vector so we don't move faster diagonally.
localMoveVector.Normalize();
Vector3f orientationVector = yawRotate.Transform(localMoveVector);
orientationVector *= MoveSpeed * dt * (ShiftDown ? 3.0f : 1.0f);
EyePos += orientationVector;
}
else if (GamepadMove.LengthSq() > 0)
{
Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw);
Vector3f orientationVector = yawRotate.Transform(GamepadMove);
orientationVector *= MoveSpeed * dt;
EyePos += orientationVector;
}
// Rotate and position View Camera, using YawPitchRoll in BodyFrame coordinates.
//
Matrix4f rollPitchYaw = Matrix4f::RotationY(EyeYaw) * Matrix4f::RotationX(EyePitch) *
Matrix4f::RotationZ(EyeRoll);
Vector3f up = rollPitchYaw.Transform(UpVector);
Vector3f forward = rollPitchYaw.Transform(ForwardVector);
// Minimal head modelling.
float headBaseToEyeHeight = 0.15f; // Vertical height of eye from base of head
float headBaseToEyeProtrusion = 0.09f; // Distance forward of eye from base of head
Vector3f eyeCenterInHeadFrame(0.0f, headBaseToEyeHeight, -headBaseToEyeProtrusion);
Vector3f shiftedEyePos = EyePos + rollPitchYaw.Transform(eyeCenterInHeadFrame);
shiftedEyePos.y -= eyeCenterInHeadFrame.y; // Bring the head back down to original height
View = Matrix4f::LookAtRH(shiftedEyePos, shiftedEyePos + forward, up);
// This is what transformation would be without head modeling.
// View = Matrix4f::LookAtRH(EyePos, EyePos + forward, up);
switch(SConfig.GetStereoMode())
{
case Stereo_None:
Render(SConfig.GetEyeRenderParams(StereoEye_Center));
break;
case Stereo_LeftRight_Multipass:
Render(SConfig.GetEyeRenderParams(StereoEye_Left));
Render(SConfig.GetEyeRenderParams(StereoEye_Right));
break;
}
pRender->Present();
// Force GPU to flush the scene, resulting in the lowest possible latency.
pRender->ForceFlushGPU();
}
// Render the scene for one eye.
void OculusRoomTinyApp::Render(const StereoEyeParams& stereo)
{
pRender->BeginScene(PostProcess);
// Apply Viewport/Projection for the eye.
pRender->ApplyStereoParams(stereo);
pRender->Clear();
pRender->SetDepthMode(true, true);
Scene.Render(pRender, stereo.ViewAdjust * View);
pRender->FinishScene();
}
//-------------------------------------------------------------------------------------
// ***** Win32-Specific Logic
bool OculusRoomTinyApp::setupWindow()
{
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.lpszClassName = L"OVRAppWindow";
wc.style = CS_OWNDC;
wc.lpfnWndProc = systemWindowProc;
wc.cbWndExtra = sizeof(OculusRoomTinyApp*);
RegisterClass(&wc);
RECT winSize = { 0, 0, Width, Height };
AdjustWindowRect(&winSize, WS_POPUP, false);
hWnd = CreateWindowA("OVRAppWindow", "OculusRoomTiny", WS_POPUP|WS_VISIBLE,
HMDInfo.DesktopX, HMDInfo.DesktopY,
winSize.right-winSize.left, winSize.bottom-winSize.top,
NULL, NULL, hInstance, (LPVOID)this);
// Initialize Window center in screen coordinates
POINT center = { Width / 2, Height / 2 };
::ClientToScreen(hWnd, ¢er);
WindowCenter = center;
return (hWnd != NULL);
}
void OculusRoomTinyApp::destroyWindow()
{
pRender.Clear();
if (hWnd)
{
// Release window resources.
::DestroyWindow(hWnd);
UnregisterClass(L"OVRAppWindow", hInstance);
hWnd = 0;
Width = Height = 0;
}
}
LRESULT CALLBACK OculusRoomTinyApp::systemWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
if (msg == WM_NCCREATE)
pApp->hWnd = hwnd;
return pApp->windowProc(msg, wp, lp);
}
void OculusRoomTinyApp::giveUsFocus(bool setFocus)
{
if (setFocus)
{
::SetCursorPos(WindowCenter.x, WindowCenter.y);
MouseCaptured = true;
::SetCapture(hWnd);
::ShowCursor(FALSE);
}
else
{
MouseCaptured = false;
::ReleaseCapture();
::ShowCursor(TRUE);
}
}
LRESULT OculusRoomTinyApp::windowProc(UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg)
{
case WM_MOUSEMOVE:
{
if (MouseCaptured)
{
// Convert mouse motion to be relative (report the offset and re-center).
POINT newPos = { LOWORD(lp), HIWORD(lp) };
::ClientToScreen(hWnd, &newPos);
if ((newPos.x == WindowCenter.x) && (newPos.y == WindowCenter.y))
break;
::SetCursorPos(WindowCenter.x, WindowCenter.y);
LONG dx = newPos.x - WindowCenter.x;
LONG dy = newPos.y - WindowCenter.y;
pApp->OnMouseMove(dx, dy, 0);
}
}
break;
case WM_MOVE:
{
RECT r;
GetClientRect(hWnd, &r);
WindowCenter.x = r.right/2;
WindowCenter.y = r.bottom/2;
::ClientToScreen(hWnd, &WindowCenter);
}
break;
case WM_KEYDOWN:
OnKey((unsigned)wp, true);
break;
case WM_KEYUP:
OnKey((unsigned)wp, false);
break;
case WM_SETFOCUS:
giveUsFocus(true);
break;
case WM_KILLFOCUS:
giveUsFocus(false);
break;
case WM_CREATE:
// Hack to position mouse in fullscreen window shortly after startup.
SetTimer(hWnd, 0, 100, NULL);
break;
case WM_TIMER:
KillTimer(hWnd, 0);
giveUsFocus(true);
break;
case WM_QUIT:
case WM_CLOSE:
Quit = true;
return 0;
}
return DefWindowProc(hWnd, msg, wp, lp);
}
static inline float GamepadStick(short in)
{
float v;
if (abs(in) < 9000)
return 0;
else if (in > 9000)
v = (float) in - 9000;
else
v = (float) in + 9000;
return v / (32767 - 9000);
}
static inline float GamepadTrigger(BYTE in)
{
return (in < 30) ? 0.0f : (float(in-30) / 225);
}
int OculusRoomTinyApp::Run()
{
// Loop processing messages until Quit flag is set,
// rendering game scene inside of OnIdle().
while (!Quit)
{
MSG msg;
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
// Read game-pad.
XINPUT_STATE xis;
if (pXInputGetState && !pXInputGetState(0, &xis) &&
(xis.dwPacketNumber != LastPadPacketNo))
{
OnGamepad(GamepadStick(xis.Gamepad.sThumbLX),
GamepadStick(xis.Gamepad.sThumbLY),
GamepadStick(xis.Gamepad.sThumbRX),
GamepadStick(xis.Gamepad.sThumbRY));
//pad.LT = GamepadTrigger(xis.Gamepad.bLeftTrigger);
LastPadPacketNo = xis.dwPacketNumber;
}
pApp->OnIdle();
// Keep sleeping when we're minimized.
if (IsIconic(hWnd))
Sleep(10);
}
}
return 0;
}
//-------------------------------------------------------------------------------------
// ***** Program Startup
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE, LPSTR inArgs, int)
{
int exitCode = 0;
// Initializes LibOVR. This LogMask_All enables maximum logging.
// Custom allocator can also be specified here.
OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All));
// Scope to force application destructor before System::Destroy.
{
OculusRoomTinyApp app(hinst);
//app.hInstance = hinst;
exitCode = app.OnStartup(inArgs);
if (!exitCode)
{
// Processes messages and calls OnIdle() to do rendering.
exitCode = app.Run();
}
}
// *** StopStreaming
int count = 0;
if(tss_isStreaming)
{
//3 Attempts
while( count < 3)
{
if(tss_stopStreaming(tss_device, NULL) == 0)
{
tss_isStreaming = false;
LogText("TSS: Stop streaming success!\n");
break;
}
count++;
}
}
if(tss_isStreaming)
{
LogText("TSS: Stop streaming failed!\n");
}
// ***
// No OVR functions involving memory are allowed after this.
OVR::System::Destroy();
OVR_DEBUG_STATEMENT(_CrtDumpMemoryLeaks());
return exitCode;
}
|
5279677279e02971de813684867ae5c17bf721a8 | cf47614d4c08f3e6e5abe82d041d53b50167cac8 | /CS101_Spring2020-21 /LAB4_L1/categorized/stream/all_passed/9_stream.cpp | af73bf9ffb8d64874b5e263ac79cb17dbbf400bd | [] | no_license | krishna-raj007/BodhiTree-Annotation | 492d782dffe3744740f48c4c7e6bbf2ee2c0febd | 28a6467038bac7710c4b3e3860a369ca0a6e31bf | refs/heads/master | 2023-02-28T18:23:05.880438 | 2021-02-07T17:55:33 | 2021-02-07T17:55:33 | 299,254,966 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 160 | cpp | 9_stream.cpp | #include<simplecpp>
main_program{
//Write your code here
int n, newn;
cin>>n;
cin>>newn;
while(newn>0){if(newn>n)n=newn;
cin>>newn;}
cout<<n<<endl;
}
|
6bce50ba0f86d35fe6fe032917125dcd609fb1c8 | 54b4dc3039a0cf47f5af64e0787bc3f47d57459a | /BrickEliminationElements.cpp | 17f206cddbd3b107770c027b33ef2f2931f575cf | [] | no_license | MorpheusDong/BrickElimination | 474d1990e0cf6f132dc32ebd3b90a9f157647c58 | 52bf6280558262d0efd00933c098295f5bba6eae | refs/heads/master | 2022-12-07T21:12:26.522522 | 2020-09-02T08:52:01 | 2020-09-02T08:52:01 | 277,071,176 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,583 | cpp | BrickEliminationElements.cpp | /* BrickEliminationElements.cpp */
#include "BrickElimination.h"
#include <graphics.h>
#include <conio.h>
#include "windows.h"
/* class ball realization */
CBall::CBall()
{
}
CBall::~CBall()
{
}
void CBall::ball_init_v()
{
m_ball_x = GRAPH_WIDTH / 2;
m_ball_y = GRAPH_HEIGHT / 2;
m_ball_vx = BALL_MOVE_SPEED;
m_ball_vy = BALL_MOVE_SPEED;
m_radius = BALL_RADIUS;
}
void CBall::ball_clean_v()
{
setcolor(BLACK);
setfillcolor(BLACK);
fillcircle(m_ball_x, m_ball_y, m_radius);
}
void CBall::ball_show_v()
{
setcolor(YELLOW);
setfillcolor(GREEN);
fillcircle(m_ball_x, m_ball_y, m_radius);
}
void CBall::ball_move_v()
{
m_ball_x += m_ball_vx;
m_ball_y += m_ball_vy;
}
/* class brick realization */
CBrick::CBrick()
{
}
CBrick::~CBrick()
{
}
void CBrick::brick_init_v()
{
m_brick_width = GRAPH_WIDTH / BRICK_NUM;
m_brick_height = GRAPH_HEIGHT / BRICK_NUM;
for (int i = 0; i < BRICK_NUM; i++)
{
Bricks[i].left = i * m_brick_width;
Bricks[i].right = Bricks[i].left + m_brick_width;
Bricks[i].top = 0;
Bricks[i].bottom = m_brick_height;
m_isBrickExisted[i] = BRICK_EXIST;
}
}
void CBrick::brick_clean_v()
{
setcolor(BLACK);
setfillcolor(BLACK);
for (int i = 0; i < BRICK_NUM; i++)
{
if (m_isBrickExisted[i] == BRICK_NOT_EXIST)
{
fillrectangle(Bricks[i].left, Bricks[i].top, Bricks[i].right, Bricks[i].bottom);
}
else
{
/* do thing */
}
}
}
void CBrick::brick_show_v()
{
for (int i = 0; i < BRICK_NUM; i++)
{
if (m_isBrickExisted[i])
{
setcolor(WHITE);
setfillcolor(RED);
fillrectangle(Bricks[i].left, Bricks[i].top, Bricks[i].right, Bricks[i].bottom);
}
else
{
/* do thing */
}
}
}
/* class bar realization */
CBar::CBar()
{
}
CBar::~CBar()
{
}
void CBar::bar_init_v()
{
m_bar_width = BAR_WIDTH;
m_bar_height = GRAPH_HEIGHT / 20;
m_bar_x = GRAPH_WIDTH / 2;
m_bar_y = GRAPH_HEIGHT - m_bar_height / 2;
m_bar_left = m_bar_x - m_bar_width / 2;
m_bar_right = m_bar_x + m_bar_width / 2;
m_bar_top = m_bar_y - m_bar_height / 2;
m_bar_bottom = m_bar_y + m_bar_height / 2;
}
void CBar::bar_clean_v()
{
setcolor(BLACK);
setfillcolor(BLACK);
bar(m_bar_left, m_bar_top, m_bar_right, m_bar_bottom);
}
void CBar::bar_show_v()
{
setcolor(YELLOW);
setfillcolor(GREEN);
bar(m_bar_left, m_bar_top, m_bar_right, m_bar_bottom);
}
void CBar::bar_move_v()
{
char input;
if (_kbhit())
{
input = _getch();
if (input == 'a' && m_bar_left > 0)
{
m_bar_x -= BAR_MOVE_SPEED;
m_bar_left = m_bar_x - m_bar_width / 2;
m_bar_right = m_bar_x + m_bar_width / 2;
}
else if (input == 'd' && m_bar_right < GRAPH_WIDTH)
{
m_bar_x += BAR_MOVE_SPEED;
m_bar_left = m_bar_x - m_bar_width / 2;
m_bar_right = m_bar_x + m_bar_width / 2;
}
else
{
/* do thing */
}
}
else
{
/* do thing */
}
}
GameBrickElimination::GameBrickElimination()
{
}
GameBrickElimination::~GameBrickElimination()
{
}
Ball_Hit_Type GameBrickElimination::check_ball_hit(Ball_Hit_Type isHit)
{
switch (isHit)
{
case Ball_Hit_Wall:
{
//check ball hit wall or not
if ((ball.get_x() <= ball.get_r()) || (ball.get_x() >= GRAPH_WIDTH - ball.get_r()))
{
ball.set_vx(-ball.get_vx());
return Ball_Hit_Wall;
}
else
{
/* do nothing */
}
if ((ball.get_y() <= ball.get_r()) || (ball.get_y() >= GRAPH_HEIGHT - ball.get_r()))
{
ball.set_vy(-ball.get_vy());
return Ball_Hit_Wall;
}
else
{
/* do nothing */
}
break;
}
case Ball_Hit_Bar:
{
if (((ball.get_y() + ball.get_r() >= bar.get_top())
&& (ball.get_y() + ball.get_r() < bar.get_bottom() - bar.get_height() / 3))
|| ((ball.get_y() - ball.get_r() <= bar.get_bottom())
&& (ball.get_y() - ball.get_r() > bar.get_top() - bar.get_height() / 3)))
{
if ((ball.get_x() > bar.get_left()) && (ball.get_x() < bar.get_right()))
{
ball.set_vy(-ball.get_vy());
return Ball_Hit_Bar;
}
else
{
/* do nothing */
}
}
else
{
/* do nothing */
}
break;
}
case Ball_Hit_Brick:
{
for (int i = 0; i < BRICK_NUM; i++)
{
if (brick.isBrickExist(i) == BRICK_EXIST)
{
if ((ball.get_y() <= brick.bricks_bottom(i) + ball.get_r())
&& (ball.get_x() >= brick.bricks_left(i))
&& (ball.get_x() <= brick.bricks_right(i)))
{
brick.setBrickExist(i, BRICK_NOT_EXIST);
ball.set_vy(-ball.get_vy());
return Ball_Hit_Brick;
}
else
{
/* do nothing */
}
}
else
{
/* do nothing */
}
}
break;
}
default:
{
break;
}
}
}
/* class game realization */
void GameBrickElimination::game_start()
{
ball.ball_init_v();
bar.bar_init_v();
brick.brick_init_v();
initgraph(GRAPH_WIDTH, GRAPH_HEIGHT);
BeginBatchDraw();
}
void GameBrickElimination::game_run()
{
while (1)
{
ball.ball_clean_v();
bar.bar_clean_v();
brick.brick_clean_v();
check_ball_hit(Ball_Hit_Wall);
ball.ball_move_v();
check_ball_hit(Ball_Hit_Bar);
bar.bar_move_v();
check_ball_hit(Ball_Hit_Brick);
ball.ball_show_v();
bar.bar_show_v();
brick.brick_show_v();
FlushBatchDraw();
Sleep(3);
}
}
void GameBrickElimination::game_over()
{
EndBatchDraw();
closegraph();
} |
5315705f2d97b891f40367750b4a117a26cdae9d | 7392a8aad0a287f98b17b8d6c567f6668c7a5726 | /src/problems/singleObjective/cec2005Competition/F13ShiftedExpandedGriewankRosenbrock.cpp | ae03be41c6511eb378f0b5f6c45e402791e9bae7 | [] | no_license | sergiosvieira/jMetalCpp | 5e51f3c0a192f22d611b4bddb410f42663ca40f7 | 8a08e080529b68ad1777fb3c9cdfd1c54f918538 | refs/heads/master | 2021-08-28T11:33:35.995740 | 2019-06-13T15:22:08 | 2019-06-13T15:22:08 | 98,532,814 | 3 | 2 | null | 2017-07-27T12:23:53 | 2017-07-27T12:23:53 | null | UTF-8 | C++ | false | false | 2,570 | cpp | F13ShiftedExpandedGriewankRosenbrock.cpp | // F13ShiftedExpandedGriewankRosenbrock.cpp
//
// Authors:
// Esteban Lรณpez-Camacho <esteban@lcc.uma.es>
// Antonio J. Nebro <antonio@lcc.uma.es>
//
// Copyright (c) 2014 Antonio J. Nebro
//
// This program 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 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <F13ShiftedExpandedGriewankRosenbrock.h>
// Fixed (class) parameters
const std::string F13ShiftedExpandedGriewankRosenbrock::FUNCTION_NAME = "Shifted Expanded Griewank's plus Rosenbrock's Function";
// TODO: Cambiar ruta
const std::string F13ShiftedExpandedGriewankRosenbrock::DEFAULT_FILE_DATA = "../../data/cec2005CompetitionResources/supportData/EF8F2_func_data.txt";
/**
* Constructor.
*/
F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias)
: F13ShiftedExpandedGriewankRosenbrock(dimension, bias, DEFAULT_FILE_DATA)
{
} // F13ShiftedExpandedGriewankRosenbrock
/**
* Constructor
*/
F13ShiftedExpandedGriewankRosenbrock::F13ShiftedExpandedGriewankRosenbrock(int dimension, double bias, std::string file_data)
: TestFunc(dimension, bias, FUNCTION_NAME)
{
// Note: dimension starts from 0
m_o = snew double[m_dimension];
m_z = snew double[m_dimension];
// Load the shifted global optimum
Benchmark::loadRowVectorFromFile(file_data, m_dimension, m_o);
// z = x - o + 1 = x - (o - 1)
// Do the "(o - 1)" part first
for (int i = 0 ; i < m_dimension ; i++)
{
m_o[i] -= 1.0;
}
} // F13ShiftedExpandedGriewankRosenbrock
/**
* Destructor
*/
F13ShiftedExpandedGriewankRosenbrock::~F13ShiftedExpandedGriewankRosenbrock()
{
delete [] m_o;
delete [] m_z;
} // ~F13ShiftedExpandedGriewankRosenbrock
/**
* Function body
*/
double F13ShiftedExpandedGriewankRosenbrock::f(double * x)
{
double result = 0.0;
Benchmark::shift(m_z, x, m_o, m_dimension);
result = Benchmark::F8F2(m_z, m_dimension);
result += m_bias;
return result;
}
|
2ba0b84127a12d80525f8cc828df4000736934cf | 588947fa105acc354e218bb28884b6ba6765e454 | /hari_sir_problems/Binary search tree/Binary search tree/bst_insert_delete.cpp | 0081e469394211c56fb8c0ef4584c659eb25a874 | [] | no_license | Divya37/my-projects | 79274d1ab8269573f70128f140b88ffefdd13c0f | ee0b51a88f5b65e19e31db6e37ac79eb89c50a6e | refs/heads/master | 2020-05-25T11:32:32.688066 | 2016-07-28T01:07:20 | 2016-07-28T01:07:20 | 64,334,154 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,020 | cpp | bst_insert_delete.cpp | //insertion and deletion in bst, least common ancestor, validate bst
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
struct node{
int data;
struct node *left;
struct node *right;
};
struct node *insert(struct node *head, int data){
if (head == NULL)
{
struct node *temp = (struct node *)malloc(sizeof(struct node));
temp->data = data;
temp->left = NULL;
temp->right = NULL;
return temp;
}
if (head->data > data)
{
head->left = insert(head->left, data);
}
else if (head->data <= data)
{
head->right = insert(head->right, data);
}
return head;
}
int issorted(int *arr, int size){
int i = 0;
for (i = 0; i < size-1; i++){
if (arr[i] > arr[i + 1])
return 0;
}
return 1;
}
void inorder_traversal(struct node *root, int *arr, int *index)
{
if (root == NULL)
return;
inorder_traversal(root->left, arr, index);
arr[*index] = root->data;
printf("%d\t", arr[*index]);
*index = *index + 1;
inorder_traversal(root->right, arr, index);
}
int inorder(struct node *root, int *arr){
int i = 0;
if (arr == NULL)
return 0;
inorder_traversal(root, arr, &i);
return issorted(arr, i);
}
struct node* min(struct node* head)
{
while (head->left != NULL) head = head->left;
return head;
}
//deletion functional
struct node *deletenode(struct node *head, int data){
if (head == NULL)
return head;
if (data < head->data){
head->left =deletenode(head->left, data);
}
if (data > head->data){
head->right=deletenode(head->right, data);
}
else{
//deleting leaf
if (head->left == NULL && head->right == NULL)
{
delete head;
head = NULL;
return head;
}
//deleting node with one leaf
if (head->left == NULL && head->right != NULL){
struct node *temp = head;
head= head->right;
delete temp;
return head;
}
if (head->left != NULL && head->right == NULL){
struct node *temp = head;
head = head->left;
delete temp;
return head;
}
//deleting node internal node
if (head->left != NULL && head->right != NULL)
{
struct node *temp = min(head->right);
head->data = temp->data;
head->right = deletenode(head->right, temp->data);
return head;
}
}
}
int validtree(struct node *head){
int *arr = (int *)malloc(sizeof(int) * 10);
return inorder(head, arr);
}
struct node *common_ans(struct node *head, int data1, int data2){
if (head==NULL)
return NULL;
if(head->data > data1 && head->data > data2){
return common_ans(head->left, data1, data2);
}
if(head->data < data1 && head->data < data2){
return common_ans(head->right, data1, data2);
}
return head;
}
void main(){
struct node *head = NULL;
head = insert(head, 15);
head = insert(head, 13);
head = insert(head, 18);
head = insert(head, 24);
head = insert(head, 11);
head = insert(head, 14);
head = deletenode(head, 11);
if (validtree(head))
printf("it is a valid bst");
struct node *t = common_ans(head, 11, 13);
printf("common ancestor = %d",t->data);
_getch();
} |
add733f929c9b2550db303e3f57f57a5abdea215 | dbc0e3582d65bcf9d8fba29d872d6407454f9e28 | /PRACTICE/minimum Deletions to make palindrome.cpp | 5826a46a2b18240f7d44f32b8314b2293e8efe14 | [] | no_license | sirAdarsh/CP-files | 0b7430e2146620535451e0ab8959f70047bd7ea2 | 8d411224293fec547a3caa2708eed351c977ebed | refs/heads/master | 2023-04-05T09:07:21.554361 | 2021-04-08T19:57:33 | 2021-04-08T19:57:33 | 297,582,418 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 686 | cpp | minimum Deletions to make palindrome.cpp | #include<bits/stdc++.h>
#define ll long long
using namespace std;
int minDeletions(string s, int i, int j, unordered_map<string,int> lookup){
string key = to_string(i) + "|" + to_string(j);
if(i>=j){
return 0;
}
if( lookup.find(key) == lookup.end() ){
if( s[i] == s[j] ){
lookup[key] = minDeletions(s,i+1,j-1,lookup);
}
else{
lookup[key] = 1 + min(minDeletions(s,i+1,j,lookup), minDeletions(s,i,j-1,lookup));
}
}
return lookup[key];
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s = "ACBCDBAA";
int n = s.size();
unordered_map<string, int> lookup;
cout << minDeletions(s,0,n-1,lookup)<<endl;
}
|
939d6a9f5c918dfbe6b89b0f8103cd929f18f0a6 | 36574fefeb2d65fec9f8c441b2e9a63b86b186dd | /mycode/DesignPattern/Singleton.cpp | f28d983c896a99cc52b7f5cddce0d9f4b18f4262 | [] | no_license | danny-wang/c-_primer_code | a896bded8b77345d14c67949265a75b2982ea670 | 3777928a4b1cba32e6eea77717925f139e3f1913 | refs/heads/master | 2021-01-13T15:10:35.464675 | 2017-11-19T11:36:06 | 2017-11-19T11:36:06 | 76,237,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 116 | cpp | Singleton.cpp | #include "Singleton.h"
singleton* singleton::p = new singleton();
singleton* singleton::instance()
{
return p;
} |
b70656d3e4540386a47b7fb84dc76f660122fffd | 11ef4bbb8086ba3b9678a2037d0c28baaf8c010e | /Source Code/server/binaries/chromium/gen/chrome/common/media_router/mojo/media_controller.mojom-shared-message-ids.h | dfe4b7daf02360e6b58f7b48cb0d300bc08cf21a | [] | no_license | lineCode/wasmview.github.io | 8f845ec6ba8a1ec85272d734efc80d2416a6e15b | eac4c69ea1cf0e9af9da5a500219236470541f9b | refs/heads/master | 2020-09-22T21:05:53.766548 | 2019-08-24T05:34:04 | 2019-08-24T05:34:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,573 | h | media_controller.mojom-shared-message-ids.h | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_MEDIA_ROUTER_MOJO_MEDIA_CONTROLLER_MOJOM_SHARED_MESSAGE_IDS_H_
#define CHROME_COMMON_MEDIA_ROUTER_MOJO_MEDIA_CONTROLLER_MOJOM_SHARED_MESSAGE_IDS_H_
#include <stdint.h>
namespace media_router {
namespace mojom {
namespace internal {
// The 894877342 value is based on sha256(salt + "MediaController1").
constexpr uint32_t kMediaController_Play_Name = 894877342;
// The 1406353202 value is based on sha256(salt + "MediaController2").
constexpr uint32_t kMediaController_Pause_Name = 1406353202;
// The 656930018 value is based on sha256(salt + "MediaController3").
constexpr uint32_t kMediaController_SetMute_Name = 656930018;
// The 35205391 value is based on sha256(salt + "MediaController4").
constexpr uint32_t kMediaController_SetVolume_Name = 35205391;
// The 1766087089 value is based on sha256(salt + "MediaController5").
constexpr uint32_t kMediaController_Seek_Name = 1766087089;
// The 347486951 value is based on sha256(salt + "MediaController6").
constexpr uint32_t kMediaController_ConnectHangoutsMediaRouteController_Name = 347486951;
// The 1076218588 value is based on sha256(salt + "HangoutsMediaRouteController1").
constexpr uint32_t kHangoutsMediaRouteController_SetLocalPresent_Name = 1076218588;
} // namespace internal
} // namespace mojom
} // namespace media_router
#endif // CHROME_COMMON_MEDIA_ROUTER_MOJO_MEDIA_CONTROLLER_MOJOM_SHARED_MESSAGE_IDS_H_ |
dc17f1e5ad5ec79252ef98016304cdf19a9ba4ed | 2398c2a717214be48f3d93da89ba11155263757b | /Sem_06/PPO/Lab_02/tests/LoadDataTest.h | 11cc1fd6d0efb9d008ecac2f7d914b8c13c83930 | [] | no_license | lieroz/University | 9af687787e3c468b34e2bfb8ffeadf44f2063bc7 | c7ee70e77e6426045fac6c5b43aab10e1ffdcddb | refs/heads/master | 2020-04-06T19:53:40.479191 | 2019-01-19T09:16:35 | 2019-01-19T09:16:35 | 68,386,115 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 398 | h | LoadDataTest.h | //
// Created by lieroz on 22.05.18.
//
#ifndef LOADDATATEST_H
#define LOADDATATEST_H
#include <QTest>
#include <ui/MainWindow.h>
class LoadDataTest : public QObject
{
Q_OBJECT
public:
explicit LoadDataTest(QObject *parent = nullptr);
private Q_SLOTS:
void testLoadRouteFromGpx();
void testLoadRouteFromPolyline();
private:
MainWindow window;
};
#endif // LOADDATATEST_H
|
d7730eac5fec920f92a41a449c9a8ecb0ee92305 | dd80a584130ef1a0333429ba76c1cee0eb40df73 | /external/chromium_org/third_party/libjingle/source/talk/session/media/channelmanager_unittest.cc | d0d380d3eb85da25cd72dde6fac16db381acff00 | [
"GPL-1.0-or-later",
"LGPL-2.0-or-later",
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"LGPL-2.1-or-later",
"BSL-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | karunmatharu/Android-4.4-Pay-by-Data | 466f4e169ede13c5835424c78e8c30ce58f885c1 | fcb778e92d4aad525ef7a995660580f948d40bc9 | refs/heads/master | 2021-03-24T13:33:01.721868 | 2017-02-18T17:48:49 | 2017-02-18T17:48:49 | 81,847,777 | 0 | 2 | MIT | 2020-03-09T00:02:12 | 2017-02-13T16:47:00 | null | UTF-8 | C++ | false | false | 24,309 | cc | channelmanager_unittest.cc | // libjingle
// Copyright 2008 Google Inc.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "talk/base/gunit.h"
#include "talk/base/logging.h"
#include "talk/base/thread.h"
#include "talk/media/base/fakecapturemanager.h"
#include "talk/media/base/fakemediaengine.h"
#include "talk/media/base/fakemediaprocessor.h"
#include "talk/media/base/nullvideorenderer.h"
#include "talk/media/devices/fakedevicemanager.h"
#include "talk/media/base/testutils.h"
#include "talk/p2p/base/fakesession.h"
#include "talk/session/media/channelmanager.h"
namespace cricket {
static const AudioCodec kAudioCodecs[] = {
AudioCodec(97, "voice", 1, 2, 3, 0),
AudioCodec(110, "CELT", 32000, 48000, 2, 0),
AudioCodec(111, "OPUS", 48000, 32000, 2, 0),
};
static const VideoCodec kVideoCodecs[] = {
VideoCodec(99, "H264", 100, 200, 300, 0),
VideoCodec(100, "VP8", 100, 200, 300, 0),
VideoCodec(96, "rtx", 100, 200, 300, 0),
};
class ChannelManagerTest : public testing::Test {
protected:
ChannelManagerTest() : fme_(NULL), fdm_(NULL), fcm_(NULL), cm_(NULL) {
}
virtual void SetUp() {
fme_ = new cricket::FakeMediaEngine();
fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs));
fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs));
fdme_ = new cricket::FakeDataEngine();
fdm_ = new cricket::FakeDeviceManager();
fcm_ = new cricket::FakeCaptureManager();
cm_ = new cricket::ChannelManager(
fme_, fdme_, fdm_, fcm_, talk_base::Thread::Current());
session_ = new cricket::FakeSession(true);
std::vector<std::string> in_device_list, out_device_list, vid_device_list;
in_device_list.push_back("audio-in1");
in_device_list.push_back("audio-in2");
out_device_list.push_back("audio-out1");
out_device_list.push_back("audio-out2");
vid_device_list.push_back("video-in1");
vid_device_list.push_back("video-in2");
fdm_->SetAudioInputDevices(in_device_list);
fdm_->SetAudioOutputDevices(out_device_list);
fdm_->SetVideoCaptureDevices(vid_device_list);
}
virtual void TearDown() {
delete session_;
delete cm_;
cm_ = NULL;
fdm_ = NULL;
fcm_ = NULL;
fdme_ = NULL;
fme_ = NULL;
}
talk_base::Thread worker_;
cricket::FakeMediaEngine* fme_;
cricket::FakeDataEngine* fdme_;
cricket::FakeDeviceManager* fdm_;
cricket::FakeCaptureManager* fcm_;
cricket::ChannelManager* cm_;
cricket::FakeSession* session_;
};
// Test that we startup/shutdown properly.
TEST_F(ChannelManagerTest, StartupShutdown) {
EXPECT_FALSE(cm_->initialized());
EXPECT_EQ(talk_base::Thread::Current(), cm_->worker_thread());
EXPECT_TRUE(cm_->Init());
EXPECT_TRUE(cm_->initialized());
cm_->Terminate();
EXPECT_FALSE(cm_->initialized());
}
// Test that we startup/shutdown properly with a worker thread.
TEST_F(ChannelManagerTest, StartupShutdownOnThread) {
worker_.Start();
EXPECT_FALSE(cm_->initialized());
EXPECT_EQ(talk_base::Thread::Current(), cm_->worker_thread());
EXPECT_TRUE(cm_->set_worker_thread(&worker_));
EXPECT_EQ(&worker_, cm_->worker_thread());
EXPECT_TRUE(cm_->Init());
EXPECT_TRUE(cm_->initialized());
// Setting the worker thread while initialized should fail.
EXPECT_FALSE(cm_->set_worker_thread(talk_base::Thread::Current()));
cm_->Terminate();
EXPECT_FALSE(cm_->initialized());
}
// Test that we fail to startup if we're given an unstarted thread.
TEST_F(ChannelManagerTest, StartupShutdownOnUnstartedThread) {
EXPECT_TRUE(cm_->set_worker_thread(&worker_));
EXPECT_FALSE(cm_->Init());
EXPECT_FALSE(cm_->initialized());
}
// Test that we can create and destroy a voice and video channel.
TEST_F(ChannelManagerTest, CreateDestroyChannels) {
EXPECT_TRUE(cm_->Init());
cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
session_, cricket::CN_AUDIO, false);
EXPECT_TRUE(voice_channel != NULL);
cricket::VideoChannel* video_channel =
cm_->CreateVideoChannel(session_, cricket::CN_VIDEO,
false, voice_channel);
EXPECT_TRUE(video_channel != NULL);
cricket::DataChannel* data_channel =
cm_->CreateDataChannel(session_, cricket::CN_DATA,
false, cricket::DCT_RTP);
EXPECT_TRUE(data_channel != NULL);
cm_->DestroyVideoChannel(video_channel);
cm_->DestroyVoiceChannel(voice_channel);
cm_->DestroyDataChannel(data_channel);
cm_->Terminate();
}
// Test that we can create and destroy a voice and video channel with a worker.
TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
worker_.Start();
EXPECT_TRUE(cm_->set_worker_thread(&worker_));
EXPECT_TRUE(cm_->Init());
delete session_;
session_ = new cricket::FakeSession(&worker_, true);
cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
session_, cricket::CN_AUDIO, false);
EXPECT_TRUE(voice_channel != NULL);
cricket::VideoChannel* video_channel =
cm_->CreateVideoChannel(session_, cricket::CN_VIDEO,
false, voice_channel);
EXPECT_TRUE(video_channel != NULL);
cricket::DataChannel* data_channel =
cm_->CreateDataChannel(session_, cricket::CN_DATA,
false, cricket::DCT_RTP);
EXPECT_TRUE(data_channel != NULL);
cm_->DestroyVideoChannel(video_channel);
cm_->DestroyVoiceChannel(voice_channel);
cm_->DestroyDataChannel(data_channel);
cm_->Terminate();
}
// Test that we fail to create a voice/video channel if the session is unable
// to create a cricket::TransportChannel
TEST_F(ChannelManagerTest, NoTransportChannelTest) {
EXPECT_TRUE(cm_->Init());
session_->set_fail_channel_creation(true);
// The test is useless unless the session does not fail creating
// cricket::TransportChannel.
ASSERT_TRUE(session_->CreateChannel(
"audio", "rtp", cricket::ICE_CANDIDATE_COMPONENT_RTP) == NULL);
cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
session_, cricket::CN_AUDIO, false);
EXPECT_TRUE(voice_channel == NULL);
cricket::VideoChannel* video_channel =
cm_->CreateVideoChannel(session_, cricket::CN_VIDEO,
false, voice_channel);
EXPECT_TRUE(video_channel == NULL);
cricket::DataChannel* data_channel =
cm_->CreateDataChannel(session_, cricket::CN_DATA,
false, cricket::DCT_RTP);
EXPECT_TRUE(data_channel == NULL);
cm_->Terminate();
}
// Test that SetDefaultVideoCodec passes through the right values.
TEST_F(ChannelManagerTest, SetDefaultVideoEncoderConfig) {
cricket::VideoCodec codec(96, "G264", 1280, 720, 60, 0);
cricket::VideoEncoderConfig config(codec, 1, 2);
EXPECT_TRUE(cm_->Init());
EXPECT_TRUE(cm_->SetDefaultVideoEncoderConfig(config));
EXPECT_EQ(config, fme_->default_video_encoder_config());
}
struct GetCapturerFrameSize : public sigslot::has_slots<> {
void OnVideoFrame(VideoCapturer* capturer, const VideoFrame* frame) {
width = frame->GetWidth();
height = frame->GetHeight();
}
GetCapturerFrameSize(VideoCapturer* capturer) : width(0), height(0) {
capturer->SignalVideoFrame.connect(this,
&GetCapturerFrameSize::OnVideoFrame);
static_cast<FakeVideoCapturer*>(capturer)->CaptureFrame();
}
size_t width;
size_t height;
};
TEST_F(ChannelManagerTest, DefaultCapturerAspectRatio) {
VideoCodec codec(100, "VP8", 640, 360, 30, 0);
VideoFormat format(640, 360, 33, FOURCC_ANY);
VideoEncoderConfig config(codec, 1, 2);
EXPECT_TRUE(cm_->Init());
// A capturer created before the default encoder config is set will have no
// set aspect ratio, so it'll be 4:3 (based on the fake video capture impl).
VideoCapturer* capturer = cm_->CreateVideoCapturer();
ASSERT_TRUE(capturer != NULL);
EXPECT_EQ(CS_RUNNING, capturer->Start(format));
GetCapturerFrameSize size(capturer);
EXPECT_EQ(640u, size.width);
EXPECT_EQ(480u, size.height);
delete capturer;
// Try again, but with the encoder config set to 16:9.
EXPECT_TRUE(cm_->SetDefaultVideoEncoderConfig(config));
capturer = cm_->CreateVideoCapturer();
ASSERT_TRUE(capturer != NULL);
EXPECT_EQ(CS_RUNNING, capturer->Start(format));
GetCapturerFrameSize cropped_size(capturer);
EXPECT_EQ(640u, cropped_size.width);
EXPECT_EQ(360u, cropped_size.height);
delete capturer;
}
// Test that SetDefaultVideoCodec passes through the right values.
TEST_F(ChannelManagerTest, SetDefaultVideoCodecBeforeInit) {
cricket::VideoCodec codec(96, "G264", 1280, 720, 60, 0);
cricket::VideoEncoderConfig config(codec, 1, 2);
EXPECT_TRUE(cm_->SetDefaultVideoEncoderConfig(config));
EXPECT_TRUE(cm_->Init());
EXPECT_EQ(config, fme_->default_video_encoder_config());
}
TEST_F(ChannelManagerTest, SetAudioOptionsBeforeInit) {
// Test that values that we set before Init are applied.
AudioOptions options;
options.auto_gain_control.Set(true);
options.echo_cancellation.Set(false);
EXPECT_TRUE(cm_->SetAudioOptions("audio-in1", "audio-out1", options));
std::string audio_in, audio_out;
AudioOptions set_options;
// Check options before Init.
EXPECT_TRUE(cm_->GetAudioOptions(&audio_in, &audio_out, &set_options));
EXPECT_EQ("audio-in1", audio_in);
EXPECT_EQ("audio-out1", audio_out);
EXPECT_EQ(options, set_options);
EXPECT_TRUE(cm_->Init());
// Check options after Init.
EXPECT_TRUE(cm_->GetAudioOptions(&audio_in, &audio_out, &set_options));
EXPECT_EQ("audio-in1", audio_in);
EXPECT_EQ("audio-out1", audio_out);
EXPECT_EQ(options, set_options);
// At this point, the media engine should also be initialized.
EXPECT_EQ(options, fme_->audio_options());
EXPECT_EQ(cricket::MediaEngineInterface::kDefaultAudioDelayOffset,
fme_->audio_delay_offset());
}
TEST_F(ChannelManagerTest, GetAudioOptionsWithNullParameters) {
std::string audio_in, audio_out;
AudioOptions options;
options.echo_cancellation.Set(true);
EXPECT_TRUE(cm_->SetAudioOptions("audio-in2", "audio-out2", options));
EXPECT_TRUE(cm_->GetAudioOptions(&audio_in, NULL, NULL));
EXPECT_EQ("audio-in2", audio_in);
EXPECT_TRUE(cm_->GetAudioOptions(NULL, &audio_out, NULL));
EXPECT_EQ("audio-out2", audio_out);
AudioOptions out_options;
EXPECT_TRUE(cm_->GetAudioOptions(NULL, NULL, &out_options));
bool echo_cancellation = false;
EXPECT_TRUE(out_options.echo_cancellation.Get(&echo_cancellation));
EXPECT_TRUE(echo_cancellation);
}
TEST_F(ChannelManagerTest, SetAudioOptions) {
// Test initial state.
EXPECT_TRUE(cm_->Init());
EXPECT_EQ(std::string(cricket::DeviceManagerInterface::kDefaultDeviceName),
fme_->audio_in_device());
EXPECT_EQ(std::string(cricket::DeviceManagerInterface::kDefaultDeviceName),
fme_->audio_out_device());
EXPECT_EQ(cricket::MediaEngineInterface::kDefaultAudioDelayOffset,
fme_->audio_delay_offset());
// Test setting specific values.
AudioOptions options;
options.auto_gain_control.Set(true);
EXPECT_TRUE(cm_->SetAudioOptions("audio-in1", "audio-out1", options));
EXPECT_EQ("audio-in1", fme_->audio_in_device());
EXPECT_EQ("audio-out1", fme_->audio_out_device());
bool auto_gain_control = false;
EXPECT_TRUE(
fme_->audio_options().auto_gain_control.Get(&auto_gain_control));
EXPECT_TRUE(auto_gain_control);
EXPECT_EQ(cricket::MediaEngineInterface::kDefaultAudioDelayOffset,
fme_->audio_delay_offset());
// Test setting bad values.
EXPECT_FALSE(cm_->SetAudioOptions("audio-in9", "audio-out2", options));
}
TEST_F(ChannelManagerTest, SetCaptureDeviceBeforeInit) {
// Test that values that we set before Init are applied.
EXPECT_TRUE(cm_->SetCaptureDevice("video-in2"));
EXPECT_TRUE(cm_->Init());
EXPECT_EQ("video-in2", cm_->video_device_name());
}
TEST_F(ChannelManagerTest, GetCaptureDeviceBeforeInit) {
std::string video_in;
// Test that GetCaptureDevice works before Init.
EXPECT_TRUE(cm_->SetCaptureDevice("video-in1"));
EXPECT_TRUE(cm_->GetCaptureDevice(&video_in));
EXPECT_EQ("video-in1", video_in);
// Test that options set before Init can be gotten after Init.
EXPECT_TRUE(cm_->SetCaptureDevice("video-in2"));
EXPECT_TRUE(cm_->Init());
EXPECT_TRUE(cm_->GetCaptureDevice(&video_in));
EXPECT_EQ("video-in2", video_in);
}
TEST_F(ChannelManagerTest, SetCaptureDevice) {
// Test setting defaults.
EXPECT_TRUE(cm_->Init());
EXPECT_TRUE(cm_->SetCaptureDevice("")); // will use DeviceManager default
EXPECT_EQ("video-in1", cm_->video_device_name());
// Test setting specific values.
EXPECT_TRUE(cm_->SetCaptureDevice("video-in2"));
EXPECT_EQ("video-in2", cm_->video_device_name());
// TODO(juberti): Add test for invalid value here.
}
// Test unplugging and plugging back the preferred devices. When the preferred
// device is unplugged, we fall back to the default device. When the preferred
// device is plugged back, we use it.
TEST_F(ChannelManagerTest, SetAudioOptionsUnplugPlug) {
// Set preferences "audio-in1" and "audio-out1" before init.
AudioOptions options;
EXPECT_TRUE(cm_->SetAudioOptions("audio-in1", "audio-out1", options));
// Unplug device "audio-in1" and "audio-out1".
std::vector<std::string> in_device_list, out_device_list;
in_device_list.push_back("audio-in2");
out_device_list.push_back("audio-out2");
fdm_->SetAudioInputDevices(in_device_list);
fdm_->SetAudioOutputDevices(out_device_list);
// Init should fall back to default devices.
EXPECT_TRUE(cm_->Init());
// The media engine should use the default.
EXPECT_EQ("", fme_->audio_in_device());
EXPECT_EQ("", fme_->audio_out_device());
// The channel manager keeps the preferences "audio-in1" and "audio-out1".
std::string audio_in, audio_out;
EXPECT_TRUE(cm_->GetAudioOptions(&audio_in, &audio_out, NULL));
EXPECT_EQ("audio-in1", audio_in);
EXPECT_EQ("audio-out1", audio_out);
cm_->Terminate();
// Plug devices "audio-in2" and "audio-out2" back.
in_device_list.push_back("audio-in1");
out_device_list.push_back("audio-out1");
fdm_->SetAudioInputDevices(in_device_list);
fdm_->SetAudioOutputDevices(out_device_list);
// Init again. The preferences, "audio-in2" and "audio-out2", are used.
EXPECT_TRUE(cm_->Init());
EXPECT_EQ("audio-in1", fme_->audio_in_device());
EXPECT_EQ("audio-out1", fme_->audio_out_device());
EXPECT_TRUE(cm_->GetAudioOptions(&audio_in, &audio_out, NULL));
EXPECT_EQ("audio-in1", audio_in);
EXPECT_EQ("audio-out1", audio_out);
}
// We have one camera. Unplug it, fall back to no camera.
TEST_F(ChannelManagerTest, SetCaptureDeviceUnplugPlugOneCamera) {
// Set preferences "video-in1" before init.
std::vector<std::string> vid_device_list;
vid_device_list.push_back("video-in1");
fdm_->SetVideoCaptureDevices(vid_device_list);
EXPECT_TRUE(cm_->SetCaptureDevice("video-in1"));
// Unplug "video-in1".
vid_device_list.clear();
fdm_->SetVideoCaptureDevices(vid_device_list);
// Init should fall back to avatar.
EXPECT_TRUE(cm_->Init());
// The media engine should use no camera.
EXPECT_EQ("", cm_->video_device_name());
// The channel manager keeps the user preference "video-in".
std::string video_in;
EXPECT_TRUE(cm_->GetCaptureDevice(&video_in));
EXPECT_EQ("video-in1", video_in);
cm_->Terminate();
// Plug device "video-in1" back.
vid_device_list.push_back("video-in1");
fdm_->SetVideoCaptureDevices(vid_device_list);
// Init again. The user preferred device, "video-in1", is used.
EXPECT_TRUE(cm_->Init());
EXPECT_EQ("video-in1", cm_->video_device_name());
EXPECT_TRUE(cm_->GetCaptureDevice(&video_in));
EXPECT_EQ("video-in1", video_in);
}
// We have multiple cameras. Unplug the preferred, fall back to another camera.
TEST_F(ChannelManagerTest, SetCaptureDeviceUnplugPlugTwoDevices) {
// Set video device to "video-in1" before init.
EXPECT_TRUE(cm_->SetCaptureDevice("video-in1"));
// Unplug device "video-in1".
std::vector<std::string> vid_device_list;
vid_device_list.push_back("video-in2");
fdm_->SetVideoCaptureDevices(vid_device_list);
// Init should fall back to default device "video-in2".
EXPECT_TRUE(cm_->Init());
// The media engine should use the default device "video-in2".
EXPECT_EQ("video-in2", cm_->video_device_name());
// The channel manager keeps the user preference "video-in".
std::string video_in;
EXPECT_TRUE(cm_->GetCaptureDevice(&video_in));
EXPECT_EQ("video-in1", video_in);
cm_->Terminate();
// Plug device "video-in1" back.
vid_device_list.push_back("video-in1");
fdm_->SetVideoCaptureDevices(vid_device_list);
// Init again. The user preferred device, "video-in1", is used.
EXPECT_TRUE(cm_->Init());
EXPECT_EQ("video-in1", cm_->video_device_name());
EXPECT_TRUE(cm_->GetCaptureDevice(&video_in));
EXPECT_EQ("video-in1", video_in);
}
TEST_F(ChannelManagerTest, GetCaptureDevice) {
std::string video_in;
// Test setting/getting defaults.
EXPECT_TRUE(cm_->Init());
EXPECT_TRUE(cm_->SetCaptureDevice(""));
EXPECT_TRUE(cm_->GetCaptureDevice(&video_in));
EXPECT_EQ("video-in1", video_in);
// Test setting/getting specific values.
EXPECT_TRUE(cm_->SetCaptureDevice("video-in2"));
EXPECT_TRUE(cm_->GetCaptureDevice(&video_in));
EXPECT_EQ("video-in2", video_in);
}
TEST_F(ChannelManagerTest, GetSetOutputVolumeBeforeInit) {
int level;
// Before init, SetOutputVolume() remembers the volume but does not change the
// volume of the engine. GetOutputVolume() should fail.
EXPECT_EQ(-1, fme_->output_volume());
EXPECT_FALSE(cm_->GetOutputVolume(&level));
EXPECT_FALSE(cm_->SetOutputVolume(-1)); // Invalid volume.
EXPECT_TRUE(cm_->SetOutputVolume(99));
EXPECT_EQ(-1, fme_->output_volume());
// Init() will apply the remembered volume.
EXPECT_TRUE(cm_->Init());
EXPECT_TRUE(cm_->GetOutputVolume(&level));
EXPECT_EQ(99, level);
EXPECT_EQ(level, fme_->output_volume());
EXPECT_TRUE(cm_->SetOutputVolume(60));
EXPECT_TRUE(cm_->GetOutputVolume(&level));
EXPECT_EQ(60, level);
EXPECT_EQ(level, fme_->output_volume());
}
TEST_F(ChannelManagerTest, GetSetOutputVolume) {
int level;
EXPECT_TRUE(cm_->Init());
EXPECT_TRUE(cm_->GetOutputVolume(&level));
EXPECT_EQ(level, fme_->output_volume());
EXPECT_FALSE(cm_->SetOutputVolume(-1)); // Invalid volume.
EXPECT_TRUE(cm_->SetOutputVolume(60));
EXPECT_EQ(60, fme_->output_volume());
EXPECT_TRUE(cm_->GetOutputVolume(&level));
EXPECT_EQ(60, level);
}
// Test that a value set before Init is applied properly.
TEST_F(ChannelManagerTest, SetLocalRendererBeforeInit) {
cricket::NullVideoRenderer renderer;
EXPECT_TRUE(cm_->SetLocalRenderer(&renderer));
EXPECT_TRUE(cm_->Init());
EXPECT_EQ(&renderer, fme_->local_renderer());
}
// Test that a value set after init is passed through properly.
TEST_F(ChannelManagerTest, SetLocalRenderer) {
cricket::NullVideoRenderer renderer;
EXPECT_TRUE(cm_->Init());
EXPECT_TRUE(cm_->SetLocalRenderer(&renderer));
EXPECT_EQ(&renderer, fme_->local_renderer());
}
// Test that logging options set before Init are applied properly,
// and retained even after Init.
TEST_F(ChannelManagerTest, SetLoggingBeforeInit) {
cm_->SetVoiceLogging(talk_base::LS_INFO, "test-voice");
cm_->SetVideoLogging(talk_base::LS_VERBOSE, "test-video");
EXPECT_EQ(talk_base::LS_INFO, fme_->voice_loglevel());
EXPECT_STREQ("test-voice", fme_->voice_logfilter().c_str());
EXPECT_EQ(talk_base::LS_VERBOSE, fme_->video_loglevel());
EXPECT_STREQ("test-video", fme_->video_logfilter().c_str());
EXPECT_TRUE(cm_->Init());
EXPECT_EQ(talk_base::LS_INFO, fme_->voice_loglevel());
EXPECT_STREQ("test-voice", fme_->voice_logfilter().c_str());
EXPECT_EQ(talk_base::LS_VERBOSE, fme_->video_loglevel());
EXPECT_STREQ("test-video", fme_->video_logfilter().c_str());
}
// Test that logging options set after Init are applied properly.
TEST_F(ChannelManagerTest, SetLogging) {
EXPECT_TRUE(cm_->Init());
cm_->SetVoiceLogging(talk_base::LS_INFO, "test-voice");
cm_->SetVideoLogging(talk_base::LS_VERBOSE, "test-video");
EXPECT_EQ(talk_base::LS_INFO, fme_->voice_loglevel());
EXPECT_STREQ("test-voice", fme_->voice_logfilter().c_str());
EXPECT_EQ(talk_base::LS_VERBOSE, fme_->video_loglevel());
EXPECT_STREQ("test-video", fme_->video_logfilter().c_str());
}
// Test that the Video/Voice Processors register and unregister
TEST_F(ChannelManagerTest, RegisterProcessors) {
cricket::FakeMediaProcessor fmp;
EXPECT_TRUE(cm_->Init());
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_TX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_RX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_TX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_RX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_TX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_RX));
EXPECT_TRUE(cm_->RegisterVoiceProcessor(1,
&fmp,
cricket::MPD_RX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_TX));
EXPECT_TRUE(fme_->voice_processor_registered(cricket::MPD_RX));
EXPECT_TRUE(cm_->UnregisterVoiceProcessor(1,
&fmp,
cricket::MPD_RX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_TX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_RX));
EXPECT_TRUE(cm_->RegisterVoiceProcessor(1,
&fmp,
cricket::MPD_TX));
EXPECT_TRUE(fme_->voice_processor_registered(cricket::MPD_TX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_RX));
EXPECT_TRUE(cm_->UnregisterVoiceProcessor(1,
&fmp,
cricket::MPD_TX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_TX));
EXPECT_FALSE(fme_->voice_processor_registered(cricket::MPD_RX));
}
TEST_F(ChannelManagerTest, SetVideoRtxEnabled) {
std::vector<VideoCodec> codecs;
const VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0);
// By default RTX is disabled.
cm_->GetSupportedVideoCodecs(&codecs);
EXPECT_FALSE(ContainsMatchingCodec(codecs, rtx_codec));
// Enable and check.
EXPECT_TRUE(cm_->SetVideoRtxEnabled(true));
cm_->GetSupportedVideoCodecs(&codecs);
EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec));
// Disable and check.
EXPECT_TRUE(cm_->SetVideoRtxEnabled(false));
cm_->GetSupportedVideoCodecs(&codecs);
EXPECT_FALSE(ContainsMatchingCodec(codecs, rtx_codec));
// Cannot toggle rtx after initialization.
EXPECT_TRUE(cm_->Init());
EXPECT_FALSE(cm_->SetVideoRtxEnabled(true));
EXPECT_FALSE(cm_->SetVideoRtxEnabled(false));
// Can set again after terminate.
cm_->Terminate();
EXPECT_TRUE(cm_->SetVideoRtxEnabled(true));
cm_->GetSupportedVideoCodecs(&codecs);
EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec));
}
} // namespace cricket
|
c3825b92ee351c6ae5ab393a8e549c075fcf8ff1 | 346c17a1b3feba55e3c8a0513ae97a4282399c05 | /CodeGenere/photogram/cEqAppui_Droite_NoDist__PTInc_M2CDRad5.cpp | d6c17a4fe88339bf520cb1bef558b6149f56d5a2 | [
"LicenseRef-scancode-cecill-b-en"
] | permissive | micmacIGN/micmac | af4ab545c3e1d9c04b4c83ac7e926a3ff7707df6 | 6e5721ddc65cb9b480e53b5914e2e2391d5ae722 | refs/heads/master | 2023-09-01T15:06:30.805394 | 2023-07-25T09:18:43 | 2023-08-30T11:35:30 | 74,707,998 | 603 | 156 | NOASSERTION | 2023-06-19T12:53:13 | 2016-11-24T22:09:54 | C++ | UTF-8 | C++ | false | false | 13,649 | cpp | cEqAppui_Droite_NoDist__PTInc_M2CDRad5.cpp | // File Automatically generated by eLiSe
#include "StdAfx.h"
#include "cEqAppui_Droite_NoDist__PTInc_M2CDRad5.h"
cEqAppui_Droite_NoDist__PTInc_M2CDRad5::cEqAppui_Droite_NoDist__PTInc_M2CDRad5():
cElCompiledFonc(1)
{
AddIntRef (cIncIntervale("Intr",0,10));
AddIntRef (cIncIntervale("Orient",10,16));
AddIntRef (cIncIntervale("Tmp_PTer",16,19));
Close(false);
}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::ComputeVal()
{
double tmp0_ = mCompCoord[10];
double tmp1_ = mCompCoord[11];
double tmp2_ = cos(tmp1_);
double tmp3_ = sin(tmp0_);
double tmp4_ = cos(tmp0_);
double tmp5_ = sin(tmp1_);
double tmp6_ = mCompCoord[12];
double tmp7_ = mCompCoord[16];
double tmp8_ = mCompCoord[13];
double tmp9_ = tmp7_-tmp8_;
double tmp10_ = sin(tmp6_);
double tmp11_ = -(tmp10_);
double tmp12_ = -(tmp5_);
double tmp13_ = cos(tmp6_);
double tmp14_ = mCompCoord[17];
double tmp15_ = mCompCoord[14];
double tmp16_ = tmp14_-tmp15_;
double tmp17_ = mCompCoord[18];
double tmp18_ = mCompCoord[15];
double tmp19_ = tmp17_-tmp18_;
double tmp20_ = -(tmp3_);
double tmp21_ = tmp4_*tmp12_;
double tmp22_ = tmp3_*tmp12_;
double tmp23_ = tmp20_*tmp11_;
double tmp24_ = tmp21_*tmp13_;
double tmp25_ = tmp23_+tmp24_;
double tmp26_ = (tmp25_)*(tmp9_);
double tmp27_ = tmp4_*tmp11_;
double tmp28_ = tmp22_*tmp13_;
double tmp29_ = tmp27_+tmp28_;
double tmp30_ = (tmp29_)*(tmp16_);
double tmp31_ = tmp26_+tmp30_;
double tmp32_ = tmp2_*tmp13_;
double tmp33_ = tmp32_*(tmp19_);
double tmp34_ = tmp31_+tmp33_;
double tmp35_ = tmp4_*tmp2_;
double tmp36_ = tmp35_*(tmp9_);
double tmp37_ = tmp3_*tmp2_;
double tmp38_ = tmp37_*(tmp16_);
double tmp39_ = tmp36_+tmp38_;
double tmp40_ = tmp5_*(tmp19_);
double tmp41_ = tmp39_+tmp40_;
double tmp42_ = (tmp41_)/(tmp34_);
double tmp43_ = tmp20_*tmp13_;
double tmp44_ = tmp21_*tmp10_;
double tmp45_ = tmp43_+tmp44_;
double tmp46_ = (tmp45_)*(tmp9_);
double tmp47_ = tmp4_*tmp13_;
double tmp48_ = tmp22_*tmp10_;
double tmp49_ = tmp47_+tmp48_;
double tmp50_ = (tmp49_)*(tmp16_);
double tmp51_ = tmp46_+tmp50_;
double tmp52_ = tmp2_*tmp10_;
double tmp53_ = tmp52_*(tmp19_);
double tmp54_ = tmp51_+tmp53_;
double tmp55_ = (tmp54_)/(tmp34_);
mVal[0] = (mLocXIm-cos(mLocYIm)*(mLocNDP0_x+mLocNDdx_x*(tmp42_)+mLocNDdy_x*(tmp55_))-sin(mLocYIm)*(mLocNDP0_y+mLocNDdx_y*(tmp42_)+mLocNDdy_y*(tmp55_)))*mLocScNorm;
}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::ComputeValDeriv()
{
double tmp0_ = mCompCoord[10];
double tmp1_ = mCompCoord[11];
double tmp2_ = cos(tmp1_);
double tmp3_ = sin(tmp0_);
double tmp4_ = cos(tmp0_);
double tmp5_ = sin(tmp1_);
double tmp6_ = mCompCoord[12];
double tmp7_ = mCompCoord[16];
double tmp8_ = mCompCoord[13];
double tmp9_ = tmp7_-tmp8_;
double tmp10_ = sin(tmp6_);
double tmp11_ = -(tmp10_);
double tmp12_ = -(tmp5_);
double tmp13_ = cos(tmp6_);
double tmp14_ = mCompCoord[17];
double tmp15_ = mCompCoord[14];
double tmp16_ = tmp14_-tmp15_;
double tmp17_ = mCompCoord[18];
double tmp18_ = mCompCoord[15];
double tmp19_ = tmp17_-tmp18_;
double tmp20_ = -(tmp3_);
double tmp21_ = tmp4_*tmp12_;
double tmp22_ = tmp3_*tmp12_;
double tmp23_ = tmp20_*tmp11_;
double tmp24_ = tmp21_*tmp13_;
double tmp25_ = tmp23_+tmp24_;
double tmp26_ = (tmp25_)*(tmp9_);
double tmp27_ = tmp4_*tmp11_;
double tmp28_ = tmp22_*tmp13_;
double tmp29_ = tmp27_+tmp28_;
double tmp30_ = (tmp29_)*(tmp16_);
double tmp31_ = tmp26_+tmp30_;
double tmp32_ = tmp2_*tmp13_;
double tmp33_ = tmp32_*(tmp19_);
double tmp34_ = tmp31_+tmp33_;
double tmp35_ = tmp4_*tmp2_;
double tmp36_ = tmp35_*(tmp9_);
double tmp37_ = tmp3_*tmp2_;
double tmp38_ = tmp37_*(tmp16_);
double tmp39_ = tmp36_+tmp38_;
double tmp40_ = tmp5_*(tmp19_);
double tmp41_ = tmp39_+tmp40_;
double tmp42_ = (tmp41_)/(tmp34_);
double tmp43_ = tmp20_*tmp13_;
double tmp44_ = tmp21_*tmp10_;
double tmp45_ = tmp43_+tmp44_;
double tmp46_ = (tmp45_)*(tmp9_);
double tmp47_ = tmp4_*tmp13_;
double tmp48_ = tmp22_*tmp10_;
double tmp49_ = tmp47_+tmp48_;
double tmp50_ = (tmp49_)*(tmp16_);
double tmp51_ = tmp46_+tmp50_;
double tmp52_ = tmp2_*tmp10_;
double tmp53_ = tmp52_*(tmp19_);
double tmp54_ = tmp51_+tmp53_;
double tmp55_ = (tmp54_)/(tmp34_);
double tmp56_ = -(1);
double tmp57_ = tmp56_*tmp3_;
double tmp58_ = -(tmp4_);
double tmp59_ = tmp57_*tmp12_;
double tmp60_ = tmp58_*tmp11_;
double tmp61_ = tmp59_*tmp13_;
double tmp62_ = tmp60_+tmp61_;
double tmp63_ = (tmp62_)*(tmp9_);
double tmp64_ = tmp57_*tmp11_;
double tmp65_ = tmp64_+tmp24_;
double tmp66_ = (tmp65_)*(tmp16_);
double tmp67_ = tmp63_+tmp66_;
double tmp68_ = ElSquare(tmp34_);
double tmp69_ = cos(mLocYIm);
double tmp70_ = tmp57_*tmp2_;
double tmp71_ = tmp70_*(tmp9_);
double tmp72_ = tmp35_*(tmp16_);
double tmp73_ = tmp71_+tmp72_;
double tmp74_ = (tmp73_)*(tmp34_);
double tmp75_ = (tmp41_)*(tmp67_);
double tmp76_ = tmp74_-tmp75_;
double tmp77_ = (tmp76_)/tmp68_;
double tmp78_ = tmp58_*tmp13_;
double tmp79_ = tmp59_*tmp10_;
double tmp80_ = tmp78_+tmp79_;
double tmp81_ = (tmp80_)*(tmp9_);
double tmp82_ = tmp57_*tmp13_;
double tmp83_ = tmp82_+tmp44_;
double tmp84_ = (tmp83_)*(tmp16_);
double tmp85_ = tmp81_+tmp84_;
double tmp86_ = (tmp85_)*(tmp34_);
double tmp87_ = (tmp54_)*(tmp67_);
double tmp88_ = tmp86_-tmp87_;
double tmp89_ = (tmp88_)/tmp68_;
double tmp90_ = sin(mLocYIm);
double tmp91_ = tmp56_*tmp5_;
double tmp92_ = -(tmp2_);
double tmp93_ = tmp92_*tmp4_;
double tmp94_ = tmp92_*tmp3_;
double tmp95_ = tmp93_*tmp13_;
double tmp96_ = tmp95_*(tmp9_);
double tmp97_ = tmp94_*tmp13_;
double tmp98_ = tmp97_*(tmp16_);
double tmp99_ = tmp96_+tmp98_;
double tmp100_ = tmp91_*tmp13_;
double tmp101_ = tmp100_*(tmp19_);
double tmp102_ = tmp99_+tmp101_;
double tmp103_ = tmp91_*tmp4_;
double tmp104_ = tmp103_*(tmp9_);
double tmp105_ = tmp91_*tmp3_;
double tmp106_ = tmp105_*(tmp16_);
double tmp107_ = tmp104_+tmp106_;
double tmp108_ = tmp2_*(tmp19_);
double tmp109_ = tmp107_+tmp108_;
double tmp110_ = (tmp109_)*(tmp34_);
double tmp111_ = (tmp41_)*(tmp102_);
double tmp112_ = tmp110_-tmp111_;
double tmp113_ = (tmp112_)/tmp68_;
double tmp114_ = tmp93_*tmp10_;
double tmp115_ = tmp114_*(tmp9_);
double tmp116_ = tmp94_*tmp10_;
double tmp117_ = tmp116_*(tmp16_);
double tmp118_ = tmp115_+tmp117_;
double tmp119_ = tmp91_*tmp10_;
double tmp120_ = tmp119_*(tmp19_);
double tmp121_ = tmp118_+tmp120_;
double tmp122_ = (tmp121_)*(tmp34_);
double tmp123_ = (tmp54_)*(tmp102_);
double tmp124_ = tmp122_-tmp123_;
double tmp125_ = (tmp124_)/tmp68_;
double tmp126_ = -(tmp13_);
double tmp127_ = tmp56_*tmp10_;
double tmp128_ = tmp126_*tmp20_;
double tmp129_ = tmp127_*tmp21_;
double tmp130_ = tmp128_+tmp129_;
double tmp131_ = (tmp130_)*(tmp9_);
double tmp132_ = tmp126_*tmp4_;
double tmp133_ = tmp127_*tmp22_;
double tmp134_ = tmp132_+tmp133_;
double tmp135_ = (tmp134_)*(tmp16_);
double tmp136_ = tmp131_+tmp135_;
double tmp137_ = tmp127_*tmp2_;
double tmp138_ = tmp137_*(tmp19_);
double tmp139_ = tmp136_+tmp138_;
double tmp140_ = (tmp41_)*(tmp139_);
double tmp141_ = -(tmp140_);
double tmp142_ = tmp141_/tmp68_;
double tmp143_ = tmp127_*tmp20_;
double tmp144_ = tmp13_*tmp21_;
double tmp145_ = tmp143_+tmp144_;
double tmp146_ = (tmp145_)*(tmp9_);
double tmp147_ = tmp127_*tmp4_;
double tmp148_ = tmp13_*tmp22_;
double tmp149_ = tmp147_+tmp148_;
double tmp150_ = (tmp149_)*(tmp16_);
double tmp151_ = tmp146_+tmp150_;
double tmp152_ = tmp13_*tmp2_;
double tmp153_ = tmp152_*(tmp19_);
double tmp154_ = tmp151_+tmp153_;
double tmp155_ = (tmp154_)*(tmp34_);
double tmp156_ = (tmp54_)*(tmp139_);
double tmp157_ = tmp155_-tmp156_;
double tmp158_ = (tmp157_)/tmp68_;
double tmp159_ = tmp56_*(tmp25_);
double tmp160_ = tmp56_*tmp35_;
double tmp161_ = tmp160_*(tmp34_);
double tmp162_ = (tmp41_)*tmp159_;
double tmp163_ = tmp161_-tmp162_;
double tmp164_ = (tmp163_)/tmp68_;
double tmp165_ = tmp56_*(tmp45_);
double tmp166_ = tmp165_*(tmp34_);
double tmp167_ = (tmp54_)*tmp159_;
double tmp168_ = tmp166_-tmp167_;
double tmp169_ = (tmp168_)/tmp68_;
double tmp170_ = tmp56_*(tmp29_);
double tmp171_ = tmp56_*tmp37_;
double tmp172_ = tmp171_*(tmp34_);
double tmp173_ = (tmp41_)*tmp170_;
double tmp174_ = tmp172_-tmp173_;
double tmp175_ = (tmp174_)/tmp68_;
double tmp176_ = tmp56_*(tmp49_);
double tmp177_ = tmp176_*(tmp34_);
double tmp178_ = (tmp54_)*tmp170_;
double tmp179_ = tmp177_-tmp178_;
double tmp180_ = (tmp179_)/tmp68_;
double tmp181_ = tmp56_*tmp32_;
double tmp182_ = tmp91_*(tmp34_);
double tmp183_ = (tmp41_)*tmp181_;
double tmp184_ = tmp182_-tmp183_;
double tmp185_ = (tmp184_)/tmp68_;
double tmp186_ = tmp56_*tmp52_;
double tmp187_ = tmp186_*(tmp34_);
double tmp188_ = (tmp54_)*tmp181_;
double tmp189_ = tmp187_-tmp188_;
double tmp190_ = (tmp189_)/tmp68_;
double tmp191_ = tmp35_*(tmp34_);
double tmp192_ = (tmp41_)*(tmp25_);
double tmp193_ = tmp191_-tmp192_;
double tmp194_ = (tmp193_)/tmp68_;
double tmp195_ = (tmp45_)*(tmp34_);
double tmp196_ = (tmp54_)*(tmp25_);
double tmp197_ = tmp195_-tmp196_;
double tmp198_ = (tmp197_)/tmp68_;
double tmp199_ = tmp37_*(tmp34_);
double tmp200_ = (tmp41_)*(tmp29_);
double tmp201_ = tmp199_-tmp200_;
double tmp202_ = (tmp201_)/tmp68_;
double tmp203_ = (tmp49_)*(tmp34_);
double tmp204_ = (tmp54_)*(tmp29_);
double tmp205_ = tmp203_-tmp204_;
double tmp206_ = (tmp205_)/tmp68_;
double tmp207_ = tmp5_*(tmp34_);
double tmp208_ = (tmp41_)*tmp32_;
double tmp209_ = tmp207_-tmp208_;
double tmp210_ = (tmp209_)/tmp68_;
double tmp211_ = tmp52_*(tmp34_);
double tmp212_ = (tmp54_)*tmp32_;
double tmp213_ = tmp211_-tmp212_;
double tmp214_ = (tmp213_)/tmp68_;
mVal[0] = (mLocXIm-tmp69_*(mLocNDP0_x+mLocNDdx_x*(tmp42_)+mLocNDdy_x*(tmp55_))-tmp90_*(mLocNDP0_y+mLocNDdx_y*(tmp42_)+mLocNDdy_y*(tmp55_)))*mLocScNorm;
mCompDer[0][0] = 0;
mCompDer[0][1] = 0;
mCompDer[0][2] = 0;
mCompDer[0][3] = 0;
mCompDer[0][4] = 0;
mCompDer[0][5] = 0;
mCompDer[0][6] = 0;
mCompDer[0][7] = 0;
mCompDer[0][8] = 0;
mCompDer[0][9] = 0;
mCompDer[0][10] = (-(((tmp77_)*mLocNDdx_x+(tmp89_)*mLocNDdy_x)*tmp69_)-((tmp77_)*mLocNDdx_y+(tmp89_)*mLocNDdy_y)*tmp90_)*mLocScNorm;
mCompDer[0][11] = (-(((tmp113_)*mLocNDdx_x+(tmp125_)*mLocNDdy_x)*tmp69_)-((tmp113_)*mLocNDdx_y+(tmp125_)*mLocNDdy_y)*tmp90_)*mLocScNorm;
mCompDer[0][12] = (-(((tmp142_)*mLocNDdx_x+(tmp158_)*mLocNDdy_x)*tmp69_)-((tmp142_)*mLocNDdx_y+(tmp158_)*mLocNDdy_y)*tmp90_)*mLocScNorm;
mCompDer[0][13] = (-(((tmp164_)*mLocNDdx_x+(tmp169_)*mLocNDdy_x)*tmp69_)-((tmp164_)*mLocNDdx_y+(tmp169_)*mLocNDdy_y)*tmp90_)*mLocScNorm;
mCompDer[0][14] = (-(((tmp175_)*mLocNDdx_x+(tmp180_)*mLocNDdy_x)*tmp69_)-((tmp175_)*mLocNDdx_y+(tmp180_)*mLocNDdy_y)*tmp90_)*mLocScNorm;
mCompDer[0][15] = (-(((tmp185_)*mLocNDdx_x+(tmp190_)*mLocNDdy_x)*tmp69_)-((tmp185_)*mLocNDdx_y+(tmp190_)*mLocNDdy_y)*tmp90_)*mLocScNorm;
mCompDer[0][16] = (-(((tmp194_)*mLocNDdx_x+(tmp198_)*mLocNDdy_x)*tmp69_)-((tmp194_)*mLocNDdx_y+(tmp198_)*mLocNDdy_y)*tmp90_)*mLocScNorm;
mCompDer[0][17] = (-(((tmp202_)*mLocNDdx_x+(tmp206_)*mLocNDdy_x)*tmp69_)-((tmp202_)*mLocNDdx_y+(tmp206_)*mLocNDdy_y)*tmp90_)*mLocScNorm;
mCompDer[0][18] = (-(((tmp210_)*mLocNDdx_x+(tmp214_)*mLocNDdy_x)*tmp69_)-((tmp210_)*mLocNDdx_y+(tmp214_)*mLocNDdy_y)*tmp90_)*mLocScNorm;
}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::ComputeValDerivHessian()
{
ELISE_ASSERT(false,"Foncteur cEqAppui_Droite_NoDist__PTInc_M2CDRad5 Has no Der Sec");
}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::SetNDP0_x(double aVal){ mLocNDP0_x = aVal;}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::SetNDP0_y(double aVal){ mLocNDP0_y = aVal;}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::SetNDdx_x(double aVal){ mLocNDdx_x = aVal;}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::SetNDdx_y(double aVal){ mLocNDdx_y = aVal;}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::SetNDdy_x(double aVal){ mLocNDdy_x = aVal;}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::SetNDdy_y(double aVal){ mLocNDdy_y = aVal;}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::SetScNorm(double aVal){ mLocScNorm = aVal;}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::SetXIm(double aVal){ mLocXIm = aVal;}
void cEqAppui_Droite_NoDist__PTInc_M2CDRad5::SetYIm(double aVal){ mLocYIm = aVal;}
double * cEqAppui_Droite_NoDist__PTInc_M2CDRad5::AdrVarLocFromString(const std::string & aName)
{
if (aName == "NDP0_x") return & mLocNDP0_x;
if (aName == "NDP0_y") return & mLocNDP0_y;
if (aName == "NDdx_x") return & mLocNDdx_x;
if (aName == "NDdx_y") return & mLocNDdx_y;
if (aName == "NDdy_x") return & mLocNDdy_x;
if (aName == "NDdy_y") return & mLocNDdy_y;
if (aName == "ScNorm") return & mLocScNorm;
if (aName == "XIm") return & mLocXIm;
if (aName == "YIm") return & mLocYIm;
return 0;
}
cElCompiledFonc::cAutoAddEntry cEqAppui_Droite_NoDist__PTInc_M2CDRad5::mTheAuto("cEqAppui_Droite_NoDist__PTInc_M2CDRad5",cEqAppui_Droite_NoDist__PTInc_M2CDRad5::Alloc);
cElCompiledFonc * cEqAppui_Droite_NoDist__PTInc_M2CDRad5::Alloc()
{ return new cEqAppui_Droite_NoDist__PTInc_M2CDRad5();
}
|
36c2020a29fa86ff14ac5878dcb33caf83f75ae3 | a349faea976025191188b2ddcda5bed2fba913af | /Ch12/ex12_1/BinarySearchTree3.cpp | ae2ce8ab7cd9bbd7c4e1a5f8109ca0960d0dbfe2 | [] | no_license | ljw-LAB/Algorithm | 3faa976c6031637ce70d438d46dd0c8fcad8a75d | 14f21e9c740093e8c5eec071f94fced06977fbdd | refs/heads/main | 2023-03-25T11:29:57.063846 | 2021-03-29T15:44:38 | 2021-03-29T15:44:38 | 341,037,134 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 3,807 | cpp | BinarySearchTree3.cpp | #include <stdio.h>
#include <stdlib.h>
#include "BinaryTree3.h"
#include "BinarySearchTree3.h"
#include "AVLRebalance.h"
void BSTMakeAndInit(BTreeNode ** pRoot)
{
*pRoot = NULL;
}
BSTData BSTGetNodeData(BTreeNode * bst)
{
return GetData(bst);
}
BTreeNode* BSTInsert(BTreeNode ** pRoot, BSTData data)
{
if (*pRoot == NULL)
{
*pRoot = MakeBTreeNode();
SetData(*pRoot, data);
}
else if (data < GetData(*pRoot))
{
BSTInsert(&((*pRoot)->left), data);
*pRoot = Rebalance(pRoot);
}
else if (data > GetData(*pRoot))
{
BSTInsert(&((*pRoot)->right), data);
*pRoot = Rebalance(pRoot);
}
else
{
return NULL; // ํค์ ์ค๋ณต์ ํ์ฉํ์ง ์๋๋ค.
}
return *pRoot;
}
BTreeNode * BSTSearch(BTreeNode * bst, BSTData target)
{
BTreeNode * cNode = bst; // current node
BSTData cd; // current data
while(cNode != NULL)
{
cd = GetData(cNode);
if(target == cd)
return cNode;
else if(target < cd)
cNode = GetLeftSubTree(cNode);
else
cNode = GetRightSubTree(cNode);
}
return NULL;
}
BTreeNode * BSTRemove(BTreeNode ** pRoot, BSTData target)
{
// ์ญ์ ๋์์ด ๋ฃจํธ ๋
ธ๋์ธ ๊ฒฝ์ฐ๋ฅผ ๋ณ๋๋ก ๊ณ ๋ คํด์ผ ํ๋ค.
BTreeNode * pVRoot = MakeBTreeNode(); // ๊ฐ์ ๋ฃจํธ ๋
ธ๋;
BTreeNode * pNode = pVRoot; // parent node
BTreeNode * cNode = *pRoot; // current node
BTreeNode * dNode; // delete node
// ๋ฃจํธ ๋
ธ๋๋ฅผ pVRoot๊ฐ ๊ฐ๋ฆฌํค๋ ๋
ธ๋์ ์ค๋ฅธ์ชฝ ์๋ธ ๋
ธ๋๊ฐ ๋๊ฒ ํ๋ค.
ChangeRightSubTree(pVRoot, *pRoot);
// ์ญ์ ๋์์ ์ ์ฅํ ๋
ธ๋ ํ์
while(cNode != NULL && GetData(cNode) != target)
{
pNode = cNode;
if(target < GetData(cNode))
cNode = GetLeftSubTree(cNode);
else
cNode = GetRightSubTree(cNode);
}
if(cNode == NULL) // ์ญ์ ๋์์ด ์กด์ฌํ์ง ์๋๋ค๋ฉด,
return NULL;
dNode = cNode; // ์ญ์ ๋์์ dNode๊ฐ ๊ฐ๋ฆฌํค๊ฒ ํ๋ค.
// ์ฒซ ๋ฒ์งธ ๊ฒฝ์ฐ: ์ญ์ ํ ๋
ธ๋๊ฐ ๋จ๋ง ๋
ธ๋์ธ ๊ฒฝ์ฐ
if(GetLeftSubTree(dNode) == NULL && GetRightSubTree(dNode) == NULL)
{
if(GetLeftSubTree(pNode) == dNode)
RemoveLeftSubTree(pNode);
else
RemoveRightSubTree(pNode);
}
// ๋ ๋ฒ์งธ ๊ฒฝ์ฐ: ํ๋์ ์์ ๋
ธ๋๋ฅผ ๊ฐ๋ ๊ฒฝ์ฐ
else if(GetLeftSubTree(dNode) == NULL || GetRightSubTree(dNode) == NULL)
{
BTreeNode * dcNode; // delete node์ ์์ ๋
ธ๋
if(GetLeftSubTree(dNode) != NULL)
dcNode = GetLeftSubTree(dNode);
else
dcNode = GetRightSubTree(dNode);
if(GetLeftSubTree(pNode) == dNode)
ChangeLeftSubTree(pNode, dcNode);
else
ChangeRightSubTree(pNode, dcNode);
}
// ์ธ ๋ฒ์งธ ๊ฒฝ์ฐ: ๋ ๊ฐ์ ์์ ๋
ธ๋๋ฅผ ๋ชจ๋ ๊ฐ๋ ๊ฒฝ์ฐ
else
{
BTreeNode * mNode = GetRightSubTree(dNode); // mininum node
BTreeNode * mpNode = dNode; // mininum node์ ๋ถ๋ชจ ๋
ธ๋
int delData;
// ์ญ์ ํ ๋
ธ๋๋ฅผ ๋์ฒดํ ๋
ธ๋๋ฅผ ์ฐพ๋๋ค.
while(GetLeftSubTree(mNode) != NULL)
{
mpNode = mNode;
mNode = GetLeftSubTree(mNode);
}
// ๋์ฒดํ ๋
ธ๋์ ์ ์ฅ๋ ๊ฐ์ ์ญ์ ํ ๋
ธ๋์ ๋์
ํ๋ค.
delData = GetData(dNode); // ๋์
์ ๋ฐ์ดํฐ ๋ฐฑ์
SetData(dNode, GetData(mNode));
// ๋์ฒดํ ๋
ธ๋์ ๋ถ๋ชจ ๋
ธ๋์ ์์ ๋
ธ๋๋ฅผ ์ฐ๊ฒฐํ๋ค.
if(GetLeftSubTree(mpNode) == mNode)
ChangeLeftSubTree(mpNode, GetRightSubTree(mNode));
else
ChangeRightSubTree(mpNode, GetRightSubTree(mNode));
dNode = mNode;
SetData(dNode, delData); // ๋ฐฑ์
๋ฐ์ดํฐ ๋ณต์
}
// ์ญ์ ๋ ๋
ธ๋๊ฐ ๋ฃจํธ ๋
ธ๋์ธ ๊ฒฝ์ฐ์ ๋ํ ์ฒ๋ฆฌ
if(GetRightSubTree(pVRoot) != *pRoot)
*pRoot = GetRightSubTree(pVRoot);
free(pVRoot);
*pRoot = Rebalance(pRoot); // ๋
ธ๋ ์ ๊ฑฐ ํ ๋ฆฌ๋ฐธ๋ฐ์ฑ!
return dNode;
}
void ShowIntData(int data)
{
printf("%d ", data);
}
void BSTShowAll(BTreeNode * bst)
{
InorderTraverse(bst, ShowIntData);
} |
cf5cb52d6c453dcb92657a227a67a6e44b698dce | da5f781feaa50941c12e9b8e19dd930d524ddeac | /ะะะ/lab1.cpp | 244bd52821beed5dc87c53c6a1b659130321d767 | [] | no_license | IvanMerejko/3-semestr | ebb4899784caa62237ae174203ca63972411e07e | 712aada2ddb74d58a5080769f64eb34337d7c8fe | refs/heads/master | 2020-07-22T18:50:17.171472 | 2019-12-17T06:07:02 | 2019-12-17T06:07:02 | 207,294,531 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,094 | cpp | lab1.cpp | #include <iostream>
#include <cmath>
#include <iomanip>
#include <tuple>
#include <thread>
using returnableTuple = std::tuple<double, double, int>;
class Task
{
private:
enum class NumberOfTask
{
First,
Second
};
private:
double m_a;
double m_b;
const double m_PI;
double m_x;
mutable double m_nForSecondTask;
public:
Task();
Task(const double a, const double b);
void createFirstTable() const;
void createSecondTable() const;
private:
returnableTuple getSinFunctionValue(NumberOfTask task, double x = 0.0, double eps = 0.0 ) const;
};
Task::Task()
: Task(0, 0)
{}
Task::Task(const double a, const double b)
: m_a(a)
, m_b(b)
, m_PI(3.14159265)
, m_x( ((m_a + m_b) /2) * m_PI / 180)
, m_nForSecondTask(0)
{}
void Task::createFirstTable() const
{
std::cout << "First Table\n\n";
std::cout << "eps"
<< std::setw(10) << "n"
<< std::setw(12) << "abs_delta"
<< std::setw(21) << "last (R)"
<< std::endl << std::endl;
const auto step = 1e-3;
const auto limit = 1e-14;
for (auto eps = 1e-2; eps > limit; eps *= step)
{
double R;
int n;
double result;
std::tie(result, R, n) = getSinFunctionValue(NumberOfTask::First,m_x, eps);
std::cout << std::setprecision(2) << std::scientific
<< std::setw(6) << eps
<< std::setw(6) << n
<< std::setw(12) << abs(abs(sin(m_x)) - abs(result))
<< std::setw(18) << R
<< std::endl;
if (eps == 1e-8)
m_nForSecondTask = n;
}
}
returnableTuple Task::getSinFunctionValue(NumberOfTask task, double x, double eps) const
{
auto U = x, result = x;
auto k = 1;
auto lambda = [=](const double x, const int k,const double U)
{
return -x * x / ( (2*k + 1)* 2*k) * U;
};
if (task == NumberOfTask::First)
{
do
{
U = lambda(m_x, k, U);
result += U;
k += 1;
} while (abs(lambda(m_x, k, U)) > eps);
}
else
{
for(; k < m_nForSecondTask ; ++k)
{
U = lambda(x, k, U);
result += U;
}
}
return std::make_tuple(result, lambda(x, k, U), k);
}
void Task::createSecondTable() const
{
std::cout << "\n\nSecond Table\n" << std::endl;
const auto h = (m_b - m_a) / 10;
std::cout << "x_i"
<< std::setw(21) << "abs_delta"
<< std::setw(21) << "last (R)"
<< std::endl << std::endl;
for (int i = 0; i < 10; i++)
{
const auto x = m_a + h * i;
double R;
double result;
int unused;
std::tie(result, R, unused) = getSinFunctionValue(NumberOfTask::Second, x*m_PI / 180);
std::cout << std::defaultfloat << std::setw(7) << std::setprecision(4) << x
<< std::setw(17) << abs(abs(sin(x*m_PI / 180)) - abs(result))
<< std::setw(22) << abs(R) << std::endl;
}
std::cout << std::endl;
}
int main()
{
std::cout.precision(14);
std::cout.setf(std::ios::fixed | std::ios::right);
Task task(-3.3, 24.9);
task.createFirstTable();
task.createSecondTable();
std::cin.get();
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.