blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d4979e3ed9dbd1d257d6af6612d6fe9b3736a03a | 00fa01b6d570e02c6c4b7a4a7b9c75bd7d8f6b56 | /RandomPlayer.h | aec91b6e6b9967861bd07389b4cabeea787ef65b | [] | no_license | Aardeehar/BattleshipC | a20bb893ce943bff07e810e6fce5683715f892a7 | 1404e9420adfe4906808f36efa81fda95688440b | refs/heads/master | 2023-06-29T04:20:58.692370 | 2021-07-27T16:33:33 | 2021-07-27T16:33:33 | 390,049,692 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 310 | h | /*Name: Aarden Muller-Hartle
ID: 0342958
BattleShip
*/
#include "ComputerPlayer.h"
#ifndef RANDOMPLAYER_H
#define RANDOMPLAYER_H
#include <random>
#include "time.h"
class RandomPlayer : public ComputerPlayer {
public:
Board::Move makeMove(const Board& b1);
//make a random, but legal, move
};
#endif | [
"amullerhartle@laurentian.ca"
] | amullerhartle@laurentian.ca |
f9a2c77c905c8f5feb1aa465025b9ad87ec901cc | c6aa5271b36ba37bd9eb36ac2255bd5b864ff091 | /Source/sfm_train.cpp | 3992a7d61ee1f2060a8263de43f27f76a02cfaaa | [] | no_license | Sher10k/Reconst_plane | a00f790d5a012756d427687240d172bd685b6f57 | 0c1fbcbfd2122aa8720324f77f9a5b9a7b7e3e4c | refs/heads/master | 2020-07-12T23:36:53.325619 | 2019-09-20T15:18:03 | 2019-09-20T15:18:03 | 204,936,031 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,061 | cpp |
#include "Header/sfm_train.h"
#define FLOW_FLAG 0
//SFM_Reconstruction::SFM_Reconstruction( ){}
void SFM_Reconstruction::Reconstruct3D( Mat *data_frame0, Mat *data_frame1, Matx33d K_ )
{
//points3D *= 0;
points3D.release();
points3D_BGR.clear();
R *= 0;
t *= 0;
K[0] = K_;
K[1] = K_;
//--- STEP 1 --- Detection and calculation
keypoints[0].clear();
keypoints[1].clear();
descriptors[0] *= 0;
descriptors[1] *= 0;
int Xc = 751, Yc = 250;
Mat maskL = Mat::zeros( frame[0].size(), CV_8UC1 );
Mat maskR = maskL.clone();
for ( int i = 0; i < frame[1].rows; i++ )
{
for ( int j = 0; j < frame[1].cols; j++ )
{
if ( j < Xc ) maskL.at< char >(i, j) = 1;
else maskR.at< char >(i, j) = 1;
}
}
vector< KeyPoint > kpL, kpR;
Mat dpL, dpR;
dpL *= 0;
dpR *= 0;
if ( !data_frame0->empty() ) {
(*data_frame0).copyTo(frame[0]);
// kpL.clear();
// kpR.clear();
// detectorSIFT->detectAndCompute( frame[0], maskL, kpL, dpL );
// detectorSIFT->detectAndCompute( frame[0], maskR, kpR, dpR );
// keypoints[0]_SIFT.reserve( kpL.size() + kpR.size() );
// keypoints[0]_SIFT.insert( keypoints[0]_SIFT.end(), kpL.begin(), kpL.end() );
// keypoints[0]_SIFT.insert( keypoints[0]_SIFT.end(), kpR.begin(), kpR.end() );
detectorSIFT->detectAndCompute(frame[0], cv::noArray(), keypoints[0], descriptors[0]);
}
else frame[0] = Mat::zeros( data_frame1->size(), CV_8UC3 );
if ( !data_frame1->empty() ) {
(*data_frame1).copyTo(frame[1]);
// kpL.clear();
// kpR.clear();
// dpL *= 0;
// dpR *= 0;
// detectorSIFT->detectAndCompute( frame[1], maskL, kpL, dpL );
// detectorSIFT->detectAndCompute( frame[1], maskR, kpR, dpR );
// keypoints[0]_SIFT.reserve( kpL.size() + kpR.size() );
// keypoints[0]_SIFT.insert( keypoints[0]_SIFT.end(), kpL.begin(), kpL.end() );
// keypoints[0]_SIFT.insert( keypoints[0]_SIFT.end(), kpR.begin(), kpR.end() );
// kpL.clear();
// kpR.clear();
detectorSIFT->detectAndCompute(frame[1], cv::noArray(), keypoints[1], descriptors[1]);
}
else frame[1] = Mat::zeros( data_frame0->size(), CV_8UC3 );
//--- STEP 2 --- Matcher keypoints
good_matches.clear();
good_points[0].clear();
good_points[1].clear();
points[0].clear();
points[1].clear();
numKeypoints = 0;
frame4 = Mat::zeros( Size( frame[0].cols + frame[1].cols, frame[0].rows ), CV_8UC3 );
if ((keypoints[0].size() != 0) && (keypoints[1].size() != 0))
{
numKeypoints = Match_find_SIFT( keypoints[0],
keypoints[1],
descriptors[0],
descriptors[1],
&good_points[0],
&good_points[1],
&good_matches );
points[0].resize( numKeypoints );
points[1].resize( numKeypoints );
KeyPoint::convert( good_points[0], points[0] ); // Convert from KeyPoint to Point2f
KeyPoint::convert( good_points[1], points[1] );
//--- STEP 3 --- Find essential matrix
if (numKeypoints > 7)
{
valid_mask = Mat::ones( Size( 1, int(numKeypoints)), valid_mask.type());
E = findEssentialMat(points[0], points[1], K[0], RANSAC, 0.999, 3.0, valid_mask);
F = findFundamentalMat(points[0], points[1], FM_RANSAC, 3, 0.99, valid_mask);
correctMatches(F, points[0], points[1], points[0], points[1]);
//--- STEP 4 --- Decompose essential matrix
Mat p3D;
p3D *= 0;
recoverPose(E, points[0], points[1], K[0], R, t, 100, valid_mask, p3D);
Rodrigues( R, r );
int numNoZeroMask = countNonZero(valid_mask);
points3D = Mat::zeros( 4, numNoZeroMask, p3D.type() );
int k = 0;
for (int i = 0; i < p3D.cols; i++)
{
if ( valid_mask.at< uchar >(i) == 1 )
{
for (int j = 0; j < points3D.rows; j++)
{
points3D.at< double >(j, k) = p3D.at< double >(j, k) / p3D.at< double >(3, k);
}
points3D_BGR.push_back( Scalar( (frame[0].at<Vec3b>(points[0].at(static_cast<size_t>(i)))[0] +
frame[1].at<Vec3b>(points[1].at(static_cast<size_t>(i)))[0] ) / 2,
(frame[0].at<Vec3b>(points[0].at(static_cast<size_t>(i)))[1] +
frame[1].at<Vec3b>(points[1].at(static_cast<size_t>(i)))[1] ) / 2,
(frame[0].at<Vec3b>(points[0].at(static_cast<size_t>(i)))[2] +
frame[1].at<Vec3b>(points[1].at(static_cast<size_t>(i)))[2] ) / 2 ) );
k++;
}
}
FileStorage SFM_Result;
SFM_Result.open("SFM_Result.txt", FileStorage::WRITE);
SFM_Result << "E" << E;
SFM_Result << "F" << F;
//SFM_Result << "points[0]" << points[0];
//SFM_Result << "points[1]" << points[1];
SFM_Result << "K" << K[0];
SFM_Result << "R" << R;
SFM_Result << "r" << r;
SFM_Result << "t" << t;
SFM_Result << "points3D" << points3D;
SFM_Result << "valid_mask" << valid_mask;
SFM_Result.release();
cout << " --- SFM_Result written into file: SFM_Result.txt" << endl;
drawMatches( frame[0], good_points[0], frame[1], good_points[1], good_matches, frame4 );
// imshow("SFM-result", frame4);
// waitKey(10);
imwrite( "SFM-result_keypoints.png", frame4 );
}
else
{
if ( !frame[0].empty()) drawKeyPoints(&frame[0], &keypoints[0] );
if ( !frame[1].empty()) drawKeyPoints(&frame[1], &keypoints[1] );
Rect r1(0, 0, frame[0].cols, frame[0].rows);
Rect r2(frame[1].cols, 0, frame[1].cols, frame[1].rows);
frame[0].copyTo(frame4( r1 ));
frame[1].copyTo(frame4( r2 ));
// imshow("SFM-result", frame4);
// waitKey(10);
imwrite( "SFM-result_keypoints.png", frame4 );
cout << " --- Not enough keypoints" << endl;
}
}
else
{
if ( !frame[0].empty()) drawKeyPoints(&frame[0], &keypoints[0] );
if ( !frame[1].empty()) drawKeyPoints(&frame[1], &keypoints[1] );
Rect r1(0, 0, frame[0].cols, frame[0].rows);
Rect r2(frame[1].cols, 0, frame[1].cols, frame[1].rows);
frame[0].copyTo(frame4( r1 ));
frame[1].copyTo(frame4( r2 ));
// imshow("SFM-result", frame4);
// waitKey(10);
imwrite( "SFM-result_keypoints.png", frame4 );
cout <<" --- No keypoints found in one of the frames" << endl;
}
}
void SFM_Reconstruction::Reconstruct3DopticFlow( Mat *data_frame0, Mat *data_frame1, Matx33d K_ )
{
R *= 0;
t *= 0;
frame[0] = *data_frame0;
frame[1] = *data_frame1;
frame4 = Mat::zeros( frame[0].size(), CV_8UC3 );
flow = Mat::zeros( frame4.size(), CV_32FC2 );
K[0] = K_;
K[1] = K_;
if ( (!frame[0].empty()) && (!frame[1].empty()) )
{
//--- STEP 1 --- Calculate optical flow -------------------------------------//
points[0].clear();
points[1].clear();
numKeypoints = 0;
Mat fg1, fg2;
cvtColor( frame[0], fg1, COLOR_BGR2GRAY );
cvtColor( frame[1], fg2, COLOR_BGR2GRAY );
// imshow( "fg1", fg1 );
// imshow( "fg2", fg2 );
// waitKey(20);
#if (FLOW_FLAG == 0)
//calcOpticalFlowFarneback( fg1, fg2, flow, 0.9, 1, 12, 2, 7, 1.7, 0 ); // OPTFLOW_FARNEBACK_GAUSSIAN
//calcOpticalFlowFarneback( fg1, fg2, flow, 0.6, 4, 5, 2, 3, 1.1, OPTFLOW_FARNEBACK_GAUSSIAN );
optflow::calcOpticalFlowSparseToDense( fg1, fg2, flow, 4, 128, 0.01f, true, 500.0f, 1.5f);
//optflow::calcOpticalFlowSparseToDense( fg1, fg2, flow, 13, 256, 0.002f, true, 500.0f, 1.5f);
//optflow::calcOpticalFlowSparseToDense( fg1, fg2, flow, 3, 32, 0.01f, false );
#elif (FLOW_FLAG == 1)
// fg1.convertTo(fg1, CV_32F);
// fg2.convertTo(fg2, CV_32F);
gpu_fg1.upload(fg1);
gpu_fg2.upload(fg2);
gpu_flow.upload(flow);
FOF->calc( gpu_fg1, gpu_fg2, gpu_flow ); // good
//DPLKOF->calc( gpu_fg1, gpu_fg2, gpu_flow );
// convert to CV_32F
//BOF->calc( gpu_fg1, gpu_fg2, gpu_flow );
//OFD->calc( gpu_fg1, gpu_fg2, gpu_flow );
gpu_flow.download(flow);
#endif
// Paint optic flow
Mat Lmax;
normalize( flow, Lmax, 1.0, 0.0, NORM_INF);
cvtColor( frame4, frame4, COLOR_BGR2HSV );
int win = 3;
for (int y = 0; y < frame4.rows; y += win)
{
for (int x = 0; x < frame4.cols; x += win)
{
// get the flow from y, x position * 3 for better visibility
const Point2f flowatxy = flow.at< Point2f >(y, x) * 1;
const Point2f Lxy = Lmax.at< Point2f >(y, x) * 1;
//double Lhsv = double( sqrt( ((Lxy.x)*(Lxy.x)) + ((Lxy.y)*(Lxy.y)) ) );
float Hsv = 179 * sqrt( ((Lxy.x)*(Lxy.x)) + ((Lxy.y)*(Lxy.y)) );
// draw line at flow direction
line( frame4,
Point(x, y),
Point(cvRound(x + flowatxy.x), cvRound(y + flowatxy.y)),
Scalar(unsigned( Hsv ), 255, 255) ); // H: 0-179, S: 0-255, V: 0-255
// draw initial point
//circle(frame4, Point(x, y), 1, Scalar(0, 0, 0), -1);
points[0].push_back( Point2f(x, y) );
points[1].push_back( Point2f((x + flowatxy.x), (y + flowatxy.y)) );
numKeypoints++;
}
}
cvtColor( frame4, frame4, COLOR_HSV2BGR );
//imshow("RGB", points3D_BGR);
//waitKey(10);
//--- STEP 2 --- Find essential matrix --------------------------------------//
valid_mask = Mat::ones( Size( 1, int(numKeypoints)), valid_mask.type());
E = findEssentialMat( points[0], points[1], K[0], RANSAC, 0.999, 3.0, valid_mask );
F = findFundamentalMat( points[0], points[1], FM_RANSAC, 3, 0.99);
// correctMatches(F, points[0], points[1], points[0], points[1]);
//--- STEP 3 --- Calculation of 3d points -----------------------------------//
char maskf = 1;
Mat p3D;
p3D.release();
points3D.release();
points3D_BGR.clear();
recoverPose(E, points[0], points[1], K[0], R, t, 100, valid_mask, p3D); // valid_mask
Rodrigues( R, r );
int k = 0;
if ( maskf )
{
int numNoZeroMask = countNonZero(valid_mask);
points3D = Mat::zeros( 4, numNoZeroMask, p3D.type() );
for (int i = 0; i < p3D.cols; i++)
{
if ( valid_mask.at< uchar >(i) == 1 )
{
for (int j = 0; j < points3D.rows; j++)
{
points3D.at< double >(j, k) = p3D.at< double >(j, i) / p3D.at< double >(3, i);
}
points3D_BGR.push_back( Scalar( (frame[0].at<Vec3b>(points[0].at(static_cast<size_t>(i)))[0] +
frame[1].at<Vec3b>(points[1].at(static_cast<size_t>(i)))[0] ) / 2,
(frame[0].at<Vec3b>(points[0].at(static_cast<size_t>(i)))[1] +
frame[1].at<Vec3b>(points[1].at(static_cast<size_t>(i)))[1] ) / 2,
(frame[0].at<Vec3b>(points[0].at(static_cast<size_t>(i)))[2] +
frame[1].at<Vec3b>(points[1].at(static_cast<size_t>(i)))[2] ) / 2 ) );
k++;
}
}
}
else
{
points3D = p3D.clone();
for (int i = 0; i < points3D.cols; i++)
{
for (int j = 0; j < points3D.rows; j++) points3D.at< double >(j, i) /= points3D.at< double >(3, i);
points3D_BGR.push_back( Scalar( (frame[0].at<Vec3b>(points[0].at(static_cast<size_t>(i)))[0] +
frame[1].at<Vec3b>(points[1].at(static_cast<size_t>(i)))[0] ) / 2,
(frame[0].at<Vec3b>(points[0].at(static_cast<size_t>(i)))[1] +
frame[1].at<Vec3b>(points[1].at(static_cast<size_t>(i)))[1] ) / 2,
(frame[0].at<Vec3b>(points[0].at(static_cast<size_t>(i)))[2] +
frame[1].at<Vec3b>(points[1].at(static_cast<size_t>(i)))[2] ) / 2 ) );
}
}
FileStorage SFM_Result;
SFM_Result.open("SFM_Result_opticflow.txt", FileStorage::WRITE);
SFM_Result << "E" << E;
SFM_Result << "F" << F;
//SFM_Result << "points[0]" << points[0];
//SFM_Result << "points[1]" << points[1];
SFM_Result << "K" << K[0];
SFM_Result << "R" << R;
SFM_Result << "r" << r;
SFM_Result << "t" << t;
//SFM_Result << "points3D" << points3D;
//SFM_Result << "valid_mask" << valid_mask;
SFM_Result.release();
cout << " --- SFM_Result written into file: SFM_Result_opticflow.txt" << endl;
frame4.copyTo( frameFlow );
//resize( frame4, frame4, Size(640, 480), 0, 0, INTER_LINEAR );
//imshow("SFM-result", frame4);
imwrite("SFM-result_opticflow.png", frame4);
waitKey(10);
}
else
{
cout << " --- Not enough frames" << endl;
}
}
void SFM_Reconstruction::Reconstruct3Dstereo( Mat *data_frameL, Mat *data_frameR, Matx33d KL_, Matx33d KR_ )
{
frame[0] = *data_frameL;
frame[1] = *data_frameR;
K[0] = KL_;
K[1] = KR_;
//--- STEP 0 --- Find keypoints ---------------------------------------------//
keypoints[0].clear();
keypoints[1].clear();
descriptors[0] *= 0;
descriptors[1] *= 0;
/*
* Алгоритм поиска ключевых точек
* или маркеров для дальнейшей реконструкции
*/
//--- STEP 1 --- Find Essential & Fundamental matrix ------------------------//
valid_mask = Mat::ones( Size( 1, int(numKeypoints)), valid_mask.type() );
//valid_mask.setTo( Scalar::all(1) );
//E = findEssentialMat( points[0], points[1], K[0], RANSAC, 0.999, 3.0, valid_mask );
//E = findEssentialMat( points[0], points[1], K[0], K[1], RANSAC, 0.999, 3.0, valid_mask );
F = findFundamentalMat( points[0], points[1], FM_RANSAC, 3, 0.99);
// correctMatches(F, points[0], points[1], points[0], points[1]);
}
void SFM_Reconstruction::opticalFlow(Mat *data_frame0, Mat *data_frame1, int win, int vecS)
{
(*data_frame0).copyTo(frameFlow);
//frameFlow = *data_frame0;
flow = Mat::zeros( frameFlow.size(), CV_32FC2 );
Mat frameGrey[2];
cvtColor(*data_frame0, frameGrey[0], COLOR_BGR2GRAY);
cvtColor(*data_frame1, frameGrey[1], COLOR_BGR2GRAY);
//calcOpticalFlowFarneback(frameGrey[0], frameGrey[1], flow, 0.9, 1, 12, 2, 8, 1.7, 0);//OPTFLOW_FARNEBACK_GAUSSIAN
optflow::calcOpticalFlowSparseToDense(frameGrey[0], frameGrey[1], flow, 8, 128, 0.05f, true, 500.0f, 1.5f);
//cv::normalize(flow, flow, 1, 0, NORM_L2, -1, noArray());
for (int y = 0; y < frameFlow.rows; y += win) {
for (int x = 0; x < frameFlow.cols; x += win) {
// get the flow from y, x position * 3 for better visibility
const Point2f flowatxy = flow.at<Point2f>(y, x) * vecS;
// draw line at flow direction
line(frameFlow, Point(x, y), Point(cvRound(x + flowatxy.x), cvRound(y + flowatxy.y)), Scalar(255, 200, 0));
// draw initial point
circle(frameFlow, Point(x, y), 1, Scalar(0, 0, 0), -1);
}
}
}
void SFM_Reconstruction::destroyWinSFM()
{
namedWindow("SFM-result", WINDOW_AUTOSIZE);
destroyWindow("SFM-result");
namedWindow("OpticalFlow", WINDOW_AUTOSIZE);
destroyWindow("OpticalFlow");
}
// SIFT Find matches between points
unsigned long SFM_Reconstruction::Match_find_SIFT( vector< KeyPoint > kpf1,
vector< KeyPoint > kpf2,
Mat dpf1,
Mat dpf2,
vector< KeyPoint > *gp1,
vector< KeyPoint > *gp2,
vector< DMatch > *gm)
{
cv::Ptr<cv::FlannBasedMatcher> matcher = cv::FlannBasedMatcher::create();
vector<cv::DMatch> matches;
cv::DMatch dist1, dist2;
matcher->match(dpf1, dpf2, matches, cv::noArray()); // Matches key points of the frame with key points of the frame2
// Sort match
unsigned long temp = 0;
unsigned long kn = static_cast<unsigned long>(matches.size());
for (unsigned long i = 0; i < kn - 1; i++) { //key_num - 1
dist1 = matches[i];
for (unsigned long j = i + 1; j < kn; j++) {
dist2 = matches[j];
if (dist2.distance < dist1.distance) {
dist1 = matches[j];
temp = j;
}
if (j == kn - 1) {
matches[temp] = matches[i];
matches[i] = dist1;
break;
}
}
}
//-- Вычисление максимального и минимального расстояния среди всех дескрипторов в пространстве признаков
float max_dist = 0, min_dist = 100;
for(size_t i = 0; i < matches.size(); i++ ) {
float dist = matches[i].distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}
//cout << "-- Max dist : " << max_dist << endl;
//cout << "-- Min dist : " << min_dist << endl;
// Selection of key points on both frames satisfying the threshold
temp = 0;
for (size_t i = 0; i < matches.size(); i++) {
if (matches[i].distance < 10 * min_dist) { // threshold
int new_i = static_cast<int>( gp1->size() );
gp1->push_back( kpf1[ static_cast<unsigned long>( matches[i].queryIdx ) ] ); // queryIdx
gp2->push_back( kpf2[ static_cast<unsigned long>( matches[i].trainIdx ) ] ); // trainIdx
gm->push_back( cv::DMatch(new_i, new_i, 0) );
temp++;
}
}
cout << " --- Number of similar keypoints found : " << temp << endl;
return temp;
}
void SFM_Reconstruction::drawKeyPoints( Mat *f,
vector< KeyPoint > *kp)
{
vector< Point2f > drawPoint;
KeyPoint::convert(*kp, drawPoint);
RNG rng(12345);
for (size_t i = 0; i < drawPoint.size(); i++) {
Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
circle(*f, drawPoint[i], 3, color, 1, LINE_8, 0);
//putText( *f, to_string(i), drawPoint[i], FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 0, 0), 2);
}
}
| [
"suhanovroman96@yandex.ru"
] | suhanovroman96@yandex.ru |
2166f6c6b4150b29ec689a2b02881a416da10429 | e339991d523d8d0e974296c878dabca2ff2d4e1f | /105buildTree/105buildTree.cpp | 8cc3d9769d9b195f23c63539e2432f1914df274a | [] | no_license | SadMathLovergo/LeetCodeSolution | dd9ad61c05496b5a5fe32bca7b53530cce09550f | 2dbf73f979ac980d225333b0230ee1c0cf7c3c72 | refs/heads/master | 2020-03-30T05:45:52.389614 | 2019-04-04T10:56:08 | 2019-04-04T10:56:08 | 150,818,348 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,088 | cpp | #include <vector>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
/*第105题 从前序和中序遍历序列构造二叉树*/
//解题思路:前序遍历顺序为:根节点->左子树->右子树,中序遍历顺序为:左子树->根节点->右子树
//找到根节点在中序遍历中的位置,即可知道此根节点左孩子节点以及右孩子节点
class Solution {
private:
//找到preorder[curIndex]在inorder中的位置([indexL,indexR]中),即可找到preorder[curIndex]的左孩子节点和右孩子节点
TreeNode * findRoot(vector<int>& preorder, int curIndex, vector<int>& inorder, int indexL, int indexR) {
//当indexL>indexR时,意味着此孩子节点为NULL
if (curIndex >= preorder.size() || indexL > indexR)
return NULL;
TreeNode* newNode = new TreeNode(preorder[curIndex]);
//preorder[curIndex]在inorder中的索引为indexL+newIndex,左孩子数量为newIndex个,右孩子数量为indexR-indexL-newIndex个
//因此preorder[curIndex]的左孩子节点为preorder[curIndex+1],右孩子节点为preorder[curIndex+newIndex+1],如果存在的话
//左孩子节点preorder[curIndex+1]在inorder中的索引范围为[indexL,indexL+newIndex-1]
//右孩子节点preorder[curIndex+newIndex+1]在inorder中的索引范围为[indexL+newIndex+1,indexR]
int newIndex = 0;
for (int i = indexL; i <= indexR; i++)
if (inorder[i] == preorder[curIndex])
break;
else
newIndex++;
newNode->left = findRoot(preorder, curIndex + 1, inorder, indexL, indexL + newIndex - 1);
newNode->right = findRoot(preorder, curIndex + newIndex + 1, inorder, indexL + newIndex + 1, indexR);
return newNode;
}
public:
TreeNode * buildTree(vector<int>& preorder, vector<int>& inorder) {
return findRoot(preorder, 0, inorder, 0, preorder.size() - 1);
}
};
int main() {
vector<int> preorder{ 3,9,20,115,7 };
vector<int> inorder{ 9,3,15,20,7 };
TreeNode* newNode = Solution().buildTree(preorder, inorder);
system("pause");
return 0;
} | [
"sadmathlover@gmail.com"
] | sadmathlover@gmail.com |
bee240fdc5775aba89af549aeef654e26e564d0a | 86bfff493c02e148be37014332bc49ece0446b7d | /Qt-2048/numbergrid.h | 417dd97b6838ae465d7d3a15ac10bec55a70c350 | [] | no_license | jjzhang166/Qt-project | 12f4e02191f6b0313013d84dfb365a8e9df6ee74 | a9638be429a28f920e35759f259b1e9a40ac1d5e | refs/heads/master | 2021-01-16T21:41:53.739507 | 2015-09-13T12:42:27 | 2015-09-13T12:42:27 | 100,246,375 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 433 | h | #ifndef NUMBERGRID_H
#define NUMBERGRID_H
#include <QWidget>
#include <QStyleOption>
#include <QPainter>
#include "tile.h"
class NumberGrid : public QWidget
{
Q_OBJECT
public:
explicit NumberGrid(QWidget *parent = 0);
void mapFromMatrix(int (*matrix)[4]); //从二位数组映射到数字网格界面
signals:
public slots:
private:
void paintEvent(QPaintEvent*);
Tile *tiles[4][4];
};
#endif // NUMBERGRID_H
| [
"1901981503@qq.com"
] | 1901981503@qq.com |
5e8c5b66ecea38c2dbdd27b166fda5d6f471f1ec | bb7874f3251cdf25d911995edffff832ae888130 | /Labs assignments/Lab8/Controller.h | 7d2a918edbf4ecb4724a0e6d43910acd05a7ac43 | [] | no_license | teodoraalexandra/Object-Oriented-Programming | 35b11ba915c88c513ce85ba1d498892444b90a56 | fcb4e93bd0eed7751fcbc23773c5ce38995367c0 | refs/heads/master | 2021-05-20T20:43:28.320959 | 2020-04-02T10:05:48 | 2020-04-02T10:05:48 | 252,410,240 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 650 | h | //
// Created by Teodora Dan on 2019-04-27.
//
#ifndef LAB8_9_CONTROLLER_H
#define LAB8_9_CONTROLLER_H
#endif //LAB8_9_CONTROLLER_H
#pragma once
#include "Repository.h"
#include <vector>
class Controller
{
private:
Repository & repository;
public:
Controller(Repository & repo);
void add(const std::string& name, const std::string& size, int price, const std::string& photo);
void update(const std::string& name, const std::string& size, int price, const std::string& photo, int position);
void remove(int position);
Coat getCoat(int position);
std::vector<Coat> search() const;
int size();
~Controller();
}; | [
"33027937+teodoraalexanra@users.noreply.github.com"
] | 33027937+teodoraalexanra@users.noreply.github.com |
19cec0dea32147285721883a7607f4106920af5d | b5e09ae4fac2c9051e88dc3498157aff889ce289 | /src/mingw-w64-x86_64-static-opencv2.cpp | 2e129318b56a6e06d9087e124b980620997c9599 | [] | no_license | bradosia/mingw-w64-x86_64-static-opencv2 | 2fdc31eaeb451beeb88891b496a36ed2d3e111a4 | f9797e6704300dcd11d9bb809486a05cc8420f6d | refs/heads/master | 2020-11-30T21:42:51.700529 | 2020-01-05T04:02:59 | 2020-01-05T04:02:59 | 230,486,604 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,200 | cpp | /*
* Windows only example
*/
#include <iostream>
// windows libraries
#include <Windows.h>
// openCV 4.1.1 libraries
#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
using namespace std;
using namespace cv;
Mat hwnd2mat(HWND hwnd);
void detectAndDraw(Mat& img, CascadeClassifier& cascade,
CascadeClassifier& nestedCascade, double scale, bool tryflip);
string cascadeName;
string nestedCascadeName;
int main(int argc, const char** argv) {
VideoCapture capture;
Mat frame, croppedImage;
string inputName;
bool tryflip;
CascadeClassifier cascade, nestedCascade;
double scale;
cascadeName = "data/haarcascades/haarcascade_frontalface_alt.xml";
nestedCascadeName = "data/haarcascades/haarcascade_eye_tree_eyeglasses.xml";
scale = 1;
tryflip = false;
if (!nestedCascade.load(samples::findFileOrKeep(nestedCascadeName)))
cerr << "WARNING: Could not load classifier cascade for nested objects"
<< endl;
if (!cascade.load(samples::findFile(cascadeName))) {
cerr << "ERROR: Could not load classifier cascade" << endl;
return -1;
}
HWND hWndDesktop = GetDesktopWindow();
frame = hwnd2mat(hWndDesktop);
int frameWidth = frame.cols;
int frameX = frameWidth - 720;
cout <<frameWidth;
// Setup a rectangle to define your region of interest
cv::Rect myROI(frameX, 0, 720, 480);
cout << "Desktop capturing has been started ..." << endl;
cv::namedWindow( "result", WINDOW_NORMAL );
resizeWindow("result", 720, 480);
for (;;) {
HWND hWndDesktop = GetDesktopWindow();
frame = hwnd2mat(hWndDesktop);
// Crop the full image to that image contained by the rectangle myROI
// Note that this doesn't copy the data
croppedImage = frame(myROI);
detectAndDraw(croppedImage, cascade, nestedCascade, scale, tryflip);
char c = (char) waitKey(10);
if (c == 27 || c == 'q' || c == 'Q')
break;
}
system("pause");
return 0;
}
void detectAndDraw(Mat& img, CascadeClassifier& cascade,
CascadeClassifier& nestedCascade, double scale, bool tryflip) {
double t = 0;
vector<Rect> faces, faces2;
const static Scalar colors[] = { Scalar(255, 0, 0), Scalar(255, 128, 0),
Scalar(255, 255, 0), Scalar(0, 255, 0), Scalar(0, 128, 255), Scalar(
0, 255, 255), Scalar(0, 0, 255), Scalar(255, 0, 255) };
Mat gray, smallImg;
cvtColor(img, gray, COLOR_BGR2GRAY);
double fx = 1 / scale;
resize(gray, smallImg, Size(), fx, fx, INTER_LINEAR_EXACT);
equalizeHist(smallImg, smallImg);
t = (double) getTickCount();
cascade.detectMultiScale(smallImg, faces, 1.1, 2, 0
//|CASCADE_FIND_BIGGEST_OBJECT
//|CASCADE_DO_ROUGH_SEARCH
| CASCADE_SCALE_IMAGE, Size(30, 30));
if (tryflip) {
flip(smallImg, smallImg, 1);
cascade.detectMultiScale(smallImg, faces2, 1.1, 2, 0
//|CASCADE_FIND_BIGGEST_OBJECT
//|CASCADE_DO_ROUGH_SEARCH
| CASCADE_SCALE_IMAGE, Size(30, 30));
for (vector<Rect>::const_iterator r = faces2.begin(); r != faces2.end();
++r) {
faces.push_back(
Rect(smallImg.cols - r->x - r->width, r->y, r->width,
r->height));
}
}
t = (double) getTickCount() - t;
printf("detection time = %g ms\n", t * 1000 / getTickFrequency());
for (size_t i = 0; i < faces.size(); i++) {
Rect r = faces[i];
Mat smallImgROI;
vector<Rect> nestedObjects;
Point center;
Scalar color = colors[i % 8];
int radius;
double aspect_ratio = (double) r.width / r.height;
if (0.75 < aspect_ratio && aspect_ratio < 1.3) {
center.x = cvRound((r.x + r.width * 0.5) * scale);
center.y = cvRound((r.y + r.height * 0.5) * scale);
radius = cvRound((r.width + r.height) * 0.25 * scale);
circle(img, center, radius, color, 3, 8, 0);
} else
rectangle(img, Point(cvRound(r.x * scale), cvRound(r.y * scale)),
Point(cvRound((r.x + r.width - 1) * scale),
cvRound((r.y + r.height - 1) * scale)), color, 3, 8,
0);
if (nestedCascade.empty())
continue;
smallImgROI = smallImg(r);
nestedCascade.detectMultiScale(smallImgROI, nestedObjects, 1.1, 2, 0
//|CASCADE_FIND_BIGGEST_OBJECT
//|CASCADE_DO_ROUGH_SEARCH
//|CASCADE_DO_CANNY_PRUNING
| CASCADE_SCALE_IMAGE, Size(30, 30));
for (size_t j = 0; j < nestedObjects.size(); j++) {
Rect nr = nestedObjects[j];
center.x = cvRound((r.x + nr.x + nr.width * 0.5) * scale);
center.y = cvRound((r.y + nr.y + nr.height * 0.5) * scale);
radius = cvRound((nr.width + nr.height) * 0.25 * scale);
circle(img, center, radius, color, 3, 8, 0);
}
}
imshow("result", img);
}
Mat hwnd2mat(HWND hwnd) {
HDC hwindowDC, hwindowCompatibleDC;
int height, width, srcheight, srcwidth;
HBITMAP hbwindow;
Mat src;
BITMAPINFOHEADER bi;
hwindowDC = GetDC(hwnd);
hwindowCompatibleDC = CreateCompatibleDC(hwindowDC);
SetStretchBltMode(hwindowCompatibleDC, COLORONCOLOR);
RECT windowsize; // get the height and width of the screen
GetClientRect(hwnd, &windowsize);
srcheight = windowsize.bottom;
srcwidth = windowsize.right;
height = windowsize.bottom / 1; //change this to whatever size you want to resize to
width = windowsize.right / 1;
src.create(height, width, CV_8UC4);
// create a bitmap
hbwindow = CreateCompatibleBitmap(hwindowDC, width, height);
bi.biSize = sizeof(BITMAPINFOHEADER); //http://msdn.microsoft.com/en-us/library/windows/window/dd183402%28v=vs.85%29.aspx
bi.biWidth = width;
bi.biHeight = -height; //this is the line that makes it draw upside down or not
bi.biPlanes = 1;
bi.biBitCount = 32;
bi.biCompression = BI_RGB;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
// use the previously created device context with the bitmap
SelectObject(hwindowCompatibleDC, hbwindow);
// copy from the window device context to the bitmap device context
StretchBlt(hwindowCompatibleDC, 0, 0, width, height, hwindowDC, 0, 0,
srcwidth, srcheight, SRCCOPY); //change SRCCOPY to NOTSRCCOPY for wacky colors !
GetDIBits(hwindowCompatibleDC, hbwindow, 0, height, src.data,
(BITMAPINFO *) &bi, DIB_RGB_COLORS); //copy from hwindowCompatibleDC to hbwindow
// avoid memory leak
DeleteObject(hbwindow);
DeleteDC(hwindowCompatibleDC);
ReleaseDC(hwnd, hwindowDC);
return src;
}
| [
"32529373+bradosia@users.noreply.github.com"
] | 32529373+bradosia@users.noreply.github.com |
3734a8a2ffc4f78c032ae9bc14c4c4a4d2b8602b | 11ee35b4dc8588c21ea9e75619fc9475e04c408d | /tests/lexy/dsl/if.cpp | 02f9dfe7cecbe00b87d350ca268ebd0b3e02a4b5 | [
"BSL-1.0"
] | permissive | netcan/lexy | 7b258384756234135e7960e0b5dec1b0fba70d59 | 775e3d6bf1169ce13b08598d774e707c253f0792 | refs/heads/main | 2023-01-28T14:55:09.416540 | 2020-12-06T14:20:10 | 2020-12-06T16:17:25 | 318,488,104 | 0 | 0 | BSL-1.0 | 2020-12-04T10:55:56 | 2020-12-04T10:55:55 | null | UTF-8 | C++ | false | false | 3,160 | cpp | // Copyright (C) 2020 Jonathan Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
#include <lexy/dsl/if.hpp>
#include "verify.hpp"
TEST_CASE("dsl::if_()")
{
SUBCASE("pattern")
{
constexpr auto pattern = if_(LEXY_LIT("abc"));
CHECK(lexy::is_pattern<decltype(pattern)>);
constexpr auto empty = pattern_matches(pattern, "");
CHECK(empty);
CHECK(empty.match().empty());
constexpr auto abc = pattern_matches(pattern, "abc");
CHECK(abc);
CHECK(abc.match() == "abc");
constexpr auto ab = pattern_matches(pattern, "ab");
CHECK(ab);
CHECK(ab.match().empty());
}
SUBCASE("rule")
{
constexpr auto rule = if_(LEXY_LIT("abc"));
CHECK(lexy::is_rule<decltype(rule)>);
struct callback
{
const char* str;
constexpr int success(const char* cur)
{
if (cur == str)
return 0;
else
{
CONSTEXPR_CHECK(cur - str == 3);
return 1;
}
}
};
constexpr auto empty = rule_matches<callback>(rule, "");
CHECK(empty == 0);
constexpr auto success = rule_matches<callback>(rule, "abc");
CHECK(success == 1);
constexpr auto partial = rule_matches<callback>(rule, "ab");
CHECK(partial == 0);
}
SUBCASE("pattern branch")
{
constexpr auto pattern = if_(LEXY_LIT("a") >> LEXY_LIT("bc"));
CHECK(lexy::is_pattern<decltype(pattern)>);
constexpr auto empty = pattern_matches(pattern, "");
CHECK(empty);
CHECK(empty.match().empty());
constexpr auto abc = pattern_matches(pattern, "abc");
CHECK(abc);
CHECK(abc.match() == "abc");
constexpr auto ab = pattern_matches(pattern, "ab");
CHECK(!ab);
CHECK(ab.match().empty());
}
SUBCASE("rule branch")
{
constexpr auto rule = if_(LEXY_LIT("a") >> LEXY_LIT("bc"));
CHECK(lexy::is_rule<decltype(rule)>);
struct callback
{
const char* str;
constexpr int success(const char* cur)
{
if (cur == str)
return 0;
else
{
CONSTEXPR_CHECK(cur - str == 3);
return 1;
}
}
constexpr int error(test_error<lexy::expected_literal> e)
{
CONSTEXPR_CHECK(e.string() == "bc");
return -1;
}
};
constexpr auto empty = rule_matches<callback>(rule, "");
CHECK(empty == 0);
constexpr auto success = rule_matches<callback>(rule, "abc");
CHECK(success == 1);
constexpr auto condition = rule_matches<callback>(rule, "a");
CHECK(condition == -1);
constexpr auto partial = rule_matches<callback>(rule, "ab");
CHECK(partial == -1);
}
}
| [
"git@foonathan.net"
] | git@foonathan.net |
2c74b74bf0dbbc5e93e8bf3afd22ea489eb8c27f | 66f0e00d98ebcfbb467d9da9b1991981199cb022 | /src/routines/levelx/xaxpybatched.cpp | 6a4269be2dac2ef69f4a74b8fb9a9c77fd4cb654 | [
"Apache-2.0"
] | permissive | dividiti/CLBlast | 6623dc0a2de9f44a377f839f95f7adc11c1c8543 | ed607c494c599f0a4c1c8a3f79e34fa9d1e287d1 | refs/heads/master | 2020-12-25T22:37:13.779325 | 2018-07-23T12:44:02 | 2018-07-23T12:44:02 | 58,128,877 | 0 | 0 | null | 2016-05-05T12:20:21 | 2016-05-05T12:20:21 | null | UTF-8 | C++ | false | false | 4,060 | cpp |
// =================================================================================================
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
// width of 100 characters per line.
//
// Author(s):
// Cedric Nugteren <www.cedricnugteren.nl>
//
// This file implements the XaxpyBatched class (see the header for information about the class).
//
// =================================================================================================
#include "routines/levelx/xaxpybatched.hpp"
#include <string>
#include <vector>
namespace clblast {
// =================================================================================================
// Constructor: forwards to base class constructor
template <typename T>
XaxpyBatched<T>::XaxpyBatched(Queue &queue, EventPointer event, const std::string &name):
Routine(queue, event, name, {"Xaxpy"}, PrecisionValue<T>(), {}, {
#include "../../kernels/level1/level1.opencl"
#include "../../kernels/level1/xaxpy.opencl"
}) {
}
// =================================================================================================
// The main routine
template <typename T>
void XaxpyBatched<T>::DoAxpyBatched(const size_t n, const std::vector<T> &alphas,
const Buffer<T> &x_buffer, const std::vector<size_t> &x_offsets, const size_t x_inc,
const Buffer<T> &y_buffer, const std::vector<size_t> &y_offsets, const size_t y_inc,
const size_t batch_count) {
// Tests for a valid batch count
if ((batch_count < 1) || (alphas.size() != batch_count) ||
(x_offsets.size() != batch_count) || (y_offsets.size() != batch_count)) {
throw BLASError(StatusCode::kInvalidBatchCount);
}
// Makes sure all dimensions are larger than zero
if (n == 0) { throw BLASError(StatusCode::kInvalidDimension); }
// Tests the vectors for validity
for (auto batch = size_t{0}; batch < batch_count; ++batch) {
TestVectorX(n, x_buffer, x_offsets[batch], x_inc);
TestVectorY(n, y_buffer, y_offsets[batch], y_inc);
}
// Upload the arguments to the device
std::vector<int> x_offsets_int(x_offsets.begin(), x_offsets.end());
std::vector<int> y_offsets_int(y_offsets.begin(), y_offsets.end());
auto x_offsets_device = Buffer<int>(context_, BufferAccess::kReadOnly, batch_count);
auto y_offsets_device = Buffer<int>(context_, BufferAccess::kReadOnly, batch_count);
auto alphas_device = Buffer<T>(context_, BufferAccess::kReadOnly, batch_count);
x_offsets_device.Write(queue_, batch_count, x_offsets_int);
y_offsets_device.Write(queue_, batch_count, y_offsets_int);
alphas_device.Write(queue_, batch_count, alphas);
// Retrieves the Xaxpy kernel from the compiled binary
auto kernel = Kernel(program_, "XaxpyBatched");
// Sets the kernel arguments
kernel.SetArgument(0, static_cast<int>(n));
kernel.SetArgument(1, alphas_device());
kernel.SetArgument(2, x_buffer());
kernel.SetArgument(3, x_offsets_device());
kernel.SetArgument(4, static_cast<int>(x_inc));
kernel.SetArgument(5, y_buffer());
kernel.SetArgument(6, y_offsets_device());
kernel.SetArgument(7, static_cast<int>(y_inc));
// Launches the kernel
auto n_ceiled = Ceil(n, db_["WGS"]*db_["WPT"]);
auto global = std::vector<size_t>{n_ceiled/db_["WPT"], batch_count};
auto local = std::vector<size_t>{db_["WGS"], 1};
RunKernel(kernel, queue_, device_, global, local, event_);
}
// =================================================================================================
// Compiles the templated class
template class XaxpyBatched<half>;
template class XaxpyBatched<float>;
template class XaxpyBatched<double>;
template class XaxpyBatched<float2>;
template class XaxpyBatched<double2>;
// =================================================================================================
} // namespace clblast
| [
"web@cedricnugteren.nl"
] | web@cedricnugteren.nl |
074496dbf615cbe87048ae448701510f649b626e | a1dce8306153cc1bedf55e03e41a894328201c81 | /src/SDK/RH_Event_Spin2Win_Crate_classes.hpp | 794ebb5e73f02d8d32aeacf55dfa44334a4b70dd | [] | no_license | zanzo420/SDK-RadicalHeights | 97848bebd47baaa799e6a82546727fb9f829d7f1 | 0eeacd1418b2ee45c1522babed684baf4daf79a9 | refs/heads/master | 2020-03-29T22:22:00.257774 | 2018-04-20T14:11:36 | 2018-04-20T14:11:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,762 | hpp | #pragma once
// Radical Heights (ALPHA-1-201356) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "RH_Event_Spin2Win_Crate_structs.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// DynamicClass Event_Spin2Win_Crate.Event_Spin2Win_Crate_C
// 0x0358 (0x0748 - 0x03F0)
class AEvent_Spin2Win_Crate_C : public AShooterSpin2WinCrate
{
public:
class UStaticMeshComponent* Cylinder; // 0x03F0(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
class UParticleSystemComponent* ParticleSystem; // 0x03F8(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
class USkeletalMeshComponent* CraneClaw; // 0x0400(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
class USkeletalMeshComponent* Spin2WinBox; // 0x0408(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
class UAkComponent* AkEvent_Crate; // 0x0410(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
class UBoxComponent* DamageBox; // 0x0418(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
class USceneComponent* Scene; // 0x0420(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
class UMapMarkerComponent* MapMarker; // 0x0428(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
struct FVector CallFunc_K2_GetComponentLocation_ReturnValue; // 0x0430(0x000C) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_X; // 0x043C(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_Y; // 0x0440(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_Z; // 0x0444(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_Add_FloatFloat_ReturnValue; // 0x0448(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool CallFunc_HasAuthority_ReturnValue; // 0x044C(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool CallFunc_HasAuthority_ReturnValue2; // 0x044D(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x044E(0x0002) MISSED OFFSET
class UPrimitiveComponent* K2Node_ComponentBoundEvent_OverlappedComponent; // 0x0450(0x0008) (ExportObject, ZeroConstructor, Transient, InstancedReference, DuplicateTransient, IsPlainOldData)
class AActor* K2Node_ComponentBoundEvent_OtherActor; // 0x0458(0x0008) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
class UPrimitiveComponent* K2Node_ComponentBoundEvent_OtherComp; // 0x0460(0x0008) (ExportObject, ZeroConstructor, Transient, InstancedReference, DuplicateTransient, IsPlainOldData)
int K2Node_ComponentBoundEvent_OtherBodyIndex; // 0x0468(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool K2Node_ComponentBoundEvent_bFromSweep; // 0x046C(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData01[0x3]; // 0x046D(0x0003) MISSED OFFSET
struct FHitResult K2Node_ComponentBoundEvent_SweepResult; // 0x0470(0x0088) (Transient, DuplicateTransient, IsPlainOldData)
class AShooterCharacter* K2Node_DynamicCast_AsShooter_Character; // 0x04F8(0x0008) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool K2Node_DynamicCast_bSuccess; // 0x0500(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool CallFunc_IsAlive_ReturnValue; // 0x0501(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool CallFunc_Not_PreBool_ReturnValue; // 0x0502(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData02[0x5]; // 0x0503(0x0005) MISSED OFFSET
class UAkSoundInstance* CallFunc_PostAkEvent_ReturnValue; // 0x0508(0x0008) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
class UAkSoundInstance* CallFunc_PostAkEvent_ReturnValue2; // 0x0510(0x0008) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool CallFunc_HasAuthority_ReturnValue3; // 0x0518(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData03[0x7]; // 0x0519(0x0007) MISSED OFFSET
class UAkSoundInstance* CallFunc_PostAkEvent_ReturnValue3; // 0x0520(0x0008) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool CallFunc_K2_AttachToComponent_ReturnValue; // 0x0528(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData04[0x3]; // 0x0529(0x0003) MISSED OFFSET
struct FVector CallFunc_K2_GetComponentLocation_ReturnValue2; // 0x052C(0x000C) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_X2; // 0x0538(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_Y2; // 0x053C(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_Z2; // 0x0540(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
struct FVector CallFunc_MakeVector_ReturnValue; // 0x0544(0x000C) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
struct FHitResult CallFunc_K2_SetWorldLocation_SweepHitResult; // 0x0550(0x0088) (Transient, DuplicateTransient, IsPlainOldData)
bool CallFunc_K2_AttachToComponent_ReturnValue2; // 0x05D8(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData05[0x3]; // 0x05D9(0x0003) MISSED OFFSET
struct FVector CallFunc_K2_GetComponentLocation_ReturnValue3; // 0x05DC(0x000C) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
struct FVector CallFunc_K2_GetComponentLocation_ReturnValue4; // 0x05E8(0x000C) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_X3; // 0x05F4(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_Y3; // 0x05F8(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_Z3; // 0x05FC(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_X4; // 0x0600(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_Y4; // 0x0604(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_BreakVector_Z4; // 0x0608(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
struct FVector CallFunc_MakeVector_ReturnValue2; // 0x060C(0x000C) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_Add_FloatFloat_ReturnValue2; // 0x0618(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData06[0x4]; // 0x061C(0x0004) MISSED OFFSET
struct FHitResult CallFunc_K2_SetWorldLocation_SweepHitResult2; // 0x0620(0x0088) (Transient, DuplicateTransient, IsPlainOldData)
float CallFunc_Subtract_FloatFloat_ReturnValue; // 0x06A8(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
struct FVector CallFunc_MakeVector_ReturnValue3; // 0x06AC(0x000C) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool CallFunc_HasAuthority_ReturnValue4; // 0x06B8(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData07[0x7]; // 0x06B9(0x0007) MISSED OFFSET
struct FHitResult CallFunc_K2_SetWorldLocation_SweepHitResult3; // 0x06C0(0x0088) (Transient, DuplicateTransient, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("DynamicClass Event_Spin2Win_Crate.Event_Spin2Win_Crate_C");
return ptr;
}
void UserConstructionScript();
void ReceiveBeginPlay();
void OnStartSpin2WinCrateEvent();
void OnReleaseSpin2WinCrateEvent();
void OnLandSpin2WinCrateEvent();
void ExecuteUbergraph_Event_Spin2Win_Crate_5(int bpp__EntryPoint__pf);
void ExecuteUbergraph_Event_Spin2Win_Crate_4(int bpp__EntryPoint__pf);
void ExecuteUbergraph_Event_Spin2Win_Crate_2(int bpp__EntryPoint__pf);
void BndEvt__DamageBox_K2Node_ComponentBoundEvent_0_ComponentBeginOverlapSignature__DelegateSignature(class UPrimitiveComponent* bpp__OverlappedComponent__pf, class AActor* bpp__OtherActor__pf, class UPrimitiveComponent* bpp__OtherComp__pf, int bpp__OtherBodyIndex__pf, bool bpp__bFromSweep__pf, const struct FHitResult& bpp__SweepResult__pf);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"aeonlucid@outlook.com"
] | aeonlucid@outlook.com |
33f84e64d0472f072fb9b65b64c6510d2826917c | d27221545f07ab6b09b35ff2c8076f97869651a3 | /Trees/A_17 (IMP) CompletetBST.cpp | fce53f4be107512a2d5cbc5da28563df8b11e5a3 | [] | no_license | SinghVikram97/DP-and-Trees | b06534b56a2863dd672d16c73206be1601c5cca7 | d7f610a08785bd5847e53cd060570d9b6565a329 | refs/heads/master | 2022-11-28T01:35:35.819231 | 2020-07-22T06:32:43 | 2020-07-22T06:32:43 | 231,622,080 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,164 | cpp | // https://leetcode.com/problems/check-completeness-of-a-binary-tree/
// Full Node is a node which has both left and right children
// Once a node is found which isn't a full node
// All other nodes should be leaf nodes
// Also if there is a right child left child can't be empty
// To handle case
// 1
// / \
// 2 3
// \
// 4
class Solution
{
public:
bool isCompleteTree(TreeNode *root)
{
queue<TreeNode *> mq;
mq.push(root);
bool notFullFound = false;
while (!mq.empty())
{
TreeNode *front = mq.front();
mq.pop();
if (front->right && !front->left)
{
return false;
}
if (notFullFound)
{
// Every node should be a leaf node
if (front->left || front->right)
{
return false;
}
}
else
{
if (front->left && front->right)
{
}
else
{
notFullFound = true;
}
if (front->left)
{
mq.push(front->left);
}
if (front->right)
{
mq.push(front->right);
}
}
}
return true;
}
}; | [
"vikram.bedi97@gmail.com"
] | vikram.bedi97@gmail.com |
b3f4ad8e6f6c413d80ccf7a5a44ac6573aa4ac86 | 22d5d10c1f67efe97b8854760b7934d8e16d269b | /LeetCodeCPP/210. Course Schedule II/main.cpp | 0f3e51cc8f3f94fb6ae3e49a223df06346d865b2 | [
"Apache-2.0"
] | permissive | 18600130137/leetcode | 42241ece7fce1536255d427a87897015b26fd16d | fd2dc72c0b85da50269732f0fcf91326c4787d3a | refs/heads/master | 2020-04-24T01:48:03.049019 | 2019-10-17T06:02:57 | 2019-10-17T06:02:57 | 171,612,908 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,491 | cpp | //
// main.cpp
// 210. Course Schedule II
//
// Created by admin on 2019/6/13.
// Copyright © 2019年 liu. All rights reserved.
//
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
class Solution {
public:
vector<int> findOrder(int n, vector<vector<int>>& p) {
int m=p.size();
vector<int> ret;
if(m==0){
for(int i=0;i<n;i++){
ret.push_back(i);
}
return ret;
}
vector<vector<int>> graph(n);
vector<int> indegree(n,0);
for(auto v:p){
graph[v[1]].push_back(v[0]);
indegree[v[0]]++;
}
queue<int> helper;
for(int i=0;i<indegree.size();i++){
if(indegree[i]==0){
helper.push(i);
}
}
int count=0;
while(!helper.empty()){
int front=helper.front();
helper.pop();
count++;
ret.push_back(front);
for(auto item:graph[front]){
if(--indegree[item]==0){
helper.push(item);
}
}
}
vector<int> empty;
return (count==n)?ret:empty;
}
};
int main(int argc, const char * argv[]) {
vector<vector<int>> input={{1,0},{2,0},{3,1},{3,2}};
Solution so=Solution();
vector<int> ret=so.findOrder(4, input);
for(auto i:ret){
cout<<i<<" ";
}
cout<<endl;
return 0;
}
| [
"guodongliu6@crediteses.cn"
] | guodongliu6@crediteses.cn |
f9f16ff2612ae930186a4d3c7799fe8b01d5b8a1 | 1f6c81a14481c7f791fe983a44c9bd2993d60cbd | /include/control headers/traycontrol.hpp | 21dfdd54746c3d413260836276f02657989bba7a | [] | no_license | kitorer/mickey_vex2019_robot | 3efb14caee5ed998793439a9bc479f72c1a2040e | d2db38f6c962aab75fd2c0a62a99b1ab64581ff4 | refs/heads/master | 2023-08-01T14:13:27.465285 | 2021-09-12T22:05:20 | 2021-09-12T22:05:20 | 209,926,643 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 276 | hpp | #include "main.h"
//traycontrol header file
void Tray_control(void*);
void setTrayAnglerMotor(void*);
void auto_tray();
void setTrayAngler (int power);
void tray_macro(void*);
void set_tray(int distance, int voltage);
void reverse_tray(void);
void reverse_tray_macro(void*);
| [
"31045060+kitorer@users.noreply.github.com"
] | 31045060+kitorer@users.noreply.github.com |
1c3b82aeeeaf9bad7c0687e6149b3cf105d02342 | e4f3379add5a033c9c98fec029135742d2d977f6 | /Secular_Simulation_Code/Orbit.h | 863780171caa46895c068494826e0ebd944113d3 | [] | no_license | oygx210/LISA-Asteroid-Simulation | cdc711dd299ba8f35adc1e1060411ca058cf5284 | 7eff478a63689db6983588f6a382540c7906bc27 | refs/heads/master | 2022-11-29T14:12:28.286527 | 2020-08-13T15:35:21 | 2020-08-13T15:35:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,243 | h | #pragma once
#include <string>
#include "VectorSpace.h"
namespace lisa{
class Orbit
{
double trueAnomaly, eccentricAnomaly, meanAnomaly, meanAnomaly0;
double semiMajorAxis, semiLatusRectum, eccentricity;
double inclination, longitudeOfAscendingNode, argumentOfPeriapsis;
double meanAngularMotion, time, mass;
double cLongAsc, sLongAsc, cInc, sInc;
double r;
std::string name;
inline void trueToEccAnom();
inline void eccToTrueAnom();
inline void meanToEccAnom();
inline void makeR();
inline void eccToMeanAnom();
public:
Orbit();
Orbit(double anomaly, double ecc, double semiMajor,
double incline, double longAscend,
double argPeri, bool isMeanAnom);
Orbit(double anomaly, double ecc, double semiMajor,
double incline, double longAscend,
double argPeri, bool isMeanAnom, double timeOfParameters,
double definedTimeZero, double inMass, std::string inName);
void setTime(double newTime);
double x();
double y();
double z();
vsu::ProductSpace<double, double, double> pos();
double vx();
double vy();
double vz();
vsu::ProductSpace<double, double, double> vel();
double getMass();
std::string getName();
};
}
#undef TOTAL_ACCESS
| [
"davidbron15@gmail.com"
] | davidbron15@gmail.com |
f5449b3720ee2df399268a1ae26ad3da4c726d98 | bc15af91d4c997d50a1e4b618b0afa460ba58297 | /src/verilog/ast/types/display_statement.h | a6e1639d305262dd737665d6af1d3a5451ea62e4 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | sagniknitr/cascade | fa3f0ced7a420170156e68695da69a3260c01fa9 | 2fc36ec208b87013c58f86e2c152a3fe2f21d5fe | refs/heads/master | 2020-04-19T11:24:40.854017 | 2019-01-26T03:48:21 | 2019-01-26T03:48:21 | 160,314,791 | 0 | 0 | NOASSERTION | 2019-01-20T06:52:27 | 2018-12-04T07:12:32 | C++ | UTF-8 | C++ | false | false | 2,827 | h | // Copyright 2017-2019 VMware, Inc.
// SPDX-License-Identifier: BSD-2-Clause
//
// The BSD-2 license (the License) set forth below applies to all parts of the
// Cascade project. You may not use this file except in compliance with the
// License.
//
// BSD-2 License
//
// 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.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CASCADE_SRC_VERILOG_AST_DISPLAY_STATEMENT_H
#define CASCADE_SRC_VERILOG_AST_DISPLAY_STATEMENT_H
#include "src/verilog/ast/types/expression.h"
#include "src/verilog/ast/types/macro.h"
#include "src/verilog/ast/types/system_task_enable_statement.h"
namespace cascade {
class DisplayStatement : public SystemTaskEnableStatement {
public:
// Constructors:
DisplayStatement();
template <typename ArgsItr>
DisplayStatement(ArgsItr args_begin__, ArgsItr args_end__);
~DisplayStatement() override;
// Node Interface:
NODE(DisplayStatement)
DisplayStatement* clone() const override;
// Get/Set:
MANY_GET_SET(DisplayStatement, Expression, args)
private:
MANY_ATTR(Expression, args);
};
inline DisplayStatement::DisplayStatement() : SystemTaskEnableStatement() {
MANY_DEFAULT_SETUP(args);
parent_ = nullptr;
}
template <typename ArgsItr>
inline DisplayStatement::DisplayStatement(ArgsItr args_begin__, ArgsItr args_end__) : DisplayStatement() {
MANY_SETUP(args);
}
inline DisplayStatement::~DisplayStatement() {
MANY_TEARDOWN(args);
}
inline DisplayStatement* DisplayStatement::clone() const {
auto* res = new DisplayStatement();
MANY_CLONE(args);
return res;
}
} // namespace cascade
#endif
| [
"eric.schkufza@gmail.com"
] | eric.schkufza@gmail.com |
5cb8ba699af6c90e258f9bcf8e2bc9cb481bf5cc | 2ac1f0547aabde67fc3883240785e7abe731c8ac | /Singleton/Singleton/Singleton.cpp | dfe8b750d7307fbc90c856be621146dbd42d5a37 | [] | no_license | Magicmay/designMode | 2edc4b091736b228628bc4d7f5ea31a2795d1005 | 992b00fa8debd5e40bc71d3fddb0bc1fb5a56232 | refs/heads/master | 2021-01-10T17:01:22.322852 | 2016-05-05T09:31:46 | 2016-05-05T09:31:46 | 54,381,308 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 273 | cpp | #include "Singleton.h"
#include <iostream>
using namespace std;
Singleton* Singleton::_instance = 0;
Singleton::Singleton()
{
cout << "Singleton...." << endl;
}
Singleton* Singleton::Instance()
{
if (_instance==0)
{
_instance = new Singleton();
}
return _instance;
} | [
"634665383@qq.com"
] | 634665383@qq.com |
d150d22608fbf06aae534e2efe3692d6b252e366 | 156d7b3e35d249377df5923017cc8af52489f97f | /brlyd/BrlydOpprc.h | a6d2c28c4a100b0c2c5fd95fdc3f51f0188bdc9a | [
"MIT"
] | permissive | mpsitech/brly-BeamRelay | fa11efae1fdd34110505ac10dee9d2e96a5ea8bd | ade30cfa9285360618d9d8c717fe6591da0c8683 | refs/heads/master | 2022-09-30T21:12:35.188234 | 2022-09-12T20:46:24 | 2022-09-12T20:46:24 | 282,705,295 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 844 | h | /**
* \file BrlydOpprc.h
* operation processor for Brly daemon (declarations)
* \copyright (C) 2016-2020 MPSI Technologies GmbH
* \author Alexander Wirthmueller (auto-generation)
* \date created: 11 Jan 2021
*/
// IP header --- ABOVE
#ifndef BRLYDOPPRC_H
#define BRLYDOPPRC_H
/**
* BrlydOpprc
*/
namespace BrlydOpprc {
void* run(void* arg);
void cleanup(void* _arg);
Sbecore::uint CurlPostrecv(void* data, Sbecore::uint size, Sbecore::uint blocksize, void* _ret);
void writeDpchInv(CURL* curl, XchgBrlyd* xchg, ReqBrly* req);
Sbecore::uint readDpchRet(XchgBrlyd* xchg, ReqBrly* req);
};
/**
* BrlydOpprc_arg
*/
struct BrlydOpprc_arg {
XchgBrlyd* xchg;
NodeBrly* node;
};
/**
* BrlydOpprc_cuarg
*/
struct BrlydOpprc_cuarg {
XchgBrlyd* xchg;
ReqBrly** req;
Sbecore::ubigint* oref;
Sbecore::ubigint* jref;
};
#endif
| [
"aw@mpsitech.com"
] | aw@mpsitech.com |
648e3a4598cd1eae45874597d65ab1c08e716172 | f81124e4a52878ceeb3e4b85afca44431ce68af2 | /re20_3/processor27/20/U | 73a653be878ab814e093fc5c2b44dc4a310a1685 | [] | no_license | chaseguy15/coe-of2 | 7f47a72987638e60fd7491ee1310ee6a153a5c10 | dc09e8d5f172489eaa32610e08e1ee7fc665068c | refs/heads/master | 2023-03-29T16:59:14.421456 | 2021-04-06T23:26:52 | 2021-04-06T23:26:52 | 355,040,336 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 38,520 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "20";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
928
(
(0.149913 -0.00195293 2.59095e-22)
(0.155586 -0.00194117 -1.52067e-22)
(0.161226 -0.00192887 -1.15088e-22)
(0.166832 -0.00191608 -2.73821e-22)
(0.172403 -0.00190286 -5.43549e-23)
(0.177937 -0.00188925 -2.96138e-22)
(0.151208 -0.00585463 -2.38996e-21)
(0.156867 -0.00581938 1.59425e-21)
(0.162494 -0.00578251 -4.17582e-21)
(0.168087 -0.00574418 4.1761e-22)
(0.173645 -0.00570454 1.28089e-22)
(0.179167 -0.00566375 1.54604e-21)
(0.153792 -0.00974121 -2.28279e-21)
(0.159425 -0.0096826 -2.27417e-21)
(0.165026 -0.00962129 3.88865e-21)
(0.170594 -0.00955756 -5.01251e-21)
(0.176126 -0.00949165 2.03362e-21)
(0.181621 -0.00942382 2.65728e-21)
(0.157657 -0.0136027 5.44572e-21)
(0.163251 -0.0135209 -5.65359e-21)
(0.168813 -0.0134354 -2.54085e-21)
(0.174341 -0.0133465 5.70965e-21)
(0.179835 -0.0132545 2.78961e-21)
(0.185292 -0.0131599 -4.06165e-21)
(0.16833 -0.0173244 7.33853e-21)
(0.17384 -0.017215 5.58458e-21)
(0.179317 -0.0171012 -1.13543e-20)
(0.184759 -0.0169836 8.16548e-21)
(0.190165 -0.0168626 -3.15205e-21)
(0.174645 -0.0210834 1.12341e-21)
(0.18009 -0.0209505 7.83503e-22)
(0.185502 -0.0208123 -5.99308e-21)
(0.19088 -0.0206695 2.03406e-21)
(0.196223 -0.0205224 5.34327e-21)
(0.182172 -0.0247883 4.98116e-21)
(0.18754 -0.0246324 5.19814e-21)
(0.192875 -0.0244703 -1.21266e-20)
(0.198177 -0.0243028 6.54543e-21)
(0.203444 -0.0241304 5.75325e-22)
(0.190884 -0.0284297 1.63271e-21)
(0.196162 -0.0282514 1.80496e-21)
(0.201408 -0.0280661 -3.70094e-22)
(0.206621 -0.0278745 -8.49308e-21)
(0.2118 -0.0276774 8.6182e-21)
(0.20075 -0.0319984 6.12923e-21)
(0.205926 -0.0317985 -5.79015e-21)
(0.211071 -0.0315907 1.29894e-21)
(0.216183 -0.0313759 6.00504e-21)
(0.221262 -0.0311547 -4.25963e-21)
(0.211735 -0.0354856 9.72662e-21)
(0.216797 -0.0352648 -2.11114e-21)
(0.221829 -0.0350354 1.18973e-21)
(0.226829 -0.0347982 -4.57917e-21)
(0.231796 -0.0345539 1.80256e-20)
(0.2238 -0.0388825 7.57901e-21)
(0.228737 -0.0386419 6.06402e-21)
(0.233643 -0.0383918 1.05778e-20)
(0.238519 -0.0381332 -3.69637e-20)
(0.243364 -0.0378669 1.65754e-20)
(0.236903 -0.042181 3.01869e-20)
(0.241702 -0.0419215 -3.89331e-22)
(0.246472 -0.0416519 -3.29322e-20)
(0.251213 -0.041373 2.09548e-20)
(0.255924 -0.0410858 2.73761e-22)
(0.260604 -0.0407912 -1.09048e-21)
(0.255647 -0.045096 -9.10071e-21)
(0.260271 -0.0448079 -8.87446e-21)
(0.264866 -0.04451 1.73585e-20)
(0.269433 -0.0442031 -2.56335e-20)
(0.27397 -0.0438883 1.18043e-20)
(0.270524 -0.0481577 -1.47896e-20)
(0.27499 -0.0478527 9.25319e-21)
(0.279429 -0.0475371 2.441e-21)
(0.283842 -0.0472119 -1.97671e-20)
(0.288226 -0.0468783 1.36988e-20)
(0.286281 -0.0510999 1.35847e-20)
(0.290579 -0.0507793 1.08577e-20)
(0.294853 -0.0504475 -1.40821e-20)
(0.299101 -0.0501056 -2.15029e-20)
(0.303323 -0.0497546 2.04304e-20)
(0.302864 -0.0539159 -1.83039e-21)
(0.306985 -0.0535814 1.66811e-20)
(0.311084 -0.0532351 -2.21163e-20)
(0.315159 -0.052878 9.14819e-21)
(0.319209 -0.0525113 6.39796e-21)
(0.320216 -0.0565999 1.09748e-20)
(0.324152 -0.0562532 -3.24436e-20)
(0.328066 -0.055894 2.55892e-20)
(0.331959 -0.0555235 -6.17444e-21)
(0.33583 -0.0551428 -9.02223e-21)
(0.342021 -0.0587893 -3.94162e-20)
(0.345744 -0.0584192 1.85486e-20)
(0.349447 -0.0580371 8.03142e-21)
(0.35313 -0.0576443 -1.71002e-20)
(0.356793 -0.0572417 1.3675e-20)
(0.360535 -0.0611849 -5.32798e-21)
(0.364057 -0.0608059 1.09313e-20)
(0.367563 -0.0604142 1.92564e-20)
(0.371051 -0.0600112 -1.7035e-20)
(0.374522 -0.059598 1.41027e-20)
(0.379631 -0.0634359 4.05486e-21)
(0.382946 -0.06305 -5.17643e-21)
(0.386248 -0.0626509 1.337e-20)
(0.389535 -0.0622398 -8.85788e-21)
(0.392807 -0.0618179 1.15752e-20)
(0.399248 -0.0655387 -5.25417e-21)
(0.402351 -0.0651482 1.24191e-20)
(0.405442 -0.0647438 -1.58342e-20)
(0.408521 -0.0643268 8.36749e-21)
(0.411589 -0.0638983 1.44544e-20)
(0.422208 -0.0670975 1.44657e-21)
(0.425084 -0.0666902 3.31496e-20)
(0.42795 -0.0662695 -1.26254e-20)
(0.430808 -0.0658367 -1.14044e-20)
(0.433656 -0.065393 7.73467e-21)
(0.442457 -0.0688958 1.34063e-20)
(0.445112 -0.0684879 1.30712e-20)
(0.447762 -0.0680659 2.7385e-21)
(0.450406 -0.0676311 -4.74743e-20)
(0.453043 -0.0671847 4.42599e-20)
(0.463036 -0.0705416 3.06071e-20)
(0.465467 -0.0701355 -3.88803e-20)
(0.467896 -0.0697147 2.96792e-20)
(0.470322 -0.0692802 -1.54108e-20)
(0.472745 -0.0688335 2.63676e-20)
(0.486086 -0.0716325 3.11377e-20)
(0.488291 -0.0712153 2.58765e-20)
(0.490497 -0.0707836 -2.17582e-20)
(0.492703 -0.0703389 7.91721e-21)
(0.494909 -0.0698822 2.61431e-20)
(0.50691 -0.0729785 -4.26709e-21)
(0.508889 -0.0725673 -2.6056e-20)
(0.510873 -0.0721409 4.17998e-20)
(0.51286 -0.0717006 -9.07971e-22)
(0.51485 -0.0712476 9.0033e-21)
(0.52788 -0.0741707 4.56607e-21)
(0.529631 -0.0737682 -1.72267e-20)
(0.531391 -0.0733497 2.18381e-20)
(0.533159 -0.0729163 -1.35575e-20)
(0.534933 -0.0724694 1.04957e-20)
(0.550461 -0.0748203 -4.81242e-20)
(0.551996 -0.074412 5.49617e-21)
(0.553543 -0.073988 1.64585e-20)
(0.555101 -0.0735495 -1.33208e-20)
(0.556667 -0.0730978 2.70918e-20)
(0.571322 -0.0757559 2.63388e-20)
(0.572633 -0.07536 -6.46357e-20)
(0.57396 -0.0749473 2.00581e-20)
(0.575301 -0.0745192 3.35221e-20)
(0.576655 -0.0740768 -2.2826e-20)
(0.592161 -0.0765796 -5.05904e-20)
(0.59325 -0.0761987 -9.39267e-21)
(0.594357 -0.0757999 2.93366e-20)
(0.595483 -0.0753846 3.73837e-20)
(0.596625 -0.074954 -3.14152e-20)
(0.625364 -0.0770121 0)
(0.62617 -0.0766446 0)
(0.626999 -0.0762588 0)
(0.62785 -0.0758562 0)
(0.62872 -0.0754379 0)
(0.672565 -0.0778294 0)
(0.672926 -0.0774957 0)
(0.673317 -0.0771422 -6.72692e-29)
(0.673736 -0.0767703 6.72692e-29)
(0.674182 -0.0763813 0)
(0.720062 -0.078012 0)
(0.71998 -0.0777266 0)
(0.719935 -0.0774192 3.69926e-28)
(0.719925 -0.0770914 -3.69926e-28)
(0.71995 -0.0767445 0)
(0.767292 -0.0775533 0)
(0.766781 -0.0773268 0)
(0.766314 -0.0770759 -4.95631e-11)
(0.765888 -0.0768023 4.95631e-11)
(0.765503 -0.0765074 0)
(0.813722 -0.0764969 0)
(0.812805 -0.0763379 0)
(0.811938 -0.0761521 -4.94152e-11)
(0.811119 -0.075941 4.94152e-11)
(0.810346 -0.0757063 0)
(0.858853 -0.0748827 0)
(0.857564 -0.0747988 0)
(0.856329 -0.0746855 0)
(0.855146 -0.0745444 0)
(0.854014 -0.0743771 0)
(0.902236 -0.0727628 0)
(0.900614 -0.07276 0)
(0.899049 -0.072725 -4.90304e-11)
(0.897541 -0.0726596 4.90304e-11)
(0.896086 -0.0725655 0)
(0.943477 -0.0702003 0)
(0.941568 -0.0702823 0)
(0.939719 -0.0703295 -4.87927e-11)
(0.937928 -0.0703437 4.87927e-11)
(0.936192 -0.0703267 0)
(0.982249 -0.0672652 0)
(0.980103 -0.0674337 0)
(0.978018 -0.0675649 -4.85244e-11)
(0.975991 -0.0676606 4.85244e-11)
(0.974021 -0.0677227 0)
(1.01829 -0.0640318 0)
(1.01597 -0.0642862 0)
(1.01369 -0.0645011 -4.82259e-11)
(1.01148 -0.0646783 4.82259e-11)
(1.00932 -0.0648198 0)
(1.05143 -0.0605759 0)
(1.04897 -0.0609136 0)
(1.04657 -0.0612099 -1.68676e-27)
(1.04422 -0.0614667 1.68676e-27)
(1.04192 -0.0616858 0)
(1.08156 -0.0569716 0)
(1.07901 -0.0573883 0)
(1.07652 -0.057762 -1.22319e-27)
(1.07408 -0.0580946 1.22319e-27)
(1.0717 -0.058388 0)
(1.10862 -0.0532892 0)
(1.10604 -0.053779 0)
(1.10351 -0.0542246 0)
(1.10103 -0.054628 0)
(1.0986 -0.0549908 0)
(1.13266 -0.049593 0)
(1.13009 -0.0501488 0)
(1.12756 -0.0506597 -4.67478e-11)
(1.12508 -0.0511274 4.67478e-11)
(1.12263 -0.0515539 0)
(1.15375 -0.0459394 0)
(1.15122 -0.0465534 0)
(1.14873 -0.0471221 -9.2631e-11)
(1.14628 -0.0476472 9.2631e-11)
(1.14387 -0.0481306 0)
(1.17202 -0.0423763 0)
(1.16957 -0.0430403 0)
(1.16715 -0.0436589 -4.58625e-11)
(1.16476 -0.0442339 4.58625e-11)
(1.1624 -0.044767 0)
(1.18764 -0.0389427 0)
(1.18529 -0.0396483 0)
(1.18296 -0.0403089 1.5985e-27)
(1.18066 -0.0409261 -1.5985e-27)
(1.17839 -0.0415016 0)
(1.20081 -0.0356683 0)
(1.19857 -0.0364074 0)
(1.19636 -0.0371021 1.15535e-27)
(1.19417 -0.037754 -1.15535e-27)
(1.19199 -0.0383645 0)
(1.21174 -0.0325743 0)
(1.20963 -0.0333393 0)
(1.20754 -0.0340607 -1.14249e-27)
(1.20547 -0.03474 1.14249e-27)
(1.20341 -0.0353786 0)
(1.22065 -0.0296742 0)
(1.21868 -0.030458 0)
(1.21672 -0.0311991 -4.3894e-11)
(1.21478 -0.0318991 4.3894e-11)
(1.21284 -0.0325592 0)
(1.22777 -0.0269747 0)
(1.22594 -0.0277707 0)
(1.22412 -0.0285254 -8.67514e-11)
(1.2223 -0.0292399 8.67514e-11)
(1.22049 -0.0299156 0)
(1.23331 -0.0244765 0)
(1.23162 -0.0252792 0)
(1.22993 -0.0260418 -4.28519e-11)
(1.22825 -0.0267655 4.28519e-11)
(1.22657 -0.0274513 0)
(1.23749 -0.022176 0)
(1.23594 -0.0229806 0)
(1.23438 -0.0237462 3.02361e-28)
(1.23282 -0.0244742 -3.02361e-28)
(1.23127 -0.0251655 0)
(1.2405 -0.0200662 0)
(1.23907 -0.0208682 0)
(1.23764 -0.0216328 -4.17967e-11)
(1.23621 -0.0223609 4.17967e-11)
(1.23478 -0.0230536 0)
(1.24252 -0.0181372 0)
(1.24121 -0.0189332 0)
(1.2399 -0.0196932 -4.12695e-11)
(1.23859 -0.0204179 4.12695e-11)
(1.23727 -0.0211085 0)
(1.2437 -0.0163778 0)
(1.24251 -0.0171649 0)
(1.24132 -0.0179172 -4.07449e-11)
(1.24011 -0.0186357 4.07449e-11)
(1.23891 -0.0193211 0)
(1.2442 -0.0147758 0)
(1.24312 -0.0155515 0)
(1.24203 -0.0162937 -4.02245e-11)
(1.24093 -0.0170034 4.02245e-11)
(1.23982 -0.0176813 0)
(1.24414 -0.0133188 0)
(1.24315 -0.014081 0)
(1.24216 -0.0148112 -3.97101e-11)
(1.24115 -0.0155101 3.97101e-11)
(1.24014 -0.0161784 0)
(1.24363 -0.0119945 0)
(1.24273 -0.0127416 0)
(1.24182 -0.013458 -7.84055e-11)
(1.2409 -0.0141443 7.84055e-11)
(1.23998 -0.0148013 0)
(1.24275 -0.0107911 0)
(1.24194 -0.0115218 0)
(1.24111 -0.012223 -7.74076e-11)
(1.24027 -0.0128954 7.74076e-11)
(1.23942 -0.0135396 0)
(1.2416 -0.00969754 0)
(1.24086 -0.0104107 0)
(1.2401 -0.0110956 -7.64288e-11)
(1.23934 -0.0117529 7.64288e-11)
(1.23856 -0.0123831 0)
(1.24023 -0.00870372 0)
(1.23956 -0.00939835 0)
(1.23887 -0.010066 -3.77355e-11)
(1.23817 -0.0107071 3.77355e-11)
(1.23745 -0.0113223 0)
(1.23871 -0.00780033 0)
(1.23809 -0.00847563 0)
(1.23746 -0.00912508 -3.72679e-11)
(1.23682 -0.00974922 3.72679e-11)
(1.23617 -0.0103486 0)
(1.23707 -0.00697902 0)
(1.23651 -0.00763427 0)
(1.23593 -0.00826486 -7.36251e-11)
(1.23535 -0.00887125 7.36251e-11)
(1.23475 -0.00945394 0)
(1.23536 -0.00623231 0)
(1.23485 -0.0068669 0)
(1.23432 -0.00747797 -7.27403e-11)
(1.23378 -0.00806595 7.27403e-11)
(1.23323 -0.00863131 0)
(1.2336 -0.00555356 0)
(1.23313 -0.00616692 0)
(1.23265 -0.00675789 -3.59413e-11)
(1.23216 -0.00732686 3.59413e-11)
(1.23165 -0.00787426 0)
(1.23182 -0.00493685 0)
(1.2314 -0.00552848 0)
(1.23096 -0.00609881 -9.1407e-28)
(1.23051 -0.00664822 9.1407e-28)
(1.23004 -0.00717708 0)
(1.23005 -0.00437694 0)
(1.22966 -0.00494635 0)
(1.22926 -0.00549556 -1.23701e-27)
(1.22885 -0.00602489 1.23701e-27)
(1.22842 -0.0065347 0)
(1.22829 -0.00386912 0)
(1.22794 -0.00441589 0)
(1.22758 -0.00494351 -8.93871e-28)
(1.22719 -0.00545229 8.93871e-28)
(1.2268 -0.00594255 0)
(1.22657 -0.00340923 0)
(1.22625 -0.00393294 0)
(1.22591 -0.00443854 -3.4372e-11)
(1.22557 -0.00492633 3.4372e-11)
(1.2252 -0.00539658 0)
(1.22488 -0.00299348 0)
(1.2246 -0.00349375 0)
(1.22429 -0.00397694 -3.40184e-11)
(1.22397 -0.00444331 3.40184e-11)
(1.22364 -0.00489313 0)
(1.22325 -0.00261845 0)
(1.22299 -0.00309493 0)
(1.22272 -0.00355534 -3.36811e-11)
(1.22242 -0.0039999 3.36811e-11)
(1.22212 -0.00442887 0)
(1.22168 -0.00228102 0)
(1.22145 -0.00273338 0)
(1.2212 -0.00317066 -3.33602e-11)
(1.22093 -0.00359306 3.33602e-11)
(1.22065 -0.00400081 0)
(1.22018 -0.00197832 0)
(1.21997 -0.00240625 0)
(1.21974 -0.00282007 0)
(1.21949 -0.00321997 0)
(1.21923 -0.00360614 0)
(1.21874 -0.00170766 0)
(1.21856 -0.00211089 0)
(1.21835 -0.00250096 -3.27691e-11)
(1.21813 -0.00287804 3.27691e-11)
(1.21789 -0.00324231 0)
(1.21739 -0.00146655 0)
(1.21722 -0.00184482 0)
(1.21703 -0.00221086 -3.24992e-11)
(1.21683 -0.00256484 3.24992e-11)
(1.21661 -0.00290691 0)
(1.21611 -0.00125261 0)
(1.21595 -0.00160569 0)
(1.21579 -0.00194746 1.1356e-27)
(1.2156 -0.00227807 -1.1356e-27)
(1.2154 -0.00259766 0)
(1.21491 -0.00106361 0)
(1.21477 -0.00139129 0)
(1.21462 -0.00170856 0)
(1.21445 -0.00201556 0)
(1.21427 -0.00231242 0)
(1.21379 -0.000897393 0)
(1.21367 -0.00119948 0)
(1.21354 -0.00149205 -3.17943e-11)
(1.21338 -0.00177523 3.17943e-11)
(1.21321 -0.00204912 0)
(1.21277 -0.00075189 0)
(1.21266 -0.00102821 0)
(1.21254 -0.00129591 -3.15947e-11)
(1.2124 -0.00155506 3.15947e-11)
(1.21224 -0.00180578 0)
(1.21183 -0.000625107 0)
(1.21173 -0.000875524 0)
(1.21162 -0.00111817 -3.1413e-11)
(1.2115 -0.00135314 3.1413e-11)
(1.21135 -0.0015805 0)
(1.21098 -0.000515105 0)
(1.2109 -0.000739485 0)
(1.2108 -0.000956948 -6.24984e-11)
(1.21068 -0.00116757 6.24984e-11)
(1.21054 -0.00137141 0)
(1.21022 -0.000419995 0)
(1.21015 -0.000618225 0)
(1.21006 -0.000810378 -6.22069e-11)
(1.20995 -0.000996516 6.22069e-11)
(1.20983 -0.0011767 0)
(1.20955 -0.000337932 0)
(1.20949 -0.000509915 0)
(1.20941 -0.000676652 -3.09758e-11)
(1.20931 -0.000838194 3.09758e-11)
(1.20919 -0.000994598 0)
(1.20898 -0.000267105 0)
(1.20893 -0.00041276 0)
(1.20885 -0.000553991 0)
(1.20876 -0.00069084 0)
(1.20865 -0.000823354 0)
(1.20851 -0.000205734 0)
(1.20846 -0.000324994 0)
(1.20839 -0.000440645 0)
(1.2083 -0.00055272 0)
(1.2082 -0.000661257 0)
(1.20812 -0.000152067 0)
(1.20808 -0.00024488 0)
(1.20801 -0.000334891 -3.07019e-11)
(1.20793 -0.000422126 3.07019e-11)
(1.20783 -0.000506616 0)
(1.20783 -0.000104373 0)
(1.20779 -0.000170696 0)
(1.20773 -0.000235021 -6.12942e-11)
(1.20766 -0.000297368 6.12942e-11)
(1.20756 -0.000357755 0)
(1.20764 -6.08978e-05 0)
(1.2076 -0.000100704 0)
(1.20755 -0.000139313 -3.06105e-11)
(1.20747 -0.000176735 3.06105e-11)
(1.20738 -0.000212984 0)
(1.20755 -1.99963e-05 0)
(1.20751 -3.32674e-05 0)
(1.20745 -4.61397e-05 -3.11673e-11)
(1.20738 -5.86168e-05 3.11673e-11)
(1.20729 -7.07028e-05 0)
(0.903917 0.0727318 0)
(0.945446 0.0700817 0)
(0.984455 0.0670576 0)
(1.02068 0.0637359 0)
(1.05395 0.0601946 0)
(1.08415 0.0565098 0)
(1.11125 0.0527532 0)
(1.13527 0.0489902 0)
(1.15631 0.0452781 0)
(1.1745 0.0416652 0)
(1.19002 0.0381904 0)
(1.20307 0.0348831 0)
(1.21386 0.0317642 0)
(1.22263 0.0288465 0)
(1.22961 0.0261358 0)
(1.23501 0.0236323 0)
(1.23905 0.0213315 0)
(1.24192 0.0192255 0)
(1.24381 0.017304 0)
(1.24488 0.015555 0)
(1.24528 0.0139658 0)
(1.24512 0.0125236 0)
(1.24451 0.0112157 0)
(1.24356 0.0100301 0)
(1.24233 0.00895546 0)
(1.2409 0.00798143 0)
(1.23931 0.00709861 0)
(1.23761 0.00629855 0)
(1.23585 0.0055737 0)
(1.23405 0.00491733 0)
(1.23223 0.0043235 0)
(1.23042 0.00378691 0)
(1.22862 0.00330284 0)
(1.22687 0.00286708 0)
(1.22515 0.00247582 0)
(1.2235 0.00212562 0)
(1.2219 0.00181333 0)
(1.22037 0.00153604 0)
(1.21892 0.00129107 0)
(1.21754 0.00107587 0)
(1.21624 0.000888065 0)
(1.21502 0.000725387 0)
(1.21389 0.000585665 0)
(1.21285 0.000466813 0)
(1.2119 0.000366814 0)
(1.21104 0.000283714 0)
(1.21027 0.000215608 0)
(1.2096 0.000160633 0)
(1.20902 0.000116967 0)
(1.20854 8.28171e-05 0)
(1.20815 5.64184e-05 0)
(1.20786 3.60275e-05 0)
(1.20766 1.98797e-05 0)
(1.20757 6.32139e-06 0)
(0.625363 0.0770126 0)
(0.672565 0.0778298 0)
(0.720061 0.0780124 0)
(0.767291 0.0775537 0)
(0.813721 0.0764972 0)
(0.858853 0.0748829 0)
(0.902236 0.072763 0)
(0.943476 0.0702005 0)
(0.982248 0.0672653 0)
(1.01829 0.0640319 0)
(1.05143 0.0605759 0)
(1.08155 0.0569716 0)
(1.10862 0.0532892 0)
(1.13266 0.049593 0)
(1.15375 0.0459394 0)
(1.17202 0.0423763 0)
(1.18764 0.0389427 0)
(1.20081 0.0356683 0)
(1.21174 0.0325743 0)
(1.22065 0.0296742 0)
(1.22777 0.0269746 0)
(1.23331 0.0244764 0)
(1.23749 0.022176 0)
(1.2405 0.0200661 0)
(1.24252 0.0181371 0)
(1.2437 0.0163777 0)
(1.2442 0.0147757 0)
(1.24414 0.0133187 0)
(1.24363 0.0119944 0)
(1.24275 0.010791 0)
(1.2416 0.00969746 0)
(1.24023 0.00870364 0)
(1.23871 0.00780025 0)
(1.23707 0.00697894 0)
(1.23536 0.00623224 0)
(1.2336 0.00555349 0)
(1.23182 0.00493678 0)
(1.23005 0.00437687 0)
(1.22829 0.00386906 0)
(1.22657 0.00340916 0)
(1.22488 0.00299341 0)
(1.22325 0.00261839 0)
(1.22168 0.00228097 0)
(1.22018 0.00197827 0)
(1.21874 0.00170761 0)
(1.21739 0.0014665 0)
(1.21611 0.00125257 0)
(1.21491 0.00106357 0)
(1.21379 0.000897355 0)
(1.21277 0.000751855 0)
(1.21183 0.000625076 0)
(1.21098 0.000515077 0)
(1.21022 0.00041997 0)
(1.20955 0.00033791 0)
(1.20898 0.000267086 0)
(1.20851 0.000205719 0)
(1.20812 0.000152056 0)
(1.20783 0.000104365 0)
(1.20764 6.08928e-05 0)
(1.20755 1.99946e-05 0)
(0.62617 0.076645 0)
(0.672926 0.0774961 0)
(0.719979 0.0777269 0)
(0.76678 0.077327 0)
(0.812805 0.0763382 0)
(0.857564 0.0747991 0)
(0.900614 0.0727602 0)
(0.941568 0.0702825 0)
(0.980103 0.0674338 0)
(1.01596 0.0642863 0)
(1.04897 0.0609137 0)
(1.07901 0.0573884 0)
(1.10604 0.0537791 0)
(1.13009 0.0501488 0)
(1.15122 0.0465534 0)
(1.16957 0.0430403 0)
(1.18529 0.0396483 0)
(1.19857 0.0364074 0)
(1.20963 0.0333392 0)
(1.21868 0.0304579 0)
(1.22594 0.0277707 0)
(1.23162 0.0252792 0)
(1.23593 0.0229805 0)
(1.23907 0.0208681 0)
(1.24121 0.0189331 0)
(1.24251 0.0171648 0)
(1.24312 0.0155514 0)
(1.24315 0.0140809 0)
(1.24273 0.0127415 0)
(1.24194 0.0115217 0)
(1.24086 0.0104106 0)
(1.23956 0.00939827 0)
(1.23809 0.00847554 0)
(1.23651 0.00763419 0)
(1.23485 0.00686682 0)
(1.23313 0.00616685 0)
(1.2314 0.0055284 0)
(1.22966 0.00494628 0)
(1.22794 0.00441582 0)
(1.22625 0.00393287 0)
(1.2246 0.00349368 0)
(1.22299 0.00309487 0)
(1.22145 0.00273332 0)
(1.21997 0.0024062 0)
(1.21856 0.00211084 0)
(1.21722 0.00184477 0)
(1.21595 0.00160564 0)
(1.21477 0.00139124 0)
(1.21367 0.00119944 0)
(1.21266 0.00102818 0)
(1.21173 0.000875491 0)
(1.2109 0.000739455 0)
(1.21015 0.000618199 0)
(1.20949 0.000509892 0)
(1.20893 0.000412741 0)
(1.20846 0.000324979 0)
(1.20808 0.000244867 0)
(1.20779 0.000170687 0)
(1.2076 0.000100699 0)
(1.20751 3.32657e-05 0)
(0.626999 0.0762593 -6.68734e-28)
(0.673316 0.0771426 0)
(0.719934 0.0774195 4.96832e-11)
(0.766313 0.0770762 4.95629e-11)
(0.811938 0.0761523 -9.7984e-28)
(0.856328 0.0746857 0)
(0.899049 0.0727252 -4.90303e-11)
(0.939719 0.0703297 -4.87926e-11)
(0.978018 0.067565 -1.24849e-27)
(1.01369 0.0645012 1.24081e-27)
(1.04657 0.06121 0)
(1.07652 0.0577621 0)
(1.10351 0.0542246 0)
(1.12756 0.0506596 0)
(1.14873 0.047122 0)
(1.16715 0.0436589 0)
(1.18296 0.0403088 1.59849e-27)
(1.19636 0.0371021 0)
(1.20754 0.0340606 1.14249e-27)
(1.21672 0.031199 1.54577e-27)
(1.22411 0.0285253 -4.33756e-11)
(1.22993 0.0260417 -4.28518e-11)
(1.23438 0.0237461 3.02361e-28)
(1.23764 0.0216327 6.95103e-28)
(1.2399 0.0196931 1.06183e-27)
(1.24132 0.0179171 0)
(1.24203 0.0162936 0)
(1.24216 0.0148111 0)
(1.24182 0.0134579 1.38056e-27)
(1.24111 0.0122229 0)
(1.2401 0.0110955 0)
(1.23887 0.0100659 0)
(1.23746 0.00912499 9.58875e-28)
(1.23593 0.00826477 0)
(1.23432 0.00747788 0)
(1.23265 0.00675781 -2.11192e-27)
(1.23096 0.00609873 9.1407e-28)
(1.22926 0.00549548 0)
(1.22757 0.00494343 -8.9387e-28)
(1.22591 0.00443847 0)
(1.22429 0.00397687 -1.19799e-27)
(1.22272 0.00355527 -8.66588e-28)
(1.2212 0.00317059 8.58333e-28)
(1.21974 0.00282001 0)
(1.21835 0.00250091 0)
(1.21703 0.00221081 0)
(1.21579 0.00194742 0)
(1.21462 0.00170852 0)
(1.21354 0.00149201 -8.18042e-28)
(1.21254 0.00129587 -1.11264e-27)
(1.21162 0.00111814 -8.08231e-28)
(1.2108 0.000956916 0)
(1.21006 0.000810351 -1.09534e-27)
(1.20941 0.000676628 0)
(1.20885 0.000553971 0)
(1.20839 0.000440628 0)
(1.20801 0.000334878 0)
(1.20773 0.000235012 0)
(1.20755 0.000139307 -3.06105e-11)
(1.20745 4.61379e-05 -3.11673e-11)
(0.627849 0.0758566 6.68733e-28)
(0.673735 0.0767707 0)
(0.719925 0.0770917 -4.96832e-11)
(0.765888 0.0768026 -4.95629e-11)
(0.811119 0.0759413 9.7984e-28)
(0.855146 0.0745446 0)
(0.89754 0.0726598 4.90303e-11)
(0.937927 0.0703438 4.87926e-11)
(0.975991 0.0676607 1.24849e-27)
(1.01148 0.0646784 -1.24081e-27)
(1.04422 0.0614667 0)
(1.07408 0.0580946 0)
(1.10103 0.0546279 0)
(1.12508 0.0511274 0)
(1.14628 0.0476472 0)
(1.16476 0.0442339 0)
(1.18066 0.040926 -1.59849e-27)
(1.19417 0.0377539 0)
(1.20547 0.0347399 -1.14249e-27)
(1.21478 0.031899 -1.54577e-27)
(1.2223 0.0292398 4.33756e-11)
(1.22825 0.0267654 4.28518e-11)
(1.23282 0.0244741 -3.02361e-28)
(1.23621 0.0223608 -6.95103e-28)
(1.23859 0.0204178 -1.06183e-27)
(1.24011 0.0186355 0)
(1.24093 0.0170033 0)
(1.24115 0.0155099 0)
(1.2409 0.0141442 -1.38056e-27)
(1.24027 0.0128953 0)
(1.23934 0.0117527 0)
(1.23817 0.010707 0)
(1.23682 0.00974912 -9.58875e-28)
(1.23535 0.00887116 0)
(1.23378 0.00806586 0)
(1.23216 0.00732677 2.11192e-27)
(1.23051 0.00664813 -9.1407e-28)
(1.22885 0.0060248 0)
(1.22719 0.00545221 8.9387e-28)
(1.22557 0.00492625 0)
(1.22397 0.00444324 1.19799e-27)
(1.22242 0.00399983 8.66588e-28)
(1.22093 0.00359299 -8.58333e-28)
(1.21949 0.00321991 0)
(1.21813 0.00287798 0)
(1.21683 0.00256478 0)
(1.2156 0.00227802 0)
(1.21445 0.00201551 0)
(1.21338 0.00177518 8.18042e-28)
(1.2124 0.00155502 1.11264e-27)
(1.2115 0.0013531 8.08231e-28)
(1.21068 0.00116753 0)
(1.20995 0.000996487 1.09534e-27)
(1.20931 0.000838169 0)
(1.20876 0.000690819 0)
(1.2083 0.000552703 0)
(1.20793 0.000422113 0)
(1.20766 0.000297358 0)
(1.20747 0.000176729 3.06105e-11)
(1.20738 5.86149e-05 3.11673e-11)
(0.62872 0.0754382 0)
(0.674182 0.0763816 0)
(0.71995 0.0767448 0)
(0.765503 0.0765076 0)
(0.810345 0.0757065 0)
(0.854013 0.0743773 0)
(0.896085 0.0725656 0)
(0.936192 0.0703268 0)
(0.974021 0.0677228 0)
(1.00932 0.0648198 0)
(1.04192 0.0616858 0)
(1.0717 0.058388 0)
(1.0986 0.0549908 0)
(1.12263 0.0515538 0)
(1.14387 0.0481305 0)
(1.1624 0.044767 0)
(1.17839 0.0415015 0)
(1.19199 0.0383644 0)
(1.20341 0.0353785 0)
(1.21284 0.0325591 0)
(1.22049 0.0299155 0)
(1.22657 0.0274512 0)
(1.23127 0.0251654 0)
(1.23478 0.0230535 0)
(1.23727 0.0211084 0)
(0.59216 0.0765801 5.07485e-20)
(0.593249 0.0761992 9.49655e-21)
(0.594357 0.0758004 -2.91851e-20)
(0.595482 0.075385 -3.74138e-20)
(0.596625 0.0749544 3.13677e-20)
(0.571321 0.0757564 -2.63965e-20)
(0.572633 0.0753605 6.45723e-20)
(0.57396 0.0749478 -2.0105e-20)
(0.575301 0.0745196 -3.33892e-20)
(0.576654 0.0740772 2.28995e-20)
(0.55046 0.0748208 4.76719e-20)
(0.551996 0.0744125 -6.07123e-21)
(0.553543 0.0739885 -1.68993e-20)
(0.5551 0.07355 1.26966e-20)
(0.556667 0.0730982 -2.71216e-20)
(0.52788 0.0741712 -4.50398e-21)
(0.529631 0.0737687 1.7836e-20)
(0.531391 0.0733502 -2.18694e-20)
(0.533158 0.0729168 1.41403e-20)
(0.534932 0.0724698 -5.07649e-20)
(0.50691 0.072979 4.3904e-21)
(0.508889 0.0725678 2.53228e-20)
(0.510872 0.0721415 -4.15661e-20)
(0.51286 0.0717011 7.97424e-22)
(0.51485 0.0712481 -7.94126e-21)
(0.486086 0.0716331 -3.10584e-20)
(0.488291 0.0712158 -2.51237e-20)
(0.490497 0.0707842 2.17187e-20)
(0.492703 0.0703394 -7.78503e-21)
(0.494909 0.0698827 -2.66584e-20)
(0.463036 0.0705422 -3.09355e-20)
(0.465467 0.0701361 3.84836e-20)
(0.467895 0.0697152 -2.91664e-20)
(0.470322 0.0692808 1.47365e-20)
(0.472745 0.068834 -2.5877e-20)
(0.442457 0.0688964 -1.23553e-20)
(0.445112 0.0684885 -1.40659e-20)
(0.447762 0.0680665 -4.54778e-21)
(0.450406 0.0676317 4.74357e-20)
(0.453043 0.0671853 -4.59909e-20)
(0.422208 0.0670982 -1.26729e-21)
(0.425083 0.0666908 -3.14827e-20)
(0.42795 0.0662701 1.27759e-20)
(0.430808 0.0658373 1.16183e-20)
(0.433656 0.0653935 -6.74904e-21)
(0.399248 0.0655393 -1.73381e-20)
(0.40235 0.0651488 8.23472e-21)
(0.405441 0.0647444 1.43961e-20)
(0.408521 0.0643274 -8.3125e-21)
(0.411588 0.0638989 -1.40774e-20)
(0.379631 0.0634366 -2.81364e-21)
(0.382946 0.0630507 6.37499e-21)
(0.386248 0.0626515 -1.17739e-20)
(0.389534 0.0622404 9.88163e-21)
(0.392806 0.0618185 -1.01332e-20)
(0.360534 0.0611856 5.03024e-21)
(0.364057 0.0608065 -1.23541e-20)
(0.367563 0.0604149 -2.09571e-20)
(0.371051 0.0600119 1.75026e-20)
(0.374522 0.0595986 -1.51342e-20)
(0.342021 0.05879 3.97018e-20)
(0.345744 0.0584199 -1.8601e-20)
(0.349447 0.0580378 -6.24203e-21)
(0.35313 0.0576449 1.69873e-20)
(0.356793 0.0572424 -1.36032e-20)
(0.320216 0.0566006 -1.11038e-20)
(0.324152 0.0562539 1.13013e-20)
(0.328066 0.0558947 -4.60148e-21)
(0.331959 0.0555242 5.26431e-21)
(0.33583 0.0551435 8.36162e-21)
(0.302864 0.0539167 1.60519e-21)
(0.306985 0.0535822 -1.66318e-20)
(0.311084 0.0532358 2.19879e-20)
(0.315159 0.0528787 -9.08756e-21)
(0.319209 0.0525119 -6.89543e-21)
(0.286281 0.0511006 -1.20191e-20)
(0.290579 0.05078 -1.08483e-20)
(0.294853 0.0504482 1.49279e-20)
(0.299101 0.0501063 2.07405e-20)
(0.303323 0.0497553 -2.05298e-20)
(0.270524 0.0481585 1.37837e-20)
(0.27499 0.0478534 -9.55316e-21)
(0.279429 0.0475378 -2.73773e-21)
(0.283842 0.0472126 2.11636e-20)
(0.288226 0.046879 -1.33311e-20)
(0.255647 0.0450967 1.01563e-20)
(0.26027 0.0448087 8.69184e-21)
(0.264866 0.0445107 -1.7731e-20)
(0.269433 0.0442039 2.45468e-20)
(0.27397 0.043889 -1.15483e-20)
(0.236902 0.0421818 -3.14593e-20)
(0.241702 0.0419223 -7.66639e-22)
(0.246472 0.0416526 3.22476e-20)
(0.251213 0.0413737 -2.06549e-20)
(0.255924 0.0410865 1.12379e-21)
(0.2238 0.0388833 -5.96162e-21)
(0.228737 0.0386427 -6.24201e-21)
(0.233643 0.0383926 -9.07906e-21)
(0.238519 0.0381339 3.73022e-20)
(0.243364 0.0378676 -1.75344e-20)
(0.211735 0.0354864 -9.9427e-21)
(0.216797 0.0352656 1.76219e-21)
(0.221829 0.0350362 -1.82567e-21)
(0.226829 0.0347989 4.3196e-21)
(0.231796 0.0345547 -1.80687e-20)
(0.20075 0.0319992 -6.60937e-21)
(0.205926 0.0317993 6.48116e-21)
(0.211071 0.0315915 8.63028e-21)
(0.216183 0.0313766 -1.59638e-20)
(0.221262 0.0311555 4.57426e-21)
(0.190884 0.0284305 -1.61711e-21)
(0.196162 0.0282522 7.76552e-21)
(0.201408 0.0280669 -9.70576e-21)
(0.206621 0.0278753 8.16907e-21)
(0.2118 0.0276781 -9.05518e-21)
(0.182172 0.0247891 -4.2841e-21)
(0.18754 0.0246332 -5.2573e-21)
(0.192875 0.0244712 1.27465e-20)
(0.198177 0.0243036 -6.133e-21)
(0.203443 0.0241311 -5.42245e-22)
(0.174645 0.0210842 -1.45394e-21)
(0.18009 0.0209513 -9.42671e-22)
(0.185502 0.0208131 5.90698e-21)
(0.19088 0.0206703 -2.34357e-21)
(0.196223 0.0205232 -4.85646e-21)
(0.16833 0.0173253 -7.65109e-21)
(0.17384 0.0172158 4.95001e-21)
(0.179317 0.0171021 8.73904e-22)
(0.184759 0.0169844 -8.13462e-21)
(0.190165 0.0168634 2.84501e-21)
(0.157657 0.0136035 -5.48646e-21)
(0.163251 0.0135218 5.68988e-21)
(0.168813 0.0134362 2.68269e-21)
(0.174341 0.0133473 -5.67492e-21)
(0.179835 0.0132554 -2.85386e-21)
(0.185292 0.0131607 4.1019e-21)
(0.153792 0.00974208 2.29565e-21)
(0.159425 0.00968346 2.4985e-21)
(0.165026 0.00962214 -4.12278e-21)
(0.170594 0.00955839 5.2186e-21)
(0.176126 0.00949248 -2.06524e-21)
(0.181621 0.00942462 -2.68905e-21)
(0.151208 0.0058555 2.43004e-21)
(0.156867 0.00582025 -1.54613e-21)
(0.162494 0.00578336 4.20158e-21)
(0.168087 0.00574502 -3.62932e-22)
(0.173645 0.00570537 -3.69435e-23)
(0.179167 0.00566455 -1.48299e-21)
(0.149913 0.00195381 -2.71326e-22)
(0.155586 0.00194204 1.22187e-22)
(0.161226 0.00192973 1.16931e-22)
(0.166832 0.00191693 2.45222e-22)
(0.172403 0.00190369 -2.94183e-24)
(0.177937 0.00189006 2.50459e-22)
)
;
boundaryField
{
inlet
{
type uniformFixedValue;
uniformValue constant (1 0 0);
value nonuniform 0();
}
outlet
{
type pressureInletOutletVelocity;
value nonuniform 0();
}
cylinder
{
type fixedValue;
value nonuniform 0();
}
top
{
type symmetryPlane;
}
bottom
{
type symmetryPlane;
}
defaultFaces
{
type empty;
}
procBoundary27to26
{
type processor;
value nonuniform List<vector>
195
(
(0.14421 -0.00196409 3.26154e-22)
(0.145517 -0.00588807 -1.59895e-21)
(0.148128 -0.00979682 -5.97156e-21)
(0.152032 -0.0136802 6.5087e-22)
(0.162789 -0.017429 8.63171e-22)
(0.162789 -0.017429 8.63171e-22)
(0.169168 -0.0212105 -7.95366e-21)
(0.176773 -0.0249374 5.58457e-21)
(0.185575 -0.0286002 -4.61858e-22)
(0.195544 -0.0321896 -7.6864e-21)
(0.206644 -0.0356967 2.94906e-20)
(0.218835 -0.0391127 -9.80284e-21)
(0.232076 -0.0424291 9.57623e-21)
(0.250996 -0.045373 -2.73779e-20)
(0.250996 -0.045373 -2.73779e-20)
(0.266032 -0.048451 -3.00134e-21)
(0.281958 -0.051408 -2.79947e-21)
(0.298719 -0.0542373 1.14941e-20)
(0.31626 -0.0569327 -8.21116e-21)
(0.33828 -0.0591462 -1.99211e-20)
(0.33828 -0.0591462 -1.99211e-20)
(0.356996 -0.0615501 2.02578e-20)
(0.376302 -0.0638072 1.75581e-20)
(0.396135 -0.0659139 -2.55869e-20)
(0.419325 -0.0674903 2.11495e-20)
(0.419325 -0.0674903 2.11495e-20)
(0.439797 -0.0692884 3.45606e-20)
(0.460604 -0.0709315 4.09252e-20)
(0.483883 -0.0720342 6.89102e-20)
(0.483883 -0.0720342 6.89102e-20)
(0.504936 -0.0733731 -8.79545e-21)
(0.526137 -0.0745556 5.47644e-20)
(0.548937 -0.0752115 1.43815e-20)
(0.548937 -0.0752115 1.43815e-20)
(0.570026 -0.0761337 -5.5757e-21)
(0.591092 -0.0769411 -6.89911e-21)
(0.624581 -0.07736 0)
(0.624581 -0.07736 0)
(0.672236 -0.0781419 0)
(0.720182 -0.0782741 0)
(0.767848 -0.0777541 0)
(0.814689 -0.0766274 0)
(0.860199 -0.0749352 0)
(0.903917 -0.0727316 0)
(0.945447 -0.0700815 0)
(0.984455 -0.0670574 0)
(1.02068 -0.0637358 0)
(1.05395 -0.0601945 0)
(1.08415 -0.0565097 0)
(1.11125 -0.0527532 0)
(1.13527 -0.0489902 0)
(1.15631 -0.0452781 0)
(1.1745 -0.0416652 0)
(1.19002 -0.0381904 0)
(1.20307 -0.0348832 0)
(1.21386 -0.0317643 0)
(1.22263 -0.0288466 0)
(1.22961 -0.0261359 0)
(1.23501 -0.0236324 0)
(1.23905 -0.0213316 0)
(1.24192 -0.0192256 0)
(1.24381 -0.017304 0)
(1.24488 -0.015555 0)
(1.24528 -0.0139659 0)
(1.24512 -0.0125237 0)
(1.24451 -0.0112158 0)
(1.24356 -0.0100302 0)
(1.24233 -0.00895553 0)
(1.2409 -0.0079815 0)
(1.23931 -0.00709869 0)
(1.23761 -0.00629862 0)
(1.23585 -0.00557377 0)
(1.23405 -0.0049174 0)
(1.23223 -0.00432357 0)
(1.23042 -0.00378698 0)
(1.22862 -0.00330291 0)
(1.22687 -0.00286714 0)
(1.22515 -0.00247588 0)
(1.2235 -0.00212567 0)
(1.2219 -0.00181338 0)
(1.22037 -0.00153609 0)
(1.21892 -0.00129111 0)
(1.21754 -0.00107591 0)
(1.21624 -0.000888107 0)
(1.21502 -0.000725426 0)
(1.21389 -0.000585701 0)
(1.21285 -0.000466846 0)
(1.2119 -0.000366844 0)
(1.21104 -0.000283741 0)
(1.21027 -0.000215631 0)
(1.2096 -0.000160654 0)
(1.20902 -0.000116985 0)
(1.20854 -8.28314e-05 0)
(1.20815 -5.64295e-05 0)
(1.20786 -3.60354e-05 0)
(1.20766 -1.98845e-05 0)
(1.20757 -6.32298e-06 0)
(0.90566 0.0726646 0)
(0.94748 0.0699242 0)
(0.986725 0.0668085 0)
(1.02314 0.0633963 0)
(1.05653 0.0597678 0)
(1.0868 0.0560009 0)
(1.11393 0.052169 0)
(1.13793 0.0483386 0)
(1.15891 0.0445678 0)
(1.17702 0.0409052 0)
(1.19243 0.0373896 0)
(1.20534 0.0340504 0)
(1.216 0.0309076 0)
(1.22462 0.0279735 0)
(1.23145 0.025253 0)
(1.2367 0.0227456 0)
(1.2406 0.020446 0)
(1.24334 0.0183454 0)
(1.24511 0.0164328 0)
(1.24606 0.0146957 0)
(1.24634 0.0131209 0)
(1.24608 0.0116949 0)
(1.24539 0.0104049 0)
(1.24435 0.00923843 0)
(1.24305 0.008184 0)
(1.24154 0.00723108 0)
(1.23989 0.00637012 0)
(1.23814 0.00559256 0)
(1.23633 0.00489078 0)
(1.23448 0.004258 0)
(1.23262 0.00368822 0)
(1.23077 0.0031761 0)
(1.22894 0.00271689 0)
(1.22715 0.00230636 0)
(1.22541 0.00194066 0)
(1.22372 0.00161634 0)
(1.2221 0.00133021 0)
(1.22055 0.00107935 0)
(1.21907 0.000861043 0)
(1.21767 0.000672731 0)
(1.21635 0.000512008 0)
(1.21512 0.000376586 0)
(1.21398 0.000264274 0)
(1.21292 0.000172969 0)
(1.21196 0.000100637 0)
(1.21108 4.53073e-05 0)
(1.21031 5.05943e-06 0)
(1.20962 -2.19812e-05 0)
(1.20904 -3.76511e-05 0)
(1.20855 -4.37546e-05 0)
(1.20816 -4.20662e-05 0)
(1.20786 -3.43396e-05 0)
(1.20766 -2.23497e-05 0)
(1.20757 -7.75709e-06 0)
(0.624581 0.0773605 0)
(0.624581 0.0773605 0)
(0.672235 0.0781423 0)
(0.720182 0.0782744 0)
(0.767848 0.0777544 0)
(0.814689 0.0766277 0)
(0.860198 0.0749355 0)
(0.860198 0.0749355 0)
(0.591091 0.0769416 6.84616e-21)
(0.570026 0.0761342 5.72252e-21)
(0.548937 0.075212 -1.44793e-20)
(0.548937 0.075212 -1.44793e-20)
(0.526137 0.0745562 -5.50066e-20)
(0.504936 0.0733737 8.16267e-21)
(0.483882 0.0720348 -6.8402e-20)
(0.483882 0.0720348 -6.8402e-20)
(0.460604 0.0709321 -4.20417e-20)
(0.439797 0.069289 -3.39754e-20)
(0.419324 0.0674909 -2.08972e-20)
(0.419324 0.0674909 -2.08972e-20)
(0.396135 0.0659146 2.47473e-20)
(0.376301 0.0638079 -1.66545e-20)
(0.356996 0.0615508 -1.97011e-20)
(0.33828 0.0591469 1.93563e-20)
(0.33828 0.0591469 1.93563e-20)
(0.31626 0.0569334 8.49518e-21)
(0.298719 0.054238 -1.06937e-20)
(0.281958 0.0514088 2.64406e-21)
(0.266032 0.0484518 1.76699e-21)
(0.250996 0.0453738 2.86639e-20)
(0.250996 0.0453738 2.86639e-20)
(0.232076 0.0424299 -8.90263e-21)
(0.218835 0.0391135 1.02595e-20)
(0.206644 0.0356975 -3.02324e-20)
(0.195544 0.0321905 8.14479e-21)
(0.185575 0.028601 -3.67547e-22)
(0.176773 0.0249382 -5.26118e-21)
(0.169168 0.0212113 8.4968e-21)
(0.162789 0.0174299 -1.17687e-21)
(0.162789 0.0174299 -1.17687e-21)
(0.152032 0.0136811 -9.73688e-22)
(0.148128 0.0097977 6.19552e-21)
(0.145517 0.00588895 1.58109e-21)
(0.14421 0.00196497 -2.78826e-22)
)
;
}
procBoundary27to28
{
type processor;
value nonuniform List<vector>
193
(
(0.183433 -0.0018753 -4.37307e-22)
(0.18465 -0.00562191 -7.20449e-22)
(0.187079 -0.00935426 3.41132e-21)
(0.190712 -0.0130629 -1.70369e-21)
(0.195535 -0.0167384 -4.33755e-21)
(0.201529 -0.0203717 8.91687e-21)
(0.208675 -0.0239535 -6.32421e-21)
(0.216944 -0.0274752 1.06473e-20)
(0.226307 -0.0309279 9.65786e-21)
(0.23673 -0.0343035 2.50181e-20)
(0.248177 -0.0375938 9.29546e-21)
(0.248177 -0.0375938 9.29546e-21)
(0.265253 -0.04049 -5.99402e-21)
(0.278477 -0.0435664 -2.51396e-21)
(0.292582 -0.046537 -1.11474e-20)
(0.307519 -0.0493954 9.16006e-21)
(0.323235 -0.0521359 7.38449e-21)
(0.339679 -0.0547529 -1.30307e-21)
(0.339679 -0.0547529 -1.30307e-21)
(0.360436 -0.0568305 -1.68993e-21)
(0.377974 -0.0591754 9.18333e-21)
(0.396063 -0.0613861 9.87156e-21)
(0.414643 -0.0634595 -4.10899e-21)
(0.414643 -0.0634595 -4.10899e-21)
(0.436494 -0.0649393 2.31725e-21)
(0.455673 -0.0667277 1.85823e-20)
(0.475164 -0.0683755 -1.83226e-20)
(0.475164 -0.0683755 -1.83226e-20)
(0.497114 -0.0694147 3.08552e-20)
(0.516843 -0.070783 2.00845e-20)
(0.536712 -0.07201 4.04911e-20)
(0.536712 -0.07201 4.04911e-20)
(0.558242 -0.0726338 9.13718e-21)
(0.578021 -0.0736213 3.15687e-21)
(0.597783 -0.0745093 8.84675e-21)
(0.597783 -0.0745093 8.84675e-21)
(0.62961 -0.0750052 0)
(0.674655 -0.0759765 0)
(0.720007 -0.0763799 0)
(0.765157 -0.0761925 0)
(0.809616 -0.0754493 0)
(0.85293 -0.0741851 0)
(0.894683 -0.0724442 0)
(0.934511 -0.0702801 0)
(0.972106 -0.067753 0)
(1.00722 -0.0649272 0)
(1.03968 -0.061869 0)
(1.06936 -0.0586439 0)
(1.09621 -0.055315 0)
(1.12024 -0.0519408 0)
(1.14149 -0.0485738 0)
(1.16008 -0.0452598 0)
(1.17614 -0.0420368 0)
(1.18985 -0.0389352 0)
(1.20137 -0.0359779 0)
(1.21092 -0.0331808 0)
(1.2187 -0.0305536 0)
(1.2249 -0.0281006 0)
(1.22972 -0.0258213 0)
(1.23335 -0.0237119 0)
(1.23596 -0.0217658 0)
(1.2377 -0.0199745 0)
(1.23871 -0.0183283 0)
(1.23912 -0.0168169 0)
(1.23904 -0.0154296 0)
(1.23856 -0.0141563 0)
(1.23777 -0.0129869 0)
(1.23673 -0.0119122 0)
(1.2355 -0.0109236 0)
(1.23414 -0.0100134 0)
(1.23267 -0.00917448 0)
(1.23113 -0.00840049 0)
(1.22956 -0.00768579 0)
(1.22798 -0.00702534 0)
(1.22639 -0.00641462 0)
(1.22483 -0.0058496 0)
(1.22329 -0.00532665 0)
(1.22179 -0.00484249 0)
(1.22035 -0.00439412 0)
(1.21896 -0.0039788 0)
(1.21763 -0.00359396 0)
(1.21637 -0.00323723 0)
(1.21518 -0.00290638 0)
(1.21406 -0.00259926 0)
(1.21303 -0.00231384 0)
(1.21207 -0.00204818 0)
(1.21119 -0.00180037 0)
(1.21039 -0.00156858 0)
(1.20968 -0.00135101 0)
(1.20906 -0.00114592 0)
(1.20853 -0.000951583 0)
(1.20808 -0.000766296 0)
(1.20772 -0.000588389 0)
(1.20745 -0.000416206 0)
(1.20727 -0.000248071 0)
(1.20718 -8.24018e-05 0)
(1.23891 0.019321 0)
(1.23982 0.0176812 0)
(1.24014 0.0161782 0)
(1.23998 0.0148012 0)
(1.23942 0.0135395 0)
(1.23856 0.012383 0)
(1.23745 0.0113222 0)
(1.23617 0.0103485 0)
(1.23475 0.00945384 0)
(1.23323 0.00863121 0)
(1.23165 0.00787416 0)
(1.23004 0.00717699 0)
(1.22842 0.00653461 0)
(1.2268 0.00594247 0)
(1.2252 0.0053965 0)
(1.22364 0.00489305 0)
(1.22212 0.0044288 0)
(1.22065 0.00400074 0)
(1.21923 0.00360608 0)
(1.21789 0.00324225 0)
(1.21661 0.00290685 0)
(1.2154 0.00259761 0)
(1.21427 0.00231237 0)
(1.21321 0.00204907 0)
(1.21224 0.00180574 0)
(1.21135 0.00158046 0)
(1.21054 0.00137138 0)
(1.20983 0.00117667 0)
(1.20919 0.000994572 0)
(1.20865 0.000823332 0)
(1.2082 0.000661239 0)
(1.20783 0.000506601 0)
(1.20756 0.000357745 0)
(1.20738 0.000212978 0)
(1.20729 7.07007e-05 0)
(0.62961 0.0750055 0)
(0.597782 0.0745097 3.44759e-20)
(0.674654 0.0759768 0)
(0.720007 0.0763802 0)
(0.765156 0.0761928 0)
(0.809616 0.0754495 0)
(0.852929 0.0741853 0)
(0.894683 0.0724443 0)
(0.934511 0.0702801 0)
(0.972106 0.067753 0)
(1.00722 0.0649273 0)
(1.03968 0.061869 0)
(1.06936 0.0586439 0)
(1.09621 0.055315 0)
(1.12024 0.0519407 0)
(1.14149 0.0485738 0)
(1.16008 0.0452597 0)
(1.17614 0.0420367 0)
(1.18985 0.0389351 0)
(1.20137 0.0359778 0)
(1.21092 0.0331807 0)
(1.2187 0.0305535 0)
(1.2249 0.0281004 0)
(1.22972 0.0258211 0)
(1.23335 0.0237117 0)
(1.23891 0.019321 0)
(1.23596 0.0217656 0)
(0.597782 0.0745097 3.44759e-20)
(0.57802 0.0736217 -2.9956e-21)
(0.558242 0.0726342 -9.76832e-21)
(0.536712 0.0720104 -4.82182e-23)
(0.536712 0.0720104 -4.82182e-23)
(0.516843 0.0707834 -2.04833e-20)
(0.497113 0.0694151 -3.0437e-20)
(0.475164 0.068376 1.91602e-20)
(0.475164 0.068376 1.91602e-20)
(0.455673 0.0667283 -2.04494e-20)
(0.436494 0.0649398 -2.11175e-21)
(0.414643 0.06346 3.65133e-21)
(0.414643 0.06346 3.65133e-21)
(0.396063 0.0613867 -8.75816e-21)
(0.377974 0.059176 -1.00577e-20)
(0.360435 0.0568311 2.64992e-21)
(0.339679 0.0547536 1.64585e-21)
(0.339679 0.0547536 1.64585e-21)
(0.323235 0.0521365 -7.63817e-21)
(0.307518 0.0493961 -9.29624e-21)
(0.292582 0.0465377 1.14909e-20)
(0.278477 0.0435671 2.92952e-21)
(0.260604 0.0407919 -5.44335e-21)
(0.260604 0.0407919 -5.44335e-21)
(0.248176 0.0375945 9.7595e-21)
(0.23673 0.0343042 -2.53027e-20)
(0.226307 0.0309287 -9.90325e-21)
(0.216944 0.0274759 -1.06815e-20)
(0.208674 0.0239543 6.94904e-21)
(0.201529 0.0203724 -9.28727e-21)
(0.195535 0.0167392 4.65768e-21)
(0.190712 0.0130637 1.42581e-21)
(0.187079 0.00935504 -3.43362e-21)
(0.18465 0.0056227 7.43182e-22)
(0.183433 0.00187608 4.38995e-22)
)
;
}
}
// ************************************************************************* //
| [
"chaseh13@login4.stampede2.tacc.utexas.edu"
] | chaseh13@login4.stampede2.tacc.utexas.edu | |
fd19942378b6545493d30e715781f7692725f76e | 2fead4c5a5cf816b2a31308b032011364da561a6 | /kutil/kutil.cpp | 19313755c9490fcb4c82c3bc46849b238aa0cc4d | [
"MIT"
] | permissive | dynaroars/gentree | ec25dae9e0572749e9253d564baf8da582881e22 | 694ad9f26ef693c6870935de3988f31130587afc | refs/heads/master | 2023-02-25T01:31:56.304989 | 2021-02-06T19:09:23 | 2021-02-06T19:09:23 | 322,162,697 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,720 | cpp | //
// Created by kh on 3/31/20.
//
#include <iostream>
#include <klib/common.h>
#include <klib/random.h>
#include <klib/WorkQueue.h>
#include <z3++.h>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/timer/timer.hpp>
#include <boost/scope_exit.hpp>
#include <boost/filesystem.hpp>
#include <glog/raw_logging.h>
#include <igen/algo/Algo.h>
namespace po = boost::program_options;
#include "kutil.h"
void init_glog(int argc, char **argv) {
(void) argc;
FLAGS_colorlogtostderr = true;
//FLAGS_timestamp_in_logfile_name = false;
FLAGS_max_log_size = 32;
FLAGS_logbuflevel = google::GLOG_INFO;
google::SetStderrLogging(0);
//google::SetVLOGLevel("*", 20);
google::InitGoogleLogging(argv[0]);
}
int prog(int argc, char *argv[]) {
using str = std::string;
po::options_description desc("Dynamic Interaction Inference for Configurable Software");
desc.add_options()
("filestem,F", po::value<str>(), "Filestem")
("target", po::value<str>(), "Target")
("dom", po::value<str>(), "Dom file")
("runner,r", po::value<str>(), "Select program runner")
("simple-runner,S", "Simple runner")
("builtin-runner,B", "Builtin runner")
("gcov-runner,G", "GCov runner")
("seed,s", po::value<uint64_t>()->default_value(123), "Random seed")
("output,O", po::value<str>(), "Output result")
("disj-conj", "Gen expr strat DisjOfConj")
("cache,c", po::value<str>(), "Cache control: read/write/execute")
("cache-path,p", po::value<str>()->default_value(""), "Custom cachedb path")
("runner-threads,j", po::value<int>()->default_value(1), "Number of program runner threads")
("config-script", po::value<str>()->default_value(""), "JS configure script")
("full", "Run with full configs")
("rand", po::value<int>(), "Run with random configs")
("analyze,A", po::value<int>()->implicit_value(0), "Run anaylzer")
("c50,J", po::value<int>()->implicit_value(0), "Run the ML algorithm")
("alg-version,T", po::value<int>()->default_value(0), "Select algo version")
("batch-size", po::value<int>()->default_value(0), "Batch size")
("input,I", po::value<str>()->default_value(""), "Algorithm input")
("term-cnt", po::value<int>()->default_value(0), "Termination counter")
("loc,X", po::value<str>(), "Interested location")
("rounds,R", po::value<int>(), "Number of iterations")
("seed-configs,C", po::value<std::vector<str>>()->default_value(std::vector<str>(), "none"), "Seed configs")
("rep", po::value<int>()->default_value(1), "Repeat the experiment")
("rep-parallel", po::value<int>()->default_value(1), "Repeat multithreaded")
("fixed-seed", "Keep seed fixed")
("count-keys", po::value<str>())
("vmodule,V", po::value<str>(), "Verbose logging. eg -V mapreduce=2,file=1,gfs*=3")
("verbose,v", po::value<int>(), "Verbose level")
("no-buf,N", "Do not buffer log")
("log-dir,L", po::value<str>(), "Log to file")
("help,h", "Print usage");
po::variables_map vm;
auto x = po::parse_command_line(argc, argv, desc);
po::store(x, vm);
po::notify(vm);
//=======================================================================
if (vm.count("help")) {
std::cout << desc << std::endl;
return 1;
}
if (vm.count("no-buf")) {
FLAGS_logbufsecs = 0;
FLAGS_logbuflevel = -1;
std::cout.setf(std::ios::unitbuf);
std::cerr.setf(std::ios::unitbuf);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
}
if (vm.count("verbose")) {
FLAGS_v = vm["verbose"].as<int>();
google::SetVLOGLevel("*", FLAGS_v);
}
if (vm.count("vmodule")) {
igen::vec<str> p1, p2;
str conf = vm["vmodule"].as<str>();
boost::split(p1, conf, boost::is_any_of(","));
for (const auto &p : p1) {
boost::split(p2, p, boost::is_any_of("="));
google::SetVLOGLevel(p2.at(0).c_str(), boost::lexical_cast<int>(p2.at(1)));
}
}
if (vm.count("log-dir")) {
str dir = vm["log-dir"].as<str>();
RAW_VLOG(0, "Log to dir %s", dir.c_str());
CHECKF(boost::filesystem::exists(dir), "Logdir {} does not exist", dir);
CHECKF(boost::filesystem::is_directory(dir), "Logdir {} is not a directory", dir);
FLAGS_log_dir = dir;
} else {
for (int i = 0; i < google::NUM_SEVERITIES; ++i) {
google::SetLogDestination(i, "");
}
}
init_glog(argc, argv);
std::vector<str> all_args{argv, argv + argc};
LOG(WARNING, "Args: {}", fmt::join(all_args, " "));
boost::timer::cpu_timer timer;
BOOST_SCOPE_EXIT(&timer) {
LOG(INFO, "{}", timer.format(1));
}
BOOST_SCOPE_EXIT_END
// == BEGIN REAL PROGRAM ==
using namespace igen;
if (vm.count("count-keys"))
return count_keys(vm["count-keys"].as<str>());
return 0;
}
int main(int argc, char *argv[]) {
// int main_z3_test();
// return main_z3_test();
try {
return prog(argc, argv);
} catch (z3::exception &ex) {
LOG(ERROR, "z3 exception: {}", ex);
} catch (std::exception &ex) {
LOG(ERROR, "exception: {}", ex.what());
}
return 0;
} | [
"k@k"
] | k@k |
744b4ba3dfd714168b82b31043a9dfd72f5b0d6e | 1ddaaca308a8b8694ce797c7afefe99a44fcec85 | /src/include/prevector.h | 62b685184460faafed4b14415092919337e2674f | [] | no_license | robling/Leetcode | 4b50bcb9d5ec407a89a03acc0f128a282ecc513e | ceedb3165b9dc24cffff36756b5156755bfe3df7 | refs/heads/master | 2021-01-17T13:32:37.891612 | 2016-05-18T03:26:50 | 2016-05-18T03:26:50 | 34,882,726 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 284 | h | #ifndef _PREVECTOR_H_
#define _PREVECTOR_H_
#include "pre.h"
#include <vector>
using std::vector;
template<typename _T>
void PrintVector(std::vector<_T> list, string splitMark = ", ")
{
for (_T elem : list)
{
cout << elem << splitMark;
}
cout << endl;
}
#endif //_PREVECTOR_H_ | [
"spdf@live.com"
] | spdf@live.com |
3a43aaf0cbabc2e01d724e4c74a8e86bb10a4a16 | cefd6c17774b5c94240d57adccef57d9bba4a2e9 | /WebKit/Source/WebCore/platform/graphics/win/ImageWin.cpp | 03de163c7902217eeaeeb68704a1b7fab7f5214c | [
"BSL-1.0",
"BSD-2-Clause",
"LGPL-2.0-only",
"LGPL-2.1-only"
] | permissive | adzhou/oragle | 9c054c25b24ff0a65cb9639bafd02aac2bcdce8b | 5442d418b87d0da161429ffa5cb83777e9b38e4d | refs/heads/master | 2022-11-01T05:04:59.368831 | 2014-03-12T15:50:08 | 2014-03-12T15:50:08 | 17,238,063 | 0 | 1 | BSL-1.0 | 2022-10-18T04:23:53 | 2014-02-27T05:39:44 | C++ | UTF-8 | C++ | false | false | 2,004 | cpp | /*
* Copyright (C) 2006, 2007, 2008 Apple 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:
* 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "Image.h"
#include "BitmapImage.h"
#include "SharedBuffer.h"
// This function loads resources from WebKit
PassRefPtr<WebCore::SharedBuffer> loadResourceIntoBuffer(const char*);
namespace WebCore {
void BitmapImage::invalidatePlatformData()
{
}
PassRefPtr<Image> Image::loadPlatformResource(const char *name)
{
RefPtr<SharedBuffer> buffer = loadResourceIntoBuffer(name);
RefPtr<BitmapImage> img = BitmapImage::create();
img->setData(buffer.release(), true);
return img.release();
}
bool BitmapImage::getHBITMAP(HBITMAP bmp)
{
return getHBITMAPOfSize(bmp, 0);
}
} // namespace WebCore
| [
"adzhou@hp.com"
] | adzhou@hp.com |
0c7f1a259256dd8d988d6c2b74b97a5c0cbc5e32 | 69cc0b451be1452334ee32ba20765c14cc3e0c77 | /src/util/be.parse.cpp | f710833ed3ebc4482de0012eb6afb3a7ec2ca129 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | stlsoft/Pantheios | 2d0dcdd964469abcfb564deb2fcf3b0dafb9f9d1 | a35eaa4c070f88d0642bd78c223f1c0399374c3b | refs/heads/master | 2021-06-03T07:12:06.292602 | 2021-03-21T01:45:47 | 2021-03-21T01:45:47 | 339,237,439 | 0 | 0 | NOASSERTION | 2021-02-15T23:42:05 | 2021-02-15T23:42:05 | null | UTF-8 | C++ | false | false | 18,072 | cpp | /* /////////////////////////////////////////////////////////////////////////
* File: src/util/be.parse.cpp
*
* Purpose: Utility functions for use in Pantheios back-ends.
*
* Created: 19th August 2007
* Updated: 17th December 2016
*
* Home: http://www.pantheios.org/
*
* Copyright (c) 2007-2016, Matthew Wilson and Synesis Software
* 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(s) of Matthew Wilson and Synesis Software nor the
* names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ////////////////////////////////////////////////////////////////////// */
#include <pantheios/pantheios.h>
#include <pantheios/internal/nox.h>
#include <pantheios/backend.h>
#include <pantheios/quality/contract.h>
#include <pantheios/util/backends/arguments.h>
#include <pantheios/util/memory/memcopy.h>
#include <stlsoft/string/string_view.hpp>
#include <stlsoft/string/split_functions.hpp>
#include <stlsoft/string/view_slice_functions.hpp>
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
# include <new>
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
#include <ctype.h>
#ifdef PANTHEIOS_USE_WIDE_STRINGS
# include <wchar.h>
#endif /* PANTHEIOS_USE_WIDE_STRINGS */
/* /////////////////////////////////////////////////////////////////////////
* compiler compatibility
*/
#if defined(STLSOFT_COMPILER_IS_MSVC) && \
_MSC_VER >= 1300
# pragma warning(disable : 4702)
#endif /* _MSC_VER >= 1400 */
/* /////////////////////////////////////////////////////////////////////////
* string encoding compatibility
*/
#ifdef PANTHEIOS_USE_WIDE_STRINGS
# define pan_toupper_ towupper
typedef stlsoft::wstring_view string_view_t;
#else /* ? PANTHEIOS_USE_WIDE_STRINGS */
# define pan_toupper_ toupper
typedef stlsoft::string_view string_view_t;
#endif /* PANTHEIOS_USE_WIDE_STRINGS */
/* /////////////////////////////////////////////////////////////////////////
* namespace
*/
#ifndef PANTHEIOS_NO_NAMESPACE
using pantheios::util::pantheios_onBailOut3;
using pantheios::util::pantheios_onBailOut4;
#endif /* !PANTHEIOS_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* forward declarations
*/
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
static int
pantheios_be_parseBooleanArg_(
size_t numArgs
, pantheios_slice_t args[]
, PAN_CHAR_T const* argName
, int flagSuppressesAction
, pantheios_uint32_t flagValue
, pantheios_uint32_t* flags
);
static int
pantheios_be_parseStringArg_(
size_t numArgs
, pantheios_slice_t args[]
, PAN_CHAR_T const* argName
, pantheios_slice_t* argValue
);
static int
pantheios_be_parseStockArgs_(
size_t numArgs
, pantheios_slice_t args[]
, pantheios_uint32_t* flags
);
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
/* /////////////////////////////////////////////////////////////////////////
* helper functions
*/
namespace
{
bool has_boolean_flag_value(string_view_t const& value, bool &flagIsOn)
{
// Can be one of: yes, true, on, 1, no, false, off, 0 (in any case)
size_t n = value.size();
if(n < 6)
{
PAN_CHAR_T copy[6];
PANTHEIOS_char_copy(©[0], value.data(), n);
::memset(©[0] + n, '\0', (6 - n) * sizeof(PAN_CHAR_T));
PANTHEIOS_CONTRACT_ENFORCE_POSTCONDITION_STATE_INTERNAL('\0' == copy[5], "the character at [5] must be the nul-terminator");
{ for(size_t i = 0; '\0' != copy[i]; ++i)
{
copy[i] = static_cast<PAN_CHAR_T>(pan_toupper_(copy[i]));
}}
const string_view_t val2(©[0], n);
if( PANTHEIOS_LITERAL_STRING("1") == val2 ||
PANTHEIOS_LITERAL_STRING("ON") == val2 ||
PANTHEIOS_LITERAL_STRING("YES") == val2 ||
PANTHEIOS_LITERAL_STRING("TRUE") == val2)
{
flagIsOn = true;
return true;
}
else if(PANTHEIOS_LITERAL_STRING("0") == val2 ||
PANTHEIOS_LITERAL_STRING("OFF") == val2 ||
PANTHEIOS_LITERAL_STRING("NO") == val2 ||
PANTHEIOS_LITERAL_STRING("FALSE") == val2)
{
flagIsOn = false;
return true;
}
}
return false;
}
} /* anonymous namespace */
/* /////////////////////////////////////////////////////////////////////////
* API functions
*/
PANTHEIOS_CALL(int)
pantheios_be_parseBooleanArg(
size_t numArgs
, pantheios_slice_t args[]
, PAN_CHAR_T const* argName
, int flagSuppressesAction
, pantheios_uint32_t flagValue
, pantheios_uint32_t* flags
)
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
{
try
{
return pantheios_be_parseBooleanArg_(numArgs, args, argName, flagSuppressesAction, flagValue, flags);
}
catch(std::bad_alloc&)
{
pantheios_onBailOut3(PANTHEIOS_SEV_CRITICAL, "Out of memory when parsing boolean argument", NULL);
}
catch(std::exception& x)
{
pantheios_onBailOut4(PANTHEIOS_SEV_CRITICAL, "Unspecified exception when parsing boolean argument", NULL, x.what());
}
# ifdef PANTHEIOS_USE_CATCHALL
catch(...)
{
pantheios_onBailOut3(PANTHEIOS_SEV_EMERGENCY, "Unknown failure when parsing boolean argument", NULL);
# if defined(PANTHEIOS_CATCHALL_TRANSLATE_UNKNOWN_EXCEPTIONS_TO_FAILURE_CODE)
;
# elif defined(PANTHEIOS_CATCHALL_RETHROW_UNKNOWN_EXCEPTIONS)
throw;
# else
pantheios_exitProcess(EXIT_FAILURE);
# endif
}
# endif /* PANTHEIOS_USE_CATCHALL */
return 0;
}
static int
pantheios_be_parseBooleanArg_(
size_t numArgs
, pantheios_slice_t args[]
, PAN_CHAR_T const* argName
, int flagSuppressesAction
, pantheios_uint32_t flagValue
, pantheios_uint32_t* flags
)
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
{
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API((NULL != args || 0 == numArgs), "arguments pointer may only be null if the number of arguments is 0");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != argName, "argument name may not be the null string");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API('\0' != 0[argName], "argument name may not be the empty string");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != flags, "flags pointer may not be null");
int numProcessed = 0;
{ for(size_t i = 0; i < numArgs; ++i)
{
pantheios_slice_t& slice = *(args + i);
if(0 != slice.len)
{
string_view_t arg(slice.ptr, slice.len);
string_view_t name;
string_view_t value;
if(!stlsoft::split(arg, PANTHEIOS_LITERAL_CHAR('='), name, value))
{
value = PANTHEIOS_LITERAL_STRING("yes");
}
if(name == argName)
{
// Now read what is required, compare it with the
// default flag, and
bool flagIsOn;
if(!has_boolean_flag_value(value, flagIsOn))
{
continue; // Invalid value. Mark to ignore
}
++numProcessed;
if((!flagIsOn) != (!flagSuppressesAction))
{
*flags |= flagValue;
}
slice.len = 0; // Mark this slice as having been processed successfully
break;
}
}
}}
return numProcessed;
}
PANTHEIOS_CALL(int)
pantheios_be_parseStringArg(
size_t numArgs
, pantheios_slice_t args[]
, PAN_CHAR_T const* argName
, pantheios_slice_t* argValue
)
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
{
try
{
return pantheios_be_parseStringArg_(numArgs, args, argName, argValue);
}
catch(std::bad_alloc&)
{
pantheios_onBailOut3(PANTHEIOS_SEV_CRITICAL, "Out of memory when parsing string argument", NULL);
}
catch(std::exception& x)
{
pantheios_onBailOut4(PANTHEIOS_SEV_CRITICAL, "Unspecified exception when parsing string argument", NULL, x.what());
}
# ifdef PANTHEIOS_USE_CATCHALL
catch(...)
{
pantheios_onBailOut3(PANTHEIOS_SEV_EMERGENCY, "Unknown failure when parsing boolean argument", NULL);
# if defined(PANTHEIOS_CATCHALL_TRANSLATE_UNKNOWN_EXCEPTIONS_TO_FAILURE_CODE)
;
# elif defined(PANTHEIOS_CATCHALL_RETHROW_UNKNOWN_EXCEPTIONS)
throw;
# else
pantheios_exitProcess(EXIT_FAILURE);
# endif
}
# endif /* PANTHEIOS_USE_CATCHALL */
return 0;
}
static int
pantheios_be_parseStringArg_(
size_t numArgs
, pantheios_slice_t args[]
, PAN_CHAR_T const* argName
, pantheios_slice_t* argValue
)
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
{
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API((NULL != args || 0 == numArgs), "arguments pointer may only be null if the number of arguments is 0");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != argName, "argument name may not be the null string");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API('\0' != 0[argName], "argument name may not be the empty string");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != argValue, "argument value pointer may not be null");
int numProcessed = 0;
{ for(size_t i = 0; i < numArgs; ++i)
{
pantheios_slice_t& slice = *(args + i);
if(0 != slice.len)
{
string_view_t arg(slice.ptr, slice.len);
string_view_t name;
string_view_t value;
stlsoft::split(arg, PANTHEIOS_LITERAL_CHAR('='), name, value);
if(name == argName)
{
++numProcessed;
argValue->len = value.size();
argValue->ptr = value.data();
slice.len = 0; // Mark this slice as having been processed successfully
break;
}
}
}}
return numProcessed;
}
PANTHEIOS_CALL(int)
pantheios_be_parseStockArgs(
size_t numArgs
, pantheios_slice_t args[]
, pantheios_uint32_t* flags
)
#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
{
try
{
return pantheios_be_parseStockArgs_(numArgs, args, flags);
}
catch(std::bad_alloc&)
{
pantheios_onBailOut3(PANTHEIOS_SEV_CRITICAL, "Out of memory when parsing stock argument", NULL);
}
catch(std::exception& x)
{
pantheios_onBailOut4(PANTHEIOS_SEV_CRITICAL, "Unspecified exception when parsing stock argument", NULL, x.what());
}
# ifdef PANTHEIOS_USE_CATCHALL
catch(...)
{
pantheios_onBailOut3(PANTHEIOS_SEV_EMERGENCY, "Unknown failure when parsing stock argument", NULL);
# if defined(PANTHEIOS_CATCHALL_TRANSLATE_UNKNOWN_EXCEPTIONS_TO_FAILURE_CODE)
;
# elif defined(PANTHEIOS_CATCHALL_RETHROW_UNKNOWN_EXCEPTIONS)
throw;
# else
pantheios_exitProcess(EXIT_FAILURE);
# endif
}
# endif /* PANTHEIOS_USE_CATCHALL */
return 0;
}
static int
pantheios_be_parseStockArgs_(
size_t numArgs
, pantheios_slice_t args[]
, pantheios_uint32_t* flags
)
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
{
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API((NULL != args || 0 == numArgs), "arguments pointer may only be null if the number of arguments is 0");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != flags, "flags pointer may not be null");
int numProcessed = 0;
{ for(size_t i = 0; i < numArgs; ++i)
{
pantheios_slice_t& slice = *(args + i);
if(0 != slice.len)
{
string_view_t arg(slice.ptr, slice.len);
string_view_t name;
string_view_t value;
bool flagSuppresses;
int flagValue;
if(!stlsoft::split(arg, PANTHEIOS_LITERAL_CHAR('='), name, value))
{
value = PANTHEIOS_LITERAL_STRING("yes");
}
if(!name.empty())
{
// PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
if(name == PANTHEIOS_LITERAL_STRING("showProcessId"))
{
flagSuppresses = true;
flagValue = PANTHEIOS_BE_INIT_F_NO_PROCESS_ID;
}
// PANTHEIOS_BE_INIT_F_NO_THREAD_ID
else if(name == PANTHEIOS_LITERAL_STRING("showThreadId"))
{
flagSuppresses = true;
flagValue = PANTHEIOS_BE_INIT_F_NO_PROCESS_ID;
}
// PANTHEIOS_BE_INIT_F_NO_DATETIME
else if(name == PANTHEIOS_LITERAL_STRING("showDateTime"))
{
flagSuppresses = true;
flagValue = PANTHEIOS_BE_INIT_F_NO_DATETIME;
}
// PANTHEIOS_BE_INIT_F_NO_SEVERITY
else if(name == PANTHEIOS_LITERAL_STRING("showSeverity"))
{
flagSuppresses = true;
flagValue = PANTHEIOS_BE_INIT_F_NO_SEVERITY;
}
// PANTHEIOS_BE_INIT_F_USE_SYSTEM_TIME
else if(name == PANTHEIOS_LITERAL_STRING("useSystemTime"))
{
flagSuppresses = false;
flagValue = PANTHEIOS_BE_INIT_F_USE_SYSTEM_TIME;
}
// PANTHEIOS_BE_INIT_F_DETAILS_AT_START
else if(name == PANTHEIOS_LITERAL_STRING("showDetailsAtStart"))
{
flagSuppresses = false;
flagValue = PANTHEIOS_BE_INIT_F_DETAILS_AT_START;
}
// PANTHEIOS_BE_INIT_F_USE_UNIX_FORMAT
else if(name == PANTHEIOS_LITERAL_STRING("useUnixFormat") ||
name == PANTHEIOS_LITERAL_STRING("useUNIXFormat"))
{
flagSuppresses = false;
flagValue = PANTHEIOS_BE_INIT_F_USE_UNIX_FORMAT;
}
// PANTHEIOS_BE_INIT_F_HIDE_DATE
else if(name == PANTHEIOS_LITERAL_STRING("showDate"))
{
flagSuppresses = true;
flagValue = PANTHEIOS_BE_INIT_F_HIDE_DATE;
}
// PANTHEIOS_BE_INIT_F_HIDE_TIME
else if(name == PANTHEIOS_LITERAL_STRING("showTime"))
{
flagSuppresses = true;
flagValue = PANTHEIOS_BE_INIT_F_HIDE_TIME;
}
// PANTHEIOS_BE_INIT_F_HIGH_RESOLUTION
else if(name == PANTHEIOS_LITERAL_STRING("highResolution"))
{
flagSuppresses = false;
flagValue = PANTHEIOS_BE_INIT_F_HIGH_RESOLUTION;
}
// PANTHEIOS_BE_INIT_F_LOW_RESOLUTION
else if(name == PANTHEIOS_LITERAL_STRING("lowResolution"))
{
flagSuppresses = false;
flagValue = PANTHEIOS_BE_INIT_F_LOW_RESOLUTION;
}
// PANTHEIOS_BE_INIT_F_NUMERIC_SEVERITY
else if(name == PANTHEIOS_LITERAL_STRING("numericSeverity"))
{
flagSuppresses = false;
flagValue = PANTHEIOS_BE_INIT_F_NUMERIC_SEVERITY;
}
else
{
continue; // We ignore any non-stock flags
}
// Now read what is required, compare it with the
// default flag, and
bool flagIsOn;
if(!has_boolean_flag_value(value, flagIsOn))
{
continue; // Invalid value. Mark to ignore
}
++numProcessed;
if((!flagIsOn) != (!flagSuppresses))
{
*flags |= flagValue;
}
slice.len = 0; // Mark this slice as having been processed successfully
}
}
}}
return numProcessed;
}
/* ///////////////////////////// end of file //////////////////////////// */
| [
"matthew@synesis.com.au"
] | matthew@synesis.com.au |
88b535880546a07f1f4fa88f0e374cfa78440041 | 2351c922fbee24a3856d885fc70263dae58a9eb0 | /src/princekin/utils/SwitchControl.cpp | a38bbafc03f143e086ff1208b3143cfa72043418 | [] | no_license | waitMonster/android | dc4298c9e4827389e24782a9dfa33c7dab84eae1 | 6f9b223ba330ff3bb22e048348df1309930c31b0 | refs/heads/master | 2021-08-16T15:42:39.163958 | 2017-11-17T10:47:20 | 2017-11-17T10:47:20 | 111,359,369 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,698 | cpp | #include <QPainter>
#include <QMouseEvent>
#include "SwitchControl.h"
SwitchControl::SwitchControl(QWidget *parent)
: QWidget(parent),
m_nHeight(16),
m_bChecked(false),
m_radius(8.0),
m_nMargin(3),
m_checkedColor(0, 150, 136),
m_thumbColor(Qt::gray),
m_disabledColor(190, 190, 190),
m_background(Qt::gray)
{
// 鼠标滑过光标形状 - 手型
setCursor(Qt::PointingHandCursor);
// 连接信号槽
connect(&m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()));
}
// 绘制开关
void SwitchControl::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setPen(Qt::NoPen);
painter.setRenderHint(QPainter::Antialiasing);
QPainterPath path;
QColor background;
QColor thumbColor;
qreal dOpacity;
if (isEnabled()) { // 可用状态
if (m_bChecked) { // 打开状态
background = m_checkedColor;
thumbColor = m_checkedColor;
dOpacity = 0.600;
} else { //关闭状态
background = m_background;
thumbColor = m_thumbColor;
dOpacity = 0.800;
}
} else { // 不可用状态
background = m_background;
dOpacity = 0.260;
thumbColor = m_disabledColor;
}
// 绘制大椭圆
painter.setBrush(background);
painter.setOpacity(dOpacity);
path.addRoundedRect(QRectF(m_nMargin, m_nMargin, width() - 2 * m_nMargin, height() - 2 * m_nMargin), m_radius, m_radius);
painter.drawPath(path.simplified());
// 绘制小椭圆
painter.setBrush(thumbColor);
painter.setOpacity(1.0);
painter.drawEllipse(QRectF(m_nX - (m_nHeight / 2), m_nY - (m_nHeight / 2), height(), height()));
}
// 鼠标按下事件
void SwitchControl::mousePressEvent(QMouseEvent *event)
{
if (isEnabled()) {
if (event->buttons() & Qt::LeftButton) {
event->accept();
} else {
event->ignore();
}
}
}
// 鼠标释放事件 - 切换开关状态、发射toggled()信号
void SwitchControl::mouseReleaseEvent(QMouseEvent *event)
{
if (isEnabled()) {
if ((event->type() == QMouseEvent::MouseButtonRelease) && (event->button() == Qt::LeftButton)) {
event->accept();
m_bChecked = !m_bChecked;
emit toggled(m_bChecked);
m_timer.start(10);
} else {
event->ignore();
}
}
}
// 大小改变事件
void SwitchControl::resizeEvent(QResizeEvent *event)
{
m_nX = m_nHeight / 2;
m_nY = m_nHeight / 2;
QWidget::resizeEvent(event);
}
// 默认大小
QSize SwitchControl::sizeHint() const
{
return minimumSizeHint();
}
// 最小大小
QSize SwitchControl::minimumSizeHint() const
{
return QSize(3 * (m_nHeight + m_nMargin), m_nHeight + 2 * m_nMargin);
}
// 切换状态 - 滑动
void SwitchControl::onTimeout()
{
if (m_bChecked) {
m_nX += 1;
if (m_nX >= width() - m_nHeight)
m_timer.stop();
} else {
m_nX -= 1;
if (m_nX <= m_nHeight / 2)
m_timer.stop();
}
update();
}
// 返回开关状态 - 打开:true 关闭:false
bool SwitchControl::isToggled() const
{
return m_bChecked;
}
// 设置开关状态
void SwitchControl::setToggle(bool checked)
{
m_bChecked = checked;
m_timer.start(10);
}
// 设置背景颜色
void SwitchControl::setBackgroundColor(QColor color)
{
m_background = color;
}
// 设置选中颜色
void SwitchControl::setCheckedColor(QColor color)
{
m_checkedColor = color;
}
// 设置不可用颜色
void SwitchControl::setDisbaledColor(QColor color)
{
m_disabledColor = color;
}
| [
"chorushechang@126.com"
] | chorushechang@126.com |
e1afd0e263083f415b004d46c897cee21ec215a2 | 4b84c467209e647227fbaa009b6bcbf81a02f109 | /algorithm/1463_1로만들기.cpp | 7358bed6cfa5554da57f1bf3f2b15e72c1d1e551 | [] | no_license | kangukKim/algorithm | 1889075f8e24c0db7495414b75e63380811ab621 | b86f38039d6f4e27ca316a4ee710ad843e40bd8a | refs/heads/master | 2023-07-09T18:04:00.283549 | 2021-07-27T13:19:07 | 2021-07-27T13:19:07 | 329,225,266 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 566 | cpp | #include<iostream>
#include<algorithm>
using namespace std;
int dp[1000001];
int main() {
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
dp[1] = 0;
dp[2] = 1;
dp[3] = 1;
for (int i = 4; i <= n; i++) {
if (i % 3 == 0) {
if (i % 2 == 0) {
dp[i] = min({ dp[i / 3], dp[i / 2], dp[i - 1] }) + 1;
}
else {
dp[i] = min(dp[i / 3], dp[i - 1]) + 1;
}
}
else {
if (i % 2 == 0) {
dp[i] = min(dp[i / 2], dp[i - 1]) + 1;
}
else {
dp[i] = dp[i - 1] + 1;
}
}
}
cout << dp[n];
return 0;
} | [
"12171728@inha.edu"
] | 12171728@inha.edu |
39936988145acc960b42e6afde63d67c7e4472b6 | 8f98e89b786db3dcffaa2f80d87f55a37e1e49ca | /notAnotherClockProject/Button.h | 76bcfd9188b13b93bb6084c6e2bab8a39886189e | [] | no_license | fornellas/sketchbook | cd25a930246678ccc6efab48ca9c47e8b8af2ff7 | 734eea6769a954beaec339c3261ed6ccce949ddd | refs/heads/master | 2022-02-26T05:50:43.967410 | 2022-02-19T14:49:17 | 2022-02-19T14:49:17 | 3,287,133 | 4 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 621 | h | #ifndef Button_h
#define Button_h
#define BUTTON_COUNT 4
#define BUTTON_MODE 0
#define BUTTON_A 1
#define BUTTON_B 2
#define BUTTON_C 3
class Button {
private:
boolean buttonState[BUTTON_COUNT];
unsigned long lastChangeTime[BUTTON_COUNT];
boolean pressedState[BUTTON_COUNT];
boolean releasedState[BUTTON_COUNT];
public:
Button();
// to be called in loop or interrupt to update button status
void update();
// get the status of a button
boolean state(byte button);
// true if button has been pressed
boolean pressed(byte button);
boolean released(byte button);
};
extern Button button;
#endif
| [
"fabio.ornellas@gmail.com"
] | fabio.ornellas@gmail.com |
3712918e04b5e0b2e62c29003c830f2493976321 | 0628581b4ea5f55fcf371fae3efcc9e813d78cdc | /Week07/CollisionDetection/CollisionDetection/Form1.h | b94c01ad9d503d9ba199da1f2302bae4f2ea0daa | [] | no_license | darvja1op/IN628-Prog4-C- | e66741deba4d2d2451a4bae549ad759eca38c345 | c713121bfb422159aecddd560236beeabe1692a5 | refs/heads/master | 2021-01-11T19:07:15.786780 | 2016-11-08T04:14:18 | 2016-11-08T04:14:18 | 79,320,752 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,078 | h | #pragma once
#include "SpriteList.h"
#include "Sprite.h"
namespace CollisionDetection {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::ComponentModel::IContainer^ components;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
Graphics^ formCanvas;
const int NUM_FRAMES = 8;
int additionCount;
Bitmap^ offScreenBitmap;
Graphics^ offScreenCanvas;
SpriteList^ chickenList;
Random^ rGen;
Sprite^ knight;
int HEIGHT;
private: System::Windows::Forms::Timer^ timer1;
int WIDTH;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
this->SuspendLayout();
//
// timer1
//
this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::Black;
this->ClientSize = System::Drawing::Size(1223, 726);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::Form1_KeyDown);
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
formCanvas = CreateGraphics();
rGen = gcnew Random();
WIDTH = this->Width;
HEIGHT = this->Height;
offScreenBitmap = gcnew Bitmap(WIDTH, HEIGHT);
offScreenCanvas = Graphics::FromImage(offScreenBitmap);
formCanvas->DrawImage(offScreenBitmap, 0, 0);
generateChickenSprites();
knight = generateKnightSprite();
timer1->Enabled = true;
}
private: Sprite^ generateKnightSprite(){
int framesInKnightSheet = 8;
int directions = 4;
array<String^>^ knightImages = gcnew array<String^>(directions);
knightImages[EAST] = "images/Knight Walk East 8.bmp";
knightImages[NORTH] = "images/Knight Walk North 8.bmp";
knightImages[SOUTH] = "images/Knight Walk South 8.bmp";
knightImages[WEST] = "images/Knight Walk West 8.bmp";
return gcnew Sprite(offScreenCanvas, knightImages, rGen, framesInKnightSheet, Rectangle(0, 0, Width, Height),0.1);
}
private: void generateChickenSprites(){
int framesInChickenSheet = 8;
int directions = 4;
int nChickens = 12;
chickenList = gcnew SpriteList();
array<String^>^ chickenImages = gcnew array<String^>(directions);
chickenImages[EAST] = "images/Little Chicken Walk East 8.bmp";
chickenImages[NORTH] = "images/Little Chicken Walk North 8.bmp";
chickenImages[SOUTH] = "images/Little Chicken Walk South 8.bmp";
chickenImages[WEST] = "images/Little Chicken Walk West 8.bmp";
Rectangle chickenBounds = Rectangle(0, 0, Width, Height);
for (int i = 0; i < nChickens; i++)
{
Sprite^ newChicken = gcnew Sprite(offScreenCanvas, chickenImages, rGen, framesInChickenSheet, chickenBounds, 0.3);
newChicken->SpriteDirection = rGen->Next(directions);
newChicken->XVel = rGen->Next(1, 7);
newChicken->YVel = rGen->Next(1, 7);
chickenList->addSprite(newChicken);
}
}
private: System::Void Form1_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e)
{
switch (e->KeyData)
{
case Keys::Left:
knight->SpriteDirection = WEST;
break;
case Keys::Right:
knight->SpriteDirection = EAST;
break;
case Keys::Up:
knight->SpriteDirection = NORTH;
break;
case Keys::Down:
knight->SpriteDirection = SOUTH;
break;
}
}
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
Sprite^ victim = chickenList->checkCollisions(knight);
if (victim != nullptr)
{
victim->XVel = 0;
victim->YVel = 0;
}
chickenList->eraseSprites();
chickenList->moveSprites();
chickenList->updateSprites();
chickenList->drawSprites();
knight->erase(Color::Black);
knight->move();
knight->updateFrame();
knight->draw();
formCanvas->DrawImage(offScreenBitmap, 0, 0);
}
};
}
| [
"jared.darvilljackson@gmail.com"
] | jared.darvilljackson@gmail.com |
1d6f48da8da278b47f4f4fb5173dad14308f1126 | 1d928c3f90d4a0a9a3919a804597aa0a4aab19a3 | /c++/ClickHouse/2017/4/AggregateFunctionArray.h | e4396ba4fbf93603572d6d732f3bf21be48a6ae7 | [
"BSL-1.0"
] | permissive | rosoareslv/SED99 | d8b2ff5811e7f0ffc59be066a5a0349a92cbb845 | a062c118f12b93172e31e8ca115ce3f871b64461 | refs/heads/main | 2023-02-22T21:59:02.703005 | 2021-01-28T19:40:51 | 2021-01-28T19:40:51 | 306,497,459 | 1 | 1 | null | 2020-11-24T20:56:18 | 2020-10-23T01:18:07 | null | UTF-8 | C++ | false | false | 4,207 | h | #pragma once
#include <Columns/ColumnArray.h>
#include <DataTypes/DataTypeArray.h>
#include <AggregateFunctions/IAggregateFunction.h>
#include <IO/WriteHelpers.h>
namespace DB
{
/** Not an aggregate function, but an adapter of aggregate functions,
* which any aggregate function `agg(x)` makes an aggregate function of the form `aggArray(x)`.
* The adapted aggregate function calculates nested aggregate function for each element of the array.
*/
class AggregateFunctionArray final : public IAggregateFunction
{
private:
AggregateFunctionPtr nested_func_owner;
IAggregateFunction * nested_func;
size_t num_agruments;
public:
AggregateFunctionArray(AggregateFunctionPtr nested_) : nested_func_owner(nested_), nested_func(nested_func_owner.get()) {}
String getName() const override
{
return nested_func->getName() + "Array";
}
DataTypePtr getReturnType() const override
{
return nested_func->getReturnType();
}
void setArguments(const DataTypes & arguments) override
{
num_agruments = arguments.size();
if (0 == num_agruments)
throw Exception("Array aggregate functions requires at least one argument", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
DataTypes nested_arguments;
for (size_t i = 0; i < num_agruments; ++i)
{
if (const DataTypeArray * array = typeid_cast<const DataTypeArray *>(&*arguments[i]))
nested_arguments.push_back(array->getNestedType());
else
throw Exception("Illegal type " + arguments[i]->getName() + " of argument #" + toString(i + 1) + " for aggregate function " + getName() + ". Must be array.", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
nested_func->setArguments(nested_arguments);
}
void setParameters(const Array & params) override
{
nested_func->setParameters(params);
}
void create(AggregateDataPtr place) const override
{
nested_func->create(place);
}
void destroy(AggregateDataPtr place) const noexcept override
{
nested_func->destroy(place);
}
bool hasTrivialDestructor() const override
{
return nested_func->hasTrivialDestructor();
}
size_t sizeOfData() const override
{
return nested_func->sizeOfData();
}
size_t alignOfData() const override
{
return nested_func->alignOfData();
}
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena * arena) const override
{
const IColumn * nested[num_agruments];
for (size_t i = 0; i < num_agruments; ++i)
nested[i] = &static_cast<const ColumnArray &>(*columns[i]).getData();
const ColumnArray & first_array_column = static_cast<const ColumnArray &>(*columns[0]);
const IColumn::Offsets_t & offsets = first_array_column.getOffsets();
size_t begin = row_num == 0 ? 0 : offsets[row_num - 1];
size_t end = offsets[row_num];
for (size_t i = begin; i < end; ++i)
nested_func->add(place, nested, i, arena);
}
void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena * arena) const override
{
nested_func->merge(place, rhs, arena);
}
void serialize(ConstAggregateDataPtr place, WriteBuffer & buf) const override
{
nested_func->serialize(place, buf);
}
void deserialize(AggregateDataPtr place, ReadBuffer & buf, Arena * arena) const override
{
nested_func->deserialize(place, buf, arena);
}
void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override
{
nested_func->insertResultInto(place, to);
}
bool allocatesMemoryInArena() const override
{
return nested_func->allocatesMemoryInArena();
}
static void addFree(const IAggregateFunction * that, AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena * arena)
{
static_cast<const AggregateFunctionArray &>(*that).add(place, columns, row_num, arena);
}
IAggregateFunction::AddFunc getAddressOfAddFunction() const override final { return &addFree; }
};
}
| [
"rodrigosoaresilva@gmail.com"
] | rodrigosoaresilva@gmail.com |
79f0486be71bf5eac70f61c0babe76f80c99093e | d01e69627ab2e6746ee92ffa1e60fd1c5c3509bc | /src/db.cpp | 12ce4d17b2e8074ab00dd8d055abeeaa7fb716b7 | [] | no_license | etnKlendathu/db | 79275d6c291a532bd7f6e2c64c8775e6c259f96a | f0f0332185e483ce9e12aac1df0a17d85ac2a372 | refs/heads/master | 2023-08-13T05:13:10.532072 | 2021-10-06T11:08:19 | 2021-10-06T11:08:19 | 411,966,297 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,898 | cpp | #include "fty/db.h"
//#include <tntdb.h>
#if 0
namespace fty::db {
static std::string dbpath()
{
return fmt::format("mysql:db=box_utf8;user={};password={}",
getenv("DB_USER") == nullptr ? "root" : getenv("DB_USER"),
getenv("DB_PASSWD") == nullptr ? "" : getenv("DB_PASSWD")
);
}
// =====================================================================================================================
// =====================================================================================================================
void shutdown()
{
tntdb::dropCached();
}
// =====================================================================================================================
struct Row::Impl
{
explicit Impl(const tntdb::Row& row)
: m_row(row)
{
}
tntdb::Row m_row;
};
// =====================================================================================================================
struct Rows::Impl
{
explicit Impl(const tntdb::Result& rows)
: m_rows(rows)
{
}
tntdb::Result m_rows;
};
// =====================================================================================================================
struct Statement::Impl
{
explicit Impl(const tntdb::Statement& st)
: m_st(st)
{
}
mutable tntdb::Statement m_st;
};
// =====================================================================================================================
// =====================================================================================================================
struct Transaction::Impl
{
explicit Impl(tntdb::Connection& tr)
: m_trans(tr)
{
}
tntdb::Transaction m_trans;
};
// =====================================================================================================================
// =====================================================================================================================
Statement::Statement(std::unique_ptr<Statement::Impl> impl)
: m_impl(std::move(impl))
{
}
Statement::~Statement()
{
}
Row Statement::selectRow() const
{
try {
return Row(std::make_shared<Row::Impl>(m_impl->m_st.selectRow()));
} catch (const tntdb::NotFound& e) {
return unexpected<Error>({Error::Code::NotFound, e.what()});
} catch (const tntdb::NullValue& e) {
return unexpected<Error>({Error::Code::NullValue, e.what()});
} catch (const tntdb::TypeError& e) {
return unexpected<Error>({Error::Code::TypeError, e.what()});
} catch (const tntdb::SqlError& e) {
return unexpected<Error>({Error::Code::SqlError, e.what()});
} catch (const tntdb::FieldNotFound& e) {
return unexpected<Error>({Error::Code::FieldNotFound, e.what()});
} catch (const tntdb::Error& e) {
return unexpected<Error>({Error::Code::Error, e.what()});
} catch (const std::exception& e) {
return unexpected<Error>({Error::Code::Error, e.what()});
}
}
Expected<Rows, Error> Statement::select() const
{
try {
return Rows(std::make_shared<Rows::Impl>(m_impl->m_st.select()));
} catch (const tntdb::NotFound& e) {
return unexpected<Error>({Error::Code::NotFound, e.what()});
} catch (const tntdb::NullValue& e) {
return unexpected<Error>({Error::Code::NullValue, e.what()});
} catch (const tntdb::TypeError& e) {
return unexpected<Error>({Error::Code::TypeError, e.what()});
} catch (const tntdb::SqlError& e) {
return unexpected<Error>({Error::Code::SqlError, e.what()});
} catch (const tntdb::FieldNotFound& e) {
return unexpected<Error>({Error::Code::FieldNotFound, e.what()});
} catch (const tntdb::Error& e) {
return unexpected<Error>({Error::Code::Error, e.what()});
} catch (const std::exception& e) {
return unexpected<Error>({Error::Code::Error, e.what()});
}
}
Expected<uint, Error> Statement::execute() const
{
try {
return m_impl->m_st.execute();
} catch (const tntdb::NotFound& e) {
return unexpected<Error>({Error::Code::NotFound, e.what()});
} catch (const tntdb::NullValue& e) {
return unexpected<Error>({Error::Code::NullValue, e.what()});
} catch (const tntdb::TypeError& e) {
return unexpected<Error>({Error::Code::TypeError, e.what()});
} catch (const tntdb::SqlError& e) {
return unexpected<Error>({Error::Code::SqlError, e.what()});
} catch (const tntdb::FieldNotFound& e) {
return unexpected<Error>({Error::Code::FieldNotFound, e.what()});
} catch (const tntdb::Error& e) {
return unexpected<Error>({Error::Code::Error, e.what()});
} catch (const std::exception& e) {
return unexpected<Error>({Error::Code::Error, e.what()});
}
}
Statement& Statement::bind()
{
return *this;
}
void Statement::set(const std::string& name, const std::string& val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, bool val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, int8_t val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, uint8_t val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, int16_t val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, uint16_t val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, int32_t val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, uint32_t val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, int64_t val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, uint64_t val)
{
m_impl->m_st.set(name, val);
}
void Statement::setNull(const std::string& name)
{
m_impl->m_st.setNull(name);
}
void Statement::set(const std::string& name, float val)
{
m_impl->m_st.set(name, val);
}
void Statement::set(const std::string& name, double val)
{
m_impl->m_st.set(name, val);
}
// =====================================================================================================================
Row::Row(std::shared_ptr<Impl> impl)
: m_impl(impl)
{
}
Row::~Row()
{
}
std::string Row::getString(const std::string& name, const std::string& defVal) const
{
try {
return m_impl->m_row.getString(name);
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
bool Row::getBool(const std::string& name, bool defVal) const
{
try {
return m_impl->m_row.getBool(name);
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
int8_t Row::getInt8(const std::string& name, int8_t defVal) const
{
try {
return int8_t(m_impl->m_row.getInt(name));
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
uint8_t Row::getUint8(const std::string& name, uint8_t defVal) const
{
try {
return uint8_t(m_impl->m_row.getUnsigned(name));
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
int16_t Row::getInt16(const std::string& name, int16_t defVal) const
{
try {
return int16_t(m_impl->m_row.getUnsigned(name));
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
uint16_t Row::getUint16(const std::string& name, uint16_t defVal) const
{
try {
return uint16_t(m_impl->m_row.getUnsigned(name));
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
int32_t Row::getInt32(const std::string& name, int32_t defVal) const
{
try {
return m_impl->m_row.getInt(name);
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
uint32_t Row::getUint32(const std::string& name, uint32_t defVal) const
{
try {
return m_impl->m_row.getUnsigned(name);
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
int64_t Row::getInt64(const std::string& name, int64_t defVal) const
{
try {
return m_impl->m_row.getInt64(name);
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
uint64_t Row::getUint64(const std::string& name, uint64_t defVal) const
{
try {
return m_impl->m_row.getUnsigned64(name);
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
float Row::getFloat(const std::string& name, float defVal) const
{
try {
return m_impl->m_row.getFloat(name);
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
double Row::getDouble(const std::string& name, double defVal) const
{
try {
return m_impl->m_row.getDouble(name);
} catch (const tntdb::NullValue& /* e*/) {
return defVal;
}
}
bool Row::isNull(const std::string& name) const
{
try {
return m_impl->m_row.isNull(name);
} catch (const tntdb::NullValue& /* e*/) {
return {};
}
}
std::string Row::get(const std::string& col, const std::string& defVal) const
{
if (isNull(col)) {
return defVal;
} else {
return getString(col, defVal);
}
}
// =====================================================================================================================
// Rows iterator impl
// =====================================================================================================================
void ConstIterator::setOffset(size_t off)
{
if (off != m_offset) {
m_offset = off;
if (m_offset < m_rows.m_impl->m_rows.size()) {
m_current = std::make_shared<Row::Impl>(m_rows.m_impl->m_rows.getRow(unsigned(m_offset)));
}
}
}
ConstIterator::ConstIterator(const Rows& r, size_t off)
: m_rows(r)
, m_offset(off)
{
if (m_offset < r.m_impl->m_rows.size()) {
m_current = std::make_shared<Row::Impl>(r.m_impl->m_rows.getRow(unsigned(m_offset)));
}
}
bool ConstIterator::operator==(const ConstIterator& it) const
{
return m_offset == it.m_offset;
}
bool ConstIterator::operator!=(const ConstIterator& it) const
{
return !operator==(it);
}
ConstIterator& ConstIterator::operator++()
{
setOffset(m_offset + 1);
return *this;
}
ConstIterator ConstIterator::operator++(int)
{
ConstIterator ret = *this;
setOffset(m_offset + 1);
return ret;
}
ConstIterator ConstIterator::operator--()
{
setOffset(m_offset - 1);
return *this;
}
ConstIterator ConstIterator::operator--(int)
{
ConstIterator ret = *this;
setOffset(m_offset - 1);
return ret;
}
ConstIterator::ConstReference ConstIterator::operator*() const
{
return m_current;
}
ConstIterator::ConstPointer ConstIterator::operator->() const
{
return &m_current;
}
ConstIterator& ConstIterator::operator+=(difference_type n)
{
setOffset(m_offset + size_t(n));
return *this;
}
ConstIterator ConstIterator::operator+(difference_type n) const
{
ConstIterator it(*this);
it += n;
return it;
}
ConstIterator& ConstIterator::operator-=(difference_type n)
{
setOffset(m_offset - size_t(n));
return *this;
}
ConstIterator ConstIterator::operator-(difference_type n) const
{
ConstIterator it(*this);
it -= n;
return it;
}
ConstIterator::difference_type ConstIterator::operator-(const ConstIterator& it) const
{
return ConstIterator::difference_type(m_offset - it.m_offset);
}
// =====================================================================================================================
// Rows impl
// =====================================================================================================================
Rows::~Rows()
{
}
ConstIterator Rows::begin() const
{
return ConstIterator(*this, 0);
}
ConstIterator Rows::end() const
{
return ConstIterator(*this, size());
}
size_t Rows::size() const
{
return m_impl->m_rows.size();
}
bool Rows::empty() const
{
return m_impl->m_rows.empty();
}
Row Rows::operator[](size_t off) const
{
return Row(std::make_unique<Row::Impl>(m_impl->m_rows.getRow(unsigned(off))));
}
Rows::Rows(std::shared_ptr<Impl> impl)
: m_impl(impl)
{
}
Rows::Rows()
{
}
// =====================================================================================================================
// Transaction impl
// =====================================================================================================================
Transaction::Transaction(Connection& con)
: m_impl(std::make_unique<Impl>(con.m_impl->m_connection))
{
}
Transaction::~Transaction()
{
}
void Transaction::commit()
{
m_impl->m_trans.commit();
}
void Transaction::rollback()
{
m_impl->m_trans.rollback();
}
// =====================================================================================================================
} // namespace fty::db
#endif
| [
"dmitrijzukov@eaton.com"
] | dmitrijzukov@eaton.com |
3ec2eb4972c4aca56948275e15cf9674e640a29b | ec3a754ac21137a04250ef7dc9e5152e94fb7bd3 | /damBreakFine/processor2/0.8/alpha.water | 9876e1bdc45d135763a0864a52d2e2d01f282503 | [] | no_license | johnathoncobabe/425 | 2336a62cd0f575b777cd549a886a15b5799b6c72 | e1ee61fb87a1078683d71a1d15131713c435cfae | refs/heads/master | 2021-01-10T10:00:11.128510 | 2015-10-02T17:54:40 | 2015-10-02T17:54:40 | 43,466,206 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,535 | water | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.4.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0.8";
object alpha.water;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
leftWall
{
type zeroGradient;
}
rightWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
atmosphere
{
type inletOutlet;
inletValue uniform 0;
value uniform 0;
}
defaultFaces
{
type empty;
}
procBoundary2to0
{
type processor;
value uniform 0;
}
procBoundary2to3
{
type processor;
value uniform 0;
}
}
// ************************************************************************* //
| [
"johnathoncobabe@gmail.com"
] | johnathoncobabe@gmail.com |
8f15a9eb7b6abdb11b6d7013734e2c42f6d6474f | ae035cee99be3eb9fe80894958594133b02434c5 | /DNP3Test/ReadableVtoWriter.h | 92b88c39047a522084079cfa2c2bb38a79f87be9 | [
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"Zlib"
] | permissive | prakashnsm/dnp3 | 668c285c995b4cd770574a5da253d9bf89ae0005 | 8c2dae38905daef9756cb1cfc4054f760e1ec9fa | refs/heads/master | 2021-01-20T21:25:56.481259 | 2012-07-27T21:46:44 | 2012-07-27T21:46:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,616 | h | /*
* Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. Green Enery
* Corp licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#ifndef __READABLE_VTO_WRITER_H_
#define __READABLE_VTO_WRITER_H_
#include <DNP3/VtoWriter.h>
#include <DNP3/IVtoEventAcceptor.h>
namespace apl
{
namespace dnp
{
/**
* Provides a simple read function that makes testing easier
*/
class ReadableVtoWriter : public VtoWriter, private IVtoEventAcceptor
{
public:
ReadableVtoWriter(Logger* apLogger, size_t aMaxVtoChunks) : VtoWriter(apLogger, aMaxVtoChunks), mpEvent(NULL)
{}
bool Read(VtoEvent& arEvent) {
mpEvent = &arEvent;
size_t num = this->Flush(this, 1);
mpEvent = NULL;
return num > 0;
}
private:
void Update(const VtoData& arEvent, PointClass aClass, size_t aIndex) {
assert(mpEvent != NULL);
VtoEvent evt(arEvent, aClass, aIndex);
*mpEvent = evt;
}
VtoEvent* mpEvent;
};
}
}
/* vim: set ts=4 sw=4: */
#endif
| [
"jadamcrain@gmail.com"
] | jadamcrain@gmail.com |
41c3eb295700a8e1391cd033d214427af2e24f0d | 515461daff5195180a6cddf3146d6e80899e8173 | /src/tjs2_lib/tjs2_basic_drawdevice.h | 18f3afdcf134275fc0eaa103370bb5bca897b4b7 | [
"Apache-2.0"
] | permissive | yydcnjjw/my-krkrz | 9f02bc649728cfa5c0bca4c7afea3dc3d153ffaf | 75b1c74758ce776e441090f6d5f08e3aac7ece15 | refs/heads/master | 2021-05-21T16:27:01.606313 | 2020-08-16T10:38:27 | 2020-08-16T10:38:27 | 252,716,969 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,765 | h | #pragma once
#include <MsgIntf.h>
#include <tjs2_lib/tjs2_lib.h>
namespace krkrz {
enum TJS2DeviceDrawType {
dtNone, //!< drawer
dtDrawDib, //
dtDBGDI, // GDI
dtDBDD, // DirectDraw
dtDBD3D // Direct3D
};
class TJS2NativeBasicDrawDevice : public tTJSNativeInstance {
public:
tjs_error TJS_INTF_METHOD Construct(tjs_int numparams, tTJSVariant **param,
iTJSDispatch2 *tjs_obj) {
this->_this_obj = tjs_obj;
return TJS_S_OK;
}
iTJSDispatch2 *this_obj() {
assert(this->_this_obj);
return this->_this_obj;
}
private:
iTJSDispatch2 *_this_obj;
};
class TJS2BasicDrawDevice : public tTJSNativeClass {
typedef tTJSNativeClass inherited;
public:
TJS2BasicDrawDevice();
static tjs_uint32 ClassID;
static TJS2BasicDrawDevice *get() {
auto instance = getNoRef();
instance->AddRef();
return instance;
}
static TJS2BasicDrawDevice *getNoRef() {
static TJS2BasicDrawDevice instance;
return &instance;
}
static TJS2NativeBasicDrawDevice *create() {
auto _this = TJS2BasicDrawDevice::getNoRef();
iTJSDispatch2 *out{};
if (TJS_FAILED(
_this->CreateNew(0, nullptr, nullptr, &out, 0, nullptr, _this)))
TVPThrowInternalError;
TJS2NativeBasicDrawDevice *device;
out->NativeInstanceSupport(TJS_NIS_GETINSTANCE,
TJS2BasicDrawDevice::ClassID,
(iTJSNativeInstance **)&device);
return device;
}
protected:
tTJSNativeInstance *CreateNativeInstance() {
return new TJS2NativeBasicDrawDevice;
}
};
} // namespace krkrz
| [
"yydcnjjw@gmail.com"
] | yydcnjjw@gmail.com |
df65fde12d24ae4a0efb506caed0676378c8280d | a4e3ee9274033f167516352bb85ee9b1e786bbbe | /workspaces/hug_trees/hug_trees.ino | df09c455c8d8723823954f68791bdd7534d5436b | [] | no_license | avinoama/indnegev2017_interactions | 93d559f4f5557418f494bf350584c30b8bc4e142 | 24d7d9ca308a58cd85096d29b0c7f50f273ca81c | refs/heads/master | 2018-12-20T13:23:27.399552 | 2018-09-17T15:45:13 | 2018-09-17T15:45:13 | 105,457,447 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,029 | ino | /*
Hug tree
its a heart shape spunge that is painted like a heart nd will be hang on trees
Using Attiny 85
*/
#define PULSE_PIN 3 // 0 //3
#define HEART_PIN 2 // 2
#define DEBUG 0
int delay_time=1000;
int sensorValue=0;
void setup() {
// declare pin 9 to be an output:
pinMode(PULSE_PIN, OUTPUT);
if(DEBUG) {
//Serial.begin(9600);
}
}
void loop() {
// read presure on heart
sensorValue = analogRead(HEART_PIN);
if(DEBUG) {
Serial.println(sensorValue);
}
delay_time = map(sensorValue, 1, 1000, 1000, 0);
// map presure from high to low
// the hight the preuser the lower the delay
beep(50);
beep(50);
delay(delay_time);
}
void beep(unsigned char delayms){
analogWrite(PULSE_PIN, 20); // Almost any value can be used except 0 and 255
// experiment to get the best tone
delay(delayms); // wait for a delayms ms
analogWrite(PULSE_PIN, 0); // 0 turns it off
delay(delayms); // wait for a delayms ms
}
| [
"avinoam@trackonomics.net"
] | avinoam@trackonomics.net |
1f72ef6888ed28f598c7e5b347f9fec2f06cabe9 | 49b878b65e9eb00232490243ccb9aea9760a4a6d | /chrome/browser/ui/views/omnibox/omnibox_tab_switch_button.h | 12c44cce6c6ab227fab6fc22ba47e8220ef91539 | [
"BSD-3-Clause"
] | permissive | romanzes/chromium | 5a46f234a233b3e113891a5d643a79667eaf2ffb | 12893215d9efc3b0b4d427fc60f5369c6bf6b938 | refs/heads/master | 2022-12-28T00:20:03.524839 | 2020-10-08T21:01:52 | 2020-10-08T21:01:52 | 302,470,347 | 0 | 0 | BSD-3-Clause | 2020-10-08T22:10:22 | 2020-10-08T21:54:38 | null | UTF-8 | C++ | false | false | 2,197 | h | // Copyright (c) 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_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_TAB_SWITCH_BUTTON_H_
#define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_TAB_SWITCH_BUTTON_H_
#include "ui/views/controls/button/md_text_button.h"
class OmniboxPopupContentsView;
class OmniboxResultView;
class OmniboxTabSwitchButton : public views::MdTextButton {
public:
OmniboxTabSwitchButton(PressedCallback callback,
OmniboxPopupContentsView* popup_contents_view,
OmniboxResultView* result_view,
const base::string16& hint,
const base::string16& hint_short,
const gfx::VectorIcon& icon);
~OmniboxTabSwitchButton() override;
// views::MdTextButton:
void StateChanged(ButtonState old_state) override;
void OnThemeChanged() override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// Called by parent views to change background on external (not mouse related)
// event (tab key).
void UpdateBackground();
// Called by parent view to provide the width of the surrounding area
// so the button can adjust its size or even presence.
void ProvideWidthHint(int width);
private:
// Consults the parent views to see if the button is selected.
bool IsSelected() const;
// Helper function to translate parent width into goal width, and
// pass back the text at that width.
int CalculateGoalWidth(int parent_width, base::string16* goal_text);
// The ancestor views.
OmniboxPopupContentsView* const popup_contents_view_;
OmniboxResultView* const result_view_;
// Only calculate the width of various contents once.
static bool calculated_widths_;
static int icon_only_width_;
static int short_text_width_;
static int full_text_width_;
// Label strings for hint text and its short version (may be same).
base::string16 hint_;
base::string16 hint_short_;
DISALLOW_COPY_AND_ASSIGN(OmniboxTabSwitchButton);
};
#endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_TAB_SWITCH_BUTTON_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
9ac3efd76ebfa8015f28f3db3d4ae0f114b0c9ab | 2b3f666658cc4bc236af56958c3d0f4facc399cf | /MySort.cpp | cef670c818cd36d8e48af3783c78a9dcf51e8427 | [
"MIT"
] | permissive | kcrissey/PokerHandEvaluator | 9953c42e74f4e4b7972cbe10bc25171eae0cd020 | fae532dec14741ad6c9e516a0d419f0517db4d72 | refs/heads/master | 2016-09-06T09:35:37.731417 | 2015-05-03T19:28:08 | 2015-05-03T19:28:08 | 34,995,131 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 551 | cpp | #include <iostream>
#include <string.h>
#include <stdlib.h>
#include "MySort.h"
using namespace std;
void Sort (char *Array[], long NumElements) {
bool Sorted;
char c;
char *ptr;
long Found;
do {
NumElements--;
Sorted = true;
for (long i = 0; i < NumElements; i++) {
if ((strcasecmp(Array[i], Array[i + 1])) > 0) {
ptr = Array[i];
Array[i] = Array[i + 1];
Array[i + 1] = ptr;
Sorted = false;
}
else;
}
} while (!Sorted);
}
| [
"kenn.cris12@gmail.com"
] | kenn.cris12@gmail.com |
a2b8d1eecc93a3439b4cbdcacefd5978e2e84cd3 | e7492dcf59026d0ddd641e80de74404fe8f36218 | /cppdug/2015-04-09/code/TemplateFactoryWithMethodDetection.cpp | 2e45d4ceb705d27258ec38b8c0f3a1745239995d | [
"MIT"
] | permissive | mihaitodor/Presentations | 58b94dfdf2e19c55e026a2bceeef81dcf58aff64 | 98c698acce779383c8a7f29f5cabd2389c292e54 | refs/heads/main | 2023-01-11T23:41:33.320851 | 2022-12-21T15:46:07 | 2022-12-21T15:49:48 | 30,158,051 | 15 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 2,246 | cpp | /*
See the original code for details: https://github.com/mihaitodor/Presentations/blob/master/cppdug/20.01.2015/code/TemplateFactoryWithMethodDetection.cpp
Note: The above code has several flaws which are highlited here!
*/
#include <iostream>
#include <utility>
class Object
{
public:
Object()
{
std::cout << "Object constructor.\n";
}
//This method MUST be called after an Object instance has been constructed.
bool Init()
{
std::cout << "Performing object initialization.\n";
return true;
}
};
class SimpleObject
{
public:
SimpleObject()
{
std::cout << "Simple object constructor.\n";
}
};
//Initialize SimpleObject (do nothing, in our case)
SimpleObject InitializeObject(SimpleObject &obj)
{
return obj;
}
/*
int operator,(bool x, Object obj)
{
return 0;
}
*/
//Initialize all other objects
//Avoid issues with overloaded comma operators
template <typename T>
auto InitializeObject(T &obj) -> decltype(std::declval<T>().Init(), void(), T())
{
obj.Init();
return obj;
}
/*
Did anyone notice the asymmetry between using std::declval<T>() in the first expression
and T() in the third expression inside decltype?
What will happen if Object::Object() is private?
(ObjectFactory can he a friend of Object, so it can call its constructor)
(Yes, C++ spports template friends)
My original code should have looked like this:
template<typename T>
auto InitializeObject(T &obj) -> std::remove_reference<decltype(std::declval<T>().Init(), void(), std::declval<T>())>::type
{
obj.Init();
return obj;
}
*/
/*
So, in this case, why do we even need to rely on SFINAE?
Overload resolution is enough to select the appropriate function in this simple case!
A more robust way would be to use template specialization.
template <typename T>
T InitializeObject(T &obj)
{
obj.Init();
return obj;
}
template <>
SimpleObject InitializeObject<SimpleObject>(SimpleObject &obj)
{
return obj;
}
*/
template <typename T>
T ObjectFactory()
{
T obj;
return InitializeObject(obj);
}
int main()
{
std::cout << "Constructing object with initializer.\n";
auto obj = ObjectFactory<Object>();
std::cout << "Constructing object without initializer.\n";
auto objWithoutInitializer = ObjectFactory<SimpleObject>();
return 0;
} | [
"todormihai@gmail.com"
] | todormihai@gmail.com |
fe2b7b7777eaaa2732fb96ff53790ba4b9285533 | c6759b857e55991fea3ef0b465dbcee53fa38714 | /gap8/gvsoc/dpi-models/include/common/telnet_proxy.hpp | 8f61de9f10617ca39f57e2b351bdb786bd90e07d | [
"Apache-2.0"
] | permissive | GreenWaves-Technologies/gap_sdk | 1b343bba97b7a5ce62a24162bd72eef5cc67e269 | 3fea306d52ee33f923f2423c5a75d9eb1c07e904 | refs/heads/master | 2023-09-01T14:38:34.270427 | 2023-08-10T09:04:44 | 2023-08-10T09:04:44 | 133,324,605 | 145 | 96 | Apache-2.0 | 2023-08-27T19:03:52 | 2018-05-14T07:50:29 | C | UTF-8 | C++ | false | false | 712 | hpp | #pragma once
#include <thread>
#include <mutex>
#include <condition_variable>
#include <queue>
class Telnet_proxy
{
public:
void pop_byte(uint8_t*);
void push_byte(uint8_t*);
Telnet_proxy(int);
private:
bool open_telnet_socket(int port);
std::mutex rx_mutex;
std::mutex tx_mutex;
std::condition_variable rx_cond;
std::condition_variable tx_cond;
std::queue<uint8_t> rx_queue;
std::queue<uint8_t> tx_queue;
void push_byte_from_proxy(uint8_t*);
int pop_byte_from_client(uint8_t*);
void listener(void);
void proxy_loop(int);
int telnet_socket;
int telnet_port;
std::thread *loop_thread;
std::thread *listener_thread;
};
| [
"noreply@github.com"
] | noreply@github.com |
1a9fe46a273291279fbd37826e2a90a68b60d323 | 99daac3bca35a99b01c9302e3a92bf319c1e577e | /src/root.h | 85f36ed8b2ba14f8094dab72a5e707326f596837 | [] | no_license | texpert/flight_search_interface_cutelyst_backend | 71c48933ee8a105d17d721412ac9a317b21cd14f | 093889ef263588f851268843155930f91020672c | refs/heads/master | 2020-12-02T17:44:38.061474 | 2017-07-06T10:46:01 | 2017-07-06T10:46:01 | 96,419,531 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 470 | h | #ifndef ROOT_H
#define ROOT_H
#include <Cutelyst/Controller>
using namespace Cutelyst;
class Root : public Controller
{
Q_OBJECT
C_NAMESPACE("")
public:
explicit Root(QObject *parent = 0);
~Root();
C_ATTR(index, :Path :Args(0))
void index(Context *c);
C_ATTR(defaultPage, :Path)
void defaultPage(Context *c);
private:
C_ATTR(End, :ActionClass("RenderView"))
void End(Context *c) { Q_UNUSED(c); }
};
#endif //ROOT_H
| [
"abrinzeanu@endava.com"
] | abrinzeanu@endava.com |
c73d93b2ca98b813fa673bf534a4d8cd52d358ef | 9ff8e317e7293033e3983c5e6660adc4eff75762 | /Gamecore/network/SGF_NetServer.h | 4a5296137e66e79beaaa06ee64e33acaca521562 | [] | no_license | rasputtim/SGF | b26fd29487b93c8e67c73f866635830796970116 | d8af92216bf4e86aeb452fda841c73932de09b65 | refs/heads/master | 2020-03-28T21:55:14.668643 | 2018-11-03T21:15:32 | 2018-11-03T21:15:32 | 147,579,544 | 0 | 0 | null | null | null | null | MacCentralEurope | C++ | false | false | 1,060 | h | /*
SGF - Super Game Fabric Super Game Fabric
Copyright (C) 2010-2011 Rasputtim <raputtim@hotmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _S_G_F_network_server_h
#define _S_G_F_network_server_h
#include "../SGF_Config.h"
namespace SGF{
namespace Network{
/** \brief inicializa o servidor de conex„oe de rede */
void SGE_API networkServer();
}
} //end SGF
#endif
| [
"rasputtim@hotmail.com"
] | rasputtim@hotmail.com |
6bfb0f66a081a908daa8afdcc12f0f3174caf351 | 89ab9c481bb50fb4ac1d75ca5a356d0a0cc12fb7 | /scwin/AppNavigator.xaml.h | 25683d319fe6ad65a012df541095a2e28ad976b9 | [] | no_license | vze2rdgy/scwin | 7884ddcd7126ff4792d05752be2470a587006418 | 735ecaa75c3043e04d9f518394a69e0589a7e821 | refs/heads/master | 2021-08-03T07:10:30.833267 | 2021-08-02T03:20:22 | 2021-08-02T03:20:22 | 156,920,387 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,765 | h | //
// AppNavigator.xaml.h
// Declaration of the AppNavigator class
//
#pragma once
#include "AppNavigator.g.h"
namespace scwin
{
[Windows::Foundation::Metadata::WebHostHidden]
public ref class AppNavigator sealed
{
static DependencyProperty^ selectedSubmenuItemsProperty;
static DependencyProperty^ selectedSubmenuItemProperty;
public:
static void Register();
AppNavigator();
static property DependencyProperty^ SelectedSubmenuItemsProperty
{
DependencyProperty^ get() { return selectedSubmenuItemsProperty; }
}
static property DependencyProperty^ SelectedSubmenuItemProperty
{
DependencyProperty^ get() { return selectedSubmenuItemProperty; }
}
property IObservableVector<NavMenuItem^>^ AppNavIcons;
property IObservableVector<NavMenuItem^>^ SelectedSubmenuItems
{
IObservableVector<NavMenuItem^>^ get();
void set(IObservableVector<NavMenuItem^>^);
}
property NavMenuItem^ SelectedSubmenuItem
{
NavMenuItem^ get();
void set(NavMenuItem^);
}
protected:
void OnKeyDown(KeyRoutedEventArgs ^ e) override;
private:
void LogoutNavPaneButton_Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void SettingsNavPaneButton_Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void gvNavIcons_ItemClick(Platform::Object^ sender, Windows::UI::Xaml::Controls::ItemClickEventArgs^ e);
void btnForNavBar_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void BuildSubmenus(String^ navHeaderName, String^ lastSelectedSubmenuItem = nullptr);
void KeyDownHandler(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
};
}
| [
"noreply@github.com"
] | noreply@github.com |
02161ef3913a2706fc2aea470c4b5c805196792e | ea69a2590f1489aa72e00d1c90c20ac3936b666c | /FCIChern2TriangularLatticeModel.cc | f4b0bfcf430f73f1c2289a86f4880158b9be8a4e | [] | no_license | tianhansamuel/fractional-chern-insulator | 6794fdb9d90bdd0befca3fca666f74cb2fda1560 | 63f55de3ec2e0de24773abd4f54538e334aaea7e | refs/heads/master | 2020-07-01T21:02:23.854818 | 2019-08-09T12:44:14 | 2019-08-09T12:44:14 | 201,299,232 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,809 | cc | #include "Options/Options.h"
#include "HilbertSpace/FermionOnSquareLatticeWithSpinMomentumSpace.h"
#include "HilbertSpace/FermionOnSquareLatticeMomentumSpace.h"
#include "HilbertSpace/FermionOnSquareLatticeWithSpinMomentumSpaceLong.h"
#include "HilbertSpace/FermionOnSquareLatticeMomentumSpaceLong.h"
#include "HilbertSpace/BosonOnSquareLatticeMomentumSpace.h"
#include "Hamiltonian/ParticleOnLatticeChern2TriangularLatticeSingleBandHamiltonian.h"
#include "Hamiltonian/ParticleOnLatticeChern2TriangularLatticeSingleBandHamiltonianThreeBodyHamiltonian.h"
#include "LanczosAlgorithm/LanczosManager.h"
#include "Architecture/ArchitectureManager.h"
#include "Architecture/AbstractArchitecture.h"
#include "Architecture/ArchitectureOperation/MainTaskOperation.h"
#include "Matrix/HermitianMatrix.h"
#include "Matrix/RealDiagonalMatrix.h"
#include "GeneralTools/FilenameTools.h"
#include "MainTask/GenericComplexMainTask.h"
#include "Tools/FTITightBinding/TightBindingModelChern2TriangularLattice.h"
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <fstream>
using std::cout;
using std::endl;
using std::ios;
using std::ofstream;
int main(int argc, char** argv)
{
OptionManager Manager ("FCIChern2TriangularLatticeModel" , "0.01");
OptionGroup* MiscGroup = new OptionGroup ("misc options");
OptionGroup* SystemGroup = new OptionGroup ("system options");
OptionGroup* ToolsGroup = new OptionGroup ("tools options");
OptionGroup* PrecalculationGroup = new OptionGroup ("precalculation options");
ArchitectureManager Architecture;
LanczosManager Lanczos(true);
Manager += SystemGroup;
Architecture.AddOptionGroup(&Manager);
Lanczos.AddOptionGroup(&Manager);
Manager += PrecalculationGroup;
Manager += ToolsGroup;
Manager += MiscGroup;
(*SystemGroup) += new SingleIntegerOption ('p', "nbr-particles", "number of particles", 4);
(*SystemGroup) += new SingleIntegerOption ('x', "nbr-sitex", "number of sites along the x direction", 3);
(*SystemGroup) += new SingleIntegerOption ('y', "nbr-sitey", "number of sites along the y direction", 3);
(*SystemGroup) += new SingleIntegerOption ('\n', "only-kx", "only evalute a given x momentum sector (negative if all kx sectors have to be computed)", -1);
(*SystemGroup) += new SingleIntegerOption ('\n', "only-ky", "only evalute a given y momentum sector (negative if all ky sectors have to be computed)", -1);
(*SystemGroup) += new BooleanOption ('\n', "boson", "use bosonic statistics instead of fermionic statistics");
(*SystemGroup) += new BooleanOption ('\n', "full-momentum", "compute the spectrum for all momentum sectors, disregarding symmetries");
(*SystemGroup) += new SingleDoubleOption ('\n', "u-potential", "repulsive nearest neighbor potential strength", 1.0);
(*SystemGroup) += new SingleDoubleOption ('\n', "v-potential", "repulsive next to nearest neighbor potential strength", 0.0);
(*SystemGroup) += new BooleanOption ('\n', "three-body", "use a three body interaction instead of a two body interaction");
(*SystemGroup) += new BooleanOption ('\n', "four-body", "use a four body interaction instead of a two body interaction");
(*SystemGroup) += new BooleanOption ('\n', "five-body", "use a five body interaction instead of a two body interaction");
(*SystemGroup) += new SingleDoubleOption ('\n', "t1", "nearest neighbor hopping amplitude", 1.0);
(*SystemGroup) += new SingleDoubleOption ('\n', "t2", "next to nearest neighbor hopping amplitude", 0.25);
(*SystemGroup) += new SingleDoubleOption ('\n', "phi", "phase in the hoppng terms", 0.166667);
(*SystemGroup) += new SingleDoubleOption ('\n', "mus", "chemical potential on site A", 0.0);
(*SystemGroup) += new SingleDoubleOption ('\n', "gamma-x", "boundary condition twisting angle along x (in 2 Pi unit)", 0.0);
(*SystemGroup) += new SingleDoubleOption ('\n', "gamma-y", "boundary condition twisting angle along y (in 2 Pi unit)", 0.0);
(*SystemGroup) += new BooleanOption ('\n', "singleparticle-spectrum", "only compute the one body spectrum");
(*SystemGroup) += new BooleanOption ('\n', "export-onebody", "export the one-body information (band structure and eigenstates) in a binary file");
(*SystemGroup) += new BooleanOption ('\n', "export-onebodytext", "export the one-body information (band structure and eigenstates) in an ASCII text file");
(*SystemGroup) += new SingleStringOption ('\n', "export-onebodyname", "optional file name for the one-body information output");
(*SystemGroup) += new BooleanOption ('\n', "flat-band", "use flat band model");
(*SystemGroup) += new BooleanOption ('\n', "single-band", "project onto the lowest energy band");
(*SystemGroup) += new SingleDoubleOption ('\n', "3body-potential", "3 body interaction strength", 0.0);
(*SystemGroup) += new SingleIntegerOption ('\n', "band", "band to be filled", 0);
(*SystemGroup) += new SingleStringOption ('\n', "eigenvalue-file", "filename for eigenvalues output");
(*SystemGroup) += new SingleStringOption ('\n', "eigenstate-file", "filename for eigenstates output; to be appended by _kx_#_ky_#.#.vec");
(*PrecalculationGroup) += new SingleIntegerOption ('m', "memory", "amount of memory that can be allocated for fast multiplication (in Mbytes)", 500);
#ifdef __LAPACK__
(*ToolsGroup) += new BooleanOption ('\n', "use-lapack", "use LAPACK libraries instead of DiagHam libraries");
#endif
#ifdef __SCALAPACK__
(*ToolsGroup) += new BooleanOption ('\n', "use-scalapack", "use SCALAPACK libraries instead of DiagHam or LAPACK libraries");
#endif
(*ToolsGroup) += new BooleanOption ('\n', "show-hamiltonian", "show matrix representation of the hamiltonian");
(*ToolsGroup) += new SingleStringOption ('\n', "export-hamiltonian", "export hamiltonian in an ASCII column formatted file", 0);
(*ToolsGroup) += new BooleanOption ('\n', "test-hermitian", "show matrix representation of the hamiltonian");
(*MiscGroup) += new BooleanOption ('h', "help", "display this help");
if (Manager.ProceedOptions(argv, argc, cout) == false)
{
cout << "see man page for option syntax or type FCIChern2TriangularLatticeModel -h" << endl;
return -1;
}
if (Manager.GetBoolean("help") == true)
{
Manager.DisplayHelp (cout);
return 0;
}
int NbrParticles = Manager.GetInteger("nbr-particles");
int NbrSitesX = Manager.GetInteger("nbr-sitex");
int NbrSitesY = Manager.GetInteger("nbr-sitey");
long Memory = ((unsigned long) Manager.GetInteger("memory")) << 20;
char* StatisticPrefix = new char [16];
if (Manager.GetBoolean("boson") == false)
{
sprintf (StatisticPrefix, "fermions");
}
else
{
sprintf (StatisticPrefix, "bosons");
}
char* FilePrefix = new char [256];
if ((Manager.GetBoolean("three-body") == false) && (Manager.GetBoolean("four-body") == false) && (Manager.GetBoolean("five-body") == false))
{
sprintf (FilePrefix, "%s_singleband_triangularlatticemodel_n_%d_x_%d_y_%d", StatisticPrefix, NbrParticles, NbrSitesX, NbrSitesY);
}
else
{
if (Manager.GetBoolean("three-body") == true)
{
sprintf (FilePrefix, "%s_singleband_threebody_triangularlatticemodel_n_%d_x_%d_y_%d",StatisticPrefix, NbrParticles, NbrSitesX, NbrSitesY);
}
else
{
if (Manager.GetBoolean("four-body") == true)
{
sprintf (FilePrefix, "%s_singleband_fourbody_triangularlatticemodel_n_%d_x_%d_y_%d", StatisticPrefix, NbrParticles, NbrSitesX, NbrSitesY);
}
else
{
sprintf (FilePrefix, "%s_singleband_fivebody_triangularlatticemodel_n_%d_x_%d_y_%d", StatisticPrefix, NbrParticles, NbrSitesX, NbrSitesY);
}
}
}
char* CommentLine = new char [256];
sprintf (CommentLine, "eigenvalues\n# kx ky ");
char* EigenvalueOutputFile = new char [512];
if (Manager.GetString("eigenvalue-file")!=0)
strcpy(EigenvalueOutputFile, Manager.GetString("eigenvalue-file"));
else
{
if (Manager.GetBoolean("flat-band") == true)
{
sprintf (EigenvalueOutputFile, "%s_t_%g_t1_%g_phi_%g_gx_%g_gy_%g.dat",FilePrefix, Manager.GetDouble("t1"), Manager.GetDouble("t2"), Manager.GetDouble("phi"), Manager.GetDouble("gamma-x"), Manager.GetDouble("gamma-y"));
}
else
{
sprintf (EigenvalueOutputFile, "%s_u_%g_v_%g_t_%g_t1_%g_phi_%g_gx_%g_gy_%g.dat",FilePrefix, Manager.GetDouble("u-potential"),Manager.GetDouble("v-potential"), Manager.GetDouble("t1"), Manager.GetDouble("t2"), Manager.GetDouble("phi"), Manager.GetDouble("gamma-x"), Manager.GetDouble("gamma-y"));
}
}
if (Manager.GetBoolean("singleparticle-spectrum") == true)
{
bool ExportOneBody = false;
if ((Manager.GetBoolean("export-onebody") == true) || (Manager.GetBoolean("export-onebodytext") == true))
ExportOneBody = true;
TightBindingModelChern2TriangularLattice TightBindingModel(NbrSitesX, NbrSitesY,
Manager.GetDouble("t1"), Manager.GetDouble("t2"), Manager.GetDouble("phi"),
Manager.GetDouble("mus"), Manager.GetDouble("gamma-x"), Manager.GetDouble("gamma-y"),
Architecture.GetArchitecture(), ExportOneBody);
TightBindingModel.WriteAsciiSpectrum(EigenvalueOutputFile);
double BandSpread = TightBindingModel.ComputeBandSpread(0);
double DirectBandGap = TightBindingModel.ComputeDirectBandGap(0);
cout << "Spread = " << BandSpread << " Direct Gap = " << DirectBandGap << " Flattening = " << (BandSpread / DirectBandGap) << endl;
if (ExportOneBody == true)
{
char* BandStructureOutputFile = new char [512];
if (Manager.GetString("export-onebodyname") != 0)
strcpy(BandStructureOutputFile, Manager.GetString("export-onebodyname"));
else
sprintf (BandStructureOutputFile, "%s_tightbinding.dat", FilePrefix);
if (Manager.GetBoolean("export-onebody") == true)
{
TightBindingModel.WriteBandStructure(BandStructureOutputFile);
}
else
{
TightBindingModel.WriteBandStructureASCII(BandStructureOutputFile);
}
delete[] BandStructureOutputFile;
}
return 0;
}
int MinKx = 0;
int MaxKx = NbrSitesX - 1;
if (Manager.GetInteger("only-kx") >= 0)
{
MinKx = Manager.GetInteger("only-kx");
MaxKx = MinKx;
}
int MinKy = 0;
int MaxKy = NbrSitesY - 1;
if (Manager.GetInteger("only-ky") >= 0)
{
MinKy = Manager.GetInteger("only-ky");
MaxKy = MinKy;
}
TightBindingModelChern2TriangularLattice TightBindingModel(NbrSitesX, NbrSitesY,
Manager.GetDouble("t1"), Manager.GetDouble("t2"), Manager.GetDouble("phi"),
Manager.GetDouble("mus"), Manager.GetDouble("gamma-x"), Manager.GetDouble("gamma-y"),
Architecture.GetArchitecture());
bool FirstRunFlag = true;
for (int i = MinKx; i <= MaxKx; ++i)
{
for (int j = MinKy; j <= MaxKy; ++j)
{
cout << "(kx=" << i << ",ky=" << j << ") : " << endl;
ParticleOnSphere* Space = 0;
if (Manager.GetBoolean("boson") == false)
{
if ((NbrSitesX * NbrSitesY) <= 63)
{
Space = new FermionOnSquareLatticeMomentumSpace (NbrParticles, NbrSitesX, NbrSitesY, i, j);
}
else
{
Space = new FermionOnSquareLatticeMomentumSpaceLong (NbrParticles, NbrSitesX, NbrSitesY, i, j);
}
}
else
{
Space = new BosonOnSquareLatticeMomentumSpace (NbrParticles, NbrSitesX, NbrSitesY, i, j);
}
cout << "dim = " << Space->GetHilbertSpaceDimension() << endl;
if (Architecture.GetArchitecture()->GetLocalMemory() > 0)
Memory = Architecture.GetArchitecture()->GetLocalMemory();
Architecture.GetArchitecture()->SetDimension(Space->GetHilbertSpaceDimension());
AbstractQHEHamiltonian* Hamiltonian = 0;
if ((Manager.GetBoolean("three-body") == false) && (Manager.GetBoolean("four-body") == false) && (Manager.GetBoolean("five-body") == false))
{
Hamiltonian = new ParticleOnLatticeChern2TriangularLatticeSingleBandHamiltonian(Space, NbrParticles, NbrSitesX, NbrSitesY, Manager.GetDouble("u-potential"),Manager.GetDouble("v-potential"), &TightBindingModel , Manager.GetBoolean("flat-band"), Manager.GetInteger("band"),Architecture.GetArchitecture(), Memory);
}
else
{
if (Manager.GetBoolean("three-body") == true)
{
Hamiltonian = new ParticleOnLatticeChern2TriangularLatticeSingleBandThreeBodyHamiltonian(Space, NbrParticles, NbrSitesX, NbrSitesY, Manager.GetDouble("3body-potential"), Manager.GetDouble("u-potential"),Manager.GetDouble("v-potential") , &TightBindingModel , Manager.GetBoolean("flat-band") , Architecture.GetArchitecture(), Memory);
}
else
{
if (Manager.GetBoolean("four-body") == true)
{
Hamiltonian = 0;
// Hamiltonian = new ParticleOnLatticeChern2DiceLatticeSingleBandFourBodyHamiltonian(Space, NbrParticles, NbrSitesX, NbrSitesY,
// Manager.GetDouble("u-potential"), Manager.GetDouble("t1"), Manager.GetDouble("epsilon"), Manager.GetDouble("lambda"), Manager.GetDouble("B1"),
// Manager.GetDouble("mus"), Manager.GetDouble("gamma-x"), Manager.GetDouble("gamma-y"),
// Manager.GetBoolean("flat-band"), Architecture.GetArchitecture(), Memory);
}
else
{
Hamiltonian = 0;
// Hamiltonian = new ParticleOnLatticeChern2DiceLatticeSingleBandFiveBodyHamiltonian(Space, NbrParticles, NbrSitesX, NbrSitesY,
// Manager.GetDouble("u-potential"), Manager.GetDouble("t1"), Manager.GetDouble("epsilon"), Manager.GetDouble("lambda"), Manager.GetDouble("B1"),
// Manager.GetDouble("mus"), Manager.GetDouble("gamma-x"), Manager.GetDouble("gamma-y"),
// Manager.GetBoolean("flat-band"), Architecture.GetArchitecture(), Memory);
}
}
}
char* ContentPrefix = new char[256];
sprintf (ContentPrefix, "%d %d", i, j);
char* EigenstateOutputFile = new char [512];
if (Manager.GetString("eigenstate-file")!=0)
sprintf (EigenstateOutputFile, "%s_kx_%d_ky_%d", Manager.GetString("eigenstate-file"), i, j);
else
{
char* TmpExtention = new char [512];
sprintf (TmpExtention, "_kx_%d_ky_%d", i, j);
EigenstateOutputFile = ReplaceExtensionToFileName(EigenvalueOutputFile, ".dat", TmpExtention);
}
GenericComplexMainTask Task(&Manager, Hamiltonian->GetHilbertSpace(), &Lanczos, Hamiltonian, ContentPrefix, CommentLine, 0.0, EigenvalueOutputFile, FirstRunFlag, EigenstateOutputFile);
FirstRunFlag = false;
MainTaskOperation TaskOperation (&Task);
TaskOperation.ApplyOperation(Architecture.GetArchitecture());
cout << "------------------------------------" << endl;
delete Hamiltonian;
delete Space;
delete[] EigenstateOutputFile;
delete[] ContentPrefix;
}
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
4d980fa20049fadfb91f0c6d2fd0bccf8a712fce | 245ce77616363cc2fac61d642421d91104a539a8 | /src/qt/test/test_main.cpp | 006d7f74d9ece6f895b930102b9456261f014b83 | [
"MIT",
"FSFAP"
] | permissive | TradeTensor/tradetensor | fe60406a0c483904de0ee48520ff7cd8fa59ac37 | 54e76bed3723dfb06c3365843358b528ba06c50a | refs/heads/master | 2022-11-22T14:21:00.352545 | 2020-07-27T04:14:49 | 2020-07-27T04:14:49 | 274,551,704 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,295 | cpp | // Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2017 The Tradetensor developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/tradetensor-config.h"
#endif
#include "util.h"
#include "uritests.h"
#ifdef ENABLE_WALLET
#include "paymentservertests.h"
#endif
#include <QCoreApplication>
#include <QObject>
#include <QTest>
#if defined(QT_STATICPLUGIN) && QT_VERSION < 0x050000
#include <QtPlugin>
Q_IMPORT_PLUGIN(qcncodecs)
Q_IMPORT_PLUGIN(qjpcodecs)
Q_IMPORT_PLUGIN(qtwcodecs)
Q_IMPORT_PLUGIN(qkrcodecs)
#endif
// This is all you need to run all the tests
int main(int argc, char *argv[])
{
SetupEnvironment();
bool fInvalid = false;
// Don't remove this, it's needed to access
// QCoreApplication:: in the tests
QCoreApplication app(argc, argv);
app.setApplicationName("Tradetensor-Qt-test");
URITests test1;
if (QTest::qExec(&test1) != 0)
fInvalid = true;
#ifdef ENABLE_WALLET
PaymentServerTests test2;
if (QTest::qExec(&test2) != 0)
fInvalid = true;
#endif
return fInvalid;
}
| [
"support@tradetensor.xyz"
] | support@tradetensor.xyz |
7b1dd943388387a18ccf414e392cc56d630bd063 | 7208837d6c1f0ac3ff623060fe0b64dfd4e541a1 | /components/sync_sessions/task_tracker.h | bf79ab1688255f48eb5d39203634577b6b997a7b | [
"BSD-3-Clause"
] | permissive | isoundy000/chromium | b2ee07ebc5ce85e5d635292f6a37dbb7c2135a93 | 62580345c78c08c977ba504d789ed92c1ff18525 | refs/heads/master | 2023-03-17T17:29:40.945889 | 2017-06-29T22:29:10 | 2017-06-29T22:29:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,137 | 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 COMPONENTS_SYNC_SESSIONS_TASK_TRACKER_H_
#define COMPONENTS_SYNC_SESSIONS_TASK_TRACKER_H_
#include <stddef.h>
#include <map>
#include <memory>
#include <vector>
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "components/sessions/core/session_id.h"
#include "components/sessions/core/session_types.h"
#include "ui/base/page_transition_types.h"
namespace sync_sessions {
// Default/invalid global id. These are internal timestamp representations of
// a navigation (see base::Time::ToInternalValue()). Note that task ids are
// a subset of global ids.
static constexpr int64_t kInvalidGlobalID = -1;
// Default/invalid id for a navigation.
static constexpr int kInvalidNavID = 0;
// The maximum number of tasks we track in a tab.
static constexpr int kMaxNumTasksPerTab = 100;
// Class to generate and manage task ids for navigations of a tab. It is
// expected that there is only 1 TabTasks object for every tab, although Task
// ids can be duplicated across TabTasks (see copy constructor).
class TabTasks {
public:
TabTasks();
explicit TabTasks(const TabTasks& rhs);
virtual ~TabTasks();
// Gets root->leaf task id list for the navigation denoted by |nav_id|.
// Returns an empty vector if |nav_id| is not found.
std::vector<int64_t> GetTaskIdsForNavigation(int nav_id) const;
void UpdateWithNavigation(int nav_id,
ui::PageTransition transition,
int64_t global_id);
private:
FRIEND_TEST_ALL_PREFIXES(TaskTrackerTest, LimitMaxNumberOfTasksPerTab);
FRIEND_TEST_ALL_PREFIXES(TaskTrackerTest,
CreateSubTaskFromExcludedAncestorTask);
// The task id and and immediate parent for a navigation (see
// |nav_to_task_id_map_|).
struct TaskIdAndParent {
// The task id for this navigation. Should always be present.
int64_t task_id = kInvalidGlobalID;
// The most recent global id for this navigation. This is used to determine
// the age of this navigation when expiring old navigations. Should always
// be present.
int64_t global_id = kInvalidGlobalID;
// If present, the nav id that this task is a continuation of. If this is
// the first navigation in a new task, may not be present.
int parent_nav_id = kInvalidNavID;
};
// Map converting navigation ids to a TaskIdAndParent. To find the root to
// leaf chain for a navigation, start with its navigation id, and reindex into
// the map using the parent id, until the parent id is kInvalidNavID.
std::map<int, TaskIdAndParent> nav_to_task_id_map_;
// The most recent navigation id seen for this tab.
int most_recent_nav_id_ = kInvalidNavID;
DISALLOW_ASSIGN(TabTasks);
};
// Tracks tasks of current session. Tasks are a set of navigations that are
// related by explicit user actions (as determined by transition type. See
// |UpdateWithNavigation| above). Each task is composed of a tree of task ids
// that identify the navigations of that task (see |GetTaskIdsForNavigation|).
class TaskTracker {
public:
TaskTracker();
virtual ~TaskTracker();
// Returns a TabTasks pointer, which is owned by this object, for the tab of
// given |tab_id|. |parent_id|, if set, can be used to link the task ids
// from one tab to another (e.g. when opening a navigation in a new tab, the
// task ids from the original tab are necessary to continue tracking the
// task chain).
TabTasks* GetTabTasks(SessionID::id_type tab_id,
SessionID::id_type parent_id);
// Cleans tracked task ids of navigations in the tab of |tab_id|.
void CleanTabTasks(SessionID::id_type tab_id);
private:
FRIEND_TEST_ALL_PREFIXES(TaskTrackerTest, CleanTabTasks);
std::map<SessionID::id_type, std::unique_ptr<TabTasks>> local_tab_tasks_map_;
DISALLOW_COPY_AND_ASSIGN(TaskTracker);
};
} // namespace sync_sessions
#endif // COMPONENTS_SYNC_SESSIONS_TASK_TRACKER_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
73710325ea2478a79ba10c386f0647258b794511 | a1ac51bc40e0d40f62865e3ed369bcd55da70f5f | /project/src/viewer.cpp | f96ca666e57e3d2771f651ff34a0f2cbcd998135 | [] | no_license | 1988kramer/CSCI-5229 | d91aa4d8db75a5acf159bcc2f13e5f735455c688 | a16a5a400e4f1e7b0e38edc9605bd3f0d69a0b3b | refs/heads/master | 2021-08-10T17:43:49.015029 | 2018-12-05T00:10:40 | 2018-12-05T00:10:40 | 147,578,522 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,630 | cpp | //
// Viewer Widget
//
#include <QPushButton>
#include <QComboBox>
#include <QLabel>
#include <QGroupBox>
#include <QLayout>
#include "viewer.h"
#include "SlamViz.h"
//
// Constructor for Viewer widget
//
Viewer::Viewer(QWidget* parent)
: QWidget(parent)
{
// Set window title
setWindowTitle(tr("Airplane Viewer Test"));
// Create new Lorenz widget
SlamViz* slam_viz = new SlamViz;
slam_viz->resize(slam_viz->sizeHint());
// Display widget for angles and dimension
//QLabel* display = new QLabel();
//QLabel* lighting = new QLabel();
//QLabel* axes = new QLabel();
// Pushbutton to reset view angle
QPushButton* reset = new QPushButton("Reset View");
QCheckBox* display = new QCheckBox("Orthogonal");
QCheckBox* axes = new QCheckBox("Show Axes");
QPushButton* texture = new QPushButton("Texture");
QCheckBox* sky_button = new QCheckBox("Show Skybox");
QCheckBox* inactive = new QCheckBox("Show Inactive Lmrks");
QDoubleSpinBox* land_lower = new QDoubleSpinBox();
QCheckBox* track_pose = new QCheckBox("Track Pose With Cam");
QCheckBox* prev_poses = new QCheckBox("Show Prev Poses");
QLabel* dim = new QLabel();
land_lower->setDecimals(2);
land_lower->setSingleStep(0.01);
land_lower->setRange(0.01,1.0);
land_lower->setValue(0.03);
// Connect valueChanged() signals to Lorenz slots
connect(reset, SIGNAL(clicked(void)), slam_viz, SLOT(reset(void)));
connect(display, SIGNAL(clicked(void)), slam_viz, SLOT(toggleDisplay(void)));
connect(axes, SIGNAL(clicked(void)), slam_viz, SLOT(toggleAxes(void)));
connect(texture, SIGNAL(clicked(void)), slam_viz, SLOT(switchTexture(void)));
connect(sky_button, SIGNAL(clicked(void)), slam_viz, SLOT(toggleSky(void)));
connect(inactive, SIGNAL(clicked(void)), slam_viz, SLOT(toggleInactive(void)));
connect(land_lower, SIGNAL(valueChanged(double)), slam_viz, SLOT(setLmrkDispBound(double)));
connect(track_pose, SIGNAL(clicked(void)), slam_viz, SLOT(togglePoseTrack(void)));
connect(prev_poses, SIGNAL(clicked(void)), slam_viz, SLOT(togglePrevPoses(void)));
// Connect lorenz signals to display widgets
connect(slam_viz, SIGNAL(dimen(QString)), dim, SLOT(setText(QString)));
// Connect combo box to setPAR in myself
// connect(preset , SIGNAL(currentIndexChanged(const QString&)), this , SLOT(setPAR(const QString&)));
// Set layout of child widgets
QGridLayout* layout = new QGridLayout;
layout->setColumnStretch(0,100);
layout->setColumnMinimumWidth(0,100);
layout->setRowStretch(4,100);
// Lorenz widget
layout->addWidget(slam_viz,0,0,5,1);
// Group Display parameters
QGroupBox* dspbox = new QGroupBox("Display");
QGridLayout* dsplay = new QGridLayout;
dsplay->addWidget(reset,1,0);
dsplay->addWidget(display,4,0);
dsplay->addWidget(axes,6,0);
dsplay->addWidget(texture,2,0);
dsplay->addWidget(sky_button,7,0);
dsplay->addWidget(new QLabel("Minimum Lmrk Qual"),3,1);
dsplay->addWidget(land_lower,3,0);
dsplay->addWidget(dim,5,0);
dsplay->addWidget(inactive,8,0);
dsplay->addWidget(track_pose,9,0);
dsplay->addWidget(prev_poses,10,0);
dspbox->setLayout(dsplay);
layout->addWidget(dspbox,2,1);
// Overall layout
setLayout(layout);
}
/*
// Set SBR, dt & dim in viewer
//
void Viewer::setPAR(const QString& str)
{
QStringList par = str.mid(2).split(',');
if (par.size()<5) return;
s->setValue(par[0].toDouble());
b->setValue(par[1].toDouble());
r->setValue(par[2].toDouble());
dt->setValue(par[3].toDouble());
dim->setValue(par[4].toDouble());
}
*/
| [
"1988kramer@gmail.com"
] | 1988kramer@gmail.com |
9b83f85d9321ab137acbc87f1cf0a14f22745707 | 56440b42d3ff55809d6d1fb12f74ceb6d1a24c2e | /lib/Sema/SemaInit.cpp | 95c2e7ab2d37ed35caabb338a9aea8a8ec1238ac | [
"NCSA"
] | permissive | f-akazawa/mlang | b8b3c393b78ee606ef7bba65c6b286832bcf8471 | 393edb214478d4185e594ad85ef02779002e6f72 | refs/heads/master | 2020-04-24T09:02:29.181586 | 2012-06-08T07:20:17 | 2012-06-08T07:20:17 | 34,935,578 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,441 | cpp | //===--- SemaInit.cpp - Semantic Analysis for Initializers ----------------===//
//
// Copyright (C) 2010 yabin @ CGCL
// HuaZhong University of Science and Technology, China
//
//===----------------------------------------------------------------------===//
//
// This file implements semantic analysis for initializers. The main entry
// point is Sema::CheckInitList(), but all of the work is performed
// within the InitListChecker class.
//
//===----------------------------------------------------------------------===//
#include "mlang/Sema/Sema.h"
#include "mlang/Sema/Lookup.h"
#include "mlang/Lex/Preprocessor.h"
#include "mlang/AST/ASTContext.h"
#include "mlang/AST/ExprAll.h"
#include "llvm/Support/ErrorHandling.h"
#include <map>
using namespace mlang;
//===----------------------------------------------------------------------===//
// Sema Initialization Checking
//===----------------------------------------------------------------------===//
static Expr *IsStringInit(Expr *Init, Type DefnType, ASTContext &Context) {
return NULL;
}
static void CheckStringInit(Expr *Str, Type &DefnT, Sema &S) {
}
//===----------------------------------------------------------------------===//
// Semantic checking for initializer lists.
//===----------------------------------------------------------------------===//
namespace {
class InitListChecker {
Sema &SemaRef;
bool hadError;
public:
InitListChecker(Sema &S, /*const InitializedEntity &Entity,
InitListExpr *IL,*/ Type &T);
bool HadError() { return hadError; }
};
}
//===----------------------------------------------------------------------===//
// Initialization entity
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
// Initialization sequence
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
// Attempt initialization
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
// Perform initialization
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
// Diagnose initialization failures
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
// Initialization helper functions
//===----------------------------------------------------------------------===//
//ExprResult
//Sema::PerformCopyInitialization(const InitializedEntity &Entity,
// SourceLocation EqualLoc,
// ExprResult Init) {
// if (Init.isInvalid())
// return ExprError();
//
// Expr *InitE = Init.get();
// assert(InitE && "No initialization expression?");
//
// if (EqualLoc.isInvalid())
// EqualLoc = InitE->getLocStart();
//
// InitializationKind Kind = InitializationKind::CreateCopy(InitE->getLocStart(),
// EqualLoc);
// InitializationSequence Seq(*this, Entity, Kind, &InitE, 1);
// Init.release();
// return Seq.Perform(*this, Entity, Kind, MultiExprArg(&InitE, 1));
//}
| [
"yabin.hwu@gmail.com"
] | yabin.hwu@gmail.com |
70dc13cef8a79623e0013f6ee60d5b72ac2dbc91 | c228f73222f0a29b06210bddf6ed1364353d93aa | /LeetCode/p0008/I/8-string-to-integer-atoi.cpp | 81d450d4c21b5f97192c321782119e6278b3a40f | [] | no_license | Ynjxsjmh/PracticeMakesPerfect | 40e2071e7f34ea7ae02a11f93af21e89947001c6 | 860590239da0618c52967a55eda8d6bbe00bfa96 | refs/heads/master | 2023-04-30T00:35:14.530113 | 2023-04-14T15:06:41 | 2023-04-14T15:06:41 | 167,309,940 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 948 | cpp | int myAtoi(string str) {
long sum = 0;
int sign = 1;
for (int i = 0; i < str.size(); i++) {
while (i < str.size() && str[i] == ' ') {
// if begin with a series of spaces, skip them
i++;
}
// judge the sign
if (i < str.size() && str[i] == '-') {
sign = -1;
i++;
} else if (i < str.size() && str[i] == '+') {
sign = 1;
i++;
}
// handle the sumber
while (i < str.size() && str[i] >= '0' && str[i] <= '9') {
if (sign * sum * 10 > INT_MAX || sign * (sum * 10 + str[i] - '0') > INT_MAX) {
return INT_MAX;
}
if (sign * sum * 10 < INT_MIN || sign * (sum * 10 + str[i] - '0') < INT_MIN) {
return INT_MIN;
}
sum = sum * 10 + str[i] - '0';
i++;
}
break;
}
return sign * sum;
} | [
"ynjxsjmh@gmail.com"
] | ynjxsjmh@gmail.com |
e0a5e9e7e6db50eac51a201f3c37cc7159ea50a2 | 28faf6066e77f9592918b4828eb5585790368740 | /arms_func.cpp | a811cebd3922b9ae57c5348796ed14f90121d65f | [] | no_license | dbmohit/learning-cpp | 26cd76a94d5f8e3a217df72fe7063bc33a3d798c | 7d26e3f1c60f0522afabffae7847aaa7da22ba00 | refs/heads/main | 2023-08-28T15:30:44.790659 | 2021-11-09T14:43:02 | 2021-11-09T14:43:02 | 404,365,141 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 294 | cpp | #include <iostream>
using namespace std;
void ars(int n) {
int x = 0;
int m = 1;
for (int i = 1; n>=i;i++){
int c = x + m;
x = m;
m = c;
cout<<c<<endl;
}
}
int main(){
int num;
cin>>num;
ars(num);
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
1bf7a259f7b6def2b553b9f365ff19c906e058e8 | 3e4fd5153015d03f147e0f105db08e4cf6589d36 | /Cpp/SDK/Stabby_SPECIALSoldier_Cutscene_parameters.h | c5cc3bec418a3f1e85948a32c0e5382c0f5b116e | [] | no_license | zH4x-SDK/zTorchlight3-SDK | a96f50b84e6b59ccc351634c5cea48caa0d74075 | 24135ee60874de5fd3f412e60ddc9018de32a95c | refs/heads/main | 2023-07-20T12:17:14.732705 | 2021-08-27T13:59:21 | 2021-08-27T13:59:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,897 | h | #pragma once
// Name: Torchlight3, Version: 1.0.0
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Parameters
//---------------------------------------------------------------------------
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyEnd_9C6D013A4AB2705A0B0DA58FC39EF96D
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyEnd_9C6D013A4AB2705A0B0DA58FC39EF96D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyBegin_9C6D013A4AB2705A0B0DA58FC39EF96D
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyBegin_9C6D013A4AB2705A0B0DA58FC39EF96D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnInterrupted_9C6D013A4AB2705A0B0DA58FC39EF96D
struct AStabby_SPECIALSoldier_Cutscene_C_OnInterrupted_9C6D013A4AB2705A0B0DA58FC39EF96D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnBlendOut_9C6D013A4AB2705A0B0DA58FC39EF96D
struct AStabby_SPECIALSoldier_Cutscene_C_OnBlendOut_9C6D013A4AB2705A0B0DA58FC39EF96D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnCompleted_9C6D013A4AB2705A0B0DA58FC39EF96D
struct AStabby_SPECIALSoldier_Cutscene_C_OnCompleted_9C6D013A4AB2705A0B0DA58FC39EF96D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyEnd_0D2805CD4A419D5071D0599EBD8A2D41
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyEnd_0D2805CD4A419D5071D0599EBD8A2D41_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyBegin_0D2805CD4A419D5071D0599EBD8A2D41
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyBegin_0D2805CD4A419D5071D0599EBD8A2D41_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnInterrupted_0D2805CD4A419D5071D0599EBD8A2D41
struct AStabby_SPECIALSoldier_Cutscene_C_OnInterrupted_0D2805CD4A419D5071D0599EBD8A2D41_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnBlendOut_0D2805CD4A419D5071D0599EBD8A2D41
struct AStabby_SPECIALSoldier_Cutscene_C_OnBlendOut_0D2805CD4A419D5071D0599EBD8A2D41_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnCompleted_0D2805CD4A419D5071D0599EBD8A2D41
struct AStabby_SPECIALSoldier_Cutscene_C_OnCompleted_0D2805CD4A419D5071D0599EBD8A2D41_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyEnd_E2C8FDF84A82312F4ACC4F9FF9E14D32
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyEnd_E2C8FDF84A82312F4ACC4F9FF9E14D32_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyBegin_E2C8FDF84A82312F4ACC4F9FF9E14D32
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyBegin_E2C8FDF84A82312F4ACC4F9FF9E14D32_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnInterrupted_E2C8FDF84A82312F4ACC4F9FF9E14D32
struct AStabby_SPECIALSoldier_Cutscene_C_OnInterrupted_E2C8FDF84A82312F4ACC4F9FF9E14D32_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnBlendOut_E2C8FDF84A82312F4ACC4F9FF9E14D32
struct AStabby_SPECIALSoldier_Cutscene_C_OnBlendOut_E2C8FDF84A82312F4ACC4F9FF9E14D32_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnCompleted_E2C8FDF84A82312F4ACC4F9FF9E14D32
struct AStabby_SPECIALSoldier_Cutscene_C_OnCompleted_E2C8FDF84A82312F4ACC4F9FF9E14D32_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyEnd_8498647C4B160116B19FBFBB3C610457
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyEnd_8498647C4B160116B19FBFBB3C610457_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyBegin_8498647C4B160116B19FBFBB3C610457
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyBegin_8498647C4B160116B19FBFBB3C610457_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnInterrupted_8498647C4B160116B19FBFBB3C610457
struct AStabby_SPECIALSoldier_Cutscene_C_OnInterrupted_8498647C4B160116B19FBFBB3C610457_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnBlendOut_8498647C4B160116B19FBFBB3C610457
struct AStabby_SPECIALSoldier_Cutscene_C_OnBlendOut_8498647C4B160116B19FBFBB3C610457_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnCompleted_8498647C4B160116B19FBFBB3C610457
struct AStabby_SPECIALSoldier_Cutscene_C_OnCompleted_8498647C4B160116B19FBFBB3C610457_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyEnd_9F47EE5B49B757361F0A6EBB8D5A7655
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyEnd_9F47EE5B49B757361F0A6EBB8D5A7655_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyBegin_9F47EE5B49B757361F0A6EBB8D5A7655
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyBegin_9F47EE5B49B757361F0A6EBB8D5A7655_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnInterrupted_9F47EE5B49B757361F0A6EBB8D5A7655
struct AStabby_SPECIALSoldier_Cutscene_C_OnInterrupted_9F47EE5B49B757361F0A6EBB8D5A7655_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnBlendOut_9F47EE5B49B757361F0A6EBB8D5A7655
struct AStabby_SPECIALSoldier_Cutscene_C_OnBlendOut_9F47EE5B49B757361F0A6EBB8D5A7655_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnCompleted_9F47EE5B49B757361F0A6EBB8D5A7655
struct AStabby_SPECIALSoldier_Cutscene_C_OnCompleted_9F47EE5B49B757361F0A6EBB8D5A7655_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyEnd_2A6B0C4F4E98D66198FFCD9CCB02D48D
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyEnd_2A6B0C4F4E98D66198FFCD9CCB02D48D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyBegin_2A6B0C4F4E98D66198FFCD9CCB02D48D
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyBegin_2A6B0C4F4E98D66198FFCD9CCB02D48D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnInterrupted_2A6B0C4F4E98D66198FFCD9CCB02D48D
struct AStabby_SPECIALSoldier_Cutscene_C_OnInterrupted_2A6B0C4F4E98D66198FFCD9CCB02D48D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnBlendOut_2A6B0C4F4E98D66198FFCD9CCB02D48D
struct AStabby_SPECIALSoldier_Cutscene_C_OnBlendOut_2A6B0C4F4E98D66198FFCD9CCB02D48D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnCompleted_2A6B0C4F4E98D66198FFCD9CCB02D48D
struct AStabby_SPECIALSoldier_Cutscene_C_OnCompleted_2A6B0C4F4E98D66198FFCD9CCB02D48D_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyEnd_B56548B346DBDD9E0CD69C9BE1A5EF6A
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyEnd_B56548B346DBDD9E0CD69C9BE1A5EF6A_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyBegin_B56548B346DBDD9E0CD69C9BE1A5EF6A
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyBegin_B56548B346DBDD9E0CD69C9BE1A5EF6A_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnInterrupted_B56548B346DBDD9E0CD69C9BE1A5EF6A
struct AStabby_SPECIALSoldier_Cutscene_C_OnInterrupted_B56548B346DBDD9E0CD69C9BE1A5EF6A_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnBlendOut_B56548B346DBDD9E0CD69C9BE1A5EF6A
struct AStabby_SPECIALSoldier_Cutscene_C_OnBlendOut_B56548B346DBDD9E0CD69C9BE1A5EF6A_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnCompleted_B56548B346DBDD9E0CD69C9BE1A5EF6A
struct AStabby_SPECIALSoldier_Cutscene_C_OnCompleted_B56548B346DBDD9E0CD69C9BE1A5EF6A_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyEnd_031E58A04E578F50D99B5FA678A24838
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyEnd_031E58A04E578F50D99B5FA678A24838_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnNotifyBegin_031E58A04E578F50D99B5FA678A24838
struct AStabby_SPECIALSoldier_Cutscene_C_OnNotifyBegin_031E58A04E578F50D99B5FA678A24838_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnInterrupted_031E58A04E578F50D99B5FA678A24838
struct AStabby_SPECIALSoldier_Cutscene_C_OnInterrupted_031E58A04E578F50D99B5FA678A24838_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnBlendOut_031E58A04E578F50D99B5FA678A24838
struct AStabby_SPECIALSoldier_Cutscene_C_OnBlendOut_031E58A04E578F50D99B5FA678A24838_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.OnCompleted_031E58A04E578F50D99B5FA678A24838
struct AStabby_SPECIALSoldier_Cutscene_C_OnCompleted_031E58A04E578F50D99B5FA678A24838_Params
{
struct FName NotifyName; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.ReceiveBeginPlay
struct AStabby_SPECIALSoldier_Cutscene_C_ReceiveBeginPlay_Params
{
};
// Function Stabby_SPECIALSoldier_Cutscene.Stabby_SPECIALSoldier_Cutscene_C.ExecuteUbergraph_Stabby_SPECIALSoldier_Cutscene
struct AStabby_SPECIALSoldier_Cutscene_C_ExecuteUbergraph_Stabby_SPECIALSoldier_Cutscene_Params
{
int EntryPoint; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"zp2kshield@gmail.com"
] | zp2kshield@gmail.com |
17db43568840eecaee23564651d3d590c8d74248 | 262d7d75e2e73ff830359b02155d32f45ef62fe1 | /Source/InitialConditions/MinkowskiMetric.hpp | 6d32f5fcd797a88a423dd2071ed47f72ec377424 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | zainabnazari/GRChombo | 18c9785babf2d5c913bd98e3fbdc63b9838921d3 | b31e8aeb1411fec8022c3a723990d26693775c93 | refs/heads/master | 2021-06-24T01:09:07.250127 | 2020-04-15T09:57:41 | 2020-04-15T09:57:41 | 170,687,559 | 0 | 0 | BSD-3-Clause | 2019-12-10T17:11:26 | 2019-02-14T12:25:58 | C++ | UTF-8 | C++ | false | false | 951 | hpp | /* GRChombo
* Copyright 2012 The GRChombo collaboration.
* Please refer to LICENSE in GRChombo's root directory.
*/
#ifndef MINKOWSKIMETRIC_HPP_
#define MINKOWSKIMETRIC_HPP_
#include "CCZ4Vars.hpp"
#include "Cell.hpp"
#include "Coordinates.hpp"
#include "Tensor.hpp"
#include "UserVariables.hpp" //This files needs c_NUM
#include "VarsTools.hpp"
#include "simd.hpp"
//! Class which sets CCZ4 vars to Minkowski
class MinkowskiMetric
{
public:
MinkowskiMetric() {}
public:
//! Function to compute the value of all the initial vars on the grid
template <class data_t> void compute(Cell<data_t> current_cell) const
{
// Set Minkowski vars
CCZ4Vars::VarsWithGauge<data_t> vars;
VarsTools::assign(vars, 0.0);
vars.lapse = 1.0;
vars.chi = 1.0;
FOR1(i) { vars.h[i][i] = 1.0; }
// store vars
current_cell.store_vars(vars);
}
};
#endif /* MINKOWSKIMETRIC_HPP_ */
| [
"42781686+zainabnazari@users.noreply.github.com"
] | 42781686+zainabnazari@users.noreply.github.com |
7e9d9e8d1546c01952d508dc87ce3769f2ca28c0 | 4f48a6bf3170776bdd75c1c7c6d266d0a42238e7 | /examples/jsonserializer/Sample/sampleobject.h | 4a263d6d9277e9ce540de23752c0051c75d1ff6b | [
"BSD-3-Clause"
] | permissive | leithergit/QtJsonSerializer | 2f97dc3286fc29c90dcf359f9cb6737f6697c2c9 | fea92481f6a46cb15ad518449a98a7c040077081 | refs/heads/master | 2022-02-26T12:33:45.976737 | 2018-07-17T09:19:56 | 2018-07-17T09:19:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,256 | h | #ifndef SAMPLEOBJECT_H
#define SAMPLEOBJECT_H
#include <QObject>
#include "samplegadget.h"
class SampleObject : public QObject
{
Q_OBJECT
Q_PROPERTY(int id MEMBER id)
Q_PROPERTY(QString title MEMBER title)
Q_PROPERTY(SuperFlags flags READ getFlags WRITE setFlags)
Q_PROPERTY(QList<double> scores MEMBER scores)
Q_PROPERTY(SampleObject* child MEMBER child)
Q_PROPERTY(SampleGadget gadget MEMBER gadget)
Q_PROPERTY(QString secret MEMBER secret STORED false)
public:
enum SuperFlag {
ValueA = 0x01,
ValueB = 0x02,
ValueC = 0x04
};
Q_DECLARE_FLAGS(SuperFlags, SuperFlag)
Q_FLAG(SuperFlags)
Q_INVOKABLE SampleObject(QObject *parent = nullptr);
int id;
QString title;
SuperFlags flags;
QList<double> scores;
SampleObject *child;
SampleGadget gadget;
QString secret;
private:
SuperFlags getFlags() const;
void setFlags(const SuperFlags &value);
};
class SuperSampleObject : public SampleObject
{
Q_OBJECT
Q_CLASSINFO("polymorphic", "true")
Q_PROPERTY(bool working MEMBER working)
public:
Q_INVOKABLE SuperSampleObject(QObject *parent = nullptr);
bool working;
};
Q_DECLARE_METATYPE(SampleObject*)
Q_DECLARE_METATYPE(SuperSampleObject*)
Q_DECLARE_OPERATORS_FOR_FLAGS(SampleObject::SuperFlags)
#endif // SAMPLEOBJECT_H
| [
"Skycoder42@users.noreply.github.com"
] | Skycoder42@users.noreply.github.com |
ead5278f899aded8af32fef64b290b0b708240a4 | f3a91ca59a9b6256b90960e6ca864634d106651e | /t2.cpp | 1f443833937d37983274039e5cbf9a41cfb329c7 | [] | no_license | DarkerTimes/PRACTISE2015 | 17ab28fa5a6ac1d76537b2f8107b3f21bff30a98 | 1bb89e8a2d2fc70a0117a8564b56c29de25b084e | refs/heads/master | 2016-08-04T08:42:51.836162 | 2015-07-22T07:18:30 | 2015-07-22T07:18:30 | 39,184,974 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,045 | cpp | #include <cstdio>
#include <iostream>
#include <math.h>
#include <fstream>
#include <vector>
using namespace std;
class image{
private:
int **matrix;
int x,y;
public:
image(int x, int y, int **mat){
this->matrix = new int*[x];
for(int i=0;i<x;i++){
this->matrix[i]=new int[y];
for (int j=0;j<y;j++)
this->matrix[i][j]=mat[i][j];
}
this->x=x;
this->y=y;
}
image(int x, int y){
this->matrix = new int*[x];
for(int i=0;i<x;i++){
this->matrix[i]=new int[y];
for (int j=0;j<y;j++)
this->matrix[i][j]=0;
}
this->x=x;
this->y=y;
}
int get_x(){
return this->x;
}
int get_y(){
return this->y;
}
int get_p(int x,int y){
return this->matrix[x][y];
}
void print_image(){
for(int i=0; i<this->x;i++){
for(int j=0;j<this->y;j++)
cout<<this->matrix[i][j]<<" ";
cout<<endl;
}
}
void set_points(vector <int*> points){
for(int i=0; i<points.size();i++){
this->matrix[points[i][0]][points[i][1]]=1;
}
}
void draw_rad(int r, int *t){
int xs,xf,ys,yf;
if(t[0]-r<0)
xs=0;
else
xs=t[0]-r;
if(t[1]-r<0)
ys=0;
else
ys=t[1]-r;
if(t[0]+r>=this->get_x())
xf=this->get_x();
else
xf=t[0]+r;
if(t[1]+r>=this->get_y())
yf=this->get_y();
else
yf=t[1]+r;
for(int i=xs;i<xf;i++)
for(int j=ys;j<yf;j++){
if(this->matrix[i][j]==0){
if((i==xs)||(i==xf-1))
this->matrix[i][j]=3;
if((j==ys)||(j==yf-1))
this->matrix[i][j]=3;
}
}
this->matrix[t[0]][t[1]]=2;
}
int rad_prov(int x1, int y1, int x2, int y2,int r){
double r1=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
if(r1>(double)r) return 0;
return 1;
}
int prov(vector<int*> p, int*t){
for(int i=0;i<p.size();i++)
if((t[0]==p[i][0])&&(t[1]==p[i][1]))
return 0;
return 1;
}
vector<int*> get_obj(int r,int fl){
vector<int*> p;
vector<int*> p1;
int *c=new int[2];
int *t;
for(int i=0;i<this->x;i++){
for(int j=0;j<this->y;j++){
p1.clear();
for(int i1=0;i1<=r;i1++)
for(int j1=0;j1<=r;j1++){
if((j-j1>=0)&&(i-i1>=0)){
if((this->rad_prov(j,i,j-j1,i-i1,r))&&(this->matrix[i-i1][j-j1]==1)){
t=new int[2];
t[1]=j-j1;
t[0]=i-i1;
if(prov(p1,t))
p1.push_back(t);
}
}
if((j+j1<this->y)&&(i+i1<this->x)){
if((this->rad_prov(j,i,j+j1,i+i1,r))&&(this->matrix[i+i1][j+j1]==1)){
t=new int[2];
t[1]=j+j1;
t[0]=i+i1;
if(prov(p1,t))
p1.push_back(t);
}
}
}
if(p1.size()>p.size()){
p=p1;
c[1]=j;
c[0]=i;
}
}
}
if(fl!=0){
p.clear();
p.push_back(c);
}
else cout<<"Центр окружности: "<<endl<<"x= "<<c[0]<<" y="<<c[1]<<endl;
return p;
}
};
vector<int*> read_coords( char* filename){
vector<int*> p;
ifstream file(filename);
int x,y;
int *t;
while (!file.eof()){
file>>x>>y;
t=new int[2];
t[0]=x;
t[1]=y;
p.push_back(t);
}
return p;
};
int* get_mass_centr(vector<int*> obj){
int *t=new int[2];
double x=0;
double y=0;
for(int i=0;i<obj.size();i++){
x+=obj[i][0];
y+=obj[i][1];
}
x=x/obj.size();
y=y/obj.size();
t[0]=(int)x;
t[1]=(int)y;
return t;
}
int* get_size(vector <int*> p){
int *s=new int[2];
s[0]=0;
s[1]=0;
for(int i=0; i<p.size();i++)
{
if(s[0]<p[i][0]) s[0]=p[i][0];
if(s[1]<p[i][1]) s[1]=p[i][1];
}
return s;
}
void draw_points(image* i1){
char fn[]="plain.pnm";
ofstream file(fn);
file<<"P3"<<endl;
file<<i1->get_y()<<" "<<i1->get_x()<<endl;
file<<255<<endl;
for(int i=0; i<i1->get_x();i++){
for(int j=i1->get_y()-1;j>=0;j--){
if(i1->get_p(i,j)!=0)
file<<0<<" "<<0<<" "<<0<<endl;
else
file<<255<<" "<<255<<" "<<255<<endl;
}
}
file.close();
}
void draw_obj(image* i1,int r){
char fn[]="obj.pnm";
ofstream file(fn);
vector<int*> p;
int *t;
t=i1->get_obj(r,1)[0];
i1->draw_rad(r,t);
file<<"P3"<<endl;
file<<i1->get_y()<<" "<<i1->get_x()<<endl;
file<<255<<endl;
for(int i=0; i<i1->get_x();i++){
for(int j=i1->get_y()-1;j>=0;j--){
if(i1->get_p(i,j)==1)
file<<0<<" "<<0<<" "<<0<<endl;
if(i1->get_p(i,j)==0)
file<<255<<" "<<255<<" "<<255<<endl;
if(i1->get_p(i,j)==2)
file<<100<<" "<<0<<" "<<0<<endl;
if(i1->get_p(i,j)==3)
file<<100<<" "<<100<<" "<<100<<endl;
}
}
file.close();
}
int main(int argc, char *argv[]){
char fn[]="to4ki";
int r=4; //radius
vector<int*> p;
vector<int*> obj;
int *s=new int[2];
p=read_coords(fn);
s=get_size(p);
image *i1=new image(s[0]+1,s[1]+1);
i1->set_points(p);
cout<<"Радиус: "<<r<<endl;
obj=i1->get_obj(r,0);
cout<<"Точки объекта:"<<endl;
for(int i=0;i<obj.size();i++)
cout<<"x= "<<obj[i][0]<<" y= "<<obj[i][1]<<endl;
cout<<"Центр масс:"<<endl;
s=get_mass_centr(obj);
cout<<"x= "<<s[0]<<" y= "<<s[1]<<endl;
draw_points(i1);
draw_obj(i1,r);
return 0;
}
| [
"sergeydbw@gmail.com"
] | sergeydbw@gmail.com |
210c08b28ff98019eba016e7752706becbeae6c3 | 83b0b64b729d1c93fa2174e4d853ea7d40f01df0 | /include/ExpParameters.h | fab1cfff4efc14b2996f9410419cb40be2ea93df | [
"MIT"
] | permissive | chrisk27/growdifgrow | 33cc01ca6503a7d53850a277e3203bef156ced37 | ff7482b1ca716560a93efdf3d626f441ff5b9c04 | refs/heads/master | 2020-11-26T14:46:21.685496 | 2020-07-07T02:05:55 | 2020-07-07T02:05:55 | 229,108,918 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,042 | h | #ifndef __EXPPARAMETERS_H_INCLUDED__
#define __EXPPARAMETERS_H_INCLUDED__
#include<math.h>
using namespace std;
class ExpParameters {
public:
// This section relates to experimental parameters
static const unsigned short rows; // Rows in experimental array
static const unsigned short cols; // Columns in experimental array
static const unsigned short h; // Distance used for long-range interactions
unsigned steps; // Steps in the experiment used (standard is 10**9)
// This section relates to reaction rates
float bx; // birth of xantophores
float bm; // birth of melanophores
float dx; // natural death of xantophores
float dm; // natural death of melanophores
float sm; // short-range killing of xantophore by melanophore
float sx; // short-range killing of melanophore by xantophore
float lx; // long-range activation/birth strength
float sum_rates = bx + bm + dx + dm + sm + sx + lx; // sum of all process reaction rates
float prob(float rate);
};
#endif | [
"chriskonow27@gmail.com"
] | chriskonow27@gmail.com |
98a9d9a106b1a6120b972121c90c1029015c2563 | ed2c28d704e1390755d8b7b682f954cf34073b19 | /examples/lecture08/simple-overload.cpp | 65d8b992a55191ef6a7ec24c8c3ba64b99eea0af | [] | no_license | waqarsqureshi/OOPDS | 1726099287ad80e8948afc4bebd277d8f96bfc15 | ca6ff0d556aaaa9510c927e0a90a239f8651fe93 | refs/heads/master | 2021-10-07T23:46:47.397349 | 2018-12-05T18:52:59 | 2018-12-05T18:52:59 | 106,158,901 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 913 | cpp | #include <iostream>
using namespace std;
class Distance {
private:
int feet; // 0 to infinite
int inches; // 0 to 12
public:
// required constructors
Distance() {
feet = 0;
inches = 0;
}
Distance(int f, int i) {
feet = f;
inches = i;
}
// method to display distance
void displayDistance() {
cout << "F: " << feet << " I:" << inches <<endl;
}
// overloaded minus (-) operator
Distance operator- () {
feet = -feet;
inches = -inches;
return Distance(feet, inches);
}
};
int main() {
Distance D1(11, 10), D2(-5, 11);
-D1; // apply negation
D1.displayDistance(); // display D1
-D2; // apply negation
D2.displayDistance(); // display D2
return 0;
}
| [
"xyz@xyz"
] | xyz@xyz |
f075f96924f2d24b91b089d0592b231dded54702 | c48deb0c760df6e0cc75f41201e9aac7b03b19f7 | /BackTracking/ratInAMaze.cpp | c996063e07b9aa2b6a14acb36762783a9dbba6bb | [] | no_license | piiyer0811/DSA | 9f3f9192e37161c372c0c358013974904a2bb3c1 | f42a395159bf01bdd8d4f75a3cdd93475b8da7d0 | refs/heads/master | 2023-06-30T13:08:50.935884 | 2021-08-07T11:40:40 | 2021-08-07T11:40:40 | 379,522,305 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 899 | cpp | class Solution{
public:
void helper(vector<vector<int>> &m,int i,int j,int n,string path,vector<string> &ans){
if(i<0||i>=n||j<0||j>=n){
return;
}
if(m[i][j]==0){
return;
}
if(i==n-1&&j==n-1){
ans.push_back(path);
return;
}
m[i][j]=0;
helper(m,i+1,j,n,path+"D",ans);
helper(m,i,j+1,n,path+"R",ans);
helper(m,i-1,j,n,path+"U",ans);
helper(m,i,j-1,n,path+"L",ans);
m[i][j]=1;
return;
}
vector<string> findPath(vector<vector<int>> &m, int n) {
vector<string> ans;
helper(m,0,0,n,"",ans);
sort(ans.begin(),ans.end());
return ans;
}
};
| [
"pratikiyer00@gmail.com"
] | pratikiyer00@gmail.com |
3b2af75f0b3a7cd608728d16ff155717178f4a6f | 211011c24a4b56be43a8941de35a4f8d53a964ba | /Backend/filemanager.h | 40677d3ee5d4c09442e33bf09968f635de95ae23 | [] | no_license | MartinSova/Linux-Backup-Software | 5c8e9e4e6776f5b609e5c02ea1fb57ebcab6569d | 2b2f9bfd764a8856a01db842eb084d6cebe4126b | refs/heads/master | 2021-09-20T23:35:57.335184 | 2018-08-16T19:55:52 | 2018-08-16T19:55:52 | 115,436,774 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 458 | h | #ifndef FILEMANAGER_H
#define FILEMANAGER_H
#include "json.hpp"
#include <iostream>
#include <fstream>
#include <syslog.h>
#include "configmanager.h"
using namespace std;
using json = nlohmann::json;
typedef vector<pair<int,int>> deviceIds;
class filemanager
{
public:
static void existsConfigurationFile();
static void existsStatusFile();
static void existsFileModFile();
static void write(int fd, char *buf);
};
#endif // FILEMANAGER_H
| [
"martinkevinsova@gmail.com"
] | martinkevinsova@gmail.com |
5a2f7e149e059bbf962c1aaa9e5a66dd2687ab4b | d6d8b5ee7fdd1a16c717b427e95d1d77c7fd0312 | /hw3/hw3fsck/IndexTableChecker.h | d71c0f7cb27051d6888b50d78c9ca35e66cf328e | [] | no_license | megakun/System-programming- | f1963706aba6d79b635c0a59853641fd530a96ad | 3d46a211eaa54bbc6e3bc080e67de3f98180c18d | refs/heads/main | 2023-02-15T20:48:10.726842 | 2021-01-09T05:58:03 | 2021-01-09T05:58:03 | 327,211,121 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,590 | h | /*
* Copyright ©2020 Travis McGaha. All rights reserved. Permission is
* hereby granted to students registered for University of Washington
* CSE 333 for use solely during Summer Quarter 2020 for purposes of
* the course. No other use, copying, distribution, or modification
* is permitted without prior written consent. Copyrights for
* third-party components of this work must be honored. Instructors
* interested in reusing these course materials should contact the
* author.
*/
#ifndef HW3_HW3FSCK_INDEXTABLECHECKER_H_
#define HW3_HW3FSCK_INDEXTABLECHECKER_H_
#include <stdint.h> // for uint32_t, etc.
#include <cstdio> // for (FILE *)
#include "../Utils.h"
#include "./HashTableChecker.h"
namespace hw3 {
// An IndexTableChecker is a subclass of HashTableChecker used to
// read the word-->docID_table "index" within the index file.
class IndexTableChecker : public HashTableChecker {
public:
// Construct an IndexTableChecker. Arguments:
//
// - f: an open (FILE *) for the underlying index file. The new
// object takes ownership of the (FILE *) and will fclose() it
// on destruction.
//
// - offset: the file offset of the first byte of the doctable
IndexTableChecker(FILE *f, int32_t offset, int32_t len);
// Check an IndexTableElement.
// Returns true if the element seems correct, false otherwise.
virtual bool CheckElement(int32_t elementOffset,
int32_t bucketNumber);
private:
DISALLOW_COPY_AND_ASSIGN(IndexTableChecker);
};
} // namespace hw3
#endif // HW3_HW3FSCK_INDEXTABLECHECKER_H_
| [
"megakbig@gmail.com"
] | megakbig@gmail.com |
755f03fbc243a3986fa493972a7f18256439e3be | e029526c2fe719c4ebe88881e8e54f03ed44a25c | /cryptonote/src/WalletLegacy/WalletUserTransactionsCache.cpp | dca441ed5f54a5b0d840fd37df86eae634850f81 | [
"MIT"
] | permissive | VortexTech/FTSCOIN | c4b2e443b77ec51627deb7215ae0289f43aab537 | d9b682e0ec1260ccdedf1e474eb6ca6d15642334 | refs/heads/master | 2020-12-22T16:36:47.467747 | 2020-02-08T06:14:37 | 2020-02-08T06:14:37 | 238,838,103 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 25,783 | cpp | // Copyright (c) 2011-2017 The Cryptonote developers
// Copyright (c) 2017-2020 The Circle Foundation & FTSCoin Devs
// Copyright (c) 2020-2019 FTSCoin Network & FTSCoin Devs
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "IWalletLegacy.h"
#include "crypto/hash.h"
#include "CryptoNoteCore/TransactionExtra.h"
#include "Wallet/WalletErrors.h"
#include "WalletLegacy/WalletUserTransactionsCache.h"
#include "WalletLegacy/WalletLegacySerialization.h"
#include "WalletLegacy/WalletUtils.h"
#include "Serialization/ISerializer.h"
#include "Serialization/SerializationOverloads.h"
#include <algorithm>
using namespace Crypto;
namespace CryptoNote {
struct LegacyDeposit {
TransactionId creatingTransactionId;
TransactionId spendingTransactionId;
uint32_t term;
uint64_t amount;
uint64_t interest;
};
struct LegacyDepositInfo {
Deposit deposit;
uint32_t outputInTransaction;
};
void serialize(LegacyDeposit& deposit, ISerializer& serializer) {
uint64_t creatingTxId = static_cast<uint64_t>(deposit.creatingTransactionId);
serializer(creatingTxId, "creating_transaction_id");
deposit.creatingTransactionId = static_cast<size_t>(creatingTxId);
uint64_t spendingTxIx = static_cast<uint64_t>(deposit.spendingTransactionId);
serializer(spendingTxIx, "spending_transaction_id");
deposit.creatingTransactionId = static_cast<size_t>(spendingTxIx);
serializer(deposit.term, "term");
serializer(deposit.amount, "amount");
serializer(deposit.interest, "interest");
}
void serialize(LegacyDepositInfo& depositInfo, ISerializer& serializer) {
serializer(depositInfo.deposit, "deposit");
serializer(depositInfo.outputInTransaction, "output_in_transaction");
}
namespace {
class DepositIdSequenceIterator: public std::iterator<std::random_access_iterator_tag, DepositId> {
public:
explicit DepositIdSequenceIterator(DepositId start) : val(start) {}
DepositId operator *() const { return val; }
const DepositIdSequenceIterator& operator ++() { ++val; return *this; }
DepositIdSequenceIterator operator ++(int) { DepositIdSequenceIterator copy(*this); ++val; return copy; }
const DepositIdSequenceIterator& operator --() { --val; return *this; }
DepositIdSequenceIterator operator --(int) { DepositIdSequenceIterator copy(*this); --val; return copy; }
DepositIdSequenceIterator operator +(const difference_type& n) const { return DepositIdSequenceIterator(val + n); }
DepositIdSequenceIterator operator -(const difference_type& n) const { return DepositIdSequenceIterator(val - n); }
difference_type operator -(const DepositIdSequenceIterator& other) const { return val - other.val; }
DepositIdSequenceIterator& operator +=(const difference_type& n) { val += n; return *this; }
DepositIdSequenceIterator& operator -=(const difference_type& n) { val -= n; return *this; }
bool operator <(const DepositIdSequenceIterator& other) const { return val < other.val; }
bool operator >(const DepositIdSequenceIterator& other) const { return val > other.val; }
bool operator <=(const DepositIdSequenceIterator& other) const { return !(val > other.val); }
bool operator >=(const DepositIdSequenceIterator& other) const { return !(val < other.val); }
bool operator ==(const DepositIdSequenceIterator& other) const { return val == other.val; }
bool operator !=(const DepositIdSequenceIterator& other) const { return val != other.val; }
private:
DepositId val;
};
void convertLegacyDeposits(const std::vector<LegacyDepositInfo>& legacyDeposits, UserDeposits& deposits) {
deposits.reserve(legacyDeposits.size());
for (const LegacyDepositInfo& legacyDepositInfo: legacyDeposits) {
DepositInfo info;
info.deposit.amount = legacyDepositInfo.deposit.amount;
info.deposit.creatingTransactionId = legacyDepositInfo.deposit.creatingTransactionId;
info.deposit.interest = legacyDepositInfo.deposit.interest;
info.deposit.spendingTransactionId = legacyDepositInfo.deposit.spendingTransactionId;
info.deposit.term = legacyDepositInfo.deposit.term;
info.deposit.locked = true;
info.outputInTransaction = legacyDepositInfo.outputInTransaction;
deposits.push_back(std::move(info));
}
}
}
WalletUserTransactionsCache::WalletUserTransactionsCache(uint64_t mempoolTxLiveTime) : m_unconfirmedTransactions(mempoolTxLiveTime) {
}
bool WalletUserTransactionsCache::serialize(CryptoNote::ISerializer& s) {
s(m_transactions, "transactions");
s(m_transfers, "transfers");
s(m_unconfirmedTransactions, "unconfirmed");
s(m_deposits, "deposits");
if (s.type() == CryptoNote::ISerializer::INPUT) {
updateUnconfirmedTransactions();
deleteOutdatedTransactions();
restoreTransactionOutputToDepositIndex();
rebuildPaymentsIndex();
}
return true;
}
void WalletUserTransactionsCache::deserializeLegacyV1(CryptoNote::ISerializer& s) {
s(m_transactions, "transactions");
s(m_transfers, "transfers");
m_unconfirmedTransactions.deserializeV1(s);
std::vector<LegacyDepositInfo> legacyDeposits;
s(legacyDeposits, "deposits");
convertLegacyDeposits(legacyDeposits, m_deposits);
restoreTransactionOutputToDepositIndex();
}
bool paymentIdIsSet(const PaymentId& paymentId) {
return paymentId != NULL_HASH;
}
bool canInsertTransactionToIndex(const WalletLegacyTransaction& info) {
return info.state == WalletLegacyTransactionState::Active && info.blockHeight != WALLET_LEGACY_UNCONFIRMED_TRANSACTION_HEIGHT &&
info.totalAmount > 0 && !info.extra.empty();
}
void WalletUserTransactionsCache::pushToPaymentsIndex(const PaymentId& paymentId, Offset distance) {
m_paymentsIndex[paymentId].push_back(distance);
}
void WalletUserTransactionsCache::popFromPaymentsIndex(const PaymentId& paymentId, Offset distance) {
auto it = m_paymentsIndex.find(paymentId);
if (it == m_paymentsIndex.end()) {
return;
}
auto toErase = std::lower_bound(it->second.begin(), it->second.end(), distance);
if (toErase == it->second.end() || *toErase != distance) {
return;
}
it->second.erase(toErase);
}
void WalletUserTransactionsCache::rebuildPaymentsIndex() {
auto begin = std::begin(m_transactions);
auto end = std::end(m_transactions);
std::vector<uint8_t> extra;
for (auto it = begin; it != end; ++it) {
PaymentId paymentId;
extra.insert(extra.begin(), it->extra.begin(), it->extra.end());
if (canInsertTransactionToIndex(*it) && getPaymentIdFromTxExtra(extra, paymentId)) {
pushToPaymentsIndex(paymentId, std::distance(begin, it));
}
extra.clear();
}
}
uint64_t WalletUserTransactionsCache::unconfirmedTransactionsAmount() const {
return m_unconfirmedTransactions.countUnconfirmedTransactionsAmount();
}
uint64_t WalletUserTransactionsCache::unconfrimedOutsAmount() const {
return m_unconfirmedTransactions.countUnconfirmedOutsAmount();
}
uint64_t WalletUserTransactionsCache::countUnconfirmedCreatedDepositsSum() const {
return m_unconfirmedTransactions.countCreatedDepositsSum();
}
uint64_t WalletUserTransactionsCache::countUnconfirmedSpentDepositsProfit() const {
return m_unconfirmedTransactions.countSpentDepositsProfit();
}
uint64_t WalletUserTransactionsCache::countUnconfirmedSpentDepositsTotalAmount() const {
return m_unconfirmedTransactions.countSpentDepositsTotalAmount();
}
size_t WalletUserTransactionsCache::getTransactionCount() const {
return m_transactions.size();
}
size_t WalletUserTransactionsCache::getTransferCount() const {
return m_transfers.size();
}
size_t WalletUserTransactionsCache::getDepositCount() const {
return m_deposits.size();
}
TransactionId WalletUserTransactionsCache::addNewTransaction(uint64_t amount,
uint64_t fee,
const std::string& extra,
const std::vector<WalletLegacyTransfer>& transfers,
uint64_t unlockTime,
const std::vector<TransactionMessage>& messages) {
WalletLegacyTransaction transaction;
if (!transfers.empty()) {
transaction.firstTransferId = insertTransfers(transfers);
} else {
transaction.firstTransferId = WALLET_LEGACY_INVALID_TRANSFER_ID;
}
transaction.transferCount = transfers.size();
transaction.firstDepositId = WALLET_LEGACY_INVALID_DEPOSIT_ID;
transaction.depositCount = 0;
transaction.totalAmount = -static_cast<int64_t>(amount);
transaction.fee = fee;
transaction.sentTime = time(nullptr);
transaction.isCoinbase = false;
transaction.timestamp = 0;
transaction.extra = extra;
transaction.blockHeight = WALLET_LEGACY_UNCONFIRMED_TRANSACTION_HEIGHT;
transaction.state = WalletLegacyTransactionState::Sending;
transaction.unlockTime = unlockTime;
for (const TransactionMessage& message : messages) {
transaction.messages.push_back(message.message);
}
return insertTransaction(std::move(transaction));
}
void WalletUserTransactionsCache::updateTransaction(
TransactionId transactionId, const CryptoNote::Transaction& tx, uint64_t amount, const std::vector<TransactionOutputInformation>& usedOutputs) {
// update extra field from created transaction
auto& txInfo = m_transactions.at(transactionId);
txInfo.extra.assign(tx.extra.begin(), tx.extra.end());
m_unconfirmedTransactions.add(tx, transactionId, amount, usedOutputs);
}
void WalletUserTransactionsCache::updateTransactionSendingState(TransactionId transactionId, std::error_code ec) {
auto& txInfo = m_transactions.at(transactionId);
if (ec) {
txInfo.state = ec.value() == error::TX_CANCELLED ? WalletLegacyTransactionState::Cancelled : WalletLegacyTransactionState::Failed;
m_unconfirmedTransactions.erase(txInfo.hash);
} else {
txInfo.sentTime = time(nullptr); // update sending time
txInfo.state = WalletLegacyTransactionState::Active;
}
}
std::deque<std::unique_ptr<WalletLegacyEvent>> WalletUserTransactionsCache::onTransactionUpdated(const TransactionInformation& txInfo,
int64_t txBalance,
const std::vector<TransactionOutputInformation>& newDepositOutputs,
const std::vector<TransactionOutputInformation>& spentDepositOutputs,
const Currency& currency) {
std::deque<std::unique_ptr<WalletLegacyEvent>> events;
TransactionId id = CryptoNote::WALLET_LEGACY_INVALID_TRANSACTION_ID;
if (!m_unconfirmedTransactions.findTransactionId(txInfo.transactionHash, id)) {
id = findTransactionByHash(txInfo.transactionHash);
} else {
m_unconfirmedTransactions.erase(txInfo.transactionHash);
}
if (id == CryptoNote::WALLET_LEGACY_INVALID_TRANSACTION_ID) {
WalletLegacyTransaction transaction;
bool isCoinbase = txInfo.totalAmountIn == 0;
if (isCoinbase){
transaction.fee = 0;
} else {
transaction.fee = txInfo.totalAmountIn < txInfo.totalAmountOut ? CryptoNote::parameters::MINIMUM_FEE : txInfo.totalAmountIn - txInfo.totalAmountOut;
}
transaction.firstTransferId = WALLET_LEGACY_INVALID_TRANSFER_ID;
transaction.transferCount = 0;
transaction.firstDepositId = WALLET_LEGACY_INVALID_DEPOSIT_ID;
transaction.depositCount = 0;
transaction.totalAmount = txBalance;
transaction.sentTime = 0;
transaction.hash = txInfo.transactionHash;
transaction.blockHeight = txInfo.blockHeight;
transaction.isCoinbase = isCoinbase;
transaction.timestamp = txInfo.timestamp;
transaction.extra.assign(txInfo.extra.begin(), txInfo.extra.end());
transaction.state = WalletLegacyTransactionState::Active;
transaction.unlockTime = txInfo.unlockTime;
transaction.messages = txInfo.messages;
id = insertTransaction(std::move(transaction));
events.push_back(std::unique_ptr<WalletLegacyEvent>(new WalletExternalTransactionCreatedEvent(id)));
auto updatedDepositIds = createNewDeposits(id, newDepositOutputs, currency, transaction.blockHeight);
if (!updatedDepositIds.empty()) {
auto& tx = getTransaction(id);
tx.firstDepositId = updatedDepositIds[0];
tx.depositCount = updatedDepositIds.size();
}
auto spentDepositIds = processSpentDeposits(id, spentDepositOutputs);
updatedDepositIds.insert(updatedDepositIds.end(), spentDepositIds.begin(), spentDepositIds.end());
if (!updatedDepositIds.empty()) {
events.push_back(std::unique_ptr<WalletLegacyEvent>(new WalletDepositsUpdatedEvent(std::move(updatedDepositIds))));
}
} else {
WalletLegacyTransaction& tr = getTransaction(id);
tr.blockHeight = txInfo.blockHeight;
tr.timestamp = txInfo.timestamp;
tr.state = WalletLegacyTransactionState::Active;
// notification event
events.push_back(std::unique_ptr<WalletLegacyEvent>(new WalletTransactionUpdatedEvent(id)));
if (tr.firstDepositId != WALLET_LEGACY_INVALID_DEPOSIT_ID) {
for (auto id = tr.firstDepositId; id < tr.firstDepositId + tr.depositCount; ++id) {
m_unconfirmedTransactions.eraseCreatedDeposit(id);
}
}
}
if (canInsertTransactionToIndex(getTransaction(id)) && paymentIdIsSet(txInfo.paymentId)) {
pushToPaymentsIndex(txInfo.paymentId, id);
}
return events;
}
std::deque<std::unique_ptr<WalletLegacyEvent>> WalletUserTransactionsCache::onTransactionDeleted(const Crypto::Hash& transactionHash) {
TransactionId id = CryptoNote::WALLET_LEGACY_INVALID_TRANSACTION_ID;
if (m_unconfirmedTransactions.findTransactionId(transactionHash, id)) {
m_unconfirmedTransactions.erase(transactionHash);
// LOG_ERROR("Unconfirmed transaction is deleted: id = " << id << ", hash = " << transactionHash);
assert(false);
} else {
id = findTransactionByHash(transactionHash);
}
std::deque<std::unique_ptr<WalletLegacyEvent>> events;
if (id != CryptoNote::WALLET_LEGACY_INVALID_TRANSACTION_ID) {
WalletLegacyTransaction& tr = getTransaction(id);
std::vector<uint8_t> extra(tr.extra.begin(), tr.extra.end());
PaymentId paymentId;
if (getPaymentIdFromTxExtra(extra, paymentId)) {
popFromPaymentsIndex(paymentId, id);
}
tr.blockHeight = WALLET_LEGACY_UNCONFIRMED_TRANSACTION_HEIGHT;
tr.timestamp = 0;
tr.state = WalletLegacyTransactionState::Deleted;
events.push_back(std::unique_ptr<WalletLegacyEvent>(new WalletTransactionUpdatedEvent(id)));
std::vector<DepositId> unspentDeposits = getDepositIdsBySpendingTransaction(id);
std::for_each(unspentDeposits.begin(), unspentDeposits.end(), [this] (DepositId id) {
Deposit& deposit = getDeposit(id);
deposit.spendingTransactionId = WALLET_LEGACY_INVALID_TRANSACTION_ID;
});
DepositIdSequenceIterator depositIdSequenceStart(tr.firstDepositId);
DepositIdSequenceIterator depositIdSequenceEnd(tr.firstDepositId + tr.depositCount);
if (depositIdSequenceStart != depositIdSequenceEnd || !unspentDeposits.empty()) {
unspentDeposits.insert(unspentDeposits.end(), depositIdSequenceStart, depositIdSequenceEnd);
events.push_back(std::unique_ptr<WalletLegacyEvent>(new WalletDepositsUpdatedEvent(std::move(unspentDeposits))));
}
} else {
// LOG_ERROR("Transaction wasn't found: " << transactionHash);
assert(false);
}
return events;
}
std::vector<Payments> WalletUserTransactionsCache::getTransactionsByPaymentIds(const std::vector<PaymentId>& paymentIds) const {
std::vector<Payments> payments(paymentIds.size());
auto payment = payments.begin();
for (auto& key : paymentIds) {
payment->paymentId = key;
auto it = m_paymentsIndex.find(key);
if (it != m_paymentsIndex.end()) {
std::transform(it->second.begin(), it->second.end(), std::back_inserter(payment->transactions),
[this](decltype(it->second)::value_type val) {
assert(val < m_transactions.size());
return m_transactions[val];
});
}
++payment;
}
return payments;
}
std::vector<DepositId> WalletUserTransactionsCache::unlockDeposits(const std::vector<TransactionOutputInformation>& transfers) {
std::vector<DepositId> unlockedDeposits;
for (const auto& transfer: transfers) {
auto it = m_transactionOutputToDepositIndex.find(std::tie(transfer.transactionHash, transfer.outputInTransaction));
if (it == m_transactionOutputToDepositIndex.end()) {
continue;
}
auto id = it->second;
unlockedDeposits.push_back(id);
m_deposits[id].deposit.locked = false;
}
return unlockedDeposits;
}
std::vector<DepositId> WalletUserTransactionsCache::lockDeposits(const std::vector<TransactionOutputInformation>& transfers) {
std::vector<DepositId> lockedDeposits;
for (const auto& transfer: transfers) {
auto it = m_transactionOutputToDepositIndex.find(std::tie(transfer.transactionHash, transfer.outputInTransaction));
if (it == m_transactionOutputToDepositIndex.end()) {
continue;
}
auto id = it->second;
lockedDeposits.push_back(id);
m_deposits[id].deposit.locked = true;
}
return lockedDeposits;
}
TransactionId WalletUserTransactionsCache::findTransactionByTransferId(TransferId transferId) const
{
TransactionId id;
for (id = 0; id < m_transactions.size(); ++id) {
const WalletLegacyTransaction& tx = m_transactions[id];
if (tx.firstTransferId == WALLET_LEGACY_INVALID_TRANSFER_ID || tx.transferCount == 0)
continue;
if (transferId >= tx.firstTransferId && transferId < (tx.firstTransferId + tx.transferCount))
break;
}
if (id == m_transactions.size())
return WALLET_LEGACY_INVALID_TRANSACTION_ID;
return id;
}
bool WalletUserTransactionsCache::getTransaction(TransactionId transactionId, WalletLegacyTransaction& transaction) const
{
if (transactionId >= m_transactions.size())
return false;
transaction = m_transactions[transactionId];
return true;
}
bool WalletUserTransactionsCache::getTransfer(TransferId transferId, WalletLegacyTransfer& transfer) const
{
if (transferId >= m_transfers.size())
return false;
transfer = m_transfers[transferId];
return true;
}
bool WalletUserTransactionsCache::getDeposit(DepositId depositId, Deposit& deposit) const {
if (depositId >= m_deposits.size()) {
return false;
}
deposit = m_deposits[depositId].deposit;
return true;
}
Deposit& WalletUserTransactionsCache::getDeposit(DepositId depositId) {
assert(depositId < m_deposits.size());
return m_deposits[depositId].deposit;
}
TransactionId WalletUserTransactionsCache::insertTransaction(WalletLegacyTransaction&& Transaction) {
m_transactions.emplace_back(std::move(Transaction));
return m_transactions.size() - 1;
}
TransactionId WalletUserTransactionsCache::findTransactionByHash(const Hash& hash) {
auto it = std::find_if(m_transactions.begin(), m_transactions.end(), [&hash](const WalletLegacyTransaction& tx) { return tx.hash == hash; });
if (it == m_transactions.end())
return CryptoNote::WALLET_LEGACY_INVALID_TRANSACTION_ID;
return std::distance(m_transactions.begin(), it);
}
bool WalletUserTransactionsCache::isUsed(const TransactionOutputInformation& out) const {
return m_unconfirmedTransactions.isUsed(out);
}
WalletLegacyTransaction& WalletUserTransactionsCache::getTransaction(TransactionId transactionId) {
return m_transactions.at(transactionId);
}
TransferId WalletUserTransactionsCache::insertTransfers(const std::vector<WalletLegacyTransfer>& transfers) {
std::copy(transfers.begin(), transfers.end(), std::back_inserter(m_transfers));
return m_transfers.size() - transfers.size();
}
void WalletUserTransactionsCache::updateUnconfirmedTransactions() {
for (TransactionId id = 0; id < m_transactions.size(); ++id) {
if (m_transactions[id].blockHeight == WALLET_LEGACY_UNCONFIRMED_TRANSACTION_HEIGHT) {
m_unconfirmedTransactions.updateTransactionId(m_transactions[id].hash, id);
}
}
}
WalletLegacyTransfer& WalletUserTransactionsCache::getTransfer(TransferId transferId) {
return m_transfers.at(transferId);
}
void WalletUserTransactionsCache::reset() {
m_transactions.clear();
m_transfers.clear();
m_unconfirmedTransactions.reset();
}
std::vector<TransactionId> WalletUserTransactionsCache::deleteOutdatedTransactions() {
auto deletedTransactions = m_unconfirmedTransactions.deleteOutdatedTransactions();
for (auto id: deletedTransactions) {
assert(id < m_transactions.size());
m_transactions[id].state = WalletLegacyTransactionState::Deleted;
}
return deletedTransactions;
}
void WalletUserTransactionsCache::restoreTransactionOutputToDepositIndex() {
m_transactionOutputToDepositIndex.clear();
DepositId id = 0;
for (const auto& d: m_deposits) {
WalletLegacyTransaction transaction = m_transactions[d.deposit.creatingTransactionId];
m_transactionOutputToDepositIndex[std::tie(transaction.hash, d.outputInTransaction)] = id;
++id;
}
}
DepositId WalletUserTransactionsCache::insertDeposit(const Deposit& deposit, size_t depositIndexInTransaction, const Hash& transactionHash) {
DepositInfo info;
info.deposit = deposit;
info.outputInTransaction = static_cast<uint32_t>(depositIndexInTransaction);
DepositId id = m_deposits.size();
m_deposits.push_back(std::move(info));
m_transactionOutputToDepositIndex.emplace(std::piecewise_construct, std::forward_as_tuple(transactionHash, static_cast<uint32_t>(depositIndexInTransaction)),
std::forward_as_tuple(id));
return id;
}
bool WalletUserTransactionsCache::getDepositInTransactionInfo(DepositId depositId, Hash& transactionHash, uint32_t& outputInTransaction) {
if (depositId >= m_deposits.size()) {
return false;
}
assert(m_deposits[depositId].deposit.creatingTransactionId < m_transactions.size());
outputInTransaction = m_deposits[depositId].outputInTransaction;
transactionHash = m_transactions[m_deposits[depositId].deposit.creatingTransactionId].hash;
return true;
}
std::vector<DepositId> WalletUserTransactionsCache::createNewDeposits(TransactionId creatingTransactionId, const std::vector<TransactionOutputInformation>& depositOutputs,
const Currency& currency, uint32_t height) {
std::vector<DepositId> deposits;
for (size_t i = 0; i < depositOutputs.size(); i++) {
auto id = insertNewDeposit(depositOutputs[i], creatingTransactionId, currency, height);
deposits.push_back(id);
}
return deposits;
}
DepositId WalletUserTransactionsCache::insertNewDeposit(const TransactionOutputInformation& depositOutput, TransactionId creatingTransactionId,
const Currency& currency, uint32_t height) {
assert(depositOutput.type == TransactionTypes::OutputType::Multisignature);
assert(depositOutput.term != 0);
assert(m_transactionOutputToDepositIndex.find(std::tie(depositOutput.transactionHash, depositOutput.outputInTransaction)) == m_transactionOutputToDepositIndex.end());
Deposit deposit;
deposit.amount = depositOutput.amount;
deposit.creatingTransactionId = creatingTransactionId;
deposit.term = depositOutput.term;
deposit.spendingTransactionId = WALLET_LEGACY_INVALID_TRANSACTION_ID;
deposit.interest = currency.calculateInterest(deposit.amount, deposit.term, height);
deposit.locked = true;
return insertDeposit(deposit, depositOutput.outputInTransaction, depositOutput.transactionHash);
}
std::vector<DepositId> WalletUserTransactionsCache::processSpentDeposits(TransactionId spendingTransactionId, const std::vector<TransactionOutputInformation>& spentDepositOutputs) {
std::vector<DepositId> deposits;
deposits.reserve(spentDepositOutputs.size());
for (size_t i = 0; i < spentDepositOutputs.size(); i++) {
auto depositId = getDepositId(spentDepositOutputs[i].transactionHash, spentDepositOutputs[i].outputInTransaction);
assert(depositId != WALLET_LEGACY_INVALID_DEPOSIT_ID);
if (depositId == WALLET_LEGACY_INVALID_DEPOSIT_ID) {
throw std::invalid_argument("processSpentDeposits error: requested deposit doesn't exist");
}
auto& d = m_deposits[depositId];
d.deposit.spendingTransactionId = spendingTransactionId;
deposits.push_back(depositId);
}
return deposits;
}
DepositId WalletUserTransactionsCache::getDepositId(const Hash& creatingTransactionHash, uint32_t outputInTransaction) {
auto it = m_transactionOutputToDepositIndex.find(std::tie(creatingTransactionHash, outputInTransaction));
if (it == m_transactionOutputToDepositIndex.end()) {
return WALLET_LEGACY_INVALID_DEPOSIT_ID;
}
return it->second;
}
std::vector<DepositId> WalletUserTransactionsCache::getDepositIdsBySpendingTransaction(TransactionId transactionId) {
std::vector<DepositId> ids;
for (DepositId dId = 0; dId < m_deposits.size(); ++dId) {
auto& deposit = m_deposits[dId].deposit;
if (deposit.spendingTransactionId == transactionId) {
ids.push_back(dId);
}
}
return ids;
}
void WalletUserTransactionsCache::addCreatedDeposit(DepositId id, uint64_t totalAmount) {
m_unconfirmedTransactions.addCreatedDeposit(id, totalAmount);
}
void WalletUserTransactionsCache::addDepositSpendingTransaction(const Hash& transactionHash, const UnconfirmedSpentDepositDetails& details) {
m_unconfirmedTransactions.addDepositSpendingTransaction(transactionHash, details);
}
void WalletUserTransactionsCache::eraseCreatedDeposit(DepositId id) {
m_unconfirmedTransactions.eraseCreatedDeposit(id);
}
} //namespace CryptoNote
| [
"pablob07@mail.com"
] | pablob07@mail.com |
1ef9aff1a48179f6973c117f6e35fb6184755c0a | e02ef380ffa9e18587fef69695a2cf9ab9595e45 | /HoloLensTerrainGenDemo/HoloLensTerrainGenDemo/Common/PlaneFinding/MergePlanes.cpp | 88855fb05b2c3530dbbf1a03a675fcba2055040b | [] | no_license | Traagen/HoloLensTerrainGenDemo | 8f7a5991193044e6b76414ec2ecb36b4c8a7c8c3 | e5096df1bba1a7f2bb923a5c8f0c51f57215f588 | refs/heads/master | 2021-01-11T03:44:39.291833 | 2017-07-14T19:18:42 | 2017-07-14T19:18:42 | 71,295,248 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,723 | cpp | #include "common.h"
#include "pch.h"
#include "PlaneFinding.h"
#include "Util.h"
using namespace DirectX;
namespace PlaneFinding
{
const XMVECTOR cUpDirection = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
struct PlaneGraphNode
{
BoundedPlane* plane;
bool walked;
vector<PlaneGraphNode*> neighbors;
};
float PlaneAngle(_In_ const Plane &p1, _In_ const Plane &p2)
{
return XMVectorGetX(XMVector3AngleBetweenVectors(p1.AsVector(), p2.AsVector()));
}
vector<PlaneGraphNode> BuildPlaneGraph(
_In_ INT32 numPlanes,
_In_count_(numPlanes) BoundedPlane* planes)
{
vector<PlaneGraphNode> nodes = vector<PlaneGraphNode>();
// create PlaneGraphNodes for all the planes
for (int i = 0; i < numPlanes; ++i)
{
nodes.push_back({ &planes[i], false });
}
// populate the neighbors
for (UINT32 i = 0; i < nodes.size(); ++i)
{
for (UINT32 j = i + 1; j < nodes.size(); ++j)
{
if (PlaneAngle(nodes[i].plane->plane, nodes[j].plane->plane) < 0.3f && nodes[i].plane->bounds.Intersects(nodes[j].plane->bounds))
{
nodes[i].neighbors.push_back(&nodes[j]);
nodes[j].neighbors.push_back(&nodes[i]);
}
}
}
return nodes;
}
vector<BoundedPlane*> GetNeighborsRecursive(PlaneGraphNode& startNode, vector<PlaneGraphNode>& nodes)
{
vector<BoundedPlane*> neighbors;
queue<PlaneGraphNode*> toExpand;
toExpand.push(&startNode);
startNode.walked = true;
while (!toExpand.empty())
{
PlaneGraphNode* expand = toExpand.front();
toExpand.pop();
neighbors.push_back(expand->plane);
for (PlaneGraphNode* neighbor : expand->neighbors)
{
if (!neighbor->walked)
{
neighbor->walked = true;
toExpand.push(neighbor);
}
}
}
return neighbors;
}
BoundingOrientedBox GetTightBounds(
const vector<DirectX::XMFLOAT3> &bounds,
const DirectX::XMVECTOR &plane,
bool isGravityAligned)
{
// find tight bounding box
UINT32 index = 0;
XMVECTOR normal = XMVector3Normalize(XMVectorSetW(plane, 0));
XMMATRIX planeToObserver;
if (isGravityAligned)
{
// plane space is z=-normal, y=dominant tangent, x=orthogonal
planeToObserver = XMMatrixIdentity();
planeToObserver.r[2] = -normal; // negative normal, so if you are looking at the plane, the normal is pointing backwards
planeToObserver.r[1] = XMVector3Normalize(XMVector3Cross(normal, cUpDirection));
planeToObserver.r[0] = XMVector3Cross(planeToObserver.r[1], planeToObserver.r[2]);
}
else
{
planeToObserver = ComputeYAlignedRotation(-normal);
// we actually want z-aligned instead of y-aligned (note that this incurs a flip in addition to rotation, so we need to negate an axis)
std::swap(planeToObserver.r[1], planeToObserver.r[2]);
planeToObserver.r[2] = -planeToObserver.r[2];
}
XMMATRIX observerToPlane = XMMatrixInverse(nullptr, planeToObserver);
auto boundsInPlaneSpace = GetBoundsInOrientedSpace(!isGravityAligned, [&](XMFLOAT3* vert)
{
if (index < bounds.size())
{
XMStoreFloat3(vert, XMVector3TransformCoord(XMLoadFloat3(&bounds[index]), observerToPlane));
}
index++;
return index <= bounds.size();
});
BoundingOrientedBox boundsInObserverSpace;
boundsInPlaneSpace.Transform(boundsInObserverSpace, planeToObserver);
return boundsInObserverSpace;
}
vector<BoundedPlane> MergePlanes(
_In_ INT32 numSubPlanes,
_In_count_(numSubPlanes) BoundedPlane* subPlanes,
_In_ float minArea,
_In_ float snapToGravityThreshold)
{
vector<PlaneGraphNode> nodes = BuildPlaneGraph(numSubPlanes, subPlanes);
// find the cliques in our graph of PlaneGraphNodes
// TODO: over large distances, low curvature walls will be handled as a single plane even though they may not be planar
// consider whether that causes issues. We can address the issue by deriving a plane equation and filtering verts again.
// this is a breadth-first search to flood-fill the graph. We expand each node only one time.
vector<BoundedPlane> planes;
for (auto &startNode : nodes)
{
if (!startNode.walked)
{
vector<BoundedPlane*> neighbors = GetNeighborsRecursive(startNode, nodes);
// Compute aggregate area, center, normal, and the collection of vertices that define the bounding boxes for each of the planes
// in this clique
float totalArea = 0;
vector<XMFLOAT3> boundVerts;
XMVECTOR averageCenter = g_XMZero;
XMVECTOR averageNormal = g_XMZero;
for (BoundedPlane* boundedPlane : neighbors)
{
// Rather than walk all the planes vertices again to re-run PCA, we average the plane equations of the component planes.
// This isn't guaranteed to give the plane through all the vertices if there are large angles between the planes.
// however, it saves compute time, and in practice our plane equations are close enough that this doesn't
// cause significant error.
XMVECTOR plane = XMPlaneNormalize(boundedPlane->plane.AsVector());
// We make a similar performance optimization for the bounding box - we find a tight bounding box that includes all the
// bounding boxes for each sub-plane. We could make it tighter, but it would require walking all vertices again.
// Since the component bounding boxes are tight, the box that contains them is also relatively tight.
XMMATRIX rotation = XMMatrixRotationQuaternion(XMLoadFloat4(&boundedPlane->bounds.Orientation));
XMVECTOR dx = rotation.r[0] * boundedPlane->bounds.Extents.x;
XMVECTOR dy = rotation.r[1] * boundedPlane->bounds.Extents.y;
XMVECTOR dz = rotation.r[2] * boundedPlane->bounds.Extents.z;
XMVECTOR center = XMLoadFloat3(&boundedPlane->bounds.Center);
double area = boundedPlane->area;
totalArea += static_cast<float>(area);
for (int i = 0; i < 8; ++i)
{
float signx = i & 1 ? -1.0f : 1.0f;
float signy = i & 2 ? -1.0f : 1.0f;
float signz = i & 4 ? -1.0f : 1.0f;
XMFLOAT3 boundVert;
XMStoreFloat3(&boundVert, center + dx*signx + dy*signy + dz*signz);
boundVerts.push_back(boundVert);
}
// Project center of bounding box onto plane
center -= (XMPlaneDotCoord(plane, center) * plane);
// Add weighted normal and center to averages
averageCenter += static_cast<float>(area) * center;
averageNormal += static_cast<float>(area) * plane;
}
// If the total area is big enough, then create a merged plane for this clique
if (totalArea > minArea) {
averageCenter /= totalArea;
averageNormal = XMVector3Normalize(averageNormal);
XMVECTOR averagePlane = XMPlaneFromPointNormal(averageCenter, averageNormal);
bool isGravityAligned = false;
SurfaceType st = UNKNOWN;
if (snapToGravityThreshold != 0.0f) {
Plane plane = Plane(averagePlane);
XMFLOAT3 center;
XMStoreFloat3(¢er, averageCenter);
isGravityAligned = SnapToGravity(&plane, nullptr, center, snapToGravityThreshold, cUpDirection);
averagePlane = plane.AsVector();
st = plane.surface;
}
Plane plane = Plane(averagePlane);
plane.surface = st;
BoundingOrientedBox bounds = GetTightBounds(boundVerts, averagePlane, isGravityAligned);
planes.push_back({ plane, bounds, totalArea }); // add all our aggregated information for this clique to the surface observer plane, then return it
}
}
}
return planes;
}
} | [
"Traagen@thedemonthrone.ca"
] | Traagen@thedemonthrone.ca |
84fa1a588ded8d0e1d354972cae8533f4a85c0bc | 9907672fcd81ab73ac63b2a83422a82bf31eadde | /codeeval/tyama_codeeval163.cpp | b8c4d3e6b3dd8e9d952088d92dbd902037fdf32c | [
"0BSD"
] | permissive | cielavenir/procon | bbe1974b9bddb51b76d58722a0686a5b477c4456 | 746e1a91f574f20647e8aaaac0d9e6173f741176 | refs/heads/master | 2023-06-21T23:11:24.562546 | 2023-06-11T13:15:15 | 2023-06-11T13:15:15 | 7,557,464 | 137 | 136 | null | 2020-10-20T09:35:52 | 2013-01-11T09:40:26 | C++ | UTF-8 | C++ | false | false | 762 | cpp | #include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<string> v={
"-**----*--***--***---*---****--**--****--**---**--",
"*--*--**-----*----*-*--*-*----*-------*-*--*-*--*-",
"*--*---*---**---**--****-***--***----*---**---***-",
"*--*---*--*-------*----*----*-*--*--*---*--*----*-",
"-**---***-****-***-----*-***---**---*----**---**--",
"--------------------------------------------------",
};
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string line;
for(;getline(cin,line);){
for(int i=line.size()-1;i>=0;i--)if(line[i]<'0'||'9'<line[i])line.erase(line.begin()+i);
for(int j=0;j<v.size();j++){
for(int i=0;i<line.size();i++){
for(int k=0;k<5;k++)putchar(v[j][(line[i]-'0')*5+k]);
}
puts("");
}
}
} | [
"cielartisan@gmail.com"
] | cielartisan@gmail.com |
87742fe1bd80d9e131abb775ba70e6d73cca783f | 4749fe002b04b84044b3ee953de07ba34c2e071a | /exercises/Queue/basic_int_queue.h | aa1bee8e46f8431d0216f9c69c67fb28ae3ca2cb | [] | no_license | AndyCYao/cmpt225_codes | c70cc7c9f28a0b9b2d482ad59d040059f0180b76 | d1bc31087532d739f5edac0c3232ab510e3fa394 | refs/heads/master | 2021-01-18T00:22:12.675882 | 2016-09-27T07:09:07 | 2016-09-27T07:09:07 | 68,621,264 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 543 | h | /*
File: basic_int_queue.h
Header file for a very basic "circular array" imp. of a queue.
*/
class Basic_int_queue{
public:
Basic_int_queue();
void enqueue(int item);
int dequeue();
int front();
bool empty();
int size();
private:
//This part is implementation depedent;
int capacity;
int *A; //this is the pointer to the array
int front_index; //index in A of the current front item (if queue is not empty)
int rear_index; // index in A where next item enqueued will go
int current_size; //curr number of elements in the queue
}; | [
"andyyao3@gmail.com"
] | andyyao3@gmail.com |
b44f9e9900eef794076d6bc04cfcf729e6fcc288 | 3d851b66fc6d5431f732f8d0cf699fdaa479f3a0 | /ashell.cpp | 9c9e2934cddb84afd9603de3c0255e97bed4e7da | [] | no_license | hmzkht/shell | 4ffb32ace1f7acd4b328b3e810cc05edbd37d2ef | dac72d39ceada8e29d710ad4d865f14a2ec72335 | refs/heads/master | 2021-01-23T06:44:29.483084 | 2017-03-27T23:30:36 | 2017-03-27T23:30:36 | 86,393,806 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,888 | cpp | #include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <termios.h>
#include <ctype.h>
#include <errno.h>
#include <dirent.h>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
void ResetCanonicalMode(int fd, struct termios *savedattributes){
tcsetattr(fd, TCSANOW, savedattributes);
}
void SetNonCanonicalMode(int fd, struct termios *savedattributes){
struct termios TermAttributes;
// Make sure stdin is a terminal.
if(!isatty(fd)){
fprintf (stderr, "Not a terminal.\n");
exit(0);
}
// Save the terminal attributes so we can restore them later.
tcgetattr(fd, savedattributes);
// Set the funny terminal modes.
tcgetattr (fd, &TermAttributes);
TermAttributes.c_lflag &= ~(ICANON | ECHO); // Clear ICANON and ECHO.
TermAttributes.c_cc[VMIN] = 1;
TermAttributes.c_cc[VTIME] = 0;
tcsetattr(fd, TCSAFLUSH, &TermAttributes);
}
int get_size(char * str){
int size = 0;
int i = 0;
while(str[i] != '\0'){
size++;
i++;
}
return size;
}
void history()
{
}
void cd()
{
}
void pwd(){
char * curr_directory = get_current_dir_name();
write(STDOUT_FILENO, curr_directory, get_size(curr_directory));
write(STDOUT_FILENO, "\n", 1);
}
void ls(char *path)
{
DIR *dir = opendir(path);
struct stat perms;
if(dir) {
struct dirent *dirInfo;
while((dirInfo = readdir(dir)) != NULL)
{
stat(dirInfo->d_name, &perms);
//check each permission individually
if(S_ISDIR(perms.st_mode))
write(STDOUT_FILENO, "d", 1);
else
write(STDOUT_FILENO, "-", 1);
//user permissions
if(S_IRUSR & perms.st_mode)
write(STDOUT_FILENO, "r", 1);
else
write(STDOUT_FILENO, "-", 1);
if(S_IWUSR & perms.st_mode)
write(STDOUT_FILENO, "w", 1);
else
write(STDOUT_FILENO, "-", 1);
if(S_IXUSR & perms.st_mode)
write(STDOUT_FILENO, "x", 1);
else
write(STDOUT_FILENO, "-", 1);
//group permissions
if(S_IRGRP & perms.st_mode)
write(STDOUT_FILENO, "r", 1);
else
write(STDOUT_FILENO, "-", 1);
if(S_IWGRP & perms.st_mode)
write(STDOUT_FILENO, "w", 1);
else
write(STDOUT_FILENO, "-", 1);
if(S_IXGRP & perms.st_mode)
write(STDOUT_FILENO, "x", 1);
else
write(STDOUT_FILENO, "-", 1);
//other permissions
if(S_IROTH & perms.st_mode)
write(STDOUT_FILENO, "r", 1);
else
write(STDOUT_FILENO, "-", 1);
if(S_IWOTH & perms.st_mode)
write(STDOUT_FILENO, "w", 1);
else
write(STDOUT_FILENO, "-", 1);
if(S_IXOTH & perms.st_mode)
write(STDOUT_FILENO, "x", 1);
else
write(STDOUT_FILENO, "-", 1);
write(STDOUT_FILENO, " ", 1);
write(STDOUT_FILENO, dirInfo->d_name, get_size(dirInfo->d_name));
write(STDOUT_FILENO, "\n", 1);
}
}
return;
}
void clearString(char string[], int len)
{
for(int i = 0; i < len; i++)
string[i] = 0;
}
class histQ {
public:
char hist[10][256];
int numHist;
histQ() {
numHist = 0;
for(int i = 0; i < 10; i++)
clearString(hist[i], 256);
}
void enqueue(char *cmd) {
if(numHist == 10) {
for(int i = 0; i < 9; i++) {
strcpy(hist[i], hist[i+1]);
}
strcpy(hist[9], cmd);
}
else {
strcpy(hist[numHist], cmd);
numHist++;
}
}
void showAll() {
char num[1];
for(int i = 0; i < numHist; i++) {
num[0] = '0' + i;
write(STDOUT_FILENO, num, 1);
write(STDOUT_FILENO, " ", 1);
write(STDOUT_FILENO, hist[i], get_size(hist[i]));
write(STDOUT_FILENO, "\n", 1);
}
}
char* getHist(int index) {
return hist[index];
}
};
void parse(char *data, histQ history)
{
int argCount = 0;
char args[16][256];
char currArg[256];
int currArgC = 0;
for(int i = 0; i < 16; i++)
clearString(args[i], 256);
for(int i = 0; i < get_size(data)+1; i++) {
if(data[i] == ' ') { //space
strcpy(args[argCount], currArg);
argCount++;
clearString(currArg, 256);
currArgC = 0;
}
else if(data[i] == '\000') { //end of data
strcpy(args[argCount], currArg);
argCount++;
clearString(currArg, 256);
currArgC = 0;
}
else if(data[i] == '>') { //input redirect
strcpy(args[argCount], currArg);
argCount++;
strcpy(args[argCount], ">");
argCount++;
clearString(currArg, 256);
currArgC = 0;
//redirect stuff
}
else if(data[i] == '<') { //output redirect
strcpy(args[argCount], currArg);
argCount++;
strcpy(args[argCount], "<");
argCount++;
clearString(currArg, 256);
currArgC = 0;
//redirect stuff
}
else if(data[i] == '|') { //pipe
strcpy(args[argCount], currArg);
argCount++;
strcpy(args[argCount], "|");
argCount++;
clearString(currArg, 256);
currArgC = 0;
//redirect stuff
}
else { //build currArg
currArg[currArgC] = data[i];
currArgC++;
}
}
if(strcmp(args[0], "ls") == 0) {
if(args[1][0] != '\0')
ls(args[1]);
else
ls(".");
}
else if(strcmp(args[0], "pwd") == 0) {
pwd();
}
else if(strcmp(args[0], "exit") == 0) {
exit(1);
}
else if(strcmp(args[0], "history") == 0) {
history.showAll();
}
}
int main(int argc, char *argv[])
{
struct termios SavedTermAttributes;
SetNonCanonicalMode(STDIN_FILENO, &SavedTermAttributes);
char data[256];
clearString(data, 256);
int dataCount = 0;
char RXchar;
char cmdChar[5];
histQ history;
int histNum = 0;
int histIndex = 0;
while(true)
{
char * curr_directory = get_current_dir_name();
write(STDOUT_FILENO, curr_directory, get_size(curr_directory));
write(STDOUT_FILENO, ">", 1);
histIndex = histNum;
while(1)
{
clearString(cmdChar, 5);
read(STDIN_FILENO, &RXchar, 1);
if(RXchar == 0x1B) //up, down, delete
{
read(STDIN_FILENO, &cmdChar, 5);
if(cmdChar[1] == 0x41) //up
{
if(histIndex == 0) {
write(STDOUT_FILENO, "\a", 1);
}
else {
while(dataCount != 0) {
write(STDOUT_FILENO, "\b \b", 3);
dataCount--;
}
clearString(data, 256);
histIndex--;
strcpy(data, history.getHist(histIndex));
write(STDOUT_FILENO, data, get_size(data));
dataCount = get_size(data);
continue;
}
}
else if(cmdChar[1] == 0x42) //down
{
if(histIndex >= 9) {
write(STDOUT_FILENO, "\a", 1);
}
else {
while(dataCount != 0) {
write(STDOUT_FILENO, "\b \b", 3);
dataCount--;
}
clearString(data, 256);
histIndex++;
strcpy(data, history.getHist(histIndex));
write(STDOUT_FILENO, data, get_size(data));
dataCount = get_size(data);
continue;
}
}
else if(cmdChar[1] == 0x33) //delete
{
if(dataCount > 0)
{
write(STDOUT_FILENO, "\b \b", 3);
dataCount--;
}
else
continue;
}
else
continue;
}
else if(RXchar == 0x7F) //backspace
{
if(dataCount > 0)
{
write(STDOUT_FILENO, "\b \b", 3);
dataCount--;
}
else
continue;
}
else if(RXchar == 0x0A) //enter
{
write(STDOUT_FILENO, "\n", 1);
data[dataCount] = '\0';
history.enqueue(data);
if(histNum < 10)
histNum++;
parse(data, history);
clearString(data, dataCount+1);
dataCount = 0;
break;
}
else //alphanumeric
{
data[dataCount] = RXchar;
dataCount++;
write(STDOUT_FILENO, &RXchar, 1);
}
}
//write(STDOUT_FILENO, "\n", 1);
}
ResetCanonicalMode(STDIN_FILENO, &SavedTermAttributes);
} | [
"noreply@github.com"
] | noreply@github.com |
fee1c67c57317c3c6a094410d4c943c1b759184c | 1a51e3e3ca7bc7151181b85ecaf896cee4aa37d6 | /thirdparties/boost/boost/mpl/set/set30_c.hpp | 990980e236990ff44e5163afd325155a9b6ed3e0 | [] | no_license | jingjing54007/mmo | f04f0c9db1cbc0c15664c476aba4fc193d91e9e9 | 3a48a719c87bc6b3557130873ae39115cca93cc0 | refs/heads/master | 2021-01-19T19:59:53.737222 | 2014-02-05T16:50:42 | 2014-02-05T16:50:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,235 | hpp |
#ifndef BOOST_MPL_SET_SET30_C_HPP_INCLUDED
#define BOOST_MPL_SET_SET30_C_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id: set30_c.hpp 49239 2008-10-10 09:10:26Z agurtovoy $
// $Date: 2008-10-10 18:10:26 +0900 (금, 10 10 2008) $
// $Revision: 49239 $
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
# include <boost/mpl/set/set20_c.hpp>
# include <boost/mpl/set/set30.hpp>
#endif
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
# define BOOST_MPL_PREPROCESSED_HEADER set30_c.hpp
# include <boost/mpl/set/aux_/include_preprocessed.hpp>
#else
# include <boost/preprocessor/iterate.hpp>
namespace boost { namespace mpl {
# define BOOST_PP_ITERATION_PARAMS_1 \
(3,(21, 30, <boost/mpl/set/aux_/numbered_c.hpp>))
# include BOOST_PP_ITERATE()
}}
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#endif // BOOST_MPL_SET_SET30_C_HPP_INCLUDED
| [
"gasbank@bluehole.net"
] | gasbank@bluehole.net |
efca09414f3d468e9bacd75ea12ff8e3cf6dd5a1 | ab1c643f224197ca8c44ebd562953f0984df321e | /wmi/wbem/providers/snmpprovider/common/sclcomm/reg.cpp | 869e83b5d8fa047cd5f258dbaa280c73cd810ce0 | [] | no_license | KernelPanic-OpenSource/Win2K3_NT_admin | e162e0452fb2067f0675745f2273d5c569798709 | d36e522f16bd866384bec440517f954a1a5c4a4d | refs/heads/master | 2023-04-12T13:25:45.807158 | 2021-04-13T16:33:59 | 2021-04-13T16:33:59 | 357,613,696 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,612 | cpp | //***************************************************************************
//
// File:
//
// Module: MS SNMP Provider
//
// Purpose:
//
// Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
//
//***************************************************************************
/*---------------------------------------------------------
Filename: reg.cpp
Written By: B.Rajeev
----------------------------------------------------------*/
#include "precomp.h"
#include "common.h"
#include "sync.h"
#include "message.h"
#include "dummy.h"
#include "reg.h"
#include "idmap.h"
#include "vblist.h"
#include "sec.h"
#include "pdu.h"
#include "flow.h"
#include "frame.h"
#include "timer.h"
#include "ssent.h"
#include "opreg.h"
#include "session.h"
RequestId MessageRegistry::next_request_id = 1 ;
RequestId MessageRegistry::GenerateRequestId(
IN WaitingMessage &waiting_message)
{
RequestId request_id = next_request_id++;
if (next_request_id == ILLEGAL_REQUEST_ID)
next_request_id++;
mapping[request_id] = &waiting_message;
return request_id;
}
// used by the event handler to notify the message registry
// of a message receipt
// it must receive the message and notify the concerned
// waiting message of the event
void MessageRegistry::MessageArrivalNotification(IN SnmpPdu &snmp_pdu)
{
// determine the concerned waiting message and pass it the SnmpPdu
RequestId request_id ;
session->m_EncodeDecode.GetRequestId(snmp_pdu,request_id);
// if failed, return, as there is no use going any further
if ( request_id == ILLEGAL_REQUEST_ID )
return;
WaitingMessage *waiting_message;
BOOL found = mapping.Lookup(request_id, waiting_message);
// if no such waiting message, return
if ( !found )
return;
// check if still waiting for the SentFrameEvent on
// this waiting message
SessionFrameId session_frame_id = waiting_message->GetMessage()->GetSessionFrameId();
// if not waiting for the sent frame event
// let the waiting message receive the reply
// else buffer the snmp pdu
if ( waiting_message->GetSentMessageProcessed() == TRUE )
waiting_message->ReceiveReply(&snmp_pdu);
else
waiting_message->BufferReply(snmp_pdu);
}
// delete (request_id, waiting_message) pair
void MessageRegistry::RemoveMessage(IN RequestId request_id)
{
if ( !mapping.RemoveKey(request_id) )
throw GeneralException(Snmp_Error, Snmp_Local_Error,__FILE__,__LINE__);
}
MessageRegistry::~MessageRegistry(void)
{
mapping.RemoveAll();
}
| [
"polarisdp@gmail.com"
] | polarisdp@gmail.com |
fb435bd4be8fa09c2ce0d6d3cdd99d6438b2990a | 187b10c2db9a3b8d68178eacf74824ae2ab4896e | /FK2DEngine/demo/Demo1/Main.cpp | 4168a9a132b1d4f59bc8305ee4f2ec695de645d4 | [] | no_license | PubFork/FKEngine | 0eb61c02038bc64e9c157fb8c792e4e29796dc1f | 1c81a2b3be19d818f6f1d950ffcef205349652f4 | refs/heads/master | 2020-04-29T03:04:22.293325 | 2015-11-28T07:53:32 | 2015-11-28T07:53:32 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 8,304 | cpp | /********************************************************************
*
* 本文件是FKMMORPG的一部分。本文件版权归属FreeKnightDuzhi(王宏张)所有。
* E-mail: duzhi5368@163.com
* QQ: 281862942
*
* -----------------------------------------------------------------
*
* 文件名: Main
* 作者: FreeKnightDuzhi[ 王宏张 ]
* 文件说明:
*
* 修改人:
* 修改内容:
*********************************************************************/
#include "../../interface/FKEngineInclude.h"
//--------------------------------------------------------------------
//#ifdef NDEBUG
//#pragma comment(lib, "FK2DEngine.lib")
//#else
//#pragma comment(lib, "FK2DEngine_D.lib")
//#endif
//--------------------------------------------------------------------
#include "../../../depend/boost/scoped_ptr.hpp"
#include "../../../depend/boost/shared_ptr.hpp"
#include "../../../depend/boost/lexical_cast.hpp"
#include <cmath>
#include <cstdlib>
#include <list>
#include <vector>
//--------------------------------------------------------------------
enum ENUM_ZOrder
{
eZ_Backgroud,
eZ_Stars,
eZ_Player,
eZ_UI,
};
//--------------------------------------------------------------------
typedef std::vector< boost::shared_ptr< FK2DEngine::CImage > > Animation;
//--------------------------------------------------------------------
class CStar
{
private:
Animation* m_pAnimation;
FK2DEngine::CColor m_pColor;
double m_dPosX;
double m_dPosY;
public:
explicit CStar( Animation& p_Anim )
{
m_pAnimation = &p_Anim;
m_pColor.SetAlpha( 255 );
double dRed = FK2DEngine::Random( 40, 255 );
m_pColor.SetRed( static_cast< FK2DEngine::CColor::Channel >( dRed ) );
double dGreen = FK2DEngine::Random( 40, 255 );
m_pColor.SetGreen( static_cast< FK2DEngine::CColor::Channel >( dGreen ) );
double dBlue = FK2DEngine::Random( 40, 255 );
m_pColor.SetBlue( static_cast< FK2DEngine::CColor::Channel >( dBlue ) );
m_dPosX = FK2DEngine::Random( 0, 640 );
m_dPosY = FK2DEngine::Random( 0, 640 );
}
double X() const
{
return m_dPosX;
}
double Y() const
{
return m_dPosY;
}
void FKDraw() const
{
FK2DEngine::CImage& img = *m_pAnimation->at( FK2DEngine::MilliSeconds() / 100 % m_pAnimation->size() );
img.FKDraw( m_dPosX - img.Width() / 2.0, m_dPosY - img.Height() / 2.0,
eZ_Stars, 1, 1, m_pColor, FK2DEngine::EAM_Additive );
}
};
//--------------------------------------------------------------------
class CPlayer
{
private:
boost::scoped_ptr< FK2DEngine::CImage > m_pImg;
boost::scoped_ptr< FK2DEngine::CFKSample > m_pBeep;
double m_dPosX;
double m_dPosY;
double m_dVelX;
double m_dVelY;
double m_dAngel;
unsigned int m_unScore;
public:
CPlayer( FK2DEngine::CGraphics& p_Graphics, FK2DEngine::CAudio& p_Audio )
{
std::wstring szFileName = FK2DEngine::ShareResourcePrefix() + L"rc/media/Starfighter.bmp";
m_pImg.reset( new FK2DEngine::CImage( p_Graphics, szFileName ) );
szFileName = FK2DEngine::ShareResourcePrefix() + L"rc/media/Beep.wav";
m_pBeep.reset( new FK2DEngine::CFKSample( p_Audio, szFileName ) );
m_dPosX = m_dPosY = m_dVelX = m_dVelY = m_dAngel = 0;
m_unScore = 0;
}
unsigned int GetScore() const
{
return m_unScore;
}
void Warp( double p_dX, double p_dY )
{
m_dPosX = p_dX;
m_dPosY = p_dY;
}
void TurnLeft()
{
m_dAngel -= 4.5;
}
void TurnRight()
{
m_dAngel += 4.5;
}
void Accelerate()
{
m_dVelX += FK2DEngine::OffsetX( m_dAngel, 0.5 );
m_dVelY += FK2DEngine::OffsetY( m_dAngel, 0.5 );
}
void Move()
{
m_dPosX += m_dVelX;
while( m_dPosX < 0 )
{
m_dPosX += 640;
}
while( m_dPosX > 640 )
{
m_dPosX -= 640;
}
m_dPosY += m_dVelY;
while( m_dPosY < 0 )
{
m_dPosY += 480;
}
while( m_dPosY > 480 )
{
m_dPosY -= 480;
}
m_dVelX *= 0.95;
m_dVelY *= 0.95;
}
void FKDraw() const
{
m_pImg->DrawRot( m_dPosX, m_dPosY, eZ_Player, m_dAngel );
}
void CollectStars( std::list<CStar>& p_Stars )
{
std::list<CStar>::iterator IteCur = p_Stars.begin();
while( IteCur != p_Stars.end() )
{
if( FK2DEngine::Distance( m_dPosX, m_dPosY, IteCur->X(), IteCur->Y() ) < 35 )
{
IteCur = p_Stars.erase( IteCur );
m_unScore += 10;
m_pBeep->Play();
}
else
{
++IteCur;
}
}
}
};
//--------------------------------------------------------------------
class CGameWindow : public FK2DEngine::CFKWindow
{
private:
boost::scoped_ptr< FK2DEngine::CImage > m_pBackgroundImage;
Animation m_StarAnim;
CPlayer m_Player;
std::list<CStar> m_Stars;
FK2DEngine::CFont m_Font;
CBitmap m_pCursorBitmap;
int m_nFps;
int m_nLastFps;
public:
CGameWindow()
: CFKWindow( 640,480,false )
, m_Player( Graphics(), Audio() )
, m_Font( Graphics(), FK2DEngine::DefaultFontName(), 24 )
, m_nFps( 0 )
, m_nLastFps( 0 )
{
SetCaption( L"自由骑士笃志引擎:DEMO1" );
std::wstring szFileName = FK2DEngine::ShareResourcePrefix() + L"rc/media/Space.png";
m_pBackgroundImage.reset( new FK2DEngine::CImage( Graphics(), szFileName, false ) );
szFileName = FK2DEngine::ShareResourcePrefix() + L"rc/media/Star.png";
FK2DEngine::ImagesFromTiledBitmap( Graphics(), szFileName, 25, 25, false, m_StarAnim );
m_Player.Warp( 320, 240 );
//szFileName = FK2DEngine::ShareResourcePrefix() + L"avgRc\\Attack.cur";
//SetNewCursor( szFileName );
szFileName = FK2DEngine::ShareResourcePrefix() + L"avgRc\\AnimCursor.bmp";
m_pCursorBitmap = LoadImageFile( szFileName );
SSAnimationCursorManager::Instance()->AddCursor( m_pCursorBitmap, L"默认鼠标", 32, 32 );
SSAnimationCursorManager::Instance()->SetAnimCursor( L"默认鼠标" );
SSAnimationCursorManager::Instance()->Enable( true );
}
void Update( float p_fDelta )
{
if( Input().Down( FK2DEngine::EKB_Left ) || Input().Down( FK2DEngine::GP_Left ) )
{
m_Player.TurnLeft();
}
if( Input().Down( FK2DEngine::EKB_Right ) || Input().Down( FK2DEngine::GP_Right ) )
{
m_Player.TurnRight();
}
if( Input().Down( FK2DEngine::EKB_Up ) || Input().Down( FK2DEngine::GP_Button0 ) )
{
m_Player.Accelerate();
}
m_Player.Move();
m_Player.CollectStars( m_Stars );
if( std::rand() % 25 == 0 && m_Stars.size() < 25 )
{
m_Stars.push_back( CStar(m_StarAnim) );
}
m_nFps = FK2DEngine::GetFPS();
}
void FKDraw()
{
m_Player.FKDraw();
m_pBackgroundImage->FKDraw( 0, 0, eZ_Backgroud );
for( std::list<CStar>::const_iterator i = m_Stars.begin();
i != m_Stars.end(); ++i )
{
i->FKDraw();
}
if( m_nLastFps != m_nFps )
{
m_nLastFps = m_nFps;
}
m_Font.FKDraw(L"FPS:" + boost::lexical_cast< std::wstring >( m_nLastFps ), 510, 10, eZ_UI, 1, 1, FK2DEngine::CColor::BLUE );
m_Font.FKDraw( L"得分:" + boost::lexical_cast< std::wstring >( m_Player.GetScore()),
10, 10, eZ_UI, 1, 1, FK2DEngine::CColor::YELLOW );
}
void KeyDown( FK2DEngine::CKey p_Key )
{
if( p_Key == FK2DEngine::EKB_Escape )
{
Close();
}
else if( p_Key == FK2DEngine::EKB_PrintScreen )
{
PrintScreen( FK2DEngine::ShareResourcePrefix() + L"Screen\\" + ToString( GetTime() ) + L".bmp" );
}
}
bool OnClose()
{
if( MessageBox( NULL, L"确定退出吗?", L"提示", MB_OKCANCEL | MB_ICONINFORMATION ) == IDOK )
{
return true;
}
return false;
}
};
//--------------------------------------------------------------------
// 开启CRT检查
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include<stdlib.h>
#include<crtdbg.h>
#define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
#endif
//--------------------------------------------------------------------
int main( int p_nArgc, char* p_Argv[] )
{
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
_CrtSetBreakAlloc( 717 );
try
{
CGameWindow window;
window.Show();
}
catch( ... )
{
throw;
}
_CrtDumpMemoryLeaks();
}
//-------------------------------------------------------------------- | [
"duzhi5368@163.com"
] | duzhi5368@163.com |
568f2cadbca311d6a5788036d2b2c1d9924c8720 | 1fb0cf3f8244c69e985104ecea2fd0a7809fc5ee | /tempCodeRunnerFile.cpp | f52992ae3b33a4a42d11420c3df4d5a994cb3b10 | [] | no_license | seyurlutchminarain/Sorting-Searching | 7a53ecbaf24ef3946930d2d816ee59017a1cb1e7 | 720440d848d3fc8512c27121699a548748f05c3c | refs/heads/main | 2023-08-17T11:48:09.289890 | 2021-09-12T09:15:03 | 2021-09-12T09:15:03 | 405,595,860 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 164 | cpp | int N , key;
cout << "Enter length of list:" << endl;
cin >> N;
vector<int> inputs = genInput(N);
printList(inputs);
return 0; | [
"noreply@github.com"
] | noreply@github.com |
3a7b095924e0daba2a5d73957a9852b79373d094 | 683ad3085736d8febd869a0a0484241728143ca3 | /Proxy/CommunicationProxy.cpp | 25e7ef5350b2c3ffe9888c05d10185091b53ac0d | [] | no_license | sraaphorst/design-patterns-in-cpp | 14f1774cfc0faa7c9a5ec981c4807c1736922bd2 | 7bf7e1147072062bb83a036d0011d919fbb0ff7e | refs/heads/master | 2022-12-10T07:35:38.300344 | 2019-12-30T13:13:40 | 2019-12-30T13:13:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 420 | cpp | #include <iostream>
#include <string>
struct Pingable {
virtual std::wstring ping(const std::wstring &message) = 0;
};
struct Pong : Pingable {
std::wstring ping(const std::wstring &message) override {
return message + L" pong";
}
};
void tryit(Pingable &p) {
std::wcout << p.ping(L"ping") << std::endl;
}
int main() {
Pong pong;
for (size_t i = 0; i < 3; ++i)
tryit(pong);
} | [
"sraaphorst@gemini.edu"
] | sraaphorst@gemini.edu |
9151dee0a187d561942587149e5814606b8fae9c | 7df578885d6377d6ab17109dc327549c3e698b6c | /Linked List/Union of Two Linked Lists.cpp | d018681d4b411773d88bff99682adb8434ae80d8 | [] | no_license | jainamandelhi/Geeks-For-Geeks-Solutions | b102dc8801760f2723e3c0783ebd134853f988d2 | 1851f3ab38ddde85b14c13a7834f5391e9780e65 | refs/heads/master | 2020-03-24T06:45:30.783081 | 2019-08-17T13:55:47 | 2019-08-17T13:55:47 | 142,540,641 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 739 | cpp | struct node* makeUnion(struct node* head1, struct node* head2)
{
vector<int>v;
while(head1)
{
v.push_back(head1->data);
head1=head1->next;
}
while(head2)
{
v.push_back(head2->data);
head2=head2->next;
}
sort(v.begin(),v.end());
map<int,int>m;
node *root=NULL, *temp;
for(int i=0;i<v.size();i++)
{
if(m[v[i]])
continue;
m[v[i]]++;
node *temp3=new node;
temp3->data=v[i];
temp3->next=NULL;
if(root==NULL)
{
root=temp3;
temp=root;
}
else
{
temp->next=temp3;
temp=temp3;
}
}
return root;
// code here
}
| [
"jainamandelhi@gmail.com"
] | jainamandelhi@gmail.com |
cef99192d721af138ba8cb3962175faa7881b6ce | bb7645bab64acc5bc93429a6cdf43e1638237980 | /Official Windows Platform Sample/Windows 8.1 desktop samples/99647-Windows 8.1 desktop samples/Input Method Editor (IME) sample/C++/SampleIME/SampleIME.h | 5d04a1843ec42a65059b556b973f52de15aca3bf | [
"MIT"
] | permissive | Violet26/msdn-code-gallery-microsoft | 3b1d9cfb494dc06b0bd3d509b6b4762eae2e2312 | df0f5129fa839a6de8f0f7f7397a8b290c60ffbb | refs/heads/master | 2020-12-02T02:00:48.716941 | 2020-01-05T22:39:02 | 2020-01-05T22:39:02 | 230,851,047 | 1 | 0 | MIT | 2019-12-30T05:06:00 | 2019-12-30T05:05:59 | null | UTF-8 | C++ | false | false | 11,248 | h | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved
#pragma once
#include "KeyHandlerEditSession.h"
#include "SampleIMEBaseStructure.h"
class CLangBarItemButton;
class CCandidateListUIPresenter;
class CCompositionProcessorEngine;
const DWORD WM_CheckGlobalCompartment = WM_USER;
LRESULT CALLBACK CSampleIME_WindowProc(HWND wndHandle, UINT uMsg, WPARAM wParam, LPARAM lParam);
class CSampleIME : public ITfTextInputProcessorEx,
public ITfThreadMgrEventSink,
public ITfTextEditSink,
public ITfKeyEventSink,
public ITfCompositionSink,
public ITfDisplayAttributeProvider,
public ITfActiveLanguageProfileNotifySink,
public ITfThreadFocusSink,
public ITfFunctionProvider,
public ITfFnGetPreferredTouchKeyboardLayout
{
public:
CSampleIME();
~CSampleIME();
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, _Outptr_ void **ppvObj);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
// ITfTextInputProcessor
STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId) {
return ActivateEx(pThreadMgr, tfClientId, 0);
}
// ITfTextInputProcessorEx
STDMETHODIMP ActivateEx(ITfThreadMgr *pThreadMgr, TfClientId tfClientId, DWORD dwFlags);
STDMETHODIMP Deactivate();
// ITfThreadMgrEventSink
STDMETHODIMP OnInitDocumentMgr(_In_ ITfDocumentMgr *pDocMgr);
STDMETHODIMP OnUninitDocumentMgr(_In_ ITfDocumentMgr *pDocMgr);
STDMETHODIMP OnSetFocus(_In_ ITfDocumentMgr *pDocMgrFocus, _In_ ITfDocumentMgr *pDocMgrPrevFocus);
STDMETHODIMP OnPushContext(_In_ ITfContext *pContext);
STDMETHODIMP OnPopContext(_In_ ITfContext *pContext);
// ITfTextEditSink
STDMETHODIMP OnEndEdit(__RPC__in_opt ITfContext *pContext, TfEditCookie ecReadOnly, __RPC__in_opt ITfEditRecord *pEditRecord);
// ITfKeyEventSink
STDMETHODIMP OnSetFocus(BOOL fForeground);
STDMETHODIMP OnTestKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pIsEaten);
STDMETHODIMP OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pIsEaten);
STDMETHODIMP OnTestKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pIsEaten);
STDMETHODIMP OnKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pIsEaten);
STDMETHODIMP OnPreservedKey(ITfContext *pContext, REFGUID rguid, BOOL *pIsEaten);
// ITfCompositionSink
STDMETHODIMP OnCompositionTerminated(TfEditCookie ecWrite, _In_ ITfComposition *pComposition);
// ITfDisplayAttributeProvider
STDMETHODIMP EnumDisplayAttributeInfo(__RPC__deref_out_opt IEnumTfDisplayAttributeInfo **ppEnum);
STDMETHODIMP GetDisplayAttributeInfo(__RPC__in REFGUID guidInfo, __RPC__deref_out_opt ITfDisplayAttributeInfo **ppInfo);
// ITfActiveLanguageProfileNotifySink
STDMETHODIMP OnActivated(_In_ REFCLSID clsid, _In_ REFGUID guidProfile, _In_ BOOL isActivated);
// ITfThreadFocusSink
STDMETHODIMP OnSetThreadFocus();
STDMETHODIMP OnKillThreadFocus();
// ITfFunctionProvider
STDMETHODIMP GetType(__RPC__out GUID *pguid);
STDMETHODIMP GetDescription(__RPC__deref_out_opt BSTR *pbstrDesc);
STDMETHODIMP GetFunction(__RPC__in REFGUID rguid, __RPC__in REFIID riid, __RPC__deref_out_opt IUnknown **ppunk);
// ITfFunction
STDMETHODIMP GetDisplayName(_Out_ BSTR *pbstrDisplayName);
// ITfFnGetPreferredTouchKeyboardLayout, it is the Optimized layout feature.
STDMETHODIMP GetLayout(_Out_ TKBLayoutType *ptkblayoutType, _Out_ WORD *pwPreferredLayoutId);
// CClassFactory factory callback
static HRESULT CreateInstance(_In_ IUnknown *pUnkOuter, REFIID riid, _Outptr_ void **ppvObj);
// utility function for thread manager.
ITfThreadMgr* _GetThreadMgr() { return _pThreadMgr; }
TfClientId _GetClientId() { return _tfClientId; }
// functions for the composition object.
void _SetComposition(_In_ ITfComposition *pComposition);
void _TerminateComposition(TfEditCookie ec, _In_ ITfContext *pContext, BOOL isCalledFromDeactivate = FALSE);
void _SaveCompositionContext(_In_ ITfContext *pContext);
// key event handlers for composition/candidate/phrase common objects.
HRESULT _HandleComplete(TfEditCookie ec, _In_ ITfContext *pContext);
HRESULT _HandleCancel(TfEditCookie ec, _In_ ITfContext *pContext);
// key event handlers for composition object.
HRESULT _HandleCompositionInput(TfEditCookie ec, _In_ ITfContext *pContext, WCHAR wch);
HRESULT _HandleCompositionFinalize(TfEditCookie ec, _In_ ITfContext *pContext, BOOL fCandidateList);
HRESULT _HandleCompositionConvert(TfEditCookie ec, _In_ ITfContext *pContext, BOOL isWildcardSearch);
HRESULT _HandleCompositionBackspace(TfEditCookie ec, _In_ ITfContext *pContext);
HRESULT _HandleCompositionArrowKey(TfEditCookie ec, _In_ ITfContext *pContext, KEYSTROKE_FUNCTION keyFunction);
HRESULT _HandleCompositionPunctuation(TfEditCookie ec, _In_ ITfContext *pContext, WCHAR wch);
HRESULT _HandleCompositionDoubleSingleByte(TfEditCookie ec, _In_ ITfContext *pContext, WCHAR wch);
// key event handlers for candidate object.
HRESULT _HandleCandidateFinalize(TfEditCookie ec, _In_ ITfContext *pContext);
HRESULT _HandleCandidateConvert(TfEditCookie ec, _In_ ITfContext *pContext);
HRESULT _HandleCandidateArrowKey(TfEditCookie ec, _In_ ITfContext *pContext, _In_ KEYSTROKE_FUNCTION keyFunction);
HRESULT _HandleCandidateSelectByNumber(TfEditCookie ec, _In_ ITfContext *pContext, _In_ UINT uCode);
// key event handlers for phrase object.
HRESULT _HandlePhraseFinalize(TfEditCookie ec, _In_ ITfContext *pContext);
HRESULT _HandlePhraseArrowKey(TfEditCookie ec, _In_ ITfContext *pContext, _In_ KEYSTROKE_FUNCTION keyFunction);
HRESULT _HandlePhraseSelectByNumber(TfEditCookie ec, _In_ ITfContext *pContext, _In_ UINT uCode);
BOOL _IsSecureMode(void) { return (_dwActivateFlags & TF_TMAE_SECUREMODE) ? TRUE : FALSE; }
BOOL _IsComLess(void) { return (_dwActivateFlags & TF_TMAE_COMLESS) ? TRUE : FALSE; }
BOOL _IsStoreAppMode(void) { return (_dwActivateFlags & TF_TMF_IMMERSIVEMODE) ? TRUE : FALSE; };
CCompositionProcessorEngine* GetCompositionProcessorEngine() { return (_pCompositionProcessorEngine); };
// comless helpers
static HRESULT CSampleIME::CreateInstance(REFCLSID rclsid, REFIID riid, _Outptr_result_maybenull_ LPVOID* ppv, _Out_opt_ HINSTANCE* phInst, BOOL isComLessMode);
static HRESULT CSampleIME::ComLessCreateInstance(REFGUID rclsid, REFIID riid, _Outptr_result_maybenull_ void **ppv, _Out_opt_ HINSTANCE *phInst);
static HRESULT CSampleIME::GetComModuleName(REFGUID rclsid, _Out_writes_(cchPath)WCHAR* wchPath, DWORD cchPath);
private:
// functions for the composition object.
HRESULT _HandleCompositionInputWorker(_In_ CCompositionProcessorEngine *pCompositionProcessorEngine, TfEditCookie ec, _In_ ITfContext *pContext);
HRESULT _CreateAndStartCandidate(_In_ CCompositionProcessorEngine *pCompositionProcessorEngine, TfEditCookie ec, _In_ ITfContext *pContext);
HRESULT _HandleCandidateWorker(TfEditCookie ec, _In_ ITfContext *pContext);
void _StartComposition(_In_ ITfContext *pContext);
void _EndComposition(_In_opt_ ITfContext *pContext);
BOOL _IsComposing();
BOOL _IsKeyboardDisabled();
HRESULT _AddComposingAndChar(TfEditCookie ec, _In_ ITfContext *pContext, _In_ CStringRange *pstrAddString);
HRESULT _AddCharAndFinalize(TfEditCookie ec, _In_ ITfContext *pContext, _In_ CStringRange *pstrAddString);
BOOL _FindComposingRange(TfEditCookie ec, _In_ ITfContext *pContext, _In_ ITfRange *pSelection, _Outptr_result_maybenull_ ITfRange **ppRange);
HRESULT _SetInputString(TfEditCookie ec, _In_ ITfContext *pContext, _Out_opt_ ITfRange *pRange, _In_ CStringRange *pstrAddString, BOOL exist_composing);
HRESULT _InsertAtSelection(TfEditCookie ec, _In_ ITfContext *pContext, _In_ CStringRange *pstrAddString, _Outptr_ ITfRange **ppCompRange);
HRESULT _RemoveDummyCompositionForComposing(TfEditCookie ec, _In_ ITfComposition *pComposition);
// Invoke key handler edit session
HRESULT _InvokeKeyHandler(_In_ ITfContext *pContext, UINT code, WCHAR wch, DWORD flags, _KEYSTROKE_STATE keyState);
// function for the language property
BOOL _SetCompositionLanguage(TfEditCookie ec, _In_ ITfContext *pContext);
// function for the display attribute
void _ClearCompositionDisplayAttributes(TfEditCookie ec, _In_ ITfContext *pContext);
BOOL _SetCompositionDisplayAttributes(TfEditCookie ec, _In_ ITfContext *pContext, TfGuidAtom gaDisplayAttribute);
BOOL _InitDisplayAttributeGuidAtom();
BOOL _InitThreadMgrEventSink();
void _UninitThreadMgrEventSink();
BOOL _InitTextEditSink(_In_ ITfDocumentMgr *pDocMgr);
void _UpdateLanguageBarOnSetFocus(_In_ ITfDocumentMgr *pDocMgrFocus);
BOOL _InitKeyEventSink();
void _UninitKeyEventSink();
BOOL _InitActiveLanguageProfileNotifySink();
void _UninitActiveLanguageProfileNotifySink();
BOOL _IsKeyEaten(_In_ ITfContext *pContext, UINT codeIn, _Out_ UINT *pCodeOut, _Out_writes_(1) WCHAR *pwch, _Out_opt_ _KEYSTROKE_STATE *pKeyState);
BOOL _IsRangeCovered(TfEditCookie ec, _In_ ITfRange *pRangeTest, _In_ ITfRange *pRangeCover);
VOID _DeleteCandidateList(BOOL fForce, _In_opt_ ITfContext *pContext);
WCHAR ConvertVKey(UINT code);
BOOL _InitThreadFocusSink();
void _UninitThreadFocusSink();
BOOL _InitFunctionProviderSink();
void _UninitFunctionProviderSink();
BOOL _AddTextProcessorEngine();
BOOL VerifySampleIMECLSID(_In_ REFCLSID clsid);
friend LRESULT CALLBACK CSampleIME_WindowProc(HWND wndHandle, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
ITfThreadMgr* _pThreadMgr;
TfClientId _tfClientId;
DWORD _dwActivateFlags;
// The cookie of ThreadMgrEventSink
DWORD _threadMgrEventSinkCookie;
ITfContext* _pTextEditSinkContext;
DWORD _textEditSinkCookie;
// The cookie of ActiveLanguageProfileNotifySink
DWORD _activeLanguageProfileNotifySinkCookie;
// The cookie of ThreadFocusSink
DWORD _dwThreadFocusSinkCookie;
// Composition Processor Engine object.
CCompositionProcessorEngine* _pCompositionProcessorEngine;
// Language bar item object.
CLangBarItemButton* _pLangBarItem;
// the current composition object.
ITfComposition* _pComposition;
// guidatom for the display attibute.
TfGuidAtom _gaDisplayAttributeInput;
TfGuidAtom _gaDisplayAttributeConverted;
CANDIDATE_MODE _candidateMode;
CCandidateListUIPresenter *_pCandidateListUIPresenter;
BOOL _isCandidateWithWildcard : 1;
ITfDocumentMgr* _pDocMgrLastFocused;
ITfContext* _pContext;
ITfCompartment* _pSIPIMEOnOffCompartment;
DWORD _dwSIPIMEOnOffCompartmentSinkCookie;
HWND _msgWndHandle;
LONG _refCount;
// Support the search integration
ITfFnSearchCandidateProvider* _pITfFnSearchCandidateProvider;
};
| [
"v-tiafe@microsoft.com"
] | v-tiafe@microsoft.com |
049ca74a5b44ea31bfbe7430c734433f038c5c1c | 873a38a120108e3c57c97cbd478dc8786adc7199 | /Work/Direct3D 11/Code/Include/DXInputLayout.h | b932bb8364b74b7a80a2cf1ef9bb057dfb8e0294 | [] | no_license | ab316/TrumpSuit | 111106b29b3df2075e71de1b11996f92ff50ffb5 | bd48d3c0489d66fdab1991aa2baf1ff750452883 | refs/heads/master | 2020-12-24T13:28:52.586503 | 2015-07-25T01:31:30 | 2015-07-25T01:31:30 | 39,667,523 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,340 | h | #pragma once
#include "DXResource.h"
namespace DXFramework
{ // DXFramework namespace begin
#define DX_MAX_IL_ELEMENT_NAME 15
class CDXShader;
// An input layout element describes the meaning of a group of bytes
// in a vertex in the vertex buffer. As a single vertex normally contains
// multiple information, multiple elements are required. These elements must be
// arranged in the order in which the corresponding bytes appear in an individual vertex.
struct DXInputLayoutElement
{
DX_FORMAT format;
WCHAR szName[DX_MAX_IL_ELEMENT_NAME];
// For having multiple elements having the same name.
UINT uiIndex;
// Must be zero for now.
UINT uiInputSlot;
};
// Description of an input layout.
struct DXInputLayoutDesc
{
// Since an input layout is closely related to a vertex shader, a vertex
// shader is required to which the input layout will be working with. The input
// semantics of the input layout and the shader must match. Any other vertex
// shader that has the same semantics may also be used with the same input layout.
CDXShader* pVertexShader;
DXInputLayoutElement* pInputElements;
UINT16 uiNumElements;
};
// An Input Layout describes the format of each vertex represented by a
// a vertex buffer. This is necessary to bind the data in the vertex buffer
// to appropriate registers in the Vertex shader. This is done through the
// use of semantics.
class CDXInputLayout : public IDXResource
{
private:
DXInputLayoutDesc m_descInput;
ID3D11InputLayout* m_pInputLayout;
public:
// Internal usage only.
inline ID3D11InputLayout* GetD3DLayout() const { return m_pInputLayout; };
inline virtual const void* GetDesc() const { return (void*)&m_descInput; };
public:
virtual HRESULT Create(void* pDesc);
virtual HRESULT Recreate();
virtual void Destroy();
virtual void Dispose();
virtual size_t GetSize() const { return (size_t)(m_descInput.uiNumElements * sizeof(DXInputLayoutElement)); };
virtual void SetDebugName(char* szName);
public:
virtual DX_RESOURCE_TYPE GetResourceType() const { return DX_RESOURCE_TYPE_INPUT_LAYOUT; };
virtual LPCWSTR GetResourceTypeName() const { return DX_RESOURCE_TYPE_NAME_INPUT_LAYOUT; };
public:
CDXInputLayout();
~CDXInputLayout();
};
} // DXFramework namespace end | [
"abdullahbaig456@gmail.com"
] | abdullahbaig456@gmail.com |
c456692c89d95eacdfa0ebee9733cf81a18dd31d | 9cc2b377d0a8a015a20b50eeeeaf9bf4ab9a7146 | /Source/NGCrypto/src/Encryption/AES.cpp | e54236ee8e80af4a4895353dec69610c78c5b485 | [
"MIT"
] | permissive | gnoailles/Cryptography-Sandbox | b0d914241dee53b737b3f0c9923c34f2b4995c5a | f07aba29b8c5f93e2ff61004f8f8a771d1ab1ee4 | refs/heads/master | 2021-07-20T19:07:11.123606 | 2020-05-03T00:38:42 | 2020-05-03T00:38:42 | 156,033,662 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,907 | cpp | #include "NGCrypto/Encryption/AES.h"
#include <cassert>
#include <Windows.h>
namespace Cryptography
{
namespace Encryption
{
void AES::KeyAssist1(__m128i* p_temp1, __m128i* p_temp2)
{
*p_temp2 = _mm_shuffle_epi32(*p_temp2, 0xff);
__m128i temp4 = _mm_slli_si128(*p_temp1, 0x4);
*p_temp1 = _mm_xor_si128(*p_temp1, temp4);
temp4 = _mm_slli_si128(*p_temp1, 0x4);
*p_temp1 = _mm_xor_si128(*p_temp1, temp4);
temp4 = _mm_slli_si128(*p_temp1, 0x4);
*p_temp1 = _mm_xor_si128(*p_temp1, temp4);
*p_temp1 = _mm_xor_si128(*p_temp1, *p_temp2);
}
void AES::KeyAssist2(__m128i* p_temp1, __m128i* p_temp3)
{
__m128i temp4 = _mm_aeskeygenassist_si128(*p_temp1, 0x0);
const __m128i temp2 = _mm_shuffle_epi32(temp4, 0xaa);
temp4 = _mm_slli_si128(*p_temp3, 0x4);
*p_temp3 = _mm_xor_si128(*p_temp3, temp4);
temp4 = _mm_slli_si128(*p_temp3, 0x4);
*p_temp3 = _mm_xor_si128(*p_temp3, temp4);
temp4 = _mm_slli_si128(*p_temp3, 0x4);
*p_temp3 = _mm_xor_si128(*p_temp3, temp4);
*p_temp3 = _mm_xor_si128(*p_temp3, temp2);
}
void AES::GenerateEncryptionRoundKeys()
{
__m128i temp1 = cipherKey[0];
__m128i temp3 = cipherKey[1];
encryptionRoundKeys[0] = temp1;
encryptionRoundKeys[1] = temp3;
__m128i temp2 = _mm_aeskeygenassist_si128(temp3, 0x01);
KeyAssist1(&temp1, &temp2);
encryptionRoundKeys[2] = temp1;
KeyAssist2(&temp1, &temp3);
encryptionRoundKeys[3] = temp3;
temp2 = _mm_aeskeygenassist_si128(temp3, 0x02);
KeyAssist1(&temp1, &temp2);
encryptionRoundKeys[4] = temp1;
KeyAssist2(&temp1, &temp3);
encryptionRoundKeys[5] = temp3;
temp2 = _mm_aeskeygenassist_si128(temp3, 0x04);
KeyAssist1(&temp1, &temp2);
encryptionRoundKeys[6] = temp1;
KeyAssist2(&temp1, &temp3);
encryptionRoundKeys[7] = temp3;
temp2 = _mm_aeskeygenassist_si128(temp3, 0x08);
KeyAssist1(&temp1, &temp2);
encryptionRoundKeys[8] = temp1;
KeyAssist2(&temp1, &temp3);
encryptionRoundKeys[9] = temp3;
temp2 = _mm_aeskeygenassist_si128(temp3, 0x10);
KeyAssist1(&temp1, &temp2);
encryptionRoundKeys[10] = temp1;
KeyAssist2(&temp1, &temp3);
encryptionRoundKeys[11] = temp3;
temp2 = _mm_aeskeygenassist_si128(temp3, 0x20);
KeyAssist1(&temp1, &temp2);
encryptionRoundKeys[12] = temp1;
KeyAssist2(&temp1, &temp3);
encryptionRoundKeys[13] = temp3;
temp2 = _mm_aeskeygenassist_si128(temp3, 0x40);
KeyAssist1(&temp1, &temp2);
encryptionRoundKeys[14] = temp1;
}
void AES::GenerateDecryptionRoundKeys()
{
decryptionRoundKeys[0] = encryptionRoundKeys[ROUND_COUNT];
for (int i = 1; i < ROUND_COUNT; ++i)
{
decryptionRoundKeys[i] = _mm_aesimc_si128(encryptionRoundKeys[ROUND_COUNT - i]);
}
decryptionRoundKeys[ROUND_COUNT] = encryptionRoundKeys[0];
}
AES::AES(const unsigned char p_cipherKey[64])
{
assert(IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE));
cipherKey[0] = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p_cipherKey));
cipherKey[1] = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p_cipherKey + 16));
GenerateEncryptionRoundKeys();
GenerateDecryptionRoundKeys();
}
void AES::EncryptECB(const unsigned char* p_data, unsigned char* p_out, uint64_t p_dataLength)
{
if(p_dataLength % 16)
p_dataLength = p_dataLength / 16 + 1;
else
p_dataLength = p_dataLength / 16;
for(uint32_t i = 0; i < p_dataLength; ++i)
{
__m128i temp = _mm_loadu_si128(&(reinterpret_cast<const __m128i*>(p_data))[i]);
temp = _mm_xor_si128(temp, encryptionRoundKeys[0]);
for(int j = 1; j < ROUND_COUNT; j++)
{
temp = _mm_aesenc_si128(temp, encryptionRoundKeys[j]);
}
temp = _mm_aesenclast_si128(temp, encryptionRoundKeys[ROUND_COUNT]);
_mm_storeu_si128(&(reinterpret_cast<__m128i*>(p_out))[i], temp);
}
}
void AES::DecryptECB(const unsigned char* p_data, unsigned char* p_out, uint64_t p_dataLength)
{
if(p_dataLength % 16)
p_dataLength = p_dataLength / 16 + 1;
else
p_dataLength = p_dataLength / 16;
for(uint32_t i = 0; i < p_dataLength; ++i)
{
__m128i temp = _mm_loadu_si128(&(reinterpret_cast<const __m128i*>(p_data))[i]);
temp = _mm_xor_si128(temp, decryptionRoundKeys[0]);
for(int j = 1; j < ROUND_COUNT; j++)
{
temp = _mm_aesdec_si128(temp, decryptionRoundKeys[j]);
}
temp = _mm_aesdeclast_si128(temp, decryptionRoundKeys[ROUND_COUNT]);
_mm_storeu_si128(&(reinterpret_cast<__m128i*>(p_out))[i], temp);
}
}
void AES::EncryptCBC(const unsigned char* p_data, unsigned char* p_out, uint64_t p_dataLength)
{
}
void AES::DecryptCBC(const unsigned char* p_data, unsigned char* p_out, uint64_t p_dataLength)
{
}
}
}
| [
"noailles.guillaume123@gmail.com"
] | noailles.guillaume123@gmail.com |
2690ec8e44a13c6b05acd9ca8a9a7f3bd42d369c | 937c4003450364206412b7523dde2f8ec70f3dc6 | /Example/main.cpp | 84cef0b71d4b977f503d9eb418f7b4c6827835ea | [
"MIT"
] | permissive | kovacsv/TinyCppTest | 6d5dcf62350691ef629d81db14e6dcd271dd8b1c | 12e42c8ac6e032ce450fb3f772ebdfd1ddc6008c | refs/heads/main | 2023-07-27T14:49:48.182587 | 2021-09-05T16:36:19 | 2021-09-05T16:36:19 | 378,099,713 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 288 | cpp | #include "TinyCppTest.hpp"
int main (int, char* argv[])
{
std::string executablePath (argv[0]);
std::wstring wExecutablePath (executablePath.begin (), executablePath.end ());
TinyCppTest::SetAppLocation (wExecutablePath);
if (!TinyCppTest::RunTests ()) {
return 1;
}
return 0;
}
| [
"viktorkovacs@gmail.com"
] | viktorkovacs@gmail.com |
7fd6f1edb82e7bee54565d86c93efbf529913c0f | c40d9a22f6a60f80be4945f424456cb787e24528 | /Game of Life/game_controller.cpp | 13f3c443f9e127ece777b5cfd75c931826472cd7 | [
"MIT"
] | permissive | sbogolepov/nsu_oop_cpp | 21dfbcb16bae2648c2494115692008a94a727641 | 137717513132261809faec6c56881ac6425cb306 | refs/heads/master | 2021-05-28T22:01:24.336839 | 2015-04-20T13:34:05 | 2015-04-20T13:34:05 | 34,261,619 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,296 | cpp | //
// game_controller.cpp
// Game of Life
//
// Created by Sergey Bogolepov on 10/20/14.
// Copyright (c) 2014 Sergey Bogolepov. All rights reserved.
//
#include "game_controller.h"
void GameController::run() {
if (iterations > -1) {
_tick(iterations);
try {
_dump(output_filename);
} catch (std::ofstream::failure e) {
view->show_message("Error writing to file");
}
return;
}
// Main cycle
std::string input;
do {
// Welcome message for input. Move it to another place
// Reading message from terminal.
// It's better to refactor InputHanlder and make it part of framework
// New amazing MIVC (Model-Input-View-Controller) pattern!
input_handler.parse_input();
switch (input_handler.get_current_command()) {
case InputHandler::Command::HELP:
view->show_message(Strings::help_ingame());
break;
case InputHandler::Command::TICK:
_tick(input_handler.get_tick_count());
view->show();
break;
case InputHandler::Command::PLAY: {
auto times = input_handler.get_tick_count();
for (int i = 0; i < times; i++) {
_tick(1);
view->show();
}
break;
}
case InputHandler::Command::DUMP:
try {
_dump(input_handler.get_output_file());
} catch (std::ofstream::failure e) {
view->show_message("Error writing to file");
}
break;
case InputHandler::Command::EXIT:
view->show_message("Bye! :(");
return;
// Do i need it?
case InputHandler::Command::SETTINGS:
view->show_message("Come back later");
break;
default:
break;
}
} while (true); // while(1)? O RLY?
}
void GameController::_tick(int steps) {
for (int i = 0; i < steps; i++) {
model->update();
}
}
void GameController::_dump(std::string name) {
FileCreator creator(name);
creator.set_name(game_name);
creator.set_rules(model->get_needed_to_born(), model->get_needed_to_live());
creator.set_points(get_field(), get_field_size());
creator.save_changes();
}
void GameController::set_points(std::vector<std::pair<int, int>> points) {
model->set_field(points);
}
void GameController::set_field_size(int size) {
model->set_field_size(size);
}
void GameController::set_needed_to_born(std::vector<int> arg) {
model->set_needed_to_born(arg);
}
void GameController::set_needed_to_live(std::vector<int> arg) {
model->set_needed_to_live(arg);
}
void GameController::set_iterations(int count) {
if (count >= 0) {
iterations = count;
}
}
void GameController::set_name(std::string name) {
game_name = name;
}
void GameController::set_output_file(std::string name) {
output_filename = name;
}
int GameController::get_field_size() {
return model->get_field_size();
}
bool** GameController::get_field() {
return model->get_field();
}
| [
"aceisnotmycard@icloud.com"
] | aceisnotmycard@icloud.com |
92289ad36194c1e11b9da364d2b70d94d629d7d4 | 7d31c76454801b52d8275a45f04d4adc92104869 | /src/htm/_htm_s2circle_htmcov.hxx | 7fcc7c6a624830b172e9d736fafe6a5e2cfdbe3b | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | Caltech-IPAC/libtinyhtm | 412ea240fef82068922c81236118ecf476092912 | e98b604d628f839f68956957dde2d38edda1429d | refs/heads/master | 2023-07-26T07:54:02.592017 | 2022-06-09T00:50:35 | 2022-07-27T17:43:47 | 32,607,831 | 1 | 0 | NOASSERTION | 2022-07-27T17:43:48 | 2015-03-20T21:24:04 | C++ | UTF-8 | C++ | false | false | 172 | hxx | #pragma once
#include "htm.hxx"
enum _htm_cov _htm_s2circle_htmcov (const struct _htm_node *n,
const struct htm_v3 *c, double dist2);
| [
"wlandry@caltech.edu"
] | wlandry@caltech.edu |
012a41d4cbc331fb32752114c2231bd0782604eb | dc85dd2bbce94dc06b00b9d91d56d717bb353e0b | /A2.cpp | 5809ea705bb5ded7a0b806d18bc7be87a77304c1 | [] | no_license | arshomashohag/UVA- | b5bab8dd4231819299ff27ef1bdb61b89d5a9e48 | 522af80128e538386eb933c33216e5d315ce7747 | refs/heads/master | 2020-03-07T09:33:31.937669 | 2018-03-30T09:48:10 | 2018-03-30T09:48:10 | 127,410,812 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,589 | cpp | #include<cstdio>
#include<iostream>
#include<cstring>
#include<cctype>
#include<utility>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#define LL long long int
using namespace std;
int n_of_player_a[102]={0},n_of_player_b[102]={0};
int i,j,t,num,cnt,minit,p_n;
char name_a[100],name_b[100],ch,team,card;
int main(void)
{
scanf("%[^\n]",name_a);
getchar();
scanf("%[^\n]",name_b);
scanf("%d",&num);
while(num--)
{
scanf("%d %c %d %c",&t,&team,&p_n,&card);
if(team=='h')
{
if(card=='y')
{
if(n_of_player_a[p_n]>=0)
n_of_player_a[p_n]++;
if(n_of_player_a[p_n]==2)
{
printf("%s %d %d\n",name_a,p_n,t);
n_of_player_a[p_n]=-100;
}
}
else if(card=='r' && n_of_player_a[p_n]!=-100 )
{
printf("%s %d %d\n",name_a,p_n,t);
n_of_player_a[p_n]=-100;
}
}
else if(team=='a')
{
if(card=='y')
{
if(n_of_player_b[p_n]>=0)
n_of_player_b[p_n]++;
if(n_of_player_b[p_n]==2)
{
printf("%s %d %d\n",name_b,p_n,t);
n_of_player_b[p_n]=-100;
}
}
else if(card=='r' && n_of_player_b[p_n]!=-100)
{
printf("%s %d %d\n",name_b,p_n,t);
n_of_player_b[p_n]=-100;
}
}
}
return 0;
}
| [
"shohag_92_ru@yahoo.com"
] | shohag_92_ru@yahoo.com |
48767dafc881a32c6bb43d58f3d2bd1fe4c867bf | 51635684d03e47ebad12b8872ff469b83f36aa52 | /external/gcc-12.1.0/libstdc++-v3/testsuite/abi/demangle/abi_examples/19.cc | 56b39dc3f54f4444e8fdb571d0ea703ebba323db | [
"LGPL-2.1-only",
"GPL-3.0-only",
"GCC-exception-3.1",
"GPL-2.0-only",
"LGPL-3.0-only",
"LGPL-2.0-or-later",
"Zlib",
"LicenseRef-scancode-public-domain"
] | permissive | zhmu/ananas | 8fb48ddfe3582f85ff39184fc7a3c58725fe731a | 30850c1639f03bccbfb2f2b03361792cc8fae52e | refs/heads/master | 2022-06-25T10:44:46.256604 | 2022-06-12T17:04:40 | 2022-06-12T17:04:40 | 30,108,381 | 59 | 8 | Zlib | 2021-09-26T17:30:30 | 2015-01-31T09:44:33 | C | UTF-8 | C++ | false | false | 1,140 | cc | // 2003-02-26 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2003-2022 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// IA 64 C++ ABI - 5.1 External Names (a.k.a. Mangling)
#include <testsuite_hooks.h>
// Examples given in the IA64 C++ ABI
// http://www.codesourcery.com/cxx-abi/abi-examples.html#mangling
int main()
{
using namespace __gnu_test;
verify_demangle("_Z1fI1XEvPVN1AIT_E1TE", "void f<X>(A<X>::T volatile*)");
return 0;
}
| [
"rink@rink.nu"
] | rink@rink.nu |
779ea7de3eb973ca40f4bf922c446fbc51d3cffc | 9eac178f236ee09463e3a0180072002b5195a0da | /cosc1337/Source Files/chapters/ch7_intro_classes_and_objects/7_11_focus_on_sw_eng/Rectangle.h | fdd1d599b0e04cdf16948cae33d752ed101c0eec | [] | no_license | rzuniga64/cplusplus | 3cb1c7d40b6429b61a79a7246e54becb4960d2a6 | 1a2d08d15c462a675d0d9a3ec3f5cb0fc155a01b | refs/heads/master | 2021-01-18T23:30:54.320423 | 2016-11-19T08:57:43 | 2016-11-19T08:57:43 | 15,234,467 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 341 | h | // Rectangle.h is the Rectangle class specification file.
#ifndef RECTANGLE_H
#define RECTANGLE_H
// Rectangle class declaration
class Rectangle
{
private:
double length;
double width;
public:
bool setLength(double);
bool setWidth(double);
double getLength();
double getWidth();
double getArea();
};
#endif
| [
"rzuniga64@gmail.com"
] | rzuniga64@gmail.com |
9e2ea29fa2069ac7f1a39aa57ebc8900dd55537a | 8010df1fef10ddfd83bf07966cbf7e2e4b0d7ee9 | /include/winsdk/um/RemoteSystemsInterop.h | d21bd3a965cea20aa7d28222e4474f2ec4d3afcf | [] | no_license | light-tech/MSCpp | a23ab987b7e12329ab2d418b06b6b8055bde5ca2 | 012631b58c402ceec73c73d2bda443078bc151ef | refs/heads/master | 2022-12-26T23:51:21.686396 | 2020-10-15T13:40:34 | 2020-10-15T13:40:34 | 188,921,341 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,292 | h |
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 500
#endif
/* verify that the <rpcsal.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCSAL_H_VERSION__
#define __REQUIRED_RPCSAL_H_VERSION__ 100
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif /* __RPCNDR_H_VERSION__ */
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/
#ifndef __remotesystemsinterop_h__
#define __remotesystemsinterop_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
#ifndef __ICorrelationVectorInformation_FWD_DEFINED__
#define __ICorrelationVectorInformation_FWD_DEFINED__
typedef interface ICorrelationVectorInformation ICorrelationVectorInformation;
#endif /* __ICorrelationVectorInformation_FWD_DEFINED__ */
/* header files for imported files */
#include "unknwn.h"
#include "Inspectable.h"
#ifdef __cplusplus
extern "C"{
#endif
/* interface __MIDL_itf_remotesystemsinterop_0000_0000 */
/* [local] */
#include <winapifamily.h>
#if (NTDDI_VERSION >= NTDDI_WIN10_VB)
#pragma region Application Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
extern RPC_IF_HANDLE __MIDL_itf_remotesystemsinterop_0000_0000_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_remotesystemsinterop_0000_0000_v0_0_s_ifspec;
#ifndef __ICorrelationVectorInformation_INTERFACE_DEFINED__
#define __ICorrelationVectorInformation_INTERFACE_DEFINED__
/* interface ICorrelationVectorInformation */
/* [local][object][uuid] */
EXTERN_C const IID IID_ICorrelationVectorInformation;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("83C78B3C-D88B-4950-AA6E-22B8D22AABD3")
ICorrelationVectorInformation : public IInspectable
{
public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_LastCorrelationVectorForThread(
/* [retval][out] */ HSTRING *cv) = 0;
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_NextCorrelationVectorForThread(
/* [retval][out] */ HSTRING *cv) = 0;
virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_NextCorrelationVectorForThread(
/* [in] */ HSTRING cv) = 0;
};
#else /* C style interface */
typedef struct ICorrelationVectorInformationVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
ICorrelationVectorInformation * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
ICorrelationVectorInformation * This);
ULONG ( STDMETHODCALLTYPE *Release )(
ICorrelationVectorInformation * This);
HRESULT ( STDMETHODCALLTYPE *GetIids )(
ICorrelationVectorInformation * This,
/* [out] */ ULONG *iidCount,
/* [size_is][size_is][out] */ IID **iids);
HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )(
ICorrelationVectorInformation * This,
/* [out] */ HSTRING *className);
HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )(
ICorrelationVectorInformation * This,
/* [out] */ TrustLevel *trustLevel);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_LastCorrelationVectorForThread )(
ICorrelationVectorInformation * This,
/* [retval][out] */ HSTRING *cv);
/* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_NextCorrelationVectorForThread )(
ICorrelationVectorInformation * This,
/* [retval][out] */ HSTRING *cv);
/* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_NextCorrelationVectorForThread )(
ICorrelationVectorInformation * This,
/* [in] */ HSTRING cv);
END_INTERFACE
} ICorrelationVectorInformationVtbl;
interface ICorrelationVectorInformation
{
CONST_VTBL struct ICorrelationVectorInformationVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define ICorrelationVectorInformation_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define ICorrelationVectorInformation_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define ICorrelationVectorInformation_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define ICorrelationVectorInformation_GetIids(This,iidCount,iids) \
( (This)->lpVtbl -> GetIids(This,iidCount,iids) )
#define ICorrelationVectorInformation_GetRuntimeClassName(This,className) \
( (This)->lpVtbl -> GetRuntimeClassName(This,className) )
#define ICorrelationVectorInformation_GetTrustLevel(This,trustLevel) \
( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) )
#define ICorrelationVectorInformation_get_LastCorrelationVectorForThread(This,cv) \
( (This)->lpVtbl -> get_LastCorrelationVectorForThread(This,cv) )
#define ICorrelationVectorInformation_get_NextCorrelationVectorForThread(This,cv) \
( (This)->lpVtbl -> get_NextCorrelationVectorForThread(This,cv) )
#define ICorrelationVectorInformation_put_NextCorrelationVectorForThread(This,cv) \
( (This)->lpVtbl -> put_NextCorrelationVectorForThread(This,cv) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __ICorrelationVectorInformation_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_remotesystemsinterop_0000_0001 */
/* [local] */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
#pragma endregion
#endif /* (NTDDI_VERSION >= NTDDI_WIN10_VB) */
extern RPC_IF_HANDLE __MIDL_itf_remotesystemsinterop_0000_0001_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_remotesystemsinterop_0000_0001_v0_0_s_ifspec;
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
| [
"lightech@outlook.com"
] | lightech@outlook.com |
b6bbf62a9f8f9045587b0e5426b963ec656320a4 | a5f3b0001cdb692aeffc444a16f79a0c4422b9d0 | /main/svgio/source/svgreader/svgclippathnode.cxx | e04855cd596ed16fbfd71bddea4b759315cad45e | [
"Apache-2.0",
"CPL-1.0",
"bzip2-1.0.6",
"LicenseRef-scancode-other-permissive",
"Zlib",
"LZMA-exception",
"LGPL-2.0-or-later",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-philippe-de-muyter",
"OFL-1.1",
"LGPL-2.1-only",
"MPL-1.1",
"X11",
"LGPL-2.1-or-later",
"GPL-2.0-only",
... | permissive | apache/openoffice | b9518e36d784898c6c2ea3ebd44458a5e47825bb | 681286523c50f34f13f05f7b87ce0c70e28295de | refs/heads/trunk | 2023-08-30T15:25:48.357535 | 2023-08-28T19:50:26 | 2023-08-28T19:50:26 | 14,357,669 | 907 | 379 | Apache-2.0 | 2023-08-16T20:49:37 | 2013-11-13T08:00:13 | C++ | WINDOWS-1250 | C++ | false | false | 11,722 | cxx | /**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svgio.hxx"
#include <svgio/svgreader/svgclippathnode.hxx>
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <drawinglayer/geometry/viewinformation2d.hxx>
#include <drawinglayer/processor2d/contourextractor2d.hxx>
#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
//////////////////////////////////////////////////////////////////////////////
namespace svgio
{
namespace svgreader
{
SvgClipPathNode::SvgClipPathNode(
SvgDocument& rDocument,
SvgNode* pParent)
: SvgNode(SVGTokenClipPathNode, rDocument, pParent),
maSvgStyleAttributes(*this),
mpaTransform(0),
maClipPathUnits(userSpaceOnUse)
{
}
SvgClipPathNode::~SvgClipPathNode()
{
if(mpaTransform) delete mpaTransform;
}
const SvgStyleAttributes* SvgClipPathNode::getSvgStyleAttributes() const
{
return &maSvgStyleAttributes;
}
void SvgClipPathNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent)
{
// call parent
SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
// read style attributes
maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
// parse own
switch(aSVGToken)
{
case SVGTokenStyle:
{
readLocalCssStyle(aContent);
break;
}
case SVGTokenTransform:
{
const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
if(!aMatrix.isIdentity())
{
setTransform(&aMatrix);
}
break;
}
case SVGTokenClipPathUnits:
{
if(aContent.getLength())
{
if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0))
{
setClipPathUnits(userSpaceOnUse);
}
else if(aContent.match(commonStrings::aStrObjectBoundingBox, 0))
{
setClipPathUnits(objectBoundingBox);
}
}
break;
}
default:
{
break;
}
}
}
void SvgClipPathNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const
{
drawinglayer::primitive2d::Primitive2DSequence aNewTarget;
// decompose childs
SvgNode::decomposeSvgNode(aNewTarget, bReferenced);
if(aNewTarget.hasElements())
{
if(getTransform())
{
// create embedding group element with transformation
const drawinglayer::primitive2d::Primitive2DReference xRef(
new drawinglayer::primitive2d::TransformPrimitive2D(
*getTransform(),
aNewTarget));
drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(rTarget, xRef);
}
else
{
// append to current target
drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aNewTarget);
}
}
}
void SvgClipPathNode::apply(
drawinglayer::primitive2d::Primitive2DSequence& rContent,
const basegfx::B2DHomMatrix* pTransform) const
{
if(rContent.hasElements() && Display_none != getDisplay())
{
const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
drawinglayer::primitive2d::Primitive2DSequence aClipTarget;
basegfx::B2DPolyPolygon aClipPolyPolygon;
// get clipPath definition as primitives
decomposeSvgNode(aClipTarget, true);
if(aClipTarget.hasElements())
{
// extract filled plygons as base for a mask PolyPolygon
drawinglayer::processor2d::ContourExtractor2D aExtractor(aViewInformation2D, true);
aExtractor.process(aClipTarget);
const basegfx::B2DPolyPolygonVector& rResult(aExtractor.getExtractedContour());
const sal_uInt32 nSize(rResult.size());
if(nSize > 1)
{
// merge to single clipPolyPolygon
aClipPolyPolygon = basegfx::tools::mergeToSinglePolyPolygon(rResult);
}
else
{
aClipPolyPolygon = rResult[0];
}
}
if(aClipPolyPolygon.count())
{
if(objectBoundingBox == getClipPathUnits())
{
// clip is object-relative, transform using content transformation
const basegfx::B2DRange aContentRange(
drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(
rContent,
aViewInformation2D));
aClipPolyPolygon.transform(
basegfx::tools::createScaleTranslateB2DHomMatrix(
aContentRange.getRange(),
aContentRange.getMinimum()));
}
else // userSpaceOnUse
{
// #i124852#
if(pTransform)
{
aClipPolyPolygon.transform(*pTransform);
}
}
// #124313# try to avoid creating an embedding to a MaskPrimitive2D if
// possible; MaskPrimitive2D processing is potentially expensive
bool bCreateEmbedding(true);
bool bAddContent(true);
if(basegfx::tools::isRectangle(aClipPolyPolygon))
{
// ClipRegion is a rectangle, thus it is not expensive to tell
// if the content is completely inside or outside of it; get ranges
const basegfx::B2DRange aClipRange(aClipPolyPolygon.getB2DRange());
const basegfx::B2DRange aContentRange(
drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(
rContent,
aViewInformation2D));
if(aClipRange.isInside(aContentRange))
{
// completely contained, no need to clip at all, so no need for embedding
bCreateEmbedding = false;
}
else if(aClipRange.overlaps(aContentRange))
{
// overlap; embedding needed. ClipRegion can be minimized by using
// the intersection of the ClipRange and the ContentRange. Minimizing
// the ClipRegion potentially enhances further processing since
// usually clip operations are expensive.
basegfx::B2DRange aCommonRange(aContentRange);
aCommonRange.intersect(aClipRange);
aClipPolyPolygon = basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aCommonRange));
}
else
{
// not inside and no overlap -> completely outside
// no need for embedding, no need for content at all
bCreateEmbedding = false;
bAddContent = false;
}
}
else
{
// ClipRegion is not a simple rectangle, it would be possible but expensive to
// tell if the content needs clipping or not. It is also dependent of
// the content's decomposition. To do this, a processor would be needed that
// is capable if processing the given sequence of primitives and decide
// if all is inside or all is outside. Such a ClipProcessor could be written,
// but for now just create the embedding
}
if(bCreateEmbedding)
{
// redefine target. Use MaskPrimitive2D with created clip
// geometry. Using the automatically set mbIsClipPathContent at
// SvgStyleAttributes the clip definition is without fill, stroke,
// and strokeWidth and forced to black
const drawinglayer::primitive2d::Primitive2DReference xEmbedTransparence(
new drawinglayer::primitive2d::MaskPrimitive2D(
aClipPolyPolygon,
rContent));
rContent = drawinglayer::primitive2d::Primitive2DSequence(&xEmbedTransparence, 1);
}
else
{
if(!bAddContent)
{
rContent.realloc(0);
}
}
}
else
{
// An empty clipping path will completely clip away the element that had
// the ‘clip-path’ property applied. (Svg spec)
rContent.realloc(0);
}
}
}
} // end of namespace svgreader
} // end of namespace svgio
//////////////////////////////////////////////////////////////////////////////
// eof
| [
"alg@apache.org"
] | alg@apache.org |
ee8fd5a48191ecc4069d5c0da0df55797758ebf0 | 64e4fabf9b43b6b02b14b9df7e1751732b30ad38 | /src/chromium/gen/gen_combined/third_party/blink/public/mojom/web_feature/web_feature.mojom-test-utils.h | 4b49992da5c411748a2780595c1a66e9bc535818 | [
"BSD-3-Clause"
] | permissive | ivan-kits/skia-opengl-emscripten | 8a5ee0eab0214c84df3cd7eef37c8ba54acb045e | 79573e1ee794061bdcfd88cacdb75243eff5f6f0 | refs/heads/master | 2023-02-03T16:39:20.556706 | 2020-12-25T14:00:49 | 2020-12-25T14:00:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 614 | h | // Copyright 2019 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 THIRD_PARTY_BLINK_PUBLIC_MOJOM_WEB_FEATURE_WEB_FEATURE_MOJOM_TEST_UTILS_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_WEB_FEATURE_WEB_FEATURE_MOJOM_TEST_UTILS_H_
#include "third_party/blink/public/mojom/web_feature/web_feature.mojom.h"
#include "base/component_export.h"
namespace blink {
namespace mojom {
} // namespace mojom
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_MOJOM_WEB_FEATURE_WEB_FEATURE_MOJOM_TEST_UTILS_H_ | [
"trofimov_d_a@magnit.ru"
] | trofimov_d_a@magnit.ru |
29da82d7201e18265e786bf1bc2c4c018b4e1209 | c2fb6846d5b932928854cfd194d95c79c723f04c | /1st_and_2nd_Sem_c_backup/BIN/C++ algorithms coursera/ab.cpp | 01d3383ad154c07dcc2fd13c2e2ebb242ae4ff26 | [
"MIT"
] | permissive | Jimut123/code-backup | ef90ccec9fb6483bb6dae0aa6a1f1cc2b8802d59 | 8d4c16b9e960d352a7775786ea60290b29b30143 | refs/heads/master | 2022-12-07T04:10:59.604922 | 2021-04-28T10:22:19 | 2021-04-28T10:22:19 | 156,666,404 | 9 | 5 | MIT | 2022-12-02T20:27:22 | 2018-11-08T07:22:48 | Jupyter Notebook | UTF-8 | C++ | false | false | 157 | cpp | #include <iostream>
int main(){
int a = 5;
int b = 5;
int sum = 0;
std::cin >> a;
std::cin >> b;
sum = a + b;
std::cout << sum;
return 0;
}
| [
"jimutbahanpal@yahoo.com"
] | jimutbahanpal@yahoo.com |
10fed1c0d78be14e26f95b129e723f27ee094232 | b4393b82bcccc59e2b89636f1fde16d82f060736 | /include/polarphp/utils/TarWriter.h | 6cc063e07190f2f1ec74c978e17b088a9c173396 | [] | no_license | phpmvc/polarphp | abb63ed491a0175aa43c873b1b39811f4eb070a2 | eb0b406e515dd550fd99b9383d4b2952fed0bfa9 | refs/heads/master | 2020-04-08T06:51:03.842159 | 2018-11-23T06:32:04 | 2018-11-23T06:32:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,177 | h | // This source file is part of the polarphp.org open source project
//
// Copyright (c) 2017 - 2018 polarphp software foundation
// Copyright (c) 2017 - 2018 zzu_softboy <zzu_softboy@163.com>
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://polarphp.org/LICENSE.txt for license information
// See http://polarphp.org/CONTRIBUTORS.txt for the list of polarphp project authors
//
// Created by softboy on 2018/07/15.
#ifndef POLARPHP_UTILS_TAR_WRITER_H
#define POLARPHP_UTILS_TAR_WRITER_H
#include "polarphp/basic/adt/StringRef.h"
#include "polarphp/basic/adt/StringSet.h"
#include "polarphp/utils/Error.h"
#include "polarphp/utils/RawOutStream.h"
namespace polar {
namespace utils {
using polar::basic::StringSet;
class TarWriter {
public:
static Expected<std::unique_ptr<TarWriter>> create(StringRef outputPath,
StringRef baseDir);
void append(StringRef path, StringRef data);
private:
TarWriter(int fd, StringRef baseDir);
RawFdOutStream m_outstream;
std::string m_baseDir;
StringSet<> m_files;
};
} // utils
} // polar
#endif // POLARPHP_UTILS_TAR_WRITER_H
| [
"zzu_softboy@163.com"
] | zzu_softboy@163.com |
881ef2be874d6a705eb9028cf275e26ac53d211b | 678188df0515150405d557bf676566b24bea6e7b | /app/src/main/cpp/src/LookGenerator.cpp | f7b99c4a3fedc648fbc8610439b614e87af3f2ac | [] | no_license | thaiwu0107/merror3 | 68120b6b4ceab68460f58c9098c653e4651a159d | 2db379ed931917a183859ea6a305017ef6a2cebd | refs/heads/master | 2021-03-30T18:13:02.012614 | 2017-09-28T03:14:29 | 2017-09-28T03:14:29 | 102,334,357 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,475 | cpp | //
// DemoSDK
// Copyright © 2016 ModiFace Inc. All rights reserved.
//
#include "LookGenerator.hpp"
#include "MFELiveMakeup/Models/Masks/BlushMask.h"
#include "MFELiveMakeup/Models/Masks/LipLinerMask.h"
#include "MFELiveMakeup/Models/Masks/BrowMask.h"
#include "MFELiveMakeup/Models/Masks/EyeLinerMask.h"
#include "MFELiveMakeup/Models/Masks/FoundationMask.h"
#include "MFELiveMakeup/Models/Masks/LipstickMask.h"
#include "MFELiveMakeup/Models/Masks/EyeEraseMask.h"
#include "MFELiveMakeup/Models/Masks/EyeShadowMask.h"
#include "DemoOverlayMask.hpp"
LookGenerator::LookGenerator(std::string assetPath) {
mAssetPath = assetPath + (assetPath.back() == '/' ? "" : "/");
}
MFE::MakeupLook LookGenerator::generateMakeupLook(const AppliedMakeup &appliedMakeup) {
MFE::MakeupLook look;
//todo 自己客製化的範例 需要新增很多臉部位子判斷等等 etc....以後再說了
// DemoOverlayMaskPtr overlayMask = std::make_shared<DemoOverlayMask>();
// MFE::MakeupActionDrawOverlayPtr drawOverlay = std::make_shared<MFE::MakeupActionDrawOverlay>();
// drawOverlay->mask = overlayMask;
// drawOverlay->overlayImagePath = pathForResource("/Overlay/demo_overlay.png");
// MFE::MakeupProcedureOverlayPtr overlay = std::make_shared<MFE::MakeupProcedureOverlay>();
// overlay->name = "Overlay";
// overlay->actions.push_back(drawOverlay);
// look.procedures.push_back(overlay);
if (appliedMakeup.foundation) {
MFE::MakeupProcedurePtr foundation = createFoundationProcedure(appliedMakeup.foundation.product);
look.procedures.push_back(foundation);
}
if (appliedMakeup.blush) {
MFE::MakeupProcedurePtr blush = createBlushProcedure(appliedMakeup.blush.product, appliedMakeup.blush.style);
look.procedures.push_back(blush);
}
if (appliedMakeup.lipstick) {
MFE::MakeupProcedurePtr lipstick = createLipstickProcedure(appliedMakeup.lipstick.product);
look.procedures.push_back(lipstick);
}
if (appliedMakeup.lipLiner) {
MFE::MakeupProcedurePtr lipLiner = createLipLinerProcedure(appliedMakeup.lipLiner.product);
look.procedures.push_back(lipLiner);
}
if (appliedMakeup.brow) {
MFE::MakeupProcedurePtr browRecolour = createBrowRecolourProcedure(appliedMakeup.brow.product);
look.procedures.push_back(browRecolour);
}
if (appliedMakeup.lidShadow || appliedMakeup.creaseShadow || appliedMakeup.highlightShadow) {
MFE::MakeupProcedurePtr eyeShadows = createEyeShadowsProcedure(appliedMakeup.lidShadow.product, appliedMakeup.creaseShadow.product, appliedMakeup.highlightShadow.product);
look.procedures.push_back(eyeShadows);
}
if (appliedMakeup.eyeLiner) {
MFE::MakeupProcedurePtr eyeLiner = createEyeLinerProcedure(appliedMakeup.eyeLiner.product, appliedMakeup.eyeLiner.style);
look.procedures.push_back(eyeLiner);
}
if (appliedMakeup.mascara) {
MFE::MakeupProcedurePtr lash = createLashProcedure(appliedMakeup.mascara.product, appliedMakeup.mascara.style);
look.procedures.push_back(lash);
}
return look;
}
std::string LookGenerator::pathForResource(std::string name) {
return mAssetPath + name;
}
MFE::MakeupProcedurePtr LookGenerator::createBlushProcedure(MFE::MakeupProduct product, AppliedMakeup::BlushStyle style) {
std::string blushMaskFilename;
switch (style) {
case AppliedMakeup::BlushStyle::DiagonalBlurUp: blushMaskFilename = "ml_msk_blush_1.png"; break;
case AppliedMakeup::BlushStyle::DiagonalBlurDown: blushMaskFilename = "ml_msk_blush_2.png"; break;
case AppliedMakeup::BlushStyle::Circular: blushMaskFilename = "ml_msk_blush_3.png"; break;
case AppliedMakeup::BlushStyle::Diagonal: blushMaskFilename = "ml_msk_blush_4.png"; break;
default: break;
}
MFE::BlushMaskPtr leftDrawMask = std::make_shared<MFE::BlushMask>();
leftDrawMask->staticMaskFilename = pathForResource("Masks/Blush/" + blushMaskFilename);
leftDrawMask->side = MFE::MakeupMask::Side::Left;
MFE::BlushMaskPtr rightDrawMask = std::make_shared<MFE::BlushMask>(*leftDrawMask);
rightDrawMask->side = MFE::MakeupMask::Side::Right;
rightDrawMask->isStaticMaskHorizontallyFlipped = true;
MFE::BlushMaskPtr leftEraseMask = std::make_shared<MFE::BlushMask>();
leftEraseMask->staticMaskFilename = pathForResource("Masks/Subtract/blush_drop_4_sub_left.png");
leftEraseMask->side = MFE::MakeupMask::Side::Left;
leftEraseMask->isSubtractMask = true;
MFE::BlushMaskPtr rightEraseMask = std::make_shared<MFE::BlushMask>(*leftEraseMask);
rightEraseMask->side = MFE::MakeupMask::Side::Right;
rightEraseMask->isStaticMaskHorizontallyFlipped = true;
MFE::MakeupActionDrawMakeupPtr drawLeftBlush = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawLeftBlush->mask = leftDrawMask;
drawLeftBlush->product = product;
MFE::MakeupActionDrawMakeupPtr drawRightBlush = std::make_shared<MFE::MakeupActionDrawMakeup>(*drawLeftBlush);
drawRightBlush->mask = rightDrawMask;
MFE::MakeupActionErasePtr eraseLeftBlush = std::make_shared<MFE::MakeupActionErase>();
eraseLeftBlush->mask = leftEraseMask;
MFE::MakeupActionErasePtr eraseRightBlush = std::make_shared<MFE::MakeupActionErase>(*eraseLeftBlush);
eraseRightBlush->mask = rightEraseMask;
MFE::MakeupProcedureGeneralPtr blushProcedure = std::make_shared<MFE::MakeupProcedureGeneral>();
blushProcedure->name = "Blush";
blushProcedure->actions.push_back(drawLeftBlush);
blushProcedure->actions.push_back(drawRightBlush);
blushProcedure->actions.push_back(eraseLeftBlush);
blushProcedure->actions.push_back(eraseRightBlush);
return blushProcedure;
}
MFE::MakeupProcedurePtr LookGenerator::createLipLinerProcedure(MFE::MakeupProduct product) {
MFE::LipLinerMaskPtr lipLinerMask = std::make_shared<MFE::LipLinerMask>();
MFE::MakeupActionDrawMakeupPtr drawLiner = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawLiner->mask = lipLinerMask;
drawLiner->product = product;
MFE::MakeupProcedureGeneralPtr lipLinerProcedure = std::make_shared<MFE::MakeupProcedureGeneral>();
lipLinerProcedure->name = "Lip Liner";
lipLinerProcedure->actions.push_back(drawLiner);
return lipLinerProcedure;
}
MFE::MakeupProcedurePtr LookGenerator::createBrowRecolourProcedure(MFE::MakeupProduct product) {
MFE::BrowMaskPtr leftBrowMask = std::make_shared<MFE::BrowMask>();
leftBrowMask->side = MFE::BrowMask::Side::Left;
MFE::BrowMaskPtr rightBrowMask = std::make_shared<MFE::BrowMask>();
rightBrowMask->side = MFE::BrowMask::Side::Right;
MFE::MakeupActionDrawMakeupPtr drawBrowLeft = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawBrowLeft->mask = leftBrowMask;
drawBrowLeft->product = product;
MFE::MakeupActionDrawMakeupPtr drawBrowRight = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawBrowRight->mask = rightBrowMask;
drawBrowRight->product = product;
MFE::MakeupProcedureBrowRecolourPtr browRecolourProcedure = std::make_shared<MFE::MakeupProcedureBrowRecolour>();
browRecolourProcedure->name = "Brow";
browRecolourProcedure->actions.push_back(drawBrowLeft);
browRecolourProcedure->actions.push_back(drawBrowRight);
return browRecolourProcedure;
}
MFE::MakeupProcedurePtr LookGenerator::createEyeLinerProcedure(MFE::MakeupProduct product, AppliedMakeup::EyeLinerStyle style) {
MFE::EyeLinerMask::LinerStyle linerStyle = MFE::EyeLinerMask::LinerStyle::Natural;
switch (style) {
case AppliedMakeup::EyeLinerStyle::Top: linerStyle = MFE::EyeLinerMask::LinerStyle::Natural; break;
case AppliedMakeup::EyeLinerStyle::Full: linerStyle = MFE::EyeLinerMask::LinerStyle::Full; break;
case AppliedMakeup::EyeLinerStyle::Natural: linerStyle = MFE::EyeLinerMask::LinerStyle::Natural; break;
case AppliedMakeup::EyeLinerStyle::CatEye: linerStyle = MFE::EyeLinerMask::LinerStyle::CatEye; break;
default: break;
}
MFE::EyeLinerMaskPtr leftMask = std::make_shared<MFE::EyeLinerMask>();
leftMask->side = MFE::BrowMask::Side::Left;
leftMask->linerStyle = linerStyle;
MFE::EyeLinerMaskPtr rightMask = std::make_shared<MFE::EyeLinerMask>(*leftMask);
rightMask->side = MFE::BrowMask::Side::Right;
MFE::MakeupActionDrawMakeupPtr drawLeft = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawLeft->mask = leftMask;
drawLeft->product = product;
MFE::MakeupActionDrawMakeupPtr drawRight = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawRight->mask = rightMask;
drawRight->product = product;
MFE::MakeupProcedureGeneralPtr eyeLinerProcedure = std::make_shared<MFE::MakeupProcedureGeneral>();
eyeLinerProcedure->name = "Eye liner";
eyeLinerProcedure->actions.push_back(drawLeft);
eyeLinerProcedure->actions.push_back(drawRight);
return eyeLinerProcedure;
}
MFE::MakeupProcedurePtr LookGenerator::createEyeShadowsProcedure(MFE::MakeupProduct lidProduct, MFE::MakeupProduct creaseProduct, MFE::MakeupProduct highlightProduct) {
MFE::MakeupProcedureGeneralPtr eyeshadowProcedure = std::make_shared<MFE::MakeupProcedureGeneral>();
eyeshadowProcedure->name = "Eyeshadows";
MFE::EyeShadowMaskPtr leftLidMask = std::make_shared<MFE::EyeShadowMask>();
leftLidMask->side = MFE::EyeShadowMask::Side::Left;
leftLidMask->staticMaskFilename = pathForResource("Masks/Eyeshadow/ml_msk_eyeshadow_1.png");
MFE::EyeShadowMaskPtr leftCreaseMask = std::make_shared<MFE::EyeShadowMask>();
leftCreaseMask->side = MFE::EyeShadowMask::Side::Left;
leftCreaseMask->staticMaskFilename = pathForResource("Masks/Eyeshadow/ml_msk_eyeshadow_2.png");
MFE::EyeShadowMaskPtr leftHighlightMask = std::make_shared<MFE::EyeShadowMask>();
leftHighlightMask->side = MFE::EyeShadowMask::Side::Left;
leftHighlightMask->staticMaskFilename = pathForResource("Masks/Eyeshadow/ml_msk_eyeshadow_3.png");
MFE::EyeShadowMaskPtr rightLidMask = std::make_shared<MFE::EyeShadowMask>(*leftLidMask);
rightLidMask->side = MFE::EyeShadowMask::Side::Right;
rightLidMask->isStaticMaskHorizontallyFlipped = true;
MFE::EyeShadowMaskPtr rightCreaseMask = std::make_shared<MFE::EyeShadowMask>(*leftCreaseMask);
rightCreaseMask->side = MFE::EyeShadowMask::Side::Right;
rightCreaseMask->isStaticMaskHorizontallyFlipped = true;
MFE::EyeShadowMaskPtr rightHighlightMask = std::make_shared<MFE::EyeShadowMask>(*leftHighlightMask);
rightHighlightMask->side = MFE::EyeShadowMask::Side::Right;
rightHighlightMask->isStaticMaskHorizontallyFlipped = true;
MFE::MakeupActionDrawMakeupPtr drawLeftLidMask = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawLeftLidMask->mask = leftLidMask;
drawLeftLidMask->product = lidProduct;
MFE::MakeupActionDrawMakeupPtr drawLeftCreaseMask = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawLeftCreaseMask->mask = leftCreaseMask;
drawLeftCreaseMask->product = creaseProduct;
MFE::MakeupActionDrawMakeupPtr drawLeftHighlightMask = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawLeftHighlightMask->mask = leftHighlightMask;
drawLeftHighlightMask->product = highlightProduct;
MFE::MakeupActionDrawMakeupPtr drawRightLidMask = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawRightLidMask->mask = rightLidMask;
drawRightLidMask->product = lidProduct;
MFE::MakeupActionDrawMakeupPtr drawRightCreaseMask = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawRightCreaseMask->mask = rightCreaseMask;
drawRightCreaseMask->product = creaseProduct;
MFE::MakeupActionDrawMakeupPtr drawRightHighlightMask = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawRightHighlightMask->mask = rightHighlightMask;
drawRightHighlightMask->product = highlightProduct;
eyeshadowProcedure->actions.push_back(drawLeftLidMask);
eyeshadowProcedure->actions.push_back(drawLeftCreaseMask);
eyeshadowProcedure->actions.push_back(drawLeftHighlightMask);
eyeshadowProcedure->actions.push_back(drawRightLidMask);
eyeshadowProcedure->actions.push_back(drawRightCreaseMask);
eyeshadowProcedure->actions.push_back(drawRightHighlightMask);
MFE::EyeEraseMaskPtr leftEyeMask = std::make_shared<MFE::EyeEraseMask>();
leftEyeMask->side = MFE::EyeEraseMask::Side::Left;
leftEyeMask->blurFactor = 0.5;
leftEyeMask->expandFactor = 1.1;
MFE::EyeEraseMaskPtr rightEyeMask = std::make_shared<MFE::EyeEraseMask>();
rightEyeMask->side = MFE::EyeEraseMask::Side::Right;
rightEyeMask->blurFactor = 0.5;
rightEyeMask->expandFactor = 1.1;
MFE::MakeupActionErasePtr eraseLeftAction = std::make_shared<MFE::MakeupActionErase>();
eraseLeftAction->mask = leftEyeMask;
eraseLeftAction->eraseAmount = 1.0;
MFE::MakeupActionErasePtr eraseRightAction = std::make_shared<MFE::MakeupActionErase>();
eraseRightAction->mask = rightEyeMask;
eraseRightAction->eraseAmount = 1.0;
eyeshadowProcedure->actions.push_back(eraseLeftAction);
eyeshadowProcedure->actions.push_back(eraseRightAction);
return eyeshadowProcedure;
}
MFE::MakeupProcedurePtr LookGenerator::createFoundationProcedure(MFE::MakeupProduct product) {
MFE::FoundationMaskPtr foundationMask = std::make_shared<MFE::FoundationMask>();
MFE::MakeupActionDrawMakeupPtr drawFoundation = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawFoundation->mask = foundationMask;
drawFoundation->product = product;
MFE::MakeupProcedureFoundationPtr foundation = std::make_shared<MFE::MakeupProcedureFoundation>();
foundation->name = "Foundation";
foundation->actions.push_back(drawFoundation);
return foundation;
}
MFE::MakeupProcedurePtr LookGenerator::createLipstickProcedure(MFE::MakeupProduct product) {
MFE::LipstickMaskPtr lipMask = std::make_shared<MFE::LipstickMask>();
lipMask->blurFactor = 0.5;
MFE::MakeupActionDrawMakeupPtr drawLip = std::make_shared<MFE::MakeupActionDrawMakeup>();
drawLip->mask = lipMask;
drawLip->product = product;
MFE::MakeupProcedureLipstickPtr lipstick = std::make_shared<MFE::MakeupProcedureLipstick>();
lipstick->reduceShineOnEdges = true;
lipstick->name = "Lipstick";
lipstick->actions.push_back(drawLip);
return lipstick;
}
MFE::MakeupProcedurePtr LookGenerator::createLashProcedure(MFE::MakeupProduct product, AppliedMakeup::MascaraStyle style) {
MFE::LashModel lashModelTop;
lashModelTop.intensity = product.intensity;
lashModelTop.isUpperLash = true;
lashModelTop.contourThreshold = 10;
lashModelTop.colorR = product.colorR;
lashModelTop.colorG = product.colorG;
lashModelTop.colorB = product.colorB;
MFE::LashModel lashModelBottom = lashModelTop;
lashModelBottom.isUpperLash = false;
bool hasTopLash = false;
bool hasBottomLash = false;
if (style == AppliedMakeup::MascaraStyle::Top || style == AppliedMakeup::MascaraStyle::Full) {
lashModelTop.minX = 31;
lashModelTop.maxX = 141;
lashModelTop.imagePath = pathForResource("Masks/Mascara/ml_msk_mascara_1.png");
hasTopLash = true;
}
else if (style == AppliedMakeup::MascaraStyle::DenseTop || style == AppliedMakeup::MascaraStyle::DenseFull) {
lashModelTop.minX = 31;
lashModelTop.maxX = 134;
lashModelTop.imagePath = pathForResource("Masks/Mascara/ml_msk_mascara_3.png");
hasTopLash = true;
}
if (style == AppliedMakeup::MascaraStyle::Full) {
lashModelBottom.minX = 22;
lashModelBottom.maxX = 142;
lashModelBottom.imagePath = pathForResource("Masks/Mascara/ml_msk_mascara_2.png");
hasBottomLash = true;
}
else if (style == AppliedMakeup::MascaraStyle::DenseFull) {
lashModelBottom.minX = 22;
lashModelBottom.maxX = 140;
lashModelBottom.imagePath = pathForResource("Masks/Mascara/ml_msk_mascara_4.png");
hasBottomLash = true;
}
MFE::MakeupProcedureLashesPtr lash = std::make_shared<MFE::MakeupProcedureLashes>();
if (hasTopLash) {
MFE::MakeupActionDrawLashPtr drawTopLashLeft = std::make_shared<MFE::MakeupActionDrawLash>();
drawTopLashLeft->lashModel = lashModelTop;
drawTopLashLeft->isLeftSide = true;
MFE::MakeupActionDrawLashPtr drawTopLashRight = std::make_shared<MFE::MakeupActionDrawLash>();
drawTopLashRight->lashModel = lashModelTop;
drawTopLashRight->isLeftSide = false;
lash->actions.push_back(drawTopLashLeft);
lash->actions.push_back(drawTopLashRight);
}
if (hasBottomLash) {
MFE::MakeupActionDrawLashPtr drawBotLashLeft = std::make_shared<MFE::MakeupActionDrawLash>();
drawBotLashLeft->lashModel = lashModelBottom;
drawBotLashLeft->isLeftSide = true;
MFE::MakeupActionDrawLashPtr drawBotLashRight = std::make_shared<MFE::MakeupActionDrawLash>();
drawBotLashRight->lashModel = lashModelBottom;
drawBotLashRight->isLeftSide = false;
lash->actions.push_back(drawBotLashLeft);
lash->actions.push_back(drawBotLashRight);
}
return lash;
}
| [
"thaiwu@bitbucket.gamasys.com.tw"
] | thaiwu@bitbucket.gamasys.com.tw |
ec4508097245b080b2c4ae93851a2cbdf0c0db85 | ce477f12bd0e2854febecfae447524e4e914c805 | /include/tcpServer/tcpServer.h | 3b2c99ce61a0b8462a5210b5a4a06cb57f961c72 | [] | no_license | adinosaur/simple_instant_messaging | bcb2bae96e9846457cd25179320eeb715726fcca | 6d8db1339606d6f1a0c5d17231cca6c89415fa92 | refs/heads/master | 2016-09-05T18:19:58.095896 | 2015-08-30T10:46:19 | 2015-08-30T10:46:19 | 41,318,369 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 376 | h | #ifndef TCPSERVER_H
#define TCPSERVER_H
#include <set>
class TcpServer {
public:
TcpServer(int);
virtual ~TcpServer();
void run();
virtual bool do_handle(int);
protected:
void bind_and_listen();
void _bind();
void _listen();
int _port;
int _listen_fd;
std::set<int> _fd_set;
};
#endif
| [
"wumanshuo@gmail.com"
] | wumanshuo@gmail.com |
6e3e7f8ab0cd6c362afca8d0cdb4fd819a5e8d45 | 30934e1bec424f277598c4270a05f82edc17479d | /FirstProject/Weapon.cpp | 9a8f6165cad463158e811d9e7ebb7eabb10a5303 | [] | no_license | wahmarco96/ProtoTypeGameUE4 | ca9dec9ad399e8f7f6acad8a78f3aa6259a0bd9c | d4fd208468f877d99455ca4371ab6b5542224b62 | refs/heads/master | 2020-07-03T17:10:54.105794 | 2019-08-20T18:14:46 | 2019-08-20T18:14:46 | 201,980,463 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,397 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "Weapon.h"
#include "Components/SkeletalMeshComponent.h"
#include "Main.h"
#include "Engine/SkeletalMeshSocket.h"
#include "Sound/SoundCue.h"
#include "Kismet/GameplayStatics.h"
#include "Particles/ParticleSystemComponent.h"
#include "Components/BoxComponent.h"
#include "Enemy.h"
#include "Engine/SkeletalMeshSocket.h"
AWeapon::AWeapon()
{
SkeletalMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("SkeletalMesh"));
SkeletalMesh->SetupAttachment(GetRootComponent());
CombatCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("CombatCollision"));
CombatCollision->SetupAttachment(GetRootComponent());
bWeaponParticles = false;
WeaponState = EWeaponState::EWS_Pickup;
Damage = 25.f;
}
void AWeapon::BeginPlay()
{
Super::BeginPlay();
CombatCollision->OnComponentBeginOverlap.AddDynamic(this, &AWeapon::CombatOnOverlapBegin);
CombatCollision->OnComponentEndOverlap.AddDynamic(this, &AWeapon::CombatOnOverlapEnd);
CombatCollision->SetCollisionEnabled(ECollisionEnabled::NoCollision);
CombatCollision->SetCollisionObjectType(ECollisionChannel::ECC_WorldDynamic);
CombatCollision->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
CombatCollision->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);
}
void AWeapon::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
Super::OnOverlapBegin(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
if ((WeaponState == EWeaponState::EWS_Pickup) && OtherActor)
{
AMain* Main = Cast<AMain>(OtherActor);
if (Main)
{
Main->SetActiveOverlappingItem(this);
}
}
}
void AWeapon::OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
Super::OnOverlapEnd(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex);
if (OtherActor)
{
AMain* Main = Cast<AMain>(OtherActor);
if (Main)
{
Main->SetActiveOverlappingItem(nullptr);
}
}
}
void AWeapon::Equip(AMain* Char)
{
if (Char)
{
SetInstigator(Char->GetController());
SkeletalMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore);
SkeletalMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore);
SkeletalMesh->SetSimulatePhysics(false);
const USkeletalMeshSocket* RightHandSocket = Char->GetMesh()->GetSocketByName("RightHandSocket");
if (RightHandSocket)
{
RightHandSocket->AttachActor(this, Char->GetMesh());
bRotate = false;
Char->SetEquippedWeapon(this);
Char->SetActiveOverlappingItem(nullptr);
}
if (OnEquipSound) UGameplayStatics::PlaySound2D(this, OnEquipSound);
if (!bWeaponParticles)
{
IdleParticlesComponent->Deactivate();
}
}
}
void AWeapon::CombatOnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
if (OtherActor)
{
AEnemy* Enemy = Cast<AEnemy>(OtherActor);
if (Enemy)
{
if (Enemy->HitParticles)
{
const USkeletalMeshSocket* WeaponSocket = SkeletalMesh->GetSocketByName("WeaponSocket");
if (WeaponSocket)
{
FVector SocketLocation = WeaponSocket->GetSocketLocation(SkeletalMesh);
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), Enemy->HitParticles, SocketLocation, FRotator(0.f), false);
}
}
if (Enemy->HitSound)
{
UGameplayStatics::PlaySound2D(this, Enemy->HitSound);
}
if (DamageTypeClass)
{
UGameplayStatics::ApplyDamage(Enemy, Damage, WeaponInstigator, this, DamageTypeClass);
}
}
}
}
void AWeapon::CombatOnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
}
void AWeapon::ActivateCollision()
{
CombatCollision->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
}
void AWeapon::DeactivateCollision()
{
CombatCollision->SetCollisionEnabled(ECollisionEnabled::NoCollision);
} | [
"noreply@github.com"
] | noreply@github.com |
dd85c500cdad70c427fc709d2ab7488f24f2d660 | 098c9964d1071801f2fed1e751ec67e01d5a6d0d | /Problems/Arbol/A_sebas.cpp | 92af94bb61722e0033377aa4a4def61e60acbbdf | [] | no_license | rahulshankarb/assn_compiler | dc92952daeb156e9b517f04e83597fde88e9ede1 | 07816449fda7c85df2839027947cb51396e0858a | refs/heads/master | 2021-01-21T09:53:15.678272 | 2013-07-08T08:11:47 | 2013-07-08T08:11:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 224 | cpp |
#include <cstdio>
#include <cmath>
int main() {
int a,b,c,tc;
tc=0;
while (true) {
scanf("%i %i",&a,&b);
if (a==0 && b==0) break;
tc++;
c = (int)ceil( sqrt(a*a + b*b) );
printf("Caso #%i: %i\n", tc, c);
}
}
| [
"rahul@dragon.(none)"
] | rahul@dragon.(none) |
5b3e7afbe2fe64dcba668df31789ce38f22bb7b4 | 10d5cf32719829f75bb45f4e0396e35a760818a3 | /algorithms/imported/svm0.cpp | caae3ad3fb27acd1e11db0da91c17f250e658149 | [] | no_license | vireninterviewkit/PatternMatchingAlgorithmsTester | 2a73cfdd66cf71188f4dbd49dae02e707aba3661 | 2b04aeed9d3d651dea0f8181e052c6327fa1cc4c | refs/heads/master | 2023-02-24T22:46:51.622868 | 2021-02-04T11:59:53 | 2021-02-04T11:59:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,294 | cpp | /*
* SMART: string matching algorithms research tool.
* Copyright (C) 2012 Simone Faro and Thierry Lecroq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* contact the authors at: faro@dmi.unict.it, thierry.lecroq@univ-rouen.fr
* download the tool at: http://www.dmi.unict.it/~faro/smart/
*
* This is an implementation of the Shift Vector Matching algorithm
* in H. Peltola and J. Tarhio.
* Alternative Algorithms for Bit-Parallel String Matching.
* Proceedings of the 10th International Symposium on String Processing and Information Retrieval SPIRE'03, (2003).
*/
#include "algorithms/consts.h"
#include "include/main.h"
#define w ((int)sizeof(unsigned int)*8)
unsigned int asm_bsf(unsigned int x) {
asm ("bsfl %0, %0" : "=r" (x) : "0" (x));
return x;
}
int search_large_svm0(unsigned char *x, int m, unsigned char *y, int n);
int search_svm0(unsigned char *x, int m, unsigned char *y, int n) {
int count = 0;
int s, j;
unsigned int tmp, h, sv = 0, cv[MAX_SIGMA];
if(m>31) return search_large_svm0(x,m,y,n);
/* Preprocessing */
tmp = (~0);
tmp >>= (WORD-m);
for(j = 0; j < SIGMA; j++) cv[j] = tmp;
tmp = 1;
for(j = m-1; j >= 0; j--) {
cv[x[j]] &= ~tmp;
tmp <<= 1;
}
/* Searching */
if( !memcmp(x,y,m) ) OUTPUT(0);
s = m;
while(s < n) {
sv |= cv[y[s]];
j = 1;
while((sv&1) == 0) {
if(j >= m) {OUTPUT(s); break;}
sv |= (cv[y[s-j]] >> j);
j++;
}
h = ~(sv >> 1);
j = asm_bsf(h);
sv >>= j+1;
s += j+1;
}
return(count);
}
/*
* Shift Vector Matching algorithm designed for large patterns
* The present implementation searches for prefixes of the pattern of length 32.
* When an occurrence is found the algorithm tests for the whole occurrence of the pattern
*/
int search_large_svm0(unsigned char *x, int m, unsigned char *y, int n) {
int count = 0;
int s, j, p_len, first, k;
unsigned int tmp, h, sv = 0, cv[MAX_SIGMA];
p_len= m;
m = 31;
/* proprocessing */
tmp = (~0);
tmp >>= (WORD-m);
for(j = 0; j < SIGMA; j++) cv[j] = tmp;
tmp = 1;
for(j = m-1; j >= 0; j--) {
cv[x[j]] &= ~tmp;
tmp <<= 1;
}
/* searching */
if( !memcmp(x,y,m) ) OUTPUT(0);
s = m;
while(s < n){
sv |= cv[y[s]];
j = 1;
while((sv&1) == 0) {
if(j >= m) {
k = m; first = s-m+1;
while (k<p_len && x[k]==y[first+k]) k++;
if (k==p_len) OUTPUT(first);
break;
}
sv |= (cv[y[s-j]] >> j);
j++;
}
h = ~(sv >> 1);
j = asm_bsf(h);
sv >>= j+1;
s += j+1;
}
return(count);
}
| [
"toha1806@gmail.com"
] | toha1806@gmail.com |
f2f55e74f52e0c51e6c19243cc0780cb1e04b412 | e4e3f11245002c057eb64b9e14286c58c1682b43 | /服务端/系统模块/服务器组件/约战服务/PersonalRoomServiceHead.h | 4b4a5fa869d00927152e528876c6c56451955138 | [] | no_license | nofounture/HappyGameWH | dca08d293f136fc045dd408451977bab3135c04b | 25ab056c38180bad73e5fa583709e7ee5444bc14 | refs/heads/master | 2022-02-24T04:35:31.119153 | 2019-10-18T04:57:19 | 2019-10-18T04:57:19 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 11,710 | h | #ifndef PERSONAL_ROOM_SERVICE_HEAD_HEAD_FILE
#define PERSONAL_ROOM_SERVICE_HEAD_HEAD_FILE
//////////////////////////////////////////////////////////////////////////////////
//平台定义
#include "..\..\全局定义\Platform.h"
//消息定义
#include "..\..\消息定义\CMD_Commom.h"
#include "..\..\消息定义\CMD_Correspond.h"
#include "..\..\消息定义\CMD_GameServer.h"
#include "..\..\消息定义\CMD_LogonServer.h"
//平台文件
#include "..\..\公共组件\服务核心\ServiceCoreHead.h"
#include "..\..\服务器组件\游戏服务\GameServiceHead.h"
#include "..\..\服务器组件\内核引擎\KernelEngineHead.h"
//////////////////////////////////////////////////////////////////////////////////
//导出定义
//导出定义
#ifndef PERSONAL_ROOM_SERVICE_CLASS
#ifdef PERSONAL_ROOM_SERVICE_DLL
#define PERSONAL_ROOM_SERVICE_CLASS _declspec(dllexport)
#else
#define PERSONAL_ROOM_SERVICE_CLASS _declspec(dllimport)
#endif
#endif
//模块定义
#ifndef _DEBUG
#define PERSONAL_ROOM_SERVICE_DLL_NAME TEXT("PersonalRoomService.dll") //组件名字
#else
#define PERSONAL_ROOM_SERVICE_DLL_NAME TEXT("PersonalRoomService.dll") //组件名字
#endif
//////////////////////////////////////////////////////////////////////////////////
//取消报名原因
#define UNSIGNUP_REASON_PLAYER 0 //玩家取消
#define UNSIGNUP_REASON_SYSTEM 1 //系统取消
//////////////////////////////////////////////////////////////////////////////////
//类型声明
class CLockTimeMatch;
//////////////////////////////////////////////////////////////////////////////////
//约战房参数
struct tagPersonalRoomManagerParameter
{
//配置参数
tagPersonalRoomOption * pPersonalRoomOption; //约战房配置
tagGameServiceOption * pGameServiceOption; //服务配置
tagGameServiceAttrib * pGameServiceAttrib; //服务属性
//内核组件
ITimerEngine * pITimerEngine; //时间引擎
IDBCorrespondManager * pICorrespondManager; //数据引擎
ITCPNetworkEngineEvent * pTCPNetworkEngine; //网络引擎
ITCPNetworkEngine * pITCPNetworkEngine; //网络引擎
ITCPSocketService * pITCPSocketService; //网络服务
//服务组件
IAndroidUserManager * pIAndroidUserManager; //机器管理
IServerUserManager * pIServerUserManager; //用户管理
IMainServiceFrame * pIMainServiceFrame; //服务框架
IServerUserItemSink * pIServerUserItemSink; //用户接口
};
//////////////////////////////////////////////////////////////////////////////////
#ifdef _UNICODE
#define VER_IPersonalRoomServiceManager INTERFACE_VERSION(1,1)
static const GUID IID_IPersonalRoomServiceManager={0xaf116139, 0xa0, 0x40e3, 0xaa, 0x7b, 0x2f, 0x41, 0xf2, 0x3d, 0xb1, 0x89};
#else
#define VER_IPersonalRoomServiceManager INTERFACE_VERSION(1,1)
static const GUID IID_IPersonalRoomServiceManager={0xc59d784b, 0x8875, 0x41f5, 0xa3, 0xd0, 0x23, 0x94, 0x96, 0xe0, 0x28, 0x3c};
#endif
class CTableFrame;
typedef CWHArray<CTableFrame *> CTableFrameArray; //桌子数组
//绑定参数
struct tagPersonalBindParameter
{
//网络数据
DWORD dwSocketID; //网络标识
DWORD dwClientAddr; //连接地址
DWORD dwActiveTime; //激活时间
};
//比赛服务器管理接口
interface IPersonalRoomServiceManager : public IUnknownEx
{
//控制接口
public:
//停止服务
virtual bool StopService()=NULL;
//启动服务
virtual bool StartService()=NULL;
//管理接口
public:
//创建比赛
virtual bool CreatePersonalRoom(BYTE cbPersonalRoomType)=NULL;
//绑定桌子
virtual bool BindTableFrame(ITableFrame * pTableFrame,WORD wChairID)=NULL;
//初始化接口
virtual bool InitPersonalRooomInterface(tagPersonalRoomManagerParameter & PersonalRoomManagerParameter)=NULL;
//系统事件
public:
//时间事件
virtual bool OnEventTimer(DWORD dwTimerID, WPARAM dwBindParameter)=NULL;
//数据库事件
virtual bool OnEventDataBase(WORD wRequestID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize,DWORD dwContextID)=NULL;
//网络事件
public:
//约战服务事件
virtual bool OnEventSocketPersonalRoom(WORD wSubCmdID, VOID * pData, WORD wDataSize, IServerUserItem * pIServerUserItem, DWORD dwSocketID)=NULL;
//约战服务器事件
virtual bool OnTCPSocketMainServiceInfo(WORD wSubCmdID, VOID * pData, WORD wDataSize)=NULL;
//用户接口
public:
//用户登录
virtual bool OnEventUserLogon(IServerUserItem * pIServerUserItem)=NULL;
//用户登出
virtual bool OnEventUserLogout(IServerUserItem * pIServerUserItem)=NULL;
//登录完成
virtual bool OnEventUserLogonFinish(IServerUserItem * pIServerUserItem)=NULL;
//接口信息
public:
//用户接口
virtual IUnknownEx * GetServerUserItemSink()=NULL;
//用户接口
//virtual IUnknownEx * GetMatchUserItemSink()=NULL;
//测试
public:
virtual void TestPersonal() = NULL;
//查询房间
virtual bool OnTCPNetworkSubMBQueryGameServer(VOID * pData, WORD wDataSize, DWORD dwSocketID, tagPersonalBindParameter * pBindParameter, ITCPSocketService * pITCPSocketService) = NULL;
//搜索房间桌号
virtual bool OnTCPNetworkSubMBSearchServerTable(VOID * pData, WORD wDataSize, DWORD dwSocketID, tagPersonalBindParameter * pBindParameter, ITCPSocketService * pITCPSocketService) = NULL;
//强制解散搜索房间桌号
virtual bool OnTCPNetworkSubMBDissumeSearchServerTable(VOID * pData, WORD wDataSize, DWORD dwSocketID, tagPersonalBindParameter * pBindParameter, ITCPSocketService * pITCPSocketService) = NULL;
//私人房间配置
virtual bool OnTCPNetworkSubMBPersonalParameter(VOID * pData, WORD wDataSize, DWORD dwSocketID, IDataBaseEngine * pIDataBaseEngine) = NULL;
//查询私人房间列表
virtual bool OnTCPNetworkSubMBQueryPersonalRoomList(VOID * pData, WORD wDataSize, DWORD dwSocketID, ITCPSocketService * pITCPSocketService) = NULL;
///玩家请求房间成绩
virtual bool OnTCPNetworkSubQueryUserRoomScore(VOID * pData, WORD wDataSize, DWORD dwSocketID, IDataBaseEngine * pIDataBaseEngine) = NULL;
};
//////////////////////////////////////////////////////////////////////////////////
#ifdef _UNICODE
#define VER_IPersonalRoomItem INTERFACE_VERSION(1,1)
static const GUID IID_IPersonalRoomItem = {0x758b6167, 0x248f, 0x4138, 0xac, 0xcb, 0x1f, 0x72, 0x70, 0x8, 0x25, 0xc9};
#else
#define VER_IPersonalRoomItem INTERFACE_VERSION(1,1)
static const GUID IID_IPersonalRoomItem = {0xdb849912, 0x7834, 0x4429, 0xae, 0xa, 0x4c, 0x1a, 0x96, 0x87, 0x38, 0xa9};
#endif
//游戏比赛接口
interface IPersonalRoomItem : public IUnknownEx
{
//控制接口
public:
//启动通知
virtual void OnStartService()=NULL;
//管理接口
public:
//绑定桌子
virtual bool BindTableFrame(ITableFrame * pTableFrame,WORD wTableID)=NULL;
//初始化接口
virtual bool InitPersonalRooomInterface(tagPersonalRoomManagerParameter & MatchManagerParameter)=NULL;
//系统事件
public:
//时间事件
virtual bool OnEventTimer(DWORD dwTimerID, WPARAM dwBindParameter)=NULL;
//数据库事件
virtual bool OnEventDataBase(WORD wRequestID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize,DWORD dwContextID)=NULL;
//网络事件
public:
//约战服务事件
virtual bool OnEventSocketPersonalRoom(WORD wSubCmdID, VOID * pData, WORD wDataSize, IServerUserItem * pIServerUserItem, DWORD dwSocketID)=NULL;
//约战服务器事件
virtual bool OnTCPSocketMainServiceInfo(WORD wSubCmdID, VOID * pData, WORD wDataSize)=NULL;
//信息接口
public:
//用户登录
virtual bool OnEventUserLogon(IServerUserItem * pIServerUserItem)=NULL;
//用户登出
virtual bool OnEventUserLogout(IServerUserItem * pIServerUserItem)=NULL;
//登录完成
virtual bool OnEventUserLogonFinish(IServerUserItem * pIServerUserItem)=NULL;
};
//////////////////////////////////////////////////////////////////////////////////
#ifdef _UNICODE
#define VER_IPersonalRoomEventSink INTERFACE_VERSION(1,1)
static const GUID IID_IPersonalRoomEventSink={0x8d288098, 0x818c, 0x40a8, 0x9b, 0x8d, 0xb5, 0x19, 0xbb, 0x94, 0x40, 0x7d};
#else
#define VER_IPersonalRoomEventSink INTERFACE_VERSION(1,1)
static const GUID IID_IPersonalRoomEventSink={0x2650c8a7, 0x313d, 0x4635, 0xbf, 0x27, 0x4b, 0x3a, 0xd0, 0x5e, 0x0, 0x4};
#endif
//游戏事件
interface IPersonalRoomEventSink :public IUnknownEx
{
public:
//游戏开始
virtual bool OnEventGameStart(ITableFrame *pITableFrame, WORD wChairCount)=NULL;
//写参与信息
virtual void PersonalRoomWriteJoinInfo(DWORD dwUserID, WORD wTableID, WORD wChairID, DWORD dwKindID, DWORD dwPersonalRoomID, TCHAR * szPersonalRoomGUID) = NULL;
//房卡支付
virtual bool PersonalPayRoomCard(DWORD dwUserID, WORD wTableID, WORD wChairCount, DWORD dwPersonalRoomID) = NULL;
//游戏结束
virtual bool OnEventGameEnd(ITableFrame *pITableFrame,WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason)=NULL;
virtual bool OnEventGameEnd(WORD wTableID, WORD wChairCount, DWORD dwDrawCountLimit, DWORD & dwPersonalPlayCount, int nSpecialInfoLen, byte * cbSpecialInfo, SYSTEMTIME sysStartTime, tagPersonalUserScoreInfo * PersonalUserScoreInfo, BOOL bPersonalLoop,BYTE cbGameMode) = NULL;
//用户事件
public:
//玩家返赛
virtual bool OnEventUserReturnMatch(ITableFrame *pITableFrame,IServerUserItem * pIServerUserItem)=NULL;
//玩家动作
public:
//用户坐下
virtual bool OnActionUserSitDown(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser)=NULL;
//用户起来
virtual bool OnActionUserStandUp(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser)=NULL;
//用户同意
virtual bool OnActionUserOnReady(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize)=NULL;
};
///////////////////////////////////////////////////////////////////////////
#ifdef _UNICODE
#define VER_IPersonalTableFrameHook INTERFACE_VERSION(1,1)
static const GUID IID_IPersonalTableFrameHook={0x958d9add, 0xe98c, 0x4067, 0x8a, 0xca, 0x1c, 0x32, 0x6c, 0xb8, 0x1e, 0x72};
#else
#define VER_IPersonalTableFrameHook INTERFACE_VERSION(1,1)
static const GUID IID_IPersonalTableFrameHook={0x10ac366e, 0x9d0c, 0x41b6, 0x9b, 0x2e, 0x39, 0x9a, 0x10, 0x13, 0x17, 0x81};
#endif
//桌子钩子接口
interface IPersonalTableFrameHook : public IUnknownEx
{
//管理接口
public:
//设置接口
virtual bool SetPersonalRoomEventSink(IUnknownEx * pIUnknownEx)=NULL;
//初始化
virtual bool InitTableFrameHook(IUnknownEx * pIUnknownEx)=NULL;
//游戏事件
public:
//游戏开始
virtual bool OnEventGameStart(WORD wChairCount)=NULL;
//约战房写参与信息
virtual void PersonalRoomWriteJoinInfo(DWORD dwUserID, WORD wTableID, WORD wChairID, DWORD dwKindID, DWORD dwPersonalRoomID, TCHAR * szPersonalRoomGUID) = NULL;
//游戏结束
virtual bool OnEventGameEnd(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason)=NULL;
//游戏结束
virtual bool OnEventGameEnd(WORD wTableID, WORD wChairCount, DWORD dwDrawCountLimit, DWORD & dwPersonalPlayCount, int nSpecialInfoLen, byte * cbSpecialInfo, SYSTEMTIME sysStartTime, tagPersonalUserScoreInfo * PersonalUserScoreInfo, BOOL bPersonalLoop,BYTE cbGameMode) = NULL;
//房卡支付
virtual bool PersonalPayRoomCard(DWORD dwUserID, WORD wTableID, WORD wChairCount, DWORD dwPersonalRoomID)=NULL;
};
//////////////////////////////////////////////////////////////////////////////////
//游戏服务
DECLARE_MODULE_HELPER(PersonalRoomServiceManager,PERSONAL_ROOM_SERVICE_DLL_NAME,"CreatePersonalRoomServiceManager")
//////////////////////////////////////////////////////////////////////////////////
#endif | [
"542981526@qq.com"
] | 542981526@qq.com |
de4118c7a2ecc8d786a31477a3d98b25fb485eac | e7b3e7fcc23ecfb17aaa382763c7cb97e7647c4e | /src/vipre/BackgroundCamera.cpp | 508fc0af82e13030bac0279b593c5145f5522c80 | [] | no_license | sudodata/VIPRE | 7938f3049bc15462f014883d556af377b808ca36 | 6cc8b1fc613ba845a890e60a6061a038febd23c8 | refs/heads/master | 2022-12-02T13:11:51.106935 | 2020-07-07T03:05:42 | 2020-07-07T03:05:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,964 | cpp | //
// BackgroundCamera.cpp
// vipre
//
// Created by Christian Noon on 12/15/11.
// Copyright (c) 2011 Christian Noon. All rights reserved.
//
#include <boost/function.hpp>
#include <vipre/BackgroundCamera.hpp>
#include <vipre/Log.hpp>
#include <vipre/NotificationCenter.hpp>
using namespace vipre;
BackgroundCamera::BackgroundCamera() : osg::Camera()
{
// Initialize the default background, camera and quad geometry
initializeSolidBackgroundDefaults();
initializeGradientBackgroundDefaults();
initializeCamera();
initializeBackgroundGeometry();
// Register setter methods with the vipre::NotificationCenter
boost::function<void (BackgroundCamera*, SolidBackground)> addSolidCallback(&BackgroundCamera::addSolidBackground);
boost::function<void (BackgroundCamera*, GradientBackground)> addGradientCallback(&BackgroundCamera::addGradientBackground);
boost::function<void (BackgroundCamera*, String)> removeSolidCallback(&BackgroundCamera::removeSolidBackground);
boost::function<void (BackgroundCamera*, String)> removeGradientCallback(&BackgroundCamera::removeGradientBackground);
boost::function<void (BackgroundCamera*, String)> switchToSolidCallback(&BackgroundCamera::switchToSolidBackground);
boost::function<void (BackgroundCamera*, String)> switchToGradientCallback(&BackgroundCamera::switchToGradientBackground);
NotificationCenter::instance()->addObserver(this, addSolidCallback, "AddSolidBackground");
NotificationCenter::instance()->addObserver(this, addGradientCallback, "AddGradientBackground");
NotificationCenter::instance()->addObserver(this, removeSolidCallback, "RemoveSolidBackground");
NotificationCenter::instance()->addObserver(this, removeGradientCallback, "RemoveGradientBackground");
NotificationCenter::instance()->addObserver(this, switchToSolidCallback, "SwitchToSolidBackground");
NotificationCenter::instance()->addObserver(this, switchToGradientCallback, "SwitchToGradientBackground");
}
BackgroundCamera::BackgroundCamera(const BackgroundCamera& rhs, const osg::CopyOp& copyop) :
osg::Camera(rhs, copyop)
{
;
}
BackgroundCamera::~BackgroundCamera()
{
NotificationCenter::instance()->removeObserver(this);
}
void BackgroundCamera::initializeSolidBackgroundDefaults()
{
// Set up some default solid backgrounds
SolidBackground white("White", osg::Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
SolidBackground black("Black", osg::Vec4f(0.0f, 0.0f, 0.0f, 1.0f));
SolidBackground lightGrey("Light Grey", osg::Vec4f(0.75f, 0.75f, 0.75f, 1.0f));
SolidBackground grey("Grey", osg::Vec4f(0.5f, 0.5f, 0.5f, 1.0f));
SolidBackground darkGrey("Dark Grey", osg::Vec4f(0.25f, 0.25f, 0.25f, 1.0f));
_solidBackgrounds.insert(std::pair<String, SolidBackground>(white.name, white));
_solidBackgrounds.insert(std::pair<String, SolidBackground>(black.name, black));
_solidBackgrounds.insert(std::pair<String, SolidBackground>(lightGrey.name, lightGrey));
_solidBackgrounds.insert(std::pair<String, SolidBackground>(grey.name, grey));
_solidBackgrounds.insert(std::pair<String, SolidBackground>(darkGrey.name, darkGrey));
}
void BackgroundCamera::initializeGradientBackgroundDefaults()
{
// Set up some default gradient backgrounds
GradientBackground whiteGradient("White Gradient", osg::Vec4f(1.0f, 1.0f, 1.0f, 1.0f), osg::Vec4f(0.5f, 0.5f, 0.5f, 1.0f));
GradientBackground blackGradient("Black Gradient", osg::Vec4f(0.1f, 0.1f, 0.1f, 1.0f), osg::Vec4f(0.5f, 0.5f, 0.5f, 1.0f));
GradientBackground greyGradient("Grey Gradient", osg::Vec4f(0.25f, 0.25f, 0.25f, 1.0f), osg::Vec4f(0.75f, 0.75f, 0.75f, 1.0f));
_gradientBackgrounds.insert(std::pair<String, GradientBackground>(whiteGradient.name, whiteGradient));
_gradientBackgrounds.insert(std::pair<String, GradientBackground>(blackGradient.name, blackGradient));
_gradientBackgrounds.insert(std::pair<String, GradientBackground>(greyGradient.name, greyGradient));
}
void BackgroundCamera::initializeCamera()
{
// Set the projection and view matrices
setProjectionMatrix(osg::Matrix::ortho2D(0, 1000, 0, 1000));
setReferenceFrame(osg::Transform::ABSOLUTE_RF);
setViewMatrix(osg::Matrix::identity());
// Draw subgraph before main camera view
setRenderOrder(osg::Camera::PRE_RENDER);
// We don't want the camera to grab event focus from the viewers main camera
setAllowEventFocus(false);
}
void BackgroundCamera::initializeBackgroundGeometry()
{
// Setup the geode and geometry nodes
_backgroundGeode = new osg::Geode;
_backgroundGeometry = new osg::Geometry();
addChild(_backgroundGeode.get());
_backgroundGeode->addDrawable(_backgroundGeometry.get());
// Set up the vertices
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array;
vertices->push_back(osg::Vec3f(0.0f, 0.0f, 0.0f));
vertices->push_back(osg::Vec3f(1000.0f, 0.0f, 0.0f));
vertices->push_back(osg::Vec3f(1000.0f, 1000.0f, 0.0f));
vertices->push_back(osg::Vec3f(0.0f, 1000.0f, 0.0f));
_backgroundGeometry->setVertexArray(vertices.get());
// Set up the background colors
_backgroundColors = new osg::Vec4Array;
switchToGradientBackground("Black Gradient");
// Add a quad primitive to the geometry
_backgroundGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, vertices->size()));
// Disable lighting geode
_backgroundGeode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
}
void BackgroundCamera::addSolidBackground(const SolidBackground& background)
{
// Warn the user if they are going to overwrite a solid background
if (_solidBackgrounds.find(background.name) != _solidBackgrounds.end())
{
vipreLogWARNING(viprePrefix) << "The solid background: " << background.name
<< " already exists...will be overwritten with new one." << std::endl;
}
_solidBackgrounds.insert(std::pair<String, SolidBackground>(background.name, background));
}
void BackgroundCamera::addGradientBackground(const GradientBackground& background)
{
// Warn the user if they are going to overwrite a gradient background
if (_gradientBackgrounds.find(background.name) != _gradientBackgrounds.end())
{
vipreLogWARNING(viprePrefix) << "The gradient background: " << background.name
<< " already exists...will be overwritten with new one." << std::endl;
}
_gradientBackgrounds.insert(std::pair<String, GradientBackground>(background.name, background));
}
void BackgroundCamera::removeSolidBackground(const String& backgroundName)
{
std::map<String, SolidBackground>::iterator iter = _solidBackgrounds.find(backgroundName);
if (iter != _solidBackgrounds.end())
{
_solidBackgrounds.erase(iter);
}
else
{
vipreLogWARNING(viprePrefix) << "Could not remove solid background: " << backgroundName
<< " because it does not exist." << std::endl;
}
}
void BackgroundCamera::removeGradientBackground(const String& backgroundName)
{
std::map<String, GradientBackground>::iterator iter = _gradientBackgrounds.find(backgroundName);
if (iter != _gradientBackgrounds.end())
{
_gradientBackgrounds.erase(iter);
}
else
{
vipreLogWARNING(viprePrefix) << "Could not remove gradient background: " << backgroundName
<< " because it does not exist." << std::endl;
}
}
void BackgroundCamera::switchToSolidBackground(const String& backgroundName)
{
std::map<String, SolidBackground>::iterator iter = _solidBackgrounds.find(backgroundName);
if (iter != _solidBackgrounds.end())
{
SolidBackground background = iter->second;
setBackgroundColor(background.color, background.color);
}
else
{
vipreLogWARNING(viprePrefix) << "Could not switch to solid background: " << backgroundName
<< " because it does not exist." << std::endl;
}
}
void BackgroundCamera::switchToGradientBackground(const String& backgroundName)
{
std::map<String, GradientBackground>::iterator iter = _gradientBackgrounds.find(backgroundName);
if (iter != _gradientBackgrounds.end())
{
GradientBackground background = iter->second;
setBackgroundColor(background.topColor, background.bottomColor);
}
else
{
vipreLogWARNING(viprePrefix) << "Could not switch to gradient background: " << backgroundName
<< " because it does not exist." << std::endl;
}
}
void BackgroundCamera::setBackgroundColor(const osg::Vec4f& topColor, const osg::Vec4f& bottomColor)
{
// Update the background colors array
_backgroundColors->clear();
_backgroundColors->push_back(bottomColor);
_backgroundColors->push_back(bottomColor);
_backgroundColors->push_back(topColor);
_backgroundColors->push_back(topColor);
// Set the color array for the background geometry
_backgroundGeometry->setColorArray(_backgroundColors.get());
}
| [
"38545159+jackm93@users.noreply.github.com"
] | 38545159+jackm93@users.noreply.github.com |
fa3864671413713f426eba7d68a27a0def21917a | 7efd19a44953a8ab87f97a12ae2136de2c187582 | /ThirdLib/glslang/External/spirv-tools/test/bit_stream.cpp | dfc6d18767a04d72059e72b35ec5038422624abe | [
"MIT",
"Apache-2.0"
] | permissive | winddyhe/WindGE | d532c33c9135c49a7043b3c76a90567683d94642 | 377438805cd92bdb435eae8a137699fa8e0b1105 | refs/heads/master | 2020-07-06T08:35:01.912152 | 2017-12-26T16:02:50 | 2017-12-26T16:02:50 | 74,051,432 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 42,288 | cpp | // Copyright (c) 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <sstream>
#include <string>
#include <vector>
#include "gmock/gmock.h"
#include "util/bit_stream.h"
namespace {
using spvutils::BitWriterInterface;
using spvutils::BitReaderInterface;
using spvutils::BitWriterWord64;
using spvutils::BitReaderWord64;
using spvutils::StreamToBuffer;
using spvutils::BufferToStream;
using spvutils::NumBitsToNumWords;
using spvutils::PadToWord;
using spvutils::StreamToBitset;
using spvutils::BitsetToStream;
using spvutils::BitsToStream;
using spvutils::StreamToBits;
using spvutils::GetLowerBits;
using spvutils::EncodeZigZag;
using spvutils::DecodeZigZag;
using spvutils::Log2U64;
// A simple and inefficient implementatition of BitWriterInterface,
// using std::stringstream. Intended for tests only.
class BitWriterStringStream : public BitWriterInterface {
public:
void WriteStream(const std::string& bits) override {
ss_ << bits;
}
void WriteBits(uint64_t bits, size_t num_bits) override {
assert(num_bits <= 64);
ss_ << BitsToStream(bits, num_bits);
}
size_t GetNumBits() const override {
return ss_.str().size();
}
std::vector<uint8_t> GetDataCopy() const override {
return StreamToBuffer<uint8_t>(ss_.str());
}
std::string GetStreamRaw() const {
return ss_.str();
}
private:
std::stringstream ss_;
};
// A simple and inefficient implementatition of BitReaderInterface.
// Intended for tests only.
class BitReaderFromString : public BitReaderInterface {
public:
explicit BitReaderFromString(std::string&& str)
: str_(std::move(str)), pos_(0) {}
explicit BitReaderFromString(const std::vector<uint64_t>& buffer)
: str_(BufferToStream(buffer)), pos_(0) {}
explicit BitReaderFromString(const std::vector<uint8_t>& buffer)
: str_(PadToWord<64>(BufferToStream(buffer))), pos_(0) {}
size_t ReadBits(uint64_t* bits, size_t num_bits) override {
if (ReachedEnd())
return 0;
std::string sub = str_.substr(pos_, num_bits);
*bits = StreamToBits(sub);
pos_ += sub.length();
return sub.length();
}
size_t GetNumReadBits() const override {
return pos_;
}
bool ReachedEnd() const override {
return pos_ >= str_.length();
}
const std::string& GetStreamPadded64() const {
return str_;
}
private:
std::string str_;
size_t pos_;
};
TEST(Log2U16, Test) {
EXPECT_EQ(0u, Log2U64(0));
EXPECT_EQ(0u, Log2U64(1));
EXPECT_EQ(1u, Log2U64(2));
EXPECT_EQ(1u, Log2U64(3));
EXPECT_EQ(2u, Log2U64(4));
EXPECT_EQ(2u, Log2U64(5));
EXPECT_EQ(2u, Log2U64(6));
EXPECT_EQ(2u, Log2U64(7));
EXPECT_EQ(3u, Log2U64(8));
EXPECT_EQ(3u, Log2U64(9));
EXPECT_EQ(3u, Log2U64(10));
EXPECT_EQ(3u, Log2U64(11));
EXPECT_EQ(3u, Log2U64(12));
EXPECT_EQ(3u, Log2U64(13));
EXPECT_EQ(3u, Log2U64(14));
EXPECT_EQ(3u, Log2U64(15));
EXPECT_EQ(4u, Log2U64(16));
EXPECT_EQ(4u, Log2U64(17));
EXPECT_EQ(5u, Log2U64(35));
EXPECT_EQ(6u, Log2U64(72));
EXPECT_EQ(7u, Log2U64(255));
EXPECT_EQ(8u, Log2U64(256));
EXPECT_EQ(15u, Log2U64(65535));
EXPECT_EQ(16u, Log2U64(65536));
EXPECT_EQ(19u, Log2U64(0xFFFFF));
EXPECT_EQ(23u, Log2U64(0xFFFFFF));
EXPECT_EQ(27u, Log2U64(0xFFFFFFF));
EXPECT_EQ(31u, Log2U64(0xFFFFFFFF));
EXPECT_EQ(35u, Log2U64(0xFFFFFFFFF));
EXPECT_EQ(39u, Log2U64(0xFFFFFFFFFF));
EXPECT_EQ(43u, Log2U64(0xFFFFFFFFFFF));
EXPECT_EQ(47u, Log2U64(0xFFFFFFFFFFFF));
EXPECT_EQ(51u, Log2U64(0xFFFFFFFFFFFFF));
EXPECT_EQ(55u, Log2U64(0xFFFFFFFFFFFFFF));
EXPECT_EQ(59u, Log2U64(0xFFFFFFFFFFFFFFF));
EXPECT_EQ(63u, Log2U64(0xFFFFFFFFFFFFFFFF));
}
TEST(NumBitsToNumWords, Word8) {
EXPECT_EQ(0u, NumBitsToNumWords<8>(0));
EXPECT_EQ(1u, NumBitsToNumWords<8>(1));
EXPECT_EQ(1u, NumBitsToNumWords<8>(7));
EXPECT_EQ(1u, NumBitsToNumWords<8>(8));
EXPECT_EQ(2u, NumBitsToNumWords<8>(9));
EXPECT_EQ(2u, NumBitsToNumWords<8>(16));
EXPECT_EQ(3u, NumBitsToNumWords<8>(17));
EXPECT_EQ(3u, NumBitsToNumWords<8>(23));
EXPECT_EQ(3u, NumBitsToNumWords<8>(24));
EXPECT_EQ(4u, NumBitsToNumWords<8>(25));
}
TEST(NumBitsToNumWords, Word64) {
EXPECT_EQ(0u, NumBitsToNumWords<64>(0));
EXPECT_EQ(1u, NumBitsToNumWords<64>(1));
EXPECT_EQ(1u, NumBitsToNumWords<64>(64));
EXPECT_EQ(2u, NumBitsToNumWords<64>(65));
EXPECT_EQ(2u, NumBitsToNumWords<64>(128));
EXPECT_EQ(3u, NumBitsToNumWords<64>(129));
}
TEST(ZigZagCoding, Encode) {
EXPECT_EQ(0u, EncodeZigZag(0));
EXPECT_EQ(1u, EncodeZigZag(-1));
EXPECT_EQ(2u, EncodeZigZag(1));
EXPECT_EQ(3u, EncodeZigZag(-2));
EXPECT_EQ(4u, EncodeZigZag(2));
EXPECT_EQ(5u, EncodeZigZag(-3));
EXPECT_EQ(6u, EncodeZigZag(3));
EXPECT_EQ(std::numeric_limits<uint64_t>::max() - 1,
EncodeZigZag(std::numeric_limits<int64_t>::max()));
EXPECT_EQ(std::numeric_limits<uint64_t>::max(),
EncodeZigZag(std::numeric_limits<int64_t>::min()));
}
TEST(ZigZagCoding, Decode) {
EXPECT_EQ(0, DecodeZigZag(0));
EXPECT_EQ(-1, DecodeZigZag(1));
EXPECT_EQ(1, DecodeZigZag(2));
EXPECT_EQ(-2, DecodeZigZag(3));
EXPECT_EQ(2, DecodeZigZag(4));
EXPECT_EQ(-3, DecodeZigZag(5));
EXPECT_EQ(3, DecodeZigZag(6));
EXPECT_EQ(std::numeric_limits<int64_t>::min(),
DecodeZigZag(std::numeric_limits<uint64_t>::max()));
EXPECT_EQ(std::numeric_limits<int64_t>::max(),
DecodeZigZag(std::numeric_limits<uint64_t>::max() - 1));
}
TEST(ZigZagCoding, Encode0) {
EXPECT_EQ(0u, EncodeZigZag(0, 0));
EXPECT_EQ(1u, EncodeZigZag(-1, 0));
EXPECT_EQ(2u, EncodeZigZag(1, 0));
EXPECT_EQ(3u, EncodeZigZag(-2, 0));
EXPECT_EQ(std::numeric_limits<uint64_t>::max() - 1,
EncodeZigZag(std::numeric_limits<int64_t>::max(), 0));
EXPECT_EQ(std::numeric_limits<uint64_t>::max(),
EncodeZigZag(std::numeric_limits<int64_t>::min(), 0));
}
TEST(ZigZagCoding, Decode0) {
EXPECT_EQ(0, DecodeZigZag(0, 0));
EXPECT_EQ(-1, DecodeZigZag(1, 0));
EXPECT_EQ(1, DecodeZigZag(2, 0));
EXPECT_EQ(-2, DecodeZigZag(3, 0));
EXPECT_EQ(std::numeric_limits<int64_t>::min(),
DecodeZigZag(std::numeric_limits<uint64_t>::max(), 0));
EXPECT_EQ(std::numeric_limits<int64_t>::max(),
DecodeZigZag(std::numeric_limits<uint64_t>::max() - 1, 0));
}
TEST(ZigZagCoding, Decode0SameAsNormalZigZag) {
for (int32_t i = -10000; i < 10000; i += 123) {
ASSERT_EQ(DecodeZigZag(i), DecodeZigZag(i, 0));
}
}
TEST(ZigZagCoding, Encode0SameAsNormalZigZag) {
for (uint32_t i = 0; i < 10000; i += 123) {
ASSERT_EQ(EncodeZigZag(i), EncodeZigZag(i, 0));
}
}
TEST(ZigZagCoding, Encode1) {
EXPECT_EQ(0u, EncodeZigZag(0, 1));
EXPECT_EQ(1u, EncodeZigZag(1, 1));
EXPECT_EQ(2u, EncodeZigZag(-1, 1));
EXPECT_EQ(3u, EncodeZigZag(-2, 1));
EXPECT_EQ(4u, EncodeZigZag(2, 1));
EXPECT_EQ(5u, EncodeZigZag(3, 1));
EXPECT_EQ(6u, EncodeZigZag(-3, 1));
EXPECT_EQ(7u, EncodeZigZag(-4, 1));
EXPECT_EQ(std::numeric_limits<uint64_t>::max() - 2,
EncodeZigZag(std::numeric_limits<int64_t>::max(), 1));
EXPECT_EQ(std::numeric_limits<uint64_t>::max() - 1,
EncodeZigZag(std::numeric_limits<int64_t>::min() + 1, 1));
EXPECT_EQ(std::numeric_limits<uint64_t>::max(),
EncodeZigZag(std::numeric_limits<int64_t>::min(), 1));
}
TEST(ZigZagCoding, Decode1) {
EXPECT_EQ(0, DecodeZigZag(0, 1));
EXPECT_EQ(1, DecodeZigZag(1, 1));
EXPECT_EQ(-1, DecodeZigZag(2, 1));
EXPECT_EQ(-2, DecodeZigZag(3, 1));
EXPECT_EQ(2, DecodeZigZag(4, 1));
EXPECT_EQ(3, DecodeZigZag(5, 1));
EXPECT_EQ(-3, DecodeZigZag(6, 1));
EXPECT_EQ(-4, DecodeZigZag(7, 1));
EXPECT_EQ(std::numeric_limits<int64_t>::min(),
DecodeZigZag(std::numeric_limits<uint64_t>::max(), 1));
EXPECT_EQ(std::numeric_limits<int64_t>::min() + 1,
DecodeZigZag(std::numeric_limits<uint64_t>::max() - 1, 1));
EXPECT_EQ(std::numeric_limits<int64_t>::max(),
DecodeZigZag(std::numeric_limits<uint64_t>::max() - 2, 1));
}
TEST(ZigZagCoding, Encode2) {
EXPECT_EQ(0u, EncodeZigZag(0, 2));
EXPECT_EQ(1u, EncodeZigZag(1, 2));
EXPECT_EQ(2u, EncodeZigZag(2, 2));
EXPECT_EQ(3u, EncodeZigZag(3, 2));
EXPECT_EQ(4u, EncodeZigZag(-1, 2));
EXPECT_EQ(5u, EncodeZigZag(-2, 2));
EXPECT_EQ(6u, EncodeZigZag(-3, 2));
EXPECT_EQ(7u, EncodeZigZag(-4, 2));
EXPECT_EQ(8u, EncodeZigZag(4, 2));
EXPECT_EQ(9u, EncodeZigZag(5, 2));
EXPECT_EQ(10u, EncodeZigZag(6, 2));
EXPECT_EQ(11u, EncodeZigZag(7, 2));
EXPECT_EQ(12u, EncodeZigZag(-5, 2));
EXPECT_EQ(13u, EncodeZigZag(-6, 2));
EXPECT_EQ(14u, EncodeZigZag(-7, 2));
EXPECT_EQ(15u, EncodeZigZag(-8, 2));
EXPECT_EQ(std::numeric_limits<uint64_t>::max() - 4,
EncodeZigZag(std::numeric_limits<int64_t>::max(), 2));
EXPECT_EQ(std::numeric_limits<uint64_t>::max() - 3,
EncodeZigZag(std::numeric_limits<int64_t>::min() + 3, 2));
EXPECT_EQ(std::numeric_limits<uint64_t>::max() - 2,
EncodeZigZag(std::numeric_limits<int64_t>::min() + 2, 2));
EXPECT_EQ(std::numeric_limits<uint64_t>::max() - 1,
EncodeZigZag(std::numeric_limits<int64_t>::min() + 1, 2));
EXPECT_EQ(std::numeric_limits<uint64_t>::max(),
EncodeZigZag(std::numeric_limits<int64_t>::min(), 2));
}
TEST(ZigZagCoding, Decode2) {
EXPECT_EQ(0, DecodeZigZag(0, 2));
EXPECT_EQ(1, DecodeZigZag(1, 2));
EXPECT_EQ(2, DecodeZigZag(2, 2));
EXPECT_EQ(3, DecodeZigZag(3, 2));
EXPECT_EQ(-1, DecodeZigZag(4, 2));
EXPECT_EQ(-2, DecodeZigZag(5, 2));
EXPECT_EQ(-3, DecodeZigZag(6, 2));
EXPECT_EQ(-4, DecodeZigZag(7, 2));
EXPECT_EQ(4, DecodeZigZag(8, 2));
EXPECT_EQ(5, DecodeZigZag(9, 2));
EXPECT_EQ(6, DecodeZigZag(10, 2));
EXPECT_EQ(7, DecodeZigZag(11, 2));
EXPECT_EQ(-5, DecodeZigZag(12, 2));
EXPECT_EQ(-6, DecodeZigZag(13, 2));
EXPECT_EQ(-7, DecodeZigZag(14, 2));
EXPECT_EQ(-8, DecodeZigZag(15, 2));
EXPECT_EQ(std::numeric_limits<int64_t>::min(),
DecodeZigZag(std::numeric_limits<uint64_t>::max(), 2));
EXPECT_EQ(std::numeric_limits<int64_t>::min() + 1,
DecodeZigZag(std::numeric_limits<uint64_t>::max() - 1, 2));
EXPECT_EQ(std::numeric_limits<int64_t>::min() + 2,
DecodeZigZag(std::numeric_limits<uint64_t>::max() - 2, 2));
EXPECT_EQ(std::numeric_limits<int64_t>::min() + 3,
DecodeZigZag(std::numeric_limits<uint64_t>::max() - 3, 2));
EXPECT_EQ(std::numeric_limits<int64_t>::max(),
DecodeZigZag(std::numeric_limits<uint64_t>::max() - 4, 2));
}
TEST(ZigZagCoding, Encode63) {
EXPECT_EQ(0u, EncodeZigZag(0, 63));
for (int64_t i = 0; i < 0xFFFFFFFF; i += 1234567) {
const int64_t positive_val = GetLowerBits(i * i * i + i * i, 63) | 1UL;
ASSERT_EQ(static_cast<uint64_t>(positive_val),
EncodeZigZag(positive_val, 63));
ASSERT_EQ((1ULL << 63) - 1 + positive_val, EncodeZigZag(-positive_val, 63));
}
EXPECT_EQ((1ULL << 63) - 1,
EncodeZigZag(std::numeric_limits<int64_t>::max(), 63));
EXPECT_EQ(std::numeric_limits<uint64_t>::max() - 1,
EncodeZigZag(std::numeric_limits<int64_t>::min() + 1, 63));
EXPECT_EQ(std::numeric_limits<uint64_t>::max(),
EncodeZigZag(std::numeric_limits<int64_t>::min(), 63));
}
TEST(BufToStream, UInt8_Empty) {
const std::string expected_bits = "";
std::vector<uint8_t> buffer = StreamToBuffer<uint8_t>(expected_bits);
EXPECT_TRUE(buffer.empty());
const std::string result_bits = BufferToStream(buffer);
EXPECT_EQ(expected_bits, result_bits);
}
TEST(BufToStream, UInt8_OneWord) {
const std::string expected_bits = "00101100";
std::vector<uint8_t> buffer = StreamToBuffer<uint8_t>(expected_bits);
EXPECT_EQ(
std::vector<uint8_t>(
{static_cast<uint8_t>(StreamToBitset<8>(expected_bits).to_ulong())}),
buffer);
const std::string result_bits = BufferToStream(buffer);
EXPECT_EQ(expected_bits, result_bits);
}
TEST(BufToStream, UInt8_MultipleWords) {
const std::string expected_bits = "00100010""01101010""01111101""00100010";
std::vector<uint8_t> buffer = StreamToBuffer<uint8_t>(expected_bits);
EXPECT_EQ(
std::vector<uint8_t>({
static_cast<uint8_t>(StreamToBitset<8>("00100010").to_ulong()),
static_cast<uint8_t>(StreamToBitset<8>("01101010").to_ulong()),
static_cast<uint8_t>(StreamToBitset<8>("01111101").to_ulong()),
static_cast<uint8_t>(StreamToBitset<8>("00100010").to_ulong()),
}), buffer);
const std::string result_bits = BufferToStream(buffer);
EXPECT_EQ(expected_bits, result_bits);
}
TEST(BufToStream, UInt64_Empty) {
const std::string expected_bits = "";
std::vector<uint64_t> buffer = StreamToBuffer<uint64_t>(expected_bits);
EXPECT_TRUE(buffer.empty());
const std::string result_bits = BufferToStream(buffer);
EXPECT_EQ(expected_bits, result_bits);
}
TEST(BufToStream, UInt64_OneWord) {
const std::string expected_bits =
"0001000111101110011001101010101000100010110011000100010010001000";
std::vector<uint64_t> buffer = StreamToBuffer<uint64_t>(expected_bits);
ASSERT_EQ(1u, buffer.size());
EXPECT_EQ(0x1122334455667788u, buffer[0]);
const std::string result_bits = BufferToStream(buffer);
EXPECT_EQ(expected_bits, result_bits);
}
TEST(BufToStream, UInt64_Unaligned) {
const std::string expected_bits =
"0010001001101010011111010010001001001010000111110010010010010101"
"0010001001101010011111111111111111111111";
std::vector<uint64_t> buffer = StreamToBuffer<uint64_t>(expected_bits);
EXPECT_EQ(std::vector<uint64_t>({
StreamToBits(expected_bits.substr(0, 64)),
StreamToBits(expected_bits.substr(64, 64)),
}), buffer);
const std::string result_bits = BufferToStream(buffer);
EXPECT_EQ(PadToWord<64>(expected_bits), result_bits);
}
TEST(BufToStream, UInt64_MultipleWords) {
const std::string expected_bits =
"0010001001101010011111010010001001001010000111110010010010010101"
"0010001001101010011111111111111111111111000111110010010010010111"
"0000000000000000000000000000000000000000000000000010010011111111";
std::vector<uint64_t> buffer = StreamToBuffer<uint64_t>(expected_bits);
EXPECT_EQ(std::vector<uint64_t>({
StreamToBits(expected_bits.substr(0, 64)),
StreamToBits(expected_bits.substr(64, 64)),
StreamToBits(expected_bits.substr(128, 64)),
}), buffer);
const std::string result_bits = BufferToStream(buffer);
EXPECT_EQ(expected_bits, result_bits);
}
TEST(PadToWord, Test) {
EXPECT_EQ("10100000", PadToWord<8>("101"));
EXPECT_EQ("10100000""00000000", PadToWord<16>("101"));
EXPECT_EQ("10100000""00000000""00000000""00000000",
PadToWord<32>("101"));
EXPECT_EQ("10100000""00000000""00000000""00000000"
"00000000""00000000""00000000""00000000",
PadToWord<64>("101"));
}
TEST(BitWriterStringStream, Empty) {
BitWriterStringStream writer;
EXPECT_EQ(0u, writer.GetNumBits());
EXPECT_EQ(0u, writer.GetDataSizeBytes());
EXPECT_EQ("", writer.GetStreamRaw());
}
TEST(BitWriterStringStream, WriteStream) {
BitWriterStringStream writer;
const std::string bits1 = "1011111111111111111";
writer.WriteStream(bits1);
EXPECT_EQ(19u, writer.GetNumBits());
EXPECT_EQ(3u, writer.GetDataSizeBytes());
EXPECT_EQ(bits1, writer.GetStreamRaw());
const std::string bits2 = "10100001010101010000111111111111111111111111111";
writer.WriteStream(bits2);
EXPECT_EQ(66u, writer.GetNumBits());
EXPECT_EQ(9u, writer.GetDataSizeBytes());
EXPECT_EQ(bits1 + bits2, writer.GetStreamRaw());
}
TEST(BitWriterStringStream, WriteBitSet) {
BitWriterStringStream writer;
const std::string bits1 = "10101";
writer.WriteBitset(StreamToBitset<16>(bits1));
EXPECT_EQ(16u, writer.GetNumBits());
EXPECT_EQ(2u, writer.GetDataSizeBytes());
EXPECT_EQ(PadToWord<16>(bits1), writer.GetStreamRaw());
}
TEST(BitWriterStringStream, WriteBits) {
BitWriterStringStream writer;
const uint64_t bits1 = 0x1 | 0x2 | 0x10;
writer.WriteBits(bits1, 5);
EXPECT_EQ(5u, writer.GetNumBits());
EXPECT_EQ(1u, writer.GetDataSizeBytes());
EXPECT_EQ("11001", writer.GetStreamRaw());
}
TEST(BitWriterStringStream, WriteUnencodedU8) {
BitWriterStringStream writer;
const uint8_t bits = 127;
writer.WriteUnencoded(bits);
EXPECT_EQ(8u, writer.GetNumBits());
EXPECT_EQ("11111110", writer.GetStreamRaw());
}
TEST(BitWriterStringStream, WriteUnencodedS64) {
BitWriterStringStream writer;
const int64_t bits = std::numeric_limits<int64_t>::min() + 7;
writer.WriteUnencoded(bits);
EXPECT_EQ(64u, writer.GetNumBits());
EXPECT_EQ("1110000000000000000000000000000000000000000000000000000000000001",
writer.GetStreamRaw());
}
TEST(BitWriterStringStream, WriteMultiple) {
BitWriterStringStream writer;
std::string expected_result;
const std::string bits1 = "101001111111001100010000001110001111111100";
writer.WriteStream(bits1);
const std::string bits2 = "10100011000010010101";
writer.WriteBitset(StreamToBitset<20>(bits2));
const uint64_t val = 0x1 | 0x2 | 0x10;
const std::string bits3 = BitsToStream(val, 8);
writer.WriteBits(val, 8);
const std::string expected = bits1 + bits2 + bits3;
EXPECT_EQ(expected.length(), writer.GetNumBits());
EXPECT_EQ(9u, writer.GetDataSizeBytes());
EXPECT_EQ(expected, writer.GetStreamRaw());
EXPECT_EQ(PadToWord<8>(expected), BufferToStream(writer.GetDataCopy()));
}
TEST(BitWriterWord64, Empty) {
BitWriterWord64 writer;
EXPECT_EQ(0u, writer.GetNumBits());
EXPECT_EQ(0u, writer.GetDataSizeBytes());
EXPECT_EQ("", writer.GetStreamPadded64());
}
TEST(BitWriterWord64, WriteStream) {
BitWriterWord64 writer;
std::string expected;
{
const std::string bits = "101";
expected += bits;
writer.WriteStream(bits);
EXPECT_EQ(expected.length(), writer.GetNumBits());
EXPECT_EQ(1u, writer.GetDataSizeBytes());
EXPECT_EQ(PadToWord<64>(expected), writer.GetStreamPadded64());
}
{
const std::string bits = "10000111111111110000000";
expected += bits;
writer.WriteStream(bits);
EXPECT_EQ(expected.length(), writer.GetNumBits());
EXPECT_EQ(PadToWord<64>(expected), writer.GetStreamPadded64());
}
{
const std::string bits = "101001111111111100000111111111111100";
expected += bits;
writer.WriteStream(bits);
EXPECT_EQ(expected.length(), writer.GetNumBits());
EXPECT_EQ(PadToWord<64>(expected), writer.GetStreamPadded64());
}
}
TEST(BitWriterWord64, WriteBitset) {
BitWriterWord64 writer;
const std::string bits1 = "10101";
writer.WriteBitset(StreamToBitset<16>(bits1), 12);
EXPECT_EQ(12u, writer.GetNumBits());
EXPECT_EQ(2u, writer.GetDataSizeBytes());
EXPECT_EQ(PadToWord<64>(bits1), writer.GetStreamPadded64());
}
TEST(BitWriterWord64, WriteBits) {
BitWriterWord64 writer;
const uint64_t bits1 = 0x1 | 0x2 | 0x10;
writer.WriteBits(bits1, 5);
writer.WriteBits(bits1, 5);
writer.WriteBits(bits1, 5);
EXPECT_EQ(15u, writer.GetNumBits());
EXPECT_EQ(2u, writer.GetDataSizeBytes());
EXPECT_EQ(PadToWord<64>("110011100111001"), writer.GetStreamPadded64());
}
TEST(BitWriterWord64, WriteZeroBits) {
BitWriterWord64 writer;
writer.WriteBits(0, 0);
writer.WriteBits(1, 0);
EXPECT_EQ(0u, writer.GetNumBits());
writer.WriteBits(1, 1);
writer.WriteBits(0, 0);
EXPECT_EQ(PadToWord<64>("1"), writer.GetStreamPadded64());
writer.WriteBits(0, 63);
EXPECT_EQ(64u, writer.GetNumBits());
writer.WriteBits(0, 0);
writer.WriteBits(7, 3);
writer.WriteBits(0, 0);
EXPECT_EQ(PadToWord<64>(
"1"
"000000000000000000000000000000000000000000000000000000000000000"
"111"), writer.GetStreamPadded64());
}
TEST(BitWriterWord64, ComparisonTestWriteLotsOfBits) {
BitWriterStringStream writer1;
BitWriterWord64 writer2(16384);
for (uint64_t i = 0; i < 65000; i += 25) {
writer1.WriteBits(i, 16);
writer2.WriteBits(i, 16);
ASSERT_EQ(writer1.GetNumBits(), writer2.GetNumBits());
}
EXPECT_EQ(PadToWord<64>(writer1.GetStreamRaw()),
writer2.GetStreamPadded64());
}
TEST(BitWriterWord64, ComparisonTestWriteLotsOfStreams) {
BitWriterStringStream writer1;
BitWriterWord64 writer2(16384);
for (int i = 0; i < 1000; ++i) {
std::string bits = "1111100000";
if (i % 2)
bits += "101010";
if (i % 3)
bits += "1110100";
if (i % 5)
bits += "1110100111111111111";
writer1.WriteStream(bits);
writer2.WriteStream(bits);
ASSERT_EQ(writer1.GetNumBits(), writer2.GetNumBits());
}
EXPECT_EQ(PadToWord<64>(writer1.GetStreamRaw()),
writer2.GetStreamPadded64());
}
TEST(BitWriterWord64, ComparisonTestWriteLotsOfBitsets) {
BitWriterStringStream writer1;
BitWriterWord64 writer2(16384);
for (uint64_t i = 0; i < 65000; i += 25) {
std::bitset<16> bits1(i);
std::bitset<24> bits2(i);
writer1.WriteBitset(bits1);
writer1.WriteBitset(bits2);
writer2.WriteBitset(bits1);
writer2.WriteBitset(bits2);
ASSERT_EQ(writer1.GetNumBits(), writer2.GetNumBits());
}
EXPECT_EQ(PadToWord<64>(writer1.GetStreamRaw()),
writer2.GetStreamPadded64());
}
TEST(GetLowerBits, Test) {
EXPECT_EQ(0u, GetLowerBits<uint8_t>(255, 0));
EXPECT_EQ(1u, GetLowerBits<uint8_t>(255, 1));
EXPECT_EQ(3u, GetLowerBits<uint8_t>(255, 2));
EXPECT_EQ(7u, GetLowerBits<uint8_t>(255, 3));
EXPECT_EQ(15u, GetLowerBits<uint8_t>(255, 4));
EXPECT_EQ(31u, GetLowerBits<uint8_t>(255, 5));
EXPECT_EQ(63u, GetLowerBits<uint8_t>(255, 6));
EXPECT_EQ(127u, GetLowerBits<uint8_t>(255, 7));
EXPECT_EQ(255u, GetLowerBits<uint8_t>(255, 8));
EXPECT_EQ(0xFFu, GetLowerBits<uint32_t>(0xFFFFFFFF, 8));
EXPECT_EQ(0xFFFFu, GetLowerBits<uint32_t>(0xFFFFFFFF, 16));
EXPECT_EQ(0xFFFFFFu, GetLowerBits<uint32_t>(0xFFFFFFFF, 24));
EXPECT_EQ(0xFFFFFFu, GetLowerBits<uint64_t>(0xFFFFFFFFFFFF, 24));
EXPECT_EQ(0xFFFFFFFFFFFFFFFFu,
GetLowerBits<uint64_t>(0xFFFFFFFFFFFFFFFFu, 64));
EXPECT_EQ(StreamToBits("1010001110"),
GetLowerBits<uint64_t>(
StreamToBits("1010001110111101111111"), 10));
}
TEST(BitReaderFromString, FromU8) {
std::vector<uint8_t> buffer = {
0xAA, 0xBB, 0xCC, 0xDD,
};
const std::string total_stream =
"01010101""11011101""00110011""10111011";
BitReaderFromString reader(buffer);
EXPECT_EQ(PadToWord<64>(total_stream), reader.GetStreamPadded64());
uint64_t bits = 0;
EXPECT_EQ(2u, reader.ReadBits(&bits, 2));
EXPECT_EQ(PadToWord<64>("01"), BitsToStream(bits));
EXPECT_EQ(20u, reader.ReadBits(&bits, 20));
EXPECT_EQ(PadToWord<64>("01010111011101001100"), BitsToStream(bits));
EXPECT_EQ(20u, reader.ReadBits(&bits, 20));
EXPECT_EQ(PadToWord<64>("11101110110000000000"), BitsToStream(bits));
EXPECT_EQ(22u, reader.ReadBits(&bits, 30));
EXPECT_EQ(PadToWord<64>("0000000000000000000000"), BitsToStream(bits));
EXPECT_TRUE(reader.ReachedEnd());
}
TEST(BitReaderFromString, FromU64) {
std::vector<uint64_t> buffer = {
0xAAAAAAAAAAAAAAAA,
0xBBBBBBBBBBBBBBBB,
0xCCCCCCCCCCCCCCCC,
0xDDDDDDDDDDDDDDDD,
};
const std::string total_stream =
"0101010101010101010101010101010101010101010101010101010101010101"
"1101110111011101110111011101110111011101110111011101110111011101"
"0011001100110011001100110011001100110011001100110011001100110011"
"1011101110111011101110111011101110111011101110111011101110111011";
BitReaderFromString reader(buffer);
EXPECT_EQ(total_stream, reader.GetStreamPadded64());
uint64_t bits = 0;
size_t pos = 0;
size_t to_read = 5;
while (reader.ReadBits(&bits, to_read) > 0) {
EXPECT_EQ(BitsToStream(bits),
PadToWord<64>(total_stream.substr(pos, to_read)));
pos += to_read;
to_read = (to_read + 35) % 64 + 1;
}
EXPECT_TRUE(reader.ReachedEnd());
}
TEST(BitReaderWord64, ReadBitsSingleByte) {
BitReaderWord64 reader(std::vector<uint8_t>({uint8_t(0xF0)}));
EXPECT_FALSE(reader.ReachedEnd());
uint64_t bits = 0;
EXPECT_EQ(1u, reader.ReadBits(&bits, 1));
EXPECT_EQ(0u, bits);
EXPECT_EQ(2u, reader.ReadBits(&bits, 2));
EXPECT_EQ(0u, bits);
EXPECT_EQ(2u, reader.ReadBits(&bits, 2));
EXPECT_EQ(2u, bits);
EXPECT_EQ(2u, reader.ReadBits(&bits, 2));
EXPECT_EQ(3u, bits);
EXPECT_FALSE(reader.OnlyZeroesLeft());
EXPECT_FALSE(reader.ReachedEnd());
EXPECT_EQ(2u, reader.ReadBits(&bits, 2));
EXPECT_EQ(1u, bits);
EXPECT_TRUE(reader.OnlyZeroesLeft());
EXPECT_FALSE(reader.ReachedEnd());
EXPECT_EQ(55u, reader.ReadBits(&bits, 64));
EXPECT_EQ(0u, bits);
EXPECT_TRUE(reader.ReachedEnd());
}
TEST(BitReaderWord64, ReadBitsetSingleByte) {
BitReaderWord64 reader(std::vector<uint8_t>({uint8_t(0xCC)}));
std::bitset<4> bits;
EXPECT_EQ(2u, reader.ReadBitset(&bits, 2));
EXPECT_EQ(0u, bits.to_ullong());
EXPECT_EQ(2u, reader.ReadBitset(&bits, 2));
EXPECT_EQ(3u, bits.to_ullong());
EXPECT_FALSE(reader.OnlyZeroesLeft());
EXPECT_EQ(4u, reader.ReadBitset(&bits, 4));
EXPECT_EQ(12u, bits.to_ullong());
EXPECT_TRUE(reader.OnlyZeroesLeft());
}
TEST(BitReaderWord64, ReadStreamSingleByte) {
BitReaderWord64 reader(std::vector<uint8_t>({uint8_t(0xAA)}));
EXPECT_EQ("", reader.ReadStream(0));
EXPECT_EQ("0", reader.ReadStream(1));
EXPECT_EQ("101", reader.ReadStream(3));
EXPECT_EQ("01010000", reader.ReadStream(8));
EXPECT_TRUE(reader.OnlyZeroesLeft());
EXPECT_EQ("0000000000000000000000000000000000000000000000000000",
reader.ReadStream(64));
EXPECT_TRUE(reader.ReachedEnd());
}
TEST(BitReaderWord64, ReadStreamEmpty) {
std::vector<uint64_t> buffer;
BitReaderWord64 reader(std::move(buffer));
EXPECT_TRUE(reader.OnlyZeroesLeft());
EXPECT_TRUE(reader.ReachedEnd());
EXPECT_EQ("", reader.ReadStream(10));
EXPECT_TRUE(reader.ReachedEnd());
}
TEST(BitReaderWord64, ReadBitsTwoWords) {
std::vector<uint64_t> buffer = {
0x0000000000000001,
0x0000000000FFFFFF
};
BitReaderWord64 reader(std::move(buffer));
uint64_t bits = 0;
EXPECT_EQ(1u, reader.ReadBits(&bits, 1));
EXPECT_EQ(1u, bits);
EXPECT_EQ(62u, reader.ReadBits(&bits, 62));
EXPECT_EQ(0u, bits);
EXPECT_EQ(2u, reader.ReadBits(&bits, 2));
EXPECT_EQ(2u, bits);
EXPECT_EQ(3u, reader.ReadBits(&bits, 3));
EXPECT_EQ(7u, bits);
EXPECT_FALSE(reader.OnlyZeroesLeft());
EXPECT_EQ(32u, reader.ReadBits(&bits, 32));
EXPECT_EQ(0xFFFFFu, bits);
EXPECT_TRUE(reader.OnlyZeroesLeft());
EXPECT_FALSE(reader.ReachedEnd());
EXPECT_EQ(28u, reader.ReadBits(&bits, 32));
EXPECT_EQ(0u, bits);
EXPECT_TRUE(reader.ReachedEnd());
}
TEST(BitReaderFromString, ReadUnencodedU8) {
BitReaderFromString reader("11111110");
uint8_t val = 0;
ASSERT_TRUE(reader.ReadUnencoded(&val));
EXPECT_EQ(8u, reader.GetNumReadBits());
EXPECT_EQ(127, val);
}
TEST(BitReaderFromString, ReadUnencodedU16Fail) {
BitReaderFromString reader("11111110");
uint16_t val = 0;
ASSERT_FALSE(reader.ReadUnencoded(&val));
}
TEST(BitReaderFromString, ReadUnencodedS64) {
BitReaderFromString reader(
"1110000000000000000000000000000000000000000000000000000000000001");
int64_t val = 0;
ASSERT_TRUE(reader.ReadUnencoded(&val));
EXPECT_EQ(64u, reader.GetNumReadBits());
EXPECT_EQ(std::numeric_limits<int64_t>::min() + 7, val);
}
TEST(BitReaderWord64, FromU8) {
std::vector<uint8_t> buffer = {
0xAA, 0xBB, 0xCC, 0xDD,
};
BitReaderWord64 reader(std::move(buffer));
uint64_t bits = 0;
EXPECT_EQ(2u, reader.ReadBits(&bits, 2));
EXPECT_EQ(PadToWord<64>("01"), BitsToStream(bits));
EXPECT_EQ(20u, reader.ReadBits(&bits, 20));
EXPECT_EQ(PadToWord<64>("01010111011101001100"), BitsToStream(bits));
EXPECT_EQ(20u, reader.ReadBits(&bits, 20));
EXPECT_EQ(PadToWord<64>("11101110110000000000"), BitsToStream(bits));
EXPECT_EQ(22u, reader.ReadBits(&bits, 30));
EXPECT_EQ(PadToWord<64>("0000000000000000000000"), BitsToStream(bits));
EXPECT_TRUE(reader.ReachedEnd());
}
TEST(BitReaderWord64, FromU64) {
std::vector<uint64_t> buffer = {
0xAAAAAAAAAAAAAAAA,
0xBBBBBBBBBBBBBBBB,
0xCCCCCCCCCCCCCCCC,
0xDDDDDDDDDDDDDDDD,
};
const std::string total_stream =
"0101010101010101010101010101010101010101010101010101010101010101"
"1101110111011101110111011101110111011101110111011101110111011101"
"0011001100110011001100110011001100110011001100110011001100110011"
"1011101110111011101110111011101110111011101110111011101110111011";
BitReaderWord64 reader(std::move(buffer));
uint64_t bits = 0;
size_t pos = 0;
size_t to_read = 5;
while (reader.ReadBits(&bits, to_read) > 0) {
EXPECT_EQ(BitsToStream(bits),
PadToWord<64>(total_stream.substr(pos, to_read)));
pos += to_read;
to_read = (to_read + 35) % 64 + 1;
}
EXPECT_TRUE(reader.ReachedEnd());
}
TEST(BitReaderWord64, ComparisonLotsOfU8) {
std::vector<uint8_t> buffer;
for(uint32_t i = 0; i < 10003; ++i) {
buffer.push_back(static_cast<uint8_t>(i % 255));
}
BitReaderFromString reader1(buffer);
BitReaderWord64 reader2(std::move(buffer));
uint64_t bits1 = 0, bits2 = 0;
size_t to_read = 5;
while (reader1.ReadBits(&bits1, to_read) > 0) {
reader2.ReadBits(&bits2, to_read);
EXPECT_EQ(bits1, bits2);
to_read = (to_read + 35) % 64 + 1;
}
EXPECT_EQ(0u, reader2.ReadBits(&bits2, 1));
}
TEST(BitReaderWord64, ComparisonLotsOfU64) {
std::vector<uint64_t> buffer;
for(uint64_t i = 0; i < 1000; ++i) {
buffer.push_back(i);
}
BitReaderFromString reader1(buffer);
BitReaderWord64 reader2(std::move(buffer));
uint64_t bits1 = 0, bits2 = 0;
size_t to_read = 5;
while (reader1.ReadBits(&bits1, to_read) > 0) {
reader2.ReadBits(&bits2, to_read);
EXPECT_EQ(bits1, bits2);
to_read = (to_read + 35) % 64 + 1;
}
EXPECT_EQ(0u, reader2.ReadBits(&bits2, 1));
}
TEST(ReadWriteWord64, ReadWriteLotsOfBits) {
BitWriterWord64 writer(16384);
for (uint64_t i = 0; i < 65000; i += 25) {
const uint64_t num_bits = i % 64 + 1;
const uint64_t bits = i >> (64 - num_bits);
writer.WriteBits(bits, size_t(num_bits));
}
BitReaderWord64 reader(writer.GetDataCopy());
for (uint64_t i = 0; i < 65000; i += 25) {
const uint64_t num_bits = i % 64 + 1;
const uint64_t expected_bits = i >> (64 - num_bits);
uint64_t bits = 0;
reader.ReadBits(&bits, size_t(num_bits));
EXPECT_EQ(expected_bits, bits);
}
EXPECT_TRUE(reader.OnlyZeroesLeft());
}
TEST(VariableWidthWrite, Write0U) {
BitWriterStringStream writer;
writer.WriteVariableWidthU64(0, 2);
EXPECT_EQ("000", writer.GetStreamRaw ());
writer.WriteVariableWidthU32(0, 2);
EXPECT_EQ("000""000", writer.GetStreamRaw());
writer.WriteVariableWidthU16(0, 2);
EXPECT_EQ("000""000""000", writer.GetStreamRaw());
writer.WriteVariableWidthU8(0, 2);
EXPECT_EQ("000""000""000""000", writer.GetStreamRaw());
}
TEST(VariableWidthWrite, Write0S) {
BitWriterStringStream writer;
writer.WriteVariableWidthS64(0, 2, 0);
EXPECT_EQ("000", writer.GetStreamRaw ());
writer.WriteVariableWidthS32(0, 2, 0);
EXPECT_EQ("000""000", writer.GetStreamRaw());
writer.WriteVariableWidthS16(0, 2, 0);
EXPECT_EQ("000""000""000", writer.GetStreamRaw());
writer.WriteVariableWidthS8(0, 2, 0);
EXPECT_EQ("000""000""000""000", writer.GetStreamRaw());
}
TEST(VariableWidthWrite, WriteSmallUnsigned) {
BitWriterStringStream writer;
writer.WriteVariableWidthU64(1, 2);
EXPECT_EQ("100", writer.GetStreamRaw ());
writer.WriteVariableWidthU32(2, 2);
EXPECT_EQ("100""010", writer.GetStreamRaw());
writer.WriteVariableWidthU16(3, 2);
EXPECT_EQ("100""010""110", writer.GetStreamRaw());
writer.WriteVariableWidthU8(4, 2);
EXPECT_EQ("100""010""110""001100", writer.GetStreamRaw());
}
TEST(VariableWidthWrite, WriteSmallSigned) {
BitWriterStringStream writer;
writer.WriteVariableWidthS64(1, 2, 0);
EXPECT_EQ("010", writer.GetStreamRaw ());
writer.WriteVariableWidthS64(-1, 2, 0);
EXPECT_EQ("010""100", writer.GetStreamRaw());
writer.WriteVariableWidthS16(3, 2, 0);
EXPECT_EQ("010""100""011100", writer.GetStreamRaw());
writer.WriteVariableWidthS8(-4, 2, 0);
EXPECT_EQ("010""100""011100""111100", writer.GetStreamRaw());
}
TEST(VariableWidthWrite, U64Val127ChunkLength7) {
BitWriterStringStream writer;
writer.WriteVariableWidthU64(127, 7);
EXPECT_EQ("1111111""0", writer.GetStreamRaw());
}
TEST(VariableWidthWrite, U32Val255ChunkLength7) {
BitWriterStringStream writer;
writer.WriteVariableWidthU32(255, 7);
EXPECT_EQ("1111111""1""1000000""0", writer.GetStreamRaw());
}
TEST(VariableWidthWrite, U16Val2ChunkLength4) {
BitWriterStringStream writer;
writer.WriteVariableWidthU16(2, 4);
EXPECT_EQ("0100""0", writer.GetStreamRaw());
}
TEST(VariableWidthWrite, U8Val128ChunkLength7) {
BitWriterStringStream writer;
writer.WriteVariableWidthU8(128, 7);
EXPECT_EQ("0000000""1""1", writer.GetStreamRaw());
}
TEST(VariableWidthWrite, U64ValAAAAChunkLength2) {
BitWriterStringStream writer;
writer.WriteVariableWidthU64(0xAAAA, 2);
EXPECT_EQ("01""1""01""1""01""1""01""1"
"01""1""01""1""01""1""01""0", writer.GetStreamRaw());
}
TEST(VariableWidthWrite, S8ValM128ChunkLength7) {
BitWriterStringStream writer;
writer.WriteVariableWidthS8(-128, 7, 0);
EXPECT_EQ("1111111""1""1", writer.GetStreamRaw());
}
TEST(VariableWidthRead, U64Val127ChunkLength7) {
BitReaderFromString reader("1111111""0");
uint64_t val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU64(&val, 7));
EXPECT_EQ(127u, val);
}
TEST(VariableWidthRead, U32Val255ChunkLength7) {
BitReaderFromString reader("1111111""1""1000000""0");
uint32_t val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU32(&val, 7));
EXPECT_EQ(255u, val);
}
TEST(VariableWidthRead, U16Val2ChunkLength4) {
BitReaderFromString reader("0100""0");
uint16_t val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU16(&val, 4));
EXPECT_EQ(2u, val);
}
TEST(VariableWidthRead, U8Val128ChunkLength7) {
BitReaderFromString reader("0000000""1""1");
uint8_t val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU8(&val, 7));
EXPECT_EQ(128u, val);
}
TEST(VariableWidthRead, U64ValAAAAChunkLength2) {
BitReaderFromString reader("01""1""01""1""01""1""01""1"
"01""1""01""1""01""1""01""0");
uint64_t val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU64(&val, 2));
EXPECT_EQ(0xAAAAu, val);
}
TEST(VariableWidthRead, S8ValM128ChunkLength7) {
BitReaderFromString reader("1111111""1""1");
int8_t val = 0;
ASSERT_TRUE(reader.ReadVariableWidthS8(&val, 7, 0));
EXPECT_EQ(-128, val);
}
TEST(VariableWidthRead, FailTooShort) {
BitReaderFromString reader("00000001100000");
uint64_t val = 0;
ASSERT_FALSE(reader.ReadVariableWidthU64(&val, 7));
}
TEST(VariableWidthWriteRead, SingleWriteReadU64) {
for (uint64_t i = 0; i < 1000000; i += 1234) {
const uint64_t val = i * i * i;
const size_t chunk_length = size_t(i % 16 + 1);
BitWriterWord64 writer;
writer.WriteVariableWidthU64(val, chunk_length);
BitReaderWord64 reader(writer.GetDataCopy());
uint64_t read_val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU64(&read_val, chunk_length));
ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
}
}
TEST(VariableWidthWriteRead, SingleWriteReadS64) {
for (int64_t i = 0; i < 1000000; i += 4321) {
const int64_t val = i * i * (i % 2 ? -i : i);
const size_t chunk_length = size_t(i % 16 + 1);
const size_t zigzag_exponent = size_t(i % 13);
BitWriterWord64 writer;
writer.WriteVariableWidthS64(val, chunk_length, zigzag_exponent);
BitReaderWord64 reader(writer.GetDataCopy());
int64_t read_val = 0;
ASSERT_TRUE(reader.ReadVariableWidthS64(&read_val, chunk_length,
zigzag_exponent));
ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
}
}
TEST(VariableWidthWriteRead, SingleWriteReadU32) {
for (uint32_t i = 0; i < 100000; i += 123) {
const uint32_t val = i * i;
const size_t chunk_length = i % 16 + 1;
BitWriterWord64 writer;
writer.WriteVariableWidthU32(val, chunk_length);
BitReaderWord64 reader(writer.GetDataCopy());
uint32_t read_val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU32(&read_val, chunk_length));
ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
}
}
TEST(VariableWidthWriteRead, SingleWriteReadS32) {
for (int32_t i = 0; i < 100000; i += 123) {
const int32_t val = i * (i % 2 ? -i : i);
const size_t chunk_length = i % 16 + 1;
const size_t zigzag_exponent = i % 11;
BitWriterWord64 writer;
writer.WriteVariableWidthS32(val, chunk_length, zigzag_exponent);
BitReaderWord64 reader(writer.GetDataCopy());
int32_t read_val = 0;
ASSERT_TRUE(reader.ReadVariableWidthS32(
&read_val, chunk_length, zigzag_exponent));
ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
}
}
TEST(VariableWidthWriteRead, SingleWriteReadU16) {
for (int i = 0; i < 65536; i += 123) {
const uint16_t val = static_cast<int16_t>(i);
const size_t chunk_length = val % 10 + 1;
BitWriterWord64 writer;
writer.WriteVariableWidthU16(val, chunk_length);
BitReaderWord64 reader(writer.GetDataCopy());
uint16_t read_val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU16(&read_val, chunk_length));
ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
}
}
TEST(VariableWidthWriteRead, SingleWriteReadS16) {
for (int i = -32768; i < 32768; i += 123) {
const int16_t val = static_cast<int16_t>(i);
const size_t chunk_length = std::abs(i) % 10 + 1;
const size_t zigzag_exponent = std::abs(i) % 7;
BitWriterWord64 writer;
writer.WriteVariableWidthS16(val, chunk_length, zigzag_exponent);
BitReaderWord64 reader(writer.GetDataCopy());
int16_t read_val = 0;
ASSERT_TRUE(reader.ReadVariableWidthS16(&read_val, chunk_length,
zigzag_exponent));
ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
}
}
TEST(VariableWidthWriteRead, SingleWriteReadU8) {
for (int i = 0; i < 256; ++i) {
const uint8_t val = static_cast<uint8_t>(i);
const size_t chunk_length = val % 5 + 1;
BitWriterWord64 writer;
writer.WriteVariableWidthU8(val, chunk_length);
BitReaderWord64 reader(writer.GetDataCopy());
uint8_t read_val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU8(&read_val, chunk_length));
ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
}
}
TEST(VariableWidthWriteRead, SingleWriteReadS8) {
for (int i = -128; i < 128; ++i) {
const int8_t val = static_cast<int8_t>(i);
const size_t chunk_length = std::abs(i) % 5 + 1;
const size_t zigzag_exponent = std::abs(i) % 3;
BitWriterWord64 writer;
writer.WriteVariableWidthS8(val, chunk_length, zigzag_exponent);
BitReaderWord64 reader(writer.GetDataCopy());
int8_t read_val = 0;
ASSERT_TRUE(reader.ReadVariableWidthS8(&read_val, chunk_length,
zigzag_exponent));
ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
}
}
TEST(VariableWidthWriteRead, SmallNumbersChunkLength4) {
const std::vector<uint64_t> expected_values = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
BitWriterWord64 writer;
for (uint64_t val : expected_values) {
writer.WriteVariableWidthU64(val, 4);
}
EXPECT_EQ(50u, writer.GetNumBits());
std::vector<uint64_t> actual_values;
BitReaderWord64 reader(writer.GetDataCopy());
while(!reader.OnlyZeroesLeft()) {
uint64_t val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU64(&val, 4));
actual_values.push_back(val);
}
EXPECT_EQ(expected_values, actual_values);
}
TEST(VariableWidthWriteRead, VariedNumbersChunkLength8) {
const std::vector<uint64_t> expected_values = {1000, 0, 255, 4294967296};
const size_t kExpectedNumBits = 9 * (2 + 1 + 1 + 5);
BitWriterWord64 writer;
for (uint64_t val : expected_values) {
writer.WriteVariableWidthU64(val, 8);
}
EXPECT_EQ(kExpectedNumBits, writer.GetNumBits());
std::vector<uint64_t> actual_values;
BitReaderWord64 reader(writer.GetDataCopy());
while (!reader.OnlyZeroesLeft()) {
uint64_t val = 0;
ASSERT_TRUE(reader.ReadVariableWidthU64(&val, 8));
actual_values.push_back(val);
}
EXPECT_EQ(expected_values, actual_values);
}
TEST(FixedWidthWrite, Val0Max3) {
BitWriterStringStream writer;
writer.WriteFixedWidth(0, 3);
EXPECT_EQ("00", writer.GetStreamRaw());
}
TEST(FixedWidthWrite, Val0Max5) {
BitWriterStringStream writer;
writer.WriteFixedWidth(0, 5);
EXPECT_EQ("000", writer.GetStreamRaw());
}
TEST(FixedWidthWrite, Val0Max255) {
BitWriterStringStream writer;
writer.WriteFixedWidth(0, 255);
EXPECT_EQ("00000000", writer.GetStreamRaw());
}
TEST(FixedWidthWrite, Val3Max8) {
BitWriterStringStream writer;
writer.WriteFixedWidth(3, 8);
EXPECT_EQ("1100", writer.GetStreamRaw());
}
TEST(FixedWidthWrite, Val15Max127) {
BitWriterStringStream writer;
writer.WriteFixedWidth(15, 127);
EXPECT_EQ("1111000", writer.GetStreamRaw());
}
TEST(FixedWidthRead, Val0Max3) {
BitReaderFromString reader("0011111");
uint64_t val = 0;
ASSERT_TRUE(reader.ReadFixedWidth(&val, 3));
EXPECT_EQ(0u, val);
}
TEST(FixedWidthRead, Val0Max5) {
BitReaderFromString reader("0001010101");
uint64_t val = 0;
ASSERT_TRUE(reader.ReadFixedWidth(&val, 5));
EXPECT_EQ(0u, val);
}
TEST(FixedWidthRead, Val3Max8) {
BitReaderFromString reader("11001010101");
uint64_t val = 0;
ASSERT_TRUE(reader.ReadFixedWidth(&val, 8));
EXPECT_EQ(3u, val);
}
TEST(FixedWidthRead, Val15Max127) {
BitReaderFromString reader("111100010101");
uint64_t val = 0;
ASSERT_TRUE(reader.ReadFixedWidth(&val, 127));
EXPECT_EQ(15u, val);
}
TEST(FixedWidthRead, Fail) {
BitReaderFromString reader("111100");
uint64_t val = 0;
ASSERT_FALSE(reader.ReadFixedWidth(&val, 127));
}
} // anonymous namespace
| [
"hgplan@126.com"
] | hgplan@126.com |
9bd26801d13b415d2d59ed94bbc2495fd20707c8 | a6763d77afa4dcae5a49a05c43369d9f28010154 | /Jeu_BenHamou_Gueguen/ObjetTest.cpp | 8570e37c59ece34fa91bcdc1a81a50b86ebfcde8 | [] | no_license | hocine2725/JeuCpp | de356a5d8d8037e2b51c62ca5d812177cb235429 | cdb4be6075b5275cf9a275be4ef41e0cf3edc138 | refs/heads/master | 2023-05-25T02:49:08.633294 | 2021-06-12T21:30:11 | 2021-06-12T21:30:11 | 367,415,818 | 0 | 1 | null | 2021-05-21T18:19:55 | 2021-05-14T16:09:01 | C++ | UTF-8 | C++ | false | false | 458 | cpp | #include "catch.hpp"
//Ou si installé par la distribution : #include <catch2/catch.hpp>
#include "Objet.hpp"
TEST_CASE( "test objet", "[objet]" ) {
Objet arme(1, 200, 150);
REQUIRE(arme.getRamasse() == false);
arme.setRamasse(true);
REQUIRE(arme.getRamasse() == true);
// on verifie que linitialisation fonctionne
REQUIRE(arme.getClip().w==46);
// ca se met a zéro
arme.set();
REQUIRE(arme.getClip().w==0);
} | [
"melenn44@gmail.com"
] | melenn44@gmail.com |
96eb49a3f9e787ec79c8342398124aa5209ba9cf | 08bdd164c174d24e69be25bf952322b84573f216 | /opencores/client/foundation classes/j2sdk-1_4_2-src-scsl/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 973a272925ba673666bd29054f52753efbd84e48 | [] | no_license | hagyhang/myforthprocessor | 1861dcabcf2aeccf0ab49791f510863d97d89a77 | 210083fe71c39fa5d92f1f1acb62392a7f77aa9e | refs/heads/master | 2021-05-28T01:42:50.538428 | 2014-07-17T14:14:33 | 2014-07-17T14:14:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 94,196 | cpp | #ifdef USE_PRAGMA_IDENT_SRC
#pragma ident "@(#)c1_GraphBuilder.cpp 1.198 03/01/23 11:54:00 JVM"
#endif
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
#include "incls/_precompiled.incl"
#include "incls/_c1_GraphBuilder.cpp.incl"
// Implementation of BlockListBuilder
BlockBegin* BlockListBuilder::new_block_at(int bci, BlockBegin::Flag f) {
BlockBegin* b = _bci2block->at(bci);
if (b == NULL) {
b = new BlockBegin(bci);
_bci2block->at_put(bci, b);
}
// make sure all flags are accumulated
b->set(f);
return b;
}
void BlockListBuilder::set_leaders() {
ciBytecodeStream s(method());
while (s.next() >= 0) {
switch (s.code()) {
case Bytecodes::_ifeq : // fall through
case Bytecodes::_ifne : // fall through
case Bytecodes::_iflt : // fall through
case Bytecodes::_ifge : // fall through
case Bytecodes::_ifgt : // fall through
case Bytecodes::_ifle : // fall through
case Bytecodes::_if_icmpeq : // fall through
case Bytecodes::_if_icmpne : // fall through
case Bytecodes::_if_icmplt : // fall through
case Bytecodes::_if_icmpge : // fall through
case Bytecodes::_if_icmpgt : // fall through
case Bytecodes::_if_icmple : // fall through
case Bytecodes::_if_acmpeq : // fall through
case Bytecodes::_if_acmpne : // fall through
case Bytecodes::_ifnull : // fall through
case Bytecodes::_ifnonnull :
new_block_at(s.dest());
new_block_at(s.next_bci());
break;
case Bytecodes::_goto :
new_block_at(s.dest());
break;
case Bytecodes::_jsr :
new_block_at(s.dest(), BlockBegin::subroutine_entry_flag);
break;
case Bytecodes::_tableswitch :
{ Bytecode_tableswitch *switch_ = Bytecode_tableswitch_at(s.bcp());
// set block for each case
int l = switch_->length();
for (int i = 0; i < l; i++) new_block_at(s.bci() + switch_->dest_offset_at(i));
// set default block
new_block_at(s.bci() + switch_->default_offset());
}
break;
case Bytecodes::_lookupswitch:
{ Bytecode_lookupswitch *switch_ = Bytecode_lookupswitch_at(s.bcp());
// set block for each case
int l = switch_->number_of_pairs();
for (int i = 0; i < l; i++) new_block_at(s.bci() + switch_->pair_at(i)->offset());
// set default block
new_block_at(s.bci() + switch_->default_offset());
}
break;
case Bytecodes::_goto_w :
new_block_at(s.dest_w());
break;
case Bytecodes::_jsr_w :
new_block_at(s.dest_w(), BlockBegin::subroutine_entry_flag);
break;
default :
// nothing to do
break;
}
}
}
void BlockListBuilder::set_xhandler_entries() {
XHandlers* list = xhandlers();
const int n = list->number_of_handlers();
for (int i = 0; i < n; i++) {
XHandler* h = list->handler_at(i);
h->set_entry(new_block_at(h->handler_bci(), BlockBegin::exception_entry_flag));
}
}
BlockListBuilder::BlockListBuilder(IRScope* scope, int osr_bci, bool generate_std_entry) {
_scope = scope;
_bci2block = new BlockList(method()->code_size(), NULL);
set_leaders();
set_xhandler_entries();
if (generate_std_entry) {
_std_entry = new_block_at(0, BlockBegin::std_entry_flag);
}
_osr_entry = (osr_bci >= 0 ? new_block_at(osr_bci, BlockBegin::osr_entry_flag) : NULL);
}
// Implementation of GraphBuilder's ScopeData
GraphBuilder::ScopeData::ScopeData(ScopeData* parent)
: _parent(parent)
, _bci2block(NULL)
, _scope(NULL)
, _has_handler(false)
, _stream(NULL)
, _work_list(NULL)
, _parsing_jsr(false)
, _jsr_xhandlers(NULL)
, _caller_stack_size(-1)
, _continuation(NULL)
, _num_returns(0)
, _cleanup_block(NULL)
, _cleanup_return_prev(NULL)
, _cleanup_state(NULL)
{
if (parent != NULL) {
_max_inline_size = (intx) ((float) NestedInliningSizeRatio * (float) parent->max_inline_size() / 100.0f);
} else {
_max_inline_size = MaxInlineSize;
}
if (_max_inline_size < MaxTrivialSize) {
_max_inline_size = MaxTrivialSize;
}
}
BlockBegin* GraphBuilder::ScopeData::block_at(int bci) {
if (parsing_jsr()) {
// It is necessary to clone all blocks associated with a
// subroutine, including those for exception handlers in the scope
// of the method containing the jsr (because those exception
// handlers may contain ret instructions in some cases).
BlockBegin* block = bci2block()->at(bci);
if (block != NULL && block == parent()->bci2block()->at(bci)) {
BlockBegin* new_block = new BlockBegin(block->bci());
// Preserve certain flags for assertion checking
if (block->is_set(BlockBegin::subroutine_entry_flag)) new_block->set(BlockBegin::subroutine_entry_flag);
if (block->is_set(BlockBegin::exception_entry_flag)) new_block->set(BlockBegin::exception_entry_flag);
bci2block()->at_put(bci, new_block);
block = new_block;
}
return block;
} else {
return bci2block()->at(bci);
}
}
XHandlers* GraphBuilder::ScopeData::xhandlers() const {
if (_jsr_xhandlers == NULL) {
assert(!parsing_jsr(), "");
return scope()->xhandlers();
}
assert(parsing_jsr(), "");
return _jsr_xhandlers;
}
void GraphBuilder::ScopeData::set_scope(IRScope* scope) {
_scope = scope;
bool parent_has_handler = false;
if (parent() != NULL) {
parent_has_handler = parent()->has_handler();
}
_has_handler = parent_has_handler || scope->xhandlers()->has_handlers();
}
void GraphBuilder::ScopeData::set_inline_cleanup_info(BlockBegin* block,
Instruction* return_prev,
ValueStack* return_state) {
_cleanup_block = block;
_cleanup_return_prev = return_prev;
_cleanup_state = return_state;
}
void GraphBuilder::ScopeData::add_to_work_list(BlockBegin* block) {
if (_work_list == NULL) {
_work_list = new BlockList();
}
if (!block->is_set(BlockBegin::is_on_work_list_flag)) {
// Do not start parsing the continuation block while in a
// sub-scope
if (parsing_jsr()) {
if (block == jsr_continuation()) {
return;
}
} else {
if (block == continuation()) {
return;
}
}
block->set(BlockBegin::is_on_work_list_flag);
_work_list->push(block);
}
}
int GraphBuilder::ScopeData::caller_stack_size() const {
ValueStack* state = scope()->caller_state();
if (state == NULL) {
return 0;
}
return state->stack_size();
}
BlockBegin* GraphBuilder::ScopeData::remove_from_work_list() {
if (is_work_list_empty()) {
return NULL;
}
return _work_list->pop();
}
bool GraphBuilder::ScopeData::is_work_list_empty() const {
return (_work_list == NULL || _work_list->length() == 0);
}
void GraphBuilder::ScopeData::setup_jsr_xhandlers() {
assert(parsing_jsr(), "");
XHandlers* handlers = new XHandlers(scope()->method());
const int n = handlers->number_of_handlers();
for (int i = 0; i < n; i++) {
XHandler* h = handlers->handler_at(i);
h->set_entry(block_at(h->handler_bci()));
}
_jsr_xhandlers = handlers;
}
int GraphBuilder::ScopeData::num_returns() {
if (parsing_jsr()) {
return parent()->num_returns();
}
return _num_returns;
}
void GraphBuilder::ScopeData::incr_num_returns() {
if (parsing_jsr()) {
parent()->incr_num_returns();
} else {
++_num_returns;
}
}
// Implementation of GraphBuilder
#define BAILOUT(msg) { bailout(msg); return; }
#define BAILOUT_(msg, res) { bailout(msg); return res; }
#define INLINE_BAILOUT(msg) { inline_bailout(msg); return false; }
void GraphBuilder::load_constant() {
ciConstant con = stream()->get_constant();
if (con.basic_type() == T_ILLEGAL) {
BAILOUT("could not resolve a constant");
} else {
ValueType* t = illegalType;
switch (con.basic_type()) {
case T_BOOLEAN: t = new IntConstant (con.as_boolean()); break;
case T_BYTE : t = new IntConstant (con.as_byte ()); break;
case T_CHAR : t = new IntConstant (con.as_char ()); break;
case T_SHORT : t = new IntConstant (con.as_short ()); break;
case T_INT : t = new IntConstant (con.as_int ()); break;
case T_LONG : t = new LongConstant (con.as_long ()); break;
case T_FLOAT : t = new FloatConstant (con.as_float ()); break;
case T_DOUBLE : t = new DoubleConstant (con.as_double ()); break;
case T_ARRAY : t = new ArrayConstant (con.as_object ()->as_array ()); break;
case T_OBJECT : t = new InstanceConstant(con.as_object ()->as_instance()); break;
default : ShouldNotReachHere();
}
push(t, append(new Constant(t)));
}
}
void GraphBuilder::load_local(ValueType* type, int index) {
Value x = NULL;
if (EliminateLoads) x = state()->load_local(index);
if (x != NULL) {
if (PrintLoadElimination) tty->print_cr("load local %d eliminated @ %d", index, bci());
} else {
x = append(new LoadLocal(scope()->local_at(type, index, true)));
state()->store_local(index, x);
if (EliminateStores) state()->clear_store(index);
}
push(type, x);
}
void GraphBuilder::store_local(ValueType* type, int index) {
Value x = pop(type);
store_local(state(), x, type, index, false);
}
void GraphBuilder::store_local(ValueStack* state, Value x, ValueType* type, int index, bool is_inline_argument) {
if (parsing_jsr()) {
// We need to do additional tracking of the location of the return
// address for jsrs since we don't handle arbitrary jsr/ret
// constructs. Here we are figuring out in which circumstances we
// need to bail out.
if (x->type()->is_address()) {
scope_data()->set_jsr_return_address_local(index);
// Also check parent jsrs (if any) at this time to see whether
// they are using this local. We don't handle skipping over a
// ret.
for (ScopeData* cur_scope_data = scope_data()->parent();
cur_scope_data != NULL && cur_scope_data->parsing_jsr() && cur_scope_data->scope() == scope();
cur_scope_data = cur_scope_data->parent()) {
if (cur_scope_data->jsr_return_address_local() == index) {
BAILOUT("subroutine overwrites return address from previous subroutine");
}
}
} else if (index == scope_data()->jsr_return_address_local()) {
scope_data()->set_jsr_return_address_local(-1);
}
}
// Supports storing across scopes for full inliner.
// astore may also be used to store the return address of a jsr, so
// make sure to get the type right, otherwise local will be mistyped
if (type->is_object() && x->type()->is_address()) {
type = x->type();
}
// because of Java FPU semantics, float and doubles must be rounded
// when storing them => kill them instead of keeping the result if
// the CPU does not provide correctly rounded results in general
if (RoundFloatsWithStore && type->is_float_kind()) {
state->kill_local(index);
} else {
state->store_local(index, x);
}
StoreLocal* store = new StoreLocal(state->scope()->local_at(type, index, true), x, is_inline_argument);
append(store);
if (EliminateStores) {
state->store_local(store, bci());
}
// make sure any outstanding loads are executed before
state->pin_stack_locals(index);
if (type->is_double_word()) state->pin_stack_locals(index + 1);
}
void GraphBuilder::load_indexed(BasicType type) {
Value index = ipop();
Value array = apop();
Value length = NULL;
if (CSEArrayLength) {
length = append(new ArrayLength(array, lock_stack()));
}
push(as_ValueType(type), append(new LoadIndexed(array, index, length, type, lock_stack())));
}
void GraphBuilder::store_indexed(BasicType type) {
Value value = pop(as_ValueType(type));
Value index = ipop();
Value array = apop();
Value length = NULL;
if (CSEArrayLength) {
length = append(new ArrayLength(array, lock_stack()));
}
StoreIndexed* result = new StoreIndexed(array, index, length, type, value, lock_stack());
vmap()->kill_array(value->type()); // invalidate all CSEs that are memory accesses
state()->pin_stack_indexed(value->type());
append(result);
}
void GraphBuilder::stack_op(Bytecodes::Code code) {
switch (code) {
case Bytecodes::_pop:
{ state()->raw_pop();
}
break;
case Bytecodes::_pop2:
{ state()->raw_pop();
state()->raw_pop();
}
break;
case Bytecodes::_dup:
{ Value w = state()->raw_pop();
state()->raw_push(w);
state()->raw_push(w);
}
break;
case Bytecodes::_dup_x1:
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
state()->raw_push(w1);
state()->raw_push(w2);
state()->raw_push(w1);
}
break;
case Bytecodes::_dup_x2:
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
Value w3 = state()->raw_pop();
state()->raw_push(w1);
state()->raw_push(w3);
state()->raw_push(w2);
state()->raw_push(w1);
}
break;
case Bytecodes::_dup2:
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
state()->raw_push(w2);
state()->raw_push(w1);
state()->raw_push(w2);
state()->raw_push(w1);
}
break;
case Bytecodes::_dup2_x1:
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
Value w3 = state()->raw_pop();
state()->raw_push(w2);
state()->raw_push(w1);
state()->raw_push(w3);
state()->raw_push(w2);
state()->raw_push(w1);
}
break;
case Bytecodes::_dup2_x2:
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
Value w3 = state()->raw_pop();
Value w4 = state()->raw_pop();
state()->raw_push(w2);
state()->raw_push(w1);
state()->raw_push(w4);
state()->raw_push(w3);
state()->raw_push(w2);
state()->raw_push(w1);
}
break;
case Bytecodes::_swap:
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
state()->raw_push(w1);
state()->raw_push(w2);
}
break;
default:
ShouldNotReachHere();
break;
}
}
void GraphBuilder::arithmetic_op(ValueType* type, Bytecodes::Code code, ValueStack* stack) {
Value y = pop(type);
Value x = pop(type);
// NOTE: strictfp can be queried from current method since we don't
// inline methods with differing strictfp bits
push(type, append(new ArithmeticOp(code, x, y, method()->is_strict(), stack)));
}
void GraphBuilder::negate_op(ValueType* type) {
push(type, append(new NegateOp(pop(type))));
}
void GraphBuilder::shift_op(ValueType* type, Bytecodes::Code code) {
Value s = ipop();
Value x = pop(type);
// try to simplify
// Note: This code should go into the canonicalizer as soon as it can
// can handle canonicalized forms that contain more than one node.
if (CanonicalizeNodes && code == Bytecodes::_iushr) {
// pattern: x >>> s
IntConstant* s1 = s->type()->as_IntConstant();
if (s1 != NULL) {
// pattern: x >>> s1, with s1 constant
ShiftOp* l = x->as_ShiftOp();
if (l != NULL && l->op() == Bytecodes::_ishl) {
// pattern: (a << b) >>> s1
IntConstant* s0 = l->y()->type()->as_IntConstant();
if (s0 != NULL) {
// pattern: (a << s0) >>> s1
const int s0c = s0->value() & 0x1F; // only the low 5 bits are significant for shifts
const int s1c = s1->value() & 0x1F; // only the low 5 bits are significant for shifts
if (s0c == s1c) {
if (s0c == 0) {
// pattern: (a << 0) >>> 0 => simplify to: a
ipush(l->x());
} else {
// pattern: (a << s0c) >>> s0c => simplify to: a & m, with m constant
assert(0 < s0c && s0c < BitsPerInt, "adjust code below to handle corner cases");
const int m = (1 << (BitsPerInt - s0c)) - 1;
Value s = append(new Constant(new IntConstant(m)));
ipush(append(new LogicOp(Bytecodes::_iand, l->x(), s)));
}
return;
}
}
}
}
}
// could not simplify
push(type, append(new ShiftOp(code, x, s)));
}
void GraphBuilder::logic_op(ValueType* type, Bytecodes::Code code) {
Value y = pop(type);
Value x = pop(type);
push(type, append(new LogicOp(code, x, y)));
}
void GraphBuilder::compare_op(ValueType* type, Bytecodes::Code code) {
ValueStack* state_before = state()->copy();
Value y = pop(type);
Value x = pop(type);
ipush(append(new CompareOp(code, x, y, state_before)));
}
void GraphBuilder::convert(Bytecodes::Code op, BasicType from, BasicType to) {
push(as_ValueType(to), append(new Convert(op, pop(as_ValueType(from)), as_ValueType(to))));
}
void GraphBuilder::increment() {
int index = stream()->get_index();
int delta = stream()->is_wide() ? (signed short)Bytes::get_Java_u2(stream()->bcp() + 4) : (signed char)(stream()->bcp()[2]);
load_local(intType, index);
ipush(append(new Constant(new IntConstant(delta))));
arithmetic_op(intType, Bytecodes::_iadd);
store_local(intType, index);
}
void GraphBuilder::if_node(Value x, If::Condition cond, Value y, ValueStack* state_before) {
BlockBegin* tsux = block_at(stream()->dest());
BlockBegin* fsux = block_at(stream()->next_bci());
bool is_bb = tsux->bci() < stream()->bci() || fsux->bci() < stream()->bci();
append(new If(x, cond, false, y, tsux, fsux, state_before, is_bb));
}
void GraphBuilder::if_zero(ValueType* type, If::Condition cond) {
Value y = append(new Constant(intZero));
ValueStack* state_before = state()->copy();
Value x = ipop();
if_node(x, cond, y, state_before);
}
void GraphBuilder::if_null(ValueType* type, If::Condition cond) {
Value y = append(new Constant(objectNull));
ValueStack* state_before = state()->copy();
Value x = apop();
if_node(x, cond, y, state_before);
}
void GraphBuilder::if_same(ValueType* type, If::Condition cond) {
ValueStack* state_before = state()->copy();
Value y = pop(type);
Value x = pop(type);
if_node(x, cond, y, state_before);
}
void GraphBuilder::jsr(int dest) {
// We only handle well-formed jsrs (those which are "block-structured").
// If the bytecodes are strange (jumping out of a jsr block) then we
// might end up trying to re-parse a block containing a jsr which
// has already been activated. Watch for this case and bail out.
for (ScopeData* cur_scope_data = scope_data();
cur_scope_data != NULL && cur_scope_data->parsing_jsr() && cur_scope_data->scope() == scope();
cur_scope_data = cur_scope_data->parent()) {
if (cur_scope_data->jsr_entry_bci() == dest) {
BAILOUT("too-complicated jsr/ret structure");
}
}
push(addressType, append(new Constant(new AddressConstant(next_bci()))));
if (!try_inline_jsr(dest)) {
return; // bailed out while parsing and inlining subroutine
}
}
void GraphBuilder::ret(int local_index) {
if (!parsing_jsr()) BAILOUT("ret encountered while not parsing subroutine");
if (local_index != scope_data()->jsr_return_address_local()) {
BAILOUT("can not handle complicated jsr/ret constructs");
}
// Rets simply become (NON-SAFEPOINT) gotos to the jsr continuation
append(new Goto(scope_data()->jsr_continuation(), false));
}
void GraphBuilder::table_switch() {
Bytecode_tableswitch* switch_ = Bytecode_tableswitch_at(method()->code() + bci());
const int l = switch_->length();
if (CanonicalizeNodes && l == 1) {
// total of 2 successors => use If instead of switch
// Note: This code should go into the canonicalizer as soon as it can
// can handle canonicalized forms that contain more than one node.
Value key = append(new Constant(new IntConstant(switch_->low_key())));
BlockBegin* tsux = block_at(bci() + switch_->dest_offset_at(0));
BlockBegin* fsux = block_at(bci() + switch_->default_offset());
ValueStack* state_before = state();
bool is_bb = tsux->bci() < bci() || fsux->bci() < bci();
append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb));
} else {
// collect successors
BlockList* sux = new BlockList(l + 1, NULL);
int i;
bool has_bb = false;
for (i = 0; i < l; i++) {
sux->at_put(i, block_at(bci() + switch_->dest_offset_at(i)));
if (switch_->dest_offset_at(i) < 0) has_bb = true;
}
// add default successor
sux->at_put(i, block_at(bci() + switch_->default_offset()));
ValueStack* state_before = state();
append(new TableSwitch(ipop(), sux, switch_->low_key(), state_before, has_bb));
}
}
void GraphBuilder::lookup_switch() {
Bytecode_lookupswitch* switch_ = Bytecode_lookupswitch_at(method()->code() + bci());
const int l = switch_->number_of_pairs();
if (CanonicalizeNodes && l == 1) {
// total of 2 successors => use If instead of switch
// Note: This code should go into the canonicalizer as soon as it can
// can handle canonicalized forms that contain more than one node.
// simplify to If
LookupswitchPair* pair = switch_->pair_at(0);
Value key = append(new Constant(new IntConstant(pair->match())));
BlockBegin* tsux = block_at(bci() + pair->offset());
BlockBegin* fsux = block_at(bci() + switch_->default_offset());
ValueStack* state_before = state();
bool is_bb = tsux->bci() < bci() || fsux->bci() < bci();
append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb));
} else {
// collect successors & keys
BlockList* sux = new BlockList(l + 1, NULL);
intArray* keys = new intArray(l, 0);
int i;
bool has_bb = false;
for (i = 0; i < l; i++) {
LookupswitchPair* pair = switch_->pair_at(i);
if (pair->offset() < 0) has_bb = true;
sux->at_put(i, block_at(bci() + pair->offset()));
keys->at_put(i, pair->match());
}
// add default successor
sux->at_put(i, block_at(bci() + switch_->default_offset()));
ValueStack* state_before = state();
append(new LookupSwitch(ipop(), sux, keys, state_before, has_bb));
}
}
void GraphBuilder::method_return(Value x) {
// Check to see whether we are inlining. If so, Return
// instructions become Gotos to the continuation point.
if (continuation() != NULL) {
assert(!method()->is_synchronized(), "can not inline synchronized methods yet");
state()->truncate_stack(caller_stack_size());
if (x != NULL) {
// Must pin return value so any LoadLocals from the arguments
// are consumed before we return and potentially overwrite a
// local with an argument for a successive inlined invocation.
x->pin(Instruction::PinInlineReturnValue);
state()->push(x->type(), x);
}
Goto* goto_callee = new Goto(continuation(), false);
// See whether this is the first return; if so, store off some
// of the state for later examination
if (num_returns() == 0) {
set_inline_cleanup_info(_block, _last, state());
}
append(goto_callee);
incr_num_returns();
return;
}
int index = method()->is_synchronized() ? state()->unlock() : -1;
append(new Return(x, index));
}
void GraphBuilder::access_field(Bytecodes::Code code) {
ciField* field = stream()->get_field();
ciInstanceKlass* holder = field->holder();
BasicType field_type = field->type()->basic_type();
ValueType* type = as_ValueType(field_type);
// call to will_link may cause class loading: do not call it if holder is not loaded
const bool is_loaded = holder->is_loaded() && field->will_link(method()->holder(), code);
const bool is_initialized = is_loaded && holder->is_initialized() && !PatchALot;
Value obj = NULL;
if (code == Bytecodes::_getstatic || code == Bytecodes::_putstatic) {
// commoning of class constants should only occur if the class is
// fully initialized and resolved in this constant pool. The will_link test
// above essentially checks if this class is resolved in this constant pool
// so, the is_initialized flag should be suffiect.
obj = new Constant(new ClassConstant(holder), is_initialized);
}
ValueStack* state_copy = NULL;
if (!is_initialized) {
// make sure all values on stack get spilled in case deoptimization happens
state()->pin_stack_all(Instruction::PinUninitialized);
if (EliminateStores) {
// make sure all pending stores get executed so that the oops maps are correct
state()->clear_stores();
}
// save state before instruction for debug info when deoptimization happens during patching
state_copy = state()->copy();
}
const int offset = is_loaded ? field->offset() : -1;
AccessField* result = NULL;
switch (code) {
case Bytecodes::_getstatic:
// make sure klass is initialized, bailout otherwise
if (!LateBailout && !is_initialized) BAILOUT("klass not initialized for getstatic");
// check for compile-time constants, i.e., initialized static final fields
if (field->is_constant() && !PatchALot) {
push(type, append(new Constant(as_ValueType(field->constant_value()))));
state_copy = NULL; // Not a potential deoptimization point (see set_state_before logic below)
} else {
push(type, append(result = new LoadField(append(obj), offset, field, true, lock_stack(), is_loaded, is_initialized)));
}
break;
case Bytecodes::_putstatic:
// make sure klass is initialized, bailout otherwise
if (!LateBailout && !is_initialized) BAILOUT("klass not initialized for putstatic");
{ Value val = pop(type);
append(result = new StoreField(append(obj), offset, field, val, true, lock_stack(), is_loaded, is_initialized));
vmap()->kill_field(field); // invalidate all CSEs that are memory accesses
state()->pin_stack_fields(field); // make sure any outstanding loads are executed before (conservative)
}
break;
case Bytecodes::_getfield :
push(type, append(result = new LoadField(apop(), offset, field, false, lock_stack(), is_loaded, true)));
break;
case Bytecodes::_putfield :
{ Value val = pop(type);
append(result = new StoreField(apop(), offset, field, val, false, lock_stack(), is_loaded, true));
vmap()->kill_field(field); // invalidate all CSEs that are memory accesses
state()->pin_stack_fields(field); // make sure any outstanding loads are executed before (conservative)
}
break;
default :
ShouldNotReachHere();
break;
}
if (state_copy != NULL) {
assert(result != NULL, "result must exist for non-initialized access");
result->set_state_before(state_copy);
}
}
void GraphBuilder::add_dependent(ciInstanceKlass* klass, ciMethod* method) {
compilation()->set_needs_debug_information(true);
scope()->add_dependent(klass, method);
}
void GraphBuilder::invoke(Bytecodes::Code code) {
ciMethod* target = stream()->get_method();
// we have to make sure the argument size (incl. the receiver)
// is correct for compilation (the call would fail later during
// linkage anyway) - was bug (gri 7/28/99)
if (target->is_loaded() && target->is_static() != (code == Bytecodes::_invokestatic)) BAILOUT("will cause link error");
ciInstanceKlass* klass = target->holder();
// check if CHA possible: if so, change the code to invoke_special
ciInstanceKlass* calling_klass = method()->holder();
ciInstanceKlass* callee_holder = stream()->get_declared_method_holder();
ciInstanceKlass* actual_recv = callee_holder; // currently not possible to be more precise
NEEDS_CLEANUP
// I've added the target-is_loaded() test below but I don't really understand
// how klass->is_loaded() can be true and yet target->is_loaded() is false.
// this happened while running the JCK invokevirtual tests under doit. TKR
ciMethod* cha_monomorphic_target = UseCHA && DeoptC1 && klass->is_loaded() && klass->is_initialized() && code == Bytecodes::_invokevirtual && target->is_loaded()
? target->find_monomorphic_target(calling_klass, callee_holder, actual_recv)
: NULL;
if (cha_monomorphic_target != NULL) {
if (cha_monomorphic_target->is_abstract()) {
// Do not optimize for abstract methods
cha_monomorphic_target = NULL;
}
}
bool dependency_recorded = false;
if (cha_monomorphic_target != NULL) {
if (!(target->is_final_method())) {
// If we inlined because CHA revealed only a single target method,
// then we are dependent on that target method not getting overridden
// by dynamic class loading. Be sure to test the "static" receiver
// dest_method here, as opposed to the actual receiver, which may
// falsely lead us to believe that the receiver is final or private.
add_dependent(actual_recv, cha_monomorphic_target);
code = Bytecodes::_invokespecial;
dependency_recorded = true;
}
}
// check if we could do inlining
if (!PatchALot && Inline && klass->is_loaded() && klass->is_initialized()
&& target->will_link(klass, callee_holder, code)) {
// callee is known => check if we have static binding
assert(target->is_loaded(), "callee must be known");
if (code == Bytecodes::_invokestatic
|| code == Bytecodes::_invokespecial
|| code == Bytecodes::_invokevirtual && target->is_final_method()
) {
// static binding => check if callee is ok
ciMethod* inline_target = (cha_monomorphic_target != NULL)
? cha_monomorphic_target
: target;
bool res = try_inline(inline_target);
#ifndef PRODUCT
// printing
if (PrintInlining) {
print_inline_result(inline_target, res);
}
#endif
clear_inline_bailout();
if (res) {
// Always register dependence if JVMDI is enabled, because
// either breakpoint setting or hotswapping of methods may
// cause deoptimization.
if (jvmdi::enabled() && FullSpeedJVMDI && !dependency_recorded) {
add_dependent(actual_recv, inline_target);
}
return;
}
}
}
// If we attempted an inline which did not succeed because of a
// bailout during construction of the callee graph, the entire
// compilation has to be aborted. This is fairly rare and currently
// seems to only occur for jasm-generated classes which contain
// jsr/ret pairs which are not associated with finally clauses and
// do not have exception handlers in the containing method, and are
// therefore not caught early enough to abort the inlining without
// corrupting the graph. (We currently bail out with a non-empty
// stack at a ret in these situations.)
if (bailed_out()) return;
// inlining not successful => standard invoke
bool is_static = code == Bytecodes::_invokestatic;
ValueType* result_type = as_ValueType(target->return_type());
Values* args = state()->pop_arguments(target->arg_size_no_receiver());
Value recv = is_static ? NULL : apop();
Invoke* result = new Invoke(code, result_type, recv, args, target->is_loaded() && target->is_final_method(), target->is_loaded(), target->is_loaded() && target->is_strict());
// push result
append_split(result);
if (result_type != voidType) push(result_type, result);
}
void GraphBuilder::new_instance(int klass_index) {
ciKlass* klass = stream()->get_klass();
assert(klass->is_instance_klass(), "must be an instance klass");
apush(append_split(new NewInstance(klass->as_instance_klass())));
}
void GraphBuilder::new_type_array() {
apush(append_split(new NewTypeArray(ipop(), (BasicType)stream()->get_index())));
}
void GraphBuilder::new_object_array() {
ciKlass* klass = stream()->get_klass();
ValueStack* state_before = !klass->is_loaded() || PatchALot ? state()->copy() : NULL;
NewArray* n = new NewObjectArray(klass, ipop());
n->set_state_before(state_before); // for patching
apush(append_split(n));
}
bool GraphBuilder::direct_compare(ciKlass* k) {
if (k->is_loaded() && k->is_instance_klass() && !UseSlowPath) {
ciInstanceKlass* ik = k->as_instance_klass();
if (ik->is_final()) {
return true;
} else {
if (DeoptC1 && UseCHA && !(ik->has_subklass() || ik->flags().is_interface())) {
// test class is leaf class
add_dependent(ik, NULL);
return true;
}
}
}
return false;
}
void GraphBuilder::check_cast(int klass_index) {
ciKlass* klass = stream()->get_klass();
ValueStack* state_before = !klass->is_loaded() || PatchALot ? state()->copy() : NULL;
CheckCast* c = new CheckCast(klass, apop());
c->set_state_before(state_before); // for patching
apush(append_split(c));
c->set_direct_compare(direct_compare(klass));
}
void GraphBuilder::instance_of(int klass_index) {
ciKlass* klass = stream()->get_klass();
ValueStack* state_before = !klass->is_loaded() || PatchALot ? state()->copy() : NULL;
InstanceOf* i = new InstanceOf(klass, apop());
i->set_state_before(state_before); // for patching
ipush(append_split(i));
i->set_direct_compare(direct_compare(klass));
}
void GraphBuilder::monitorenter(Value x) {
// save state before locking in case of deoptimization after a NullPointerException
ValueStack* lock_stack_before = lock_stack();
append_split(new MonitorEnter(x, state()->lock(scope(), x), lock_stack_before));
}
void GraphBuilder::monitorexit(Value x) {
// Note: the comment below is only relevant for the case where we do
// not deoptimize due to asynchronous exceptions (!(DeoptC1 &&
// DeoptOnAsyncException), which is not used anymore)
// Note: Potentially, the monitor state in an exception handler
// can be wrong due to wrong 'initialization' of the handler
// via a wrong asynchronous exception path. This can happen,
// if the exception handler range for asynchronous exceptions
// is too long (see also java bug 4327029, and comment in
// GraphBuilder::handle_exception()). This may cause 'under-
// flow' of the monitor stack => bailout instead.
if (state()->locks_size() < 1) BAILOUT("monitor stack underflow");
append_split(new MonitorExit(x, state()->unlock()));
}
void GraphBuilder::new_multi_array(int dimensions) {
ciKlass* klass = stream()->get_klass();
ValueStack* state_before = !klass->is_loaded() || PatchALot ? state()->copy() : NULL;
if (state_before != NULL) {
// make sure all values on stack get spilled in case deoptimization happens
state()->pin_stack_all(Instruction::PinUninitialized);
}
Values* dims = new Values(dimensions, NULL);
// fill in all dimensions
int i = dimensions;
while (i-- > 0) dims->at_put(i, ipop());
// create array
NewArray* n = new NewMultiArray(klass, dims);
n->set_state_before(state_before); // for patching
apush(append_split(n));
}
void GraphBuilder::throw_op() {
// We require that the debug info for a Throw be the "state before"
// the Throw (i.e., exception oop is still on TOS)
ValueStack* state_before = state()->copy();
Throw* t = new Throw(apop());
t->set_state_before(state_before);
append(t);
}
Instruction* GraphBuilder::append_base(Instruction* instr) {
Canonicalizer canon(instr, bci());
Instruction* i1 = canon.canonical();
Instruction* i2 = vmap()->find(i1);
// The canonicalizer may return instructions which are already linked into
// the instruction list and the only way to identify an instruction which
// hasn't been linked is to see if it has a bci.
if (i1 == i2 && i2->bci() == -1) {
// i1 was not eliminated => append it
assert(i2->next() == NULL, "shouldn't already be linked");
_last = _last->set_next(i2, canon.bci());
if (++_instruction_count >= InstructionCountCutoff) {
BAILOUT_("Method and/or inlining is too large", NULL);
}
#ifndef PRODUCT
if (PrintIRDuringConstruction) {
InstructionPrinter ip;
ip.print_line(i2);
}
#endif
assert(_last == i2, "adjust code below");
if (i2->as_StateSplit() != NULL && i2->as_BlockEnd() == NULL) {
StateSplit* s = i2->as_StateSplit();
assert(s != NULL, "s must exist");
// Continue load elimination and CSE across certain intrinsics
Intrinsic* intrinsic = s->as_Intrinsic();
if (intrinsic == NULL || !intrinsic->preserves_state()) {
if (s->as_Invoke() == NULL || !EliminateLoadsAcrossCalls) {
// if EliminateLoadsAcrossCalls is true and the StateSplit is an invoke,
// do not clear all locals
state()->clear_locals(); // for now, hopefully we need this only for calls eventually
}
vmap()->kill_all(); // for now, hopefully we need this only for calls eventually
}
state()->pin_stack_for_state_split();
s->set_state(state()->copy());
}
// set up exception handlers for this instruction if necessary
BlockEnd* be = i2->as_BlockEnd();
if (i2->can_trap() ||
(be != NULL && be->is_safepoint())) {
i2->set_exception_scope(exception_scope()->copy());
}
}
return i2;
}
Instruction* GraphBuilder::append(Instruction* instr) {
assert(instr->as_StateSplit() == NULL || instr->as_BlockEnd() != NULL, "wrong append used");
return append_base(instr);
}
Instruction* GraphBuilder::append_split(StateSplit* instr) {
return append_base(instr);
}
void GraphBuilder::bailout(const char* msg) {
assert(msg != NULL, "bailout msg must exist");
_bailout_msg = msg;
if (PrintBailouts) tty->print_cr(" Bailout reason: %s", msg);
}
void GraphBuilder::handle_exception(bool is_async) {
bool cleared_stores = false;
exception_scope()->clear();
int cur_bci = bci();
int num_state_pops_needed = 0;
ScopeData* cur_scope_data = scope_data();
ValueStack* s = state()->copy();
bool is_top_scope = true;
while (cur_scope_data != NULL) {
// join with all potential exception handlers
XHandlers* list = cur_scope_data->xhandlers();
const int n = list->number_of_handlers();
for (int i = 0; i < n; i++) {
XHandler* h = list->handler_at(i);
if (h->covers(cur_bci)) {
compilation()->set_has_exception_handlers(true);
if (EliminateStores) {
if (!cleared_stores) {
// Conservatively assume that the locals may be referenced by
// GC, etc. and therefore all stores beforehand need to take place
state()->clear_stores();
cleared_stores = true;
}
}
BlockBegin* entry = h->entry();
if (cur_scope_data->parsing_jsr()) {
// Exception handlers are inherited from parent scope; must
// grab duplicated block from our scope
entry = cur_scope_data->block_at(entry->bci());
}
assert(entry == cur_scope_data->block_at(h->handler_bci()), "blocks must correspond");
// h is a potential exception handler => join it
// Note: the comment below is only relevant for the case where
// we do not deoptimize due to asynchronous exceptions
// (!(DeoptC1 && DeoptOnAsyncException), which is not used
// anymore)
// Note: The code below is necessary since methods may have in-
// correct exception handler ranges for async. exceptions
// (this is the case for the current javac and some 3rd
// party javac's). In particular, the exception handler
// ranges may be too long, in which case an asynchronous
// exception will cause a control flow to the exception
// handler with the wrong monitor state (i.e., monitor
// already unlocked). If the graph builder tries to join
// the corresponding exception handler, it will fail with
// an assertion since the monitor stacks do not correspond,
// unless we do some extra checking beforehand.
//
// This problem showed up with java.lang.ref.Finalizer::add
// in J2SE 1.3 rc2 (see also bug 4324989: we forgot to add
// consider asynchronous exception handlers - after fixing
// that problem we encountered the javac problem 4327029).
if (entry->state() != NULL) {
if (state()->locks_size() != entry->state()->locks_size()) {
// trying to join the exception handler would fail with
// an assertion failure since the monitor stacks do not
// correspond
if (is_async) {
// assume exception handler range is wrong for
// asynchronous exception => simply ignore it
return;
} else {
// the monitor states may not match because of
// an asynchronous exception path that set up
// the handler monitor state wrongly before =>
// bailout since we don't know what is correct
BAILOUT("illegal monitor state");
}
}
}
// Note: Since locals are all NULL here & the expression
// stack is empty besides the dummy exception object
// we don't have to do a full & time consuming join
// if the exception handler was visited before
// => do it always only in debug mode
#ifndef ASSERT
if (!entry->is_set(BlockBegin::was_visited_flag)) {
#endif // ASSERT
// empty expression stack after exception
s->truncate_stack(cur_scope_data->caller_stack_size());
s->apush(new Constant(objectNull)); // but the exception oop is on the stack
// Note: Usually this join must work. However, very
// complicated jsr-ret structures where we don't ret from
// the subroutine can cause the objects on the monitor
// stacks to not match because blocks can be parsed twice.
// The only test case we've seen so far which exhibits this
// problem is caught by the infinite recursion test in
// GraphBuilder::jsr() if the join doesn't work.
if (!entry->try_join(s->copy())) {
BAILOUT("error while joining with exception handler, prob. due to complicated jsr/rets");
}
// fill in exception handler subgraph lazily
// Note: exception handlers for scopes other than the top
// scope have already been added to the work list (see
// management of the exception scope below)
cur_scope_data->add_to_work_list(entry);
#ifndef ASSERT
}
#endif // ASSERT
// add h to the list of exception handlers of this block
_block->add_exception_handler(entry);
if (is_top_scope) {
// Add h to the list of exception handlers covering this bci.
// Note: the management of exception scopes requires that we
// call handle_exception before entering an inlined scope
exception_scope()->add_handler(h);
}
// stop when reaching catchall
if (h->catch_type() == 0) return;
}
}
// Set up iteration for next time.
// If parsing a jsr, do not grab exception handlers from the
// parent scopes for this method (already got them, and they
// needed to be cloned)
is_top_scope = false;
if (cur_scope_data->parsing_jsr()) {
IRScope* tmp_scope = cur_scope_data->scope();
while (cur_scope_data->parent() != NULL &&
cur_scope_data->parent()->scope() == tmp_scope) {
cur_scope_data = cur_scope_data->parent();
}
}
if (cur_scope_data != NULL) {
if (cur_scope_data->parent() != NULL) {
s = s->pop_scope(false, cur_bci);
}
cur_bci = cur_scope_data->scope()->caller_bci();
cur_scope_data = cur_scope_data->parent();
}
}
}
BlockEnd* GraphBuilder::connect_to_end(BlockBegin* beg) {
// setup iteration
vmap()->kill_all();
_block = beg;
_state = beg->state()->copy();
_last = beg;
return iterate_bytecodes_for_block(beg->bci());
}
BlockEnd* GraphBuilder::iterate_bytecodes_for_block(int bci) {
#ifndef PRODUCT
if (PrintIRDuringConstruction) {
tty->cr();
InstructionPrinter ip;
ip.print_instr(_block); tty->cr();
ip.print_stack(_block->state()); tty->cr();
ip.print_inline_level(_block);
ip.print_head();
}
#endif
ciBytecodeStream s(method());
s.set_start(bci);
int prev_bci = bci;
scope_data()->set_stream(&s);
// iterate
Bytecodes::Code code = Bytecodes::_illegal;
bool prev_is_monitorenter = false;
while (!bailed_out() && last()->as_BlockEnd() == NULL && (code = stream()->next()) >= 0 && (block_at(s.bci()) == NULL || block_at(s.bci()) == block())) {
// handle potential exceptions thrown by current bytecode
// note 1: exceptions must be handled before the bytecode as
// the (locking) state before the bytecode is relevant
// in the exception handler (e.g. for monitorenter)
// note 2: if the previous bytecode was a monitorenter bytecode,
// assume the current bytecode throws an asynchronous
// exception to get at least one control flow path to
// the handler for asynchronous exceptions (this will
// hopefully also be the first control flow path to
// that handler which will 'initialize' it correctly;
// see also javac problem mentioned in handle_exception())
if (has_handler() && (prev_is_monitorenter || can_trap(code))) {
handle_exception(prev_is_monitorenter || is_async(code));
if (bailed_out()) return NULL;
}
prev_is_monitorenter = false;
// Check for active jsr during OSR compilation
if (compilation()->is_osr_compile()
&& scope()->is_top_scope()
&& parsing_jsr()
&& s.bci() == compilation()->osr_bci()) {
bailout("OSR not supported while a jsr is active");
}
// handle bytecode
switch (code) {
case Bytecodes::_nop : /* nothing to do */ break;
case Bytecodes::_aconst_null : apush(append(new Constant(objectNull ))); break;
case Bytecodes::_iconst_m1 : ipush(append(new Constant(new IntConstant (-1)))); break;
case Bytecodes::_iconst_0 : ipush(append(new Constant(intZero ))); break;
case Bytecodes::_iconst_1 : ipush(append(new Constant(intOne ))); break;
case Bytecodes::_iconst_2 : ipush(append(new Constant(new IntConstant ( 2)))); break;
case Bytecodes::_iconst_3 : ipush(append(new Constant(new IntConstant ( 3)))); break;
case Bytecodes::_iconst_4 : ipush(append(new Constant(new IntConstant ( 4)))); break;
case Bytecodes::_iconst_5 : ipush(append(new Constant(new IntConstant ( 5)))); break;
case Bytecodes::_lconst_0 : lpush(append(new Constant(new LongConstant ( 0)))); break;
case Bytecodes::_lconst_1 : lpush(append(new Constant(new LongConstant ( 1)))); break;
case Bytecodes::_fconst_0 : fpush(append(new Constant(new FloatConstant ( 0)))); break;
case Bytecodes::_fconst_1 : fpush(append(new Constant(new FloatConstant ( 1)))); break;
case Bytecodes::_fconst_2 : fpush(append(new Constant(new FloatConstant ( 2)))); break;
case Bytecodes::_dconst_0 : dpush(append(new Constant(new DoubleConstant( 0)))); break;
case Bytecodes::_dconst_1 : dpush(append(new Constant(new DoubleConstant( 1)))); break;
case Bytecodes::_bipush : ipush(append(new Constant(new IntConstant(((signed char*)s.bcp())[1])))); break;
case Bytecodes::_sipush : ipush(append(new Constant(new IntConstant((short)Bytes::get_Java_u2(s.bcp()+1))))); break;
case Bytecodes::_ldc : // fall through
case Bytecodes::_ldc_w : // fall through
case Bytecodes::_ldc2_w : load_constant(); break;
case Bytecodes::_iload : load_local(intType , s.get_index()); break;
case Bytecodes::_lload : load_local(longType , s.get_index()); break;
case Bytecodes::_fload : load_local(floatType , s.get_index()); break;
case Bytecodes::_dload : load_local(doubleType , s.get_index()); break;
case Bytecodes::_aload : load_local(instanceType, s.get_index()); break;
case Bytecodes::_iload_0 : load_local(intType , 0); break;
case Bytecodes::_iload_1 : load_local(intType , 1); break;
case Bytecodes::_iload_2 : load_local(intType , 2); break;
case Bytecodes::_iload_3 : load_local(intType , 3); break;
case Bytecodes::_lload_0 : load_local(longType , 0); break;
case Bytecodes::_lload_1 : load_local(longType , 1); break;
case Bytecodes::_lload_2 : load_local(longType , 2); break;
case Bytecodes::_lload_3 : load_local(longType , 3); break;
case Bytecodes::_fload_0 : load_local(floatType , 0); break;
case Bytecodes::_fload_1 : load_local(floatType , 1); break;
case Bytecodes::_fload_2 : load_local(floatType , 2); break;
case Bytecodes::_fload_3 : load_local(floatType , 3); break;
case Bytecodes::_dload_0 : load_local(doubleType, 0); break;
case Bytecodes::_dload_1 : load_local(doubleType, 1); break;
case Bytecodes::_dload_2 : load_local(doubleType, 2); break;
case Bytecodes::_dload_3 : load_local(doubleType, 3); break;
case Bytecodes::_aload_0 : load_local(objectType, 0); break;
case Bytecodes::_aload_1 : load_local(objectType, 1); break;
case Bytecodes::_aload_2 : load_local(objectType, 2); break;
case Bytecodes::_aload_3 : load_local(objectType, 3); break;
case Bytecodes::_iaload : load_indexed(T_INT ); break;
case Bytecodes::_laload : load_indexed(T_LONG ); break;
case Bytecodes::_faload : load_indexed(T_FLOAT ); break;
case Bytecodes::_daload : load_indexed(T_DOUBLE); break;
case Bytecodes::_aaload : load_indexed(T_OBJECT); break;
case Bytecodes::_baload : load_indexed(T_BYTE ); break;
case Bytecodes::_caload : load_indexed(T_CHAR ); break;
case Bytecodes::_saload : load_indexed(T_SHORT ); break;
case Bytecodes::_istore : store_local(intType , s.get_index()); break;
case Bytecodes::_lstore : store_local(longType , s.get_index()); break;
case Bytecodes::_fstore : store_local(floatType , s.get_index()); break;
case Bytecodes::_dstore : store_local(doubleType, s.get_index()); break;
case Bytecodes::_astore : store_local(objectType, s.get_index()); break;
case Bytecodes::_istore_0 : store_local(intType , 0); break;
case Bytecodes::_istore_1 : store_local(intType , 1); break;
case Bytecodes::_istore_2 : store_local(intType , 2); break;
case Bytecodes::_istore_3 : store_local(intType , 3); break;
case Bytecodes::_lstore_0 : store_local(longType , 0); break;
case Bytecodes::_lstore_1 : store_local(longType , 1); break;
case Bytecodes::_lstore_2 : store_local(longType , 2); break;
case Bytecodes::_lstore_3 : store_local(longType , 3); break;
case Bytecodes::_fstore_0 : store_local(floatType , 0); break;
case Bytecodes::_fstore_1 : store_local(floatType , 1); break;
case Bytecodes::_fstore_2 : store_local(floatType , 2); break;
case Bytecodes::_fstore_3 : store_local(floatType , 3); break;
case Bytecodes::_dstore_0 : store_local(doubleType, 0); break;
case Bytecodes::_dstore_1 : store_local(doubleType, 1); break;
case Bytecodes::_dstore_2 : store_local(doubleType, 2); break;
case Bytecodes::_dstore_3 : store_local(doubleType, 3); break;
case Bytecodes::_astore_0 : store_local(objectType, 0); break;
case Bytecodes::_astore_1 : store_local(objectType, 1); break;
case Bytecodes::_astore_2 : store_local(objectType, 2); break;
case Bytecodes::_astore_3 : store_local(objectType, 3); break;
case Bytecodes::_iastore : store_indexed(T_INT ); break;
case Bytecodes::_lastore : store_indexed(T_LONG ); break;
case Bytecodes::_fastore : store_indexed(T_FLOAT ); break;
case Bytecodes::_dastore : store_indexed(T_DOUBLE); break;
case Bytecodes::_aastore : store_indexed(T_OBJECT); break;
case Bytecodes::_bastore : store_indexed(T_BYTE ); break;
case Bytecodes::_castore : store_indexed(T_CHAR ); break;
case Bytecodes::_sastore : store_indexed(T_SHORT ); break;
case Bytecodes::_pop : // fall through
case Bytecodes::_pop2 : // fall through
case Bytecodes::_dup : // fall through
case Bytecodes::_dup_x1 : // fall through
case Bytecodes::_dup_x2 : // fall through
case Bytecodes::_dup2 : // fall through
case Bytecodes::_dup2_x1 : // fall through
case Bytecodes::_dup2_x2 : // fall through
case Bytecodes::_swap : stack_op(code); break;
case Bytecodes::_iadd : arithmetic_op(intType , code); break;
case Bytecodes::_ladd : arithmetic_op(longType , code); break;
case Bytecodes::_fadd : arithmetic_op(floatType , code); break;
case Bytecodes::_dadd : arithmetic_op(doubleType, code); break;
case Bytecodes::_isub : arithmetic_op(intType , code); break;
case Bytecodes::_lsub : arithmetic_op(longType , code); break;
case Bytecodes::_fsub : arithmetic_op(floatType , code); break;
case Bytecodes::_dsub : arithmetic_op(doubleType, code); break;
case Bytecodes::_imul : arithmetic_op(intType , code); break;
case Bytecodes::_lmul : arithmetic_op(longType , code); break;
case Bytecodes::_fmul : arithmetic_op(floatType , code); break;
case Bytecodes::_dmul : arithmetic_op(doubleType, code); break;
case Bytecodes::_idiv : arithmetic_op(intType , code, lock_stack()); break;
case Bytecodes::_ldiv : arithmetic_op(longType , code, lock_stack()); break;
case Bytecodes::_fdiv : arithmetic_op(floatType , code); break;
case Bytecodes::_ddiv : arithmetic_op(doubleType, code); break;
case Bytecodes::_irem : arithmetic_op(intType , code, lock_stack()); break;
case Bytecodes::_lrem : arithmetic_op(longType , code, lock_stack()); break;
case Bytecodes::_frem : arithmetic_op(floatType , code); break;
case Bytecodes::_drem : arithmetic_op(doubleType, code); break;
case Bytecodes::_ineg : negate_op(intType ); break;
case Bytecodes::_lneg : negate_op(longType ); break;
case Bytecodes::_fneg : negate_op(floatType ); break;
case Bytecodes::_dneg : negate_op(doubleType); break;
case Bytecodes::_ishl : shift_op(intType , code); break;
case Bytecodes::_lshl : shift_op(longType, code); break;
case Bytecodes::_ishr : shift_op(intType , code); break;
case Bytecodes::_lshr : shift_op(longType, code); break;
case Bytecodes::_iushr : shift_op(intType , code); break;
case Bytecodes::_lushr : shift_op(longType, code); break;
case Bytecodes::_iand : logic_op(intType , code); break;
case Bytecodes::_land : logic_op(longType, code); break;
case Bytecodes::_ior : logic_op(intType , code); break;
case Bytecodes::_lor : logic_op(longType, code); break;
case Bytecodes::_ixor : logic_op(intType , code); break;
case Bytecodes::_lxor : logic_op(longType, code); break;
case Bytecodes::_iinc : increment(); break;
case Bytecodes::_i2l : convert(code, T_INT , T_LONG ); break;
case Bytecodes::_i2f : convert(code, T_INT , T_FLOAT ); break;
case Bytecodes::_i2d : convert(code, T_INT , T_DOUBLE); break;
case Bytecodes::_l2i : convert(code, T_LONG , T_INT ); break;
case Bytecodes::_l2f : convert(code, T_LONG , T_FLOAT ); break;
case Bytecodes::_l2d : convert(code, T_LONG , T_DOUBLE); break;
case Bytecodes::_f2i : convert(code, T_FLOAT , T_INT ); break;
case Bytecodes::_f2l : convert(code, T_FLOAT , T_LONG ); break;
case Bytecodes::_f2d : convert(code, T_FLOAT , T_DOUBLE); break;
case Bytecodes::_d2i : convert(code, T_DOUBLE, T_INT ); break;
case Bytecodes::_d2l : convert(code, T_DOUBLE, T_LONG ); break;
case Bytecodes::_d2f : convert(code, T_DOUBLE, T_FLOAT ); break;
case Bytecodes::_i2b : convert(code, T_INT , T_BYTE ); break;
case Bytecodes::_i2c : convert(code, T_INT , T_CHAR ); break;
case Bytecodes::_i2s : convert(code, T_INT , T_SHORT ); break;
case Bytecodes::_lcmp : compare_op(longType , code); break;
case Bytecodes::_fcmpl : compare_op(floatType , code); break;
case Bytecodes::_fcmpg : compare_op(floatType , code); break;
case Bytecodes::_dcmpl : compare_op(doubleType, code); break;
case Bytecodes::_dcmpg : compare_op(doubleType, code); break;
case Bytecodes::_ifeq : if_zero(intType , If::eql); break;
case Bytecodes::_ifne : if_zero(intType , If::neq); break;
case Bytecodes::_iflt : if_zero(intType , If::lss); break;
case Bytecodes::_ifge : if_zero(intType , If::geq); break;
case Bytecodes::_ifgt : if_zero(intType , If::gtr); break;
case Bytecodes::_ifle : if_zero(intType , If::leq); break;
case Bytecodes::_if_icmpeq : if_same(intType , If::eql); break;
case Bytecodes::_if_icmpne : if_same(intType , If::neq); break;
case Bytecodes::_if_icmplt : if_same(intType , If::lss); break;
case Bytecodes::_if_icmpge : if_same(intType , If::geq); break;
case Bytecodes::_if_icmpgt : if_same(intType , If::gtr); break;
case Bytecodes::_if_icmple : if_same(intType , If::leq); break;
case Bytecodes::_if_acmpeq : if_same(objectType, If::eql); break;
case Bytecodes::_if_acmpne : if_same(objectType, If::neq); break;
case Bytecodes::_goto : append(new Goto(block_at(s.dest()), s.dest() <= s.bci())); break;
case Bytecodes::_jsr : jsr(s.dest()); break;
case Bytecodes::_ret : ret(s.get_index()); break;
case Bytecodes::_tableswitch : table_switch(); break;
case Bytecodes::_lookupswitch : lookup_switch(); break;
case Bytecodes::_ireturn : method_return(ipop()); break;
case Bytecodes::_lreturn : method_return(lpop()); break;
case Bytecodes::_freturn : method_return(fpop()); break;
case Bytecodes::_dreturn : method_return(dpop()); break;
case Bytecodes::_areturn : method_return(apop()); break;
case Bytecodes::_return : method_return(NULL ); break;
case Bytecodes::_getstatic : // fall through
case Bytecodes::_putstatic : // fall through
case Bytecodes::_getfield : // fall through
case Bytecodes::_putfield : access_field(code); break;
case Bytecodes::_invokevirtual : // fall through
case Bytecodes::_invokespecial : // fall through
case Bytecodes::_invokestatic : // fall through
case Bytecodes::_invokeinterface: invoke(code); break;
case Bytecodes::_xxxunusedxxx : ShouldNotReachHere(); break;
case Bytecodes::_new : new_instance(s.get_index_big()); break;
case Bytecodes::_newarray : new_type_array(); break;
case Bytecodes::_anewarray : new_object_array(); break;
case Bytecodes::_arraylength : ipush(append(new ArrayLength(apop(), lock_stack()))); break;
case Bytecodes::_athrow : throw_op(); break;
case Bytecodes::_checkcast : check_cast(s.get_index_big()); break;
case Bytecodes::_instanceof : instance_of(s.get_index_big()); break;
// Note: we do not have special handling for the monitorenter bytecode if DeoptC1 && DeoptOnAsyncException
case Bytecodes::_monitorenter : monitorenter(apop()); prev_is_monitorenter = !(DeoptC1 && DeoptOnAsyncException); break;
case Bytecodes::_monitorexit : monitorexit (apop()); break;
case Bytecodes::_wide : ShouldNotReachHere(); break;
case Bytecodes::_multianewarray : new_multi_array(s.bcp()[3]); break;
case Bytecodes::_ifnull : if_null(objectType, If::eql); break;
case Bytecodes::_ifnonnull : if_null(objectType, If::neq); break;
case Bytecodes::_goto_w : append(new Goto(block_at(s.dest_w()), s.dest_w() <= s.bci())); break;
case Bytecodes::_jsr_w : jsr(s.dest_w()); break;
case Bytecodes::_breakpoint : BAILOUT_("concurrent setting of breakpoint", NULL);
default : ShouldNotReachHere(); break;
}
// save current bci to setup Goto at the end
prev_bci = s.bci();
}
if (bailed_out()) return NULL;
// if there are any, check if last instruction is a BlockEnd instruction
BlockEnd* end = last()->as_BlockEnd();
if (end == NULL) {
// all blocks must end with a BlockEnd instruction => add a Goto
end = new Goto(block_at(s.bci()), false);
_last = _last->set_next(end, prev_bci);
}
assert(end == last()->as_BlockEnd(), "inconsistency");
// if the method terminates, we don't need the stack anymore
if (end->as_Return() != NULL) {
state()->clear_stack();
if (EliminateStores) {
state()->eliminate_all_scope_stores(s.bci());
}
} else if (end->as_Throw() != NULL) {
// May have exception handler in caller scopes
state()->truncate_stack(scope()->lock_stack_size());
if (EliminateStores) {
state()->clear_stores();
}
}
// here all expression stack values must be pinned
// note: this only involves values that are inputs
// to phi nodes of other blocks - we must be
// sure we compute them before we compute the
// last expression of the block, usually a
// compare instruction
// We can do better than to pin all of the values on the stack in
// some situations -- specifically, if we will fall out of an
// inlined scope and resume parsing in the caller. For these
// situations we leave pinning of the stack up to the inliner.
if (state() != inline_cleanup_state()) {
state()->pin_stack_all(Instruction::PinEndOfBlock);
}
// connect to begin & set state
// NOTE that inlining may have changed the block we are parsing
block()->set_end(end);
end->set_state(state());
// propagate state
for (int i = end->number_of_sux() - 1; i >= 0; i--) {
// be careful, bailout if bytecodes are strange
if (!end->sux_at(i)->try_join(state())) BAILOUT_("block join failed", NULL);
scope_data()->add_to_work_list(end->sux_at(i));
}
// done
return end;
}
void GraphBuilder::iterate_all_blocks(bool start_in_current_block_for_inlining) {
do {
if (start_in_current_block_for_inlining && !bailed_out()) {
iterate_bytecodes_for_block(0);
start_in_current_block_for_inlining = false;
} else {
BlockBegin* b;
while ((b = scope_data()->remove_from_work_list()) != NULL) {
if (!b->is_set(BlockBegin::was_visited_flag)) {
b->set(BlockBegin::was_visited_flag);
connect_to_end(b);
}
}
}
} while (!bailed_out() && !scope_data()->is_work_list_empty());
}
bool GraphBuilder::_is_initialized = false;
bool GraphBuilder::_can_trap [Bytecodes::number_of_java_codes];
bool GraphBuilder::_is_async[Bytecodes::number_of_java_codes];
void GraphBuilder::initialize() {
// make sure initialization happens only once (need a
// lock here, if we allow the compiler to be re-entrant)
if (is_initialized()) return;
_is_initialized = true;
// the following bytecodes are assumed to potentially
// throw exceptions in compiled code - note that e.g.
// monitorexit & the return bytecodes do not throw
// exceptions since monitor pairing proved that they
// succeed (if monitor pairing succeeded)
Bytecodes::Code can_trap_list[] =
{ Bytecodes::_ldc
, Bytecodes::_ldc_w
, Bytecodes::_ldc2_w
, Bytecodes::_iaload
, Bytecodes::_laload
, Bytecodes::_faload
, Bytecodes::_daload
, Bytecodes::_aaload
, Bytecodes::_baload
, Bytecodes::_caload
, Bytecodes::_saload
, Bytecodes::_iastore
, Bytecodes::_lastore
, Bytecodes::_fastore
, Bytecodes::_dastore
, Bytecodes::_aastore
, Bytecodes::_bastore
, Bytecodes::_castore
, Bytecodes::_sastore
, Bytecodes::_idiv
, Bytecodes::_ldiv
, Bytecodes::_irem
, Bytecodes::_lrem
, Bytecodes::_getstatic
, Bytecodes::_putstatic
, Bytecodes::_getfield
, Bytecodes::_putfield
, Bytecodes::_invokevirtual
, Bytecodes::_invokespecial
, Bytecodes::_invokestatic
, Bytecodes::_invokeinterface
, Bytecodes::_new
, Bytecodes::_newarray
, Bytecodes::_anewarray
, Bytecodes::_arraylength
, Bytecodes::_athrow
, Bytecodes::_checkcast
, Bytecodes::_instanceof
, Bytecodes::_monitorenter
, Bytecodes::_multianewarray
};
// the following bytecodes are assumed to potentially
// throw asynchronous exceptions in compiled code due
// to safepoints (note: these entries could be merged
// with the can_trap_list - however, we need to know
// which ones are asynchronous for now - see also the
// comment in GraphBuilder::handle_exception)
Bytecodes::Code is_async_list[] =
{ Bytecodes::_ifeq
, Bytecodes::_ifne
, Bytecodes::_iflt
, Bytecodes::_ifge
, Bytecodes::_ifgt
, Bytecodes::_ifle
, Bytecodes::_if_icmpeq
, Bytecodes::_if_icmpne
, Bytecodes::_if_icmplt
, Bytecodes::_if_icmpge
, Bytecodes::_if_icmpgt
, Bytecodes::_if_icmple
, Bytecodes::_if_acmpeq
, Bytecodes::_if_acmpne
, Bytecodes::_goto
, Bytecodes::_jsr
, Bytecodes::_ret
, Bytecodes::_tableswitch
, Bytecodes::_lookupswitch
, Bytecodes::_ireturn
, Bytecodes::_lreturn
, Bytecodes::_freturn
, Bytecodes::_dreturn
, Bytecodes::_areturn
, Bytecodes::_return
, Bytecodes::_ifnull
, Bytecodes::_ifnonnull
, Bytecodes::_goto_w
, Bytecodes::_jsr_w
};
// inititialize trap tables
for (int i = 0; i < Bytecodes::number_of_java_codes; i++) {
_can_trap[i] = false;
_is_async[i] = false;
}
// set standard trap info
for (int j = 0; j < sizeof(can_trap_list) / sizeof(can_trap_list[0]) ; j++) {
_can_trap[can_trap_list[j]] = true;
}
// We now deoptimize if an asynchronous exception is thrown. This
// considerably cleans up corner case issues related to javac's
// incorrect exception handler ranges for async exceptions and
// allows us to precisely analyze the types of exceptions from
// certain bytecodes.
if (!(DeoptC1 && DeoptOnAsyncException)) {
// set asynchronous trap info
for (int k = 0; k < sizeof(is_async_list) / sizeof(is_async_list[0]) ; k++) {
assert(!_can_trap[is_async_list[k]], "can_trap_list and is_async_list should be disjoint");
_can_trap[is_async_list[k]] = true;
_is_async[is_async_list[k]] = true;
}
}
}
GraphBuilder::GraphBuilder(Compilation* compilation, IRScope* scope, BlockList* bci2block, BlockBegin* start)
: _scope_data(NULL)
, _exception_scope(NULL)
, _instruction_count(0)
{
assert(is_initialized(), "GraphBuilder must have been initialized");
_compilation = compilation;
push_root_scope(scope, bci2block, start);
_vmap = new ValueMap();
_bailout_msg = NULL;
scope_data()->add_to_work_list(start);
iterate_all_blocks();
#ifndef PRODUCT
if (PrintCompilation && Verbose) tty->print_cr("Created %d Instructions", _instruction_count);
#endif
}
void GraphBuilder::push_exception_scope() {
if (_exception_scope == NULL) {
_exception_scope = new ExceptionScope();
} else {
_exception_scope = _exception_scope->push_scope();
}
}
void GraphBuilder::pop_exception_scope() {
_exception_scope = _exception_scope->pop_scope();
}
ValueStack* GraphBuilder::lock_stack() {
// return a new ValueStack representing just the current lock stack
// (for debug info at safepoints in exception throwing or handling)
ValueStack* new_stack = state()->copy_locks();
return new_stack;
}
int GraphBuilder::recursive_inline_level(ciMethod* cur_callee) const {
int recur_level = 0;
for (IRScope* s = scope(); s != NULL; s = s->caller()) {
if (s->method() == cur_callee) {
++recur_level;
}
}
return recur_level;
}
bool GraphBuilder::try_inline(ciMethod* callee) {
// Clear out any existing inline bailout condition
clear_inline_bailout();
if (compilation()->jvmpi_event_method_enabled()) {
// do not inline at all
INLINE_BAILOUT("jvmpi event method enabled")
} else if (callee->should_exclude()) {
// callee is excluded
INLINE_BAILOUT("excluded by CompilerOracle")
} else if (!callee->can_be_compiled()) {
// callee is not compilable (prob. has breakpoints)
INLINE_BAILOUT("not compilable")
} else if (try_inline_intrinsics(callee)) {
// intrinsics can be native or not
return true;
} else if (callee->is_native()) {
// non-intrinsic natives cannot be inlined
INLINE_BAILOUT("non-intrinsic native")
} else {
return try_inline_full(callee);
}
}
bool GraphBuilder::try_inline_intrinsics(ciMethod* callee) {
bool preserves_state = false;
if (!InlineIntrinsics ) INLINE_BAILOUT("intrinsic method inlining disabled");
if (callee->is_synchronized()) INLINE_BAILOUT("intrinsic method is synchronized");
// callee seems like a good candidate
// determine id
ciMethod::IntrinsicId id = callee->intrinsic_id();
switch (id) {
case ciMethod::_arraycopy :
if (!InlineArrayCopy) return false;
break;
case ciMethod::_currentTimeMillis:
break;
case ciMethod::_getClass :
case ciMethod::_currentThread :
preserves_state = true;
break;
case ciMethod::_dsqrt :
preserves_state = true;
break;
case ciMethod::_dsin : // fall through
case ciMethod::_dcos : // fall through
#ifndef SPARC
preserves_state = true;
#endif
break;
// sun/misc/AtomicLong.attemptUpdate
case ciMethod::_attemptUpdate :
if (!VM_Version::supports_cx8()) return false;
if (!InlineAtomicLong) return false;
preserves_state = true;
break;
// %%% the following xxx_obj32 are temporary until the 1.4.0 sun.misc.Unsafe goes away
case ciMethod::_getObject_obj32 : append_unsafe_get_obj32(callee, T_OBJECT); return true;
case ciMethod::_getBoolean_obj32: append_unsafe_get_obj32(callee, T_BOOLEAN); return true;
case ciMethod::_getByte_obj32 : append_unsafe_get_obj32(callee, T_BYTE); return true;
case ciMethod::_getShort_obj32 : append_unsafe_get_obj32(callee, T_SHORT); return true;
case ciMethod::_getChar_obj32 : append_unsafe_get_obj32(callee, T_CHAR); return true;
case ciMethod::_getInt_obj32 : append_unsafe_get_obj32(callee, T_INT); return true;
case ciMethod::_getLong_obj32 : append_unsafe_get_obj32(callee, T_LONG); return true;
case ciMethod::_getFloat_obj32 : append_unsafe_get_obj32(callee, T_FLOAT); return true;
case ciMethod::_getDouble_obj32 : append_unsafe_get_obj32(callee, T_DOUBLE); return true;
case ciMethod::_putObject_obj32 : append_unsafe_put_obj32(callee, T_OBJECT); return true;
case ciMethod::_putBoolean_obj32: append_unsafe_put_obj32(callee, T_BOOLEAN); return true;
case ciMethod::_putByte_obj32 : append_unsafe_put_obj32(callee, T_BYTE); return true;
case ciMethod::_putShort_obj32 : append_unsafe_put_obj32(callee, T_SHORT); return true;
case ciMethod::_putChar_obj32 : append_unsafe_put_obj32(callee, T_CHAR); return true;
case ciMethod::_putInt_obj32 : append_unsafe_put_obj32(callee, T_INT); return true;
case ciMethod::_putLong_obj32 : append_unsafe_put_obj32(callee, T_LONG); return true;
case ciMethod::_putFloat_obj32 : append_unsafe_put_obj32(callee, T_FLOAT); return true;
case ciMethod::_putDouble_obj32 : append_unsafe_put_obj32(callee, T_DOUBLE); return true;
// Use special nodes for Unsafe instructions so we can more easily
// perform an address-mode optimization on the raw variants
case ciMethod::_getObject_obj : append_unsafe_get_obj(callee, T_OBJECT); return true;
case ciMethod::_getBoolean_obj: append_unsafe_get_obj(callee, T_BOOLEAN); return true;
case ciMethod::_getByte_obj : append_unsafe_get_obj(callee, T_BYTE); return true;
case ciMethod::_getShort_obj : append_unsafe_get_obj(callee, T_SHORT); return true;
case ciMethod::_getChar_obj : append_unsafe_get_obj(callee, T_CHAR); return true;
case ciMethod::_getInt_obj : append_unsafe_get_obj(callee, T_INT); return true;
case ciMethod::_getLong_obj : append_unsafe_get_obj(callee, T_LONG); return true;
case ciMethod::_getFloat_obj : append_unsafe_get_obj(callee, T_FLOAT); return true;
case ciMethod::_getDouble_obj : append_unsafe_get_obj(callee, T_DOUBLE); return true;
case ciMethod::_putObject_obj : append_unsafe_put_obj(callee, T_OBJECT); return true;
case ciMethod::_putBoolean_obj: append_unsafe_put_obj(callee, T_BOOLEAN); return true;
case ciMethod::_putByte_obj : append_unsafe_put_obj(callee, T_BYTE); return true;
case ciMethod::_putShort_obj : append_unsafe_put_obj(callee, T_SHORT); return true;
case ciMethod::_putChar_obj : append_unsafe_put_obj(callee, T_CHAR); return true;
case ciMethod::_putInt_obj : append_unsafe_put_obj(callee, T_INT); return true;
case ciMethod::_putLong_obj : append_unsafe_put_obj(callee, T_LONG); return true;
case ciMethod::_putFloat_obj : append_unsafe_put_obj(callee, T_FLOAT); return true;
case ciMethod::_putDouble_obj : append_unsafe_put_obj(callee, T_DOUBLE); return true;
case ciMethod::_getByte_raw : append_unsafe_get_raw(callee, T_BYTE); return true;
case ciMethod::_getShort_raw : append_unsafe_get_raw(callee, T_SHORT); return true;
case ciMethod::_getChar_raw : append_unsafe_get_raw(callee, T_CHAR); return true;
case ciMethod::_getInt_raw : append_unsafe_get_raw(callee, T_INT); return true;
case ciMethod::_getLong_raw : append_unsafe_get_raw(callee, T_LONG); return true;
case ciMethod::_getFloat_raw : append_unsafe_get_raw(callee, T_FLOAT); return true;
case ciMethod::_getDouble_raw : append_unsafe_get_raw(callee, T_DOUBLE); return true;
case ciMethod::_putByte_raw : append_unsafe_put_raw(callee, T_BYTE); return true;
case ciMethod::_putShort_raw : append_unsafe_put_raw(callee, T_SHORT); return true;
case ciMethod::_putChar_raw : append_unsafe_put_raw(callee, T_CHAR); return true;
case ciMethod::_putInt_raw : append_unsafe_put_raw(callee, T_INT); return true;
case ciMethod::_putLong_raw : append_unsafe_put_raw(callee, T_LONG); return true;
case ciMethod::_putFloat_raw : append_unsafe_put_raw(callee, T_FLOAT); return true;
case ciMethod::_putDouble_raw : append_unsafe_put_raw(callee, T_DOUBLE); return true;
case ciMethod::_checkIndex :
if (!InlineNIOCheckIndex) return false;
preserves_state = true;
break;
default : return false; // do not inline
}
// create intrinsic node
const bool has_receiver = !callee->is_static();
ValueType* result_type = as_ValueType(callee->return_type());
Values* args = state()->pop_arguments(callee->arg_size());
ValueStack* locks = lock_stack();
Intrinsic* result = new Intrinsic(result_type, id, args, has_receiver, lock_stack(), preserves_state);
// append instruction & push result
append_split(result);
if (result_type != voidType) push(result_type, result);
// done
return true;
}
bool GraphBuilder::try_inline_jsr(int jsr_dest_bci) {
// Introduce a new callee continuation point - all Ret instructions
// will be replaced with Gotos to this point.
BlockBegin* cont = block_at(next_bci());
bool continuation_existed = true;
if (cont == NULL) {
cont = new BlockBegin(next_bci());
continuation_existed = false;
}
// Note: can not assign state to continuation yet, as we have to
// pick up the state from the Ret instructions.
// Push callee scope
push_scope_for_jsr(cont, jsr_dest_bci);
// Temporarily set up bytecode stream so we can append instructions
// (only using the bci of this stream)
scope_data()->set_stream(scope_data()->parent()->stream());
BlockBegin* jsr_start_block = block_at(jsr_dest_bci);
assert(jsr_start_block != NULL, "jsr start block must exist");
assert(!jsr_start_block->is_set(BlockBegin::was_visited_flag), "should not have visited jsr yet");
state()->pin_stack_all(Instruction::PinInlineEndOfBlock);
Goto* goto_sub = new Goto(jsr_start_block, false);
goto_sub->set_state(state());
// Must copy state to avoid wrong sharing when parsing bytecodes
// First make callee state into phis
set_state(new ValueStack(state()));
// Now copy it
assert(jsr_start_block->state() == NULL, "should have fresh jsr starting block");
jsr_start_block->set_state(state()->copy());
append(goto_sub);
_block->set_end(goto_sub);
_last = _block = jsr_start_block;
state()->clear_locals();
vmap()->kill_all();
// Clear out bytecode stream
scope_data()->set_stream(NULL);
scope_data()->add_to_work_list(jsr_start_block);
// Ready to resume parsing in subroutine
iterate_all_blocks();
// If we bailed out during parsing, return immediately (this is bad news)
if (bailed_out()) return false;
assert(continuation_existed ||
!jsr_continuation()->is_set(BlockBegin::was_visited_flag),
"jsr continuation should not have been parsed yet if we created it");
// Detect whether the continuation can actually be reached. If not,
// it has not had state set by the join() operations in
// iterate_bytecodes_for_block()/ret() and we should not touch the
// iteration state. The calling activation of
// iterate_bytecodes_for_block will then complete normally.
if (jsr_continuation()->state() != NULL) {
// Set up iteration state for resuming parsing in jsr continuation
_last = _block = jsr_continuation();
set_state(jsr_continuation()->state()->copy());
vmap()->kill_all();
}
pop_scope_for_jsr();
return true;
}
bool GraphBuilder::try_inline_full(ciMethod* callee) {
assert(!callee->is_native(), "callee must not be native");
// first perform tests of things it's not possible to inline
if (callee->has_exception_handlers() &&
!InlineMethodsWithExceptionHandlers) INLINE_BAILOUT("callee has exception handlers");
if (callee->is_synchronized() ) INLINE_BAILOUT("callee is synchronized");
if (!callee->holder()->is_initialized()) INLINE_BAILOUT("callee's klass not initialized yet");
if (!callee->has_balanced_monitors()) INLINE_BAILOUT("callee's monitors do not match");
// NOTE: for now, also check presence of monitors -- there is a bug
// in the handling of nested scopes' monitor slots
if (callee->has_monitor_bytecodes()) INLINE_BAILOUT("monitor bytecodes not supported by inliner yet");
// Proper inlining of methods with jsrs requires us either to store
// initialization values for initvars reported by the CI, or
// (preferably) generation of oop maps directly from LIR
if (callee->has_jsrs() ) INLINE_BAILOUT("jsrs not handled properly by inliner yet");
// now perform tests that are based on flag settings
if (inline_level() > MaxInlineLevel ) INLINE_BAILOUT("too-deep inlining");
if (recursive_inline_level(callee) > MaxRecursiveInlineLevel) INLINE_BAILOUT("too-deep recursive inlining");
if (callee->code_size() > max_inline_size() ) INLINE_BAILOUT("callee is too large");
// don't inline throwable methods unless the inlining tree is rooted in a throwable class
if (callee->name() == ciSymbol::object_initializer_name() &&
callee->holder()->is_subclass_of(ciEnv::current()->Throwable_klass())) {
// Throwable constructor call
IRScope* top = scope();
while (top->caller() != NULL) {
top = top->caller();
}
if (!top->method()->holder()->is_subclass_of(ciEnv::current()->Throwable_klass())) {
INLINE_BAILOUT("don't inline Throwable constructors");
}
}
if (strict_fp_requires_explicit_rounding && method()->is_strict() != callee->is_strict()) INLINE_BAILOUT("caller and caller have different strict fp requirements");
// NOTE: Bailouts from this point on, which occur at the
// GraphBuilder level, do not cause bailout just of the inlining but
// in fact of the entire compilation.
BlockBegin* orig_block = block();
const int args_base = state()->stack_size() - callee->arg_size();
assert(args_base >= 0, "stack underflow during inlining");
// Insert null check if necessary
if (code() != Bytecodes::_invokestatic) {
// note: null check must happen even if first instruction of callee does
// an implicit null check since the callee is in a different scope
// and we must make sure exception handling does the right thing
assert(!callee->is_static(), "callee must not be static");
assert(callee->arg_size() > 0, "must have at least a receiver");
int i = args_base;
append(new NullCheck(state()->stack_at_inc(i), lock_stack()));
}
// Introduce a new callee continuation point - if the callee has
// more than one return instruction or the return does not allow
// fall-through of control flow, all return instructions of the
// callee will need to be replaced by Goto's pointing to this
// continuation point.
BlockBegin* cont = block_at(next_bci());
bool continuation_existed = true;
if (cont == NULL) {
cont = new BlockBegin(next_bci());
continuation_existed = false;
}
if (cont->state() == NULL) {
// Assign state to continuation, pushing return value if any
cont->set_state(new ValueStack(state()));
cont->state()->truncate_stack(args_base);
ValueType* return_type = NULL;
if (callee->return_type()->basic_type() != T_VOID) {
return_type = as_ValueType(callee->return_type());
cont->state()->push(return_type, new Phi(return_type));
}
}
#ifdef ASSERT
else {
ValueStack* tmp_state = new ValueStack(state());
tmp_state->truncate_stack(args_base);
ValueType* return_type = NULL;
if (callee->return_type()->basic_type() != T_VOID) {
return_type = as_ValueType(callee->return_type());
tmp_state->push(return_type, new Phi(return_type));
}
assert(cont->try_join(tmp_state), "error in management of continuation state");
}
#endif
// Push callee scope
push_scope(callee, cont);
// Temporarily set up bytecode stream so we can append instructions
// (only using the bci of this stream)
scope_data()->set_stream(scope_data()->parent()->stream());
// Pass parameters into callee state: add assignments
// note: this will also ensure that all arguments are computed before being passed
ValueStack* callee_state = state();
ValueStack* caller_state = scope()->caller_state();
{ int i = args_base;
while (i < caller_state->stack_size()) {
const int par_no = i - args_base;
Value arg = caller_state->stack_at_inc(i);
// NOTE: take base() of arg->type() to avoid problems storing
// constants
store_local(callee_state, arg, arg->type()->base(), par_no, true);
}
}
// Remove args from stack.
// Note that we preserve locals state in case we can use it later
// (see use of pop_scope() below)
caller_state->truncate_stack(args_base);
callee_state->truncate_stack(args_base);
// Compute lock stack size for callee scope now that args have been passed
scope()->compute_lock_stack_size();
BlockBegin* callee_start_block = block_at(0);
if (callee_start_block != NULL) {
// There is a backward branch to bci 0 somewhere in the callee,
// meaning that parsing can not just resume in the callee; the
// current block must be terminated, all values on the stack
// pinned, the callee state turned into phis, and the ValueMap
// killed since it is illegal to share values across basic blocks.
caller_state->pin_stack_all(Instruction::PinInlineEndOfBlock);
// Must copy callee state to avoid wrong sharing when parsing bytecodes
// First make callee state into phis
callee_state = new ValueStack(callee_state);
// Now copy it
callee_start_block->set_state(callee_state->copy());
Goto* goto_callee = new Goto(callee_start_block, false);
goto_callee->set_state(state());
append(goto_callee);
_block->set_end(goto_callee);
_last = _block = callee_start_block;
callee_state->clear_locals();
vmap()->kill_all();
scope_data()->add_to_work_list(callee_start_block);
}
// Clear out bytecode stream
scope_data()->set_stream(NULL);
// Ready to resume parsing in callee (either in the same block we
// were in before or in the callee's start block)
iterate_all_blocks(callee_start_block == NULL);
// If we bailed out during parsing, return immediately (this is bad news)
if (bailed_out()) return false;
// iterate_all_blocks theoretically traverses in random order; in
// practice, we have only traversed the continuation if we are
// inlining into a subroutine
assert(continuation_existed ||
!continuation()->is_set(BlockBegin::was_visited_flag),
"continuation should not have been parsed yet if we created it");
// At this point we are almost ready to return and resume parsing of
// the caller back in the GraphBuilder. The only thing we want to do
// first is an optimization: during parsing of the callee we
// generated at least one Goto to the continuation block. If we
// generated exactly one, and if the inlined method spanned exactly
// one block (and we didn't have to Goto its entry), then we snip
// off the Goto to the continuation, allowing control to fall
// through back into the caller block and effectively performing
// block merging. This allows load elimination and CSE to take place
// across multiple callee scopes if they are relatively simple, and
// is currently essential to making inlining profitable.
if ( num_returns() == 1
&& block() == orig_block
&& block() == inline_cleanup_block()) {
_last = inline_cleanup_return_prev();
_state = inline_cleanup_state()->pop_scope(true, bci());
} else {
// Can not perform this optimization.
// Must go back and pin the state of the first goto to the
// continuation point
if (inline_cleanup_state() != NULL) {
inline_cleanup_state()->pin_stack_all(Instruction::PinInlineEndOfBlock);
}
// Resume parsing in continuation block unless it was already parsed.
// Note that if we don't change _last here, iteration in
// iterate_bytecodes_for_block will stop when we return.
if (!continuation()->is_set(BlockBegin::was_visited_flag)) {
// Change the state that we will restore to the GraphBuilder to
// instead be a list of Phis which includes the return value; this
// is the continuation's state. (As usual, have to make a copy.)
_last = _block = continuation();
// Since we will be resuming parsing in the continuation block
// when we return, mark it as having been traversed so we don't
// visit it twice
continuation()->set(BlockBegin::was_visited_flag);
_state = continuation()->state()->copy();
// Must not canonicalize across blocks
vmap()->kill_all();
}
}
pop_scope();
compilation()->notice_inlined_method(callee);
return true;
}
void GraphBuilder::inline_bailout(const char* msg) {
assert(msg != NULL, "inline bailout msg must exist");
_inline_bailout_msg = msg;
}
void GraphBuilder::clear_inline_bailout() {
_inline_bailout_msg = NULL;
}
void GraphBuilder::push_root_scope(IRScope* scope, BlockList* bci2block, BlockBegin* start) {
ScopeData* data = new ScopeData(NULL);
data->set_scope(scope);
data->set_bci2block(bci2block);
_scope_data = data;
_block = start;
push_exception_scope();
}
void GraphBuilder::push_scope(ciMethod* callee, BlockBegin* continuation) {
IRScope* callee_scope = new IRScope(compilation(), scope(), bci(), callee, -1, false);
scope()->add_callee(callee_scope);
callee_scope->set_caller_state(state());
set_state(state()->push_scope(callee_scope));
ScopeData* data = new ScopeData(scope_data());
data->set_scope(callee_scope);
BlockListBuilder blb(callee_scope, -1, false);
data->set_bci2block(blb.bci2block());
data->set_continuation(continuation);
_scope_data = data;
push_exception_scope();
}
void GraphBuilder::push_scope_for_jsr(BlockBegin* jsr_continuation, int jsr_dest_bci) {
ScopeData* data = new ScopeData(scope_data());
data->set_parsing_jsr();
data->set_jsr_entry_bci(jsr_dest_bci);
data->set_jsr_return_address_local(-1);
// Must clone bci2block list as we will be mutating it in order to
// properly clone all blocks in jsr region as well as exception
// handlers containing rets
BlockList* new_bci2block = new BlockList(bci2block()->length());
new_bci2block->push_all(bci2block());
data->set_bci2block(new_bci2block);
data->set_scope(scope());
data->setup_jsr_xhandlers();
data->set_continuation(continuation());
data->set_jsr_continuation(jsr_continuation);
_scope_data = data;
}
void GraphBuilder::pop_scope() {
_scope_data = scope_data()->parent();
pop_exception_scope();
}
void GraphBuilder::pop_scope_for_jsr() {
_scope_data = scope_data()->parent();
}
void GraphBuilder::append_unsafe_get_obj32(ciMethod* callee, BasicType t) {
Values* args = state()->pop_arguments(callee->arg_size());
Instruction* op = new UnsafeGetObject(t, args->at(0), args->at(1), args->at(2), lock_stack());
append(op);
push(op->type(), op);
compilation()->set_has_unsafe_access(true);
}
void GraphBuilder::append_unsafe_put_obj32(ciMethod* callee, BasicType t) {
Values* args = state()->pop_arguments(callee->arg_size());
Instruction* op = new UnsafePutObject(t, args->at(0), args->at(1), args->at(2), args->at(3), lock_stack());
append(op);
compilation()->set_has_unsafe_access(true);
}
void GraphBuilder::append_unsafe_get_obj(ciMethod* callee, BasicType t) {
Values* args = state()->pop_arguments(callee->arg_size());
Instruction* offset = new Convert(Bytecodes::_l2i, args->at(2), as_ValueType(T_INT));
append(offset);
Instruction* op = new UnsafeGetObject(t, args->at(0), args->at(1), offset, lock_stack());
append(op);
push(op->type(), op);
compilation()->set_has_unsafe_access(true);
}
void GraphBuilder::append_unsafe_put_obj(ciMethod* callee, BasicType t) {
Values* args = state()->pop_arguments(callee->arg_size());
Instruction* offset = new Convert(Bytecodes::_l2i, args->at(2), as_ValueType(T_INT));
append(offset);
Instruction* op = new UnsafePutObject(t, args->at(0), args->at(1), offset, args->at(3), lock_stack());
append(op);
compilation()->set_has_unsafe_access(true);
}
void GraphBuilder::append_unsafe_get_raw(ciMethod* callee, BasicType t) {
Values* args = state()->pop_arguments(callee->arg_size());
Instruction* op = new UnsafeGetRaw(t, args->at(0), args->at(1), lock_stack());
append(op);
push(op->type(), op);
compilation()->set_has_unsafe_access(true);
}
void GraphBuilder::append_unsafe_put_raw(ciMethod* callee, BasicType t) {
Values* args = state()->pop_arguments(callee->arg_size());
Instruction* op = new UnsafePutRaw(t, args->at(0), args->at(1), args->at(2), lock_stack());
append(op);
compilation()->set_has_unsafe_access(true);
}
#ifndef PRODUCT
void GraphBuilder::print_inline_result(ciMethod* callee, bool res) {
tty->print(" ");
for (int i = 0; i < scope()->level(); i++) tty->print(" ");
if (res) {
tty->print(" ");
} else {
tty->print("- ");
}
tty->print("@ %d ", bci());
callee->print_short_name();
tty->print(" (%d bytes)", callee->code_size());
if (_inline_bailout_msg) {
tty->print(" %s", _inline_bailout_msg);
}
tty->cr();
}
void GraphBuilder::print_stats() {
vmap()->print();
}
#endif // PRODUCT
| [
"blue@cmd.nu"
] | blue@cmd.nu |
16083e7524deb7c2b29ba75328ef3a607370df13 | 1f7f699bb0ee0d24da16f4bdb8a4ad34e8f401fa | /Source/JustDoIT/JustDoITPrinter.cpp | 6624a747c7a32513d01e4baf4b3790be74e9673f | [] | no_license | kacpidev/JustDoIT | 102219a7e20a3493830a7b55e2303a83b8d567a5 | fee7306911afd7fc75efceb26f198cdabfc98117 | refs/heads/master | 2021-01-22T13:58:03.825013 | 2015-11-08T21:54:36 | 2015-11-08T21:54:36 | 39,646,280 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 566 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "JustDoIT.h"
#include "JustDoITPrinter.h"
// Sets default values
AJustDoITPrinter::AJustDoITPrinter()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AJustDoITPrinter::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AJustDoITPrinter::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
| [
"bobek0210@gmail.com"
] | bobek0210@gmail.com |
4a1227e3a665f3baab0cf20e999f5af891534f8d | 59d5ea8d350a4c6276847b899d2c6041eedfa79b | /3sem/desafios/aula25/d2.cpp | f04a8523a7be587f5235ea2e12bf31cef0dd30c3 | [] | no_license | louhmmsb/IME | 160d343d7746d72c0ae435066b380075d7ca7aba | 12c40622814ee121e0f563abca9b065e06d1e438 | refs/heads/master | 2023-02-21T05:46:02.500620 | 2021-01-22T15:23:48 | 2021-01-22T15:23:48 | 257,774,633 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,032 | cpp | #include<bits/stdc++.h>
using namespace std;
#define si(x) scanf("%d", &x);
#define pi(x) printf("%d\n", x);
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
typedef long long int ll;
typedef unsigned long long int ull;
const int MAX = 1 << 10;
int count[2][MAXC];
int main(){
memset(count, 0, sizeof(count));
int n, k, x;
si(n);si(k);si(x);
for(int i=0, aux; i<n; i++){
cin>>aux;
count[0][aux]++;
}
for(int i=0, sas=0; i<k; i++, sas=0){
for(int j=0; j<MAX; j++){
count[!(i & 1)][j^x] = count[i & 1][j]/2;
count[!(i & 1)][j^0] = count[i & 1][j]/2;
(count[(i & 1)][j] & 1)? (sas & 1? (count[!(i & 1)][j]++) : (c[!(i & 1)])): (count[!(i & 1)][j^((sas & 1)*x)]++);
sas += count[(i & 1)][j];
count[(i & 1)][j] = 0;
}
}
int joao, zezinho;
for(int i = MAX-1; i >= 0; i--)
(count[k & 1][i] ? {zezinho = i; break;} : (){continue;});
cout<<
return 0;
}
| [
"louhmmsb@hotmail.com"
] | louhmmsb@hotmail.com |
8da7a2bdf4670589f5a6cc110fe59c73e54d0768 | b52549ee08ecf4422c76d90002c8980d1037e5e8 | /server/instance.hpp | 2aeeaadb27a8b0b6703b8148748e4dfdf6df5b86 | [
"MIT"
] | permissive | irl-game/irl | e8722ccaac3294d323a45e9b0dd4cc2d3979ca11 | ba507a93371ab172b705c1ede8cd062123fc96f5 | refs/heads/master | 2020-03-30T00:19:05.978210 | 2019-05-13T04:53:58 | 2019-05-13T04:53:58 | 150,516,001 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 177 | hpp | #pragma once
#include "sim_server.hpp"
#include "world.hpp"
#include <sched/sched.hpp>
class Instance : public Sched, public World, public SimServer
{
public:
Instance();
};
| [
"te.anton@gmail.com"
] | te.anton@gmail.com |
ed33aab375752e864ea80155f50c56fafe232b42 | 8c9a4d5dd609df2fd6cdfd6ae715856264d1ee98 | /Projects/ATTINY85/RGB_Moodlamp_Photocell/Code/MoodLampATTINY85PhotoCell/MoodLampATTINY85PhotoCell.ino | 8a3313982f11cc483075db30cb73a39ff7e4ee43 | [] | no_license | hooked82/Arduino | d41f8947ee977239507da947f88e5e3e1124d636 | ad758b6bb37167480ee0252e8d249c7808285485 | refs/heads/master | 2021-01-01T19:21:04.666664 | 2015-01-25T16:57:37 | 2015-01-25T16:57:37 | 28,751,928 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,694 | ino | const int potentiometerPin = 1;
const int lightSensorPin = 3;
const int buttonPin = 3;
const int RED_PIN = 4;
const int GREEN_PIN = 1;
const int BLUE_PIN = 0;
const int ON_LEVEL = 700;
const int MODE_SPECTRUM = 0;
const int MODE_SOLID = 1;
const int MODE_FLICKER = 2;
int lastButtonState = HIGH;
int mode = 0;
int potentiometerValue;
int lightLevel;
void setup() {
//Serial.begin(9600);
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
int buttonState;
potentiometerValue = analogRead(potentiometerPin);
lightLevel = analogRead(lightSensorPin);
buttonState = digitalRead(buttonPin);
//Only turn on the LEDs if it's dark enough
while (lightLevel >= ON_LEVEL) {
if (mode == MODE_SOLID)
{
//Single Color Mode
while (true) {
potentiometerValue = analogRead(potentiometerPin);
//If mode button is pressed, change mode then reset
if (buttonPressed()) {
//changeMode();
break;
}
changeColors(potentiometerValue);
delay(10);
}
}
else if (mode == MODE_FLICKER)
{
//Candle Flicker Mode
analogWrite(RED_PIN, 255);
analogWrite(GREEN_PIN, random(15, 30));
analogWrite(BLUE_PIN, 0);
if (buttonPressed()) {
//changeMode();
break;
}
if (!isDarkEnough())
break;
delay(random(100));
}
else
{
//Spectrum Colors Mode
int x;
for (x = 0; x < 768; x++) {
potentiometerValue = analogRead(potentiometerPin);
//If mode button is pressed, change mode then reset
if (buttonPressed()) {
//changeMode();
break;
}
if (!isDarkEnough())
break;
showRGB(x);
int wait = potentiometerValue/10;
if (wait <= 10)
wait = 10;
delay(wait);
}
}
}
}
//Checks to see if the button has been pressed
boolean buttonPressed() {
int state = digitalRead(buttonPin);
if (state == LOW && lastButtonState == HIGH) {
lastButtonState = state;
changeMode();
return true;
}
lastButtonState = state;
return false;
}
//Changes the mode when the button is pressed
void changeMode() {
if (mode == MODE_FLICKER) {
mode = 0;
} else {
mode++;
}
}
boolean isDarkEnough() {
lightLevel = analogRead(lightSensorPin);
if (lightLevel < ON_LEVEL) {
changeLEDS(LOW);
return false;
}
return true;
}
//Single Color Mode
void changeColors(int potVal) {
int redVal = 0;
int grnVal = 0;
int bluVal = 0;
if (potVal < 341) // Lowest third of the potentiometer's range (0-340)
{
potVal = (potVal * 3) / 4; // Normalize to 0-255
redVal = 256 - potVal; // Red from full to off
grnVal = potVal; // Green from off to full
bluVal = 1; // Blue off
if (potVal == 0) {
redVal = 255;
}
}
else if (potVal < 682) // Middle third of potentiometer's range (341-681)
{
potVal = ( (potVal-341) * 3) / 4; // Normalize to 0-255
if (potVal == 0) {
potVal = 1;
}
redVal = 1; // Red off
grnVal = 256 - potVal; // Green from full to off
bluVal = potVal; // Blue from off to full
}
else // Upper third of potentiometer"s range (682-1023)
{
potVal = ( (potVal-683) * 3) / 4; // Normalize to 0-255
if (potVal == 0) {
potVal = 1;
}
redVal = potVal; // Red from off to full
grnVal = 1; // Green off
bluVal = 256 - potVal; // Blue from full to off
}
analogWrite(RED_PIN, redVal); // Write values to LED pins
analogWrite(GREEN_PIN, grnVal);
analogWrite(BLUE_PIN, bluVal);
}
//Used to toggle LED state On/Off
void changeLEDS(int level) {
digitalWrite(RED_PIN, level);
digitalWrite(GREEN_PIN, level);
digitalWrite(BLUE_PIN, level);
}
//Full Spectrum Mode
void showRGB(int color) {
int redIntensity;
int greenIntensity;
int blueIntensity;
if (color <= 255) {
redIntensity = 255 - color;
greenIntensity = color;
blueIntensity = 0;
} else if (color <= 511) {
redIntensity = 0;
greenIntensity = 255 - (color - 256);
blueIntensity = (color - 256);
} else {
redIntensity = (color - 512);
greenIntensity = 0;
blueIntensity = 255 - (color - 512);
}
analogWrite(RED_PIN, redIntensity);
analogWrite(BLUE_PIN, blueIntensity);
analogWrite(GREEN_PIN, greenIntensity);
}
| [
"support@myfishingcompanion.com"
] | support@myfishingcompanion.com |
3b1f010a8735017fda9125602f63f7f1eaf38e92 | b2f0d04453b171b3617fc471c9a75ac2f79f1394 | /C++/src/CircularBuffer.cpp | 8b9f1910f2d1e0c477e6c0cb57fbaefccfcd23df | [] | no_license | umutediz/Circular-Buffer | f263f97681c7da97b5321864a307e22cb458e203 | 330d358ef73d0f74b263bc7a21c1f458c548b5cf | refs/heads/master | 2022-05-09T23:10:46.150684 | 2022-05-04T16:59:00 | 2022-05-04T16:59:00 | 228,043,954 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 778 | cpp | #include "CircularBuffer.h"
uint32_t CircularBuffer::availableBytes() {
return ((this->writePos - this->readPos) & (this->size - 1));
}
tBufferStatus CircularBuffer::write(uint8_t data) {
if (this->availableBytes() == (this->size - 1)) {
return BufferFull;
}
this->Buffer[this->writePos] = data;
this->writePos = (this->writePos + 1) & (this->size - 1); // must be atomic
return BufferTrue;
};
tBufferStatus CircularBuffer::read(uint8_t *data) {
if (this->availableBytes() == 0) {
return BufferEmpty;
}
*data = this->Buffer[this->readPos];
this->readPos = ((this->readPos + 1) & (this->size - 1));
return BufferTrue;
};
uint16_t CircularBuffer::_get_pos(uint32_t index){
return ((index) & (this->size - 1));
} | [
"umtedz@gmail.com"
] | umtedz@gmail.com |
93d2a696d7100b11d14d31eaed2ad2e848dec865 | 56ff71c5f130ed426dcc9f807e4c84840a1c425d | /utils/androidutils.cpp | 488c4c5331b952acf673661c8d03f09944b57361 | [
"BSD-2-Clause"
] | permissive | KDAB/android | 0a1d547a0616bccec49ce8619518d05632a7d4f2 | b95842d422421933326b55088d850f6edb19f508 | refs/heads/master | 2022-08-13T09:36:14.920368 | 2022-07-28T07:31:34 | 2022-07-28T07:31:34 | 51,908,006 | 54 | 19 | BSD-2-Clause | 2022-07-07T06:51:14 | 2016-02-17T08:46:55 | C++ | UTF-8 | C++ | false | false | 1,617 | cpp | #include "androidutils.h"
#include <deque>
#include <memory>
#include <mutex>
#include <QtAndroid>
#include <QSemaphore>
#include <QAndroidJniEnvironment>
namespace KDAB {
namespace Android {
static std::deque<Runnable> s_pendingRunnables;
static std::mutex s_pendingRunnablesMutex;
void runOnAndroidThread(const Runnable &runnable)
{
s_pendingRunnablesMutex.lock();
bool triggerRun = s_pendingRunnables.empty();
s_pendingRunnables.push_back(runnable);
s_pendingRunnablesMutex.unlock();
if (triggerRun) {
QtAndroid::androidActivity().callMethod<void>("runOnUiThread",
"(Ljava/lang/Runnable;)V",
QAndroidJniObject("com/kdab/android/utils/Runnable").object());
}
}
void runOnAndroidThreadSync(const Runnable &runnable, int waitMs)
{
std::shared_ptr<QSemaphore> sem = std::make_shared<QSemaphore>();
runOnAndroidThread([sem, &runnable](){
runnable();
sem->release();
});
sem->tryAcquire(1, waitMs);
}
extern "C" JNIEXPORT void JNICALL Java_com_kdab_android_utils_Runnable_runPendingCppRunnables(JNIEnv */*env*/, jobject /*obj*/)
{
for (;;) { // run all posted runnables
s_pendingRunnablesMutex.lock();
if (s_pendingRunnables.empty()) {
s_pendingRunnablesMutex.unlock();
break;
}
Runnable runnable(std::move(s_pendingRunnables.front()));
s_pendingRunnables.pop_front();
s_pendingRunnablesMutex.unlock();
runnable();
}
}
} // namespace Android
} // KDAB
| [
"bogdan@kdab.com"
] | bogdan@kdab.com |
7963629e619b6d161d9e60fdd2de93b011c07e11 | 35fae9aab6d53e6d128be6f596a005ffbf043411 | /device-vk.cpp | 655e64c6c73a716663353a78fd81f05819b1542d | [] | no_license | omigamedev/x3d | add53d2d48b00d484593728fe504bf88c103c5aa | e065bc79817aa8833bcc87637ca7e5918d2df4ab | refs/heads/main | 2023-06-11T02:51:09.024514 | 2021-07-01T11:56:38 | 2021-07-01T11:56:38 | 382,017,401 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,944 | cpp | #include "device-vk.h"
#include "device-vk-state.h"
#include "buffer-vk.h"
#include "swapchain-vk.h"
#include "window.h"
#include "window-state.h"
#include <stdexcept>
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE;
DeviceVK::DeviceVK(const DeviceFeatures& features, const Window& window)
{
m_state = std::make_unique<DeviceVKState>();
if (!Create(features, window))
throw std::runtime_error("Could not create DeviceVK in ctor.");
}
DeviceVK::~DeviceVK()
{
Flush();
}
bool DeviceVK::Create(const DeviceFeatures& features, const Window& window)
{
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
m_state->dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
vk::ApplicationInfo instance_app_info;
instance_app_info.pApplicationName = "VulkanSample";
instance_app_info.applicationVersion = VK_MAKE_VERSION(0, 1, 0);
instance_app_info.pEngineName = "X3DEngine";
instance_app_info.engineVersion = VK_MAKE_VERSION(0, 1, 0);
instance_app_info.apiVersion = VK_API_VERSION_1_2;
std::vector<const char*> instance_layers;
if (features.debug)
{
instance_layers.push_back("VK_LAYER_KHRONOS_validation");
}
std::vector<const char*> instance_extensions;
instance_extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
instance_extensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
instance_extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
if (features.debug)
{
instance_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
}
vk::InstanceCreateInfo instance_info;
instance_info.pApplicationInfo = &instance_app_info;
instance_info.enabledLayerCount = (uint32_t)instance_layers.size();
instance_info.ppEnabledLayerNames = instance_layers.data();
instance_info.enabledExtensionCount = (uint32_t)instance_extensions.size();
instance_info.ppEnabledExtensionNames = instance_extensions.data();
m_state->instance = vk::createInstanceUnique(instance_info);
VULKAN_HPP_DEFAULT_DISPATCHER.init(*m_state->instance);
// Create Surface
vk::Win32SurfaceCreateInfoKHR surface_info;
surface_info.hinstance = window.State().hInst;
surface_info.hwnd = window.State().hWnd;
m_state->surface = m_state->instance->createWin32SurfaceKHRUnique(surface_info);
if (!FindDevice(features))
return false;
return true;
}
bool DeviceVK::FindDevice(const DeviceFeatures& features)
{
std::vector<vk::PhysicalDevice> physical_devices = m_state->instance->enumeratePhysicalDevices();
for (const auto& pd : physical_devices)
{
auto pd_props = pd.getProperties();
auto props = pd.getQueueFamilyProperties();
for (int family_index = 0; family_index < props.size(); family_index++)
{
bool support_graphics = (bool)(props[family_index].queueFlags & vk::QueueFlagBits::eGraphics);
bool support_present = pd.getSurfaceSupportKHR(family_index, *m_state->surface);
if (support_graphics && support_present && pd_props.deviceType == vk::PhysicalDeviceType::eDiscreteGpu)
{
std::vector<const char*> device_layers;
std::vector<const char*> device_extensions;
device_extensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
if (features.raytracing)
{
device_extensions.push_back(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME);
device_extensions.push_back(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
device_extensions.push_back(VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME);
}
std::array<float, 1> queue_priorities{ 1.f };
vk::DeviceQueueCreateInfo queue_info;
queue_info.queueFamilyIndex = family_index;
queue_info.queueCount = 1;
queue_info.pQueuePriorities = queue_priorities.data();
vk::StructureChain device_info{
vk::DeviceCreateInfo()
.setQueueCreateInfoCount(1)
.setPQueueCreateInfos(&queue_info)
.setEnabledLayerCount((uint32_t)device_layers.size())
.setPpEnabledLayerNames(device_layers.data())
.setEnabledExtensionCount((uint32_t)device_extensions.size())
.setPpEnabledExtensionNames(device_extensions.data()),
vk::StructureChain{
vk::PhysicalDeviceFeatures2(),
vk::PhysicalDeviceVulkan12Features()
.setBufferDeviceAddress(true)
.setDescriptorIndexing(true),
vk::PhysicalDeviceRayTracingPipelineFeaturesKHR()
.setRayTracingPipeline(true),
}.get<vk::PhysicalDeviceFeatures2>(),
};
m_state->device = pd.createDeviceUnique(device_info.get<vk::DeviceCreateInfo>());
m_state->physical_device = pd;
m_state->device_family = family_index;
return true;
}
}
}
return false;
}
std::shared_ptr<Swapchain> DeviceVK::CreateSwapchain()
{
return nullptr;
}
std::shared_ptr<Buffer> DeviceVK::CreateBuffer()
{
return nullptr;
}
DeviceVKState& DeviceVK::State()
{
return *m_state;
}
void DeviceVK::Flush()
{
if (m_state && m_state->device)
m_state->device->waitIdle();
}
| [
"omarator@gmail.com"
] | omarator@gmail.com |
a2449c15228f399aadf5222d10fac2a381a943a4 | 09eff63c68852a52d7a472638305641e036f2856 | /Libraries/libraries/arduino_timer-1.0.0/src/timer.h | c4414206c94b1ba1d4564a4dcd7847a3802c3bc4 | [
"BSD-3-Clause"
] | permissive | Rodrigosilvacarvalho/Arduino | cbe814f09e8ce0a6f8614230fd83c48c349fefb8 | c30abd2adeb5b84781a2dee2451462c0e7222dee | refs/heads/master | 2023-03-17T00:14:30.918080 | 2023-03-11T00:03:37 | 2023-03-11T00:03:37 | 56,406,622 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,748 | h | /**
arduino-timer - library for delaying function calls
Copyright (c) 2018, Michael Contreras
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _CM_ARDUINO_TIMER_H__
#define _CM_ARDUINO_TIMER_H__
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#ifndef TIMER_MAX_TASKS
#define TIMER_MAX_TASKS 0x10
#endif
template <
size_t max_tasks = TIMER_MAX_TASKS, /* max allocated tasks */
unsigned long (*time_func)() = millis /* time function for timer */
>
class Timer {
public:
typedef bool (*handler_t)(void *opaque); /* task handler func signature */
/* Calls handler with opaque as argument in delay units of time */
bool
in(unsigned long delay, handler_t h, void *opaque = NULL)
{
return add_task(time_func(), delay, h, opaque);
}
/* Calls handler with opaque as argument at time */
bool
at(unsigned long time, handler_t h, void *opaque = NULL)
{
const unsigned long now = time_func();
return add_task(now, time - now, h, opaque);
}
/* Calls handler with opaque as argument every interval units of time */
bool
every(unsigned long interval, handler_t h, void *opaque = NULL)
{
return add_task(time_func(), interval, h, opaque, interval);
}
/* Ticks the timer forward - call this function in loop() */
void
tick()
{
tick(time_func());
}
/* Ticks the timer forward - call this function in loop() */
inline
void
tick(unsigned long t)
{
for (size_t i = 0; i < max_tasks; ++i) {
struct task * const task = &tasks[i];
const unsigned long duration = t - task->start;
if (task->handler && duration >= task->expires) {
task->repeat = task->handler(task->opaque) && task->repeat;
if (task->repeat) task->start = t;
else remove(task);
}
}
}
private:
struct task {
handler_t handler; /* task handler callback func */
void *opaque; /* argument given to the callback handler */
unsigned long start,
expires, /* when the task expires */
repeat; /* repeat task */
} tasks[max_tasks];
inline
void
remove(struct task *task)
{
task->handler = NULL;
task->opaque = NULL;
task->start = 0;
task->expires = 0;
task->repeat = 0;
}
inline
struct task *
next_task_slot()
{
for (size_t i = 0; i < max_tasks; ++i) {
struct task * const slot = &tasks[i];
if (slot->handler == NULL) return slot;
}
return NULL;
}
inline
struct task *
add_task(unsigned long start, unsigned long expires,
handler_t h, void *opaque, bool repeat = 0)
{
struct task * const slot = next_task_slot();
if (!slot) return NULL;
slot->handler = h;
slot->opaque = opaque;
slot->start = start;
slot->expires = expires;
slot->repeat = repeat;
return slot;
}
};
/* create a timer with the default settings */
inline Timer<>
timer_create_default()
{
return Timer<>();
}
#endif
| [
"rodrigo.silva.carvalho@hotmail.com"
] | rodrigo.silva.carvalho@hotmail.com |
c54a3a02635fc61e373cda77146870b70e2e1a91 | 45517cdb50f4879dbdf6ab7b8642a6d75e6bb4f4 | /test/scratch/test.scratch.format_defects/implicit_link.cpp | 6f4cc70e1766a5390e015c5aa025754f3bde90ec | [
"BSD-2-Clause"
] | permissive | JerYme/fastformat | 582b1cf09989f24e0f4d2923c0d59078eafd162c | 4eb72021b719dbff87f71a429f874b45caa3aff1 | refs/heads/master | 2021-01-10T21:03:46.699748 | 2014-03-04T14:05:25 | 2014-03-04T14:05:25 | 17,403,641 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 961 | cpp | /* /////////////////////////////////////////////////////////////////////////
* File: implicit_link.cpp
*
* Purpose: Implicit link file for the test.scratch.format_defects project.
*
* Created: 2nd December 2008
* Updated: 11th August 2009
*
* Status: Wizard-generated
*
* License: (Licensed under the Synesis Software Open License)
*
* Copyright (c) 2008-2009, Synesis Software Pty Ltd.
* All rights reserved.
*
* www: http://www.synesis.com.au/software
*
* ////////////////////////////////////////////////////////////////////// */
/* FastFormat Header Files */
#include <fastformat/implicit_link.h>
/* UNIXEm Header Files */
#include <platformstl/platformstl.h>
#if defined(PLATFORMSTL_OS_IS_UNIX) && \
defined(_WIN32)
# include <unixem/implicit_link.h>
#endif /* operating system */
/* ///////////////////////////// end of file //////////////////////////// */
| [
"jeremy@fizames.name"
] | jeremy@fizames.name |
94c0fdf6057dfdd3fe85881148d90bdb60482c28 | 5d3f49bfbb5c2cbf5b594753a40284559568ebfd | /implement/eglplus/enums/gl_colorspace_range.ipp | 8b3493aca309e8e790bb82788bad6fdcc1d1a367 | [
"BSL-1.0"
] | permissive | highfidelity/oglplus | f28e41c20e2776b8bd9c0a87758fb6b9395ff649 | c5fb7cc21869cb9555cfa2a7e28ea6bc6491d11e | refs/heads/develop | 2021-01-16T18:57:37.366227 | 2015-04-08T18:35:37 | 2015-04-08T18:54:19 | 33,630,979 | 2 | 8 | null | 2015-04-08T20:38:33 | 2015-04-08T20:38:32 | null | UTF-8 | C++ | false | false | 1,038 | ipp | // File implement/eglplus/enums/gl_colorspace_range.ipp
//
// Automatically generated file, DO NOT modify manually.
// Edit the source 'source/enums/eglplus/gl_colorspace.txt'
// or the 'source/enums/make_enum.py' script instead.
//
// Copyright 2010-2015 Matus Chochlik.
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
namespace enums {
EGLPLUS_LIB_FUNC aux::CastIterRange<
const EGLenum*,
GLColorspace
> ValueRange_(GLColorspace*)
#if (!EGLPLUS_LINK_LIBRARY || defined(EGLPLUS_IMPLEMENTING_LIBRARY)) && \
!defined(EGLPLUS_IMPL_EVR_GLCOLORSPACE)
#define EGLPLUS_IMPL_EVR_GLCOLORSPACE
{
static const EGLenum _values[] = {
#if defined EGL_GL_COLORSPACE_sRGB
EGL_GL_COLORSPACE_sRGB,
#endif
#if defined EGL_GL_COLORSPACE_LINEAR
EGL_GL_COLORSPACE_LINEAR,
#endif
0
};
return aux::CastIterRange<
const EGLenum*,
GLColorspace
>(_values, _values+sizeof(_values)/sizeof(_values[0])-1);
}
#else
;
#endif
} // namespace enums
| [
"chochlik@gmail.com"
] | chochlik@gmail.com |
db22062e489faeba58db584ccecafd7285e4ea07 | df2fd8ad365d7dc9bb0d8e155e4315945b69119b | /mian2/Logical.h | 74f9e55430d09cdadb1c61942d41ab3bd788da60 | [] | no_license | LEE2020957316/TrafficLight | 6b91a901caef73197843d75dae6afd3d38cda79d | f3bb0058ecbc75211e0fdb691fa0acdf44ab2205 | refs/heads/master | 2021-02-05T22:50:24.923336 | 2020-04-17T00:19:25 | 2020-04-17T00:19:25 | 243,844,770 | 0 | 0 | null | 2020-02-28T20:02:04 | 2020-02-28T20:02:04 | null | UTF-8 | C++ | false | false | 4,810 | h | class Logical{
public:
int Newtg(SensorES & Ts)
{
if(Ts.outputT()<1)
{
return 10;//Tc.Gettg()= Tc.Gettg();// 3 chooses
}
else if(Ts.outputT()>=1 && Ts.outputT()<=2)
{
return 15//Tc.Gettg()+=5;
}
else if(Ts.outputT()>=2)
{
return 20;//Tc.Gettg()+=10;
}
}// 以上为四个sensor线程需要的全部过程:输出时间并计算
int Gettg(SensorES & Obj1, SensorWN & Obj2)// 作比较 输入对象(同一个类的不同对象),(加锁)
{
int tg=0; //SensorES tes; SensorWN twn;
if(Newtg(Obj1)>=Newtg(Obj2))
{
tg=Newtg(Obj1);
}
else {tg=Newtg(Obj2);}
return tg;
}
void YellowLight(CarLightEW*YL)
{ YL->CounterY();}
YellowLight(&CEW);
YellowLight(&CSN);
virtual void CounterGR()// EW绿灯亮
{
greenEWini();
redSNini();
//SNsensorini();
for(tgEW=tg,tgEW>0,tgEW--)//EW green, and SN sensortimer star
{
digitalWrite(6, 1);
digitalWrite(4, 1);
digitalWrite(5, 1); //EW green, else red
tg--;
//sensortimer();
}
void sensor(){}
void carlight(){}
void walklight(){}
private:
lock
CarLightEW CEW;
CarLightSN CSN;
SensorES SE, SS;
SensorWN SW, SN;
class SensorES{
public:
//void Counter()
void GetT()
{
t0= CarLight::tg;// ?! 此处应该有锁!
if(t0 =5)// counterv t can not exceed 1 minutes? 用 wait 等待
{
do
{
t=t+0.01;
ds delay(10); //sleep(0.01)=10ms
}while(digitalRead(12)==(1) && t0>=0);// has input signals 被遮挡
}
virtual int outputT()
{
digitalWrite (23,1); //operate timer; digitalwrite(int pin, int value)// if value != 0 == high)
reture t; }
private:
int t;
int t0;
class SensorWN: punlic SensorES
{
public:
//void Counter()
void GetT()
{
t1= CarLight::tg;
if(t1=5)// counterv t can not exceed 1 minutes?
{
do
{
t2=t2+0.01;
ds delay(10); //sleep(0.01)=10ms
}while(digitalRead(18==(1))&& t0>=0);// has input signals
}
virtual int outputT()
{
digitalWrite (23,1); //operate timer; digitalwrite(int pin, int value)// if value != 0 == high)
reture t0;
}
private:
int t2;
int t1;
class CarLightEW
{
public:
CarLightEW(int tgEW=0, int tyEW=3)
{
redEWini();
greenEWini();
yellowEWini();
this->tgEW= tgEW;
this->tg= tg;
}
public:
void redEWini()
{
PinMode(1,OUTPUT);
digitalWrite(1, LOW);
}
void greenEWini()
{
PinMode(6,OUTPUT);
digitalWrite(6, LOW);
}
void yellowEWini()
{
PinMode(3,OUTPUT);
digitalWrite(3, LOW);
}
void GNewtg(Logical & logical, SensorES & Obj1, SensorWN & Obj2)//时间比较后所得
{
tg=logical.Gettg(Obj1,Obj2);
}
virtual void CounterGR()// EW绿灯亮
{
greenEWini();
redSNini();
//SNsensorini();
for(tgEW=tg,tgEW>0,tgEW--)//EW green, and SN sensortimer star
{
digitalWrite(6, 1);
digitalWrite(4, 1);
digitalWrite(5, 1); //EW green, else red
tg--;
//sensortimer();
}
virtual void CounterY()
{
yellowEWini();
//redSNini();
for(tyEW=3,tyEW>0,tyEW--)
{
digitalWrite(2, 1);
//digitalWrite(4, 1);
//digitalWrite(5, 1); //EW yellow, else red(不用)
}
public:
static int tg;
private:
int tgEW;
int tyEW;
}
int CarLightEW::tg=0;//tg initialize.
class CarLightSN: public CarLightEW
{
CarLightSN(int tgEW=0, int tyEW=3, int tySN=3, int tgSN=0 ): CarLightEW(tgEW, tyEW)
{
redSNini();
greenSNini();
yellowSNini();
this->tgSN= tgSN;
this->tySN= tySN;
}
void redSNini()
{
PinMode(4,OUTPUT);
digitalWrite(4, LOW);
}
void greenSNini()
{
PinMode(26,OUTPUT);
digitalWrite(26, LOW);
}
void yellowSNini()
{
PinMode(2,OUTPUT);
digitalWrite(2, LOW);
}
void GNewtg(Logical & logical, SensorES & Obj1, SensorWN & Obj2)//时间比较后所得
{
CarLightEW::tg=logical.Gettg(Obj1,Obj2);
}
virtual void CounterGR()// SN绿灯亮
{
redEWini();
greenSNini();
EWsesorini(); // SN green, and EW sensortimer star
tgEW= CarLightEW::tg;
for(tgSN=10,tgSN>0,tgSN--)
{
digitalWrite(1, 1);
digitalWrite(26, 1);
digitalWrite(27, 1); //SN green, else red;
CarLightEW::tg--;
}
virtual void CounterY() //黄灯亮
{
yelloeSNini();
//redEWini();
for(tySN=3,tySN>0,tySN--)
{
//digitalWrite(1, 1);
digitalWrite(3, 1);
//digitalWrite(5, 1); //SN yellow, else red
sensortimer();
}
private:
int tgSN;
int tySN;
/* 1. public:
SensorES(){
t=0;//初始化
t0=0;
PinMode(23,OUTPUT);
}// pinmode (int pin, int mode), computer control it by 23
public:
SensorES()
{
t2=0
t1=0
PinMode(23,OUTPUT);
}// pinmode (int pin, int mode), computer control it by 23// 初始化 对象已经调用
| [
"noreply@github.com"
] | noreply@github.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.