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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b1a65c7162fcfa7fa4b81f5646d4893713bc2892 | 50f67bd6f2bff84f9803126c7f74e811e8db4648 | /sos_blink/sos_blink.ino | 011f288cea9461836764b36cc5ec019e901f70af | [] | no_license | AgungHardeka17/Arduino-1 | e788be40cf7c0cb5a00ddea0fa697647befa5695 | 6285f8a407f0fa6c234bdbd94dee9c2dd1975d6f | refs/heads/master | 2020-04-12T21:55:07.947225 | 2015-12-25T17:04:51 | 2015-12-25T17:04:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,697 | ino | /*
sos_blink.ino
Blinks "SOS" in Morse code on an LED.
Based on the "Blink" example that comes with the standard Arduino
package of code.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// blink the Morse code for the letter S
void ess() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
return;
}
// blink the Morse code for the letter O
void ohh() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
return;
}
// blink the Morse code for the space between letters
void space() {
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a 500 mS
return;
}
// the loop routine runs over and over again forever:
void loop() {
ess();
space();
ohh();
space();
ess();
space();
space();
// digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
// delay(1000); // wait for a second
// digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
// delay(500); // wait for a second
}
| [
"rth@wisdomgroup.com"
] | rth@wisdomgroup.com |
af107785712e3183551571b32245ceecf84b8256 | 6bbaf735bd1af2833c5ca54c8ba2c94362c64d37 | /opencv-4.1.1/modules/imgcodecs/src/rgbe.cpp | 7942fcd903855c9ce63f605e3d7ff6d8fd7b2926 | [
"Apache-2.0",
"BSD-3-Clause"
] | permissive | Jonsuff/AutoDeliverProject_Turtlebot3 | 93487927c97931457bed53825b47022fd0dbe90e | 7efe84c07f993d3457d5d5897c3f099688f68e75 | refs/heads/master | 2021-07-13T16:29:56.349212 | 2019-11-11T10:56:51 | 2019-11-11T10:56:51 | 212,256,298 | 0 | 1 | Apache-2.0 | 2020-10-13T16:58:32 | 2019-10-02T04:37:51 | C++ | UTF-8 | C++ | false | false | 15,833 | cpp | /*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not 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 Intel Corporation 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.
//
//M*/
#include "precomp.hpp"
#include "rgbe.hpp"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
// This file contains code to read and write four byte rgbe file format
// developed by Greg Ward. It handles the conversions between rgbe and
// pixels consisting of floats. The data is assumed to be an array of floats.
// By default there are three floats per pixel in the order red, green, blue.
// (RGBE_DATA_??? values control this.) Only the minimal header reading and
// writing is implemented. Each routine does error checking and will return
// a status value as defined below. This code is intended as a skeleton so
// feel free to modify it to suit your needs.
// Some opencv specific changes have been added:
// inline define specified, error handler uses CV_Error,
// defines changed to work in bgr color space.
//
// posted to http://www.graphics.cornell.edu/~bjw/
// written by Bruce Walter (bjw@graphics.cornell.edu) 5/26/95
// based on code written by Greg Ward
#define INLINE inline
/* offsets to red, green, and blue components in a data (float) pixel */
#define RGBE_DATA_RED 2
#define RGBE_DATA_GREEN 1
#define RGBE_DATA_BLUE 0
/* number of floats per pixel */
#define RGBE_DATA_SIZE 3
enum rgbe_error_codes {
rgbe_read_error,
rgbe_write_error,
rgbe_format_error,
rgbe_memory_error
};
/* default error routine. change this to change error handling */
static int rgbe_error(int rgbe_error_code, const char *msg)
{
switch (rgbe_error_code) {
case rgbe_read_error:
CV_Error(cv::Error::StsError, "RGBE read error");
break;
case rgbe_write_error:
CV_Error(cv::Error::StsError, "RGBE write error");
break;
case rgbe_format_error:
CV_Error(cv::Error::StsError, cv::String("RGBE bad file format: ") +
cv::String(msg));
break;
default:
case rgbe_memory_error:
CV_Error(cv::Error::StsError, cv::String("RGBE error: \n") +
cv::String(msg));
}
}
/* standard conversion from float pixels to rgbe pixels */
/* note: you can remove the "inline"s if your compiler complains about it */
static INLINE void
float2rgbe(unsigned char rgbe[4], float red, float green, float blue)
{
float v;
int e;
v = red;
if (green > v) v = green;
if (blue > v) v = blue;
if (v < 1e-32) {
rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;
}
else {
v = static_cast<float>(frexp(v,&e) * 256.0/v);
rgbe[0] = (unsigned char) (red * v);
rgbe[1] = (unsigned char) (green * v);
rgbe[2] = (unsigned char) (blue * v);
rgbe[3] = (unsigned char) (e + 128);
}
}
/* standard conversion from rgbe to float pixels */
/* note: Ward uses ldexp(col+0.5,exp-(128+8)). However we wanted pixels */
/* in the range [0,1] to map back into the range [0,1]. */
static INLINE void
rgbe2float(float *red, float *green, float *blue, unsigned char rgbe[4])
{
float f;
if (rgbe[3]) { /*nonzero pixel*/
f = static_cast<float>(ldexp(1.0,rgbe[3]-(int)(128+8)));
*red = rgbe[0] * f;
*green = rgbe[1] * f;
*blue = rgbe[2] * f;
}
else
*red = *green = *blue = 0.0;
}
/* default minimal header. modify if you want more information in header */
int RGBE_WriteHeader(FILE *fp, int width, int height, rgbe_header_info *info)
{
const char *programtype = "RGBE";
if (info && (info->valid & RGBE_VALID_PROGRAMTYPE))
programtype = info->programtype;
if (fprintf(fp,"#?%s\n",programtype) < 0)
return rgbe_error(rgbe_write_error,NULL);
/* The #? is to identify file type, the programtype is optional. */
if (info && (info->valid & RGBE_VALID_GAMMA)) {
if (fprintf(fp,"GAMMA=%g\n",info->gamma) < 0)
return rgbe_error(rgbe_write_error,NULL);
}
if (info && (info->valid & RGBE_VALID_EXPOSURE)) {
if (fprintf(fp,"EXPOSURE=%g\n",info->exposure) < 0)
return rgbe_error(rgbe_write_error,NULL);
}
if (fprintf(fp,"FORMAT=32-bit_rle_rgbe\n\n") < 0)
return rgbe_error(rgbe_write_error,NULL);
if (fprintf(fp, "-Y %d +X %d\n", height, width) < 0)
return rgbe_error(rgbe_write_error,NULL);
return RGBE_RETURN_SUCCESS;
}
/* minimal header reading. modify if you want to parse more information */
int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info)
{
char buf[128];
float tempf;
int i;
if (info) {
info->valid = 0;
info->programtype[0] = 0;
info->gamma = info->exposure = 1.0;
}
// 1. read first line
if (fgets(buf,sizeof(buf)/sizeof(buf[0]),fp) == NULL)
return rgbe_error(rgbe_read_error,NULL);
if ((buf[0] != '#')||(buf[1] != '?')) {
/* if you want to require the magic token then uncomment the next line */
/*return rgbe_error(rgbe_format_error,"bad initial token"); */
}
else if (info) {
info->valid |= RGBE_VALID_PROGRAMTYPE;
for(i=0;i<static_cast<int>(sizeof(info->programtype)-1);i++) {
if ((buf[i+2] == 0) || isspace(buf[i+2]))
break;
info->programtype[i] = buf[i+2];
}
info->programtype[i] = 0;
}
// 2. reading other header lines
bool hasFormat = false;
for(;;) {
if (fgets(buf,sizeof(buf)/sizeof(buf[0]),fp) == 0)
return rgbe_error(rgbe_read_error,NULL);
if (buf[0] == '\n') // end of the header
break;
else if (buf[0] == '#') // comment
continue;
else if (strcmp(buf,"FORMAT=32-bit_rle_rgbe\n") == 0)
hasFormat = true;
else if (info && (sscanf(buf,"GAMMA=%g",&tempf) == 1)) {
info->gamma = tempf;
info->valid |= RGBE_VALID_GAMMA;
}
else if (info && (sscanf(buf,"EXPOSURE=%g",&tempf) == 1)) {
info->exposure = tempf;
info->valid |= RGBE_VALID_EXPOSURE;
}
}
if (strcmp(buf,"\n") != 0)
return rgbe_error(rgbe_format_error,
"missing blank line after FORMAT specifier");
if (!hasFormat)
return rgbe_error(rgbe_format_error, "missing FORMAT specifier");
// 3. reading resolution string
if (fgets(buf,sizeof(buf)/sizeof(buf[0]),fp) == 0)
return rgbe_error(rgbe_read_error,NULL);
if (sscanf(buf,"-Y %d +X %d",height,width) < 2)
return rgbe_error(rgbe_format_error,"missing image size specifier");
return RGBE_RETURN_SUCCESS;
}
/* simple write routine that does not use run length encoding */
/* These routines can be made faster by allocating a larger buffer and
fread-ing and fwrite-ing the data in larger chunks */
int RGBE_WritePixels(FILE *fp, float *data, int numpixels)
{
unsigned char rgbe[4];
while (numpixels-- > 0) {
float2rgbe(rgbe,data[RGBE_DATA_RED],
data[RGBE_DATA_GREEN],data[RGBE_DATA_BLUE]);
data += RGBE_DATA_SIZE;
if (fwrite(rgbe, sizeof(rgbe), 1, fp) < 1)
return rgbe_error(rgbe_write_error,NULL);
}
return RGBE_RETURN_SUCCESS;
}
/* simple read routine. will not correctly handle run length encoding */
int RGBE_ReadPixels(FILE *fp, float *data, int numpixels)
{
unsigned char rgbe[4];
while(numpixels-- > 0) {
if (fread(rgbe, sizeof(rgbe), 1, fp) < 1)
return rgbe_error(rgbe_read_error,NULL);
rgbe2float(&data[RGBE_DATA_RED],&data[RGBE_DATA_GREEN],
&data[RGBE_DATA_BLUE],rgbe);
data += RGBE_DATA_SIZE;
}
return RGBE_RETURN_SUCCESS;
}
/* The code below is only needed for the run-length encoded files. */
/* Run length encoding adds considerable complexity but does */
/* save some space. For each scanline, each channel (r,g,b,e) is */
/* encoded separately for better compression. */
static int RGBE_WriteBytes_RLE(FILE *fp, unsigned char *data, int numbytes)
{
#define MINRUNLENGTH 4
int cur, beg_run, run_count, old_run_count, nonrun_count;
unsigned char buf[2];
cur = 0;
while(cur < numbytes) {
beg_run = cur;
/* find next run of length at least 4 if one exists */
run_count = old_run_count = 0;
while((run_count < MINRUNLENGTH) && (beg_run < numbytes)) {
beg_run += run_count;
old_run_count = run_count;
run_count = 1;
while( (beg_run + run_count < numbytes) && (run_count < 127)
&& (data[beg_run] == data[beg_run + run_count]))
run_count++;
}
/* if data before next big run is a short run then write it as such */
if ((old_run_count > 1)&&(old_run_count == beg_run - cur)) {
buf[0] = static_cast<unsigned char>(128 + old_run_count); /*write short run*/
buf[1] = data[cur];
if (fwrite(buf,sizeof(buf[0])*2,1,fp) < 1)
return rgbe_error(rgbe_write_error,NULL);
cur = beg_run;
}
/* write out bytes until we reach the start of the next run */
while(cur < beg_run) {
nonrun_count = beg_run - cur;
if (nonrun_count > 128)
nonrun_count = 128;
buf[0] = static_cast<unsigned char>(nonrun_count);
if (fwrite(buf,sizeof(buf[0]),1,fp) < 1)
return rgbe_error(rgbe_write_error,NULL);
if (fwrite(&data[cur],sizeof(data[0])*nonrun_count,1,fp) < 1)
return rgbe_error(rgbe_write_error,NULL);
cur += nonrun_count;
}
/* write out next run if one was found */
if (run_count >= MINRUNLENGTH) {
buf[0] = static_cast<unsigned char>(128 + run_count);
buf[1] = data[beg_run];
if (fwrite(buf,sizeof(buf[0])*2,1,fp) < 1)
return rgbe_error(rgbe_write_error,NULL);
cur += run_count;
}
}
return RGBE_RETURN_SUCCESS;
#undef MINRUNLENGTH
}
int RGBE_WritePixels_RLE(FILE *fp, float *data, int scanline_width,
int num_scanlines)
{
unsigned char rgbe[4];
unsigned char *buffer;
int i, err;
if ((scanline_width < 8)||(scanline_width > 0x7fff))
/* run length encoding is not allowed so write flat*/
return RGBE_WritePixels(fp,data,scanline_width*num_scanlines);
buffer = (unsigned char *)malloc(sizeof(unsigned char)*4*scanline_width);
if (buffer == NULL)
/* no buffer space so write flat */
return RGBE_WritePixels(fp,data,scanline_width*num_scanlines);
while(num_scanlines-- > 0) {
rgbe[0] = 2;
rgbe[1] = 2;
rgbe[2] = static_cast<unsigned char>(scanline_width >> 8);
rgbe[3] = scanline_width & 0xFF;
if (fwrite(rgbe, sizeof(rgbe), 1, fp) < 1) {
free(buffer);
return rgbe_error(rgbe_write_error,NULL);
}
for(i=0;i<scanline_width;i++) {
float2rgbe(rgbe,data[RGBE_DATA_RED],
data[RGBE_DATA_GREEN],data[RGBE_DATA_BLUE]);
buffer[i] = rgbe[0];
buffer[i+scanline_width] = rgbe[1];
buffer[i+2*scanline_width] = rgbe[2];
buffer[i+3*scanline_width] = rgbe[3];
data += RGBE_DATA_SIZE;
}
/* write out each of the four channels separately run length encoded */
/* first red, then green, then blue, then exponent */
for(i=0;i<4;i++) {
if ((err = RGBE_WriteBytes_RLE(fp,&buffer[i*scanline_width],
scanline_width)) != RGBE_RETURN_SUCCESS) {
free(buffer);
return err;
}
}
}
free(buffer);
return RGBE_RETURN_SUCCESS;
}
int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
int num_scanlines)
{
unsigned char rgbe[4], *scanline_buffer, *ptr, *ptr_end;
int i, count;
unsigned char buf[2];
if ((scanline_width < 8)||(scanline_width > 0x7fff))
/* run length encoding is not allowed so read flat*/
return RGBE_ReadPixels(fp,data,scanline_width*num_scanlines);
scanline_buffer = NULL;
/* read in each successive scanline */
while(num_scanlines > 0) {
if (fread(rgbe,sizeof(rgbe),1,fp) < 1) {
free(scanline_buffer);
return rgbe_error(rgbe_read_error,NULL);
}
if ((rgbe[0] != 2)||(rgbe[1] != 2)||(rgbe[2] & 0x80)) {
/* this file is not run length encoded */
rgbe2float(&data[RGBE_DATA_RED],&data[RGBE_DATA_GREEN],&data[RGBE_DATA_BLUE],rgbe);
data += RGBE_DATA_SIZE;
free(scanline_buffer);
return RGBE_ReadPixels(fp,data,scanline_width*num_scanlines-1);
}
if ((((int)rgbe[2])<<8 | rgbe[3]) != scanline_width) {
free(scanline_buffer);
return rgbe_error(rgbe_format_error,"wrong scanline width");
}
if (scanline_buffer == NULL)
scanline_buffer = (unsigned char *)
malloc(sizeof(unsigned char)*4*scanline_width);
if (scanline_buffer == NULL)
return rgbe_error(rgbe_memory_error,"unable to allocate buffer space");
ptr = &scanline_buffer[0];
/* read each of the four channels for the scanline into the buffer */
for(i=0;i<4;i++) {
ptr_end = &scanline_buffer[(i+1)*scanline_width];
while(ptr < ptr_end) {
if (fread(buf,sizeof(buf[0])*2,1,fp) < 1) {
free(scanline_buffer);
return rgbe_error(rgbe_read_error,NULL);
}
if (buf[0] > 128) {
/* a run of the same value */
count = buf[0]-128;
if ((count == 0)||(count > ptr_end - ptr)) {
free(scanline_buffer);
return rgbe_error(rgbe_format_error,"bad scanline data");
}
while(count-- > 0)
*ptr++ = buf[1];
}
else {
/* a non-run */
count = buf[0];
if ((count == 0)||(count > ptr_end - ptr)) {
free(scanline_buffer);
return rgbe_error(rgbe_format_error,"bad scanline data");
}
*ptr++ = buf[1];
if (--count > 0) {
if (fread(ptr,sizeof(*ptr)*count,1,fp) < 1) {
free(scanline_buffer);
return rgbe_error(rgbe_read_error,NULL);
}
ptr += count;
}
}
}
}
/* now convert data from buffer into floats */
for(i=0;i<scanline_width;i++) {
rgbe[0] = scanline_buffer[i];
rgbe[1] = scanline_buffer[i+scanline_width];
rgbe[2] = scanline_buffer[i+2*scanline_width];
rgbe[3] = scanline_buffer[i+3*scanline_width];
rgbe2float(&data[RGBE_DATA_RED],&data[RGBE_DATA_GREEN],
&data[RGBE_DATA_BLUE],rgbe);
data += RGBE_DATA_SIZE;
}
num_scanlines--;
}
free(scanline_buffer);
return RGBE_RETURN_SUCCESS;
}
| [
"dbwhdtjq92@gmail.com"
] | dbwhdtjq92@gmail.com |
3dcc66fac5fa1cfad7f6e7d2b76f58c9f9986321 | b1d642303a1faa701569587950fa1c5b133264d1 | /src/algorithms/sorting/bubble_sort.hpp | 01d6caf70bdd269915c0cab8bb3e7b2a2c4e9de3 | [
"MIT"
] | permissive | cleybertandre/CppNotes | 469f98eab4b7fa7af5b97a8f5aa9a7f38d6a2b69 | 1c6318976f3dccb03f32145d6d839b47c006171d | refs/heads/master | 2020-03-31T22:01:28.778636 | 2018-10-02T11:00:17 | 2018-10-02T11:00:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,072 | hpp | #ifndef BUBBLESORT_HPP_
#define BUBBLESORT_HPP_
#include <algorithm>
// Bubble Sort Algorithm
// Simple and slow algorithm
// http://en.wikipedia.org/wiki/Bubble_sort
namespace BS {
class Solution {
public:
// Basic algorithm
// Best case performance: O(n^2)
// Worst case performance: O(n^2)
// Worst Case Auxiliary Space Complexity: O(1)
// @input:
// - container - object of container type with sortable items
template<typename T>
static void BubbleSort(T& container) {
// Why we need to check container emptyness:
// container.size() = size_t
// size_t - long unsigned int
// if size == 0 -> 0 - 1 = max(long unsigned int)
if (container.empty()) {
return;
}
for (size_t i = 0; i < container.size() - 1; ++i) {
for(size_t j = 0; j < container.size() - i - 1; ++j) {
if (container[j + 1] < container[j]) {
std::swap(container[j + 1], container[j]);
// swap:
// int temp = container[j + 1];
// container[j] = container[j + 1];
// container[j + 1] = temp;
}
}
}
}
// Optimised basic algorithm
// Best case performance: O(n)
// Worst case performance: O(n^2)
// Worst Case Auxiliary Space Complexity: O(1)
// @input:
// - container - object of container type with sortable items
template<typename T>
static void BubbleSortOptimised(T& container) {
if (container.empty()) {
return;
}
for (size_t i = 0; i < container.size() - 1; ++i) {
bool swapUsed = false;
for(size_t j = 0; j < container.size() - i - 1; ++j) {
if (container[j + 1] < container[j]) {
std::swap(container[j + 1], container[j]);
swapUsed = true;
}
}
// If we did not swap elements in container, it means that
// all elements are sorted and we can exit
if (!swapUsed) {
return;
}
}
}
// Recursive algorithm
// Best case performance: O(n)
// Worst case performance: O(n^2)
// Worst Case Auxiliary Space Complexity: O(1)
// @input:
// - container - object of container type with sortable items
template<typename T>
static void BubbleSortRecursive(T& container) {
BSRImpl(container, container.size());
}
private:
template<typename T>
static void BSRImpl(T& container, const size_t size) {
if (size <= 0) {
return;
}
bool swapUsed = false;
for(size_t j = 0; j < size - 1; ++j) {
if (container[j + 1] < container[j]) {
std::swap(container[j + 1], container[j]);
swapUsed = true;
}
}
if (!swapUsed) {
return;
}
BSRImpl(container, size - 1);
}
};
}
#endif /* BUBBLESORT_HPP_ */
| [
"antony.cherepanov@gmail.com"
] | antony.cherepanov@gmail.com |
9c410328633f9efb671fa812f10bcc08c4148182 | 801ea2db8d6be6c0d5a79d3d48348b9fae14bb47 | /kernel/include/Luna/vmm/drivers/fast_a20.hpp | 5d2fff411279fa9ce035c26ae537853208b96e10 | [] | no_license | xmduke/Luna | 8a0d07cc33d705bf12246c2c34cd1becf1790200 | 1f47b4dc32f71e1a36d4cf40e7d9e190e913f8e8 | refs/heads/master | 2023-06-20T23:27:36.916709 | 2021-08-01T12:18:01 | 2021-08-01T12:18:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,171 | hpp | #pragma once
#include <Luna/common.hpp>
#include <Luna/vmm/vm.hpp>
#include <Luna/misc/log.hpp>
namespace vm::fast_a20 {
constexpr uint16_t gate = 0x92;
struct Driver : public vm::AbstractPIODriver {
Driver(Vm* vm) {
vm->pio_map[gate] = this;
}
void pio_write(uint16_t port, uint32_t value, uint8_t size) {
ASSERT(size == 1);
if(port == gate) {
auto a20 = (value >> 1) & 1;
if(!a20)
PANIC("Guest attempted to clear A20 line");
if(value != (1 << 1))
print("fast_20: Unhandled write to Port A: {:#x}\n", value);
} else {
print("fast_a20: Unhandled write to port {:#x}: {:#x}\n", port, value);
}
}
uint32_t pio_read(uint16_t port, uint8_t size) {
ASSERT(size == 1);
if(port == gate)
return (1 << 1); // Port A20 is always enabled
else {
print("fast_a20: Unhandled read from port {:#x}\n", port);
return 0;
}
}
};
} // namespace vm::fast_a20
| [
"twoertman@gmail.com"
] | twoertman@gmail.com |
6871c4e3417a220b41aaec1309b6c93b651a000b | 996c85f515e8aa549cd885fc2da20513facc0f5f | /IEEE754/bitSetN/bitSetN.ino | b93a51e4af578ec404ce95c9effd3dfaafbf4253 | [] | no_license | alafSantos/VLC_Arduino | 06093487f0068198f01b47511b33296591460726 | 483547d465bfea2ce9ab530644150dcd2dbff435 | refs/heads/main | 2023-01-28T16:32:05.234852 | 2020-12-06T16:20:18 | 2020-12-06T16:20:18 | 312,460,661 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 846 | ino | void setup() {
Serial.begin(9600);
}
void loop() {
//int bitsArray[] = {0,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //7.5
int bitsArray[] = {0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//9.0
float value = 0;
//lidando com sinal
int sign = 1;
if(bitsArray[0]) sign = -1;
//lidando com expoente
int exp754 = bitsArray[1]*pow(2,7) + bitsArray[2]*pow(2,6) + bitsArray[3]*pow(2,5) + bitsArray[4]*pow(2,4) + bitsArray[5]*pow(2,3) + bitsArray[6]*pow(2,2) + bitsArray[7]*pow(2,1) + bitsArray[8]*pow(2,0);
exp754 = exp754 - 127;
//lidando com mantissa
int power = -1;
float mant = 0.0;
for ( int i = 0; i < 23; i++ )
{
int c = bitsArray[ i + 9 ];
mant += (float) c * (float) pow( 2.0, power );
power--;
}
mant += 1.0;
value = sign*(float)pow(2.0,exp754)*mant;
Serial.println(value);
}
| [
"alaf.ns4@gmail.com"
] | alaf.ns4@gmail.com |
6b0a70294ef068769fad496b864799861958ec49 | 12769f01ead8cdac20ea20b472076f3e8c87c66b | /UdpSock.h | 04fce665c7ae8a69ab5c375b0ed8af1e9b6469e3 | [] | no_license | Shelikhov/task_1 | 68048f2088791feefc90d494567258e0443b5cca | 431e80f24e58423f84480c384a3ea2d7d2410456 | refs/heads/master | 2020-12-02T10:44:17.615294 | 2020-01-06T02:53:37 | 2020-01-06T02:53:37 | 230,985,609 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 555 | h | #include "CurTime.cpp"
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netinet/in.h>
#include "ErrorCheck.h"
#define PORT 8080
class UdpSock{
public:
void createServSock();//server socket
void createCliSock();//client socket
void closeSock();
void recvMsg(auto &buffer);
void sendMsg(auto &value);
private:
int udpSocket;
struct sockaddr_in serverAddr, clientAddr;
struct in_addr addr;//network address
int checkResult;
socklen_t len;
ErrorCheck err;//to check return value
};
| [
"shelikhov-2016@mail.ru"
] | shelikhov-2016@mail.ru |
86de6cdb1665d8d4afd0213d916f4f831041de4e | df902f892f2f38b97475a877f6fb5f7dacba7ae1 | /Version 1.6/lib/basic_tree_automaton.h | e6d167edc3622dad4e9fe4f8db927a3886987212 | [] | no_license | cathiec/CathTA | e6f32a8209437ca723abb454195207ecbab62466 | 32ff3c1e725134818dd11db467f79f935cd8b046 | refs/heads/master | 2021-01-10T13:30:52.811746 | 2016-03-22T16:50:15 | 2016-03-22T16:50:15 | 46,280,286 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,450 | h | #ifndef basic_tree_automaton_h
#define basic_tree_automaton_h
#include "basic_transition.h"
#include "basic_product_state.h"
#include "occurrence.h"
#include "state_with_dimension.h"
#include "words_automaton.h"
#include "combination.h"
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
class basic_tree_automaton
{
public:
/* name */
std::string _name;
/* ranked alphabet */
basic_set<symbol> SIGMA;
/* finite set of states */
basic_set<basic_state> Q;
/* finite set of final states */
basic_set<basic_state> F;
/* finite set of transition rules */
basic_set<basic_transition> DELTA;
/* max number of arguments for all the transition rules */
int _max_nb_arg;
public:
/// default constructor
basic_tree_automaton()
{}
/// constructor by parsing a file
basic_tree_automaton(std::string f)
{
std::ifstream file(f);
if(file.is_open())
{
std::string s;
// symbols (ranked alphabet)
do
{
file >> s;
}while(s == "\t");
if(s != "Ops")
throw 1; /// no symbol
bool has_name = false;
int nb_symbols = 0;
_max_nb_arg = -1;
while(file >> s)
{
if(s == "\t")
continue;
if(s != "Automaton")
{
int pos_mid = s.find(':');
std::string symbol_name = s.substr(0, pos_mid);
int symbol_rank = atoi(s.substr(pos_mid + 1).c_str());
if(symbol_rank > _max_nb_arg)
_max_nb_arg = symbol_rank;
SIGMA.add(symbol(symbol_name, symbol_rank), true);
nb_symbols++;
}
else
{
has_name = true;
break;
}
}
// automaton name
if(!has_name)
throw 2; /// no automaton name
do
{
file >> s;
}while(s == "\t");
_name = s;
// states
do
{
file >> s;
}while(s == "\t");
if(s != "States")
throw 3; /// no state
bool has_final_states = false;
while(file >> s)
{
if(s == "\t")
continue;
if(s != "Final")
{
int pos_mid = s.find(':');
std::string state_name = s.substr(0, pos_mid);
int state_rank = atoi(s.substr(pos_mid + 1).c_str());
if(state_rank != 0)
throw 4; /// state has a rank > 0
Q.add(basic_state(state_name), true);
}
else
{
do
{
file >> s;
}while(s == "\t");
if(s == "States")
has_final_states = true;
break;
}
}
// final states
if(!has_final_states)
throw 5; /// no final state
bool has_transitions = false;
while(file >> s)
{
if(s == "\t")
continue;
if(s != "Transitions")
F.add(basic_state(s), true);
else
{
has_transitions = true;
break;
}
}
// transitions
if(!has_transitions)
throw 6; /// no transition
file.get();
while(getline(file, s))
if(s.length() > 0)
DELTA.add(basic_transition(s), true);
file.close();
}
else
{
throw 7; ///no such file
}
}
/// destructor
~basic_tree_automaton()
{}
/// remove all the useless elements
void remove_useless()
{
}
/// save in a file
void save_in_file(std::string name) const
{
std::ofstream file(name);
if(file.is_open())
{
// ranked alphabet
file << "Ops ";
for(int i = 1; i <= SIGMA.size(); i++)
{
file << SIGMA[i]._name;
file << ":";
file << SIGMA[i]._rank;
file << " ";
}
file << std::endl << std::endl;
// name
file << "Automaton A" << std::endl << std::endl;
// finite set of states
file << "States ";
for(int i = 1; i <= Q.size(); i++)
{
file << Q[i] << " ";
}
file << std::endl << std::endl;
// finite set of final states
file << "Final States ";
for(int i = 1; i <= F.size(); i++)
{
file << F[i] << " ";
}
file << std::endl << std::endl;
// finite set of transition rules
file << "Transitions" << std::endl;
for(int i = 1; i <= DELTA.size(); i++)
{
file << to_string(DELTA[i]) << std::endl;
}
file.close();
}
else
{
throw 8; ///cannot create a new file
}
}
/// union
basic_tree_automaton rename() const
{
basic_tree_automaton result = *this;
result._name += "'";
for(int i = 1; i <= Q.size(); i++)
result.Q[i]._name += "'";
for(int i = 1; i <= F.size(); i++)
result.F[i]._name += "'";
for(int i = 1; i <= DELTA.size(); i++)
{
for(int j = 1; j <= DELTA[i]._inputs.size(); j++)
result.DELTA[i]._inputs[j]._name += "'";
result.DELTA[i]._output._name += "'";
}
return result;
}
basic_tree_automaton U(const basic_tree_automaton & B) const
{
basic_tree_automaton result;
result._name = "Union of ";
result._name += _name;
result._name += " and ";
result._name += B._name;
result.SIGMA = SIGMA;
basic_tree_automaton _B = B.rename();
result.Q = Q;
result.Q.add(_B.Q);
result.F = F;
result.F.add(_B.F);
result.DELTA = DELTA;
result.DELTA.add(_B.DELTA);
return result;
}
/// intersection
basic_tree_automaton I(const basic_tree_automaton & B) const
{
basic_tree_automaton result;
result._name = "Union of ";
result._name += _name;
result._name += " and ";
result._name += B._name;
result.SIGMA = SIGMA;
result.Q = Q * B.Q;
result.F = F * B.F;
result.DELTA = cross_product_transitions(DELTA, B.DELTA);
return result;
}
/// inclusion check
/* check if a state "s" is accepted */
bool accept(const basic_state & s) const
{
if(F.contain(s))
return true;
else
return false;
}
/* check is a macro state "ms" is rejected */
bool reject(const basic_set<basic_state> & ms) const
{
for(int i = 1; i <= ms.size(); i++)
if(accept(ms[i]))
return false;
return true;
}
/* check if a product state "ps" is accepted */
bool accept(const basic_product_state & ps, const basic_tree_automaton & B) const
{
if(accept(ps._1) && B.reject(ps._2))
return true;
else
return false;
}
/* produce the set of initial states for a given symbol "s" */
basic_set<basic_state> initial_states(const symbol & s) const
{
basic_set<basic_state> result;
for(int i = 1; i <= DELTA.size(); i++)
if(DELTA[i]._alpha == s)
result.add(DELTA[i]._output);
return result;
}
/* compute the set of post image with a given symbol "s" of a given combination of micro states "cb" */
basic_set<basic_state> post(const symbol & s, const basic_tuple<basic_set<basic_state> > cb) const
{
basic_set<basic_state> result;
if(s._rank != cb.size())
return result;
for(int i = 1; i <= DELTA.size(); i++)
{
basic_transition t = DELTA[i];
if(t._alpha == s)
{
bool ok = true;
for(int j = 1; j <= s._rank; j++)
{
if(!cb[j].contain(t._inputs[j]))
{
ok = false;
break;
}
}
if(ok)
result.add(t._output);
}
}
return result;
}
/* compute possible Pi according to qi */
basic_set<basic_set<basic_state> > possible_Pi(const basic_state & qi, const basic_set<basic_product_state> & Processed) const
{
basic_set<basic_set<basic_state> > result;
for(int i = 1; i <= Processed.size(); i++)
{
if(Processed[i]._1 == qi)
result.add(Processed[i]._2);
}
return result;
}
/* compute all the possible combinations of P1 to Pn */
basic_set<basic_tuple<basic_set<basic_state> > > possible_combinations_Pi(const basic_tuple<basic_state> & cb_qi, const basic_set<basic_product_state> & Processed) const
{
basic_set<basic_tuple<basic_set<basic_state> > > result;
if(cb_qi.size() > 1)
{
basic_tuple<basic_state> next_recursion = cb_qi;
next_recursion._size_repre--;
basic_state qn = cb_qi[cb_qi.size()];
basic_set<basic_set<basic_state> > possible_Pn = possible_Pi(qn, Processed);
basic_set<basic_tuple<basic_set<basic_state> > > possible_combinations_P1_to_Pn_minus_1 = possible_combinations_Pi(next_recursion, Processed);
for(int i = 1; i <= possible_combinations_P1_to_Pn_minus_1.size(); i++)
{
for(int j = 1; j <= possible_Pn.size(); j++)
{
basic_tuple<basic_set<basic_state> > cb_Pi = possible_combinations_P1_to_Pn_minus_1[i];
basic_set<basic_state> Pn = possible_Pn[j];
cb_Pi.add(Pn);
result.add(cb_Pi);
}
}
}
else
{
basic_state q1 = cb_qi[1];
basic_set<basic_set<basic_state> > possible_P1 = possible_Pi(q1, Processed);
for(int i = 1; i <= possible_P1.size(); i++)
{
basic_tuple<basic_set<basic_state> > cb_P1;
basic_set<basic_state> P1 = possible_P1[i];
cb_P1.add(P1);
result.add(cb_P1);
}
}
return result;
}
/* compute the set of post image of a given set of product states "Processed" w.r.t. a given product state "rR" */
basic_set<basic_product_state> post(const basic_product_state & rR, const basic_set<basic_product_state> & Processed, const basic_tree_automaton & B) const
{
basic_state r = rR._1;
basic_set<basic_state> R = rR._2;
basic_set<basic_product_state> result;
basic_set<basic_state> q_Processed;
for(int i = 1; i <= Processed.size(); i++)
q_Processed.add(Processed[i]._1);
for(int i = 1; i <= DELTA.size(); i++)
{
basic_transition t = DELTA[i];
basic_set<int> occurrences_r = occurrences(t._inputs, r);
if(occurrences_r.size() > 0 && q_Processed.contain(t._inputs))
{
basic_set<basic_tuple<basic_set<basic_state> > > possible_P1_to_Pn = possible_combinations_Pi(t._inputs, Processed);
for(int j = 1; j <= possible_P1_to_Pn.size(); j++)
{
basic_set<int> occurrences_R = occurrences(possible_P1_to_Pn[j], R);
if(occurrences_have_same_index(occurrences_r, occurrences_R))
result.add(basic_product_state(t._output, B.post(t._alpha, possible_P1_to_Pn[j])));
}
}
}
return result;
}
/* check if the language of the current tree automaton is included in the language of a tree automaton "B" */
bool is_included_in(const basic_tree_automaton & B) const
{
basic_set<basic_product_state> Processed;
basic_set<basic_product_state> Next;
for(int i = 1; i <= DELTA.size(); i++)
if(DELTA[i]._alpha._rank == 0)
{
basic_product_state temp(DELTA[i]._output, B.initial_states(DELTA[i]._alpha));
if(accept(temp, B))
return false;
Next.add(temp);
}
while(Next.size() > 0)
{
basic_product_state rR = Next[1];
Next.del(rR);
Processed.add(rR);
basic_set<basic_product_state> rR_post = post(rR, Processed, B);
for(int i = 1; i <= rR_post.size(); i++)
{
basic_product_state pP = rR_post[i];
basic_state p = pP._1;
basic_set<basic_state> P = pP._2;
if(accept(pP, B))
return false;
bool exist = false;
for(int j = 1; j <= Processed.size(); j++)
{
basic_state q = Processed[j]._1;
basic_set<basic_state> Q = Processed[j]._2;
if(p == q && P.contain(Q))
{
exist = true;
break;
}
}
if(exist)
continue;
for(int j = 1; j <= Next.size(); j++)
{
basic_state q = Next[j]._1;
basic_set<basic_state> Q = Next[j]._2;
if(p == q && P.contain(Q))
{
exist = true;
break;
}
}
if(exist)
continue;
for(int j = 1; j <= Processed.size(); j++)
{
basic_state q = Processed[j]._1;
basic_set<basic_state> Q = Processed[j]._2;
if(q == p && Q.contain(P))
{
Processed.del(Processed[j]);
j--;
}
}
for(int j = 1; j <= Next.size(); j++)
{
basic_state q = Next[j]._1;
basic_set<basic_state> Q = Next[j]._2;
if(q == p && Q.contain(P))
{
Next.del(Next[j]);
j--;
}
}
Next.add(pP);
}
}
return true;
}
/// compute the max dimension
basic_set<basic_tuple<state_with_dimension> > all_combinations(basic_tuple<basic_set<state_with_dimension> > cb) const
{
basic_set<basic_tuple<state_with_dimension> > result;
if(cb.size() == 1)
{
for(int i = 1; i <= cb[1].size(); i++)
{
basic_tuple<state_with_dimension> temp;
temp.add(cb[1][i]);
result.add(temp);
}
}
else
{
basic_tuple<basic_set<state_with_dimension> > small_recursion = cb;
small_recursion._size_repre--;
basic_set<basic_tuple<state_with_dimension> > result_small_recursion = all_combinations(small_recursion);
for(int i = 1; i <= result_small_recursion.size(); i++)
for(int j = 1; j <= cb[cb.size()].size(); j++)
{
basic_tuple<state_with_dimension> temp;
temp = result_small_recursion[i];
temp.add(cb[cb.size()][j]);
result.add(temp);
}
}
return result;
}
basic_set<state_with_dimension> Post(basic_set<state_with_dimension> Processed, state_with_dimension qd) const
{
basic_set<state_with_dimension> result;
for(int i = 1; i <= DELTA.size(); i++)
{
basic_transition t = DELTA[i];
bool all_in_Processed = true;
bool contain_qd = false;
basic_tuple<basic_set<state_with_dimension> > cb;
for(int j = 1; j <= t._inputs.size(); j++)
{
bool one_in_Processed = false;
basic_set<state_with_dimension> possible_input_slot;
for(int k = 1; k <= Processed.size(); k++)
{
if(Processed[k]._name == t._inputs[j]._name)
{
one_in_Processed = true;
possible_input_slot.add(Processed[k]);
}
}
cb.add(possible_input_slot);
if(!one_in_Processed)
{
all_in_Processed = false;
break;
}
if(!contain_qd && t._inputs[j]._name == qd._name)
contain_qd = true;
}
if(all_in_Processed && contain_qd)
{
basic_set<basic_tuple<state_with_dimension> > all_possible_inputs = all_combinations(cb);
for(int j = 1; j <= all_possible_inputs.size(); j++)
{
state_with_dimension one_result(t._output._name);
int max_d = -1;
bool max_d_twice = false;
bool triangle = false;
for(int k = 1; k <= all_possible_inputs[j].size(); k++)
{
one_result.add_history(all_possible_inputs[j][k]);
if(one_result.triangle_check())
{
triangle = true;
break;
}
if(all_possible_inputs[j][k]._dimension > max_d)
{
max_d = all_possible_inputs[j][k]._dimension;
max_d_twice = false;
}
else if(all_possible_inputs[j][k]._dimension == max_d)
max_d_twice = true;
}
if(triangle)
one_result._dimension = -1;
else
{
if(max_d_twice)
max_d++;
one_result._dimension = max_d;
}
result.add(one_result);
}
}
}
return result;
}
int max_dimension() const
{
basic_set<state_with_dimension> Processed;
basic_set<state_with_dimension> Next;
for(int i = 1; i <= DELTA.size(); i++)
if(DELTA[i]._alpha._rank == 0)
Next.add(state_with_dimension(DELTA[i]._output._name, 0));
int max_dim = 0;
while(Next.size() > 0)
{
state_with_dimension qd = Next[1];
Next.del(qd);
Processed.add(qd);
basic_set<state_with_dimension> Post_Processed_qd = Post(Processed, qd);
for(int i = 1; i <= Post_Processed_qd.size(); i++)
{
state_with_dimension pe = Post_Processed_qd[i];
if(pe._dimension == -1)
return -1;
if(pe._dimension > max_dim)
max_dim = pe._dimension;
bool exist = false;
for(int j = 1; j <= Processed.size(); j++)
{
state_with_dimension pf = Processed[j];
if(pe <= pf)
{
exist = true;
break;
}
}
if(exist)
continue;
for(int j = 1; j <= Next.size(); j++)
{
state_with_dimension pf = Next[j];
if(pe <= pf)
{
exist = true;
break;
}
}
if(!exist)
{
for(int j = 1; j <= Processed.size(); j++)
{
state_with_dimension pf = Processed[j];
if(pf <= pe)
Processed.del(pf);
}
for(int j = 1; j <= Next.size(); j++)
{
state_with_dimension pf = Next[j];
if(pf <= pe)
Next.del(pf);
}
Next.add(pe);
}
}
}
return max_dim;
}
/// transform into a words automaton with bound of dimension
basic_set<combination<std::string> > all_combinations(const basic_tuple<basic_state> inputs) const
{
basic_set<combination<std::string> > result;
if(inputs.size() == 0)
{
result.add(combination<std::string> ());
}
else if(inputs.size() == 1)
{
combination<std::string> one_element;
one_element.add(inputs[1]._name);
result.add(one_element);
}
else
{
for(int i = 1; i <= inputs.size(); i++)
{
combination<std::string> temp;
temp.add(inputs[i]._name);
basic_tuple<basic_state> copy = inputs;
copy.del(inputs[i]);
basic_set<combination<std::string> > rest_cb = all_combinations(copy);
for(int j = 1; j <= rest_cb.size(); j++)
{
combination<std::string> copy_temp = temp;
for(int k = 1; k <= rest_cb[j].size(); k++)
copy_temp.add(rest_cb[j][k]);
result.add(copy_temp);
}
}
}
return result;
}
words_automaton transform_into_words_automaton(int max_dimension) const
{
int max_stack_size = (_max_nb_arg - 1) * max_dimension + 1;
if(max_stack_size < 1)
max_stack_size = 1;
words_automaton result;
result._name = "transformed " + _name;
words_automaton_state epsilon;
result.Q.add(epsilon);
result.I.add(epsilon);
for(int i = 1; i <= F.size(); i++)
{
words_automaton_state final_state;
final_state.push_in(F[i]._name);
result.F.add(final_state);
basic_tuple<words_automaton_state> stack;
stack.add(final_state);
while(stack.size() > 0)
{
words_automaton_state current = stack[stack.size()];
stack._size_repre--;
std::string name_of_first = current._t[current._t.size()];
words_automaton_state right;
for(int j = 1; j <= current._t.size(); j++)
right.push_in(current._t[j]);
result.Q.add(right);
for(int j = 1; j <= DELTA.size(); j++)
if(DELTA[j]._output == name_of_first)
{
basic_set<combination<std::string> > cb = all_combinations(DELTA[j]._inputs);
for(int k = 1; k <= cb.size(); k++)
{
words_automaton_state left(current);
left.push_out();
for(int m = 1; m <= cb[k].size(); m++)
left.push_in(cb[k][m]);
// maximum dimension
if(left._t.size() <= max_stack_size)
{
words_automaton_transition new_transition;
new_transition._alpha = DELTA[j]._alpha._name;
new_transition._right = right;
new_transition._left = left;
//std::cout << new_transition << std::endl;
result.DELTA.add(new_transition);
if(!result.Q.contain(left))
{
result.Q.add(left, true);
stack.add(left);
}
}
}
}
//std::cout << stack << std::endl;
}
}
return result;
}
};
/// basic_tree_automaton -> std::string
std::string to_string(const basic_tree_automaton & ta)
{
std::string result = "";
int i;
result += "Automaton [";
result += ta._name;
result += "]\n";
result += "--- RANKED ALPHABET ---\n";
for(i = 1; i <= ta.SIGMA.size(); i++)
{
result += "\t";
result += to_string(ta.SIGMA[i]);
result += "\n";
}
result += "--- STATES ---\n";
for(i = 1; i <= ta.Q.size(); i++)
{
result += "\t";
result += to_string(ta.Q[i]);
result += "\n";
}
result += "--- FINAL STATES ---\n";
for(i = 1; i <= ta.F.size(); i++)
{
result += "\t";
result += to_string(ta.F[i]);
result += "\n";
}
result += "--- TRANSITIONS ---\n";
for(i = 1; i <= ta.DELTA.size(); i++)
{
result += "\t";
result += to_string(ta.DELTA[i]);
result += "\n";
}
return result;
}
/// basic_tree_automaton -> std::ostream
std::ostream & operator<<(std::ostream & out, const basic_tree_automaton & ta)
{
out << to_string(ta);
return out;
}
#endif
| [
"xiao.xu.cathiec@gmail.com"
] | xiao.xu.cathiec@gmail.com |
b8f20bd075c86358adb3f60aa1f038edd7634564 | 4599649f9889188c681bbde50dc5ceae76590d55 | /serverTool/httpModule/AccUserReg.cpp | 3f157ecc7d6a91ef6648f80558adc4ceb5c2b7a9 | [] | no_license | wuxiang/language | fbdfe078ddc261f58cbea6dcc4d7405a9ced17ca | f8d5c8c803e35285569da21ed0f1ea3650c33018 | refs/heads/master | 2021-01-18T22:58:49.824021 | 2016-07-04T03:25:56 | 2016-07-04T03:25:56 | 2,753,949 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 4,848 | cpp | #include "AccUserReg.h"
#include "CWorkThread.h"
#include "TeaEncrypt.h"
#include "CHttp.h"
extern CLog _log;
AccUserRegList_t g_AccUserRegList;
pthread_mutex_t g_AccUserRegListlock;
extern std::map<unsigned int, ServerIdTokickUser > g_mServIpToThread;
extern int RegEnable;
extern char AccUserRegAddr[128];
AccUserReg::AccUserReg(void)
{
pthread_mutex_init(&g_AccUserRegListlock,NULL);
}
AccUserReg::~AccUserReg(void)
{
pthread_mutex_destroy(&g_AccUserRegListlock);
}
char *url_encode(char const *s, int len,unsigned char *OUTBUF, int *new_length)
{
//#define safe_emalloc(nmemb, size, offset) malloc((nmemb) * (size) + (offset))
static unsigned char hexchars[] = "0123456789ABCDEF";
register unsigned char c;
unsigned char *to, *start;
unsigned char const *from, *end;
from = (unsigned char *)s;
end = (unsigned char *)s + len;
start = to = OUTBUF;//(unsigned char *) safe_emalloc(3, len, 1);
while (from < end) {
c = *from++;
if (c == ' ') {
*to++ = '+';
#ifndef CHARSET_EBCDIC
} else if ((c < '0' && c != '-' && c != '.') ||
(c < 'A' && c > '9') ||
(c > 'Z' && c < 'a' && c != '_') ||
(c > 'z')) {
to[0] = '%';
to[1] = hexchars[c >> 4];
to[2] = hexchars[c & 15];
to += 3;
#else /*CHARSET_EBCDIC*/
} else if (!isalnum(c) && strchr("_-.", c) == NULL) {
/* Allow only alphanumeric chars and '_', '-', '.'; escape the rest */
to[0] = '%';
to[1] = hexchars[os_toascii[c] >> 4];
to[2] = hexchars[os_toascii[c] & 15];
to += 3;
#endif /*CHARSET_EBCDIC*/
} else {
*to++ = c;
}
}
*to = 0;
if (new_length) {
*new_length = to - start;
}
return (char *) start;
}
void * AccUserReg::Startting(void *argv)
{
AccUserRegStruct _theAccUserReg;
std::map<unsigned int, ServerIdTokickUser>::iterator ServIpToThreaditer;
AccUserRegList_t::iterator iter;
CBase64 B64;
CHttp http;
http.SetURL(AccUserRegAddr);
char buf[1024]={0};
unsigned char SendBuf[1024]={0};
int new_length;
char recrbuf[1024]={0};
char OutBuf[2048]={0};
char UName[40]={0};
char PWord[40]={0};
char UNameB64[60]={0};
char PWordB64[60]={0};
unsigned char UNameB64URL[90]={0};
unsigned char PWordB64URL[90]={0};
char Ret=2;
while ( 1 )
{
iter = g_AccUserRegList.begin();
while ( iter != g_AccUserRegList.end() )
{
Ret=2;
memcpy(&_theAccUserReg,&(*iter),sizeof(AccUserRegStruct) );
memset(UName,0,sizeof(UName));
memset(PWord,0,sizeof(PWord));
memset(UNameB64,0,sizeof(UNameB64));
memset(PWordB64,0,sizeof(PWordB64));
memset(UNameB64URL,0,sizeof(UNameB64URL));
memset(PWordB64URL,0,sizeof(PWordB64URL));
memset(buf,0,sizeof(buf));
memset(SendBuf,0,sizeof(SendBuf));
memset(recrbuf,0,sizeof(recrbuf));
memset(OutBuf,0,sizeof(OutBuf));
strcpy(UName,_theAccUserReg.Acc_uname);
strcpy(PWord,_theAccUserReg.Acc_passwd);
int U=strlen(UName);
int P=strlen(PWord);
TeaEncrypt((unsigned char *)UName,U,0);
TeaEncrypt((unsigned char *)PWord,P,0);
B64.Encrypt(UName,U,UNameB64);
B64.Encrypt(PWord,P,PWordB64);
url_encode(UNameB64, strlen(UNameB64),UNameB64URL, &new_length);
url_encode(PWordB64, strlen(PWordB64),PWordB64URL, &new_length);
sprintf(buf,"method=adduser&uname=%s&upass=%s",UNameB64URL,PWordB64URL);
http.PostData((unsigned char *)buf,strlen(buf));
_log.WriteLog("AccUserReg SendBuf=%s\n",buf);
int len=http.RecvData(recrbuf,1024);
if ( len>0 )
{
int dlen=B64.Decrypt(recrbuf,len,OutBuf);
TeaDecrypt((unsigned char*)OutBuf, dlen, 0);
OutBuf[dlen]='\0';
_log.WriteLog("AccUserReg OutBuf=%s\n",OutBuf);
if(strcasestr(OutBuf,"result=0"))
Ret=0;//printf("成功\n");
else if(strcasestr(OutBuf,"result=1"))
Ret=1;//printf("已经存在\n");
else
Ret=2;//printf("其他失败\n");
}
_theAccUserReg.RegRet = Ret;
_log.WriteLog("AccUserReg name=%s,Ret=%d\n",_theAccUserReg.Acc_uname,Ret);
if ( _theAccUserReg.m_nServID !=0 )
{
ServIpToThreaditer = g_mServIpToThread.find(_theAccUserReg.m_nServID);
if ( ServIpToThreaditer != g_mServIpToThread.end() )
{
_theAccUserReg.m_nConnIndex = ServIpToThreaditer->second.nConnIndex;
((CWorkThread*)ServIpToThreaditer->second.pWorkThread)->AddToUserRegReturnList(&_theAccUserReg);
}
}
pthread_mutex_lock(&g_AccUserRegListlock);
g_AccUserRegList.pop_front();
pthread_mutex_unlock(&g_AccUserRegListlock);
iter = g_AccUserRegList.begin();
}
usleep(20000);
}
return 0;
}
int AccUserReg::AddToList(AccUserRegStruct * pData)
{
_log.WriteLog("AccUserReg::AddToList m_uname=%s,pw=%s\n",pData->Acc_uname,pData->Acc_passwd);
pthread_mutex_lock(&g_AccUserRegListlock);
AccUserRegStruct _theAccUserReg;
memcpy(&_theAccUserReg,pData,sizeof(AccUserRegStruct));
g_AccUserRegList.push_back(_theAccUserReg);
pthread_mutex_unlock(&g_AccUserRegListlock);
return 0;
}
| [
"wuxiang@qq.com"
] | wuxiang@qq.com |
893af39befa73714bd442fbeef3ba9999f297594 | 0012a0c49725303241b1bade9123bfa5398d0ec5 | /Texture.h | 7808797ad854c7b267f87f3a81bf757b3f5fa0f1 | [] | no_license | HarrySollis/DX11-A.T-Proj---Platformer | f5269bb045083906bf94bff857481ad6238be700 | a219f7b26a89f978bd3dd21b9f0373c6f0f3f6f6 | refs/heads/master | 2020-08-29T17:05:51.639092 | 2020-05-07T09:17:21 | 2020-05-07T09:17:21 | 218,102,314 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 261 | h | #pragma once
#include "Bindable.h"
class Texture : public Bindable
{
public:
Texture(Graphics& gfx, const class Surface& s);
void Bind(Graphics& gfx) noexcept override;
protected:
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> pTextureView;
};
| [
"noreply@github.com"
] | noreply@github.com |
677ff1c2ddf02fafc8eaa0425027b0682020ab77 | 32395ad696937acb798853bb2bc503637bd20628 | /src/define.h | a55ef4788319b6f2c652d64ac32534552b7c50f7 | [] | no_license | javiermtorres/MEPK | d7fdb679920443bd85e632402056ad028effd48b | 87357c35c77e5b8efb2347c4d37015fd8c78b66c | refs/heads/master | 2023-07-31T23:51:16.531887 | 2021-09-10T11:40:10 | 2021-09-10T11:40:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,047 | h | #ifndef __DEFINE_H__
#define __DEFINE_H__
#include "header.h"
#include "adnf.h"
#include "acdf.h"
using namespace std;
/*
* Definitions below are for ADNF
*/
enum ACTION_TYPE {
ONTIC,
OBSERVATION,
COMMUNICATION,
SENSING
};
// structure
struct SensingAction {
string name;
ACTION_TYPE category; // category of this action
KLDNF preCon;
KLDNF posRes;
KLDNF negRes;
};
struct ConditionalEffect {
KLDNF condition;
KLDNF effect;
};
struct OnticAction {
string name;
ACTION_TYPE category; // category of this action
KLDNF preCon;
vector<ConditionalEffect> eff;
};
/* the node used in LAO* */
struct LAONode {
ACDF kb;
double heuValue;
bool isSolved;
bool isDeadend;
LAONode(ACDF _kb, double hv, bool iss, bool isd) :
kb(_kb), heuValue(hv), isSolved(iss), isDeadend(isd) {}
};
/* the edge used in LAO* */
struct LAOEdge {
EdgeType et;
int actionIndex;
vector<int> childNode;
LAOEdge() {};
LAOEdge(EdgeType _et, int _actionIndex, vector<int> _childNode) : et(_et),
actionIndex(_actionIndex), childNode(_childNode) {};
bool operator == (const LAOEdge& r) const {
return et==r.et && actionIndex==r.actionIndex;
}
};
/*
* Definitions below are for ACDF
*/
//观察动作的描述
struct EpisAction
{
string name; //动作的名称
ACTION_TYPE category; // category of this action
ACDF pre_con; //动作执行的前置条件
ACDF pos_res; //将所需要观察的“公式”化为ACDF形式, 为了好做演进 positive result
ACDF neg_res; //将所需要观察的“公式”化为ACDF形式, 为了好做演进 negative result
};
//物理动作中的effect(效果三元组)
struct ConEffect
{
ACDF condition; //效果中的条件
ACDF effect;
};
//物理动作的描述
struct OntiAction
{
string name; //动作的名称
ACTION_TYPE category; // category of this action
ACDF pre_con; //动作执行的前置条件
vector<ConEffect> con_eff; //效果二元组
};
enum STATE_TYPE {
TOBEEXPLORED = 0,
EXPLORED,
DEAD,
FINAL_GOAL
};
//搜索算法中的结点
struct Node
{
ACDF kb; //结点的知识库
int depth = 0;
int ancestor_node_id = -1;
float heu_value = 0; // for heuristic searching
//下面两个变量分别是在搜索过程中所需要的两中标记
STATE_TYPE flag;
bool isolated;
Node() {};
Node(STATE_TYPE s, bool b, ACDF ed, int d, int an_id = 0) { flag = s; isolated = b; kb = ed; depth = d; ancestor_node_id = an_id; };
~Node() {};
};
struct Transition
{
int front_state; //前一个结点
int next_state; //后一个结点
bool is_observe_action; //是否为观察动作
bool is_true; //是否为感知动作的+
int action_number; //动作的编号
};
enum SearchType {
kHeuristic = 0,
kDepthFirst = 1,
kWidthFirst = 2,
};
#endif | [
"526552330@qq.com"
] | 526552330@qq.com |
e403a1af6fd2532ee56d2cf2f093a76013e06fd8 | 3abbb2ce88f9087d3b270aeb384a6dbdc1fad888 | /UglyNumber.cpp | 6e272ef34030a9a1110a7e8150cfbb9ac76fd71d | [] | no_license | liulin2012/myLeetcode | 262c8023ee2021dac02e5b055c0b071b5104f3c0 | 8a87da475a5206df5c33bfa6fdbab2042ca03a1a | refs/heads/master | 2021-01-10T19:39:11.414637 | 2015-12-04T20:16:31 | 2015-12-04T20:16:31 | 30,717,188 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 349 | cpp | class Solution {
public:
bool isUgly(int num) {
if (num == 1) return true;
if (num < 1) return false;
while (num != 1) {
if (num % 2 == 0) num /= 2;
else if (num % 3 == 0) num /= 3;
else if (num % 5 == 0) num /= 5;
else return false;
}
return true;
}
}; | [
"liulin.jacob@gmail.com"
] | liulin.jacob@gmail.com |
31e3d1eb37407f48db64518cd79fda561fc8c9ea | c2e9d797eef152e77453aefed420ec4799a11024 | /extensions/GUI/CCControlExtension/CCControlSlider.h | 9ee5e7014c9f82ccbd1b13ff678470e030941e9f | [] | no_license | aboduo/cocos2dx-classical | 01d88967d29580537344777e48b1db6b78ee1514 | 800c3ccea05df45f6c010fcf71e681b37df40ec0 | refs/heads/master | 2021-01-12T19:52:48.140094 | 2014-12-15T05:27:18 | 2014-12-15T05:27:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,963 | h | /*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2011 Yannick Loriot. All rights reserved.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*/
#ifndef __CCCONTROL_SLIDER_H__
#define __CCCONTROL_SLIDER_H__
#include "CCControl.h"
#include "CCInvocation.h"
NS_CC_EXT_BEGIN
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*
* A slider control whose value can vary between min and max value. The value
* can be changed in consecutive or discrete mode.
*
* \par
* Slider is composited by background, thumb, and progress. The progress is optional.
* If progress is present, it must have same size of background
*
* \note
* There is CCControlSlider in cocos2d-x extensions, but it doesn't support consecutive
* mode. I copied its code and enhanced it for a better slider.
*/
class CC_EX_DLL CCControlSlider : public CCControl {
protected:
CCControlSlider();
/// init slider
virtual bool initWithSprites(CCSprite* bg, CCSprite* thumb, CCSprite* progress);
/// update thumb and progress when value is changed
void updateSpritesForValueChange();
/// update layout
void updateLayout();
/// is touch in slider bounding box
bool isTouchInside(CCTouch* touch);
/// touch location in self space
CCPoint locationFromTouch(CCTouch* touch);
// event method
void sliderBegan(CCPoint location);
void sliderMoved(CCPoint location);
void sliderEnded(CCPoint location);
/// Returns the value for the given location
float valueForLocation(CCPoint location);
public:
virtual ~CCControlSlider();
static CCControlSlider* create(CCSprite* bg, CCSprite* thumb, CCSprite* progress = NULL);
// override
virtual bool ccTouchBegan(CCTouch* touch, CCEvent* pEvent);
virtual void ccTouchMoved(CCTouch* pTouch, CCEvent* pEvent);
virtual void ccTouchEnded(CCTouch* pTouch, CCEvent* pEvent);
virtual void ccTouchCancelled(CCTouch* pTouch, CCEvent* pEvent);
virtual void needsLayout() { updateSpritesForValueChange(); }
// values
CC_SYNTHESIZE_SETTER(float, m_value, Value);
CC_SYNTHESIZE_READONLY(int, m_intValue, IntValue);
CC_SYNTHESIZE_SETTER(float, m_minimumValue, MinimumValue);
CC_SYNTHESIZE_SETTER(float, m_maximumValue, MaximumValue);
CC_SYNTHESIZE(float, m_minimumAllowedValue, MinimumAllowedValue);
CC_SYNTHESIZE(float, m_maximumAllowedValue, MaximumAllowedValue);
// discrete mode
CC_SYNTHESIZE_BOOL(m_discreteMode, DiscreteMode);
// components
CC_SYNTHESIZE_SETTER(CCSprite*, m_thumbSprite, ThumbSprite);
CC_SYNTHESIZE_SETTER(CCSprite*, m_progressSprite, ProgressSprite);
CC_SYNTHESIZE_SETTER(CCSprite*, m_backgroundSprite, BackgroundSprite);
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif | [
"stubma@gmail.com"
] | stubma@gmail.com |
ad07576b2d122fe4cefde630e93c735cf16563c5 | 5d465dadc3b813b540d132363d46b658e834c63a | /vertual/ABC174A.cpp | 6d9c06e250f01f5e3ffbb99892ed6a5499057246 | [] | no_license | kazumurata/AtCoder | 030e31bdc7f2004f5666ed0fbc35c59066c2da03 | 8eee3a6bd15a23c9cb94779c450a44197e8e0b0c | refs/heads/master | 2022-12-29T23:30:34.691908 | 2020-10-06T18:25:43 | 2020-10-06T18:25:43 | 301,512,130 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 202 | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int X;
cin >> X;
string ans = "Yes";
if (X<30) {
ans = "No";
}
cout << ans << endl;
} | [
"70640220+kazumurata@users.noreply.github.com"
] | 70640220+kazumurata@users.noreply.github.com |
692266255409f7bc9c22b0b22c3920c8f9ef13c6 | 17bf36ad8a4a53abeb1d18d0fed8935a8ad97a0a | /mojo/gles2/command_buffer_client_impl.h | 1db0ae31a6e14b14f54954dd1ac89a05bb9597cf | [
"BSD-3-Clause"
] | permissive | TribeMedia/sky_engine | bfb52d96e37ed4771ca0ad049e36daea5f67daf9 | 4a3894ed246327931b198a7d64652bd0b615b036 | refs/heads/master | 2021-01-16T19:15:21.362385 | 2015-08-20T16:30:59 | 2015-08-20T16:30:59 | 41,107,776 | 1 | 0 | null | 2015-08-20T16:50:18 | 2015-08-20T16:50:17 | null | UTF-8 | C++ | false | false | 3,740 | h | // Copyright 2014 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 MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_
#define MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_
#include <map>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "gpu/command_buffer/client/gpu_control.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/services/gpu/public/interfaces/command_buffer.mojom.h"
namespace base {
class RunLoop;
}
namespace gles2 {
class CommandBufferClientImpl;
class CommandBufferDelegate {
public:
virtual ~CommandBufferDelegate();
virtual void ContextLost();
};
class CommandBufferClientImpl : public mojo::CommandBufferLostContextObserver,
public gpu::CommandBuffer,
public gpu::GpuControl {
public:
explicit CommandBufferClientImpl(
CommandBufferDelegate* delegate,
const MojoAsyncWaiter* async_waiter,
mojo::ScopedMessagePipeHandle command_buffer_handle);
~CommandBufferClientImpl() override;
// CommandBuffer implementation:
bool Initialize() override;
State GetLastState() override;
int32_t GetLastToken() override;
void Flush(int32_t put_offset) override;
void OrderingBarrier(int32_t put_offset) override;
void WaitForTokenInRange(int32_t start, int32_t end) override;
void WaitForGetOffsetInRange(int32_t start, int32_t end) override;
void SetGetBuffer(int32_t shm_id) override;
scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
int32_t* id) override;
void DestroyTransferBuffer(int32_t id) override;
// gpu::GpuControl implementation:
gpu::Capabilities GetCapabilities() override;
int32_t CreateImage(ClientBuffer buffer,
size_t width,
size_t height,
unsigned internalformat) override;
void DestroyImage(int32_t id) override;
int32_t CreateGpuMemoryBufferImage(size_t width,
size_t height,
unsigned internalformat,
unsigned usage) override;
uint32 InsertSyncPoint() override;
uint32 InsertFutureSyncPoint() override;
void RetireSyncPoint(uint32 sync_point) override;
void SignalSyncPoint(uint32 sync_point,
const base::Closure& callback) override;
void SignalQuery(uint32 query, const base::Closure& callback) override;
void SetSurfaceVisible(bool visible) override;
uint32 CreateStreamTexture(uint32 texture_id) override;
void SetLock(base::Lock*) override;
private:
class SyncClientImpl;
class SyncPointClientImpl;
// mojo::CommandBufferLostContextObserver implementation:
void DidLoseContext(int32_t lost_reason) override;
void TryUpdateState();
void MakeProgressAndUpdateState();
gpu::CommandBufferSharedState* shared_state() const { return shared_state_; }
CommandBufferDelegate* delegate_;
mojo::Binding<mojo::CommandBufferLostContextObserver> observer_binding_;
mojo::CommandBufferPtr command_buffer_;
scoped_ptr<SyncClientImpl> sync_client_impl_;
scoped_ptr<SyncPointClientImpl> sync_point_client_impl_;
gpu::Capabilities capabilities_;
State last_state_;
mojo::ScopedSharedBufferHandle shared_state_handle_;
gpu::CommandBufferSharedState* shared_state_;
int32_t last_put_offset_;
int32_t next_transfer_buffer_id_;
const MojoAsyncWaiter* async_waiter_;
};
} // gles2
#endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_
| [
"jackson@google.com"
] | jackson@google.com |
5b3c178ad16319b7a47fb7a2d2c6ab8ffb414dc6 | 6b660cb96baa003de9e18e332b048c0f1fa67ab9 | /External/SDK/BP_Lantern_classes.h | e181c718367fa56cc07c11203b52d55bf3ab7e7a | [] | no_license | zanzo420/zSoT-SDK | 1edbff62b3e12695ecf3969537a6d2631a0ff36f | 5e581eb0400061f6e5f93b3affd95001f62d4f7c | refs/heads/main | 2022-07-30T03:35:51.225374 | 2021-07-07T01:07:20 | 2021-07-07T01:07:20 | 383,634,601 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,939 | h | #pragma once
// Name: SoT, Version: 2.2.0.2
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass BP_Lantern.BP_Lantern_C
// 0x0098 (FullSize[0x0998] - InheritedSize[0x0900])
class ABP_Lantern_C : public ALantern
{
public:
struct FPointerToUberGraphFrame UberGraphFrame; // 0x0900(0x0008) (ZeroConstructor, Transient, DuplicateTransient)
class UStaticMeshComponent* LanternTriggerGlow; // 0x0908(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData, NonTransactional, NoDestructor)
class UStaticMeshComponent* LanternGlow; // 0x0910(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData, NonTransactional, NoDestructor)
class UAmbientLightSourceComponent* AmbientLightSource; // 0x0918(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData, NonTransactional, NoDestructor)
class USpotLightComponent* SpotLight; // 0x0920(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData, NonTransactional, NoDestructor)
class UUsableWieldableComponent* UsableWieldable; // 0x0928(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData, NonTransactional, NoDestructor)
class UMaterialInstanceDynamic* LanternGlowDynamicMaterial; // 0x0930(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor)
float EmissiveInt_threshold; // 0x0938(0x0004) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor)
unsigned char UnknownData_V4H9[0x4]; // 0x093C(0x0004) MISSED OFFSET (FIX SPACE BETWEEN PREVIOUS PROPERTY)
class UMaterialInstanceDynamic* LanternTriggerGlowDynamicMaterial; // 0x0940(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor)
float TriggerGlowDuration; // 0x0948(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor)
float TriggerGlowRampInDuration; // 0x094C(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor)
float TriggerGlowRampOutDuration; // 0x0950(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor)
struct FLinearColor DefaultSpotlightColour; // 0x0954(0x0010) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor)
struct FLinearColor DefaultAmbientLightColour; // 0x0964(0x0010) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor)
struct FLinearColor DefaultGlowColour; // 0x0974(0x0010) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor)
unsigned char UnknownData_WL5X[0x4]; // 0x0984(0x0004) MISSED OFFSET (FIX SPACE BETWEEN PREVIOUS PROPERTY)
TArray<class UMaterialInstanceDynamic*> DynamicMaterials; // 0x0988(0x0010) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_Lantern.BP_Lantern_C");
return ptr;
}
void CreateLanternDynamicMaterial();
void OnAttachThirdPerson();
void OnAttachFirstPerson();
void TurnOff();
void TurnOn();
void UserConstructionScript();
void ReceiveWieldFirstPerson();
void ReceiveWieldThirdPerson();
void ReceiveBeginPlay();
void ReceiveLightChange();
void TriggerGlow();
void PostMeshChangedBPEvent(bool SkipFlameColourTransition);
void ReceiveFlameData(bool WantChangeAnimation);
void ExecuteUbergraph_BP_Lantern(int EntryPoint);
void AfterRead();
void BeforeDelete();
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"Massimo.linker@gmail.com"
] | Massimo.linker@gmail.com |
359b6cf40de1bc037ca45ff3f8024e91e89ebeac | ae04470c3c266513002c2c5c9ac9b034614930cb | /13XX/zoj.1382.src.1.cpp | 2c3a38e964ab8e42f1eec85387069805569aa589 | [] | no_license | fish-ball/acm.zju.edu.cn | 281315b9aab0517801ca780972a327642867eb7d | 984d48539607ed082749204a81d4aecac5bdac53 | refs/heads/master | 2021-03-12T19:15:13.640962 | 2018-11-16T10:34:34 | 2018-11-16T10:34:34 | 14,883,882 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 211 | cpp | #include <iostream>
using namespace std;
int main() {
int N, n;
cin >> N;
while( N-- ) {
cin >> n;
int i = 0;
while( n % 2 == 0 ) {
i++;
n >>= 1;
}
cout << n << ' ' << i << endl;
}
}
| [
"alfred.h@163.com"
] | alfred.h@163.com |
6dde3cd5c01421066a00368da634c93b78db5232 | 0ea9ee47a93a324d9d4d151e4e6c2210b81667f7 | /IFRN/LIG_4 - 2014/remontagem/lig4 parte lógica diagonal.cpp | de90eacd2735c69667fb03fdd77f80b3a7ef7614 | [] | no_license | markleylopes/ProjetosAcademicos | 983c6598f1a53156d0e2f5ec2a47977572d28308 | fdbacb4a59e7f1c910ea12107361e55bc9120a6a | refs/heads/master | 2020-03-29T22:47:21.013237 | 2018-09-26T16:25:36 | 2018-09-26T16:25:36 | 150,440,503 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,200 | cpp | #include <iostream>
#include <fstream>
using namespace std;
string t[10][7];
void zerar()
{
for(int i=0; i<10; i++)
{
for(int j=0; j<7; j++)
{
t[i][j]=" ";
}
}
}
void tab()
{
cout<<" 1 2 3 4 5 6 7";
for(int i=0; i<10 ;i++)
{
for(int k=0; k<2; k++)
{
for(int r=0; r<7 ;r++)
{
if(r%7==0)
{
cout<<""<<endl;
if(r==0&&k==0)
{
cout<<" ---------------------------\n";
}
}
if(r==0&&k==0)
{
cout<<" "<<i;
}
else if(r==0&&!(k==0))
{
cout<<" ";
}
if(r==0)
{
cout<<"|";
}
cout<<t[i][r];cout<<t[i][r];cout<<t[i][r];cout<<"|";
}
}
}
cout<<"\n ---------------------------\n";
}
void ganhar0()
{
for(int i=4, c=4;i>0; i--)
{
t[i][c--]="f";
}
}
void ganhar()
{
int n=10, h=3, p=0;
while(!(p==4)){
for(n>h; n--;)
{
for(int j=0;j<7; j++){
if(t[n][j]=="f"){p++;}
}
}
if(p==4){cout<<"ganhou\n"; cout<<h<<endl;break;}
if(p!=4&&h==3){break;}
n--;
h++;
}
}
int main(){
zerar();
ganhar0();
tab();
ganhar();
system("pause");
};
| [
"walissonmarkley@gmail.com"
] | walissonmarkley@gmail.com |
786682fd3a8f5c23e952e97114939cb944e158f5 | 85a5acf94467c021e6f09abd18c9f4e44d305b42 | /avg/branches/dual/avg_client/avg_clientDlg.cpp | d15bbd1d6cc363974f8ac81c2f12773c23fd22ee | [] | no_license | ihoro/legacy | 6dae72b5924f00f0f10e7c7536c755db0ba5dfc4 | 755d04e5199cbf1068344052834d7f5b26dca953 | refs/heads/master | 2022-06-22T12:06:16.592656 | 2021-04-23T21:34:43 | 2021-04-23T21:34:43 | 201,345,573 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,626 | cpp | // avg_clientDlg.cpp : implementation file
//
#include "stdafx.h"
#include "avg_client.h"
#include "avg_clientDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Cavg_clientDlg dialog
Cavg_clientDlg::Cavg_clientDlg(CWnd* pParent /*=NULL*/)
: CDialog(Cavg_clientDlg::IDD, pParent),
pcf(0),
pobj(0),
obj_count(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
Cavg_clientDlg::~Cavg_clientDlg()
{
free(pobj);
}
void Cavg_clientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(Cavg_clientDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_CALC, OnBnClickedCalc)
ON_BN_CLICKED(IDC_CREATE_OBJECT, OnBnClickedCreateObject)
ON_BN_CLICKED(IDC_FREE_OBJECT, OnBnClickedFreeObject)
ON_BN_CLICKED(IDC_GET_CLASS_OBJECT, OnBnClickedGetClassObject)
ON_BN_CLICKED(IDC_CO_RELEASE, OnBnClickedCoRelease)
ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
END_MESSAGE_MAP()
// Cavg_clientDlg message handlers
BOOL Cavg_clientDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CheckRadioButton(IDC_INPROC, IDC_LOCAL, IDC_INPROC);
SetDlgItemText(IDC_SEQ, "2,1,-1,10,0,-10,-2");
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void Cavg_clientDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR Cavg_clientDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void Cavg_clientDlg::OnBnClickedGetClassObject()
{
// recognize context
DWORD ctx = CLSCTX_INPROC_SERVER;
if (GetCheckedRadioButton(IDC_INPROC, IDC_LOCAL) == IDC_LOCAL)
ctx = CLSCTX_LOCAL_SERVER;
// get class object
HRESULT hr = CoGetClassObject(CLSID_Average, ctx, 0, IID_IClassFactory, (void**)&pcf);
if (FAILED(hr))
MessageBox("Failed!", "Error", MB_OK|MB_ICONERROR);
else
{
ENABLE_ITEM(IDC_INPROC, false);
ENABLE_ITEM(IDC_LOCAL, false);
ENABLE_ITEM(IDC_GET_CLASS_OBJECT, false);
ENABLE_ITEM(IDC_CO_RELEASE, true);
ENABLE_ITEM(IDC_CREATE_OBJECT, true);
}
}
void Cavg_clientDlg::OnBnClickedCoRelease()
{
pcf->Release();
ENABLE_ITEM(IDC_INPROC, true);
ENABLE_ITEM(IDC_LOCAL, true);
ENABLE_ITEM(IDC_GET_CLASS_OBJECT, true);
ENABLE_ITEM(IDC_CO_RELEASE, false);
ENABLE_ITEM(IDC_CREATE_OBJECT, false);
}
void Cavg_clientDlg::OnBnClickedCreateObject()
{
// create object and get its interface
IAverage *p;
HRESULT hr = pcf->CreateInstance(0, IID_IAverage, (void**)&p);
// if no link
if (FAILED(hr))
{
MessageBox("Failed!", "Error", MB_OK|MB_ICONERROR);
return;
}
else
{
obj_count++;
pobj = (IUnknown**)realloc(pobj, sizeof(IUnknown*) * obj_count);
pobj[obj_count-1] = p;
CString s;
s.Format(" Objects count: %lu", obj_count);
SetDlgItemText(IDC_OBJECTS, s);
ENABLE_ITEM(IDC_FREE_OBJECT, true);
ENABLE_ITEM(IDC_CALC, true);
}
}
void Cavg_clientDlg::OnBnClickedFreeObject()
{
pobj[--obj_count] -> Release();
CString s;
s.Format(" Objects count: %lu", obj_count);
SetDlgItemText(IDC_OBJECTS, s);
ENABLE_ITEM(IDC_FREE_OBJECT, obj_count != 0);
ENABLE_ITEM(IDC_CALC, obj_count != 0);
}
void Cavg_clientDlg::OnBnClickedCalc()
{
// get input string
CString s;
GetDlgItemText(IDC_SEQ, s);
// calc avg sum
int avg;
( (IAverage*) (pobj[obj_count-1]) ) -> CalcAverageFromString((unsigned char*)s.GetBuffer(), ',', &avg);
// show result
SetDlgItemInt(IDC_RESULT, avg);
}
void Cavg_clientDlg::OnBnClickedButton2()
{
EndDialog(0);
}
| [
"ihoro@users.noreply.github.com"
] | ihoro@users.noreply.github.com |
09086e80c471f13d93d8d600aaf15c73ce244e48 | 28d9f1413f52d9cedc7775f59c8dbd6bffa7d8c0 | /wad/unordered_set.hpp | 8ec0f87c1100e94a67309eff2eeaca3de5532d45 | [
"MIT"
] | permissive | ToruNiina/wad | e5ce63492b0d7feebd11cc5fe0b290a202995b1a | f5f0445f7f0a53efd31988ce7d381bccb463b951 | refs/heads/master | 2022-12-14T15:07:15.128072 | 2020-09-01T14:43:06 | 2020-09-01T14:43:06 | 241,058,715 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,361 | hpp | #ifndef WAD_UNORDERED_SET_HPP
#define WAD_UNORDERED_SET_HPP
#include "binary_cast.hpp"
#include "type.hpp"
#include <utility>
#include <unordered_set>
namespace wad
{
template<typename T, typename Hash, typename Pred, typename Alloc, typename Arc>
bool save(Arc& arc, const std::unordered_set<T, Hash, Pred, Alloc>& v)
{
const auto savepoint = arc.npos();
if(!save_length<type::array>(arc, v.size()))
{
arc.seek(savepoint);
return false;
}
for(const auto& elem : v)
{
if(!save(arc, elem))
{
arc.seek(savepoint);
return false;
}
}
return true;
}
template<typename T, typename Hash, typename Pred, typename Alloc, typename Arc>
bool load(Arc& arc, std::unordered_set<T, Hash, Pred, Alloc>& v)
{
static_assert(std::is_default_constructible<T>::value,
"To load a type T, T must be default constructible.");
const auto savepoint = arc.npos();
std::size_t len;
if(!load_length<type::array>(arc, len))
{
arc.seek(savepoint);
return false;
}
for(std::size_t i=0; i<len; ++i)
{
T elem;
if(!load(arc, elem))
{
arc.seek(savepoint);
return false;
}
v.insert(std::move(elem));
}
return true;
}
} // wad
#endif// WAD_UNORDERED_SET_HPP
| [
"niina.toru.68u@gmail.com"
] | niina.toru.68u@gmail.com |
4b87c2c2a107d0b9ca7dd553650db56cac24b5bd | 63050fd8e71feeb3aefdb5d146f43bd289b59b11 | /Otoge/Util/Event/EventHandler.hpp | 944a42c2f8a522cc9ac51bcc8f0dfb59447661a1 | [
"IJG",
"libtiff",
"BSD-3-Clause",
"MIT"
] | permissive | NoixChou/Otoge | 9f4afcd056d9d5ece986cdd2e2b69d4abd0d6a50 | 61400ac0538d91f0d357e70cb9139b9aea7a5e6e | refs/heads/master | 2020-05-05T03:06:10.849706 | 2019-08-20T08:11:22 | 2019-08-20T08:11:22 | 179,661,105 | 4 | 2 | NOASSERTION | 2019-10-10T14:13:45 | 2019-04-05T10:20:23 | C++ | UTF-8 | C++ | false | false | 209 | hpp | #pragma once
#include "Event.hpp"
class EventHandler
{
private:
std::vector<std::function<bool(Event*)>> EventHandlers_;
public:
void registerHandler(std::function<bool(Event*)> eventHandler);
};
| [
"syutomcpe@gmail.com"
] | syutomcpe@gmail.com |
1131ccf3bfec1032eb13cb332d91588e6d24ba86 | 0424284ceb27e08c21de6cb60037eea4c4eac318 | /src/assets/rewards.h | e85c5128fa5ac8166223648b94dd18f6bee39c9a | [
"MIT"
] | permissive | zelantus/MainNet-critical-fix | 499ced9931f469a667c9edca8b20f3676db60bb7 | dd6483350264a93e3a806d041b61acda1cc39871 | refs/heads/master | 2022-12-14T23:46:00.374195 | 2020-09-07T18:42:44 | 2020-09-07T18:42:44 | 277,615,888 | 2 | 2 | MIT | 2020-09-07T18:41:39 | 2020-07-06T18:13:36 | C | UTF-8 | C++ | false | false | 4,164 | h | // Copyright (c) 2017-2019 The Zelantus Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef RAVENCOIN_REWARDS_H
#define RAVENCOIN_REWARDS_H
#include "amount.h"
#include "tinyformat.h"
#include "assettypes.h"
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <list>
class CRewardSnapshot;
class CWallet;
class CRewardSnapshot;
extern std::map<uint256, CRewardSnapshot> mapRewardSnapshots;
// Addresses are delimited by commas
static const std::string ADDRESS_COMMA_DELIMITER = ",";
const int MAX_PAYMENTS_PER_TRANSACTION = 1000;
// Individual payment record
struct OwnerAndAmount
{
std::string address;
CAmount amount;
OwnerAndAmount(
const std::string & p_address,
CAmount p_rewardAmt
)
{
address = p_address;
amount = p_rewardAmt;
}
bool operator<(const OwnerAndAmount &rhs) const
{
return address < rhs.address;
}
};
class CRewardTransaction {
uint256 txid;
int nHeight;
CRewardTransaction() {
SetNull();
}
CRewardTransaction(const uint256& p_txid, const int& p_nBatch) {
SetNull();
txid = p_txid;
}
void SetNull() {
txid.SetNull();
nHeight = 0;
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
{
READWRITE(nHeight);
READWRITE(txid);
}
};
class CRewardSnapshot {
public:
enum {
REWARD_ERROR = 0,
PROCESSING = 1,
COMPLETE = 2,
LOW_FUNDS = 3,
NOT_ENOUGH_FEE = 4,
LOW_REWARDS = 5,
STUCK_TX = 6,
NETWORK_ERROR = 7,
FAILED_CREATE_TRANSACTION = 8,
FAILED_COMMIT_TRANSACTION = 9
};
std::string strOwnershipAsset;
std::string strDistributionAsset;
std::string strExceptionAddresses;
CAmount nDistributionAmount;
uint32_t nHeight;
int nStatus;
CRewardSnapshot() {
SetNull();
}
CRewardSnapshot(const std::string& p_strOwnershipAsset, const std::string& p_strDistributionAsset, const std::string& p_strExceptionAddresses, const CAmount& p_nDistributionAmount, const uint32_t& p_nHeight) {
SetNull();
strOwnershipAsset = p_strOwnershipAsset;
strDistributionAsset = p_strDistributionAsset;
strExceptionAddresses = p_strExceptionAddresses;
nDistributionAmount = p_nDistributionAmount;
nHeight = p_nHeight;
nStatus = PROCESSING;
}
void SetNull() {
strOwnershipAsset = "";
strDistributionAsset = "";
strExceptionAddresses = "";
nDistributionAmount = 0;
nHeight = 0;
nStatus = REWARD_ERROR;
}
uint256 GetHash() const;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
{
READWRITE(strOwnershipAsset);
READWRITE(strDistributionAsset);
READWRITE(strExceptionAddresses);
READWRITE(nDistributionAmount);
READWRITE(nHeight);
// We don't want to add the status when computing the hash because it changes as the distribution is sent out
if (!(s.GetType() & SER_GETHASH))
READWRITE(nStatus);
}
};
enum {
FAILED_GETTING_DISTRIBUTION_LIST = 1,
FAILED_
};
bool GenerateDistributionList(const CRewardSnapshot& p_rewardSnapshot, std::vector<OwnerAndAmount>& vecDistributionList);
bool AddDistributeRewardSnapshot(CRewardSnapshot& p_rewardSnapshot);
#ifdef ENABLE_WALLET
void DistributeRewardSnapshot(CWallet * p_wallet, const CRewardSnapshot& p_rewardSnapshot);
bool BuildTransaction(
CWallet * const p_walletPtr, const CRewardSnapshot& p_rewardSnapshot,
const std::vector<OwnerAndAmount> & p_pendingPayments, const int& start,
std::string& change_address, uint256& retTxid);
void CheckRewardDistributions(CWallet * p_wallet);
#endif //ENABLE_WALLET
#endif //RAVENCOIN_REWARDS_H
| [
"comingtom531@gmail.com"
] | comingtom531@gmail.com |
b9e894c9490a72dc680de0ee664f2f13f6858ea9 | bb20ba88cc104e320374612e00fdddd5fefe86d8 | /C++/3rd_Party/CGAL/include/CGAL/Algebraic_kernel_for_spheres/internal_functions_comparison_root_for_spheres_2_3.h | 14f00e8994d376d4a3a5819614500c005c027442 | [] | no_license | cbtogu/3DLearning | 5949e22d16f14a57ab04e0eec0ef1c4364747c76 | 9cfc64ad1e0473aff4e2aef34da50731249d3433 | refs/heads/master | 2022-01-31T10:37:58.177148 | 2017-07-06T15:11:43 | 2017-07-06T15:11:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,693 | h | // Copyright (c) 2005-2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// 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.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Partially supported by the IST Programme of the EU as a Shared-cost
// RTD (FET Open) Project under Contract No IST-2000-26473
// (ECG - Effective Computational Geometry for Curves and Surfaces)
// and a STREP (FET Open) Project under Contract No IST-006413
// (ACS -- Algorithms for Complex Shapes)
//
// $URL$
// $Id: internal_functions_comparison_root_for_spheres_2_3.h,v 1.5 2017/02/06 12:37:02 Emmanuel.Pot Exp $
//
// Author(s) : Monique Teillaud <Monique.Teillaud@sophia.inria.fr>
// Sylvain Pion
// Pedro Machado
#ifndef CGAL_ALGEBRAIC_KERNEL_COMPARISON_ROOT_FOR_SPHERES_2_3_H
#define CGAL_ALGEBRAIC_KERNEL_COMPARISON_ROOT_FOR_SPHERES_2_3_H
namespace CGAL {
namespace AlgebraicSphereFunctors{
template <typename RT>
Comparison_result
compare_x(const CGAL::Root_for_spheres_2_3<RT>& r1, const CGAL::Root_for_spheres_2_3<RT>& r2){
return compare(r1.x(), r2.x());
}
template <typename RT>
Comparison_result
compare_y(const CGAL::Root_for_spheres_2_3<RT>& r1, const CGAL::Root_for_spheres_2_3<RT>& r2){
return compare(r1.y(), r2.y());
}
template <typename RT>
Comparison_result
compare_z(const CGAL::Root_for_spheres_2_3<RT>& r1, const CGAL::Root_for_spheres_2_3<RT>& r2){
return compare(r1.z(), r2.z());
}
template <typename RT>
Comparison_result
compare_xy(const CGAL::Root_for_spheres_2_3<RT>& r1, const CGAL::Root_for_spheres_2_3<RT>& r2){
Comparison_result compx = compare_x(r1, r2);
if(compx != 0)
return compx;
return compare_y(r1, r2);
}
template <typename RT>
Comparison_result
compare_xyz(const CGAL::Root_for_spheres_2_3<RT>& r1, const CGAL::Root_for_spheres_2_3<RT>& r2){
Comparison_result compxy = compare_xy(r1, r2);
if(compxy != 0)
return compxy;
return compare_z(r1, r2);
}
} // namespace AlgebraicSphereFunctors
} // namespace CGAL
#endif // CGAL_ALGEBRAIC_KERNEL_COMPARISON_ROOT_FOR_SPHERES_2_3_H
| [
"Etienne.Houze@polytechnique.edu"
] | Etienne.Houze@polytechnique.edu |
6c78211f91852c83fad0f2186c5bc1d84196789f | b07ce3cc46e1a2a638d867a602bc37e15e3f786d | /src/UpCloud-Service-NodeServer/BusinessIClient/StructIClient/bean/nsrssendfiles.cpp | 7ea90c39b084a954186dbca995cd65cec2881109 | [] | no_license | Lynzabo/UpCloudEcosphere | 9c4b12585aedffdf9f9b982f5345357efd406b12 | c7ce266f627dd6570e6b9d7606cd7e2b90bf8f9a | refs/heads/master | 2021-01-06T20:39:02.722381 | 2017-08-07T04:07:46 | 2017-08-07T04:08:01 | 99,533,490 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,153 | cpp | #include "nsrssendfiles.h"
QString NsRStructSendFiles::getUuid() const
{
return uuid;
}
void NsRStructSendFiles::setUuid(const QString &value)
{
uuid = value;
}
QString NsRStructSendFiles::getFileUrl() const
{
return fileUrl;
}
void NsRStructSendFiles::setFileUrl(const QString &value)
{
fileUrl = value;
}
QString NsRStructSendFiles::getFileAbst() const
{
return fileAbst;
}
void NsRStructSendFiles::setFileAbst(const QString &value)
{
fileAbst = value;
}
quint32 NsRStructSendFiles::getSequence() const
{
return sequence;
}
void NsRStructSendFiles::setSequence(const quint32 &value)
{
sequence = value;
}
QString NsRStructSendFiles::getTaskUuid() const
{
return taskUuid;
}
void NsRStructSendFiles::setTaskUuid(const QString &value)
{
taskUuid = value;
}
quint8 NsRStructSendFiles::getState() const
{
return state;
}
void NsRStructSendFiles::setState(const quint8 &value)
{
state = value;
}
QString NsRStructSendFiles::getError() const
{
return error;
}
void NsRStructSendFiles::setError(const QString &value)
{
error = value;
}
NsRStructSendFiles::NsRStructSendFiles()
{
}
| [
"linzhanbo@le.com"
] | linzhanbo@le.com |
9099103a8a3949a4990363d4d58357457931835b | e8f43b5cbecf3e49caa89d163d506e8483f40c9d | /MFC_销售管理系统/MFC_销售管理系统.h | 63621fafa608da91e993c858b54b53124878460c | [] | no_license | gugeaini/tiantian | 5ef843b2ad2073e1f21cd2b09d73b313bdaf292e | 08beb764a1b4caca89d8d7b1948dc15869b10ee2 | refs/heads/master | 2021-01-05T16:34:52.062516 | 2020-02-17T10:40:53 | 2020-02-17T10:40:53 | 241,076,667 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 618 | h |
// MFC_销售管理系统.h: MFC_销售管理系统 应用程序的主头文件
//
#pragma once
#ifndef __AFXWIN_H__
#error "在包含此文件之前包含 'pch.h' 以生成 PCH"
#endif
#include "resource.h" // 主符号
// CMFC销售管理系统App:
// 有关此类的实现,请参阅 MFC_销售管理系统.cpp
//
class CMFC销售管理系统App : public CWinApp
{
public:
CMFC销售管理系统App() noexcept;
// 重写
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// 实现
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
};
extern CMFC销售管理系统App theApp;
| [
"1010633391@qq.com"
] | 1010633391@qq.com |
97feaa6e390072675bfa05709a1377d9b8d7ffa3 | e4ba9232b67b3c23a33be1173ce05ae8a47ee1fe | /Project 4/part2/dfs-client-p2.cpp | 9709776ee7fc07d44f41d9d9217c1b6eabfb81bd | [] | no_license | ericyang97/GIOS | 511a88d19c39b3bfac38c7b31fcadf2fa1fa77e6 | 2734f8a6a8d5d1a30ad7518ea7175e5266c51945 | refs/heads/main | 2023-06-11T08:07:12.964814 | 2021-07-03T23:54:51 | 2021-07-03T23:54:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,006 | cpp | #include <map>
#include <regex>
#include <vector>
#include <string>
#include <thread>
#include <fstream>
#include <errno.h>
#include <csignal>
#include <iostream>
#include <iomanip>
#include <getopt.h>
#include <unistd.h>
#include <algorithm>
#include <sys/inotify.h>
#include <grpcpp/grpcpp.h>
#include "dfs-utils.h"
#include "dfs-client-p2.h"
#include "dfslibx-clientnode-p2.h"
#include "../dfslib-shared-p2.h"
#include "../dfslib-clientnode-p2.h"
DFSClient::DFSClient() {}
DFSClient::~DFSClient() noexcept { this->Unmount(); }
void DFSClient::ProcessCommand(const std::string &command, const std::string &filename) {
if (command == "mount") {
Mount(this->mount_path);
}
if (command == "fetch") {
client_node.Fetch(filename);
} else if (command == "store") {
client_node.Store(filename);
} else if (command == "delete") {
client_node.Delete(filename);
} else if (command == "list") {
std::map<std::string,int> file_map;
client_node.List(&file_map, true);
} else if (command == "stat") {
client_node.Stat(filename);
} else {
dfs_log(LL_ERROR) << "Unknown command";
}
}
void DFSClient::InitializeClientNode(const std::string &server_address) {
this->client_node.CreateStub(grpc::CreateChannel(server_address, grpc::InsecureChannelCredentials()));
}
void DFSClient::SetMountPath(const std::string &path) {
this->mount_path = dfs_clean_path(path);
this->client_node.SetMountPath(this->mount_path);
}
void DFSClient::SetDeadlineTimeout(int deadline) {
this->deadline_timeout = deadline;
this->client_node.SetDeadlineTimeout(deadline);
}
void DFSClient::Mount(const std::string &filepath) {
this->mount_path = filepath;
if (this->mount_path.back() != '/') {
this->mount_path.append("/");
}
dfs_log(LL_SYSINFO) << "Mounting on " << this->mount_path;
std::vector <std::thread> threads;
// uint event_flags = IN_CLOSE_WRITE | IN_OPEN;
uint event_flags = IN_CREATE | IN_MODIFY | IN_DELETE;
const FileDescriptor fd = inotify_init();
if (fd < 0) {
std::cerr << "Error during inotify_init: " << strerror(errno) << std::endl;
exit(-1);
}
const WatchDescriptor wd = inotify_add_watch(fd, filepath.c_str(), event_flags | IN_ONLYDIR);
std::thread thread_watcher(DFSClient::InotifyWatcher, DFSClient::InotifyEventCallback, event_flags, fd, &this->client_node);
NotifyStruct n_event = {fd, wd, event_flags, &thread_watcher, DFSClient::InotifyEventCallback};
events.emplace_back(n_event);
threads.push_back(std::move(thread_watcher));
thread_async = std::thread(&DFSClientNodeP2::HandleCallbackList, &this->client_node);
threads.push_back(std::move(thread_async));
// Initialize the callback list
this->client_node.InitCallbackList();
for (std::thread &t : threads) {
if (t.joinable()) { t.join(); }
}
}
void DFSClient::Unmount() {
std::vector <FileDescriptor> descriptors;
this->client_node.Unmount();
for (NotifyStruct &e: events) {
if (e.thread->joinable()) { e.thread->detach(); }
e.thread->~thread();
inotify_rm_watch(e.wd, e.fd);
descriptors.push_back(e.fd);
}
std::unique(descriptors.begin(), descriptors.end());
for (FileDescriptor fd: descriptors) {
if (close(fd) != 0) {
std::cerr << "Unable to close file descriptor" << std::endl;
}
}
events.clear();
if (thread_async.joinable()) {
thread_async.detach();
thread_async.~thread();
}
}
void DFSClient::InotifyWatcher(InotifyCallback callback,
uint event_type,
FileDescriptor fd,
DFSClientNode *node) {
int len;
std::allocator<char> allocator;
std::unique_ptr<char> handle(allocator.allocate(DFS_I_BUFFER_SIZE));
char *events_buffer = handle.get();
while (true) {
// Read the next inotify event as it becomes available
len = read(fd, events_buffer, DFS_I_BUFFER_SIZE);
int index = 0;
node->InotifyWatcherCallback([&]{
// This loop handles each of the inotify events as they come through
while (index < len) {
inotify_event *event = reinterpret_cast<inotify_event *>(&(events_buffer[index]));
EventStruct event_data;
event_data.event = event;
event_data.instance = node;
if ((event_type & event->mask) && event->name[0] != '.') {
callback(event_type, std::string{node->MountPath() + event->name}, &event_data);
}
size_t used = DFS_I_EVENT_SIZE + event->len;
index += (used / sizeof(char));
}
if (errno == EINTR) {
dfs_log(LL_ERROR) << "inotify system call invalid";
}
});
}
}
void DFSClient::InotifyEventCallback(uint event_type, const std::string &filename, void *data) {
// For the purposes of this assignment we will ignore files that do not
// match the following set of extensions (e.g. temporary files)
try {
if (!std::regex_match(filename, std::regex(".*\\.(jpg|png|gif|txt|xlsx|docx|md|psd)$"))) {
dfs_log(LL_ERROR) << "Ignored file type used for " << filename;
return;
}
}
catch (std::regex_error& ex) {
dfs_log(LL_ERROR) << ex.what();
return;
}
// Get the basename for the file
std::string basename = filename.substr(filename.find_last_of("/") + 1);
auto event_data = reinterpret_cast<EventStruct *>(data);
inotify_event *event = reinterpret_cast<inotify_event *>(event_data->event);
DFSClientNode *node = reinterpret_cast<DFSClientNode *>(event_data->instance);
// Handle a new file that was created by storing
// this file on the server
if (event->mask & IN_CREATE) {
dfs_log(LL_SYSINFO) << "Inotify create triggered-->\n ";
dfs_log(LL_DEBUG2) << "inotify IN_CREATE event occurred";
node->Store(basename);
}
// Handle a new file that was modified by storing
// this file on the server
if (event->mask & IN_MODIFY) {
dfs_log(LL_DEBUG2) << "inotify IN_MODIFY event occurred";
dfs_log(LL_SYSINFO) << "Inotify modify triggered -->\n ";
node->Store(basename);
}
// Handle a deleted file
if (event->mask & IN_DELETE) {
dfs_log(LL_SYSINFO) << "Inotify delete triggered-->\n ";
dfs_log(LL_DEBUG2) << "inotify IN_DELETE event occurred";
node->Delete(basename);
}
}
#ifdef DFS_MAIN
DFSClient client;
void HandleSignal(int signum) {
client.Unmount();
exit(0);
}
void Usage() {
std::cout <<
"\nUSAGE: dfs-client [OPTIONS] COMMAND [FILENAME]\n"
"-a, --address <address>: The server address to connect to (default: 0.0.0.0:42001)\n"
"-d, --debug_level <level>: The debug level to use: 0, 1, 2, 3 (default: 0 = no debug, higher numbers increase verbosity)\n"
"-m, --mount_path <path>: The mount path this client attaches to\n"
"-t, --deadline_timeout <int>: The deadline timeout in milliseconds (default: 10000)\n"
"-h, --help: Show help\n"
"\n"
"COMMAND is one of mount|fetch|store|delete|list|stat.\n"
"FILENAME is the filename to fetch, store, delete, or stat. The mount and list commands do not require a filename.\n\n";
exit(1);
}
int main(int argc, char** argv) {
const char* const short_opts = "a:d:m:r:t:h";
const option long_opts[] = {
{"address", optional_argument, nullptr, 'a'},
{"debug_level", optional_argument, nullptr, 'd'},
{"mount_path", optional_argument, nullptr, 'm'},
{"deadline_timeout", optional_argument, nullptr, 't'},
{"help", no_argument, nullptr, 'h'},
{nullptr, no_argument, nullptr, 0}
};
char option_char;
int deadline_timeout = 10000;
int debug_level = static_cast<int>(LL_ERROR);
std::string command = "";
std::string filename = "";
std::string mount_path = "";
std::string server_address = "0.0.0.0:42001";
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == NULL) {
perror("getcwd error:");
return 1;
}
std::string working_directory(cwd);
while((option_char = getopt_long(argc, argv, short_opts, long_opts, nullptr)) != -1) {
switch(option_char) {
case 'a':
server_address = std::string(optarg);
break;
case 'd':
debug_level = std::stoi(optarg);
break;
case 'm':
mount_path = std::string(optarg);
break;
case 't':
deadline_timeout = std::stoi(optarg);
break;
case 'h':
Usage();
break;
case '?':
if (optopt == 'n' || optopt == 'a') {
std::cerr << "Option '" << optopt << "' requires an argument." << std::endl;
}
else if (isprint(optopt)) {
std::cerr << "Unknown option:" << optopt << std::endl;
}
else {
std::cerr << "Unknown option characteri:" << optopt << std::endl;
}
return 1;
default:
abort();
}
}
if (debug_level > 0 && debug_level <= 3) {
DFS_LOG_LEVEL = static_cast<dfs_log_level_e>(debug_level + 1);
}
if (mount_path.empty()) {
mount_path = working_directory + "/mnt/client";
}
struct stat st;
// check for directory existence
if (!(stat(mount_path.c_str(), &st) == 0)) {
std::cerr << "Mount path not found at: " << mount_path << std::endl;
return 1;
}
for(int i = optind; i < argc; i++) {
if (command.empty()) { command = argv[i]; }
else if (filename.empty()) { filename = argv[i]; }
}
if (command.empty()) {
std::cerr << "\nMissing command!\n";
Usage();
return -1;
}
std::string commands("fetch store delete list stat mount sync");
if (commands.find(command) == std::string::npos ) {
std::cerr << "\nUnknown command!\n";
Usage();
return -1;
}
std::string nonpath_commands("list mount sync");
if (filename.empty() && nonpath_commands.find(command) == std::string::npos ) {
std::cerr << "\nMissing filename!\n";
Usage();
return -1;
}
signal(SIGINT, HandleSignal);
signal(SIGTERM, HandleSignal);
client.SetMountPath(mount_path);
client.SetDeadlineTimeout(deadline_timeout);
client.InitializeClientNode(server_address);
client.ProcessCommand(command, filename);
return 0;
}
#endif
| [
"noreply@github.com"
] | noreply@github.com |
605b7060a1d1676b5aa74de97cbb75f11ee5bead | f618e4474fa3784ef2e74958681969edf6125b11 | /src/parser.cpp | 6bcf82aba489d7e4c8906019f480891db04075e6 | [] | no_license | patrykchodur/agh_advancedcpp | 186827106b125069eba2ae1672dacd963d384a0c | 7c46afb5d77d178246364d905c2a7d7451b3583e | refs/heads/master | 2022-11-08T22:48:58.929404 | 2020-06-20T16:24:45 | 2020-06-20T16:24:45 | 261,297,258 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,564 | cpp |
enum Symbol : int {
node_description = _TOKEN_LAST + 1,
nodes_description,
list_of_node_descriptions,
line_description,
list_of_line_descriptions,
lines_section,
property,
rules_entity,
rules_scheme,
format_value,
format_entry,
list_of_format_entries,
format_section,
rtl_section,
list_of_rtl_sections,
rtl_file,
};
/* *************************************
* * *
* * PARSER GRAMMAR *
* * *
* *************************************
*
*
* node_description : _B
* | _O
*
*
* nodes_description : node_description
* | _NUMBER node_description
*
*
* list_of_node_descriptions : nodes_description
* | nodes_description list_of_node_descriptions
*
*
* line_description : list_of_nodes_descriptions
*
*
*
* list_of_line_descriptions : line_description
* | line_description _DOLAR list_of_node_descriptions
*
*
* lines_section : list_of_line_descriptions _EXCLAMATION_MARK
*
*
*
* property : _X
* | _Y
* | _RULE
*
* rules_entity : _B _NUMBER
* | _S _NUMBER
*
*
* rules_scheme : rules_entity _SLASH rules_entity
*
*
*
* format_value : _NUMBER
* | rules_scheme
*
*
* format_entry : property _EQUALS format_value
*
*
*
* list_of_format_entries : format_entry
* | format_entry _COMMA list_of_format_entries
*
*
* format_section : list_of_format_entries
*
*
*
* rtl_section : _COMMENT
* | format_section
* | lines_section
*
* list_of_rtl_sections : rtl_section
* | rtl_section list_of_rtl_sections
*
*
* rtl_file : list_of_rtl_sections
*
*
*
*/
class Parser {
public:
Parser();
Board parse_stream(std::istream& stream);
using token_ptr = std::shared_ptr<std::pair<int, std::any>>;
private:
std::optional<Lexer> m_lex;
std::optional<Board> m_board;
int m_x;
int m_y;
std::set<int> m_survives;
std::set<int> m_born;
int single_parse();
int reduce(const std::vector<int>& token_stack);
token_ptr lex();
token_ptr next();
void unget(token_ptr token);
std::stack<token_ptr> m_aquired_tokens;
std::vector<token_ptr> m_token_stack;
}
token_ptr Parser::lex() {
if (m_aquired_tokens.empty())
return { m_lex->lex() };
auto result = m_aquired_tokens.top();
m_aquired_tokens.pop();
return result;
}
void Parser::unget(token_ptr token) {
m_aquired_tokens.push(token);
}
Parser::Parser() {
m_x = 10;
m_y = 10;
m_survives.insert(3);
m_born.insert({2, 3});
}
Parser::reduce(std::vector<token_ptr>::iterator start) {
auto token = (*start)->first;
switch (token) {
case _B:
{
auto next_token = lex();
if (next_token->
int Parser::parse(const std::vector<int>& token_stack) {
if (token_stack.empty())
return _ERROR;
switch (*stack_position) {
case _B:
{
auto save_position = stack_position;
if (reduce_next() == _NUMBER &&
reduce_next() == _SLASH &&
reduce_next() == _S &&
reduce_next() == _NUMBER)
return rules_scheme;
else {
stack_position = save_position;
return node_description;
}
case _O:
}
int Parser::single_parse(int token) {
switch (token) {
}
}
#define UNEXPECTED_TOKEN(lexer, token) do { \
std::cerr << "Error: unexpected token " << #token << '\n' << \
"Position: line = " << (lexer).get_line_number() << \
", column = " << (lexer).get_col_number() << '\n'; \
} while (0)
Board parse_from_istream(std::istream& stream) {
Lexer lexer(stream);
auto assert_token = [&](token actual_token, token expected_token) {
if (actual_token != expected_token) {
UNEXPECTED_TOKEN(lexer, actual_token);
return false;
}
return true;
};
auto lexer_pair = lexer.lex();
auto& current_token = lexer_pair.first;
auto& text = lexer_pair.second;
auto next = [&]() {
lexer_pair = lexer.lex();
};
// skip comments
while (current_token == _COMMENT)
lexer_pair = lexer.lex();
// description of format
assert_token(current_token, _X);
assert_token(current_token, _EQUALS);
assert_token(current_token, );
}
Board parse_from_istream1(std::istream& stream) {
constexpr auto max = std::numeric_limits<std::streamsize>::max();
int line_nr = 0;
int x = -1;
int y = -1;
std::optional<Board> board;
std::optional<Board::Position> position;
int error = 0;
int repeat = -1;
std::set<int> survives;
std::set<int> born;
while (!stream.eof()) {
if (error)
break;
++line_nr;
auto c = stream.get();
switch (c) {
case '#':
stream.ignore(max, '\n');
continue;
case '\n':
continue;
case 'y':
if (y != -1 || board)
error = 1;
else {
char test;
stream >> test;
if (test != '=')
error = 1;
stream >> y;
if (x != -1) {
board = Board(y, x);
position = board->begin();
}
}
continue;
case 'x':
if (x != -1 || board)
error = 1;
else {
char test;
stream >> test;
if (test != '=')
error = 1;
stream >> x;
if (y != -1) {
board = Board(y, x);
position = board->begin();
}
}
continue;
case 'r': {
std::string test;
stream >> test;
if (test != "ule") {
error = 1;
break;
}
stream >> test;
if (test != "=") {
error = 1;
break;
}
char c2;
stream >> c2;
if (c2 != 'B') {
error = 1;
break;
}
while ((c2 = stream.get()) != '/')
born.emplace(c2 - '0');
if ((c2 = stream.get()) != 'S') {
error = 1;
break;
}
while (std::isdigit(c2 = stream.get())) {
survives.emplace(c2 - '0');
}
continue;
}
default:
break;
}
switch (c) {
case 'b':
if (repeat == -1)
board->kill_at((*position)++);
else while(repeat--)
board->kill_at((*position)++);
repeat = -1;
break;
case 'o':
if (repeat == -1)
board->add_at((*position)++);
else while (repeat--)
board->add_at((*position)++);
repeat = -1;
break;
case '$': {
auto col = position->col;
while (col == position->col)
board->kill_at((*position)++);
break;
}
case '!': {
board->set_rules(survives, born);
return *board;
}
if (std::isdigit(c)) {
if (repeat != -1)
repeat *= 10;
else
repeat = 0;
repeat += c - '0';
}
}
}
if (!survives.empty() && !born.empty())
board->set_rules(survives, born);
return *board;
}
| [
"patrykchodur@icloud.com"
] | patrykchodur@icloud.com |
4ebd3ca0b67c4f85a2966780ee1a11efd8089287 | 07e6fc323f657d1fbfc24f861a278ab57338b80a | /cpp/common/dataStructures/CommandParser.h | d4660330b941543229c9466487611c4d035dbe62 | [
"MIT"
] | permissive | ProkopHapala/SimpleSimulationEngine | 99cf2532501698ee8a03b2e40d1e4bedd9a12609 | 47543f24f106419697e82771289172d7773c7810 | refs/heads/master | 2022-09-05T01:02:42.820199 | 2022-08-28T10:22:41 | 2022-08-28T10:22:41 | 40,007,027 | 35 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 4,113 | h |
#ifndef CommandParser_h
#define CommandParser_h
#include <stdlib.h>
// simple command parser
// # comment
// commands are separated by some separator (;, \t )
// first world is name of command
// each application overloads its own CallTable function
//#include <vector>
#include <unordered_map>
#include <cstdio>
#include <cstring>
// TODO : dynamic construction of variables is quite complicated, for now we don't do it
// this means that commands can have just constant arguments of primitive type
class VarObj{
char type;
void * prt = NULL;
};
class FunctionObj{
//char name []
char argTypes[16];
//void exec( char* line, int nToks, int * tokIs, unordered_map<string,VarObj> varDict ){
void exec( char* line, int nToks, int * tokIs ){
for( int i=0; i<(nToks-1); i++ ){
char type = argTypes[i];
char * tok = line + tokIs[i+1];
switch(type){
case 'f': break; // float
case 'i': break; // int
case 's': break; // string
}
}
}
};
//================== test commands
void command1( int a, float b ){ printf(" command1 ( %i, %f ) \n", a, b ); }
void command2( float a, float b, int c ){ printf(" command2 ( %f, %f, %i ) \n", a, b, c ); }
void command3( float a, char* s, int c ){ printf(" command3 ( %f, %s, %i ) \n", a, s, c ); }
//==================
class CommandParser{ public:
static const int maxLineLen = 2048;
static const int maxTok = 128;
int maxLines = 10000;
char comentChar='#';
char varChar ='$';
//vector<int> tokIs;
int nToks = 0;
//int tokIs[maxTok];
char* toks[maxTok];
char line[maxLineLen];
int iline,iarg;
void line2toks( char* line ){
//tokIs.clear();
for(int i=0; i<nToks; i++) toks[i]=NULL; // clean previous tokens
nToks=0;
bool inString = false;
bool inTok = false;
for(int i=0; i<maxLineLen; i++ ){
if ( (!inString) && ((line[i]==' ' )||(line[i]=='\t'))){
line[i]='\0';
inTok=false;
}else if ( (line[i]=='\0')||(line[i]==comentChar)){
break;
}else if (!inTok){
if (line[i]=='"'){ inString = true; i++; }
//tokIs.pushBack(i);
inTok=true;
//tokIs[nToks]=i;
toks[nToks]=line+i;
nToks++;
}else{
if (line[i]=='"'){ inString = false; line[i]='\0'; }
};
}
}
int execFile( char * fname ){
FILE *pFile=fopen( fname,"r");
if(pFile==NULL){
printf("Failed to load %s \n", fname );
return -1;
}
for(iline=0; iline<maxLines; iline++){
char *str = fgets( line, maxLineLen, pFile );
if( str==NULL ) break;
if( str[0]==comentChar ) continue;
//printf( "%i : %s", iline, str );
//exit(0);
line2toks( str );
iarg = 0;
callTable( toks[0] );
};
return 0;
}
void argError(){ printf( "ERROR line %i arg %i", iline+1, iarg ); exit(0); };
int _int (char* s){ int i; iarg++; if(1!=sscanf( s, "%i", &i )) argError(); return i; };
float _float(char* s){ float f; iarg++; if(1!=sscanf( s, "%f", &f )) argError(); return f; };
void callTable_default( char * funcName ){
//char * funcName = line + tokIs[0];
//printf( "funcName : %s \n", funcName );
// TODO: strcmp should be replaced by hashtable
if ( 0==strcmp(funcName, "command1" ) ){ command1( _int (toks[1]), _float(toks[2]) ); }
else if ( 0==strcmp(funcName, "command2" ) ){ command2( _float(toks[1]), _float(toks[2]), _int(toks[3]) ); }
else if ( 0==strcmp(funcName, "command3" ) ){ command3( _float(toks[1]), toks[2] , _int(toks[3]) ); };
}
virtual void callTable( char * funcName ){
callTable_default( funcName );
}
};
#endif
| [
"ProkopHapala@gmail.com"
] | ProkopHapala@gmail.com |
30636da3a7f1c2fedac2671b4d3fafe7d1fcbc87 | c776476e9d06b3779d744641e758ac3a2c15cddc | /examples/litmus/c/run-scripts/tmp_5/ISA2+dmb.sylp+poal+poaa.c.cbmc_out.cpp | 9adb3c115352a437e2726ff642aceb9e2cb75b55 | [] | no_license | ashutosh0gupta/llvm_bmc | aaac7961c723ba6f7ffd77a39559e0e52432eade | 0287c4fb180244e6b3c599a9902507f05c8a7234 | refs/heads/master | 2023-08-02T17:14:06.178723 | 2023-07-31T10:46:53 | 2023-07-31T10:46:53 | 143,100,825 | 3 | 4 | null | 2023-05-25T05:50:55 | 2018-08-01T03:47:00 | C++ | UTF-8 | C++ | false | false | 45,039 | cpp | // Global variabls:
// 0:vars:3
// 3:atom_1_X0_1:1
// 4:atom_2_X0_1:1
// 5:atom_2_X2_0:1
// Local global variabls:
// 0:thr0:1
// 1:thr1:1
// 2:thr2:1
#define ADDRSIZE 6
#define LOCALADDRSIZE 3
#define NTHREAD 4
#define NCONTEXT 5
#define ASSUME(stmt) __CPROVER_assume(stmt)
#define ASSERT(stmt) __CPROVER_assert(stmt, "error")
#define max(a,b) (a>b?a:b)
char __get_rng();
char get_rng( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
char get_rng_th( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
int main(int argc, char **argv) {
// Declare arrays for intial value version in contexts
int local_mem[LOCALADDRSIZE];
// Dumping initializations
local_mem[0+0] = 0;
local_mem[1+0] = 0;
local_mem[2+0] = 0;
int cstart[NTHREAD];
int creturn[NTHREAD];
// declare arrays for contexts activity
int active[NCONTEXT];
int ctx_used[NCONTEXT];
// declare arrays for intial value version in contexts
int meminit_[ADDRSIZE*NCONTEXT];
#define meminit(x,k) meminit_[(x)*NCONTEXT+k]
int coinit_[ADDRSIZE*NCONTEXT];
#define coinit(x,k) coinit_[(x)*NCONTEXT+k]
int deltainit_[ADDRSIZE*NCONTEXT];
#define deltainit(x,k) deltainit_[(x)*NCONTEXT+k]
// declare arrays for running value version in contexts
int mem_[ADDRSIZE*NCONTEXT];
#define mem(x,k) mem_[(x)*NCONTEXT+k]
int co_[ADDRSIZE*NCONTEXT];
#define co(x,k) co_[(x)*NCONTEXT+k]
int delta_[ADDRSIZE*NCONTEXT];
#define delta(x,k) delta_[(x)*NCONTEXT+k]
// declare arrays for local buffer and observed writes
int buff_[NTHREAD*ADDRSIZE];
#define buff(x,k) buff_[(x)*ADDRSIZE+k]
int pw_[NTHREAD*ADDRSIZE];
#define pw(x,k) pw_[(x)*ADDRSIZE+k]
// declare arrays for context stamps
char cr_[NTHREAD*ADDRSIZE];
#define cr(x,k) cr_[(x)*ADDRSIZE+k]
char iw_[NTHREAD*ADDRSIZE];
#define iw(x,k) iw_[(x)*ADDRSIZE+k]
char cw_[NTHREAD*ADDRSIZE];
#define cw(x,k) cw_[(x)*ADDRSIZE+k]
char cx_[NTHREAD*ADDRSIZE];
#define cx(x,k) cx_[(x)*ADDRSIZE+k]
char is_[NTHREAD*ADDRSIZE];
#define is(x,k) is_[(x)*ADDRSIZE+k]
char cs_[NTHREAD*ADDRSIZE];
#define cs(x,k) cs_[(x)*ADDRSIZE+k]
char crmax_[NTHREAD*ADDRSIZE];
#define crmax(x,k) crmax_[(x)*ADDRSIZE+k]
char sforbid_[ADDRSIZE*NCONTEXT];
#define sforbid(x,k) sforbid_[(x)*NCONTEXT+k]
// declare arrays for synchronizations
int cl[NTHREAD];
int cdy[NTHREAD];
int cds[NTHREAD];
int cdl[NTHREAD];
int cisb[NTHREAD];
int caddr[NTHREAD];
int cctrl[NTHREAD];
int r0= 0;
char creg_r0;
char creg__r0__1_;
int r1= 0;
char creg_r1;
int r2= 0;
char creg_r2;
char creg__r1__1_;
char creg__r2__0_;
int r3= 0;
char creg_r3;
int r4= 0;
char creg_r4;
int r5= 0;
char creg_r5;
int r6= 0;
char creg_r6;
int r7= 0;
char creg_r7;
int r8= 0;
char creg_r8;
int r9= 0;
char creg_r9;
int r10= 0;
char creg_r10;
int r11= 0;
char creg_r11;
char creg__r11__1_;
int r12= 0;
char creg_r12;
char old_cctrl= 0;
char old_cr= 0;
char old_cdy= 0;
char old_cw= 0;
char new_creg= 0;
buff(0,0) = 0;
pw(0,0) = 0;
cr(0,0) = 0;
iw(0,0) = 0;
cw(0,0) = 0;
cx(0,0) = 0;
is(0,0) = 0;
cs(0,0) = 0;
crmax(0,0) = 0;
buff(0,1) = 0;
pw(0,1) = 0;
cr(0,1) = 0;
iw(0,1) = 0;
cw(0,1) = 0;
cx(0,1) = 0;
is(0,1) = 0;
cs(0,1) = 0;
crmax(0,1) = 0;
buff(0,2) = 0;
pw(0,2) = 0;
cr(0,2) = 0;
iw(0,2) = 0;
cw(0,2) = 0;
cx(0,2) = 0;
is(0,2) = 0;
cs(0,2) = 0;
crmax(0,2) = 0;
buff(0,3) = 0;
pw(0,3) = 0;
cr(0,3) = 0;
iw(0,3) = 0;
cw(0,3) = 0;
cx(0,3) = 0;
is(0,3) = 0;
cs(0,3) = 0;
crmax(0,3) = 0;
buff(0,4) = 0;
pw(0,4) = 0;
cr(0,4) = 0;
iw(0,4) = 0;
cw(0,4) = 0;
cx(0,4) = 0;
is(0,4) = 0;
cs(0,4) = 0;
crmax(0,4) = 0;
buff(0,5) = 0;
pw(0,5) = 0;
cr(0,5) = 0;
iw(0,5) = 0;
cw(0,5) = 0;
cx(0,5) = 0;
is(0,5) = 0;
cs(0,5) = 0;
crmax(0,5) = 0;
cl[0] = 0;
cdy[0] = 0;
cds[0] = 0;
cdl[0] = 0;
cisb[0] = 0;
caddr[0] = 0;
cctrl[0] = 0;
cstart[0] = get_rng(0,NCONTEXT-1);
creturn[0] = get_rng(0,NCONTEXT-1);
buff(1,0) = 0;
pw(1,0) = 0;
cr(1,0) = 0;
iw(1,0) = 0;
cw(1,0) = 0;
cx(1,0) = 0;
is(1,0) = 0;
cs(1,0) = 0;
crmax(1,0) = 0;
buff(1,1) = 0;
pw(1,1) = 0;
cr(1,1) = 0;
iw(1,1) = 0;
cw(1,1) = 0;
cx(1,1) = 0;
is(1,1) = 0;
cs(1,1) = 0;
crmax(1,1) = 0;
buff(1,2) = 0;
pw(1,2) = 0;
cr(1,2) = 0;
iw(1,2) = 0;
cw(1,2) = 0;
cx(1,2) = 0;
is(1,2) = 0;
cs(1,2) = 0;
crmax(1,2) = 0;
buff(1,3) = 0;
pw(1,3) = 0;
cr(1,3) = 0;
iw(1,3) = 0;
cw(1,3) = 0;
cx(1,3) = 0;
is(1,3) = 0;
cs(1,3) = 0;
crmax(1,3) = 0;
buff(1,4) = 0;
pw(1,4) = 0;
cr(1,4) = 0;
iw(1,4) = 0;
cw(1,4) = 0;
cx(1,4) = 0;
is(1,4) = 0;
cs(1,4) = 0;
crmax(1,4) = 0;
buff(1,5) = 0;
pw(1,5) = 0;
cr(1,5) = 0;
iw(1,5) = 0;
cw(1,5) = 0;
cx(1,5) = 0;
is(1,5) = 0;
cs(1,5) = 0;
crmax(1,5) = 0;
cl[1] = 0;
cdy[1] = 0;
cds[1] = 0;
cdl[1] = 0;
cisb[1] = 0;
caddr[1] = 0;
cctrl[1] = 0;
cstart[1] = get_rng(0,NCONTEXT-1);
creturn[1] = get_rng(0,NCONTEXT-1);
buff(2,0) = 0;
pw(2,0) = 0;
cr(2,0) = 0;
iw(2,0) = 0;
cw(2,0) = 0;
cx(2,0) = 0;
is(2,0) = 0;
cs(2,0) = 0;
crmax(2,0) = 0;
buff(2,1) = 0;
pw(2,1) = 0;
cr(2,1) = 0;
iw(2,1) = 0;
cw(2,1) = 0;
cx(2,1) = 0;
is(2,1) = 0;
cs(2,1) = 0;
crmax(2,1) = 0;
buff(2,2) = 0;
pw(2,2) = 0;
cr(2,2) = 0;
iw(2,2) = 0;
cw(2,2) = 0;
cx(2,2) = 0;
is(2,2) = 0;
cs(2,2) = 0;
crmax(2,2) = 0;
buff(2,3) = 0;
pw(2,3) = 0;
cr(2,3) = 0;
iw(2,3) = 0;
cw(2,3) = 0;
cx(2,3) = 0;
is(2,3) = 0;
cs(2,3) = 0;
crmax(2,3) = 0;
buff(2,4) = 0;
pw(2,4) = 0;
cr(2,4) = 0;
iw(2,4) = 0;
cw(2,4) = 0;
cx(2,4) = 0;
is(2,4) = 0;
cs(2,4) = 0;
crmax(2,4) = 0;
buff(2,5) = 0;
pw(2,5) = 0;
cr(2,5) = 0;
iw(2,5) = 0;
cw(2,5) = 0;
cx(2,5) = 0;
is(2,5) = 0;
cs(2,5) = 0;
crmax(2,5) = 0;
cl[2] = 0;
cdy[2] = 0;
cds[2] = 0;
cdl[2] = 0;
cisb[2] = 0;
caddr[2] = 0;
cctrl[2] = 0;
cstart[2] = get_rng(0,NCONTEXT-1);
creturn[2] = get_rng(0,NCONTEXT-1);
buff(3,0) = 0;
pw(3,0) = 0;
cr(3,0) = 0;
iw(3,0) = 0;
cw(3,0) = 0;
cx(3,0) = 0;
is(3,0) = 0;
cs(3,0) = 0;
crmax(3,0) = 0;
buff(3,1) = 0;
pw(3,1) = 0;
cr(3,1) = 0;
iw(3,1) = 0;
cw(3,1) = 0;
cx(3,1) = 0;
is(3,1) = 0;
cs(3,1) = 0;
crmax(3,1) = 0;
buff(3,2) = 0;
pw(3,2) = 0;
cr(3,2) = 0;
iw(3,2) = 0;
cw(3,2) = 0;
cx(3,2) = 0;
is(3,2) = 0;
cs(3,2) = 0;
crmax(3,2) = 0;
buff(3,3) = 0;
pw(3,3) = 0;
cr(3,3) = 0;
iw(3,3) = 0;
cw(3,3) = 0;
cx(3,3) = 0;
is(3,3) = 0;
cs(3,3) = 0;
crmax(3,3) = 0;
buff(3,4) = 0;
pw(3,4) = 0;
cr(3,4) = 0;
iw(3,4) = 0;
cw(3,4) = 0;
cx(3,4) = 0;
is(3,4) = 0;
cs(3,4) = 0;
crmax(3,4) = 0;
buff(3,5) = 0;
pw(3,5) = 0;
cr(3,5) = 0;
iw(3,5) = 0;
cw(3,5) = 0;
cx(3,5) = 0;
is(3,5) = 0;
cs(3,5) = 0;
crmax(3,5) = 0;
cl[3] = 0;
cdy[3] = 0;
cds[3] = 0;
cdl[3] = 0;
cisb[3] = 0;
caddr[3] = 0;
cctrl[3] = 0;
cstart[3] = get_rng(0,NCONTEXT-1);
creturn[3] = get_rng(0,NCONTEXT-1);
// Dumping initializations
mem(0+0,0) = 0;
mem(0+1,0) = 0;
mem(0+2,0) = 0;
mem(3+0,0) = 0;
mem(4+0,0) = 0;
mem(5+0,0) = 0;
// Dumping context matching equalities
co(0,0) = 0;
delta(0,0) = -1;
mem(0,1) = meminit(0,1);
co(0,1) = coinit(0,1);
delta(0,1) = deltainit(0,1);
mem(0,2) = meminit(0,2);
co(0,2) = coinit(0,2);
delta(0,2) = deltainit(0,2);
mem(0,3) = meminit(0,3);
co(0,3) = coinit(0,3);
delta(0,3) = deltainit(0,3);
mem(0,4) = meminit(0,4);
co(0,4) = coinit(0,4);
delta(0,4) = deltainit(0,4);
co(1,0) = 0;
delta(1,0) = -1;
mem(1,1) = meminit(1,1);
co(1,1) = coinit(1,1);
delta(1,1) = deltainit(1,1);
mem(1,2) = meminit(1,2);
co(1,2) = coinit(1,2);
delta(1,2) = deltainit(1,2);
mem(1,3) = meminit(1,3);
co(1,3) = coinit(1,3);
delta(1,3) = deltainit(1,3);
mem(1,4) = meminit(1,4);
co(1,4) = coinit(1,4);
delta(1,4) = deltainit(1,4);
co(2,0) = 0;
delta(2,0) = -1;
mem(2,1) = meminit(2,1);
co(2,1) = coinit(2,1);
delta(2,1) = deltainit(2,1);
mem(2,2) = meminit(2,2);
co(2,2) = coinit(2,2);
delta(2,2) = deltainit(2,2);
mem(2,3) = meminit(2,3);
co(2,3) = coinit(2,3);
delta(2,3) = deltainit(2,3);
mem(2,4) = meminit(2,4);
co(2,4) = coinit(2,4);
delta(2,4) = deltainit(2,4);
co(3,0) = 0;
delta(3,0) = -1;
mem(3,1) = meminit(3,1);
co(3,1) = coinit(3,1);
delta(3,1) = deltainit(3,1);
mem(3,2) = meminit(3,2);
co(3,2) = coinit(3,2);
delta(3,2) = deltainit(3,2);
mem(3,3) = meminit(3,3);
co(3,3) = coinit(3,3);
delta(3,3) = deltainit(3,3);
mem(3,4) = meminit(3,4);
co(3,4) = coinit(3,4);
delta(3,4) = deltainit(3,4);
co(4,0) = 0;
delta(4,0) = -1;
mem(4,1) = meminit(4,1);
co(4,1) = coinit(4,1);
delta(4,1) = deltainit(4,1);
mem(4,2) = meminit(4,2);
co(4,2) = coinit(4,2);
delta(4,2) = deltainit(4,2);
mem(4,3) = meminit(4,3);
co(4,3) = coinit(4,3);
delta(4,3) = deltainit(4,3);
mem(4,4) = meminit(4,4);
co(4,4) = coinit(4,4);
delta(4,4) = deltainit(4,4);
co(5,0) = 0;
delta(5,0) = -1;
mem(5,1) = meminit(5,1);
co(5,1) = coinit(5,1);
delta(5,1) = deltainit(5,1);
mem(5,2) = meminit(5,2);
co(5,2) = coinit(5,2);
delta(5,2) = deltainit(5,2);
mem(5,3) = meminit(5,3);
co(5,3) = coinit(5,3);
delta(5,3) = deltainit(5,3);
mem(5,4) = meminit(5,4);
co(5,4) = coinit(5,4);
delta(5,4) = deltainit(5,4);
// Dumping thread 1
int ret_thread_1 = 0;
cdy[1] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[1] >= cstart[1]);
T1BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !38, metadata !DIExpression()), !dbg !47
// br label %label_1, !dbg !48
goto T1BLOCK1;
T1BLOCK1:
// call void @llvm.dbg.label(metadata !46), !dbg !49
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !39, metadata !DIExpression()), !dbg !50
// call void @llvm.dbg.value(metadata i64 1, metadata !42, metadata !DIExpression()), !dbg !50
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) release, align 8, !dbg !51
// ST: Guess
// : Release
iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l21_c3
old_cw = cw(1,0);
cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l21_c3
// Check
ASSUME(active[iw(1,0)] == 1);
ASSUME(active[cw(1,0)] == 1);
ASSUME(sforbid(0,cw(1,0))== 0);
ASSUME(iw(1,0) >= 0);
ASSUME(iw(1,0) >= 0);
ASSUME(cw(1,0) >= iw(1,0));
ASSUME(cw(1,0) >= old_cw);
ASSUME(cw(1,0) >= cr(1,0));
ASSUME(cw(1,0) >= cl[1]);
ASSUME(cw(1,0) >= cisb[1]);
ASSUME(cw(1,0) >= cdy[1]);
ASSUME(cw(1,0) >= cdl[1]);
ASSUME(cw(1,0) >= cds[1]);
ASSUME(cw(1,0) >= cctrl[1]);
ASSUME(cw(1,0) >= caddr[1]);
ASSUME(cw(1,0) >= cr(1,0+0));
ASSUME(cw(1,0) >= cr(1,0+1));
ASSUME(cw(1,0) >= cr(1,0+2));
ASSUME(cw(1,0) >= cr(1,3+0));
ASSUME(cw(1,0) >= cr(1,4+0));
ASSUME(cw(1,0) >= cr(1,5+0));
ASSUME(cw(1,0) >= cw(1,0+0));
ASSUME(cw(1,0) >= cw(1,0+1));
ASSUME(cw(1,0) >= cw(1,0+2));
ASSUME(cw(1,0) >= cw(1,3+0));
ASSUME(cw(1,0) >= cw(1,4+0));
ASSUME(cw(1,0) >= cw(1,5+0));
// Update
caddr[1] = max(caddr[1],0);
buff(1,0) = 1;
mem(0,cw(1,0)) = 1;
co(0,cw(1,0))+=1;
delta(0,cw(1,0)) = -1;
is(1,0) = iw(1,0);
cs(1,0) = cw(1,0);
ASSUME(creturn[1] >= cw(1,0));
// call void (...) @dmbsy(), !dbg !52
// dumbsy: Guess
old_cdy = cdy[1];
cdy[1] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[1] >= old_cdy);
ASSUME(cdy[1] >= cisb[1]);
ASSUME(cdy[1] >= cdl[1]);
ASSUME(cdy[1] >= cds[1]);
ASSUME(cdy[1] >= cctrl[1]);
ASSUME(cdy[1] >= cw(1,0+0));
ASSUME(cdy[1] >= cw(1,0+1));
ASSUME(cdy[1] >= cw(1,0+2));
ASSUME(cdy[1] >= cw(1,3+0));
ASSUME(cdy[1] >= cw(1,4+0));
ASSUME(cdy[1] >= cw(1,5+0));
ASSUME(cdy[1] >= cr(1,0+0));
ASSUME(cdy[1] >= cr(1,0+1));
ASSUME(cdy[1] >= cr(1,0+2));
ASSUME(cdy[1] >= cr(1,3+0));
ASSUME(cdy[1] >= cr(1,4+0));
ASSUME(cdy[1] >= cr(1,5+0));
ASSUME(creturn[1] >= cdy[1]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !43, metadata !DIExpression()), !dbg !53
// call void @llvm.dbg.value(metadata i64 1, metadata !45, metadata !DIExpression()), !dbg !53
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !54
// ST: Guess
iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l23_c3
old_cw = cw(1,0+1*1);
cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l23_c3
// Check
ASSUME(active[iw(1,0+1*1)] == 1);
ASSUME(active[cw(1,0+1*1)] == 1);
ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(cw(1,0+1*1) >= iw(1,0+1*1));
ASSUME(cw(1,0+1*1) >= old_cw);
ASSUME(cw(1,0+1*1) >= cr(1,0+1*1));
ASSUME(cw(1,0+1*1) >= cl[1]);
ASSUME(cw(1,0+1*1) >= cisb[1]);
ASSUME(cw(1,0+1*1) >= cdy[1]);
ASSUME(cw(1,0+1*1) >= cdl[1]);
ASSUME(cw(1,0+1*1) >= cds[1]);
ASSUME(cw(1,0+1*1) >= cctrl[1]);
ASSUME(cw(1,0+1*1) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0+1*1) = 1;
mem(0+1*1,cw(1,0+1*1)) = 1;
co(0+1*1,cw(1,0+1*1))+=1;
delta(0+1*1,cw(1,0+1*1)) = -1;
ASSUME(creturn[1] >= cw(1,0+1*1));
// ret i8* null, !dbg !55
ret_thread_1 = (- 1);
goto T1BLOCK_END;
T1BLOCK_END:
// Dumping thread 2
int ret_thread_2 = 0;
cdy[2] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[2] >= cstart[2]);
T2BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !58, metadata !DIExpression()), !dbg !68
// br label %label_2, !dbg !50
goto T2BLOCK1;
T2BLOCK1:
// call void @llvm.dbg.label(metadata !67), !dbg !70
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !60, metadata !DIExpression()), !dbg !71
// %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) acquire, align 8, !dbg !53
// LD: Guess
// : Acquire
old_cr = cr(2,0+1*1);
cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l29_c15
// Check
ASSUME(active[cr(2,0+1*1)] == 2);
ASSUME(cr(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cr(2,0+1*1) >= 0);
ASSUME(cr(2,0+1*1) >= cdy[2]);
ASSUME(cr(2,0+1*1) >= cisb[2]);
ASSUME(cr(2,0+1*1) >= cdl[2]);
ASSUME(cr(2,0+1*1) >= cl[2]);
ASSUME(cr(2,0+1*1) >= cx(2,0+1*1));
ASSUME(cr(2,0+1*1) >= cs(2,0+0));
ASSUME(cr(2,0+1*1) >= cs(2,0+1));
ASSUME(cr(2,0+1*1) >= cs(2,0+2));
ASSUME(cr(2,0+1*1) >= cs(2,3+0));
ASSUME(cr(2,0+1*1) >= cs(2,4+0));
ASSUME(cr(2,0+1*1) >= cs(2,5+0));
// Update
creg_r0 = cr(2,0+1*1);
crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+1*1) < cw(2,0+1*1)) {
r0 = buff(2,0+1*1);
ASSUME((!(( (cw(2,0+1*1) < 1) && (1 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(2,0+1*1) < 2) && (2 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(2,0+1*1) < 3) && (3 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(2,0+1*1) < 4) && (4 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) {
ASSUME(cr(2,0+1*1) >= old_cr);
}
pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1));
r0 = mem(0+1*1,cr(2,0+1*1));
}
cl[2] = max(cl[2],cr(2,0+1*1));
ASSUME(creturn[2] >= cr(2,0+1*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !62, metadata !DIExpression()), !dbg !71
// %conv = trunc i64 %0 to i32, !dbg !54
// call void @llvm.dbg.value(metadata i32 %conv, metadata !59, metadata !DIExpression()), !dbg !68
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !63, metadata !DIExpression()), !dbg !74
// call void @llvm.dbg.value(metadata i64 1, metadata !65, metadata !DIExpression()), !dbg !74
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) release, align 8, !dbg !56
// ST: Guess
// : Release
iw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l30_c3
old_cw = cw(2,0+2*1);
cw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l30_c3
// Check
ASSUME(active[iw(2,0+2*1)] == 2);
ASSUME(active[cw(2,0+2*1)] == 2);
ASSUME(sforbid(0+2*1,cw(2,0+2*1))== 0);
ASSUME(iw(2,0+2*1) >= 0);
ASSUME(iw(2,0+2*1) >= 0);
ASSUME(cw(2,0+2*1) >= iw(2,0+2*1));
ASSUME(cw(2,0+2*1) >= old_cw);
ASSUME(cw(2,0+2*1) >= cr(2,0+2*1));
ASSUME(cw(2,0+2*1) >= cl[2]);
ASSUME(cw(2,0+2*1) >= cisb[2]);
ASSUME(cw(2,0+2*1) >= cdy[2]);
ASSUME(cw(2,0+2*1) >= cdl[2]);
ASSUME(cw(2,0+2*1) >= cds[2]);
ASSUME(cw(2,0+2*1) >= cctrl[2]);
ASSUME(cw(2,0+2*1) >= caddr[2]);
ASSUME(cw(2,0+2*1) >= cr(2,0+0));
ASSUME(cw(2,0+2*1) >= cr(2,0+1));
ASSUME(cw(2,0+2*1) >= cr(2,0+2));
ASSUME(cw(2,0+2*1) >= cr(2,3+0));
ASSUME(cw(2,0+2*1) >= cr(2,4+0));
ASSUME(cw(2,0+2*1) >= cr(2,5+0));
ASSUME(cw(2,0+2*1) >= cw(2,0+0));
ASSUME(cw(2,0+2*1) >= cw(2,0+1));
ASSUME(cw(2,0+2*1) >= cw(2,0+2));
ASSUME(cw(2,0+2*1) >= cw(2,3+0));
ASSUME(cw(2,0+2*1) >= cw(2,4+0));
ASSUME(cw(2,0+2*1) >= cw(2,5+0));
// Update
caddr[2] = max(caddr[2],0);
buff(2,0+2*1) = 1;
mem(0+2*1,cw(2,0+2*1)) = 1;
co(0+2*1,cw(2,0+2*1))+=1;
delta(0+2*1,cw(2,0+2*1)) = -1;
is(2,0+2*1) = iw(2,0+2*1);
cs(2,0+2*1) = cw(2,0+2*1);
ASSUME(creturn[2] >= cw(2,0+2*1));
// %cmp = icmp eq i32 %conv, 1, !dbg !57
creg__r0__1_ = max(0,creg_r0);
// %conv1 = zext i1 %cmp to i32, !dbg !57
// call void @llvm.dbg.value(metadata i32 %conv1, metadata !66, metadata !DIExpression()), !dbg !68
// store i32 %conv1, i32* @atom_1_X0_1, align 4, !dbg !58, !tbaa !59
// ST: Guess
iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l32_c15
old_cw = cw(2,3);
cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l32_c15
// Check
ASSUME(active[iw(2,3)] == 2);
ASSUME(active[cw(2,3)] == 2);
ASSUME(sforbid(3,cw(2,3))== 0);
ASSUME(iw(2,3) >= creg__r0__1_);
ASSUME(iw(2,3) >= 0);
ASSUME(cw(2,3) >= iw(2,3));
ASSUME(cw(2,3) >= old_cw);
ASSUME(cw(2,3) >= cr(2,3));
ASSUME(cw(2,3) >= cl[2]);
ASSUME(cw(2,3) >= cisb[2]);
ASSUME(cw(2,3) >= cdy[2]);
ASSUME(cw(2,3) >= cdl[2]);
ASSUME(cw(2,3) >= cds[2]);
ASSUME(cw(2,3) >= cctrl[2]);
ASSUME(cw(2,3) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,3) = (r0==1);
mem(3,cw(2,3)) = (r0==1);
co(3,cw(2,3))+=1;
delta(3,cw(2,3)) = -1;
ASSUME(creturn[2] >= cw(2,3));
// ret i8* null, !dbg !63
ret_thread_2 = (- 1);
goto T2BLOCK_END;
T2BLOCK_END:
// Dumping thread 3
int ret_thread_3 = 0;
cdy[3] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[3] >= cstart[3]);
T3BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !85, metadata !DIExpression()), !dbg !97
// br label %label_3, !dbg !52
goto T3BLOCK1;
T3BLOCK1:
// call void @llvm.dbg.label(metadata !96), !dbg !99
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !87, metadata !DIExpression()), !dbg !100
// %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) acquire, align 8, !dbg !55
// LD: Guess
// : Acquire
old_cr = cr(3,0+2*1);
cr(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM _l38_c15
// Check
ASSUME(active[cr(3,0+2*1)] == 3);
ASSUME(cr(3,0+2*1) >= iw(3,0+2*1));
ASSUME(cr(3,0+2*1) >= 0);
ASSUME(cr(3,0+2*1) >= cdy[3]);
ASSUME(cr(3,0+2*1) >= cisb[3]);
ASSUME(cr(3,0+2*1) >= cdl[3]);
ASSUME(cr(3,0+2*1) >= cl[3]);
ASSUME(cr(3,0+2*1) >= cx(3,0+2*1));
ASSUME(cr(3,0+2*1) >= cs(3,0+0));
ASSUME(cr(3,0+2*1) >= cs(3,0+1));
ASSUME(cr(3,0+2*1) >= cs(3,0+2));
ASSUME(cr(3,0+2*1) >= cs(3,3+0));
ASSUME(cr(3,0+2*1) >= cs(3,4+0));
ASSUME(cr(3,0+2*1) >= cs(3,5+0));
// Update
creg_r1 = cr(3,0+2*1);
crmax(3,0+2*1) = max(crmax(3,0+2*1),cr(3,0+2*1));
caddr[3] = max(caddr[3],0);
if(cr(3,0+2*1) < cw(3,0+2*1)) {
r1 = buff(3,0+2*1);
ASSUME((!(( (cw(3,0+2*1) < 1) && (1 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,1)> 0));
ASSUME((!(( (cw(3,0+2*1) < 2) && (2 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,2)> 0));
ASSUME((!(( (cw(3,0+2*1) < 3) && (3 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,3)> 0));
ASSUME((!(( (cw(3,0+2*1) < 4) && (4 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,4)> 0));
} else {
if(pw(3,0+2*1) != co(0+2*1,cr(3,0+2*1))) {
ASSUME(cr(3,0+2*1) >= old_cr);
}
pw(3,0+2*1) = co(0+2*1,cr(3,0+2*1));
r1 = mem(0+2*1,cr(3,0+2*1));
}
cl[3] = max(cl[3],cr(3,0+2*1));
ASSUME(creturn[3] >= cr(3,0+2*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !89, metadata !DIExpression()), !dbg !100
// %conv = trunc i64 %0 to i32, !dbg !56
// call void @llvm.dbg.value(metadata i32 %conv, metadata !86, metadata !DIExpression()), !dbg !97
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !91, metadata !DIExpression()), !dbg !103
// %1 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) acquire, align 8, !dbg !58
// LD: Guess
// : Acquire
old_cr = cr(3,0);
cr(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM _l39_c15
// Check
ASSUME(active[cr(3,0)] == 3);
ASSUME(cr(3,0) >= iw(3,0));
ASSUME(cr(3,0) >= 0);
ASSUME(cr(3,0) >= cdy[3]);
ASSUME(cr(3,0) >= cisb[3]);
ASSUME(cr(3,0) >= cdl[3]);
ASSUME(cr(3,0) >= cl[3]);
ASSUME(cr(3,0) >= cx(3,0));
ASSUME(cr(3,0) >= cs(3,0+0));
ASSUME(cr(3,0) >= cs(3,0+1));
ASSUME(cr(3,0) >= cs(3,0+2));
ASSUME(cr(3,0) >= cs(3,3+0));
ASSUME(cr(3,0) >= cs(3,4+0));
ASSUME(cr(3,0) >= cs(3,5+0));
// Update
creg_r2 = cr(3,0);
crmax(3,0) = max(crmax(3,0),cr(3,0));
caddr[3] = max(caddr[3],0);
if(cr(3,0) < cw(3,0)) {
r2 = buff(3,0);
ASSUME((!(( (cw(3,0) < 1) && (1 < crmax(3,0)) )))||(sforbid(0,1)> 0));
ASSUME((!(( (cw(3,0) < 2) && (2 < crmax(3,0)) )))||(sforbid(0,2)> 0));
ASSUME((!(( (cw(3,0) < 3) && (3 < crmax(3,0)) )))||(sforbid(0,3)> 0));
ASSUME((!(( (cw(3,0) < 4) && (4 < crmax(3,0)) )))||(sforbid(0,4)> 0));
} else {
if(pw(3,0) != co(0,cr(3,0))) {
ASSUME(cr(3,0) >= old_cr);
}
pw(3,0) = co(0,cr(3,0));
r2 = mem(0,cr(3,0));
}
cl[3] = max(cl[3],cr(3,0));
ASSUME(creturn[3] >= cr(3,0));
// call void @llvm.dbg.value(metadata i64 %1, metadata !93, metadata !DIExpression()), !dbg !103
// %conv4 = trunc i64 %1 to i32, !dbg !59
// call void @llvm.dbg.value(metadata i32 %conv4, metadata !90, metadata !DIExpression()), !dbg !97
// %cmp = icmp eq i32 %conv, 1, !dbg !60
creg__r1__1_ = max(0,creg_r1);
// %conv5 = zext i1 %cmp to i32, !dbg !60
// call void @llvm.dbg.value(metadata i32 %conv5, metadata !94, metadata !DIExpression()), !dbg !97
// store i32 %conv5, i32* @atom_2_X0_1, align 4, !dbg !61, !tbaa !62
// ST: Guess
iw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l41_c15
old_cw = cw(3,4);
cw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l41_c15
// Check
ASSUME(active[iw(3,4)] == 3);
ASSUME(active[cw(3,4)] == 3);
ASSUME(sforbid(4,cw(3,4))== 0);
ASSUME(iw(3,4) >= creg__r1__1_);
ASSUME(iw(3,4) >= 0);
ASSUME(cw(3,4) >= iw(3,4));
ASSUME(cw(3,4) >= old_cw);
ASSUME(cw(3,4) >= cr(3,4));
ASSUME(cw(3,4) >= cl[3]);
ASSUME(cw(3,4) >= cisb[3]);
ASSUME(cw(3,4) >= cdy[3]);
ASSUME(cw(3,4) >= cdl[3]);
ASSUME(cw(3,4) >= cds[3]);
ASSUME(cw(3,4) >= cctrl[3]);
ASSUME(cw(3,4) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,4) = (r1==1);
mem(4,cw(3,4)) = (r1==1);
co(4,cw(3,4))+=1;
delta(4,cw(3,4)) = -1;
ASSUME(creturn[3] >= cw(3,4));
// %cmp6 = icmp eq i32 %conv4, 0, !dbg !66
creg__r2__0_ = max(0,creg_r2);
// %conv7 = zext i1 %cmp6 to i32, !dbg !66
// call void @llvm.dbg.value(metadata i32 %conv7, metadata !95, metadata !DIExpression()), !dbg !97
// store i32 %conv7, i32* @atom_2_X2_0, align 4, !dbg !67, !tbaa !62
// ST: Guess
iw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l43_c15
old_cw = cw(3,5);
cw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l43_c15
// Check
ASSUME(active[iw(3,5)] == 3);
ASSUME(active[cw(3,5)] == 3);
ASSUME(sforbid(5,cw(3,5))== 0);
ASSUME(iw(3,5) >= creg__r2__0_);
ASSUME(iw(3,5) >= 0);
ASSUME(cw(3,5) >= iw(3,5));
ASSUME(cw(3,5) >= old_cw);
ASSUME(cw(3,5) >= cr(3,5));
ASSUME(cw(3,5) >= cl[3]);
ASSUME(cw(3,5) >= cisb[3]);
ASSUME(cw(3,5) >= cdy[3]);
ASSUME(cw(3,5) >= cdl[3]);
ASSUME(cw(3,5) >= cds[3]);
ASSUME(cw(3,5) >= cctrl[3]);
ASSUME(cw(3,5) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,5) = (r2==0);
mem(5,cw(3,5)) = (r2==0);
co(5,cw(3,5))+=1;
delta(5,cw(3,5)) = -1;
ASSUME(creturn[3] >= cw(3,5));
// ret i8* null, !dbg !68
ret_thread_3 = (- 1);
goto T3BLOCK_END;
T3BLOCK_END:
// Dumping thread 0
int ret_thread_0 = 0;
cdy[0] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[0] >= cstart[0]);
T0BLOCK0:
// %thr0 = alloca i64, align 8
// %thr1 = alloca i64, align 8
// %thr2 = alloca i64, align 8
// call void @llvm.dbg.value(metadata i32 %argc, metadata !118, metadata !DIExpression()), !dbg !140
// call void @llvm.dbg.value(metadata i8** %argv, metadata !119, metadata !DIExpression()), !dbg !140
// %0 = bitcast i64* %thr0 to i8*, !dbg !65
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !65
// call void @llvm.dbg.declare(metadata i64* %thr0, metadata !120, metadata !DIExpression()), !dbg !142
// %1 = bitcast i64* %thr1 to i8*, !dbg !67
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !67
// call void @llvm.dbg.declare(metadata i64* %thr1, metadata !124, metadata !DIExpression()), !dbg !144
// %2 = bitcast i64* %thr2 to i8*, !dbg !69
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !69
// call void @llvm.dbg.declare(metadata i64* %thr2, metadata !125, metadata !DIExpression()), !dbg !146
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !126, metadata !DIExpression()), !dbg !147
// call void @llvm.dbg.value(metadata i64 0, metadata !128, metadata !DIExpression()), !dbg !147
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !72
// ST: Guess
iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l52_c3
old_cw = cw(0,0+2*1);
cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l52_c3
// Check
ASSUME(active[iw(0,0+2*1)] == 0);
ASSUME(active[cw(0,0+2*1)] == 0);
ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(cw(0,0+2*1) >= iw(0,0+2*1));
ASSUME(cw(0,0+2*1) >= old_cw);
ASSUME(cw(0,0+2*1) >= cr(0,0+2*1));
ASSUME(cw(0,0+2*1) >= cl[0]);
ASSUME(cw(0,0+2*1) >= cisb[0]);
ASSUME(cw(0,0+2*1) >= cdy[0]);
ASSUME(cw(0,0+2*1) >= cdl[0]);
ASSUME(cw(0,0+2*1) >= cds[0]);
ASSUME(cw(0,0+2*1) >= cctrl[0]);
ASSUME(cw(0,0+2*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+2*1) = 0;
mem(0+2*1,cw(0,0+2*1)) = 0;
co(0+2*1,cw(0,0+2*1))+=1;
delta(0+2*1,cw(0,0+2*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+2*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !129, metadata !DIExpression()), !dbg !149
// call void @llvm.dbg.value(metadata i64 0, metadata !131, metadata !DIExpression()), !dbg !149
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !74
// ST: Guess
iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l53_c3
old_cw = cw(0,0+1*1);
cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l53_c3
// Check
ASSUME(active[iw(0,0+1*1)] == 0);
ASSUME(active[cw(0,0+1*1)] == 0);
ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(cw(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cw(0,0+1*1) >= old_cw);
ASSUME(cw(0,0+1*1) >= cr(0,0+1*1));
ASSUME(cw(0,0+1*1) >= cl[0]);
ASSUME(cw(0,0+1*1) >= cisb[0]);
ASSUME(cw(0,0+1*1) >= cdy[0]);
ASSUME(cw(0,0+1*1) >= cdl[0]);
ASSUME(cw(0,0+1*1) >= cds[0]);
ASSUME(cw(0,0+1*1) >= cctrl[0]);
ASSUME(cw(0,0+1*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+1*1) = 0;
mem(0+1*1,cw(0,0+1*1)) = 0;
co(0+1*1,cw(0,0+1*1))+=1;
delta(0+1*1,cw(0,0+1*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !132, metadata !DIExpression()), !dbg !151
// call void @llvm.dbg.value(metadata i64 0, metadata !134, metadata !DIExpression()), !dbg !151
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !76
// ST: Guess
iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l54_c3
old_cw = cw(0,0);
cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l54_c3
// Check
ASSUME(active[iw(0,0)] == 0);
ASSUME(active[cw(0,0)] == 0);
ASSUME(sforbid(0,cw(0,0))== 0);
ASSUME(iw(0,0) >= 0);
ASSUME(iw(0,0) >= 0);
ASSUME(cw(0,0) >= iw(0,0));
ASSUME(cw(0,0) >= old_cw);
ASSUME(cw(0,0) >= cr(0,0));
ASSUME(cw(0,0) >= cl[0]);
ASSUME(cw(0,0) >= cisb[0]);
ASSUME(cw(0,0) >= cdy[0]);
ASSUME(cw(0,0) >= cdl[0]);
ASSUME(cw(0,0) >= cds[0]);
ASSUME(cw(0,0) >= cctrl[0]);
ASSUME(cw(0,0) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0) = 0;
mem(0,cw(0,0)) = 0;
co(0,cw(0,0))+=1;
delta(0,cw(0,0)) = -1;
ASSUME(creturn[0] >= cw(0,0));
// store i32 0, i32* @atom_1_X0_1, align 4, !dbg !77, !tbaa !78
// ST: Guess
iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l55_c15
old_cw = cw(0,3);
cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l55_c15
// Check
ASSUME(active[iw(0,3)] == 0);
ASSUME(active[cw(0,3)] == 0);
ASSUME(sforbid(3,cw(0,3))== 0);
ASSUME(iw(0,3) >= 0);
ASSUME(iw(0,3) >= 0);
ASSUME(cw(0,3) >= iw(0,3));
ASSUME(cw(0,3) >= old_cw);
ASSUME(cw(0,3) >= cr(0,3));
ASSUME(cw(0,3) >= cl[0]);
ASSUME(cw(0,3) >= cisb[0]);
ASSUME(cw(0,3) >= cdy[0]);
ASSUME(cw(0,3) >= cdl[0]);
ASSUME(cw(0,3) >= cds[0]);
ASSUME(cw(0,3) >= cctrl[0]);
ASSUME(cw(0,3) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,3) = 0;
mem(3,cw(0,3)) = 0;
co(3,cw(0,3))+=1;
delta(3,cw(0,3)) = -1;
ASSUME(creturn[0] >= cw(0,3));
// store i32 0, i32* @atom_2_X0_1, align 4, !dbg !82, !tbaa !78
// ST: Guess
iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l56_c15
old_cw = cw(0,4);
cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l56_c15
// Check
ASSUME(active[iw(0,4)] == 0);
ASSUME(active[cw(0,4)] == 0);
ASSUME(sforbid(4,cw(0,4))== 0);
ASSUME(iw(0,4) >= 0);
ASSUME(iw(0,4) >= 0);
ASSUME(cw(0,4) >= iw(0,4));
ASSUME(cw(0,4) >= old_cw);
ASSUME(cw(0,4) >= cr(0,4));
ASSUME(cw(0,4) >= cl[0]);
ASSUME(cw(0,4) >= cisb[0]);
ASSUME(cw(0,4) >= cdy[0]);
ASSUME(cw(0,4) >= cdl[0]);
ASSUME(cw(0,4) >= cds[0]);
ASSUME(cw(0,4) >= cctrl[0]);
ASSUME(cw(0,4) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,4) = 0;
mem(4,cw(0,4)) = 0;
co(4,cw(0,4))+=1;
delta(4,cw(0,4)) = -1;
ASSUME(creturn[0] >= cw(0,4));
// store i32 0, i32* @atom_2_X2_0, align 4, !dbg !83, !tbaa !78
// ST: Guess
iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l57_c15
old_cw = cw(0,5);
cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l57_c15
// Check
ASSUME(active[iw(0,5)] == 0);
ASSUME(active[cw(0,5)] == 0);
ASSUME(sforbid(5,cw(0,5))== 0);
ASSUME(iw(0,5) >= 0);
ASSUME(iw(0,5) >= 0);
ASSUME(cw(0,5) >= iw(0,5));
ASSUME(cw(0,5) >= old_cw);
ASSUME(cw(0,5) >= cr(0,5));
ASSUME(cw(0,5) >= cl[0]);
ASSUME(cw(0,5) >= cisb[0]);
ASSUME(cw(0,5) >= cdy[0]);
ASSUME(cw(0,5) >= cdl[0]);
ASSUME(cw(0,5) >= cds[0]);
ASSUME(cw(0,5) >= cctrl[0]);
ASSUME(cw(0,5) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,5) = 0;
mem(5,cw(0,5)) = 0;
co(5,cw(0,5))+=1;
delta(5,cw(0,5)) = -1;
ASSUME(creturn[0] >= cw(0,5));
// %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !84
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[1] >= cdy[0]);
// %call5 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !85
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[2] >= cdy[0]);
// %call6 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !86
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[3] >= cdy[0]);
// %3 = load i64, i64* %thr0, align 8, !dbg !87, !tbaa !88
r4 = local_mem[0];
// %call7 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !90
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[1]);
// %4 = load i64, i64* %thr1, align 8, !dbg !91, !tbaa !88
r5 = local_mem[1];
// %call8 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !92
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[2]);
// %5 = load i64, i64* %thr2, align 8, !dbg !93, !tbaa !88
r6 = local_mem[2];
// %call9 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !94
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[3]);
// %6 = load i32, i32* @atom_1_X0_1, align 4, !dbg !95, !tbaa !78
// LD: Guess
old_cr = cr(0,3);
cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l67_c13
// Check
ASSUME(active[cr(0,3)] == 0);
ASSUME(cr(0,3) >= iw(0,3));
ASSUME(cr(0,3) >= 0);
ASSUME(cr(0,3) >= cdy[0]);
ASSUME(cr(0,3) >= cisb[0]);
ASSUME(cr(0,3) >= cdl[0]);
ASSUME(cr(0,3) >= cl[0]);
// Update
creg_r7 = cr(0,3);
crmax(0,3) = max(crmax(0,3),cr(0,3));
caddr[0] = max(caddr[0],0);
if(cr(0,3) < cw(0,3)) {
r7 = buff(0,3);
ASSUME((!(( (cw(0,3) < 1) && (1 < crmax(0,3)) )))||(sforbid(3,1)> 0));
ASSUME((!(( (cw(0,3) < 2) && (2 < crmax(0,3)) )))||(sforbid(3,2)> 0));
ASSUME((!(( (cw(0,3) < 3) && (3 < crmax(0,3)) )))||(sforbid(3,3)> 0));
ASSUME((!(( (cw(0,3) < 4) && (4 < crmax(0,3)) )))||(sforbid(3,4)> 0));
} else {
if(pw(0,3) != co(3,cr(0,3))) {
ASSUME(cr(0,3) >= old_cr);
}
pw(0,3) = co(3,cr(0,3));
r7 = mem(3,cr(0,3));
}
ASSUME(creturn[0] >= cr(0,3));
// call void @llvm.dbg.value(metadata i32 %6, metadata !135, metadata !DIExpression()), !dbg !140
// %7 = load i32, i32* @atom_2_X0_1, align 4, !dbg !96, !tbaa !78
// LD: Guess
old_cr = cr(0,4);
cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l68_c13
// Check
ASSUME(active[cr(0,4)] == 0);
ASSUME(cr(0,4) >= iw(0,4));
ASSUME(cr(0,4) >= 0);
ASSUME(cr(0,4) >= cdy[0]);
ASSUME(cr(0,4) >= cisb[0]);
ASSUME(cr(0,4) >= cdl[0]);
ASSUME(cr(0,4) >= cl[0]);
// Update
creg_r8 = cr(0,4);
crmax(0,4) = max(crmax(0,4),cr(0,4));
caddr[0] = max(caddr[0],0);
if(cr(0,4) < cw(0,4)) {
r8 = buff(0,4);
ASSUME((!(( (cw(0,4) < 1) && (1 < crmax(0,4)) )))||(sforbid(4,1)> 0));
ASSUME((!(( (cw(0,4) < 2) && (2 < crmax(0,4)) )))||(sforbid(4,2)> 0));
ASSUME((!(( (cw(0,4) < 3) && (3 < crmax(0,4)) )))||(sforbid(4,3)> 0));
ASSUME((!(( (cw(0,4) < 4) && (4 < crmax(0,4)) )))||(sforbid(4,4)> 0));
} else {
if(pw(0,4) != co(4,cr(0,4))) {
ASSUME(cr(0,4) >= old_cr);
}
pw(0,4) = co(4,cr(0,4));
r8 = mem(4,cr(0,4));
}
ASSUME(creturn[0] >= cr(0,4));
// call void @llvm.dbg.value(metadata i32 %7, metadata !136, metadata !DIExpression()), !dbg !140
// %8 = load i32, i32* @atom_2_X2_0, align 4, !dbg !97, !tbaa !78
// LD: Guess
old_cr = cr(0,5);
cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l69_c13
// Check
ASSUME(active[cr(0,5)] == 0);
ASSUME(cr(0,5) >= iw(0,5));
ASSUME(cr(0,5) >= 0);
ASSUME(cr(0,5) >= cdy[0]);
ASSUME(cr(0,5) >= cisb[0]);
ASSUME(cr(0,5) >= cdl[0]);
ASSUME(cr(0,5) >= cl[0]);
// Update
creg_r9 = cr(0,5);
crmax(0,5) = max(crmax(0,5),cr(0,5));
caddr[0] = max(caddr[0],0);
if(cr(0,5) < cw(0,5)) {
r9 = buff(0,5);
ASSUME((!(( (cw(0,5) < 1) && (1 < crmax(0,5)) )))||(sforbid(5,1)> 0));
ASSUME((!(( (cw(0,5) < 2) && (2 < crmax(0,5)) )))||(sforbid(5,2)> 0));
ASSUME((!(( (cw(0,5) < 3) && (3 < crmax(0,5)) )))||(sforbid(5,3)> 0));
ASSUME((!(( (cw(0,5) < 4) && (4 < crmax(0,5)) )))||(sforbid(5,4)> 0));
} else {
if(pw(0,5) != co(5,cr(0,5))) {
ASSUME(cr(0,5) >= old_cr);
}
pw(0,5) = co(5,cr(0,5));
r9 = mem(5,cr(0,5));
}
ASSUME(creturn[0] >= cr(0,5));
// call void @llvm.dbg.value(metadata i32 %8, metadata !137, metadata !DIExpression()), !dbg !140
// %and = and i32 %7, %8, !dbg !98
creg_r10 = max(creg_r8,creg_r9);
r10 = r8 & r9;
// call void @llvm.dbg.value(metadata i32 %and, metadata !138, metadata !DIExpression()), !dbg !140
// %and10 = and i32 %6, %and, !dbg !99
creg_r11 = max(creg_r10,creg_r7);
r11 = r7 & r10;
// call void @llvm.dbg.value(metadata i32 %and10, metadata !139, metadata !DIExpression()), !dbg !140
// %cmp = icmp eq i32 %and10, 1, !dbg !100
creg__r11__1_ = max(0,creg_r11);
// br i1 %cmp, label %if.then, label %if.end, !dbg !102
old_cctrl = cctrl[0];
cctrl[0] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[0] >= old_cctrl);
ASSUME(cctrl[0] >= creg__r11__1_);
if((r11==1)) {
goto T0BLOCK1;
} else {
goto T0BLOCK2;
}
T0BLOCK1:
// call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([108 x i8], [108 x i8]* @.str.1, i64 0, i64 0), i32 noundef 72, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !103
// unreachable, !dbg !103
r12 = 1;
goto T0BLOCK_END;
T0BLOCK2:
// %9 = bitcast i64* %thr2 to i8*, !dbg !106
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !106
// %10 = bitcast i64* %thr1 to i8*, !dbg !106
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !106
// %11 = bitcast i64* %thr0 to i8*, !dbg !106
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !106
// ret i32 0, !dbg !107
ret_thread_0 = 0;
goto T0BLOCK_END;
T0BLOCK_END:
ASSUME(meminit(0,1) == mem(0,0));
ASSUME(coinit(0,1) == co(0,0));
ASSUME(deltainit(0,1) == delta(0,0));
ASSUME(meminit(0,2) == mem(0,1));
ASSUME(coinit(0,2) == co(0,1));
ASSUME(deltainit(0,2) == delta(0,1));
ASSUME(meminit(0,3) == mem(0,2));
ASSUME(coinit(0,3) == co(0,2));
ASSUME(deltainit(0,3) == delta(0,2));
ASSUME(meminit(0,4) == mem(0,3));
ASSUME(coinit(0,4) == co(0,3));
ASSUME(deltainit(0,4) == delta(0,3));
ASSUME(meminit(1,1) == mem(1,0));
ASSUME(coinit(1,1) == co(1,0));
ASSUME(deltainit(1,1) == delta(1,0));
ASSUME(meminit(1,2) == mem(1,1));
ASSUME(coinit(1,2) == co(1,1));
ASSUME(deltainit(1,2) == delta(1,1));
ASSUME(meminit(1,3) == mem(1,2));
ASSUME(coinit(1,3) == co(1,2));
ASSUME(deltainit(1,3) == delta(1,2));
ASSUME(meminit(1,4) == mem(1,3));
ASSUME(coinit(1,4) == co(1,3));
ASSUME(deltainit(1,4) == delta(1,3));
ASSUME(meminit(2,1) == mem(2,0));
ASSUME(coinit(2,1) == co(2,0));
ASSUME(deltainit(2,1) == delta(2,0));
ASSUME(meminit(2,2) == mem(2,1));
ASSUME(coinit(2,2) == co(2,1));
ASSUME(deltainit(2,2) == delta(2,1));
ASSUME(meminit(2,3) == mem(2,2));
ASSUME(coinit(2,3) == co(2,2));
ASSUME(deltainit(2,3) == delta(2,2));
ASSUME(meminit(2,4) == mem(2,3));
ASSUME(coinit(2,4) == co(2,3));
ASSUME(deltainit(2,4) == delta(2,3));
ASSUME(meminit(3,1) == mem(3,0));
ASSUME(coinit(3,1) == co(3,0));
ASSUME(deltainit(3,1) == delta(3,0));
ASSUME(meminit(3,2) == mem(3,1));
ASSUME(coinit(3,2) == co(3,1));
ASSUME(deltainit(3,2) == delta(3,1));
ASSUME(meminit(3,3) == mem(3,2));
ASSUME(coinit(3,3) == co(3,2));
ASSUME(deltainit(3,3) == delta(3,2));
ASSUME(meminit(3,4) == mem(3,3));
ASSUME(coinit(3,4) == co(3,3));
ASSUME(deltainit(3,4) == delta(3,3));
ASSUME(meminit(4,1) == mem(4,0));
ASSUME(coinit(4,1) == co(4,0));
ASSUME(deltainit(4,1) == delta(4,0));
ASSUME(meminit(4,2) == mem(4,1));
ASSUME(coinit(4,2) == co(4,1));
ASSUME(deltainit(4,2) == delta(4,1));
ASSUME(meminit(4,3) == mem(4,2));
ASSUME(coinit(4,3) == co(4,2));
ASSUME(deltainit(4,3) == delta(4,2));
ASSUME(meminit(4,4) == mem(4,3));
ASSUME(coinit(4,4) == co(4,3));
ASSUME(deltainit(4,4) == delta(4,3));
ASSUME(meminit(5,1) == mem(5,0));
ASSUME(coinit(5,1) == co(5,0));
ASSUME(deltainit(5,1) == delta(5,0));
ASSUME(meminit(5,2) == mem(5,1));
ASSUME(coinit(5,2) == co(5,1));
ASSUME(deltainit(5,2) == delta(5,1));
ASSUME(meminit(5,3) == mem(5,2));
ASSUME(coinit(5,3) == co(5,2));
ASSUME(deltainit(5,3) == delta(5,2));
ASSUME(meminit(5,4) == mem(5,3));
ASSUME(coinit(5,4) == co(5,3));
ASSUME(deltainit(5,4) == delta(5,3));
ASSERT(r12== 0);
}
| [
"tuan-phong.ngo@it.uu.se"
] | tuan-phong.ngo@it.uu.se |
d2b46ce165eacc8e96b028c92ce060179e4de3d5 | 1a86829e0d70a9b1c3c22359ac85cba403b4d900 | /reverseSTRING.cpp | 3666f4651887080a5a29fc1bce1dd634e4624386 | [] | no_license | swastik2203/Basic-Data-Structures | f7f8c711ce67fa046a8b31ab6743fd5f5e0e04c6 | 10a12cf329bbd436084784fb18cb5783396d3457 | refs/heads/master | 2023-08-12T16:12:01.904930 | 2021-09-30T10:48:30 | 2021-09-30T10:54:07 | 411,976,548 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 703 | cpp | #include <bits/stdc++.h>
#include <stack>
using namespace std;
void reverse(char* str, int n)
{
stack<char> s;
for (int i = 0; i < n; i++)
s.push(str[i]);
int i=0;
while (!s.empty())
{
str[i]=s.top();
s.pop();
i++;
}
/* for (int i = 0; i <n; i++){
str[i]=s.top();
s.pop();
}
*/
}
int main(){
int n;
cin>>n;
char str[n];
cout<<"enter the string :"<<endl;
for (int i = 0; i <n ; i++)
{
cin>>str[i];
}
reverse(str,n);
for (int i = 0; i <n ; i++)
{
cout<<str[i];
}
return 0;
} | [
"mundswastik@gmail.com"
] | mundswastik@gmail.com |
716146c9ae6900c7ff32c0df17b33d332817fc0f | 920c0f5b91c9cb3b8e56a4095d523230e84dc900 | /examples/6AxisFusion/6AxisFusion.ino | cdee1f63b5a9d5e0d28b3ef16f777171a398a37c | [] | no_license | Twometer/ICM-20948-Arduino | 7c2d7c5108c80e5b816906b1ae233f4e690a13b8 | 00fb567594e473ac61e6189276d3f9d05d7272c3 | refs/heads/main | 2023-06-02T20:50:34.845461 | 2021-03-29T16:14:49 | 2021-03-29T16:14:49 | 299,130,170 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,246 | ino | #include <ICM20948.h>
#define PIN_SDA 4
#define PIN_SCL 5
ICM20948 icm;
void fail();
void setup()
{
Serial.begin(115200);
// init chip
Wire.begin(PIN_SDA, PIN_SCL);
icm.setFusionMode(FUSION_6_AXIS);
int code = icm.begin();
// check return code
switch (code)
{
case ICM_SUCCESS:
Serial.println("Init ok");
break;
case ICM_BAD_WHOAMI:
Serial.println("Bad WHOAMI");
fail();
break;
case ICM_DMP_ERROR:
Serial.println("Failed to initialize DMP");
fail();
break;
case ICM_MAG_ERROR:
Serial.println("Magnetometer not found");
fail();
break;
case ICM_SERIAL_ERROR:
Serial.println("Serial connection failure");
fail();
break;
case ICM_SETUP_ERROR:
Serial.println("Device setup failure");
fail();
break;
}
// start some sensors
icm.startSensor(INV_SENSOR_TYPE_GAME_ROTATION_VECTOR, 16000);
}
void loop()
{
icm.update();
if (icm.available())
{
Serial.printf("%f %f %f %f\n", icm.x(), icm.y(), icm.z(), icm.w());
icm.clearAvailable();
}
delay(16);
}
void fail()
{
delay(10000);
ESP.restart();
} | [
"twometer@outlook.de"
] | twometer@outlook.de |
2170016b9eee76cfacfdbb9611698d7047a3ddbc | e41ac5363851c78620e6f6c2dcf4e50e0812c96a | /Engine/Code/Engine/Math/Noise.cpp | fb5db54ee4315709b52b34c088ffc8fff54e6851 | [
"MIT"
] | permissive | cugone/Abrams2019 | b9dd9d674cfbc131543e696e60a4c7b977964ed9 | cf1fb435cbe712fc149e02496bdc7462710cbf28 | refs/heads/master | 2021-11-11T01:18:13.295349 | 2021-11-08T17:42:52 | 2021-11-08T17:42:52 | 184,484,215 | 1 | 2 | MIT | 2019-05-01T21:56:32 | 2019-05-01T21:29:25 | C++ | UTF-8 | C++ | false | false | 225 | cpp | /************************************************************************/
/* INTENTIONALLY LEFT BLANK */
/************************************************************************/
| [
"cugone@gmail.com"
] | cugone@gmail.com |
ef63bd13fe0d74bbd09ede87ccce7d3f75f0b9be | 09fcb2598a24353157c907ea68e52674af99c057 | /Arduino/Libraries/MPU6500/MPU6500.cpp | 851898849bfbf652c64dea95b2f7fde34ab62629 | [] | no_license | salocinx/Multipurpose-Robot-Controller | 05f38878b1b97ab88b73ce3424e25fc5175d99b9 | 1dd67594cf089175591d2669a57b6a11d67b3fb3 | refs/heads/master | 2020-08-05T14:07:29.576108 | 2019-10-03T14:49:24 | 2019-10-03T14:49:24 | 212,573,400 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,814 | cpp |
#include "MPU6500.h"
#include <Wire.h>
MPU6500::MPU6500() {
inited = false;
}
void MPU6500::init(uint16_t p_cid, uint8_t p_addr, uint32_t p_interval, gyroscopeSensorCallbackFunction p_callback) {
if(!inited) {
cid = p_cid;
addr = p_addr;
_interval = p_interval;
_callback = p_callback;
// initialize i2c bus
Wire.begin();
// configure accelerometer
write(p_addr, 28, ACCELEROMETER_SCALE);
// configure gyroscope
write(p_addr, 27, GYROSCOPE_SCALE);
// reset start time
_time = millis();
// flag as running instance
inited = true;
}
}
void MPU6500::reset() {
inited = false;
}
void MPU6500::changeInterval(uint32_t p_interval) {
if(inited) {
_interval = p_interval;
}
}
void MPU6500::read() {
if(inited) {
MPU6500_Result result;
uint8_t buffer[14];
read(addr, 0x3B, 14, buffer);
// parse resultfer from accelerometer
result.ax = -(buffer[0] << 8 | buffer[1]);
result.ay = -(buffer[2] << 8 | buffer[3]);
result.az = buffer[4] << 8 | buffer[5];
// parse resultfer from gyroscope
result.gx = -(buffer[8] << 8 | buffer[9]);
result.gy = -(buffer[10] << 8 | buffer[11]);
result.gz = buffer[12] << 8 | buffer[13];
// callback attached function
if(_callback != NULL) {
(*_callback)(cid, result);
}
}
}
void MPU6500::read(uint8_t addr, uint8_t reg, uint8_t nbytes, uint8_t* data) {
Wire.beginTransmission(addr);
Wire.write(reg);
Wire.endTransmission();
Wire.requestFrom(addr, nbytes);
uint8_t index = 0;
while(Wire.available()) {
data[index++] = Wire.read();
}
}
void MPU6500::write(uint8_t addr, uint8_t reg, uint8_t data) {
Wire.beginTransmission(addr);
Wire.write(reg);
Wire.write(data);
Wire.endTransmission();
}
void MPU6500::update() {
if(inited) {
if(millis() - _time >= _interval) {
read();
_time = millis();
}
}
} | [
"nicolas@baumgardt.ch"
] | nicolas@baumgardt.ch |
c6d1e465784e6715600401d6e7fd448c6df46cbc | 54ca35a5e1354aef85d01368958f9789c517be82 | /Source/FX/PluginManager.h | 561adb5ec56fa37c5144ea02d064c022693f5e88 | [] | no_license | jdicarlantonio/TranscribeHelper | c2dcf2edcca81509f4fa025d7edb4f22ceeb2385 | a26c85361d2e69f67550a4c6d20240afe8f65db9 | refs/heads/master | 2021-06-27T11:26:01.466862 | 2020-09-29T16:38:23 | 2020-09-29T16:38:23 | 143,515,601 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,459 | h | /*
==============================================================================
PluginManager.h
Created: 21 Aug 2018 1:46:59pm
Author: jd
==============================================================================
*/
#pragma once
#include "../../JuceLibraryCode/JuceHeader.h"
class PluginManager
: public DocumentWindow
, public ListBoxModel
, public ActionBroadcaster
{
public:
PluginManager(const String& name, Colour backgroundColour);
~PluginManager();
void resized() override;
int getNumRows() override { return numPlugins; }
void paintListBoxItem(
int rowNumber,
Graphics& g,
int width,
int height,
bool rowIsSelected
) override;
void listBoxItemDoubleClicked(int row, const MouseEvent& ev) override;
void closeButtonPressed() override
{
setVisible(false);
}
bool addAndScanDirectory();
void update() { pluginSelector.updateContent(); }
PluginDescription getSelectedPlugin();
public:
bool pluginHasBeenSelected { false };
private:
TextButton changeVstDirButton;
TextButton scanVstDirButton;
ListBox pluginSelector { {}, this };
int numPlugins { 0 };
String pluginDirectoryPath;
std::unique_ptr<KnownPluginList> pluginList;
std::unique_ptr<AudioPluginFormat> formatManager;
// OwnedArray<PluginDescription> descriptions;
std::unique_ptr<KnownPluginList::PluginTree> pluginTree;
PluginDescription selectedPlugin;
// JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginManager)
}; | [
"jdriv90@gmail.com"
] | jdriv90@gmail.com |
cf4b7fbc15bd3a83b8033160fc9d4f5f45404749 | cc9ff7e9db9fcc418be452613d670993f5c53c5c | /client/mainwindow.cpp | 4ddd601e6ff457dc02db3e812b5f8ae0251a911f | [] | no_license | valentingrigorean/Collaborative-Notepad | cdca699163fd4256a68b97020593e4ecda35ac9e | 4823ca9357740d0b1b92e4a83b887ceb65f6a47a | refs/heads/master | 2021-01-01T18:22:04.427756 | 2015-08-06T10:30:57 | 2015-08-06T10:30:57 | 40,298,998 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,461 | cpp | #include <QFileDialog>
#include <QTextStream>
#include <QMessageBox>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "helpFunctions.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
init();
init_slots();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::init()
{
m_status = new QLabel(this);
m_cursorPos = new QLabel(this);
m_client = new client(ui->plainTextEdit,this);
m_replace = NULL;
m_find = NULL;
m_highlight = NULL;
m_cursorPos->setText("Line:1,Col:1");
m_status->setText("Connection:OFFLINE");
ui->statusBar->addPermanentWidget(m_status);
ui->statusBar->addPermanentWidget(m_cursorPos);
this->setCentralWidget(ui->plainTextEdit);
ui->actionCopy->setEnabled(false);
ui->actionCut->setEnabled(false);
ui->actionRedo->setEnabled(false);
ui->actionUndo->setEnabled(false);
ui->actionDisconnect->setEnabled(false);
ui->actionDownload->setEnabled(false);
ui->actionC_C_Compiler->setEnabled(false);
}
void MainWindow::init_slots()
{
connect(ui->plainTextEdit,SIGNAL(copyAvailable(bool)),this,SLOT(showCopyPaste(bool)));
connect(ui->plainTextEdit,SIGNAL(undoAvailable(bool)),this,SLOT(showUndo(bool)));
connect(ui->plainTextEdit,SIGNAL(redoAvailable(bool)),this,SLOT(showRedo(bool)));
connect(m_client,SIGNAL(got_file()),this,SLOT(got_file()));
connect(m_client,SIGNAL(lost_connection()),this,SLOT(lost_connection()));
connect(m_client,SIGNAL(triggerConnection()),this,SLOT(on_connection()));
connect(m_client,SIGNAL(too_manyusers()),this,SLOT(too_manyusers()));
}
//PUBLIC SLOTS
void MainWindow::on_connection()
{
switch(m_client->isConnected())
{
case true:
ui->actionDisconnect->setEnabled(true);
ui->actionJoin_Server->setEnabled(false);
ui->actionDownload->setEnabled(true);
m_status->setText("Connection:ONLINE");
this->setWindowTitle(updateTitle(m_client));
return;
default:
ui->actionDisconnect->setEnabled(false);
ui->actionJoin_Server->setEnabled(true);
ui->actionDownload->setEnabled(false);
ui->actionC_C_Compiler->setEnabled(false);
m_status->setText("Connection:OFFLINE");
}
}
void MainWindow::got_file()
{
m_prevtext = ui->plainTextEdit->toPlainText();
}
void MainWindow::lost_connection()
{
QMessageBox::information(this,"Error!","Can't connect to server.",QMessageBox::Ok);
}
void MainWindow::too_manyusers()
{
QMessageBox::information(this,"Error!","Are 2 users editing this file.",QMessageBox::Ok);
}
void MainWindow::close_find()
{
m_find = NULL;
}
void MainWindow::close_replace()
{
m_replace = NULL;
}
//MENU ITEMS
void MainWindow::showCopyPaste(bool b)
{
if(b)
{
ui->actionCopy->setEnabled(true);
ui->actionCut->setEnabled(true);
return;
}
ui->actionCopy->setEnabled(false);
ui->actionCut->setEnabled(false);
}
void MainWindow::showUndo(bool b)
{
b ? ui->actionUndo->setEnabled(true) : ui->actionUndo->setEnabled(false);
}
void MainWindow::showRedo(bool b)
{
b ? ui->actionRedo->setEnabled(true) : ui->actionRedo->setEnabled(false);
}
void MainWindow::on_actionExit_triggered()
{
this->close();
}
void MainWindow::on_actionJoin_Server_triggered()
{
m_client->clear();
connect_ui con(m_client,this);
con.exec();
if(m_client->isSet())
{
if(strcmp(&m_client->get_file()[strlen(m_client->get_file()) -2],".c") == 0
|| strcmp(&m_client->get_file()[strlen(m_client->get_file()) -4],".cpp") == 0)
ui->actionC_C_Compiler->setEnabled(true);
if(m_client->c_or_cplusplus())
on_actionC_C_triggered();
m_client->set_connection();
ui->plainTextEdit->clear();
m_client->getFile(0);
}
}
void MainWindow::on_actionDisconnect_triggered()
{
m_client->close_connection();
}
void MainWindow::on_actionSave_as_triggered()
{
QString filename = QFileDialog::getSaveFileName(this,"Save File",QDir::currentPath(),"Text files (*.txt);");
QFile file(filename);
file.open(QFile::WriteOnly);
QTextStream out(&file);
out << ui->plainTextEdit->toPlainText();
file.close();
}
void MainWindow::on_actionDownload_triggered()
{
m_client->start_thread(false);
Download down(m_client,this);
down.exec();
m_client->start_thread(true);
}
void MainWindow::on_actionUndo_triggered()
{
ui->plainTextEdit->undo();
}
void MainWindow::on_actionRedo_triggered()
{
ui->plainTextEdit->redo();
}
void MainWindow::on_actionCut_triggered()
{
ui->plainTextEdit->cut();
}
void MainWindow::on_actionCopy_triggered()
{
ui->plainTextEdit->copy();
}
void MainWindow::on_actionPaste_triggered()
{
ui->plainTextEdit->paste();
}
void MainWindow::on_actionFind_triggered()
{
if(m_replace || m_find)
return;
m_find = new Find(ui->plainTextEdit,this);
connect(m_find,SIGNAL(finished(int)),this,SLOT(close_find()));
m_find->show();
}
void MainWindow::on_actionReplace_triggered()
{
if(m_find || m_replace)
return;
m_replace = new Replace(ui->plainTextEdit,this);
connect(m_replace,SIGNAL(finished(int)),this,SLOT(close_replace()));
m_replace->show();
}
void MainWindow::on_actionC_C_Compiler_triggered()
{
m_client->compile();
}
//Editor
void MainWindow::on_plainTextEdit_cursorPositionChanged()
{
m_cursorPos->setText("Line:" + QString::number(ui->plainTextEdit->textCursor().blockNumber()+1)
+ "Col:" + QString::number(ui->plainTextEdit->textCursor().columnNumber()+1));
}
void MainWindow::on_plainTextEdit_textChanged()
{
if(m_client->isConnected())
{
text_changed(ui->plainTextEdit,m_prevtext,m_client);
m_prevtext = ui->plainTextEdit->toPlainText();
}
}
void MainWindow::on_actionC_C_triggered()
{
if(m_highlight)
return;
m_highlight = new Highlighter(ui->plainTextEdit->document());
ui->actionC_C->setIconVisibleInMenu(true);
ui->actionPlain_Text->setIconVisibleInMenu(false);
}
void MainWindow::on_actionPlain_Text_triggered()
{
if(m_highlight != NULL)
{
delete m_highlight;
m_highlight = 0;
}
ui->actionC_C->setIconVisibleInMenu(false);
ui->actionPlain_Text->setIconVisibleInMenu(true);
}
| [
"valentin.grigorean1@gmail.com"
] | valentin.grigorean1@gmail.com |
0984461bb08e843820f3eeccd5ab2279612e1120 | 10b85163837c1c1976d4de6e179d53cf6e371478 | /third_party/common/include/RE/ExtraEditorRef3DData.h | 047fe9866c28d22c0b77830f3ac5133a69f5a07f | [
"MIT",
"ISC",
"LicenseRef-scancode-mit-taylor-variant",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | rethesda/alchemy | 8e02352240bfb295e1fe7c6682acabe93fc11aa6 | fe6897fa8c065eccc49b61c8c82eda223d865d51 | refs/heads/master | 2023-03-15T19:10:10.132829 | 2020-05-12T05:02:33 | 2020-05-12T05:02:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 640 | h | #pragma once
#include "RE/BSExtraData.h"
#include "RE/ExtraDataTypes.h"
#include "RE/NiSmartPointer.h"
namespace RE
{
class NiRefObject;
class ExtraEditorRef3DData : public BSExtraData
{
public:
inline static const void* RTTI = RTTI_ExtraEditorRef3DData;
enum { kExtraTypeID = ExtraDataType::kEditorRef3DData };
virtual ~ExtraEditorRef3DData(); // 00
// override (BSExtraData)
virtual ExtraDataType GetType() const override; // 01 - { return kEditorRef3DData; }
// members
NiPointer<NiRefObject> unk10; // 10
NiPointer<NiRefObject> unk18; // 18
};
static_assert(sizeof(ExtraEditorRef3DData) == 0x20);
}
| [
"alexej.h@xiphos.de"
] | alexej.h@xiphos.de |
82a98820a8c45fde2e0d2f124641f75d162fd65c | 216b3bb72b1ea19891acadbd86879cc3e2ee49ef | /opencamera/src/image_converter.cpp | 98eaf678ec18f9f1f42fb29df1ba0a9167efc93f | [] | no_license | furufa/ros_source | 32c3e78990b30bb4355bde502e56f8d25a925486 | a1a43375d13ce8d9616d4eef0acf42be5823b146 | refs/heads/master | 2021-08-31T21:58:00.986103 | 2017-12-23T02:47:09 | 2017-12-23T02:47:09 | 113,986,955 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,574 | cpp | #include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
static const std::string OPENCV_WINDOW = "Image window";
class ImageConverter
{
ros::NodeHandle nh_;
image_transport::ImageTransport it_;
image_transport::Subscriber image_sub_;
image_transport::Publisher image_pub_;
public:
ImageConverter()
: it_(nh_)
{
// Subscrive to input video feed and publish output video feed
image_sub_ = it_.subscribe("/cv_camera/image_raw", 1,
&ImageConverter::imageCb, this);
image_pub_ = it_.advertise("/image_converter/output_video", 1);
cv::namedWindow(OPENCV_WINDOW);
}
~ImageConverter()
{
cv::destroyWindow(OPENCV_WINDOW);
}
void imageCb(const sensor_msgs::ImageConstPtr& msg)
{
cv_bridge::CvImagePtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
// Draw an example circle on the video stream
if (cv_ptr->image.rows > 60 && cv_ptr->image.cols > 60)
cv::circle(cv_ptr->image, cv::Point(50, 50), 10, CV_RGB(255,0,0));
// Update GUI Window
cv::imshow(OPENCV_WINDOW, cv_ptr->image);
cv::waitKey(3);
// Output modified video stream
image_pub_.publish(cv_ptr->toImageMsg());
}
};
int main(int argc, char** argv)
{
ros::init(argc, argv, "image_converter");
ImageConverter ic;
ros::spin();
return 0;
}
| [
"s1411473@u.tsukuba.ac.jp"
] | s1411473@u.tsukuba.ac.jp |
377e3fa69d5fe9311b3028ce57d9d0e0f98271f3 | 7fd5e6156d6a42b305809f474659f641450cea81 | /boost/spirit/repository/home/karma/directive.hpp | a2fa84d8cf43da4d0660b3b1f2dd0166680cbff0 | [] | no_license | imos/icfpc2015 | 5509b6cfc060108c9e5df8093c5bc5421c8480ea | e998055c0456c258aa86e8379180fad153878769 | refs/heads/master | 2020-04-11T04:30:08.777739 | 2015-08-10T11:53:12 | 2015-08-10T11:53:12 | 40,011,767 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 510 | hpp | // Copyright (c) 2001-2011 Hartmut Kaiser
// Copyright (c) 2001-2011 Joel de Guzman
//
// 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)
#if !defined(SPIRIT_REPOSITORY_KARMA_DIRECTIVE_APR_28_2009_1258PM)
#define SPIRIT_REPOSITORY_KARMA_DIRECTIVE_APR_28_2009_1258PM
#if defined(_MSC_VER)
#pragma once
#endif
#include "boost/spirit/repository/home/karma/directive/confix.hpp"
#endif
| [
"git@imoz.jp"
] | git@imoz.jp |
584fdf5575cc5a0edf6fd2c2071f6e38cc4d4a73 | f0b1a191fdd5868839afca66361f1612ef9e57c7 | /GS/lib/md5-hasher/md5.h | c4a615fcf457cc6247cdca55389c461729296aa0 | [
"BSD-2-Clause",
"Zlib"
] | permissive | vsrz/CS699 | cfdf30a65c6903f0a0cabe024808ba2329fdf8bf | d10db61d263eaedb2447c5c1972f62fb10db0480 | refs/heads/master | 2020-06-08T22:04:26.615033 | 2014-11-16T06:49:41 | 2014-11-16T06:49:41 | null | 0 | 0 | null | null | null | null | ISO-8859-3 | C++ | false | false | 2,000 | h | /*
* This is the C++ implementation of the MD5 Message-Digest
* Algorithm desrcipted in RFC 1321.
* There is no warranty.
*
* Feb. 12. 2005
* Benjamin Grüdelbach
*/
/*
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
* rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*/
#ifndef _MD5_H_
#define _MD5_H_
#include <string>
typedef unsigned char *POINTER;
typedef struct
{
unsigned long int state[4]; /* state (ABCD) */
unsigned long int count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
class MD5
{
private:
void MD5Transform(unsigned long int state[4], unsigned char block[64]);
void Encode(unsigned char*, unsigned long int*, unsigned int);
void Decode(unsigned long int*, unsigned char*, unsigned int);
void MD5_memcpy(POINTER, POINTER, unsigned int);
void MD5_memset(POINTER, int, unsigned int);
public:
void MD5Init(MD5_CTX*);
void MD5Update(MD5_CTX*, unsigned char*, unsigned int);
void MD5Final(unsigned char [16], MD5_CTX*);
MD5(){};
};
#endif
/*
* EOF
*/
| [
"ritual@vsritual.com"
] | ritual@vsritual.com |
c827743808933f8fca5be67b5e6f8bce7bc5328f | 4d402199704e2c213d1074e79163106613d8db7c | /Assignment 6/HEADER_FILE.h | 8dcc46e88dcc3459225d4383ff9452dc3432d9b9 | [] | no_license | Kshumishyn/Cpp | 9839c7de5f9cbc04a2115e6a99cce05e03858cbe | 239cab8329b80a310c3c2be4efecb2576539231c | refs/heads/master | 2021-09-05T06:36:35.790206 | 2018-01-24T21:41:20 | 2018-01-24T21:41:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,059 | h | // This file is called HEADER_FILE.h
#ifndef HEADER_FILE_H_
#define HEADER_FILE_H_
// Preprocessor directives go here
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
// Global variables go here
// Prototypes go here
// This function accepts a series of parameters to output a heading
void PrintHeader(string names, //IN - Name(s) of Student(s)
string asName, //IN - Assignment number
int asNum, //IN - Assignment name
char asType, //IN - 'A'ssignment or 'L'ab
ofstream &fout); //IN & OUT - I/O Assist
// This function will assign all the relevant information for a purchase
void GetSalesInfo(int &accNum, // OUT - Account Number Input
int &month, // OUT - Month integer Input
int &day, // OUT - Day integer Input
int &year, // OUT - Year integer Input
char &countryCode, // OUT - Error Checked Char
double &saleAmount, // OUT - Sale amount (before tax)
int &weight, // OUT - Weight of Item
ifstream &fin, //IN & OUT - File I/O Assist
ofstream &fout); //IN & OUT - File I/O Assist
// This function calculates and returns the amount discounted
double CalcDiscount(int month, //IN - Month to determine discount
double saleAmount); //IN - Sale amount to calc discount
// This function calculates and returns the amount taxed
double CalcSalesTax(char countryCode, //IN - Country code to find tax
double saleAmount, //IN - Amount to calculate tax
ofstream &fout); //IN & OUT - File I/O Assist
// This function calculates and returns the shipping cost
double CalcShipping(int weight); //IN - Used to determine shipping cost
// This function formats an output of all the relevant information
void OutputInvoice(int accNum, //IN - Account Number for Output
int month, //IN - Month for formatted date
int day, //IN - Day for formatted date
int year, //IN - Year for formatted date
char countryCode, //IN - Code used to get County
double saleAmount, //IN - Output original amount
double discount, //IN - Outputs amount saved
double salesTax, //IN - Outputs amount taxed
double shipping, //IN - Outputs shipping cost
double totalDue, //IN - Outputs the net cost
ofstream &fout); //IN & OUT - File I/O Assist
#endif /* HEADER_FILE_H_ */
// To include this file
// #include "HEADER_FILE.h"
| [
"Kshumishyn@gmail.com"
] | Kshumishyn@gmail.com |
eb07888fe696c7ceb962efd0cd4255e27de42f77 | 016cb92d3cd112de1d6cfe2723dab43399dd881d | /kernal/C++P+/vector/vector.cpp | 6338fa04ec4dc0867098168d966d062310f811a2 | [] | no_license | QuasimodoJL/Unix | 23b236b44dff579aefae5a3171398f8d1d53115f | e6aea58c88236e28855076be4bd65c86e2b5c4c3 | refs/heads/master | 2023-07-07T09:31:43.720093 | 2021-06-09T19:03:33 | 2021-06-09T19:03:33 | 374,983,309 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,772 | cpp | //
// Created by 梁佳皓 on 2018/7/5.
//
#include <cmath>
#include "vector.h"
using std::sin;
using std::cos;
using std::atan2;
using std::cout;
namespace VECTOR
{
const double Rad_to_deg = 57.2957795130823;
void Vector::set_mag()
{
mag = sqrt(x * x + y * y);
}
void Vector::set_ang()
{
if (x == 0.0 && y == 0.0)
ang = 0.0;
else
ang = atan2 (y, x);
}
void Vector::set_x()
{
x = mag * cos(ang);
}
void Vector::set_y()
{
y = mag * sin(ang);
}
Vector::Vector()
{
x = y = mag = ang = 0.0;
}
Vector::Vector(double n1, double n2, char form)
{
mode = form;
if (form == 'r')
{
x = n1;
y = n2;
set_mag();
set_ang();
}
else if (form == 'p')
{
mag = n1;
ang = n2;
set_x();
set_y();
}
else
{
cout << "Incorrect 3rd argument to Vector() -- ";
cout << "Vector set to 0\n";
x = y = mag = ang = 0.0;
mode = 'r';
}
}
void Vector::set(double n1, double n2, char form)
{
mode = form;
if (form == 'r')
{
x = n1;
y = n2;
set_mag();
set_ang();
}
else if (form == 'p')
{
mag = n1;
ang = n2;
set_x();
set_y();
}
else
{
cout << "Incorrect 3rd argument to vector()-- ";
cout << "Vector set to 0\n";
x = y = mag = ang = 0.0;
mode = 'r';
}
}
Vector::~Vector()
{
}
void Vector::polar_mode()
{
mode = 'p';
}
void Vector::rect_mode()
{
mode = 'r';
}
Vector Vector::operator+(const Vector &b) const
{
return Vector (x + b.x, y + b.y);
}
Vector Vector::operator-(const Vector &b) const
{
return Vector (x - b.x, y - b.y);
}
Vector Vector::operator-() const
{
return Vector (-x, -y);
}
Vector Vector::operator*(double n) const
{
return Vector(n * x, n * y);
}
Vector operator* (double n, const Vector & a)
{
return a * n;
}
std::ostream & operator<< (std::ostream & os, const Vector & v)
{
if (v.mode == 'r')
os << " (x, y) = (" << v.x << ", " << v.y << ") ";
else if (v.mode == 'p')
{
os << " (m, a) = (" << v.mag << ", "
<< v.ang * Rad_to_deg << ") ";
}
else
os << "Vector object mode is invalid";
return os;
}
} | [
"quasimodojl@gmail.com"
] | quasimodojl@gmail.com |
4447c646831e47303ab3ddeafc54bead88543804 | ed7384df10e7786bdc469237310445eec60052a7 | /codes/accepted_codes/Isomorphic Strings_473350049.cpp | 9ece3013aae5f41466706fe8f14d3700c0ffdfa2 | [] | no_license | sreedhr92/Leetcode-Submissions | 6586bc2925c1e7c516c229b18788788271778e7a | cac7a7fcc33e3e9ea4b88fc30e1f7b283067a87c | refs/heads/master | 2023-05-26T13:02:55.965007 | 2021-06-11T14:50:17 | 2021-06-11T14:50:17 | 370,307,315 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 492 | cpp | class Solution {
public:
bool isIsomorphic(string s, string t) {
unordered_map<char,char> hash;
for(int i=0;i<s.size();i++)
hash[s[i]]=t[i];
set<char> myset;
for(auto it:hash)
{
if(myset.find(it.second)!=myset.end())
return false;
myset.insert(it.second);
}
string n="";
for(char ch:s)
n+=hash[ch];
return n.compare(t)==0?true:false;
}
};
| [
"sreedhrindi15@gmail.com"
] | sreedhrindi15@gmail.com |
92b060be2612b261be3dd9d3d4d43c26b8592aff | 78ebe3d8a5887d10879534c4adf7ad6a241fd2cc | /WK200 modbus_p7_10/modbus_p7_10.ino | ff61bf37f98d739503f5add9da795c3d7a8f89d7 | [] | no_license | formacionconarduino/control-fichajes-rondas | f104c1e0439a7d7aa9790168dadcb98b00b36e7e | 91dc6fd6f47ca4550a0470d79d8625ee602e27a7 | refs/heads/master | 2016-09-06T14:27:13.796432 | 2012-10-18T20:27:24 | 2012-10-18T20:27:24 | 3,240,631 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,758 | ino | //WK0200 -> ATMEGA 328P -> Graba datos tarjeta en EEPROM (1k - 0 a 0x3ff)
#include <SimpleModbusSlave.h>
#include <Wire.h>
#include <EEPROM.h>
#define ADDR_RFID 0x41 //Direccion I2C del lector RFID en el WK0200
#define BAUD 19200
#define DirMB 60
#define EP_punteroTarjetas 20
#define EP_puertabloqueada 19
enum
{ COMANDO, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8, ARG9, ARG10, TOTAL_ERRORS, TOTAL_REGS_SIZE };
unsigned int holdingRegs[TOTAL_REGS_SIZE];
boolean rfid=false, abrir=false, puerta_abierta=false, controlar=false;
unsigned long numero, numero_tarjeta=0, time, time2;
void setup()
{
Wire.begin(); //Inicia I2C
rfidReleOff(); //Desconectar rele
for (int i=0; i<TOTAL_REGS_SIZE; i++) { holdingRegs[i]=0; }
modbus_configure (BAUD, DirMB,0,TOTAL_REGS_SIZE);
if (EEPROM.read(EP_puertabloqueada)==0xFF)
{
EEPROM.write(EP_puertabloqueada, 0x00); //inicializar puerta desbloqueada
}
}
void loop()
{
if (puerta_abierta&&(millis()>(time+2000)))
{
rfidReleOff();
puerta_abierta=false;
}
holdingRegs[COMANDO]=0xFFFF;
holdingRegs[TOTAL_ERRORS]=modbus_update(holdingRegs);
if(holdingRegs[COMANDO]!=0xFFFF)
{
ProcesarComandoMB();
}
CompruebaRFID();
if (rfid==true)
{
boolean encontrada=false;
unsigned char info;
unsigned int punterotarjetas=EP_punteroTarjetas;
unsigned long n;
rfid=abrir=false;
if ((controlar)&&(millis()<(time2+5000)))
{
anadirtarjetaEEPROM(numero_tarjeta,0);
controlar=false;
}
else
{
controlar=false;
while((EEPROM.read(punterotarjetas+4)!=0xFF)&&(!encontrada))
{
n=leer_numero_tarjeta(punterotarjetas);
info=EEPROM.read(punterotarjetas+4);
if (n==numero_tarjeta)
{
encontrada=true;
switch(info)
{
case 0x21: //es supermaestra y habilitada
abrir=true; controlar=true; time2=millis();
break;
case 0x11: //es maestra y habilitada
case 0x01: //es normal y habilitada
if (!puerta_bloqueada()) { abrir=true; }
break;
}
}
punterotarjetas=punterotarjetas+5;
}
if (puerta_bloqueada())
{
holdingRegs[ARG8]=0x0100; //puerta bloqueada
}
else
{
holdingRegs[ARG8]=0x0000; //puerta desbloqueada
}
if (encontrada)
{
holdingRegs[ARG8]=holdingRegs[ARG8]|info; //tarjeta encontrada -> byte MSB: puerta bloqueada o no
} // -> byte LSB: tipo tarjeta+habilitada o no
else
{
holdingRegs[ARG8]=holdingRegs[ARG8]|0xFF; //tarjeta no encontrada -> byte MSB: puerta bloqueada o no
} // -> byte LSB: 0xFF (no dada de alta)
}
if (abrir)
{
rfidReleOn();
time = millis();
puerta_abierta=true;
}
}
}
void ProcesarComandoMB(void)
{
unsigned int punterotarjetas=EP_punteroTarjetas;
numero=(((unsigned long)holdingRegs[ARG1])<<16)|((unsigned long)holdingRegs[ARG2]);
switch(holdingRegs[COMANDO])
{
case 0x01: //Nueva Direccion ModBus
break;
case 0x02: //Nuevos Parametros COM del ModBus
break;
case 0x03: //Validar los nuevos parametros ModBus
break;
case 0x20: //Abrir puerta de forma remota
rfidReleOn();
time = millis();
puerta_abierta=true;
break;
case 0x21: //Dar de alta tarjeta normal
anadirtarjetaEEPROM(numero,0);
break;
case 0x22: //Dar de alta tarjeta maestra
anadirtarjetaEEPROM(numero,1);
break;
case 0x23: //Dar de alta tarjeta supermaestra
anadirtarjetaEEPROM(numero,2);
break;
case 0x24: //Dar de baja tarjeta (da igual el tipo)
dardebajatarjetaEEPROM(numero);
break;
case 0x25: //Bloquear puerta
EEPROM.write(EP_puertabloqueada,0x01);
break;
case 0x26: //Desbloquear puerta
EEPROM.write(EP_puertabloqueada,0x00);
break;
case 0x27: //Consultar puertas
break;
case 0x28: //Borrado total cerradura
for (int i=0; i<TOTAL_REGS_SIZE; i++)
{
holdingRegs[i]=0;
}
while (EEPROM.read(punterotarjetas+4)!=0xFF)
{
for (int i=0; i<5; i++)
{
EEPROM.write(punterotarjetas,0xFF);
punterotarjetas++;
}
}
break;
case 0x2c: //Borrar registros RTU con informacion ya leida -> continuacion comando TCP
holdingRegs[ARG6]=0;
holdingRegs[ARG7]=0;
holdingRegs[ARG8]=0;
break;
}
}
void CompruebaRFID (void)
{
int c=0;
byte codigo[5]={0,0,0,0,0};
Wire.requestFrom(ADDR_RFID, 1);
if (Wire.available())
{
c=Wire.read();
if (c==0x6E) //Tarjeta detectada
{
rfid=true;
Wire.beginTransmission(ADDR_RFID);
Wire.write(0x52);
Wire.endTransmission();
Wire.requestFrom(ADDR_RFID,5);
for (int i=0; i<5; i++)
{
if (Wire.available())
{
codigo[i]=Wire.read(); //El primer byte ¿es el de mayor peso?
}
}
if (codigo[4]==0x4E) //seguna parte de la transmision del codigo
{
Wire.beginTransmission(ADDR_RFID);
Wire.write(0x52);
Wire.endTransmission();
Wire.requestFrom(ADDR_RFID,1);
if (Wire.available())
{
codigo[4]=Wire.read();
}
}
numero_tarjeta= (((unsigned long)codigo[1])<<24)|(((unsigned long)codigo[2])<<16)|(((unsigned long)codigo[3])<<8)|((unsigned long)codigo[4]);
holdingRegs[ARG6]=(codigo[1]<<8)|codigo[2];
holdingRegs[ARG7]=(codigo[3]<<8)|codigo[4];
}
}
}
void rfidReleOn()
{
Wire.beginTransmission(ADDR_RFID);
Wire.write(0x62);
Wire.write(0x01);
Wire.write((byte)0x00);
Wire.write((byte)0x00);
Wire.write((byte)0x00);
Wire.write((byte)0x00);
Wire.write((byte)0x00);
Wire.write(0x63);
Wire.endTransmission();
}
void rfidReleOff()
{
Wire.beginTransmission(ADDR_RFID);
Wire.write(0x62);
Wire.write((byte)0x00);
Wire.write((byte)0x00);
Wire.write((byte)0x00);
Wire.write((byte)0x00);
Wire.write((byte)0x00);
Wire.write((byte)0x00);
Wire.write(0x62);
Wire.endTransmission();
}
boolean puerta_bloqueada (void)
{
if (EEPROM.read(EP_puertabloqueada)==0x01) return true;
else return false;
}
void anadirtarjetaEEPROM(unsigned long n_leer, int tipo)
{
unsigned char info;
int escrito=0, resto, punterotarjetas=EP_punteroTarjetas;
unsigned long n;
do
{
if (EEPROM.read(punterotarjetas+4)!=0xFF)
{
n=leer_numero_tarjeta(punterotarjetas);
info=EEPROM.read(punterotarjetas+4);
if (n==n_leer)
{
EEPROM.write(punterotarjetas+4,((tipo<<4)|0x01)); //actualizar info
escrito=1;
}
punterotarjetas=punterotarjetas+5;
}
else
{
punterotarjetas=punterotarjetas+4;
for (int x=0; x<4; x++)
{
resto=n_leer%256;
n_leer=n_leer/256;
punterotarjetas--;
EEPROM.write(punterotarjetas,resto); //escribir numero tarjeta
}
punterotarjetas=punterotarjetas+4;
EEPROM.write(punterotarjetas,((tipo<<4)|0x01)); //escribir info
escrito=1;
}
}
while(escrito==0);
}
void dardebajatarjetaEEPROM (unsigned long n_leer)
{
unsigned char info;
unsigned int punterotarjetas=EP_punteroTarjetas;
unsigned long n;
while (EEPROM.read(punterotarjetas+4)!=0xFF)
{
n=leer_numero_tarjeta(punterotarjetas);
info=EEPROM.read(punterotarjetas+4);
if (n==n_leer)
{
EEPROM.write(punterotarjetas+4,(info&0xFE)); //deshabilitar
}
punterotarjetas=punterotarjetas+5;
}
}
unsigned long leer_numero_tarjeta (int punt)
{
unsigned long leer=0;
leer=EEPROM.read(punt);
punt++;
leer=EEPROM.read(punt)|(leer<<8);
punt++;
leer=EEPROM.read(punt)|(leer<<8);
punt++;
leer=EEPROM.read(punt)|(leer<<8);
return leer;
}
| [
"mcarmen.curras@gmail.com"
] | mcarmen.curras@gmail.com |
5f7fafefa51420b641f61325e3976debc136f1cc | dd5832fbb4dd9ccf09f0b3baba298bed72f5965c | /Source/Overworld/OTacticalEncounterExit.h | ae2501ac4e1fa37ebb27dd900b3e3e96be65aed0 | [] | no_license | boarnoah/ue4_overworld | 2a9d780fd9008e2e381ca1ada8e5c6c2c5ce281f | d28082582ecd70c2a2ecdc81fb04aa6767a98db5 | refs/heads/master | 2023-01-13T00:11:58.585421 | 2020-11-20T04:11:18 | 2020-11-20T04:11:22 | 303,573,220 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,008 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "OTacticalEncounterExit.generated.h"
class USphereComponent;
UCLASS()
class OVERWORLD_API AOTacticalEncounterExit : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AOTacticalEncounterExit();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
private:
UPROPERTY(EditInstanceOnly, BlueprintReadOnly, Category = "Gameplay", meta = (AllowPrivateAccess = "true"))
USphereComponent* StartZone;
UPROPERTY(EditDefaultsOnly, Category = "Visual")
UStaticMeshComponent* Mesh;
UFUNCTION()
void OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult);
};
| [
"adipamihi@gmail.com"
] | adipamihi@gmail.com |
53dd2ac38b0172b0e699c7f3e41098e2ae760c54 | 2e5bc41add48073b3a6b853cc6aad02a6f30719b | /Voxels/Voxels/graphics/objects/Mesh.hpp | bd89decf523da845c240dc0edbd37050dcc50fd0 | [] | no_license | AIKO-Aaron/Voxels | f3e0cf20ac51e4ac411dfb7a08111cc8f88d267b | f4684c625799b440c8a132847387e6def94a8e4b | refs/heads/master | 2020-04-27T12:55:04.005890 | 2019-04-02T20:03:14 | 2019-04-02T20:03:14 | 174,349,049 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 389 | hpp | #pragma once
#include <vector>
#include "Object.hpp"
namespace graphics {
namespace objects {
class Mesh : public Object {
private:
public:
Mesh(Shader *shader, std::vector<physics::vec3> pointsInMesh, Material m);
inline std::vector<physics::hitboxData> getHitbox() override { return std::vector<physics::hitboxData>(); } // No hitbox (triangle is only 2D)
};
}
} | [
"aaronhodel@gmail.com"
] | aaronhodel@gmail.com |
3056cdb2387aad23482150d515327e74f5f44263 | cd9f6c860918142ed8cc87bcb766c4633cd6e6cf | /List_5/src/Genetic_Al_commands/AddItem.cpp | 61e5685afc105b59c6217212513c25a0249da380 | [] | no_license | Suqu13/ZMPO_Lab | 3ab365706059f8bc339d106a4a3ad70e9060e827 | 3b7ced6f077d73d431df425d86ec472a12803aa7 | refs/heads/master | 2020-03-31T09:48:40.037634 | 2018-12-18T16:06:23 | 2018-12-18T16:06:23 | 152,111,714 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 540 | cpp | //
// Created by Jakub on 17.12.2018.
//
#include <iostream>
#include "AddItem.h"
AddItem::AddItem(vector<CItem *> &itemVector): itemVector(itemVector){
}
void AddItem::RunCommand() {
string itemName;
int itemWeight;
int itemValue;
cout << GIVEN_NAME;
itemName = Utilities::sProvideString();
cout << GIVEN_WEIGHT;
itemWeight = Utilities::inputPositiveInt();
cout << GIVEN_VALUE;
itemValue = Utilities::inputPositiveInt();
itemVector.push_back(new CItem(itemName, itemWeight, itemValue));
}
| [
"jgarstka3@gmail.com"
] | jgarstka3@gmail.com |
2d1cf1ac1f3aa68f65fb4e04529f444a4d8e8cdd | 954d216e92924a84fbd64452680bc58517ae53e8 | /source/apps/demos/nckDemo_Shadows.cpp | f7cfe907c2098debcb733418a28bf493c813b992 | [
"MIT"
] | permissive | nczeroshift/nctoolkit | e18948691844a8657f8937d2d490eba1b522d548 | c9f0be533843d52036ec45200512ac54c1faeb11 | refs/heads/master | 2021-01-17T07:25:02.626447 | 2020-06-10T14:07:03 | 2020-06-10T14:07:03 | 47,587,062 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 7,169 | cpp |
/**
* NCtoolKit © 2007-2017 Luís F.Loureiro, under zlib software license.
* https://github.com/nczeroshift/nctoolkit
*/
#include "nckDemo_Shadows.h"
#include "nckMaterialToProgram.h"
#include <map>
#include "bxonDataIO.h"
Demo_Shadows::Demo_Shadows(Core::Window * wnd, Graph::Device * dev){
this->dev = dev;
this->wnd = wnd;
time = 0;
bufferSize = 1024;
program = NULL;
scene = NULL;
time = 0;
depth = NULL;
rtManager = NULL;
rtTexture = NULL;
display = NULL;
}
Demo_Shadows::~Demo_Shadows(){
SafeDelete(display);
SafeDelete(scene);
SafeDelete(program);
SafeDelete(depth);
SafeDelete(rtManager);
SafeDelete(rtTexture);
}
void Demo_Shadows::Load(){
dev->Enable(Graph::STATE_DEPTH_TEST);
dev->Enable(Graph::STATE_BLEND);
dev->BlendFunc(Graph::BLEND_SRC_ALPHA, Graph::BLEND_INV_SRC_ALPHA);
// 1. Create shadow buffer.
rtTexture = dynamic_cast<Graph::Texture2D*>(
dev->CreateTexture(Graph::TEXTURE_2D, bufferSize, bufferSize, 0, Graph::FORMAT_R_32F, true)
);
rtTexture->SetFilter(Graph::FILTER_MINIFICATION, Graph::FILTER_NEAREST);
rtTexture->SetFilter(Graph::FILTER_MAGNIFICATION, Graph::FILTER_NEAREST);
rtTexture->SetAdressMode(Graph::ADRESS_CLAMP);
// 2. Create render target and assign texture.
rtManager = dev->CreateRTManager(bufferSize, bufferSize);
rtManager->Attach(0, rtTexture);
// Load scene geometry and other stuff.
scene = new Scene::Compound_Base(dev);
scene->Load("model://buffer_shadows_scene.bxon");
// 3. Prepare generic material that accepts shadows.
// Wrap shadow buffer texture into a scene texture.
Scene::Texture * shadowTex = new Scene::Texture(dev);
shadowTex->SetTexture(rtTexture);
// Assign texture to a layer with shadow properties.
Scene::TextureLayer * shadowTL = new Scene::TextureLayer(dev);
shadowTL->SetTexture(shadowTex);
shadowTL->SetShadowFactor(1.0);
shadowTL->SetFactorFlag(Scene::FACTOR_SHADOW);
// Define a simple material with support to shadows.
Scene::Material diffuseSimple(dev);
diffuseSimple.SetTextureLayer(0, shadowTL);
diffuseSimple.SetUseShadows(true);
// 4. Generate necessary materials.
// Diffuse material with shadows support.
Scene::MaterialToProgram diffuseMTP(dev);
diffuseMTP.EnableShadows(true);
program = diffuseMTP.Generate(&diffuseSimple);
// Depth generation for shadow buffer
Scene::MaterialToProgram shadowMTP(dev);
shadowMTP.EnableLightDepth(true);
Scene::Material matDepth(dev);
depth = shadowMTP.Generate(&matDepth);
camera = (Scene::Camera*)scene->GetDatablock(Scene::DATABLOCK_CAMERA, "Camera");
lamp = (Scene::Lamp*)scene->GetDatablock(Scene::DATABLOCK_LAMP, "Lamp");
display = dev->LoadProgram("shader://shadow_depth_display.cpp");
}
void Demo_Shadows::Render(float dt){
CaptureLightBuffer();
std::vector<Scene::Object*> lampObjs;
scene->GetObjectsWithLayer(&lampObjs, Scene::DATABLOCK_LAMP);
dev->ClearColor(0, 0, 0, 0);
dev->Clear();
dev->Viewport(0, 0, wnd->GetWidth(), wnd->GetHeight());
dev->MatrixMode(Graph::MATRIX_PROJECTION);
dev->Identity();
camera->SetAspect(wnd->GetWidth() / (float)wnd->GetHeight());
camera->Enable(Graph::MATRIX_PROJECTION);
// View Matrix Mode
dev->MatrixMode(Graph::MATRIX_VIEW);
dev->Identity();
// Set camera properties as view matrix (rotation & position).
Math::Mat44 modelView = camera->GetMatrix();
modelView *= Math::RotateZ(time );
dev->LoadMatrix((float*)&modelView);
// Model Matrix Mode
dev->MatrixMode(Graph::MATRIX_MODEL);
dev->Identity();
dev->Enable(Graph::STATE_DEPTH_TEST);
program->Enable();
float bias = 0.0001;
Scene::LampUniforms lu;
// Set lamps ilumination.
Scene::Lamp::GenerateUniforms(lampObjs, modelView, &lu);
lu.Bind(program);
// Set shadow caster properties to shader.
Scene::Lamp::BindShadow(program, lampProjViewMat, bufferSize, bias);
Scene::Object * sphere1 = scene->GetObject("Icosphere");
Math::Vec3 pos = sphere1->GetPosition();
pos.SetZ(3.0 + 2.0 * cos(time*4.0));
sphere1->SetPosition(pos);
sphere1->Update();
rtTexture->Enable();
scene->Render();
rtTexture->Disable();
program->Disable();
for (int i = 0; i < lampObjs.size(); i++) {
Scene::Object * obj = lampObjs[i];
Math::Vec3 lampPos = obj->GetPosition();
dev->Begin(Graph::PRIMITIVE_LINES);
dev->Color(255, 255, 0);
dev->Vertex(lampPos.GetX(), lampPos.GetY(), lampPos.GetZ()-0.5);
dev->Vertex(lampPos.GetX(), lampPos.GetY(), lampPos.GetZ()+0.5);
dev->Vertex(lampPos.GetX(), lampPos.GetY()-0.5, lampPos.GetZ());
dev->Vertex(lampPos.GetX(), lampPos.GetY()+0.5, lampPos.GetZ());
dev->Vertex(lampPos.GetX()-0.5, lampPos.GetY(), lampPos.GetZ());
dev->Vertex(lampPos.GetX()+0.5, lampPos.GetY(), lampPos.GetZ());
dev->End();
}
dev->Disable(Graph::STATE_DEPTH_TEST);
dev->MatrixMode(Graph::MATRIX_PROJECTION);
dev->Identity();
dev->Ortho2D(wnd->GetWidth(), wnd->GetHeight());
dev->MatrixMode(Graph::MATRIX_VIEW);
dev->Identity();
display->Enable();
rtTexture->Enable();
RenderSquare2D(0, 0, 128, 128, Math::Color4ub());
rtTexture->Disable();
display->Disable();
dev->PresentAll();
time += 0.001;
}
void Demo_Shadows::RenderFromLight(float width, float height) {
float zNear = 0.2;
float zFar = 150.0;
dev->Enable(Graph::STATE_DEPTH_TEST);
dev->Disable(Graph::STATE_CULL_FACE);
dev->Disable(Graph::STATE_BLEND); // Avoid alpha issues.
dev->MatrixMode(Graph::MATRIX_PROJECTION);
dev->Identity();
Math::Mat44 matLampProj = Math::Perspective(width / height, 90, zNear, zFar);
dev->MultMatrix((float*)&matLampProj);
// Set the model matrix.
dev->MatrixMode(Graph::MATRIX_VIEW);
dev->Identity();
Scene::Camera lampCamp(dev);
lampCamp.SetObject(lamp->GetObject());
lampViewMat = lampCamp.GetMatrix();
dev->MultMatrix((float*)&lampViewMat);
dev->MatrixMode(Graph::MATRIX_MODEL);
dev->Identity();
lampProjViewMat = lampViewMat * matLampProj;
depth->Enable();
scene->Render();
depth->Disable();
dev->Enable(Graph::STATE_BLEND);
}
void Demo_Shadows::CaptureLightBuffer() {
rtManager->Enable();
dev->ClearColor(255, 255, 255, 255);
dev->Clear();
dev->Viewport(0, 0, rtTexture->GetWidth(), rtTexture->GetHeight());
RenderFromLight(rtTexture->GetWidth(), rtTexture->GetHeight());
rtManager->Disable();
}
void Demo_Shadows::UpdateWndEvents(){
}
std::vector<std::string> Demo_Shadows::GetKeywords() {
std::vector<std::string> ret;
ret.push_back("Advanced");
ret.push_back("Rendering");
ret.push_back("Shadows");
return ret;
}
std::string Demo_Shadows::GetDescription() {
return "Buffer Shadows";
}
Demo * CreateDemo_Shadows(Core::Window * wnd, Graph::Device * dev){
return new Demo_Shadows(wnd,dev);
}
| [
"nczeroshift.dev@gmail.com"
] | nczeroshift.dev@gmail.com |
61c7dc81c4369452d01547f33178604871b417fd | 276f0b31f669b3e1e36b7e2f332c4df86aec800d | /Mateusz Machaj Connect Four Source Code/Connect Four/Game Classes/PostGame.h | 95f84e688b7c45f2a55f02c7189dd2a59f9b96e9 | [] | no_license | mateuszmachaj/Code-Foo | c06b5c5f821ca29224fa778cf97e0ae2e44eb23d | 9b4279581f580b4b625b4cc362caf48a9e858f37 | refs/heads/master | 2021-01-13T02:29:52.554462 | 2012-05-01T04:25:10 | 2012-05-01T04:25:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | h | #include "../Framework/Graphics.h"
#include "../Framework/Input.h"
#include "../Framework/Audio.h"
#include "GameStates.h"
class PostGame
{
public:
PostGame();
void Render(int gameState);
int Update(int gameState);
bool Init();
private:
int selection;
CSound *win;
CSound *lose;
CSound *move;
bool enter;
}; | [
"mateuszmachaj@yahoo.com"
] | mateuszmachaj@yahoo.com |
632eef2d0dad716a8265b51bcd2e7eda556c37f9 | 32823147e40178e34d5e0b216189831aa19b2832 | /PracticaAlvaroPablo/Practica1/Util.cpp | a2c975c5cfc5b71a2c565bd40e3da5603f603e23 | [] | no_license | alvcuevas/vector-sorting-algorithms | 86d8fac9943efe462801d8c972c379867755c7a1 | 9f67f3f2fd840b8270ccca61f093b84c5d48fbb3 | refs/heads/master | 2021-06-05T01:24:07.771879 | 2016-06-21T13:49:03 | 2016-06-21T13:49:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,845 | cpp | /*
* File: Util.cpp
* Author: nestor
*
* Created on 26 de octubre de 2015, 20:15
*/
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <cstring>
#include <algorithm> // for std::partition
#include <functional> // for std::less
#include "Util.h"
#include "Algoritmo.h"
#include "LogCoco.h"
#include <limits>
#include <windows.h>
#include <sstream>
#include <limits>
#include <climits>
#include <time.h>
#include <ctime>
#include <cstdlib>
#include <iostream>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <fstream>
#include <streambuf>
using namespace std;
Util::Util() {
}
Util::Util(const Util& orig) {
}
Util::~Util() {
}
// Metodo de ayuda para meter tres vectores en órden en el vector dest.
void Util::appendVectors(vector<int>& dest, vector<int> less, vector<int> equal, vector<int> greater){
vector<int> result;
result.insert(result.end(),less.begin(),less.end());
result.insert(result.end(), equal.begin(), equal.end());
result.insert(result.end(), greater.begin(), greater.end());
dest.clear();
dest.insert(dest.begin(), result.begin(), result.end());
}
void Util::llena_vector_aleatorio(vector<int> &v, vector<int> &vec2, int tamano, Opciones &op){
int i, aleatorio;
cout << "\n|*** MODO ALEATORIO ***|\n" << endl;
//Se piden los elementos que tendrá el vector
cout << "¿Cuántos números quieres en tu vector?" << endl;
if(op.pasoAPaso) cout << "\n(Aviso: Estás en modo paso a paso. Te recomendamos elegir un número pequeño para seguir mejor la traza).\n";
Util::leerDeUsuario(tamano);
//Se ajusta el vector al tamaño escogido
v.resize(tamano);
vec2.resize(tamano);
//Inicio una semilla llamando a la función 'time' para generar numeros aleatorios distintos en cada petición
srand(time(NULL));
//Recorre hasta el final del tamaño deseado para ir añadiendo los números aleatorios
for (i=0; i<tamano; i++){
//Genera el número aleatorio comprendido entre 1 y 99
aleatorio = rand()%(tamano>50?tamano:100);
//Inserta dicho número en la capacidad del vector
v[i]=aleatorio;
vec2[i]=aleatorio;
}
//Muestra el vector final sin haber sido ordenado
cout << "\n¡Listo! Tu vector está formado por los siguientes aleatorios: \n" << endl;
muestra_vector(v, 0, 0);
cout << "\nPulsa enter para continuar...";
Util::pulsaEnterParacontinuar();
}
void Util::llena_vector_manual(vector<int> &v, vector<int> &vec2, int tamano){
int i, num;
cout << "\n|*** MODO MANUAL ***|\n" << endl;
//Se piden los elementos que tendrá el vector
cout << "¿Cuántos números quieres en tu vector?" << endl;
Util::leerDeUsuario(tamano);
//Se ajusta el vector al tamaño escogido
v.resize(tamano);
vec2.resize(tamano);
//Recorre hasta el final del tamaño deseado para ir agregando cada número escogido
for (i=0; i<tamano; i++){
//Pide por pantalla el número a ser insertado
cout << "¿Qué número quieres añadir al vector?" << endl;
Util::leerDeUsuario(num);
//Inserta dicho número en la capacidad del vector
v[i]=num;
vec2[i]=num;
}
//Muestra el vector final sin haber sido ordenado
cout << "¡Listo! Tu vector está formado por los siguientes: \n" << endl;
muestra_vector(v ,0 ,0);
cout << '\n';
}
// Método muestra_vector
// Este método lo usamos en varios sitios para imprimir un vector en consola.
//
// @param start: la primera posicion a imprimir.
// @param end: la última posicion a imprimir.
//
// Por defecto los valores serán 0 y por lo tanto se imprimirá todo el vector.
void Util::muestra_vector(vector<int> vec, int start, int end){
int contador = 0;
cout << "[";
//Mediante iteradores recorro el vector de principio a fin sumando posiciones
for (vector<int>::iterator it = vec.begin(); it != vec.end(); it++, contador++){
// Con este if, imprimimos solo la parte que queremos del vector (desde start hasta end)
// si las variables son distintas de 0. De lo contrario se imprime el vector entero.
if((start==0 || (start!=0 && start<=contador))
&& (end==0 || (end!=0 && end>=contador))){
//Muestro por pantalla el elemento en cada iteración
cout << vec.at(contador);
//Mientras no haya terminado el vector, imprimo una coma para separar elementos
if (it != vec.end()-1){
cout << "][";
}
}
}
cout << "]" << endl;
}
/**
* Este método se encarga de que el usuario elija el modo de relleno del array, y lo rellena.
*
* @param vec
*/
void Util::llena_vector(vector<int> &vec, vector<int> &vec2, Opciones &op){
int eleccionRelleno = 0;
int tamano;
//Inicio del menú para escoger un modo de asignar los elementos al vector
cout << "\n# ESCOGE UN MODO PARA RELLENAR TU VECTOR #" << endl;
cout << "1. Modo Manual" << endl;
cout << "2. Modo Aleatorio" << endl;
if(!op.primeraVez) cout << "3. Conservar el último vector utilizado." << endl;
while(eleccionRelleno != 1 && eleccionRelleno != 2 && eleccionRelleno != 3){
//Pide al usuario el número del modo escogido
Util::leerDeUsuario(eleccionRelleno);
//Mediante un switch se distribuye cada modo de relleno en los distintos casos
switch(eleccionRelleno){
case 1:
vec2.clear();
//Mediante el nº1 se activa el modo manual de relleno del vector
Util::llena_vector_manual(vec, vec2, tamano);
break;
case 2:
vec2.clear();
//Mediante el nº2 se activa el modo aleatorio de relleno del vector
Util::llena_vector_aleatorio(vec, vec2, tamano, op);
break;
case 3:
vec = vec2;
cout << "¡Listo! Tu vector está formado por los siguientes: \n" << endl;
muestra_vector(vec ,0 ,0);
cout << '\n';
break;
default:
//Caso genérico en el caso de no pulsar ninguno de los números correspondientes
cout << "¡¡¡No has pulsado el número adecuado para iniciar un modo!!!\nPor favor, escoge un numero de los siguientes para continuar:\n";
cout << "1. Modo Manual\n";
cout << "2. Modo Aleatorio\n";
if(!op.primeraVez) cout << "3. Conservar el último vector utilizado.\n";
Util::leerDeUsuario(eleccionRelleno);
break;
}
}
op.nElementsOriginalVector = vec.size();
}
void Util::elegirOrdenacion(vector<int> &vectorPrincipal, Opciones &op){
int eleccionOrdenacion = 0;
//Menú para escoger un modo de ordenar los elementos del vector
cout << "\n# ESCOGE UN MODO PARA ORDENAR TU VECTOR #" << endl;
cout << "1. Insertion Sort" << endl;
cout << "2. Bubble Sort" << endl;
cout << "3. Merge Sort" << endl;
cout << "4. Quick Sort" << endl;
if(op.imprimirEnArchivo) {
op.nombreArchivo = _nuevoNombreArchivo();
}
while(eleccionOrdenacion<1 || eleccionOrdenacion>4){
//Pide al usuario el número del modo escogido
Util::leerDeUsuario(eleccionOrdenacion);
cout << "\n";
if(op.mostrarAlgoritmo) LogCoco::imprimirAlgoritmoEnConsolaExterna(eleccionOrdenacion);
//Cuenta el tiempo transcurrido
clock_t cuentaTiempo;
long double duracion;
//Mediante un switch se distribuye cada modo de ordenación en los distintos casos
switch(eleccionOrdenacion){
case 1:
if(op.pasoAPaso || op.imprimirEnArchivo){
LogCoco::escribirCabeceraDeAlgoritmo(1,op,vectorPrincipal.size());
Algoritmo::insertion_sort(vectorPrincipal, op);
} else {
cuentaTiempo = clock();
Algoritmo::insertion_sort_rapido(vectorPrincipal, op);
}
cout << "||| Vector ordenado mediante Insertion Sort |||\n";
break;
case 2:
if(op.pasoAPaso || op.imprimirEnArchivo) {
LogCoco::escribirCabeceraDeAlgoritmo(2,op,vectorPrincipal.size());
Algoritmo::bubble_sort(vectorPrincipal, op);
} else {
cuentaTiempo = clock();
Algoritmo::bubble_sort_rapido(vectorPrincipal, op);
}
cout << "||| Vector ordenado mediante Bubble Sort |||\n";
break;
case 3:
if(op.pasoAPaso || op.imprimirEnArchivo) {
LogCoco::escribirCabeceraDeAlgoritmo(3,op,vectorPrincipal.size());
Algoritmo::mergesort(vectorPrincipal,0, vectorPrincipal.size()-1, op);
} else {
cuentaTiempo = clock();
Algoritmo::mergesort_rapido(vectorPrincipal,0, vectorPrincipal.size()-1, op);
}
cout << "||| Vector ordenado mediante Merge Sort |||\n";
break;
case 4:
if(op.pasoAPaso || op.imprimirEnArchivo) {
LogCoco::escribirCabeceraDeAlgoritmo(4,op,vectorPrincipal.size());
Algoritmo::quicksort(vectorPrincipal,op);
} else {
cuentaTiempo = clock();
Algoritmo::quicksort_rapido(vectorPrincipal,op);
}
cout << "||| Vector ordenado mediante Quick Sort |||\n";
break;
default:
cout << "# Has introducido un valor no válido. Inténtalo de nuevo. Las opciones son:" << endl;
cout << "1. Insertion Sort" << endl;
cout << "2. Bubble Sort" << endl;
cout << "3. Merge Sort" << endl;
cout << "4. Quick Sort" << endl;
Util::leerDeUsuario(eleccionOrdenacion);
break;
}
muestra_vector(vectorPrincipal,0,0);
cout << "\nNumero de pasos: " << op.contadorPasos << "\n";
op.contadorPasos = 0;
duracion = (clock() - cuentaTiempo) / (double) CLOCKS_PER_SEC;
if(op.mostrarTiempos) {cout << "\nTiempo transcurrido durante la ordenacion: " << duracion << "\n";}
}
}
/**
* Elegir las opciones.
*
* @param op
*/
void Util::eligeOpciones(Opciones &op){
cout << "\n# MENU DE OPCIONES DEL PROGRAMA #\n";
cout << "1. Modo paso a paso. (Actualmente " << (op.pasoAPaso?"VERDADERO":"FALSO") << ")\n";
cout << "2. Mostrar el algoritmo elegido. (Actualmente " << (op.mostrarAlgoritmo?"VERDADERO":"FALSO") << ")\n";
cout << "3. Mostrar los tiempos utilizados en ordenar cada vector. (Actualmente " << (op.mostrarTiempos?"VERDADERO":"FALSO") << ")\n";
cout << "4. Imprimir tabla en un txt. (Actualmente " << (op.imprimirEnArchivo?"VERDADERO":"FALSO") << ")\n";
cout << "5. Ayuda.\n";
cout << "6. Salir de las opciones.\n";
int c = 0;
Util::leerDeUsuario(c);
switch(c){
// Cambiar la opcion que se haya pulsado a su contrario
case 1:
op.pasoAPaso = !op.pasoAPaso;
if(op.mostrarTiempos) op.mostrarTiempos = !op.mostrarTiempos;
Util::eligeOpciones(op);
break;
case 2:
op.mostrarAlgoritmo = !op.mostrarAlgoritmo;
Util::eligeOpciones(op);
break;
case 3:
op.mostrarTiempos = !op.mostrarTiempos;
if(op.pasoAPaso) op.pasoAPaso = !op.pasoAPaso;
Util::eligeOpciones(op);
break;
case 4:
op.imprimirEnArchivo = !op.imprimirEnArchivo;
Util::eligeOpciones(op);
break;
case 5:
Util::escribirAyuda();
cout << "\nPulsa Enter para salir de la ayuda.";
Util::pulsaEnterParacontinuar();
Util::eligeOpciones(op);
break;
case 6:
break;
default:
break;
}
}
string Util::_nuevoNombreArchivo(){
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,80,"\\txts\\%Y%m%d%H%M%S.txt",timeinfo);
return Util::ExePath() + string(buffer);
}
string Util::ExePath() {
char buffer[MAX_PATH];
GetModuleFileName( NULL, buffer, MAX_PATH );
string::size_type pos = string( buffer ).find_last_of( "\\/" );
return string( buffer ).substr( 0, pos);
}
string Util::intToStr(int n){
stringstream sstm;
sstm << n;
return sstm.str();
}
string Util::vectorToStr(vector<int> n){
string output = "[";
for(int i=0; i<n.size(); i++){
output += (n[i]>9?"":" ");
output += Util::intToStr(n[i]);
if(i<n.size()-1) output += ",";
}
output += "]";
return output;
}
string Util::concatenarStrings(string n[], int size){
string output = "";
for(int i=0; i<size; i++){
output += n[i];
if(i!=size-1) output += "|";
}
return output;
}
// Guarda el contenido de cin en la variable ret. Y limpia a fondo el cin para poder seguir sin problemas
// con el programa.
void Util::leerDeUsuario(int& ret){
while(!(cin >> ret)){
cout << "\nEl valor que has introducido no es válido. Inténtalo de nuevo:\n";
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
// Lo mismo que el anterior pero con un char.
void Util::leerDeUsuario(char &ch){
ch = cin.get();
cin.clear();
cin.ignore();
}
// Espera que el usuario pulse enter para continuar. También limpia el cin.
void Util::pulsaEnterParacontinuar(){
cin.clear();
cin.ignore();
}
bool Util::ordenado(vector<int> v){
for(int i=1;i<v.size();i++){
if(v[i-1]>=v[i])
return false;
}
return true;
}
bool Util::escribirAyuda(){
ifstream t("ayuda.txt");
string str((istreambuf_iterator<char>(t)),
istreambuf_iterator<char>());
cout << str;
}
| [
"alvarucp@gmail.com"
] | alvarucp@gmail.com |
2ec2e9e54b87d32cc542067b60b93a41ca7720f4 | 02ac0e6a4026197534eb86141195fa5b12d87aa2 | /MiniProject/MiniProject/Map.h | 1e240337fa1b5b605dedb4850dad2f8cf3356906 | [] | no_license | 20142367/MiniProject | 3a8c2f3a342037fc8a2292c647c6ec2d763ce62b | d11e888ac14c88caddf77a0eb35cf1936549c032 | refs/heads/master | 2020-03-31T05:00:50.744073 | 2018-10-09T03:25:24 | 2018-10-09T03:25:24 | 151,929,567 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 340 | h | #pragma once
#include "Game.h"
class Map {
public :
Map();
~Map();
void LoadMap(int arr[20][30]);
void DrawMap();
void handleEvents();
private:
SDL_Rect src, dst;
SDL_Texture* block;
SDL_Texture* bomb;
SDL_Texture* empty;
SDL_Texture* sky;
SDL_Texture* leaf;
SDL_Texture* tree;
SDL_Texture* cloud;
int map[20][30];
}; | [
"alsrl0033@gmail.com"
] | alsrl0033@gmail.com |
3369fbecda42058dbc24826119c69f0dedf6695d | 0684ece135849d5db54bf383a2f4561f7f613a38 | /AIGames/Include/Core/vector2.h | 149335b77f131aedf9e772652cccc4b44bc5ad1d | [] | no_license | wangrui22/haze | 64c8bc4a3a0e5778443c7a4372dda2a44c30d46e | e9fdcf6bce3e57f1b259b2fb29cd7e6059cfeea4 | refs/heads/master | 2021-01-23T10:20:14.934363 | 2017-06-13T05:03:17 | 2017-06-13T05:03:17 | 93,049,815 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,393 | h | #ifndef ARITHMETIC_VECTOR2D_H_
#define ARITHMETIC_VECTOR2D_H_
#include <algorithm>
#include <iostream>
#include "Core/common.h"
class Vector2
{
public:
double x, y;
static const Vector2 S_ZERO_VECTOR;
public:
~Vector2()
{
}
Vector2() :x(0), y(0)
{
}
Vector2(double x1, double y1): x(x1), y(y1)
{
}
Vector2(const Vector2& v)
{
x = v.x;
y = v.y;
}
inline Vector2& operator += (const Vector2& v)
{
x += v.x;
y += v.y;
return *this;
}
inline Vector2 operator + (const Vector2& v) const
{
return Vector2(x + v.x, y + v.y);
}
inline Vector2& operator -= (const Vector2& v)
{
x -= v.x;
y -= v.y;
return *this;
}
inline Vector2 operator - (const Vector2& v) const
{
return Vector2(x - v.x, y - v.y);
}
inline Vector2 operator - () const
{
return Vector2(-x, -y);
}
inline Vector2& operator *= (double scale)
{
x *= scale;
y *= scale;
return *this;
}
inline Vector2 operator * (double scale) const
{
return Vector2(x * scale, y * scale);
}
inline bool operator != (const Vector2& v) const
{
return (std::fabs(x - v.x) > DOUBLE_EPSILON ||
std::fabs(y - v.y) > DOUBLE_EPSILON);
}
inline bool operator == (const Vector2& v) const
{
return (std::fabs(x - v.x) < DOUBLE_EPSILON &&
std::fabs(y - v.y) < DOUBLE_EPSILON);
}
inline Vector2& operator = (const Vector2& v)
{
x = v.x;
y = v.y;
return *this;
}
inline double angle_between(const Vector2& v) const
{
double len = magnitude() * v.magnitude();
len = (len > DOUBLE_EPSILON) ? len : DOUBLE_EPSILON;
double dot = dot_product(v) / len;
dot = (std::min)(dot, 1.0);
dot = (std::max)(dot, -1.0);
return std::acos(dot);
}
inline double dot_product(const Vector2& v) const
{
return x * v.x + y * v.y;
}
inline double magnitude() const
{
return std::sqrt(x * x + y * y);
}
inline void normalize()
{
double len = std::sqrt(x * x + y * y);
if (len < DOUBLE_EPSILON)
{
return;
}
double leninv = 1.0 / len;
x *= leninv;
y *= leninv;
}
Vector2 get_normalize() const
{
double len = std::sqrt(x * x + y * y);
if (len < DOUBLE_EPSILON)
{
return *this;
}
double leninv = 1.0 / len;
return Vector2(x * leninv, y * leninv);
}
bool parallel(const Vector2& v) const
{
return std::fabs(this->dot_product(v) - this->magnitude()*v.magnitude()) < DOUBLE_EPSILON;
}
bool orthogonal(const Vector2& v) const
{
return std::fabs(this->dot_product(v)) < DOUBLE_EPSILON;
}
void print()
{
std::cout <<"( "<<x << " , "<<y << " ) ";
}
};
Vector2 operator *(double scale, const Vector2& v);
double angle_between(const Vector2& v1, const Vector2& v2);
Vector2 cross(const Vector2& v1, const Vector2& v2);
double dot_product(const Vector2& v1, const Vector2& v2);
bool parallel(const Vector2& v1, const Vector2& v2);
bool orthogonal(const Vector2& v1, const Vector2& v2);
#endif | [
"worry_wang@163.com"
] | worry_wang@163.com |
5134f068866b99b9a17a10ab9c3fd5a499b8a10f | 070ce743a5bb01852fb3f79ba07a20091157e630 | /code/src/align/src/otherProjects/MPS3_fusion/utils/reformatMPS2AnnotatedFusionResults.cpp | c2ff7c651b4a4e49d41aab1898c3bfc7abcce6c4 | [] | no_license | LiuBioinfo/iMapSplice | f4d641ade9aa882cb4cdec5efd3d21daea83b2ae | ecf2b1b79014e8a5f3ba8ee19ce5aa833ac292dd | refs/heads/master | 2020-03-22T00:06:42.136338 | 2019-02-08T04:17:05 | 2019-02-08T04:17:05 | 139,225,150 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,287 | cpp | // This file is a part of iMapSplice. Please refer to LICENSE.TXT for the LICENSE
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <malloc.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <stack>
#include <vector>
#include <hash_map>
#include <map>
#include <set>
#include "../../../general/index_info.h"
using namespace std;
int main(int argc, char** argv)
{
if(argc != 3)
{
cout << "Executable inputMPS2AnnotatedFusionResults outputReformatedFusionfile" << endl;
exit(1);
}
string inputFilePath = argv[1];
string outputFilePath = argv[2];
ifstream MPS2fusion_ifs(inputFilePath.c_str());
ofstream reformatedFusion_ofs(outputFilePath.c_str());
while(!MPS2fusion_ifs.eof())
{
string tmpStr;
getline(MPS2fusion_ifs, tmpStr);
if((MPS2fusion_ifs.eof())||(tmpStr == ""))
break;
vector<string> fusionFieldVec;
int startLoc = 0;
for(int tmp = 0; ; tmp++)
{
int tabLoc = tmpStr.find("\t", startLoc);
if(tabLoc != string::npos)
{
string tmpFieldStr = tmpStr.substr(startLoc, tabLoc-startLoc);
fusionFieldVec.push_back(tmpFieldStr);
startLoc = tabLoc + 1;
}
else
break;
}
fusionFieldVec.push_back(tmpStr.substr(startLoc));
string tmpChrInfoStr = fusionFieldVec[0];
string tmpStartPosStr = fusionFieldVec[1];
string tmpEndPosStr = fusionFieldVec[2];
string tmpJuncIdStr = fusionFieldVec[3];
string tmpSupNumStr = fusionFieldVec[4];
string tmpStrandStr = fusionFieldVec[5];
string tmpFlankStringStr = fusionFieldVec[12];
string tmpGeneNameStr_1 = fusionFieldVec[fusionFieldVec.size()-3];
string tmpGeneNameStr_2 = fusionFieldVec[fusionFieldVec.size()-2];
int tlideLoc = tmpChrInfoStr.find("~");
string tmpChrName_1 = tmpChrInfoStr.substr(0, tlideLoc);
string tmpChrName_2 = tmpChrInfoStr.substr(tlideLoc+1);
string tmpStrand_1 = tmpStrandStr.substr(0,1);
string tmpStrand_2 = tmpStrandStr.substr(1,1);
reformatedFusion_ofs << tmpChrName_1 << "\t" << tmpChrName_2 << "\t"
<< tmpStartPosStr << "\t" << tmpEndPosStr << "\t"
<< tmpStrand_1 << "\t" << tmpStrand_2 << "\t" << tmpFlankStringStr << "\t"
<< tmpSupNumStr << "\t" << tmpGeneNameStr_1 << "\t" << tmpGeneNameStr_2 << endl;
}
MPS2fusion_ifs.close();
reformatedFusion_ofs.close();
return 0;
} | [
"Jinze.liu@uky.edu"
] | Jinze.liu@uky.edu |
26a9a3f75264fe451e4a8fd863401137e0a26802 | e80e05e7be0837e209a569e06f5d02a90b8a8fbf | /variable_argument.cpp | 17476171b7f602015e60acfccee95554faf27289 | [] | no_license | cmsun/examination-questions | 460897e24fd36c79f5627d19fd073bff441013e2 | e00013a0655f4ff050626aa1b0eba7ae558f7a79 | refs/heads/master | 2020-06-25T17:17:47.947242 | 2018-04-24T14:53:43 | 2018-04-24T14:53:43 | 96,978,762 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 486 | cpp | #include <stdio.h>
void show(const char *format, ...)
{
char **pfmt = (char **)&format;
long long *a = (long long *)(pfmt + 1);
long long *b = a + 1;
long long *c = b + 1;
double *f = (double *)(c + 1);
printf("%d, %d, %d, %lf\n", *a, *b, *c, *f);
}
int main(void)
{
char a = 8;
char b = 9;
float f = 1.2;
char c = 2;
show("%d, %d, %d, %f\n", a, b, c, f);
printf("%d\n", (10 & ~11));
fflush(stdout);
getchar();
return 0;
}
| [
"351721714@qq.com"
] | 351721714@qq.com |
5644919764470fa7fec339f15e249c85420e9f35 | 8b42d17832e469e75c58ce73fb2cd65cac562614 | /Training/1010/A/1.cpp | 3536495efe2360aad079a95929069b98ca61c15f | [] | no_license | wu-qing-157/Aerial-Ace | c7948a6fb683cabc9b5258f2c35d1a36ee90880c | a0ac172dffae0edf92d427d70989ba016e6944d4 | refs/heads/master | 2020-06-20T06:03:21.143666 | 2019-11-30T14:15:48 | 2019-11-30T14:15:48 | 197,018,034 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,830 | cpp | #include <cstdio>
#include <algorithm>
#include <unordered_map>
struct point {
int x, y;
point() {}
point(int x, int y) : x(x), y(y) {}
friend point operator-(const point &a, const point &b) {
return point(a.x - b.x, a.y - b.y);
}
point pure() const {
int gcd = std::__gcd(x, y);
return point(x / gcd, y / gcd);
}
point rotate90() const {
return point(-y, x);
}
point rotate270() const {
return point(y, -x);
}
friend bool operator==(const point &a, const point &b) {
return a.x == b.x && a.y == b.y;
}
};
struct hash_point {
size_t operator()(const point &a) const {
return (a.x << 16) ^ (a.x >> 16) ^ a.y;
}
};
const int N = 2e3 + 10;
int n, p;
int64_t ans[N];
point an[N], ap[N];
std::unordered_map<point, int, hash_point> map;
int main() {
while (scanf("%d%d", &n, &p) != EOF) {
for (int i = 1; i <= n; i++) scanf("%d%d", &an[i].x, &an[i].y);
for (int i = 1; i <= p; i++) scanf("%d%d", &ap[i].x, &ap[i].y);
for (int i = 1; i <= p; i++) ans[i] = 0;
for (int i = 1; i <= p; i++) {
map.clear();
for (int j = 1; j <= n; j++)
map[(an[j] - ap[i]).pure()]++;
for (int j = 1; j <= n; j++)
ans[i] += map[(an[j] - ap[i]).pure().rotate90()];
}
for (int i = 1; i <= n; i++) {
map.clear();
for (int j = 1; j <= n; j++) if (i != j)
map[(an[j] - an[i]).pure()]++;
for (int j = 1; j <= p; j++) {
ans[j] += map[(ap[j] - an[i]).pure().rotate90()];
ans[j] += map[(ap[j] - an[i]).pure().rotate270()];
}
}
for (int i = 1; i <= p; i++)
printf("%lld\n", ans[i]);
}
return 0;
}
| [
"wuqing157@gmail.com"
] | wuqing157@gmail.com |
e5614563a5a03e4bf442e2b51bfa5faa0524ea5d | ab90a6a4f7bb63d2d19eba4644e4910ccafbfcbe | /pub/1038.cpp | 4db0e3c35b9530066ec8db1c6de0b47197c0f6e4 | [
"MIT"
] | permissive | BashuMiddleSchool/Bashu_OnlineJudge_Code | cf35625b5dcb2d53044581f57f1ff50221b33d2a | 4707a271e6658158a1910b0e6e27c75f96841aca | refs/heads/main | 2023-04-22T08:12:41.235203 | 2021-05-02T15:22:25 | 2021-05-02T15:22:25 | 363,435,161 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 313 | cpp | #include<iostream>
#include<iomanip>
using namespace std;
int main()
{ double x,sum=0,minn=1000000000,maxn=-1000000000;
for(int i=1;i<=10;i++)
{
cin>>x;
sum+=x;
if(x<minn) minn=x;
if(x>maxn) maxn=x;
}
cout<<fixed<<setprecision(2)<<(sum-maxn-minn)/8;
return 0;
} | [
"60656888+ELEVENStudio-Main@users.noreply.github.com"
] | 60656888+ELEVENStudio-Main@users.noreply.github.com |
7b8911e7a30e1081860042c8a91f6b82822a3383 | 010dfe6ba48f6798f2376c9b3b1cef162fee0ae1 | /p2.cpp | b7d6c4c3263366c4592aab01159ba38fe981ab70 | [
"MIT"
] | permissive | vladutmargineanu/Graphs | 1c02967c93fa700828f13cd8a247fd3b905dc888 | 2d5fc20a94d1e6f9a434b0c0d2821e9dbab2dcaf | refs/heads/master | 2021-01-04T12:28:32.196010 | 2020-02-14T16:40:07 | 2020-02-14T16:40:07 | 240,550,374 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,194 | cpp | #include <queue>
#include <vector>
#include <string>
#include <fstream>
#include <stack>
using namespace std;
ifstream fin("p2.in");
ofstream fout("p2.out");
const int dim = 105;
const int dimM = 1e6 + 3;
int n, m, k;
int v[dim][dim];
pair<int, int> stiva[dimM];
int varf = 0;
int vi[dim][dim];
constexpr int u[4] = {1, 0, -1, 0};
constexpr int l[4] = {0, 1, 0, -1};
int solve(int i, int j, int z) {
vi[i][j] = z;
varf = 0;
stiva[varf] = {i, j};
varf++;
int r = 1;
while(varf) {
pair<int, int> p = stiva[varf - 1];
varf--;
for(int t = 3; t >= 0; t--) {
int x = p.first + u[t];
int y = p.second + l[t];
if(x == -1 || y == -1 || x == n
|| y == m || vi[x][y] == z) {
continue;
}
if(v[x][y] > v[i][j] ||
v[x][y] < v[i][j] - k) {
continue;
}
vi[x][y] = z;
stiva[varf] = {x, y};
varf++;
r++;
}
}
return r;
}
void read() {
fin >> n >> m >> k;
for(int i = 0; i < n * m; i++) {
int x;
fin >> x;
v[i / m][i % m] = x;
}
}
int main() {
read();
int r = 0;
int z = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
r = max(r, solve(i, j, ++z));
}
}
fout << r << endl;
fout.close();
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
fc8f1b33235ca748a090ff8cc00f19fb11a4edb7 | 2e359b413caee4746e931e01807c279eeea18dca | /630. Course Schedule III/greedy.cpp | 03fa965c87c09e50f8d1f6f5a9522c031e74b96d | [] | no_license | fsq/leetcode | 3a8826a11df21f8675ad1df3632d74bbbd758b71 | 70ea4138caaa48cc99bb6e6436afa8bcce370db3 | refs/heads/master | 2023-09-01T20:30:51.433499 | 2023-08-31T03:12:30 | 2023-08-31T03:12:30 | 117,914,925 | 7 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 1,004 | cpp | class Solution {
public:
// https://leetcode.com/problems/course-schedule-iii/description/
// O(nlogn) greedy algorithm
// sort ascendingly ordered by close day
// add each course to the set if possible
// else swap with the course which has longest duration
static bool cmp(const vector<int>& a, const vector<int>& b) {
return a[1] < b[1];
}
int scheduleCourse(vector<vector<int>>& courses) {
sort(courses.begin(), courses.end(), cmp);
int end=0;
priority_queue<int> durations;
for (auto &course : courses)
if (end+course[0]<=course[1]) {
end += course[0];
durations.push(course[0]);
} else if (!durations.empty() && course[0]<durations.top()) {
end += course[0];
durations.push(course[0]);
end -= durations.top();
durations.pop();
}
return durations.size();
}
}; | [
"fengsq@utexas.edu"
] | fengsq@utexas.edu |
d8ce8bcd5a6c3fa592e374cc0545663fead8521f | fefd234e516c9dd9add7bcd4091cfbb215169e85 | /sketches/AutoLightsAndTurn/Arduino_sketch.ino | bdb985882d2c95030bafc5d5b0a18aa50c1ee6b7 | [
"MIT"
] | permissive | sergesyrota/arduino-projects | 57b74d0b3cbf9cd0e2abe5feff552d593fd8db5e | 1501cfaf0fad6b11b58c0debb37b88ccddeb14dd | refs/heads/master | 2021-06-04T05:46:20.073931 | 2019-02-14T03:57:27 | 2019-02-14T03:57:27 | 11,562,988 | 0 | 1 | null | 2016-03-16T20:59:58 | 2013-07-21T14:43:38 | Eagle | UTF-8 | C++ | false | false | 675 | ino | #include <OneTouchLaneChange.h>
#include <AutoHeadlights.h>
// Initializing auto headlights class.
// A3 is the input pin of the sensor
// Digital pin 6 is the one that control the headlights.
AutoHeadlights headlight = AutoHeadlights(A3, 6);
OneTouchLaneChange lane = OneTouchLaneChange();
void setup() {
// Set thresholds for on and off readings
headlight.setSensorThreshold(300, 500);
// Override default delay, 5 sec should be better.
headlight.switchDelay = 5000;
// Configuration for lane change module
// input and output pins respectively
lane.addPair(8,9);
lane.addPair(7,10);
}
void loop() {
lane.run();
headlight.run();
delay(50);
}
| [
"github@syrota.com"
] | github@syrota.com |
5ae41c41768a364afd902f1d45bd72778fb56b05 | cf8ddfc720bf6451c4ef4fa01684327431db1919 | /SDK/ARKSurvivalEvolved_SM_AdobeWindowWall_BP_structs.hpp | 73ca9db21af0f170b03a97a9b77b4c446d137b18 | [
"MIT"
] | permissive | git-Charlie/ARK-SDK | 75337684b11e7b9f668da1f15e8054052a3b600f | c38ca9925309516b2093ad8c3a70ed9489e1d573 | refs/heads/master | 2023-06-20T06:30:33.550123 | 2021-07-11T13:41:45 | 2021-07-11T13:41:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 259 | hpp | #pragma once
// ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_Basic.hpp"
#include "ARKSurvivalEvolved_WindowWall_Metal_classes.hpp"
namespace sdk
{
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"sergey.2bite@gmail.com"
] | sergey.2bite@gmail.com |
01b0cf9dde3636b426f7dc06fdff582a9dc9a0f5 | af69e335fc0ff9632964d061833713b672abad01 | /Temp/StagingArea/Data/il2cppOutput/mscorlib_System_Collections_Generic_List_1_gen852832060.h | 14c2f4265783d214d72efe464c6baa449bd09e9c | [] | no_license | PruthvishMShirur/Solar-System | ca143ab38cef582705f0beb76f7fef8b28e25ef9 | 5cf3eaa66949801aa9a34cd3cf80eeefa64d2342 | refs/heads/master | 2023-05-26T17:53:37.489349 | 2021-06-16T19:56:48 | 2021-06-16T19:56:48 | 377,611,177 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,625 | h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "mscorlib_System_Object3080106164.h"
// System.Security.Policy.StrongName[]
struct StrongNameU5BU5D_t1449304291;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Collections.Generic.List`1<System.Security.Policy.StrongName>
struct List_1_t852832060 : public Il2CppObject
{
public:
// T[] System.Collections.Generic.List`1::_items
StrongNameU5BU5D_t1449304291* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t852832060, ____items_1)); }
inline StrongNameU5BU5D_t1449304291* get__items_1() const { return ____items_1; }
inline StrongNameU5BU5D_t1449304291** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(StrongNameU5BU5D_t1449304291* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier(&____items_1, value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t852832060, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t852832060, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
};
struct List_1_t852832060_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::EmptyArray
StrongNameU5BU5D_t1449304291* ___EmptyArray_4;
public:
inline static int32_t get_offset_of_EmptyArray_4() { return static_cast<int32_t>(offsetof(List_1_t852832060_StaticFields, ___EmptyArray_4)); }
inline StrongNameU5BU5D_t1449304291* get_EmptyArray_4() const { return ___EmptyArray_4; }
inline StrongNameU5BU5D_t1449304291** get_address_of_EmptyArray_4() { return &___EmptyArray_4; }
inline void set_EmptyArray_4(StrongNameU5BU5D_t1449304291* value)
{
___EmptyArray_4 = value;
Il2CppCodeGenWriteBarrier(&___EmptyArray_4, value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"42893637+PruthvishMShirur@users.noreply.github.com"
] | 42893637+PruthvishMShirur@users.noreply.github.com |
a97485bcbbb15b72c648cf79757a6ecb1b8b2604 | 5b8b03fe46e83f8d800516afbf7f3faf112ee5d4 | /data-structures/linked-lists/insert-a-node-into-a-sorted-doubly-linked-list/main.cpp | fb3cf1587c10cff8d1cdbf6201884374940e1673 | [] | no_license | sammyne/hacker-rank | 0142e50add45a0d9ec79b1fee1447f009d803594 | 7d7f62a64dc9e25d6a0e17648440c64844fa2c42 | refs/heads/master | 2021-09-20T15:19:07.268056 | 2018-08-11T05:53:03 | 2018-08-11T05:53:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 850 | cpp | #include <iostream>
/*
Insert Node in a doubly sorted linked list
After each insertion, the list should be sorted
Node is defined as
*/
struct Node {
int data;
Node *next;
Node *prev;
};
Node *SortedInsert(Node *head, int data) {
// Complete this function
// Do not write the main method.
Node *ptr = head, *prev = NULL;
// find the 1st node larger than/equal to data
while (ptr && (ptr->data < data)) {
prev = ptr;
ptr = ptr->next;
}
auto node_new = new Node;
node_new->data = data;
node_new->prev = prev;
node_new->next = ptr;
if (prev) {
prev->next = node_new;
} else {
head = node_new;
}
if (ptr) {
ptr->prev = node_new;
}
return head;
}
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
} | [
"xiangminli@sjtu.edu.cn"
] | xiangminli@sjtu.edu.cn |
f7f8d20843713f27bd81929c960c38a89d8355fa | 8192e49ac36c575d1347a949ec5338ce17ceafe5 | /1232 - Coin Change (II).cpp | 686a9fdaa5112609e29307eec2d8ed3455bac3ba | [] | no_license | Sarwar05/LightOJ | 35647f85d28b6763f6db85d89364302ff29e69fa | 327f14148b56e3cb5f26a0f5bf55f25700646f74 | refs/heads/master | 2021-06-08T11:08:44.281667 | 2020-08-14T13:07:07 | 2020-08-14T13:07:07 | 88,619,739 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 616 | cpp | #include<bits/stdc++.h>
using namespace std;
#define mod 100000007
int dp[10005];
int coin[105];
int k, n;
int main()
{
int tc, cs=1;
scanf("%d",&tc);
while(tc--){
memset(dp, 0, sizeof dp);
scanf("%d%d", &n, &k);
for(int i=1; i<=n; i++){
scanf("%d", &coin[i]);
}
dp[0] = 1;
for(int i=1; i<=n; i++){
for(int j=1; j<=k; j++){
if(coin[i]<=j)
dp[j] = (dp[j] + dp[j-coin[i]])%mod;
}
}
printf("Case %d: %d\n", cs++, dp[k]);
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
261df21c4cf8b4d90382e4acc272f96df0550c24 | af59b1ee3b7d3493ec632b9d204cfb3cd8e16b26 | /class/libdate/date.h | 766073570962b1e18f5ee0889e5444a9c7fb04a5 | [] | no_license | spbirhade/CPP | 766221af1bd3dcf148570d6ca92b9feb1b79cfd3 | 87ef2d0b4aaf9ea4cb7aad0a6c61df5f57ac670e | refs/heads/master | 2021-01-20T08:25:10.659375 | 2017-08-29T06:28:40 | 2017-08-29T06:28:40 | 101,556,911 | 0 | 0 | null | 2017-08-29T06:28:41 | 2017-08-27T14:14:17 | C++ | UTF-8 | C++ | false | false | 254 | h | #ifndef DATE
#define DATE
class Date
{
private:
int day, month, year;
public:
Date();
void set_day(int day);
void set_month(int month);
void set_year(int year);
int get_day(void);
int get_month(void);
int get_year(void);
};
#endif
| [
"spbirhade@gmail.com"
] | spbirhade@gmail.com |
2c5a6f98477aa60ca12fb810533b7c98b70331aa | 55264dd0dcbc2aaf52a7a918a5366f3cfae455b8 | /test22.cpp | 4c510caa1e73e119b37964ad647627e2fea93a38 | [] | no_license | Teemperor/lldb-fuzz | d4279d3929f3c483e51953a700df0939ff051e06 | 56ff6b592fe3d8e36246425a1ca1212e03fc9472 | refs/heads/master | 2020-12-08T13:57:43.408581 | 2020-11-08T15:37:40 | 2020-11-08T15:37:40 | 233,000,386 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 709 | cpp | #include <vector>
#include <algorithm>
#include <iostream>
struct Sum
{
Sum(): sum{0} { }
void operator()(int n) { sum += n; }
int sum;
};
int main()
{
std::vector<int> nums{3, 4, 2, 8, 15, 267};
auto print = [](const int& n) { std::cout << " " << n; };
std::cout << "before:";
std::for_each(nums.begin(), nums.end(), print);
std::cout << '\n';
std::for_each(nums.begin(), nums.end(), [](int &n){ n++; });
// calls Sum::operator() for each number
Sum s = std::for_each(nums.begin(), nums.end(), Sum());
std::cout << "after: ";
std::for_each(nums.begin(), nums.end(), print);
std::cout << '\n';
std::cout << "sum: " << s.sum << '\n';
}
| [
"risemann@apple.com"
] | risemann@apple.com |
b4ba32eaf9439a078d89117c19254eef9aa8a069 | 6aea36556b958a83579c00afdcd2f301d37631ab | /Include/WAVM/VFS/VFS.h | 9181139a083bf17710fbeb6713b4b8a7b8c4c5ec | [
"BSD-3-Clause"
] | permissive | UESTC-LXY/wasm-jit-prototype | 1f30c4b2d39999dac6a85e463b32b95da4e0c799 | 65ca25f8e6578ffc3bcf09c10c80af4f1ba443b2 | refs/heads/master | 2022-02-26T05:59:36.243133 | 2019-10-15T12:10:21 | 2019-10-15T12:10:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,243 | h | #pragma once
#include <string>
#include "WAVM/Inline/BasicTypes.h"
#include "WAVM/Inline/Time.h"
namespace WAVM { namespace VFS {
enum class FileAccessMode
{
none,
readOnly,
writeOnly,
readWrite,
};
enum class FileCreateMode
{
createAlways,
createNew,
openAlways,
openExisting,
truncateExisting,
};
enum class SeekOrigin
{
begin,
cur,
end
};
enum class SyncType
{
contents,
contentsAndMetadata
};
enum class FileType
{
unknown,
blockDevice,
characterDevice,
directory,
file,
datagramSocket,
streamSocket,
symbolicLink,
pipe
};
enum class VFDSync
{
none,
contentsAfterWrite,
contentsAndMetadataAfterWrite,
contentsAfterWriteAndBeforeRead,
contentsAndMetadataAfterWriteAndBeforeRead
};
struct VFDFlags
{
// If true, writes will always occur at the end of the file.
bool append{false};
// If true, reads and writes will fail if they can't immediately complete.
bool nonBlocking{false};
// The amount of synchronization implied for reads and writes.
VFDSync syncLevel{VFDSync::none};
};
struct VFDInfo
{
FileType type;
VFDFlags flags;
};
struct FileInfo
{
U64 deviceNumber;
U64 fileNumber;
FileType type;
U32 numLinks;
U64 numBytes;
// Time values correspond to the "real-time" clock defined by Platform::Clock::realtime.
Time lastAccessTime;
Time lastWriteTime;
Time creationTime;
};
struct DirEnt
{
U64 fileNumber;
std::string name;
FileType type;
};
struct IOReadBuffer
{
void* data;
Uptr numBytes;
};
struct IOWriteBuffer
{
const void* data;
Uptr numBytes;
};
// Error codes
// clang-format off
#define WAVM_ENUM_VFS_RESULTS(v) \
v(success, "Success") \
/* Asynchronous I/O statuses */ \
v(ioPending, "IO pending") \
/* Hardware errors */ \
v(ioDeviceError, "IO device error") \
/* Transient errors */ \
v(interruptedBySignal, "Interrupted by signal") \
v(interruptedByCancellation, "Interrupted by cancellation") \
v(wouldBlock, "Operation on non-blocking file descriptor would block") \
/* Invalid argument errors */ \
v(inaccessibleBuffer, "A provided buffer is in memory that is not accessible") \
v(invalidOffset, "Invalid offset") \
/* Capability errors */ \
v(notSeekable, "File descriptor is not seekable") \
v(notPermitted, "Not permitted") \
v(notAccessible, "Not accessible") \
v(notSynchronizable,"File descriptor is not synchronizable") \
/* Argument constraints */ \
v(tooManyBufferBytes, "Too many bytes") \
v(notEnoughBufferBytes, "Not enough bytes") \
v(tooManyBuffers, "Too many buffers") \
v(notEnoughBits, "Not enough bits") \
v(exceededFileSizeLimit, "File is too large") \
/* Resource exhaustion errors */ \
v(outOfSystemFDs, "Out of system file descriptors") \
v(outOfProcessFDs, "Out of process file descriptors") \
v(outOfMemory, "Out of memory") \
v(outOfQuota, "Out of quota") \
v(outOfFreeSpace, "Out of free space") \
v(outOfLinksToParentDir, "Out of links to parent directory") \
/* Path errors */ \
v(invalidNameCharacter, "Invalid filename character") \
v(nameTooLong, "Filename is too long") \
v(tooManyLinksInPath, "Path follows too many links") \
/* File state errors */ \
v(alreadyExists, "Already exists") \
v(doesNotExist, "Doesn't exist") \
v(isDirectory, "Is a directory") \
v(isNotDirectory, "Isn't a directory") \
v(isNotEmpty, "Directory isn't empty") \
v(brokenPipe, "Pipe is broken") \
v(missingDevice, "Device is missing") \
v(busy, "Device or resource busy")
enum class Result : I32
{
#define V(name, description) name,
WAVM_ENUM_VFS_RESULTS(V)
#undef V
};
// clang-format on
struct DirEntStream
{
virtual ~DirEntStream() {}
virtual void close() = 0;
virtual bool getNext(DirEnt& outEntry) = 0;
virtual void restart() = 0;
virtual U64 tell() = 0;
virtual bool seek(U64 offset) = 0;
};
struct VFD
{
// Closes the FD. Deletes the VFD regardless of whether an error code is returned.
virtual Result close() = 0;
virtual Result seek(I64 offset, SeekOrigin origin, U64* outAbsoluteOffset = nullptr) = 0;
virtual Result readv(const IOReadBuffer* buffers,
Uptr numBuffers,
Uptr* outNumBytesRead = nullptr,
const U64* offset = nullptr)
= 0;
virtual Result writev(const IOWriteBuffer* buffers,
Uptr numBuffers,
Uptr* outNumBytesWritten = nullptr,
const U64* offset = nullptr)
= 0;
virtual Result sync(SyncType type) = 0;
virtual Result getVFDInfo(VFDInfo& outInfo) = 0;
virtual Result getFileInfo(FileInfo& outInfo) = 0;
virtual Result setVFDFlags(const VFDFlags& flags) = 0;
virtual Result setFileSize(U64 numBytes) = 0;
virtual Result setFileTimes(bool setLastAccessTime,
Time lastAccessTime,
bool setLastWriteTime,
Time lastWriteTime)
= 0;
virtual Result openDir(DirEntStream*& outStream) = 0;
Result read(void* outData,
Uptr numBytes,
Uptr* outNumBytesRead = nullptr,
U64* offset = nullptr)
{
IOReadBuffer buffer{outData, numBytes};
return readv(&buffer, 1, outNumBytesRead, offset);
}
Result write(const void* data,
Uptr numBytes,
Uptr* outNumBytesWritten = nullptr,
U64* offset = nullptr)
{
IOWriteBuffer buffer{data, numBytes};
return writev(&buffer, 1, outNumBytesWritten, offset);
}
protected:
virtual ~VFD() {}
};
struct FileSystem
{
virtual ~FileSystem() {}
virtual Result open(const std::string& path,
FileAccessMode accessMode,
FileCreateMode createMode,
VFD*& outFD,
const VFDFlags& flags = VFDFlags{})
= 0;
virtual Result getFileInfo(const std::string& path, FileInfo& outInfo) = 0;
virtual Result setFileTimes(const std::string& path,
bool setLastAccessTime,
Time lastAccessTime,
bool setLastWriteTime,
Time lastWriteTime)
= 0;
virtual Result openDir(const std::string& path, DirEntStream*& outStream) = 0;
virtual Result unlinkFile(const std::string& path) = 0;
virtual Result removeDir(const std::string& path) = 0;
virtual Result createDir(const std::string& path) = 0;
};
WAVM_API const char* describeResult(Result result);
}}
| [
"andrew@scheidecker.net"
] | andrew@scheidecker.net |
0483fd1a92b47f9b6129aa85791b6b19a473135a | 75908712aee18165b79b9c6562fd590e46ea95d1 | /OOP - Initial Prototype/ProfileMenu.h | e2f3f15d605ed39bc6a4b7d737ae8b81c2c1289c | [] | no_license | Nathansykes/OOP-Project-Steam | db0b53697395c109468182d454a6f8e4bd5aacac | acfeec0c7a2dc453b73755ddd76eec2a14dc4a62 | refs/heads/master | 2023-07-18T07:53:02.904784 | 2021-08-23T19:15:56 | 2021-08-23T19:15:56 | 399,204,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 376 | h | #pragma once
#include <vector>
#include <algorithm>
#include "Menu.h"
#include "DeleteUserMenu.h"
#include "AddGuestGamesMenu.h"
#include "GameMenu.h"
#include "User.h"
#include "Utils.h"
class ProfileMenu : public Menu
{
public:
ProfileMenu(const std::string& title, Application* app);
void OutputOptions() final;
bool HandleChoice(const char choice) final;
private:
};
| [
"nathan.sykes1@hotmail.com"
] | nathan.sykes1@hotmail.com |
ea6fa47f77a726c53357249ff0fba24063c0b2aa | 16f85e641b0a77138c887cae01e2821894be6dac | /plug/third_party/nana/include/nana/paint/graphics.hpp | a194aa7ecbd59f51d9fd52d393a6e50ebe6044ac | [] | no_license | a397871706/plug | 16eb8b3962330c8ded82bba500896ee428d62586 | dbdbf30697a86c76fb6258c967ce1df5c5cb612b | refs/heads/master | 2022-10-29T03:29:15.299302 | 2016-07-19T11:00:21 | 2016-07-19T11:00:21 | 54,470,214 | 0 | 1 | null | 2022-10-21T09:37:24 | 2016-03-22T11:37:48 | C++ | UTF-8 | C++ | false | false | 8,163 | hpp | /*
* Paint Graphics Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
*
* 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)
*
* @file: nana/paint/graphics.hpp
*/
#ifndef NANA_PAINT_GRAPHICS_HPP
#define NANA_PAINT_GRAPHICS_HPP
#include "../basic_types.hpp"
#include "../gui/basis.hpp"
#include "pixel_buffer.hpp"
#include <memory>
namespace nana
{
namespace paint
{
namespace detail
{
struct native_font_signature;
}// end namespace detail
typedef detail::native_font_signature* native_font_type;
class font
{
friend class graphics;
public:
font();
font(drawable_type);
font(const font&);
font(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
~font();
bool empty() const;
void make(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
void make_raw(const char_t*, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
void set_default() const;
::nana::string name() const;
unsigned size() const;
bool bold() const;
unsigned height() const;
unsigned weight() const;
bool italic() const;
native_font_type handle() const;
void release();
font& operator=(const font&);
bool operator==(const font&) const;
bool operator!=(const font&) const;
private:
struct impl_type;
impl_type * impl_;
};
/// \brief off-screen resource defined as ref-counting, can refer one resource
///
/// Load a bitmap into a graphics:
/// \code
/// nana::paint::graphics graph;
/// nana::paint::image img("C:\\ABitmap.bmp");
/// img.paste(graph, 0, 0); //graph may create if it is empty
/// \endcode
class graphics
{
public:
typedef ::nana::native_window_type native_window_type;
graphics();
graphics(const ::nana::size&); ///< size in pixel
graphics(const graphics&); ///< the resource is not copyed, the two graphics objects refer to the *SAME* resource
graphics& operator=(const graphics&);
bool changed() const; ///< Returns true if the graphics object is operated
bool empty() const; ///< Returns true if the graphics object does not refer to any resource.
operator const void*() const;
drawable_type handle() const;
const void* pixmap() const;
const void* context() const;
void make(const ::nana::size&); ///< Creates a bitmap resource that size is width by height in pixel
void resize(const ::nana::size&);
void typeface(const font&); ///< Selects a specified font type into the graphics object.
font typeface() const;
::nana::size text_extent_size(const char_t*) const; ///< Computes the width and height of the specified string of text.
::nana::size text_extent_size(const string&) const; ///< Computes the width and height of the specified string of text.
::nana::size text_extent_size(const char_t*, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
::nana::size text_extent_size(const string&, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
::nana::size glyph_extent_size(const char_t*, std::size_t length, std::size_t begin, std::size_t end) const;
::nana::size glyph_extent_size(const string&, std::size_t length, std::size_t begin, std::size_t end) const;
bool glyph_pixels(const char_t *, std::size_t length, unsigned* pxbuf) const;
::nana::size bidi_extent_size(const std::wstring&) const;
::nana::size bidi_extent_size(const std::string&) const;
bool text_metrics(unsigned & ascent, unsigned& descent, unsigned& internal_leading) const;
void line_begin(int x, int y);
void bitblt(int x, int y, const graphics& source); ///< Transfers the source to the specified point.
void bitblt(const ::nana::rectangle& r_dst, native_window_type src); ///< Transfers the color data corresponding to r_dst from the src window to this graphics.
void bitblt(const ::nana::rectangle& r_dst, native_window_type src, const point& p_src); ///< Transfers the color data corresponding to r_dst from the src window at point p_src to this graphics.
void bitblt(const ::nana::rectangle& r_dst, const graphics& src); ///< Transfers the color data corresponding to r_dst from the src graphics to this graphics.
void bitblt(const ::nana::rectangle& r_dst, const graphics& src, const point& p_src);///< Transfers the color data corresponding to r_dst from the src graphics at point p_src to this graphics.
void blend(const ::nana::rectangle& s_r, graphics& dst, const point& d_pos, double fade_rate) const;///< blends with the dst object.
void blur(const ::nana::rectangle& r, std::size_t radius); ///< Blur process.
void paste(graphics& dst, int x, int y) const; ///< Paste the graphics object into the dest at (x, y)
void paste(native_window_type dst, const ::nana::rectangle&, int sx, int sy) const; ///< Paste the graphics object into a platform-dependent window at (x, y)
void paste(native_window_type dst, int dx, int dy, unsigned width, unsigned height, int sx, int sy) const;
void paste(drawable_type dst, int x, int y) const;
void paste(const ::nana::rectangle& r_src, graphics& dst, int x, int y) const;
void rgb_to_wb(); ///< Transform a color graphics into black&white.
void stretch(const ::nana::rectangle& src_r, graphics& dst, const ::nana::rectangle& r) const;
void stretch(graphics& dst, const ::nana::rectangle&) const;
void flush();
unsigned width() const;
unsigned height() const; ///< Returns the height of the off-screen buffer.
::nana::size size() const;
void setsta(); ///< Clears the status if the graphics object had been changed
void set_changed();
void release();
/// Saves images as a windows bitmap file
/// @param file_utf8 A UTF-8 string to a filename
void save_as_file(const char* file_utf8) const throw();
void set_color(const ::nana::color&); //deprecated, graphics::palette() instead
void set_text_color(const ::nana::color&); //deprecated, graphics::palette() instead
::nana::color palette(bool for_text) const;
graphics& palette(bool for_text, const ::nana::color&);
unsigned bidi_string(const nana::point&, const char_t *, std::size_t len);
unsigned bidi_string(const point& pos, const char*, std::size_t len);
void blend(const ::nana::rectangle& r, const ::nana::color&, double fade_rate);
void set_pixel(int x, int y, const ::nana::color&);
void set_pixel(int x, int y);
void string(point, const char_t*, std::size_t len);
void string(const point&, const char_t*);
void string(const point&, const ::nana::string&);
void string(const point&, const ::nana::string&, const color&);
void line(const point&, const point&);
void line(const point&, const point&, const color&);
void line_to(const point&, const color&);
void line_to(const point&);
void rectangle(bool solid);
void rectangle(bool solid, const color&);
void rectangle(const ::nana::rectangle&, bool solid);
void rectangle(const ::nana::rectangle&, bool solid, const color&);
void frame_rectangle(const ::nana::rectangle&, const color& left, const color& top, const color& right, const color& bottom);
void gradual_rectangle(const ::nana::rectangle&, const color& from, const color& to, bool vertical);
void round_rectangle(const ::nana::rectangle&, unsigned radius_x, unsigned radius_y, const color&, bool solid, const color& color_if_solid);
private:
std::shared_ptr< ::nana::detail::drawable_impl_type> dwptr_;
font font_shadow_;
drawable_type handle_;
::nana::size size_;
pixel_buffer pxbuf_;
bool changed_;
};
}//end namespace paint
} //end namespace nana
#endif
| [
"xulijun@kugou.net"
] | xulijun@kugou.net |
34eb33d197bb45ee8a0fe849d24a92f38bb253d8 | 52efda246a526dbd63d6128cb32360e9c6044f5b | /201811050947/text2链表.cpp | e3236708cbc5a5aa0221db719a5aff7a02161fca | [] | no_license | northand-south/tongxin181-1-sis | 76f50ea2b632e29eba91e3478c45a98d9feafa6b | b2ac3431c41d3fc99895f2e5f3381c1fe22cae0e | refs/heads/main | 2023-02-12T09:29:33.138491 | 2021-01-05T18:15:39 | 2021-01-05T18:15:39 | 327,005,389 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,653 | cpp | #include <iostream>
#include <stdlib.h>
using namespace std;
struct num
{
int number;
struct num *next;
};
int SelectMonkey(int m,int n);
int main()
{
int m,n;
cout<<"依次输入猴子数量m报数大小n:";
cin>>m>>n;
cout<<"按照"<<m<<"个猴子,每数到第"<<n<<"个数的方法,输出为大王的猴子是"<<SelectMonkey(m,n);
return 0;
}
int SelectMonkey(int m,int n)
{
struct num *p,*p1,*head,*temp;
int i=0,flag;
p=(struct num*)malloc(sizeof(struct num));
head=p;
if(n==1)
return m;
while(i<m)
{
p1=p;
p->number=i+1;
p=(struct num*)malloc(sizeof(struct num));
p1->next=p;
i++;
}
p1->next=NULL; //形成单向链表
p=head;
i=0;
flag=0;
while(i!=m-1)
{
if(flag==n-1)
{
if(p==head) //当删除的节点位于节点头时
{
head=head->next;
p=head;
}
else if(p->next==NULL) //当初节点位于节点尾时
{
temp->next=NULL;
p=head;
}
else //位于中间
{
temp->next=p->next;
p=p->next;
}
i++;
flag=0;
}
//当指针到达链表尾部时,使其指向头指针。
if(p->next==NULL)
{
p=head;
}
else
{
temp=p;
p=p->next;
}
flag++;
}
return head->number;
} | [
"noreply@github.com"
] | noreply@github.com |
c6d7ebb2c12eb8ea957a15bcdf19d352e110ed60 | 27c51e217d679e79f5771ba8d7c8b00d6b7cf234 | /ModelLoading/include/loaders/texture_loader.h | a4927acd36910133f1a26384ba8721a9948b371a | [] | no_license | niki4etoo/3D_OpenGL_Effects | d3dd984276b876deba7b30b00dd216f8df4ce6df | 03def883ebf23f77fbf179da4910ba2857060c2b | refs/heads/main | 2023-05-07T08:28:27.075863 | 2021-05-30T19:47:36 | 2021-05-30T19:47:36 | 327,902,361 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 998 | h | //Texture loader
class TextureLoader {
std::string filepath_name;
int width, height, nrChannels;
public:
TextureLoader(std::string filepath_name, unsigned int &texture)
{
// Textures
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
// set the texture wrapping/filtering options (on the currently bound texture object)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
int width, height, nrChannels;
unsigned char *data = stbi_load(filepath_name.c_str(), &width, &height, &nrChannels, 0);
if(data)
{
glGenerateMipmap(GL_TEXTURE_2D);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
}
else
{
std::cout << "Error: cannot load file" << std::endl;
}
stbi_image_free(data);
}
};
| [
"niki4etooo@gmail.com"
] | niki4etooo@gmail.com |
17b2888e7942aacb9f91a14536dd5b5bd9fb40f6 | 2ba94892764a44d9c07f0f549f79f9f9dc272151 | /Engine/Source/Editor/LevelEditor/Private/LevelViewportLayoutFourPanes.cpp | 11a3c8155d47759c20b745bb9c07e75f54a736a5 | [
"BSD-2-Clause",
"LicenseRef-scancode-proprietary-license"
] | permissive | PopCap/GameIdea | 934769eeb91f9637f5bf205d88b13ff1fc9ae8fd | 201e1df50b2bc99afc079ce326aa0a44b178a391 | refs/heads/master | 2021-01-25T00:11:38.709772 | 2018-09-11T03:38:56 | 2018-09-11T03:38:56 | 37,818,708 | 0 | 0 | BSD-2-Clause | 2018-09-11T03:39:05 | 2015-06-21T17:36:44 | null | UTF-8 | C++ | false | false | 13,881 | cpp | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "LevelEditor.h"
#include "LevelViewportLayoutFourPanes.h"
#include "SLevelViewport.h"
namespace ViewportLayoutFourPanesDefs
{
/** Default main splitter to equal 50/50 split */
static const float DefaultPrimarySplitterPercentage = 0.5f;
/** Default secondary splitter to equal three-way split */
static const float DefaultSecondarySplitterPercentage = 0.333f;
}
// FLevelViewportLayoutFourPanes /////////////////////////////
TSharedRef<SWidget> FLevelViewportLayoutFourPanes::MakeViewportLayout(const FString& LayoutString)
{
FString SpecificLayoutString = GetTypeSpecificLayoutString(LayoutString);
FString ViewportKey0, ViewportKey1, ViewportKey2, ViewportKey3;
float PrimarySplitterPercentage = ViewportLayoutFourPanesDefs::DefaultPrimarySplitterPercentage;
float SecondarySplitterPercentage0 = ViewportLayoutFourPanesDefs::DefaultSecondarySplitterPercentage;
float SecondarySplitterPercentage1 = ViewportLayoutFourPanesDefs::DefaultSecondarySplitterPercentage;
if (!SpecificLayoutString.IsEmpty())
{
// The Layout String only holds the unique ID of the Additional Layout Configs to use
const FString& IniSection = FLayoutSaveRestore::GetAdditionalLayoutConfigIni();
ViewportKey0 = SpecificLayoutString + TEXT(".Viewport0");
ViewportKey1 = SpecificLayoutString + TEXT(".Viewport1");
ViewportKey2 = SpecificLayoutString + TEXT(".Viewport2");
ViewportKey3 = SpecificLayoutString + TEXT(".Viewport3");
FString PercentageString;
if(GConfig->GetString(*IniSection, *(SpecificLayoutString + TEXT(".Percentage0")), PercentageString, GEditorPerProjectIni))
{
TTypeFromString<float>::FromString(PrimarySplitterPercentage, *PercentageString);
}
if(GConfig->GetString(*IniSection, *(SpecificLayoutString + TEXT(".Percentage1")), PercentageString, GEditorPerProjectIni))
{
TTypeFromString<float>::FromString(SecondarySplitterPercentage0, *PercentageString);
}
if(GConfig->GetString(*IniSection, *(SpecificLayoutString + TEXT(".Percentage2")), PercentageString, GEditorPerProjectIni))
{
TTypeFromString<float>::FromString(SecondarySplitterPercentage1, *PercentageString);
}
}
TSharedRef<SWidget> LayoutWidget = MakeFourPanelWidget(
Viewports,
ViewportKey0, ViewportKey1, ViewportKey2, ViewportKey3,
PrimarySplitterPercentage, SecondarySplitterPercentage0, SecondarySplitterPercentage1);
InitCommonLayoutFromString(SpecificLayoutString);
return LayoutWidget;
}
void FLevelViewportLayoutFourPanes::SaveLayoutString(const FString& LayoutString) const
{
if (!bIsTransitioning)
{
FString SpecificLayoutString = GetTypeSpecificLayoutString(LayoutString);
const FString& IniSection = FLayoutSaveRestore::GetAdditionalLayoutConfigIni();
check (PrimarySplitterWidget->GetChildren()->Num() == 2);
float PrimaryPercentage = PrimarySplitterWidget->SlotAt(0).SizeValue.Get();
check (SecondarySplitterWidget->GetChildren()->Num() == 3);
float SecondaryPercentage0 = SecondarySplitterWidget->SlotAt(0).SizeValue.Get();
float SecondaryPercentage1 = SecondarySplitterWidget->SlotAt(1).SizeValue.Get();
GConfig->SetString(*IniSection, *(SpecificLayoutString + TEXT(".Percentage0")), *TTypeToString<float>::ToString(PrimaryPercentage), GEditorPerProjectIni);
GConfig->SetString(*IniSection, *(SpecificLayoutString + TEXT(".Percentage1")), *TTypeToString<float>::ToString(SecondaryPercentage0), GEditorPerProjectIni);
GConfig->SetString(*IniSection, *(SpecificLayoutString + TEXT(".Percentage2")), *TTypeToString<float>::ToString(SecondaryPercentage1), GEditorPerProjectIni);
SaveCommonLayoutString(SpecificLayoutString);
}
}
void FLevelViewportLayoutFourPanes::ReplaceWidget( TSharedRef< SWidget > Source, TSharedRef< SWidget > Replacement )
{
bool bWasFound = false;
for (int32 SlotIdx = 0; SlotIdx < PrimarySplitterWidget->GetChildren()->Num(); SlotIdx++)
{
if (PrimarySplitterWidget->GetChildren()->GetChildAt(SlotIdx) == Source)
{
PrimarySplitterWidget->SlotAt(SlotIdx)
[
Replacement
];
bWasFound = true;
break;
}
}
for (int32 SlotIdx = 0; SlotIdx < SecondarySplitterWidget->GetChildren()->Num(); SlotIdx++)
{
if (SecondarySplitterWidget->GetChildren()->GetChildAt(SlotIdx) == Source)
{
SecondarySplitterWidget->SlotAt(SlotIdx)
[
Replacement
];
bWasFound = true;
break;
}
}
// Source widget should have already been a content widget for the splitter
check( bWasFound );
}
// FLevelViewportLayoutFourPanesLeft /////////////////////////////
TSharedRef<SWidget> FLevelViewportLayoutFourPanesLeft::MakeFourPanelWidget(
TArray<TSharedPtr< SLevelViewport >>& ViewportWidgets,
const FString& ViewportKey0, const FString& ViewportKey1, const FString& ViewportKey2, const FString& ViewportKey3,
float PrimarySplitterPercentage, float SecondarySplitterPercentage0, float SecondarySplitterPercentage1)
{
TSharedPtr< SLevelViewport > ViewportWidget0;
TSharedPtr< SLevelViewport > ViewportWidget1;
TSharedPtr< SLevelViewport > ViewportWidget2;
TSharedPtr< SLevelViewport > ViewportWidget3;
TSharedRef<SWidget> Widget =
SAssignNew( PrimarySplitterWidget, SSplitter )
.Orientation(EOrientation::Orient_Horizontal)
+SSplitter::Slot()
.Value(PrimarySplitterPercentage)
[
SAssignNew( ViewportWidget0, SLevelViewport )
.ViewportType( LVT_Perspective )
.Realtime( true )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey0 )
]
+SSplitter::Slot()
.Value(1.0f - PrimarySplitterPercentage)
[
SAssignNew( SecondarySplitterWidget, SSplitter )
.Orientation(EOrientation::Orient_Vertical)
+SSplitter::Slot()
.Value(SecondarySplitterPercentage0)
[
SAssignNew( ViewportWidget1, SLevelViewport )
.ViewportType( LVT_OrthoXY )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey1 )
]
+SSplitter::Slot()
.Value(SecondarySplitterPercentage1)
[
SAssignNew( ViewportWidget2, SLevelViewport )
.ViewportType( LVT_OrthoXZ )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey2 )
]
+SSplitter::Slot()
.Value(1.0f - SecondarySplitterPercentage0 - SecondarySplitterPercentage1)
[
SAssignNew( ViewportWidget3, SLevelViewport )
.ViewportType( LVT_OrthoYZ )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey3 )
]
];
ViewportWidgets.Add( ViewportWidget0 );
ViewportWidgets.Add( ViewportWidget1 );
ViewportWidgets.Add( ViewportWidget2 );
ViewportWidgets.Add( ViewportWidget3 );
// Make newly-created perspective viewports active by default
GCurrentLevelEditingViewportClient = &ViewportWidget0->GetLevelViewportClient();
return Widget;
}
// FLevelViewportLayoutFourPanesRight /////////////////////////////
TSharedRef<SWidget> FLevelViewportLayoutFourPanesRight::MakeFourPanelWidget(
TArray<TSharedPtr< SLevelViewport >>& ViewportWidgets,
const FString& ViewportKey0, const FString& ViewportKey1, const FString& ViewportKey2, const FString& ViewportKey3,
float PrimarySplitterPercentage, float SecondarySplitterPercentage0, float SecondarySplitterPercentage1)
{
TSharedPtr< SLevelViewport > ViewportWidget0;
TSharedPtr< SLevelViewport > ViewportWidget1;
TSharedPtr< SLevelViewport > ViewportWidget2;
TSharedPtr< SLevelViewport > ViewportWidget3;
TSharedRef<SWidget> Widget =
SAssignNew( PrimarySplitterWidget, SSplitter )
.Orientation(EOrientation::Orient_Horizontal)
+SSplitter::Slot()
.Value(PrimarySplitterPercentage)
[
SAssignNew( SecondarySplitterWidget, SSplitter )
.Orientation(EOrientation::Orient_Vertical)
+SSplitter::Slot()
.Value(SecondarySplitterPercentage0)
[
SAssignNew( ViewportWidget1, SLevelViewport )
.ViewportType( LVT_OrthoXY )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey1 )
]
+SSplitter::Slot()
.Value(SecondarySplitterPercentage1)
[
SAssignNew( ViewportWidget2, SLevelViewport )
.ViewportType( LVT_OrthoXZ )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey2 )
]
+SSplitter::Slot()
.Value(1.0f - SecondarySplitterPercentage0 - SecondarySplitterPercentage1)
[
SAssignNew( ViewportWidget3, SLevelViewport )
.ViewportType( LVT_OrthoYZ )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey3 )
]
]
+SSplitter::Slot()
.Value(1.0f - PrimarySplitterPercentage)
[
SAssignNew( ViewportWidget0, SLevelViewport )
.ViewportType( LVT_Perspective )
.Realtime( true )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey0 )
];
ViewportWidgets.Add( ViewportWidget0 );
ViewportWidgets.Add( ViewportWidget1 );
ViewportWidgets.Add( ViewportWidget2 );
ViewportWidgets.Add( ViewportWidget3 );
// Make newly-created perspective viewports active by default
GCurrentLevelEditingViewportClient = &ViewportWidget0->GetLevelViewportClient();
return Widget;
}
// FLevelViewportLayoutFourPanesTop /////////////////////////////
TSharedRef<SWidget> FLevelViewportLayoutFourPanesTop::MakeFourPanelWidget(
TArray<TSharedPtr< SLevelViewport >>& ViewportWidgets,
const FString& ViewportKey0, const FString& ViewportKey1, const FString& ViewportKey2, const FString& ViewportKey3,
float PrimarySplitterPercentage, float SecondarySplitterPercentage0, float SecondarySplitterPercentage1)
{
TSharedPtr< SLevelViewport > ViewportWidget0;
TSharedPtr< SLevelViewport > ViewportWidget1;
TSharedPtr< SLevelViewport > ViewportWidget2;
TSharedPtr< SLevelViewport > ViewportWidget3;
TSharedRef<SWidget> Widget =
SAssignNew( PrimarySplitterWidget, SSplitter )
.Orientation(EOrientation::Orient_Vertical)
+SSplitter::Slot()
.Value(PrimarySplitterPercentage)
[
SAssignNew( ViewportWidget0, SLevelViewport )
.ViewportType( LVT_Perspective )
.Realtime( true )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey0 )
]
+SSplitter::Slot()
.Value(1.0f - PrimarySplitterPercentage)
[
SAssignNew( SecondarySplitterWidget, SSplitter )
.Orientation(EOrientation::Orient_Horizontal)
+SSplitter::Slot()
.Value(SecondarySplitterPercentage0)
[
SAssignNew( ViewportWidget1, SLevelViewport )
.ViewportType( LVT_OrthoXY )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey1 )
]
+SSplitter::Slot()
.Value(SecondarySplitterPercentage1)
[
SAssignNew( ViewportWidget2, SLevelViewport )
.ViewportType( LVT_OrthoXZ )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey2 )
]
+SSplitter::Slot()
.Value(1.0f - SecondarySplitterPercentage0 - SecondarySplitterPercentage1)
[
SAssignNew( ViewportWidget3, SLevelViewport )
.ViewportType( LVT_OrthoYZ )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey3 )
]
];
ViewportWidgets.Add( ViewportWidget0 );
ViewportWidgets.Add( ViewportWidget1 );
ViewportWidgets.Add( ViewportWidget2 );
ViewportWidgets.Add( ViewportWidget3 );
// Make newly-created perspective viewports active by default
GCurrentLevelEditingViewportClient = &ViewportWidget0->GetLevelViewportClient();
return Widget;
}
// FLevelViewportLayoutFourPanesBottom /////////////////////////////
TSharedRef<SWidget> FLevelViewportLayoutFourPanesBottom::MakeFourPanelWidget(
TArray<TSharedPtr< SLevelViewport >>& ViewportWidgets,
const FString& ViewportKey0, const FString& ViewportKey1, const FString& ViewportKey2, const FString& ViewportKey3,
float PrimarySplitterPercentage, float SecondarySplitterPercentage0, float SecondarySplitterPercentage1)
{
TSharedPtr< SLevelViewport > ViewportWidget0;
TSharedPtr< SLevelViewport > ViewportWidget1;
TSharedPtr< SLevelViewport > ViewportWidget2;
TSharedPtr< SLevelViewport > ViewportWidget3;
TSharedRef<SWidget> Widget =
SAssignNew( PrimarySplitterWidget, SSplitter )
.Orientation(EOrientation::Orient_Vertical)
+SSplitter::Slot()
.Value(PrimarySplitterPercentage)
[
SAssignNew( SecondarySplitterWidget, SSplitter )
.Orientation(EOrientation::Orient_Horizontal)
+SSplitter::Slot()
.Value(SecondarySplitterPercentage0)
[
SAssignNew( ViewportWidget1, SLevelViewport )
.ViewportType( LVT_OrthoXY )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey1 )
]
+SSplitter::Slot()
.Value(SecondarySplitterPercentage1)
[
SAssignNew( ViewportWidget2, SLevelViewport )
.ViewportType( LVT_OrthoXZ )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey2 )
]
+SSplitter::Slot()
.Value(1.0f - SecondarySplitterPercentage0 - SecondarySplitterPercentage1)
[
SAssignNew( ViewportWidget3, SLevelViewport )
.ViewportType( LVT_OrthoYZ )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey3 )
]
]
+SSplitter::Slot()
.Value(1.0f - PrimarySplitterPercentage)
[
SAssignNew( ViewportWidget0, SLevelViewport )
.ViewportType( LVT_Perspective )
.Realtime( true )
.ParentLayout( AsShared() )
.ParentLevelEditor( ParentLevelEditor )
.ConfigKey( ViewportKey0 )
];
ViewportWidgets.Add( ViewportWidget0 );
ViewportWidgets.Add( ViewportWidget1 );
ViewportWidgets.Add( ViewportWidget2 );
ViewportWidgets.Add( ViewportWidget3 );
// Make newly-created perspective viewports active by default
GCurrentLevelEditingViewportClient = &ViewportWidget0->GetLevelViewportClient();
return Widget;
}
| [
"dkroell@acm.org"
] | dkroell@acm.org |
97138dbbb5eb1a89197179a137aa06656e220d30 | ba23f7d006377df5c14ce8c9451f066c0b1aba60 | /1931.cpp | d93a9f628544ebade82eebf1218eb9be10d207b8 | [] | no_license | holicAZ/AlgorithmStudy | 89a1ad5b95e85f582e0124c130c1a1e88ac73eb9 | 8259d60f5ced234d6170b720790e6854a5cc6b63 | refs/heads/master | 2023-03-23T13:51:11.467640 | 2021-03-24T14:22:58 | 2021-03-24T14:22:58 | 278,343,793 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 888 | cpp | #include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
vector<pii> v;
bool compare(pii a, pii b) {
if (a.second == b.second) {
return a.first < b.first;
}
else {
return a.second < b.second;
}
}
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,cnt=1;
cin >> n;
while (n--) {
int s, e;
cin >> s >> e;
v.push_back({ s,e });
}
sort(v.begin(), v.end(), compare); // 종료시간 second 값을 먼저 비교해서 작은 값부터 오름차순 동일하면 시작시간 빠른 순
int e1 = v[0].second; // 첫 강의 종료 시간
for (int i = 1; i < v.size(); i++) {
if (e1 <= v[i].first) { // 다음 강의의 시작시간이 앞 강의의 종료시간 보다 뒤면 카운팅
e1 = v[i].second;
cnt++;
}
}
cout << cnt;
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
fe4ac7021faf553d9fbdbc3e54e49b46b81694aa | fca768a2ae424b436fadf529733bd2de317d2398 | /CPPQTDatabaseTest/GeneratedFiles/ui_CustomerWindow.h | d59aa40232cc501e44ca417e41aea73277d29a8a | [] | no_license | DodgeeSoftware/CPPQTDatabaseTest | 98b255c50f01e7cb292ce3bc266242c1ccfa519a | d671b236423ea508100166255e2790da98fd4ff8 | refs/heads/master | 2021-09-20T02:33:49.051487 | 2018-08-02T09:25:29 | 2018-08-02T09:25:29 | 139,801,065 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,318 | h | /********************************************************************************
** Form generated from reading UI file 'CustomerWindow.ui'
**
** Created by: Qt User Interface Compiler version 5.11.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_CUSTOMERWINDOW_H
#define UI_CUSTOMERWINDOW_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_CustomerWindowClass
{
public:
QWidget *centralwidget;
QPushButton *DoneButton;
QLabel *TitleLabel;
QLabel *IDLabel;
QLabel *GivenNamesLabel;
QLabel *LastNameLabel;
QLineEdit *TitleTextBox;
QLineEdit *IDTextBox;
QLineEdit *GivenNamesTextBox;
QLineEdit *LastNameTextBox;
void setupUi(QMainWindow *CustomerWindowClass)
{
if (CustomerWindowClass->objectName().isEmpty())
CustomerWindowClass->setObjectName(QStringLiteral("CustomerWindowClass"));
CustomerWindowClass->setWindowModality(Qt::ApplicationModal);
CustomerWindowClass->resize(217, 160);
CustomerWindowClass->setMinimumSize(QSize(217, 160));
CustomerWindowClass->setMaximumSize(QSize(217, 160));
centralwidget = new QWidget(CustomerWindowClass);
centralwidget->setObjectName(QStringLiteral("centralwidget"));
DoneButton = new QPushButton(centralwidget);
DoneButton->setObjectName(QStringLiteral("DoneButton"));
DoneButton->setGeometry(QRect(10, 130, 191, 23));
TitleLabel = new QLabel(centralwidget);
TitleLabel->setObjectName(QStringLiteral("TitleLabel"));
TitleLabel->setGeometry(QRect(10, 40, 47, 13));
IDLabel = new QLabel(centralwidget);
IDLabel->setObjectName(QStringLiteral("IDLabel"));
IDLabel->setGeometry(QRect(10, 10, 47, 13));
GivenNamesLabel = new QLabel(centralwidget);
GivenNamesLabel->setObjectName(QStringLiteral("GivenNamesLabel"));
GivenNamesLabel->setGeometry(QRect(10, 70, 61, 16));
LastNameLabel = new QLabel(centralwidget);
LastNameLabel->setObjectName(QStringLiteral("LastNameLabel"));
LastNameLabel->setGeometry(QRect(10, 100, 51, 16));
TitleTextBox = new QLineEdit(centralwidget);
TitleTextBox->setObjectName(QStringLiteral("TitleTextBox"));
TitleTextBox->setGeometry(QRect(90, 40, 113, 20));
TitleTextBox->setReadOnly(true);
IDTextBox = new QLineEdit(centralwidget);
IDTextBox->setObjectName(QStringLiteral("IDTextBox"));
IDTextBox->setGeometry(QRect(90, 10, 113, 20));
IDTextBox->setReadOnly(true);
GivenNamesTextBox = new QLineEdit(centralwidget);
GivenNamesTextBox->setObjectName(QStringLiteral("GivenNamesTextBox"));
GivenNamesTextBox->setGeometry(QRect(90, 70, 113, 20));
LastNameTextBox = new QLineEdit(centralwidget);
LastNameTextBox->setObjectName(QStringLiteral("LastNameTextBox"));
LastNameTextBox->setGeometry(QRect(90, 100, 113, 20));
LastNameTextBox->setReadOnly(true);
CustomerWindowClass->setCentralWidget(centralwidget);
retranslateUi(CustomerWindowClass);
QMetaObject::connectSlotsByName(CustomerWindowClass);
} // setupUi
void retranslateUi(QMainWindow *CustomerWindowClass)
{
CustomerWindowClass->setWindowTitle(QApplication::translate("CustomerWindowClass", "Customer", nullptr));
DoneButton->setText(QApplication::translate("CustomerWindowClass", "Done", nullptr));
TitleLabel->setText(QApplication::translate("CustomerWindowClass", "Title", nullptr));
IDLabel->setText(QApplication::translate("CustomerWindowClass", "ID", nullptr));
GivenNamesLabel->setText(QApplication::translate("CustomerWindowClass", "Given Names", nullptr));
LastNameLabel->setText(QApplication::translate("CustomerWindowClass", "Last Name", nullptr));
} // retranslateUi
};
namespace Ui {
class CustomerWindowClass: public Ui_CustomerWindowClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_CUSTOMERWINDOW_H
| [
"sergeant.neipo@gmail.com"
] | sergeant.neipo@gmail.com |
be8f4df39ff6dae851cedc4c2e739b01a323eedf | 5941ed638e984e906754595398170535b9844b9c | /Cube.cpp | 3be2920f8f07c99630e2c9e92969181d3716df56 | [] | no_license | ssoreide/carthingy | 0cdac82e7230cbce5bf676adedecf30001fe20d7 | 08b07a9ba6a38c6e3ff87a902c29904a86fd7b54 | refs/heads/master | 2020-04-13T11:38:47.033854 | 2019-01-09T12:55:06 | 2019-01-09T12:55:06 | 163,179,766 | 0 | 0 | null | null | null | null | IBM852 | C++ | false | false | 2,071 | cpp | #include "Cube.h"
#include "TextureManager.h"
#include <iostream>
#include <glm/gtc/type_ptr.hpp>
Cube::Cube()
{
}
void Cube::Draw() {
DrawChildren();
UpdateMaterial();
glPushMatrix();
glMultMatrixf(glm::value_ptr(getTransformMatrix()));
// glMaterialfv(GL_FRONT, GL_DIFFUSE, glm::value_ptr(glm::vec3(1, 0, 0)));
// glMaterialfv(GL_FRONT, GL_SPECULAR, glm::value_ptr(glm::vec3(0, 1, 0)));
// glMaterialfv(GL_FRONT, GL_EMISSION, glm::value_ptr(glm::vec3(0, 0, 1)));
glBegin(GL_QUADS);
// Front Rectangle
glNormal3f(0.0, 0.0, 1.0);
glTexCoord2d(0, 0); glVertex3f(-0.5, -0.5, 0.5); // Nede, venstre
glTexCoord2d(1, 0); glVertex3f(0.5, -0.5, 0.5); // nede, h°yre
glTexCoord2d(1, 1); glVertex3f(0.5, 0.5, 0.5); // oppe, h°yre
glTexCoord2d(0, 1); glVertex3f(-0.5, 0.5, 0.5); // oppe, venstre
// Right Rectangle
glNormal3f(1.0, 0.0, 0.0);
glTexCoord2d(0, 0); glVertex3f(0.5, -0.5, -0.5);
glTexCoord2d(1, 0); glVertex3f(0.5, 0.5, -0.5);
glTexCoord2d(1, 1); glVertex3f(0.5, 0.5, 0.5);
glTexCoord2d(0, 1); glVertex3f(0.5, -0.5, 0.5);
// Left Rectangle
glNormal3f(-1.0, 0.0, 0.0);
glTexCoord2d(0, 0); glVertex3f(-0.5, -0.5, 0.5);
glTexCoord2d(1, 0); glVertex3f(-0.5, 0.5, 0.5);
glTexCoord2d(1, 1); glVertex3f(-0.5, 0.5, -0.5);
glTexCoord2d(0, 1); glVertex3f(-0.5, -0.5, -0.5);
// Back Rectangle
glNormal3f(0.0, 0.0, -1.0);
glTexCoord2d(0, 0); glVertex3f(-0.5, -0.5, -0.5);
glTexCoord2d(1, 0); glVertex3f(-0.5, 0.5, -0.5);
glTexCoord2d(1, 1); glVertex3f(0.5, 0.5, -0.5);
glTexCoord2d(0, 1); glVertex3f(0.5, -0.5, -0.5);
// Top Rectangle
glNormal3f(0.0, 1.0, 0.0);
glTexCoord2d(0, 0); glVertex3f(0.5, 0.5, 0.5);
glTexCoord2d(1, 0); glVertex3f(0.5, 0.5, -0.5);
glTexCoord2d(1, 1); glVertex3f(-0.5, 0.5, -0.5);
glTexCoord2d(0, 1); glVertex3f(-0.5, 0.5, 0.5);
// Bottom Rectangle
glNormal3f(0.0, -1.0, 0.0);
glTexCoord2d(0, 0); glVertex3f(0.5, -0.5, -0.5);
glTexCoord2d(1, 0); glVertex3f(0.5, -0.5, 0.5);
glTexCoord2d(1, 1); glVertex3f(-0.5, -0.5, 0.5);
glTexCoord2d(0, 1); glVertex3f(-0.5, -0.5, -0.5);
glEnd();
glPopMatrix();
} | [
"steinar.soreide@mediability.com"
] | steinar.soreide@mediability.com |
95c11d93111f42af6c1883aa34c1e63f2376fa64 | ee9c8980a23ee83d35ee868f9ef004abd3c361cd | /Vehicles/Vehicles/Car.hpp | 7c7a9fd34fef4499ee75d60dee8e7209065f8b23 | [] | no_license | BillC13/VehiclesFinal | 77d594341dc28a12199eafae7bd771edb90de770 | f5648d7579f801b32a62e3d588ffedbd7ea31a0f | refs/heads/master | 2023-07-15T15:32:02.570802 | 2021-08-26T08:25:26 | 2021-08-26T08:25:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 412 | hpp | #pragma once
#include "I_Vehicle.hpp"
namespace Vehicles
{
class Car : public I_Vehicle
{
public:
Car(std::string, int, double); // prototype for declaring cars (notice names for the parameters are optional here)
~Car(); // I'll also provide a destructor for when we dont need the car any more.
std::string VehicleReport(); // VehicleReport required by I_Vehicle
void SetNumDoors(int);
};
}
| [
"bill_carter@hotmail.co.uk"
] | bill_carter@hotmail.co.uk |
23f42cf872c1087428dd3538cd91afd73fd2dc51 | 4cc7fe346ff204986881c282362464c13cdac76d | /DATE.CPP | db196c80f5db372a8d962c4dcacc58b3ce550f48 | [] | no_license | vsaini1m/c-_programs | 8ed563faf89498cb64b1caf7ddc2173683d13233 | 6d044b6f67e8872707377a8a2d7af3dffd760958 | refs/heads/master | 2023-03-20T06:12:53.604857 | 2019-09-03T15:55:31 | 2019-09-03T15:55:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 213 | cpp | #include<iostream>
#include<ctime>
using namespace std;
int main(){
time_t t=time(0);
struct tm*now=localtime(&t);
cout<<"date is:";
cout<<now->tm_mday<<"-"<<(now->tm_mon+1)<<"-"<<(now->tm_year+1900)<<endl;
}
| [
"vinitsaini357@gmail.com"
] | vinitsaini357@gmail.com |
ce76923f18e0e6390428a55142f16aa4765026b2 | 4ff9973214f66522bf11795ae35da9dcd67fbcda | /finding subarray having sum of elements as desired.cpp | e1b88a23737af7f0fa49de9c9c3a131ca3e9559f | [] | no_license | Yashbhatia27/special-c-programs | 9764ccde24585fb4ef04aa841cb448d97a490f0c | 9f2564639ff4cccb948b38960b90dabf5fd55296 | refs/heads/main | 2023-08-15T15:44:03.242271 | 2021-10-06T11:06:31 | 2021-10-06T11:06:31 | 413,447,830 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 629 | cpp | #include <iostream>
using namespace std;
int main()
{
int n;
cout<<"enter the number of indexes in the array"<<"\n";
cin >> n;
int a[n];
cout<<"enter the elements of array"<<"\n";
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
int sum;
cout<<"Enter the sum\n";
cin >> sum;
for (int i = 0; i < n; i++)
{
int s = 0;
for (int k = i; k < n; k++)
{
s += a[k];
if (s == sum)
{
for (int j = i; j <= k; j++)
{
cout << a[j] << " ";
}
cout << endl;
}
}
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
0d6681739b5b98bfc8caeac2e3ff9e1a02f85065 | 2e2c8f7706685bf042b829b288b9408fc8dcf4be | /src/TextureManager.cpp | 0879112a528538d67ac7eea924e26e74f94714b8 | [] | no_license | kaktusas2598/Vigilant | 0723df7bdcfa580cb675a5a793fa37e784e6ae1f | 183545e552dd7bcd4d6748b5d4faa066ce6098e7 | refs/heads/master | 2023-02-02T19:06:58.369667 | 2023-01-22T11:07:58 | 2023-01-22T11:07:58 | 95,713,802 | 2 | 0 | null | 2022-12-19T22:16:51 | 2017-06-28T21:36:54 | C++ | UTF-8 | C++ | false | false | 6,949 | cpp | #include "TextureManager.hpp"
#include <SDL2/SDL_image.h>
#include "Engine.hpp"
#include "Logger.hpp"
namespace Vigilant {
TextureManager* TextureManager::s_pInstance = 0;
bool TextureManager::load(std::string fileName, std::string id) {
// Protect against loading texture with same id for now
// In the future we just want to make sure we dont double load same id unless we want to change
// actual texture, this will be used to catch any logical errors for now!
if (m_textureMap.find(id) != m_textureMap.end()) {
std::cout << "Trying to load texture with existing id: " << id << std::endl;
return true;
}
SDL_Surface* pTempSurface = IMG_Load(fileName.c_str());
if(pTempSurface == 0)
{
return false;
}
SDL_Texture* pTexture = SDL_CreateTextureFromSurface(renderer, pTempSurface);
SDL_FreeSurface(pTempSurface);
if(pTexture != 0)
{
m_textureMap[id] = pTexture;
return true;
}
return false;
}
bool TextureManager::loadFont(std::string fileName, std::string id) {
if (m_fontMap.find(id) != m_fontMap.end()) {
return true;
}
TTF_Font* font = TTF_OpenFont(fileName.c_str(), 28 );
if ( font == NULL ) {
Logger::Instance()->error(TTF_GetError());
return false;
}
m_fontMap[id] = font;
return true;
}
void TextureManager::draw(std::string id,
int x, int y,
int width, int height,
SDL_RendererFlip flip,
float scaleX, float scaleY,
bool absolutePos
) {
// All these draw methods do very similar stuff with rectangles,
// this could be refactored
SDL_Rect srcRect;
SDL_Rect destRect;
srcRect.x = 0;
srcRect.y = 0;
srcRect.w = width;
srcRect.h = height;
destRect.w = width * scaleX;
destRect.h = height * scaleY;
destRect.x = x;
destRect.y = y;
destRect.x = x - (absolutePos ? 0 : TheEngine::Instance()->camera.x);
destRect.y = y - (absolutePos ? 0 : TheEngine::Instance()->camera.y);
if (SDL_RenderCopyEx(renderer, m_textureMap[id], &srcRect, &destRect, 0, 0, flip) != 0) {
Logger::Instance()->error(SDL_GetError());
}
}
void TextureManager::draw(std::string id, int x, int y, int width, int height, double angle, SDL_RendererFlip flip) {
SDL_Rect srcRect;
SDL_Rect destRect;
srcRect.x = 0;
srcRect.y = 0;
srcRect.w = destRect.w = width;
srcRect.h = destRect.h = height;
destRect.x = x;
destRect.y = y;
if (SDL_RenderCopyEx(renderer, m_textureMap[id], &srcRect, &destRect, angle, 0, flip) != 0) {
Logger::Instance()->error(SDL_GetError());
}
}
void TextureManager::drawFrame(std::string id,
int x, int y,
int width, int height,
int currentRow, int currentFrame,
SDL_RendererFlip flip,
float scaleX, float scaleY,
bool absolutePos
) {
SDL_Rect srcRect;
SDL_Rect destRect;
srcRect.x = width * currentFrame;
srcRect.y = height * currentRow;
srcRect.w = width;
srcRect.h = height;
destRect.w = width * scaleX;
destRect.h = height * scaleY;
destRect.x = x - (absolutePos ? 0 : TheEngine::Instance()->camera.x);
destRect.y = y - (absolutePos ? 0 : TheEngine::Instance()->camera.y);
if (SDL_RenderCopyEx(renderer, m_textureMap[id], &srcRect, &destRect, 0, 0, flip) != 0) {
Logger::Instance()->error(SDL_GetError());
}
}
void TextureManager::drawTile(std::string id, int margin, int spacing, int x, int y, int width, int height, int currentRow, int currentFrame, double scale) {
SDL_Rect srcRect;
SDL_Rect destRect;
srcRect.x = margin + (spacing + width) * currentFrame;
srcRect.y = margin + (spacing + height) * currentRow;
srcRect.w = width;
srcRect.h = height;
destRect.w = width * scale;
destRect.h = height * scale;
destRect.x = x; //- TheEngine::Instance()->camera.x;
destRect.y = y; //- TheEngine::Instance()->camera.y;
SDL_RenderCopyEx(renderer, m_textureMap[id], &srcRect, &destRect, 0, 0, SDL_FLIP_NONE);
}
void TextureManager::drawRect(SDL_Rect rect, SDL_Color color, bool absolutePos, bool fill) {
if (!absolutePos) {
rect.x -= TheEngine::Instance()->camera.x;
rect.y -= TheEngine::Instance()->camera.y;
}
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
if (fill)
SDL_RenderFillRect(renderer, &rect);
else
SDL_RenderDrawRect(renderer, &rect);
}
SDL_Texture* TextureManager::getTextTexture(std::string font, std::string text, SDL_Color color) {
// TODO: read about TTF_RenderText_Blended() as well
SDL_Surface* textSurface = TTF_RenderText_Solid(getFont(font) , text.c_str(), color);
if( textSurface == NULL ) {
Logger::Instance()->error(TTF_GetError());
}
//Create texture from surface pixels
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, textSurface);
if( texture == NULL ) {
Logger::Instance()->error(SDL_GetError());
}
// Get rid of old surface
SDL_FreeSurface(textSurface);
return texture;
}
void TextureManager::draw(SDL_Texture* texture, int x, int y, bool absolutePos) {
SDL_Rect dest;
dest.x = x - (absolutePos ? 0 : TheEngine::Instance()->camera.x);
dest.y = y - (absolutePos ? 0 : TheEngine::Instance()->camera.y);
SDL_QueryTexture(texture, NULL, NULL, &dest.w, &dest.h);
SDL_RenderCopy(renderer, texture, NULL, &dest);
}
void TextureManager::draw(std::string id, SDL_Rect srcRect, SDL_Rect dstRect) {
SDL_RenderCopy(renderer, m_textureMap[id], &srcRect, &dstRect);
}
void TextureManager::clearTextureMap() {
m_textureMap.clear();
}
void TextureManager::clearFromTextureMap(std::string id) {
// Lack of this line was the cause of massive memory leak!
// Beginning of this class many years ago originated from SDL2 Game Development book and it was
// full of errors like these, so lesson: always make sure clear any dynamically allocted memory!
SDL_DestroyTexture(m_textureMap[id]);
m_textureMap.erase(id);
}
void TextureManager::clearFontMap() {
m_fontMap.clear();
}
void TextureManager::clearFromFontMap(std::string id) {
TTF_CloseFont(m_fontMap[id]);
m_fontMap.erase(id);
}
}
| [
"nerijus.vilcinskas@gmail.com"
] | nerijus.vilcinskas@gmail.com |
60204d3a681a520c79919553f1a222789e65c713 | 7a56d4684fd450381898cc86d22f11a1f06afb37 | /DoubleLinkedList/DoubleLinkedList/DoubleLinked.h | e2fcd0cf800abf9840c71860415f2bcca0fe4597 | [] | no_license | kingofBokgu/ConsoleEx | de33637f0adca7c223baebf6094c2320d63584e5 | d92aca013b6d034651214bc2c46d922649d027aa | refs/heads/master | 2021-07-14T02:35:08.523022 | 2017-10-14T09:27:01 | 2017-10-14T09:27:01 | 106,915,732 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 743 | h | #include<iostream>
#include<crtdbg.h>
#include<string>
#include<cstdlib>
#include<ctime>
#ifndef _DEBUG
#define new new(_CLIENT_BLOCK,_FILE_,_LINE)
#endif
using namespace std;
class Node
{
private:
Node *m_prePoint;
Node *m_nextPoint;
char m_data;
public:
Node();
void SetPoint(Node *pp, Node *np);
void SetData(char d);
Node *GetPrePosition();
Node *GetNextPosition();
char GetData();
};
Node::Node()
{
m_prePoint = nullptr;
m_nextPoint = nullptr;
}
void Node::SetPoint(Node *pp, Node *np)
{
m_prePoint = pp;
m_nextPoint = np;
}
void Node::SetData(char d)
{
m_data =d;
}
Node* Node::GetPrePosition()
{
return m_prePoint;
}
Node* Node::GetNextPosition()
{
return m_nextPoint;
}
char Node::GetData()
{
return m_data;
} | [
"sourcedev5@gmail.com"
] | sourcedev5@gmail.com |
d5ceac19ff88b7394fd7dcbf24023c9791dbfe4e | b4c9a89b9acf805ba7d6beb43eac29d48d71944d | /client/src/clientpathfinder.hpp | cbec4b5e2f87dee9d0dc6eda982a4e29023a7f35 | [] | no_license | ufaith/mir2x | 5db0b5132c69cf63b4ce8e74b65b062164720feb | 2e08a371794372c346b0cd43934a8785bfedd133 | refs/heads/master | 2022-03-26T01:45:33.209809 | 2022-02-22T21:29:35 | 2022-02-22T21:29:35 | 93,562,935 | 1 | 0 | null | 2017-06-06T20:54:08 | 2017-06-06T20:54:08 | null | UTF-8 | C++ | false | false | 879 | hpp | /*
* =====================================================================================
*
* Filename: clientpathfinder.hpp
* Created: 03/28/2017 21:13:11
* Description:
*
* Version: 1.0
* Revision: none
* Compiler: gcc
*
* Author: ANHONG
* Email: anhonghe@gmail.com
* Organization: USTC
*
* =====================================================================================
*/
#pragma once
#include <map>
#include "pathfinder.hpp"
class ClientPathFinder final: public AStarPathFinder
{
private:
friend class ProcessRun;
private:
const bool m_checkGround;
private:
const int m_checkCreature;
private:
mutable std::map<uint64_t, int> m_cache;
public:
ClientPathFinder(bool, int, int);
private:
int getGrid(int, int) const;
};
| [
"anhonghe@gmail.com"
] | anhonghe@gmail.com |
218d294ba507b9a6c8cce24917be7499f7f1e65e | 9180e24096701db9ad36f034d3519c82f9661b19 | /5.23.cpp | 0e3352bf9f351bd82051999bc5c3568a376483ed | [] | no_license | KainatArif/OOP-Ch-5 | e9df654b01a4a56e298f319a649124bb995a387c | f3170a174e41874a2fd333290a9a7a5cb398b2d0 | refs/heads/master | 2020-11-26T16:09:44.976551 | 2019-12-23T18:10:41 | 2019-12-23T18:10:41 | 229,134,573 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 473 | cpp | // 5.23
// EggTimer
#include<iostream>
using namespace std;
int main()
{
for(int i=1;i<=9;i++)
{
if(i==1||i==9)
{
cout<<"###########";
cout<<"\n";
}
else
{
cout<<"#";
for(int k=7;k>=1;k=k-2)
{
cout<<"*";
if(k==1)
{
for(int l=3;l<=7;l++)
{
cout<<"*";
}
}
}
cout<<"#";
cout<<"\n";
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
d22a3769bba6d9f7a018436264c67d8436ff21c4 | 123b4f818addb76172abbd6ec42a7d8b409a1ec4 | /Code/Engine/Net/UDPIP/NetMessage.hpp | 5ee0747b0466bc2dc5710be14bf042a946659790 | [] | no_license | Sunken-City/Engine | 94bb5c3d401c72f767da7d87bb63f7695c0fccf5 | 32f8ae2df0d5819952a598bbd584c280be6cc2cb | refs/heads/master | 2021-09-24T20:11:16.987854 | 2018-10-14T01:16:01 | 2018-10-14T01:16:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,116 | hpp | #pragma once
#include "Engine/DataStructures/BytePacker.hpp"
#include <stdint.h>
typedef unsigned char byte;
struct NetSender;
struct NetMessageDefinition;
#define MESSAGE_MTU 1024
#define BIT_FLAG(f) (1 << (f))
class NetMessage : public BytePacker
{
public:
//ENUMS/////////////////////////////////////////////////////////////////////
enum CoreMessageTypes : byte
{
PING = 0,
PONG = 1,
HEARTBEAT,
INORDER_HEARTBEAT,
ACK,
JOIN_REQUEST,
JOIN_DENY,
JOIN_ACCEPT,
CONNECTION_LEAVE,
KICK,
QUIT,
NUM_MESSAGES
};
//------------------------------------------------------------------------
// Used to define how the message is transferred.
// By defualt all messages are unreliable and unordered (UDP)
enum class Option : uint8_t
{
NONE = 0,
UNRELIABLE = 0,
//Message is guaranteed to arrive
RELIABLE = BIT_FLAG(0),
// Message will be processed in order sent
INORDER = BIT_FLAG(1),
};
//------------------------------------------------------------------------
// Used to dictate the conditions in which a message CAN be processed.
// Usually used for valdation to make sure messages are used as intended.
enum class Control : uint8_t
{
NONE = 0,
// By default, messages are ignored if they don't have a connect
// unless they have this flag.
PROCESS_CONNECTIONLESS = BIT_FLAG(0),
};
//CONSTRUCTORS/////////////////////////////////////////////////////////////////////
NetMessage()
: BytePacker(m_msgBuffer, MESSAGE_MTU, 0, IBinaryReader::BIG_ENDIAN)
, m_reliableId(0)
, m_sequenceId(0)
, m_lastSentTimestampMs(0)
{
};
NetMessage(uint8_t msg_idx)
: BytePacker(m_msgBuffer, MESSAGE_MTU, 0, IBinaryReader::BIG_ENDIAN)
, m_type(msg_idx)
, m_reliableId(0)
, m_sequenceId(0)
, m_lastSentTimestampMs(0)
{
};
NetMessage(const NetMessage& other)
: BytePacker(m_msgBuffer, MESSAGE_MTU, other.GetReadableBytes(), IBinaryReader::BIG_ENDIAN)
{
m_type = other.m_type;
m_reliableId = other.m_reliableId;
m_sequenceId = other.m_sequenceId;
m_lastSentTimestampMs = other.m_lastSentTimestampMs;
memcpy(m_msgBuffer, other.m_msgBuffer, other.GetReadableBytes());
}
//FUNCTIONS/////////////////////////////////////////////////////////////////////
size_t GetHeaderSize() const;
size_t GetPayloadSize() const;
void Process(const NetSender& from);
bool IsReliable() const;
const NetMessageDefinition* GetDefinition() const;
bool RequiresConnection() const;
bool IsInOrder();
//MEMBER VARIABLES/////////////////////////////////////////////////////////////////////
byte m_type;
// Reliable ID assigned
uint16_t m_reliableId;
uint16_t m_sequenceId;
// If reliable, time since this was last attempted to be sent
uint32_t m_lastSentTimestampMs;
byte m_msgBuffer[MESSAGE_MTU];
}; | [
"acloudy@mail.smu.edu"
] | acloudy@mail.smu.edu |
c7563db10a5b37338cb1a440dc19403bed3af772 | 2ec5420c60a122189ae86f14d33466442fbcac02 | /RootTools/Treenity/Include/WaterTool.h | 6b58f1cfe1c93584e57963720745efa591c72463 | [] | no_license | blockspacer/zombieshroom | 14a26a80f54c3efb894f8826f50ea83c2d0f21d5 | b6b1745689c5f418b1a229517f71a295a52af084 | refs/heads/master | 2021-05-28T13:10:02.401463 | 2014-10-05T17:29:43 | 2014-10-05T17:29:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 965 | h | #pragma once
//Qt includes
#include <QWidget>
#include <QDockWidget>
#include <QColorDialog>
#include <RootTools/Treenity/GeneratedFiles/ui_WaterTool.h>
//Engine includes
#include <RootTools/Treenity/Include/EngineInterface.h>
//Other includes
#include <sstream>
class WaterTool : public QDockWidget
{
Q_OBJECT
public:
WaterTool(QWidget* p_parent = 0);
~WaterTool();
void SetEngineInterface(EngineInterface* p_engineInterface);
public slots:
void Show();
private:
EngineInterface* m_engineInterface;
QColorDialog* m_colorDialog;
QColor m_waterColor;
Ui::WaterUI ui;
private slots:
void SetWaterSpeed(double p_speed);
void SetWaterDepth(double p_depth);
void SetWaterRefractions(bool p_active);
void SetWaterReflections(bool p_active);
void SetWaterNormals(bool p_active);
void SetWaterPause(bool p_active);
void SetWaterColor(const QColor& p_color);
void ResetWater();
void InitWater();
void DisplayData();
void OpenColorDialog();
}; | [
"kevinortegren@gmail.com"
] | kevinortegren@gmail.com |
b430d40bd785110114c7294956bb721d2492a738 | d07e16020c90d5370707a53439bfb3295fd282e9 | /test1/sell.cpp | 8fb5f8666448f278aca4c58d8f70aae51b01cad1 | [] | no_license | Alva112358/database | b65dfa8c0ac307daeb0af781a35c516e478dda6c | f1d868b28d20cae274db2b44fad0bd47f009cb0e | refs/heads/master | 2022-05-18T21:01:54.075785 | 2019-12-01T12:14:17 | 2019-12-01T12:14:17 | 178,811,814 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,973 | cpp | #include "sell.h"
#include "ui_sell.h"
#include <string>
#include <iostream>
#include <sstream>
Sell::Sell(QWidget *parent) :
QDialog(parent),
ui(new Ui::Sell)
{
ui->setupUi(this);
connect(ui->searchbutton, SIGNAL(clicked()), this, SLOT(getBookStock()));
connect(ui->submitbutton, SIGNAL(clicked()), this, SLOT(sell()));
}
/*
输入书名,显示库存量
*/
void Sell::getBookStock() {
// Clear messages
ui->textBrowser->setText("");
ui->textBrowser_2->setText("");
QString qbookName = ui->BookName->toPlainText();
if (qbookName == "") {
return;
}
string bookName = string((const char*)qbookName.toLocal8Bit());
int stockNumber = bookAccess.getTotalBookNumber(bookName);
string number;
stringstream ss;
ss << stockNumber;
ss >> number;
cout << number;
QString text;
if (stockNumber != -1) {
text = QString(QString::fromLocal8Bit(number.c_str()));
ui->textBrowser_2->setText(text);
}
else {
text = "The book is not in our stock!";
ui->textBrowser->setText(text);
}
}
/*
输入销售量,根据书名销售
*/
void Sell::sell() {
// Clear Message
ui->textBrowser->setText("");
QString qbookName = ui->BookName->toPlainText();
QString qbookNumber = ui->BookNumber->toPlainText();
if (qbookName == "" || qbookNumber == "") {
// Clear Message
ui->textBrowser->setText("");
ui->textBrowser_2->setText("");
return;
}
string bookName = string((const char*)qbookName.toLocal8Bit());
string bookNumber = string((const char*)qbookNumber.toLocal8Bit());
if (!checkIfNumbers(bookNumber)) {
ui->textBrowser->setText("Please input number in [Number]");
return;
}
sellInfo data = bookAccess.sellBook(bookName, bookNumber);
string returnID = data.sellId;
string returnNumber = data.sellNumber;
string returnDate = data.sellDate;
string returnName = data.sellName;
string returnPrice = data.sellPrice;
QString ID = QString(QString::fromLocal8Bit(returnID.c_str()));
QString number = QString(QString::fromLocal8Bit(returnNumber.c_str()));
QString date = QString(QString::fromLocal8Bit(returnDate.c_str()));
QString name = QString(QString::fromLocal8Bit(returnName.c_str()));
QString price = QString(QString::fromLocal8Bit(returnPrice.c_str()));
if (returnID == "-1") {
QString text = "Not enough book!";
ui->textBrowser->setText(text);
}
else if (returnID == "-2") {
QString text = "This book is not in our stock!";
ui->textBrowser->setText(text);
}
else {
QString text = "ID: " + ID
+ "\nName: " + name
+ "\nNumber: " + number
+ "\nPrice: " + price
+ "\nDate: " + date;
ui->textBrowser->setText(text);
}
}
Sell::~Sell()
{
delete ui;
}
| [
"285129134@qq.com"
] | 285129134@qq.com |
2c629dbb28f1a5bd3fdb809b6873623c32cfea3b | b21b160bd16b7d299b2d37c286d227f3872cdd0d | /src/ctestmedian.h | ee2538877e7886407c550ef6d0dbbc70c59d70ad | [] | no_license | triclozan/stegotest | f8e0cfd817ecfd4e7390d00e8ee6b1dcae161220 | c8378a1f363a56afbb58ef41c74fc07764d09a1f | refs/heads/master | 2021-01-21T21:55:32.786142 | 2013-04-15T09:06:37 | 2013-04-15T09:06:37 | 9,272,587 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 371 | h | #ifndef CTESTMEDIAN_H
#define CTESTMEDIAN_H
#include "ctest.h"
class CTestMedian : public CTest
{
public:
//virtual void Test(CAlgorithm* alg, QByteArray& params, QByteArray& alg_params, sResults& result, const QString& container_name, const QString& watermark_name);
virtual void Attack(QImage& img, QByteArray& params);
};
#endif // CTESTMEDIAN_H
| [
"�����@www-A.(none)"
] | �����@www-A.(none) |
ac9552e1969cea83516f3a96d21ac82cf5a01937 | 72592091df03ecb4f7af4d6c0aabef33e19cec52 | /INVCNT.cpp | c46c83ccb1bd779f78fa901be2ff0d1baa80c1ee | [] | no_license | ravismash/Competitive | d3e853efe4985634262cbf21403b4dfdc57c82f8 | 2585d083c0667637ea426cc1be187fd5815e6493 | refs/heads/master | 2021-01-17T19:16:10.440971 | 2016-12-28T13:40:42 | 2016-12-28T13:40:42 | 63,539,806 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 624 | cpp | #include<iostream>
#include<stdio.h>
using namespace std;
const int N=2e5+20,MAX=1e7+20;
int t,n,i,a[N],BIT[MAX],v;
long long ans;
void update(int x,int delta)
{
for(;x<MAX;x+=x&-x) BIT[x]+=delta;
}
int query(int x)
{
int sum=0;
for(;x>0;x-=x&-x) sum+=BIT[x];
return sum;
}
int main()
{
scanf("%d",&t);
while(t--)
{
for(i=0;i<MAX;i++) BIT[i]=0;
ans=0;
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%d",&a[i]);
for(i=n;i>=1;i--)
{
v=query(a[i]);
ans+=v;
update(a[i],1);
}
printf("%lld\n",ans);
}
}
| [
"r.ravimeena@gmail.com"
] | r.ravimeena@gmail.com |
c4c684390095748399b793e1beab945e90050ea6 | 8fb42d05ff5cb908577caa8a28043c857b371484 | /src/FrontEnd/Pages/Settings.cpp | f153f7846a90c2f02f509ba34c949fd3c68ad18a | [] | no_license | Rogozin-high-school/ground_station | 58c3fad95feb2a69c9a0697164604d49d8a94ddc | cab6a1655f8070e08d0b87ea3954cdf3990e0c6d | refs/heads/master | 2020-09-21T01:03:07.057538 | 2020-02-19T13:03:24 | 2020-02-19T13:03:24 | 224,635,523 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 447 | cpp | #include <FrontEnd/Pages/Settings.hpp>
#include <FrontEnd.hpp>
#include <gtkmm/box.h>
#include <gtkmm/image.h>
namespace FrontEnd::Pages
{
static Gtk::Widget *pPage;
static Gtk::Widget *pIcon;
void Settings::load()
{
pPage = Gtk::manage(new Gtk::Box);
pIcon = Gtk::manage(new Gtk::Image(SCALE(Resources::Pixbufs::pIconGears, 96)));
pNotebook->append_page(*pPage, *pIcon);
pNotebook->show_all();
}
} // namespace FrontEnd::Pages | [
"mgmaorvids@gmail.com"
] | mgmaorvids@gmail.com |
44f3b3b41c561793e2ef31544852ef65205e917d | c66129d551456ea813f1e09ba93b7c6cf38307fb | /MenuRequestHandler.cpp | dfdd98ad5840ed02e9ed89bfd61c2654cd943eba | [] | no_license | DanielBuzkov/trivia | 1ddade85e722c0197e193ee29de0b89f18f6cb4e | a930dcd71946c8653d290c17775544f213d4b61d | refs/heads/master | 2022-12-30T09:45:12.358012 | 2018-06-26T20:32:44 | 2018-06-26T20:32:44 | 299,983,139 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,452 | cpp | #include "MenuRequestHandler.h"
//Update handler for next stage
MenuRequestHandler::MenuRequestHandler()
{
m_user = LoggedUser();
m_roomManager = RoomManager();
m_highscoreTable = HighscoreTable();
}
bool MenuRequestHandler::isRequestRelevant(Request r)
{
return r.id == SIGNOUT_REQUEST ||
r.id == GET_ROOMS_REQUEST ||
r.id == GET_PLAYERS_IN_ROOM_REQUEST ||
r.id == GET_HIGHSCORES_REQUEST ||
r.id == JOIN_ROOM_REQUEST ||
r.id == CREATE_ROOM_REQUEST;
}
RequestResult MenuRequestHandler::signout(Request r)
{
RequestResult success;
success.Response = JsonResponsePacketSerializer::serializeResponse(LogoutResponse());
success.newHandler = nullptr;
return success;
}
RequestResult MenuRequestHandler::getRooms(Request r)
{
RequestResult success;
success.Response = JsonResponsePacketSerializer::serializeResponse(LogoutResponse());
return success;
}
RequestResult MenuRequestHandler::getPlayersInRoom(Request r)
{
RequestResult success;
success.Response = JsonResponsePacketSerializer::serializeResponse(GetPlayersInRoomResponse());
return success;
}
RequestResult MenuRequestHandler::getHighscores(Request r)
{
RequestResult success;
success.Response = JsonResponsePacketSerializer::serializeResponse(HighscoreResponse());
return success;
}
RequestResult MenuRequestHandler::joinRoom(Request r)
{
RequestResult success;
success.Response = JsonResponsePacketSerializer::serializeResponse(JoinRoomResponse());
success.newHandler = &RequestHandlerFactory::createRoomMemeberRequestHandler();
return success;
}
RequestResult MenuRequestHandler::createRoom(Request r)
{
RequestResult success;
success.Response = JsonResponsePacketSerializer::serializeResponse(CreateRoomResponse());
success.newHandler = &RequestHandlerFactory::createRoomAdminRequestHandler();
return success;
}
RequestResult MenuRequestHandler::handleRequest(Request r)
{
if (isRequestRelevant)
{
if (r.id == SIGNOUT_REQUEST)
return signout(r);
else if (r.id == GET_ROOMS_REQUEST)
return getRooms(r);
else if (r.id == GET_PLAYERS_IN_ROOM_REQUEST)
return getPlayersInRoom(r);
else if (r.id == GET_HIGHSCORES_REQUEST)
return getHighscores(r);
else if (r.id == JOIN_ROOM_REQUEST)
return joinRoom(r);
else if (r.id == CREATE_ROOM_REQUEST)
return createRoom(r);
}
else
{
RequestResult fail;
fail.Response = JsonResponsePacketSerializer::serializeResponse(ErrorResponse());
fail.newHandler = nullptr;
}
}
| [
"danielb442000@gmail.com"
] | danielb442000@gmail.com |
9e627ef5a72a2c42d51dd4275deda9b311a0efc1 | 5a4a40e3d005c41bf1fad4da1761f612769f6bdf | /cnlab/fileser.cpp | c04a2d6c1fc7ceae2a1b9ff10e62b42bd4be2c05 | [
"MIT"
] | permissive | shainisoni1696/SocketProgramming | 4924c5336a167d8aeb2ae426470a78165c965230 | c277b689f83ae0f8fd875a0e27f8d7a93bcbcadc | refs/heads/master | 2020-05-15T02:48:38.866377 | 2019-04-18T09:24:14 | 2019-04-18T09:24:14 | 182,056,036 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,070 | cpp | // receving file from client and print the data of the file
#include<stdio.h>
#include<unistd.h>
#include<sys/socket.h>
#include<stdlib.h>
#include<netinet/in.h>
#include<string.h>
#include<iostream>
#define SERV_PORT 2000
using namespace std;
int main(int argc, char **argv)
{
int i,j;
ssize_t n;
FILE *fp;
char s[80],f[80];
struct sockaddr_in servaddr,cliaddr;
int listenfd,connfd,clilen;
listenfd=socket(AF_INET,SOCK_STREAM,0); //create socket object
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family=AF_INET;
servaddr.sin_port=htons(SERV_PORT);
bind(listenfd,(struct sockaddr*)&servaddr,sizeof(servaddr)); //bind obj to ip
listen(listenfd,1);//listen to clients
clilen=sizeof(cliaddr);
connfd=accept(listenfd,(struct sockaddr*)&cliaddr,(socklen_t*)&clilen);//connect to client
cout<<"client connected";
read(connfd,f,80);//read file name
fp=fopen(f,"r");
cout<<"\nname of file is:"<<f<<endl;
while(fgets(s,80,fp)!=NULL) //print data of file
{
cout<<s;
write(connfd,s,sizeof(s));//send same data to client
}
close(listenfd);
fclose(fp);
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
e617e98a82ed5a8695cf21ebb79b3a51362a7ff1 | 3cb889e26a8e94782c637aa1126ad897ccc0d7a9 | /C++/Gobang/Gobang/stdafx.cpp | 2a99d41b724c288388188aed5ba74a5fe376e6bc | [] | no_license | GHScan/DailyProjects | 1d35fd5d69e574758d68980ac25b979ef2dc2b4d | 52e0ca903ee4e89c825a14042ca502bb1b1d2e31 | refs/heads/master | 2021-04-22T06:43:42.374366 | 2020-06-15T17:04:59 | 2020-06-15T17:04:59 | 8,292,627 | 29 | 10 | null | null | null | null | GB18030 | C++ | false | false | 258 | cpp | // stdafx.cpp : 只包括标准包含文件的源文件
// Gobang.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中
// 引用任何所需的附加头文件,而不是在此文件中引用
| [
"ppscan@qq.com"
] | ppscan@qq.com |
aab3a405ed000f11ccde5dee7b1b652309da7cdf | b67d7e7b787394b1332b06a006008295758463e7 | /OOP_LAB_4/OOP_LAB_4/shape.h | 26da97f6ae66cc5588f7b48fc8bd3d80002dd5fe | [] | no_license | Pickto/OOP_LABS | 7fd9e4c9ed699db6192e808c0eb03a8bfe8d537c | ee17b81dad1cdb018dc6bcd9093dc1b14a6e374f | refs/heads/master | 2020-07-21T10:02:11.486316 | 2019-10-24T06:58:34 | 2019-10-24T06:58:34 | 206,824,651 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 909 | h | #pragma once
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <conio.h>
#include <fstream>
#include <string>
class Shape
{
protected:
POINT* points;
int count_points;
COLORREF pen_color;
int pen_style;
int pen_depth;
virtual void set_point(int number, int x, int y) = 0;
public:
virtual ~Shape();
virtual void set_points(POINT* points, int count_points) = 0;
virtual void set_pen_color(int R, int G, int B) = 0;
virtual void set_pen_style(int hash) = 0;
virtual void set_pen_depth(int pen_depth) = 0;
virtual POINT get_point(int number) = 0;
virtual int get_count_points() = 0;
virtual COLORREF get_pen_color() = 0;
virtual const char* get_pen_style() = 0;
virtual int get_pen_depth() = 0;
virtual void draw(HWND hwnd, HDC hdc) = 0;
virtual void move(int x, int y) = 0;
virtual void read(std::ifstream& file) = 0;
virtual void save(std::ofstream& file) = 0;
};
| [
"van7ka.777@gmail.com"
] | van7ka.777@gmail.com |
38e67c892beeb830d93c1da014a323d8c8488f23 | c7675290ccdc2180881a432029d59e862a40a80b | /ESP8266WifiTest.ino | 549a8ae97abf1e036a9f007362ac075884048f5a | [] | no_license | d900139/ESP8266Test | 42a0c27015bc4e0ae530fb1481e6216bb0235af1 | 1535cf9b7eeaed0a385a03b3404f2e7ae3cfb642 | refs/heads/master | 2021-01-23T03:05:18.001487 | 2017-03-24T09:23:43 | 2017-03-24T09:23:43 | 86,048,920 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,732 | ino | #include <SoftwareSerial.h>
SoftwareSerial WIFI(7, 8); //RX, TX
#define SSID "SSID"
#define PASS "password"
int Wifi_State = 0, mStep = 0;;
char val, q;
boolean redo, flag, wait;
String cmd, res;
/*----------*/
int connectionId, pinNumber;
String closeCommand;
/*----------*/
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println(F("Wifi is ready!"));
WIFI.begin(9600);
}
void loop() {
if (Serial.available()) {
val = Serial.read();
}
if (WIFI.available()) {
res = get_response();
Serial.print("Result: ");
Serial.println(res);
}
switch (val) {
case 'A': //--------------------------------------------------測試 esp8266 AT
case 'a':
Serial.println(F("-----------Case A-----------"));
sendDebug("AT");
if (Loding("Sent AT")) {
redo = false;
} else {
redo = true;
}
Serial.println(F("----------------------------"));
break;
case 'B': //--------------------------------------------------查看 esp8266 狀態
case 'b':
Serial.println(F("-----------Case B-----------"));
flag = !flag;
while (flag) {
switch (Wifi_State) {
case 0:
Serial.println(F("------Firmware Version------"));
sendDebug("AT+GMR");
if (Loding("Get firmware version")) { //delay 1 sec
Wifi_State++; //next setting wifi mode
}
break;
case 1: //--------------------------------------------------查詢鮑率
Serial.println(F("----------Baud Rate---------"));
sendDebug("AT+CIOBAUD?");
if (Loding("Get BAUD rate")) { //delay 1 sec
Wifi_State++; //next setting wifi mode
}
break;
case 2: //--------------------------------------------------查詢目前工作模式
Serial.println(F("---------Work Mode----------"));
Serial.println(F("- 1: STA - 2: AP - 3: BOTH -"));
sendDebug("AT+CWMODE?"); // 1 = STA (網卡模式), 2 = AP (基地台模式), 3 = BOTH (AP+STA).
if (Loding("Get work mode")) { //delay 1 sec
Wifi_State++; //next setting wifi mode
}
break;
case 3: // Get ip address 數據機"http://192.168.xxx.xxx" 手機熱點" http://xx.xx.xx.xx:port/pin=" <== ip
Serial.println(F("-------------IP-------------"));
sendDebug("AT+CIFSR");
if (Loding("Get ip address")) { //delay 1 sec
Wifi_State++; //next setting wifi mode
}
break;
case 4: //--------------------------------------------------查詢目前連線到哪一個基地台
Serial.println(F("---Connected Base Station---"));
sendDebug("AT+CWJAP?");
if (Loding("Get connected base station")) { //delay 1 sec
Wifi_State++;
}
break;
case 5: //---------------------------------查詢有哪些 Client 連線至此 AP (只在 AP/BOTH 模式有效)
Serial.println(F("-----Connected Devices------"));
sendDebug("AT+CWLIF");
if (Loding("Get connected devices")) { //delay 1 sec
Wifi_State++;
}
break;
case 6: //--------------------------------------------------詢問目前 TCP/UDP 連線模式
Serial.println(F("-----------TCP/UDP----------"));
sendDebug("AT+CIPMUX?");
if (Loding("Get TCP/UDP mode")) { //delay 1 sec
Wifi_State++;
}
Serial.println(F("----------------------------"));
break;
case 7: //--------------------------------------------------查看連線狀態
Serial.println(F("------Connection Status-----"));
sendDebug("AT+CIPSTATUS");
if (Loding("Get Connection Status")) { //delay 1 sec
Wifi_State = 0;
flag = !flag;
}
Serial.println(F("----------------------------"));
break;
default :
break;
}
}
break;
case 'T': //--------------------------------------------------測試發送訊號
case 't':
Serial.println(F("-----------Case T-----------"));
flag = !flag;
while (flag) {
switch (mStep) {
case 0:
Serial.println(F("-----Connect To WIFI AP-----"));
cmd = "AT+CWJAP=\"";
cmd += SSID;
cmd += "\",\"";
cmd += PASS;
cmd += "\"";
sendDebug(cmd);
if (Loding("Wifi connect")) {
mStep++;
} else {
mStep = 0;
}
Serial.println(F("----------------------------"));
break;
case 1:
Serial.println(F("------Set TCP/UDP mode-----"));
sendDebug("AT+CIPMUX=1");
if (Loding("Set TCP/UDP mode")) {
mStep++;
}
break;
case 2:
Serial.println(F("-------Enable TCP Server------"));
sendDebug("AT+CIPSERVER=1,8888");
if (Loding("Enable TCP Server")) {
mStep++;
} else {
mStep--;
}
break;
case 3:
Serial.println(F("---------Getting msg----------"));
if (getMsg("Getting msg")) {
mStep++;
}
break;
case 4:// wait for the serial buffer to fill up (read all the serial data)
delay(10);
connectionId = WIFI.read() - 48; // subtract 48 because the read() function returns
// the ASCII decimal value and 0 (the first decimal number) starts at 4
WIFI.find("pin="); // advance cursor to "pin="
pinNumber = (WIFI.read() - 48) * 10; // get first number i.e. if the pin 13 then the 1st number is 1, then multiply to get 10
pinNumber += (WIFI.read() - 48); // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number
// digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin
// make close command
closeCommand = "AT+CIPCLOSE=";
closeCommand += connectionId; // append connection id
closeCommand += "\r\n";
Serial.print("Turn Pin");
Serial.print(pinNumber);
Serial.print(":");
// Serial.print(digitalRead(pinNumber));
Serial.print("ON");
Serial.println("!");
sendDebug(closeCommand); // close connection
mStep--; //next setting wifi mode
break;
case 5:
Serial.println(F("-----Connect Server By TCP----"));
cmd = "AT+CIPSTART=\"";
cmd += "TCP";
cmd += "\",\"";
cmd += "www.google.com";
cmd += "\",";
cmd += "8080";
sendDebug(cmd);
// if (Loding("Connect Server By TCP")) {
// mStep++;
// } else {
// mStep = 3;
// }
if (gg("Connect Server By TCP")) {
mStep++;
} else {
mStep = 5;
}
break;
case 6:
Serial.println(F("---Wait For Server Response---"));
sendDebug("AT+CIPSEND=7");
mStep++;
break;
case 7:
if (test("Wait For Server Response")) {
mStep++;
} else {
mStep = 7;
}
break;
case 8:
Serial.println(F("---------Send Message---------"));
sendDebug("GET /");
if (Loding("Wait For Server Response")) {
mStep++;
} else {
mStep = 8;
}
break;
case 9:
Serial.println(F("----Disable TCP Connection----"));
sendDebug("AT + CIPCLOSE = 0");
if (Loding("Disable TCP Connection")) {
mStep = 3;
flag = !flag;
} else {
mStep = 9;
}
break;
default:
break;
}
}
break;
default:
break;
}
if (!redo)
val = ' ';
}
String get_response() { //get esp responce without "Serial.find()".
String response = "";
char c;
while (WIFI.available()) {
c = WIFI.read();
response.concat(c);
delay(10);
}
response.trim();
return response;
}
boolean Loding(String state) {
String response = get_response();
for (int timeout = 0 ; timeout < 30 ; timeout++) {
if (response.indexOf("OK") != -1 || response.indexOf("no change") != -1) {
if (timeout >= 2) {
Serial.print(F(" OK! "));
Serial.print(F("This commend waste "));
Serial.print(timeout / 2);
Serial.println(F(" sec."));
} else {
Serial.print(F("Get: "));
Serial.println(response);
}
return 1;
break;
} else if (timeout == 29) { //after 15 sec for wait esp without responce.
Serial.print(state);
Serial.println(F(" fail...\nExit2"));
return 0;
} else {
response = get_response(); //reget
if (timeout == 0)
Serial.print(F("Wifi Loading."));
else
Serial.print(F("."));
delay(500);
}
}
}
void sendDebug(String sent_cmd) {
Serial.print("SEND: ");
Serial.println(sent_cmd);
WIFI.println(sent_cmd);
}
boolean getMsg(String state) {
String response = get_response();
q = Serial.read();
for (int timeout = 0 ; timeout < 30 ; timeout++) {
if (q == 'q') {
q = ' ';
mStep = 5;
break;
}
if (response.indexOf("+IPD,") != -1) {
if (timeout >= 2) {
Serial.print(F(" OK! "));
Serial.print(F("This commend waste "));
Serial.print(timeout / 2);
Serial.println(F(" sec."));
Serial.println("Get webpage signal, analyzing...");
Serial.print(F("Get: "));
Serial.println(response);
} else {
Serial.print(F("Get: "));
Serial.println(response);
}
return 1;
break;
} else if (timeout == 29) { //after 15 sec for wait esp without responce.
Serial.print(state);
Serial.println(F(" fail...\nExit2"));
return 0;
} else {
response = get_response(); //reget
if (timeout == 0)
Serial.print(F("Wifi Loading."));
else
Serial.print(F("."));
delay(500);
}
}
}
boolean gg(String state) {
String response = get_response();
if (!response.equals("")) {
Serial.println(response);
return 1;
} else {
return 0;
}
}
boolean test(String state) {
String response = get_response();
Serial.println(response);
for (int timeout = 0 ; timeout < 30 ; timeout++) {
if (response.indexOf(">") != -1) {
if (timeout >= 2) {
Serial.print(F(" OK! "));
Serial.print(F("This commend waste "));
Serial.print(timeout / 2);
Serial.println(F(" sec."));
Serial.println(response);
} else {
Serial.println(response);
}
return 1;
break;
} else if (timeout == 29) { //after 15 sec for wait esp without responce.
Serial.print(state);
Serial.println(F(" fail...\nExit2"));
return 0;
} else {
response = get_response(); //reget
if (timeout == 0)
Serial.print(F("Wifi Loading."));
else
Serial.print(F("."));
delay(500);
}
}
}
| [
"d900139@gmail.com"
] | d900139@gmail.com |
25ce1bd83d998965ea77c5c75b0c59dee48008ed | fd19426360266e2579fd960f26959a363e761c86 | /basic.cpp | 303162c7bfaf0eaaec5b652caa7fe2037521c064 | [] | no_license | leitao/cpptutorial | 29b730c561feaeef967d9a0a933a49b548b587a2 | e19a2929e39446c226bf14d94c07f8cd557a87d6 | refs/heads/master | 2021-01-10T08:37:43.633713 | 2015-10-01T13:00:38 | 2015-10-01T13:00:38 | 43,495,256 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 412 | cpp | #include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
Rectangle(int, int);
void set_values (int,int);
int area (void);
};
void Rectangle::set_values(int a, int b){
width = a;
height = b;
}
int Rectangle::area(){
return width * height;
}
Rectangle::Rectangle(int a, int b){
set_values(a, b);
}
int main()
{
Rectangle rect(3,4);
cout << rect.area();
}
| [
"brenohl@br.ibm.com"
] | brenohl@br.ibm.com |
ef04c5437184338c3ed0d988bd0f4d10e27fa76c | 383d4f46fb754dd88387706558549d82db9318de | /Projects/Game Of Death/Game Of Death/Building.h | 0a3e8f4f2207e175e0575cef4600d51c0559dfa4 | [] | no_license | Matt392/Ascension | bc6879a0e2297ae5a12043dcba28cb3e3b4bebce | ff57780e7bcebda8bb57dcb852ea176db6884722 | refs/heads/master | 2021-01-23T20:50:18.945222 | 2012-12-22T03:33:39 | 2012-12-22T03:33:39 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 756 | h | /**
* @Ascension Engine
* @file Ascension 2D\Projects\Game Of Death\Game Of Death\Building.h
* @brief
*
* Copyright()
* Copyright © 2011 Matt Dalzell. All Rights Reserved.
*
*********************************************************************************************/
#ifndef _BUILDING_H__Included_1573642051
#define _BUILDING_H__Included_1573642051
#include "GameOfDeathInc.h"
namespace ASC
{
class CBuilding
{
public:
CBuilding(void);
~CBuilding(void);
bool Initialise(UINT32 uColour, SPatternTemplate& Template, SCoordinates sStartPos, bool bTop);
void DrawOnField(UINT32* pTexels, UINT32 uPitch);
protected:
UINT32 m_uColour;
ASCVector<SCoordinates> m_uCoordinates;
};
}
#endif //_BUILDING_H__Included_1573642051
| [
"matt@custardsquare.com"
] | matt@custardsquare.com |
f3a0f1b78f37de5b1caa356cef80448db0a39d64 | 814621dbf05f98a1d140c956c07ba5a6cd7e20bd | /src/xengine/stream/datastream.h | 9ca5f944806f123b164b8126f7b015f5170b2145 | [
"MIT"
] | permissive | sunny023/BigBang | 64a308d340f1705a9161784c87c732a3a7a06dff | 8a41582df5320b0c08fa4db2b143528bb219130c | refs/heads/master | 2020-09-09T14:52:46.127960 | 2019-09-29T04:07:57 | 2019-09-29T04:07:57 | 221,476,302 | 1 | 0 | MIT | 2019-11-13T14:20:08 | 2019-11-13T14:20:07 | null | UTF-8 | C++ | false | false | 4,849 | h | // Copyright (c) 2019 The Bigbang developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef XENGINE_STREAM_DATASTREAM_H
#define XENGINE_STREAM_DATASTREAM_H
#include <boost/type_traits.hpp>
#include <cstring>
#include <exception>
#include <map>
#include <vector>
namespace xengine
{
class CODataStream
{
#define BEGIN(a) ((unsigned char*)&(a))
#define END(a) ((unsigned char*)&((&(a))[1]))
#define UNSIGNED(T) typename boost::conditional<boost::is_unsigned<T>::value, T, unsigned int>::type
public:
CODataStream(std::vector<unsigned char>& vchIn,
std::vector<unsigned char>::size_type capacity = 1024)
: vch(vchIn)
{
vch.reserve(capacity);
}
void Push(const void* p, std::size_t size)
{
vch.insert(vch.end(), (const unsigned char*)p, (const unsigned char*)p + size);
}
template <typename T>
void Push(const T& data, const boost::true_type&)
{
vch.insert(vch.end(), BEGIN(data), END(data));
}
template <typename T>
void Push(const T& data, const boost::false_type&)
{
data.ToDataStream(*this);
}
template <typename T>
CODataStream& operator<<(const T& data)
{
Push(data, boost::is_fundamental<T>());
return (*this);
}
template <typename T, typename A>
CODataStream& operator<<(const std::vector<T, A>& data)
{
typename std::vector<T, A>::size_type size = data.size();
vch.insert(vch.end(), BEGIN(size), END(size));
if (size > 0)
{
if (boost::is_fundamental<T>::value)
{
vch.insert(vch.end(), BEGIN(data[0]), END(data[size - 1]));
}
else
{
for (decltype(size) i = 0; i < size; i++)
{
(*this) << data[i];
}
}
}
return (*this);
}
template <typename K, typename V, typename C, typename A>
CODataStream& operator<<(const std::map<K, V, C, A>& data)
{
typename std::map<K, V, C, A>::size_type size = data.size();
vch.insert(vch.end(), BEGIN(size), END(size));
for (typename std::map<K, V, C, A>::const_iterator it = data.begin(); it != data.end(); ++it)
{
(*this) << (*it).first << (*it).second;
}
return (*this);
}
protected:
std::vector<unsigned char>& vch;
};
class CIDataStream
{
public:
CIDataStream(const std::vector<unsigned char>& vchIn,
const std::vector<unsigned char>::size_type nPositionIn = 0)
: vch(vchIn), nPosition(nPositionIn) {}
std::size_t GetSize()
{
return (vch.size() - nPosition);
}
void Pop(void* p, std::size_t size)
{
if (nPosition + size > vch.size())
{
throw std::range_error("out of range");
}
std::memmove(p, &vch[nPosition], size);
nPosition += size;
}
template <typename T>
void Pop(T& data, const boost::true_type&)
{
if (nPosition + sizeof(T) > vch.size())
{
throw std::range_error("out of range");
}
data = *((T*)&vch[nPosition]);
nPosition += sizeof(T);
}
template <typename T>
void Pop(T& data, const boost::false_type&)
{
data.FromDataStream(*this);
}
template <typename T>
CIDataStream& operator>>(T& data)
{
Pop(data, boost::is_fundamental<T>());
return (*this);
}
template <typename T, typename A>
CIDataStream& operator>>(std::vector<T, A>& data)
{
typename std::vector<T, A>::size_type size;
*this >> size;
if (boost::is_fundamental<T>::value)
{
data.assign((T*)&vch[nPosition], (T*)&vch[nPosition] + size);
nPosition += size * sizeof(T);
}
else
{
data.resize(size);
for (decltype(size) i = 0; i < size; i++)
{
*this >> data[i];
}
}
return (*this);
}
template <typename K, typename V, typename C, typename A>
CIDataStream& operator>>(std::map<K, V, C, A>& data)
{
typename std::map<K, V, C, A>::size_type size;
*this >> size;
for (decltype(size) i = 0; i < size; i++)
{
K k;
V v;
*this >> k >> v;
if (!data.insert(std::make_pair(k, v)).second)
{
throw std::runtime_error("data conflict");
}
}
return (*this);
}
protected:
const std::vector<unsigned char>& vch;
std::vector<unsigned char>::size_type nPosition;
};
} // namespace xengine
#endif //XENGINE_STREAM_DATASTREAM_H
| [
"jhkghmn@gmail.com"
] | jhkghmn@gmail.com |
54576123d1c1e5a360dfa09178a3009de45b643e | 8f777207d23154e0ba2d7ddd4ef039a244c293fa | /app/select-fixed-points/include/select-fixed-points/GUIControl.h | 1c0136b02e76146eaf45f48cf78c91603314878e | [] | no_license | danoan/exhaustive-gc | b827a84ef6ec0d48bdca1f1900f29e2fff281e09 | 1e3c2a3bf44631c8a200766eefb923bafdf6c9e3 | refs/heads/master | 2020-04-17T01:50:59.934345 | 2020-03-05T10:31:18 | 2020-03-05T10:31:18 | 166,110,491 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 864 | h | #ifndef EXHAUSTIVE_GC_SELECTFIXEDPOINTS_GUICONTROL_H
#define EXHAUSTIVE_GC_SELECTFIXEDPOINTS_GUICONTROL_H
namespace SelectFixedPixels
{
struct GUIControl
{
GUIControl(const cv::Mat& loadedImg, cv::Mat& displayedImg):loadedImg(loadedImg),displayedImg(displayedImg){}
void addPointsInRect(const cv::Point& lb, const cv::Point& ub,int maxY)
{
cv::Point diff = ub - lb;
for(auto x=0;x<=diff.x;++x)
{
for(auto y=0;y<=diff.y;++y)
{
cv::Point p = (lb+cv::Point(x,y));
p.y=maxY-p.y;
fixedPixels.push_back(p);
}
}
}
const cv::Mat& loadedImg;
cv::Mat& displayedImg;
std::vector<cv::Point> fixedPixels;
};
}
#endif //EXHAUSTIVE_GC_GUICONTROL_H
| [
"danoan2008@gmail.com"
] | danoan2008@gmail.com |
4ad2805a8f5373c482e3e02b24e0f602660378cb | d31dfed6b8b69d27ce9e86dc4cf57b53e4fcf89b | /lab5/boggle/lib/StanfordCPPLib/lexicon.h | fea47263a36b58ea4b2f6311439ea540553d4808 | [] | no_license | PeyWn/LABS_TDDD86 | 49d5dec9db64db34cecdd603e3588f3e2241586d | d73c8adcaae89601b0ac54ca3018c7ea74662d4d | refs/heads/master | 2020-09-16T13:10:17.182523 | 2016-12-13T17:08:08 | 2016-12-13T17:08:08 | 67,675,840 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,695 | h | /*
* File: lexicon.h
* ---------------
* This file exports the <code>Lexicon</code> class, which is a
* compact structure for storing a list of words.
*/
#ifndef _lexicon_h
#define _lexicon_h
#include <string>
#include "foreach.h"
#include "set.h"
#include "stack.h"
/*
* Class: Lexicon
* --------------
* This class is used to represent a <b><i>lexicon,</i></b> or word list.
* The main difference between a lexicon and a dictionary is that
* a lexicon does not provide any mechanism for storing definitions;
* the lexicon contains only words, with no associated information.
* It is therefore similar to a set of strings, but with a more
* space-efficient internal representation. The <code>Lexicon</code>
* class supports efficient lookup operations for words and prefixes.
*
* <p>As an example of the use of the <code>Lexicon</code> class, the
* following program lists all the two-letter words in the lexicon
* stored in <code>EnglishWords.dat</code>:
*
*<pre>
* int main() {
* Lexicon english("EnglishWords.dat");
* foreach (string word in english) {
* if (word.length() == 2) {
* cout << word << endl;
* }
* }
* return 0;
* }
*</pre>
*/
#include <cctype>
class Lexicon {
public:
/*
* Constructor: Lexicon
* Usage: Lexicon lex;
* Lexicon lex(filename);
* -----------------------------
* Initializes a new lexicon. The default constructor creates an empty
* lexicon. The second form reads in the contents of the lexicon from
* the specified data file. The data file must be in one of two formats:
* (1) a space-efficient precompiled binary format or (2) a text file
* containing one word per line. The Stanford library distribution
* includes a binary lexicon file named <code>English.dat</code>
* containing a list of words in English. The standard code pattern
* to initialize that lexicon looks like this:
*
*<pre>
* Lexicon english("English.dat");
*</pre>
*/
Lexicon();
Lexicon(std::string filename);
/*
* Destructor: ~Lexicon
* --------------------
* The destructor deallocates any storage associated with the lexicon.
*/
virtual ~Lexicon();
/*
* Method: size
* Usage: int n = lex.size();
* --------------------------
* Returns the number of words contained in the lexicon.
*/
int size() const;
/*
* Method: isEmpty
* Usage: if (lex.isEmpty()) ...
* -----------------------------
* Returns <code>true</code> if the lexicon contains no words.
*/
bool isEmpty() const;
/*
* Method: clear
* Usage: lex.clear();
* -------------------
* Removes all words from the lexicon.
*/
void clear();
/*
* Method: add
* Usage: lex.add(word);
* ---------------------
* Adds the specified word to the lexicon.
*/
void add(std::string word);
/*
* Method: addWordsFromFile
* Usage: lex.addWordsFromFile(filename);
* --------------------------------------
* Reads the file and adds all of its words to the lexicon.
*/
void addWordsFromFile(std::string filename);
/*
* Method: contains
* Usage: if (lex.contains(word)) ...
* ----------------------------------
* Returns <code>true</code> if <code>word</code> is contained in the
* lexicon. In the <code>Lexicon</code> class, the case of letters is
* ignored, so "Zoo" is the same as "ZOO" or "zoo".
*/
bool contains(std::string word) const;
/*
* Method: containsPrefix
* Usage: if (lex.containsPrefix(prefix)) ...
* ------------------------------------------
* Returns true if any words in the lexicon begin with <code>prefix</code>.
* Like <code>containsWord</code>, this method ignores the case of letters
* so that "MO" is a prefix of "monkey" or "Monday".
*/
bool containsPrefix(std::string prefix) const;
/*
* Method: mapAll
* Usage: lexicon.mapAll(fn);
* --------------------------
* Calls the specified function on each word in the lexicon.
*/
void mapAll(void (*fn)(std::string)) const;
void mapAll(void (*fn)(const std::string &)) const;
template <typename FunctorType>
void mapAll(FunctorType fn) const;
/*
* Additional Lexicon operations
* -----------------------------
* In addition to the methods listed in this interface, the Lexicon
* class supports the following operations:
*
* - Deep copying for the copy constructor and assignment operator
* - Iteration using the range-based for statement and STL iterators
*
* All iteration is guaranteed to proceed in alphabetical order. All
* words in the lexicon are stored in lowercase.
*/
/* Private section */
/**********************************************************************/
/* Note: Everything below this point in the file is logically part */
/* of the implementation and should not be of interest to clients. */
/**********************************************************************/
private:
#ifdef _WIN32
#define LITTLE_ENDIAN 1
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#pragma pack(1)
struct Edge {
#if defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
unsigned long letter:5;
unsigned long lastEdge:1;
unsigned long accept:1;
unsigned long unused:1;
unsigned long children:24;
#else
unsigned long children:24;
unsigned long unused:1;
unsigned long accept:1;
unsigned long lastEdge:1;
unsigned long letter:5;
#endif
};
#pragma pack()
Edge *edges, *start;
int numEdges, numDawgWords;
Set<std::string> otherWords;
public:
/*
* Deep copying support
* --------------------
* This copy constructor and operator= are defined to make a
* deep copy, making it possible to pass/return lexicons by value
* and assign from one lexicon to another. The entire contents of
* the lexicon, including all words, are copied. Making copies is
* generally avoided because of the expense and thus, lexicons are
* typically passed by reference. When a copy is needed, these
* operations are supported.
*/
Lexicon(const Lexicon & src);
Lexicon & operator=(const Lexicon & src);
/*
* Iterator support
* ----------------
* The classes in the StanfordCPPLib collection implement input
* iterators so that they work symmetrically with respect to the
* corresponding STL classes.
*/
class iterator : public std::iterator<std::input_iterator_tag,std::string> {
private:
const Lexicon *lp;
int index;
std::string currentDawgPrefix;
std::string currentSetWord;
std::string tmpWord;
Edge *edgePtr;
Stack<Edge *> stack;
Set<std::string>::iterator setIterator;
Set<std::string>::iterator setEnd;
void advanceToNextWordInDawg();
void advanceToNextWordInSet();
void advanceToNextEdge();
public:
iterator() {
this->lp = NULL;
}
iterator(const Lexicon *lp, bool endFlag) {
this->lp = lp;
if (endFlag) {
index = lp->size();
} else {
index = 0;
edgePtr = NULL;
setIterator = lp->otherWords.begin();
setEnd = lp->otherWords.end();
currentDawgPrefix = "";
currentSetWord = "";
advanceToNextWordInDawg();
advanceToNextWordInSet();
}
}
iterator(const iterator & it) {
lp = it.lp;
index = it.index;
currentDawgPrefix = it.currentDawgPrefix;
currentSetWord = it.currentSetWord;
edgePtr = it.edgePtr;
stack = it.stack;
setIterator = it.setIterator;
}
iterator & operator++() {
if (edgePtr == NULL) {
advanceToNextWordInSet();
} else {
if (currentSetWord == "" || currentDawgPrefix < currentSetWord) {
advanceToNextWordInDawg();
} else {
advanceToNextWordInSet();
}
}
index++;
return *this;
}
iterator operator++(int) {
iterator copy(*this);
operator++();
return copy;
}
bool operator==(const iterator & rhs) {
return lp == rhs.lp && index == rhs.index;
}
bool operator!=(const iterator & rhs) {
return !(*this == rhs);
}
std::string operator*() {
if (edgePtr == NULL) return currentSetWord;
if (currentSetWord == "" || currentDawgPrefix < currentSetWord) {
return currentDawgPrefix + lp->ordToChar(edgePtr->letter);
} else {
return currentSetWord;
}
}
std::string *operator->() {
if (edgePtr == NULL) return ¤tSetWord;
if (currentSetWord == "" || currentDawgPrefix < currentSetWord) {
tmpWord = currentDawgPrefix + lp->ordToChar(edgePtr->letter);
return &tmpWord;
} else {
return ¤tSetWord;
}
}
};
iterator begin() const {
return iterator(this, false);
}
iterator end() const {
return iterator(this, true);
}
private:
Edge *findEdgeForChar(Edge *children, char ch) const;
Edge *traceToLastEdge(const std::string & s) const;
void readBinaryFile(std::string filename);
void deepCopy(const Lexicon & src);
int countDawgWords(Edge *start) const;
unsigned int charToOrd(char ch) const {
return ((unsigned int)(tolower(ch) - 'a' + 1));
}
char ordToChar(unsigned int ord) const {
return ((char)(ord - 1 + 'a'));
}
};
template <typename FunctorType>
void Lexicon::mapAll(FunctorType fn) const {
foreach (std::string word in *this) {
fn(word);
}
}
// hashing functions for lexicons; defined in hashmap.cpp
int hashCode(const Lexicon& l);
#endif
| [
"joel.oscarsson@hotmail.com"
] | joel.oscarsson@hotmail.com |
76c5dca13597715ceb088f3592aa5f0a8606d0c9 | efb266771f94aeae71680beb9904db56bd7db413 | /include/caffe/layers/image_data_layer.hpp | 986c9a9a898e3f14e9f9b0eb61dc9926cdb40630 | [
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-generic-cla"
] | permissive | naibaf7/caffe | 3080a325f31b180a78a92076e7cd69a3be2285a8 | 29960153c828820b1abb55a5792283742f57caa2 | refs/heads/master | 2020-04-02T03:11:35.578860 | 2018-06-27T14:51:41 | 2018-06-27T14:51:41 | 34,186,808 | 91 | 30 | null | 2018-08-18T09:50:54 | 2015-04-18T23:29:30 | C++ | UTF-8 | C++ | false | false | 1,353 | hpp | #ifndef CAFFE_IMAGE_DATA_LAYER_HPP_
#define CAFFE_IMAGE_DATA_LAYER_HPP_
#include <string>
#include <utility>
#include <vector>
#include "caffe/blob.hpp"
#include "caffe/data_transformer.hpp"
#include "caffe/internal_thread.hpp"
#include "caffe/layer.hpp"
#include "caffe/layers/base_data_layer.hpp"
#include "caffe/proto/caffe.pb.h"
namespace caffe {
/**
* @brief Provides data to the Net from image files.
*
* TODO(dox): thorough documentation for Forward and proto params.
*/
template<typename Dtype, typename MItype, typename MOtype>
class ImageDataLayer
: public BasePrefetchingDataLayer<Dtype, MItype, MOtype> {
public:
explicit ImageDataLayer(const LayerParameter& param)
: BasePrefetchingDataLayer<Dtype, MItype, MOtype>(param) {}
virtual ~ImageDataLayer();
virtual void DataLayerSetUp(const vector<Blob<MItype>*>& bottom,
const vector<Blob<MOtype>*>& top);
virtual inline const char* type() const { return "ImageData"; }
virtual inline int_tp ExactNumBottomBlobs() const { return 0; }
virtual inline int_tp ExactNumTopBlobs() const { return 2; }
protected:
shared_ptr<Caffe::RNG> prefetch_rng_;
virtual void ShuffleImages();
virtual void load_batch(Batch<Dtype>* batch);
vector<pair<string, int_tp> > lines_;
int_tp lines_id_;
};
} // namespace caffe
#endif // CAFFE_IMAGE_DATA_LAYER_HPP_
| [
"fabian@m-tschopp.ch"
] | fabian@m-tschopp.ch |
47911bcd967e9e5af4c4197f1d4adc5831cb1cc1 | 385cb811d346a4d7a285fc087a50aaced1482851 | /IFHLC/2019/C9/J.cpp | e14661a2af219530760e1873fe7e2c6fb3081548 | [] | no_license | NoureldinYosri/competitive-programming | aa19f0479420d8d1b10605536e916f0f568acaec | 7739344404bdf4709c69a97f61dc3c0b9deb603c | refs/heads/master | 2022-11-22T23:38:12.853482 | 2022-11-10T20:32:28 | 2022-11-10T20:32:28 | 40,174,513 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,000 | cpp | #ifdef ACTIVE
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
typedef std::vector<int> vi;
typedef std::pair<int,int> pi;
typedef std::vector<pi> vp;
typedef long long ll;
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prArr(A,n,t) cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
template<class A,class B>
std::ostream& operator << (std::ostream& st,const std::pair<A,B> p) {
st << "(" << p.first << ", " << p.second << ")";
return st;
}
#define tc() int T; scanf("%d",&T); for(int t = 1;t <= T;t++)
using namespace std;
const int MAX = 10*1000;
int X[MAX],Y[MAX],n;
pi P[MAX];
ll cross(pi a,pi b,pi c) {
b.first -= a.first,b.second -= a.second;
c.first -= a.first,c.second -= a.second;
return b.first*(ll)c.second - b.second*(ll)c.first;
}
vi ord;
pi solve(pi A,pi B) {
pi ret(0,0);
loop(j,n) {
int i = ord[j];
ll s = cross(A,B,P[i]);
// cout << A << " " << B << " " << P[i] << ": " << s << endl;
if(s == 0) continue;
if(s > 0) ret.first = i+1;
else ret.second = i+1;
if(ret.first && ret.second) return ret;
}
return ret;
}
int main(){
#ifdef HOME
freopen("in.in", "r", stdin);
#endif
scanf("%d",&n);
loop(i,n){
scanf("%d %d",X + i,Y + i);
P[i] = pi(X[i],Y[i]);
ord.push_back(i);
}
int m; scanf("%d",&m);
pi A,B;
random_shuffle(all(ord));
loop(i,m) {
scanf("%d %d",&A.first,&A.second);
scanf("%d %d",&B.first,&B.second);
pi res = solve(A,B);
if(!res.first || !res.second) puts("0");
else printf("%d %d\n",res.first,res.second);
}
return 0;
}
#endif
| [
"noureldinyosri@gmail.com"
] | noureldinyosri@gmail.com |
278a6f5eaaa5bc7aa1c5ee990e0f7f965d362896 | 45f78ef0c270d16952d8db884278faa6691de399 | /codebase/apps/Radx/src/Radx2Grid/Args.cc | dbfb6e3c8f55877e9d6c658dcfbe81e3154689ff | [
"BSD-3-Clause"
] | permissive | bgin/lrose-core | 6da3e856c099cbb2fc273795653da39bee472869 | 2bff382ccaa9e927a922b2d545dd418a3ba791fc | refs/heads/master | 2021-06-09T05:33:52.806917 | 2016-11-17T13:13:38 | 2016-11-17T13:13:38 | 75,398,778 | 1 | 0 | null | 2016-12-02T13:39:13 | 2016-12-02T13:39:13 | null | UTF-8 | C++ | false | false | 7,951 | cc | // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
// ** Copyright UCAR (c) 1990 - 2016
// ** University Corporation for Atmospheric Research (UCAR)
// ** National Center for Atmospheric Research (NCAR)
// ** Boulder, Colorado, USA
// ** BSD licence applies - redistribution and use in source and binary
// ** forms, with or without modification, are permitted provided that
// ** the following conditions are met:
// ** 1) If the software is modified to produce derivative works,
// ** such modified software should be clearly marked, so as not
// ** to confuse it with the version available from UCAR.
// ** 2) Redistributions of source code must retain the above copyright
// ** notice, this list of conditions and the following disclaimer.
// ** 3) Redistributions in binary form must reproduce the above copyright
// ** notice, this list of conditions and the following disclaimer in the
// ** documentation and/or other materials provided with the distribution.
// ** 4) Neither the name of UCAR nor the names of its contributors,
// ** if any, may be used to endorse or promote products derived from
// ** this software without specific prior written permission.
// ** DISCLAIMER: THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
// ** OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
//////////////////////////////////////////////////////////
// Args.cc : command line args
//
// Mike Dixon, EOL, NCAR, P.O.Box 3000, Boulder, CO, 80307-3000, USA
//
// May 2012
//
//////////////////////////////////////////////////////////
#include "Args.hh"
#include "Params.hh"
#include <string>
#include <iostream>
#include <Radx/RadxTime.hh>
using namespace std;
// Constructor
Args::Args ()
{
TDRP_init_override(&override);
startTime = 0;
endTime = 0;
}
// Destructor
Args::~Args ()
{
TDRP_free_override(&override);
}
// parse the command line
//
// returns 0 on success, -1 on failure
int Args::parse (int argc, char **argv, string &prog_name)
{
_progName = prog_name;
char tmp_str[BUFSIZ];
bool OK = true;
// loop through args
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--") ||
!strcmp(argv[i], "-h") ||
!strcmp(argv[i], "-help") ||
!strcmp(argv[i], "-man")) {
_usage(cout);
exit (0);
} else if (!strcmp(argv[i], "-d") ||
!strcmp(argv[i], "-debug")) {
sprintf(tmp_str, "debug = DEBUG_NORM;");
TDRP_add_override(&override, tmp_str);
} else if (!strcmp(argv[i], "-v") ||
!strcmp(argv[i], "-verbose")) {
sprintf(tmp_str, "debug = DEBUG_VERBOSE;");
TDRP_add_override(&override, tmp_str);
} else if (!strcmp(argv[i], "-vv") ||
!strcmp(argv[i], "-extra")) {
sprintf(tmp_str, "debug = DEBUG_EXTRA;");
TDRP_add_override(&override, tmp_str);
} else if (!strcmp(argv[i], "-instance")) {
if (i < argc - 1) {
sprintf(tmp_str, "instance = %s;", argv[i+1]);
TDRP_add_override(&override, tmp_str);
}
} else if (!strcmp(argv[i], "-name_start")) {
sprintf(tmp_str, "name_file_from_start_time = TRUE;");
TDRP_add_override(&override, tmp_str);
} else if (!strcmp(argv[i], "-start")) {
if (i < argc - 1) {
startTime = RadxTime::parseDateTime(argv[++i]);
if (startTime == RadxTime::NEVER) {
OK = false;
} else {
sprintf(tmp_str, "mode = ARCHIVE;");
TDRP_add_override(&override, tmp_str);
}
} else {
OK = false;
}
} else if (!strcmp(argv[i], "-end")) {
if (i < argc - 1) {
endTime = RadxTime::parseDateTime(argv[++i]);
if (endTime == RadxTime::NEVER) {
OK = false;
} else {
sprintf(tmp_str, "mode = ARCHIVE;");
TDRP_add_override(&override, tmp_str);
}
} else {
OK = false;
}
} else if (!strcmp(argv[i], "-time_offset")) {
if (i < argc - 1) {
i++;
sprintf(tmp_str, "time_offset_secs = %s;", argv[i]);
TDRP_add_override(&override, tmp_str);
sprintf(tmp_str, "apply_time_offset = true;");
TDRP_add_override(&override, tmp_str);
} else {
OK = false;
}
} else if (!strcmp(argv[i], "-path") || !strcmp(argv[i], "-f")) {
if (i < argc - 1) {
// load up file list vector. Break at next arg which
// start with -
for (int j = i + 1; j < argc; j++) {
if (argv[j][0] == '-') {
break;
} else {
inputFileList.push_back(argv[j]);
}
}
sprintf(tmp_str, "mode = FILELIST;");
TDRP_add_override(&override, tmp_str);
} else {
OK = false;
}
} else if (!strcmp(argv[i], "-outdir")) {
if (i < argc - 1) {
sprintf(tmp_str, "output_dir = \"%s\";", argv[++i]);
TDRP_add_override(&override, tmp_str);
} else {
OK = false;
}
} else if (!strcmp(argv[i], "-outname")) {
if (i < argc - 1) {
sprintf(tmp_str, "output_filename = \"%s\";", argv[++i]);
TDRP_add_override(&override, tmp_str);
sprintf(tmp_str, "specify_output_filename = TRUE;");
TDRP_add_override(&override, tmp_str);
} else {
OK = false;
}
} else if (!strcmp(argv[i], "-vol_num")) {
if (i < argc - 1) {
i++;
sprintf(tmp_str, "starting_volume_number = %s;", argv[i]);
TDRP_add_override(&override, tmp_str);
sprintf(tmp_str, "override_volume_number = true;");
TDRP_add_override(&override, tmp_str);
} else {
OK = false;
}
} else if (!strcmp(argv[i], "-vol_num_auto")) {
if (i < argc - 1) {
i++;
sprintf(tmp_str, "starting_volume_number = %s;", argv[i]);
TDRP_add_override(&override, tmp_str);
sprintf(tmp_str, "autoincrement_volume_number = true;");
TDRP_add_override(&override, tmp_str);
} else {
OK = false;
}
}
} // i
// set fields if specified
if (!OK) {
_usage(cerr);
return -1;
}
return 0;
}
void Args::_usage(ostream &out)
{
out << "Usage: " << _progName << " [args as below]\n"
<< "Options:\n"
<< "\n"
<< " [ -h ] produce this list.\n"
<< "\n"
<< " [ -d, -debug ] print debug messages\n"
<< "\n"
<< " [ -end \"yyyy mm dd hh mm ss\"] end time\n"
<< " Sets mode to ARCHIVE\n"
<< "\n"
<< " [ -f, -paths ? ] set file paths\n"
<< " Sets mode to FILELIST\n"
<< "\n"
<< " [ -instance ?] specify the instance\n"
<< "\n"
<< " [ -name_start ] name file using start time\n"
<< "\n"
<< " [ -outdir ? ] set output directory\n"
<< "\n"
<< " [ -outname ? ] specify output file name\n"
<< " file of this name will be written to outdir\n"
<< "\n"
<< " [ -start \"yyyy mm dd hh mm ss\"] start time\n"
<< " Sets mode to ARCHIVE\n"
<< "\n"
<< " [ -time_offset ? ] set time offset (secs)\n"
<< "\n"
<< " [ -v, -verbose ] print verbose debug messages\n"
<< "\n"
<< " [ -vv, -extra ] print extra verbose debug messages\n"
<< "\n"
<< " [ -vol_num ? ] specify volume number\n"
<< " Overrides the volume number in the data\n"
<< "\n"
<< " [ -vol_num_auto ? ] specify incrementing volume numbers,\n"
<< " starting at the number specified.\n"
<< " Overrides the volume number in the data\n"
<< "\n"
<< endl;
Params::usage(out);
}
| [
"dixon@ucar.edu"
] | dixon@ucar.edu |
e549cb48b0df77ed5df8d5c9daca09e2c472d599 | 8c0aa69b4a148f96bcdf4637329262d5227ddf08 | /include/goetia/sketches/sketch/vec/blaze/blazemark/blazemark/blitz/TVec6Mat6Mult.h | b27fbae9e737ae822ffb38fc963dac05696d286c | [
"BSD-3-Clause",
"MIT"
] | permissive | camillescott/goetia | edd42c80451a13d4d0ced2f6ddb4ed9cb9ac7c80 | db75dc0d87126c5ad20c35405699d89153f109a8 | refs/heads/main | 2023-04-12T15:30:48.253961 | 2022-03-25T00:23:39 | 2022-03-25T00:23:39 | 81,270,193 | 6 | 0 | MIT | 2022-04-01T21:40:58 | 2017-02-08T00:40:08 | C++ | UTF-8 | C++ | false | false | 3,040 | h | //=================================================================================================
/*!
// \file blazemark/blitz/TVec6Mat6Mult.h
// \brief Header file for the Blitz++ 6D transpose vector/matrix multiplication kernel
//
// Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD 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.
// 3. Neither the names of the Blaze development group 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 _BLAZEMARK_BLITZ_TVEC6MAT6MULT_H_
#define _BLAZEMARK_BLITZ_TVEC6MAT6MULT_H_
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <blazemark/system/Types.h>
namespace blazemark {
namespace blitz {
//=================================================================================================
//
// KERNEL FUNCTIONS
//
//=================================================================================================
//*************************************************************************************************
/*!\name Blitz++ kernel functions */
//@{
double tvec6mat6mult( size_t N, size_t steps );
//@}
//*************************************************************************************************
} // namespace blitz
} // namespace blazemark
#endif
| [
"noreply@github.com"
] | noreply@github.com |
fd57890c46bc95dafbd4738d3fbfc469e16cb9a7 | 77c736924a8a377ffbe625721b03a1093b58982a | /sort-transformed-array.cpp | cc8f4cf56316bde33a273477f4041f488f74843c | [] | no_license | ppriyasingh/AlgorithmsLibrary | 4a475091425aa39c08ddb37e0c15e9131505e4c1 | 90e39449df2638e65bfb56f0a163df33370755c8 | refs/heads/master | 2022-12-30T15:23:57.618795 | 2020-10-03T11:42:04 | 2020-10-03T11:42:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,743 | cpp | // Given a sorted array of integers nums and integer values a, b and c. Apply a quadratic function of the form f(x) = ax2 + bx + c to each element x in the array.
// The returned array must be in sorted order.
// Expected time complexity: O(n)
// Example 1:
// Input: nums = [-4,-2,2,4], a = 1, b = 3, c = 5
// Output: [3,9,15,33]
// Example 2:
// Input: nums = [-4,-2,2,4], a = -1, b = 3, c = 5
// Output: [-23,-5,1,7]
the problem seems to have many cases a>0, a=0,a<0, (when a=0, b>0, b<0). However, they can be combined into just 2 cases: a>0 or a<0
1.a>0, two ends in original array are bigger than center if you learned middle school math before.
2.a<0, center is bigger than two ends.
so use two pointers i, j and do a merge-sort like process. depending on sign of a, you may want to start from the beginning or end of the transformed array. For a==0 case, it does not matter what b's sign is.
The function is monotonically increasing or decreasing. you can start with either beginning or end.
public class Solution {
public int[] sortTransformedArray(int[] nums, int a, int b, int c) {
int n = nums.length;
int[] sorted = new int[n];
int i = 0, j = n - 1;
int index = a >= 0 ? n - 1 : 0;
while (i <= j) {
if (a >= 0) {
sorted[index--] = quad(nums[i], a, b, c) >= quad(nums[j], a, b, c) ? quad(nums[i++], a, b, c) : quad(nums[j--], a, b, c);
} else {
sorted[index++] = quad(nums[i], a, b, c) >= quad(nums[j], a, b, c) ? quad(nums[j--], a, b, c) : quad(nums[i++], a, b, c);
}
}
return sorted;
}
private int quad(int x, int a, int b, int c) {
return a * x * x + b * x + c;
}
} | [
"pawkumar@microsoft.com"
] | pawkumar@microsoft.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.