blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
072243ffb3427e608c97cb5bffadb5ed376cf3e7
375ee821d2cebf8398aa61784d94883f519dffc8
/data_structure/create_combinations.cpp
6e488a5249111366bda85381c07995802d8e8b4a
[]
no_license
iam-hitesh/Programming
837883ff25482ff7aa3c886fa7f4ae8140a8c001
d33c2b62a9685d1ba1d706b088f4a9265066fe48
refs/heads/master
2022-03-05T10:07:30.128237
2018-10-31T19:32:52
2018-10-31T19:32:52
102,463,080
3
3
null
2019-10-14T15:05:14
2017-09-05T09:38:07
C++
UTF-8
C++
false
false
1,045
cpp
#include <bits/stdc++.h> using namespace std; int main() { int no_of_cards, mod, target; cin >> no_of_cards >> mod >> target; vector<long long> A(no_of_cards + 1); for(int i = 1; i <= no_of_cards; i++) scanf("%lld", &A[i]); typedef vector <int> v_int; vector <v_int> no_of_combinations(no_of_cards + 1, v_int(mod + 1, 0)); for(int i = 1; i <= no_of_cards; i++) { for(int m = 0; m < mod; m++) { no_of_combinations[i][m] += no_of_combinations[i - 1][m]; //printf("f()") int product_m = (m*A[i])%mod; no_of_combinations[i][product_m] += no_of_combinations[i - 1][m]; //? 1 : 2*no_of_combinations[i - 1][product_m]); //printf("P %d x %lld = %d\n", m, A[i], product_m); } no_of_combinations[i][A[i]%mod]++; // for(int m = 0; m < mod; m++) printf("f(%d, %d) = %d\n", i, m, no_of_combinations[i][m]); } cout << no_of_combinations[no_of_cards][target]; return 0; }
[ "noreply@github.com" ]
iam-hitesh.noreply@github.com
6f6a3a9dc2eebfc4f1943e658698b30420bb687a
2ec3c51831ca29cd97fc50a28e2bfd10918ba296
/avr/cores/casper/HardwareSerial0.cpp
c4258d811a06b053d3bebd0c40d02abf5a420a0c
[]
no_license
coduino/coduino_boards
d845767bbf6429c3fbaab578753a3d6fb90f81e5
ca823a87493aef62ca31a433ceb0642cf7b0c3c2
refs/heads/master
2016-08-11T15:51:38.115652
2016-02-18T12:47:22
2016-02-18T12:47:22
52,006,436
0
0
null
null
null
null
UTF-8
C++
false
false
2,608
cpp
/* HardwareSerial0.cpp - Hardware serial library for Wiring Copyright (c) 2006 Nicholas Zambetti. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul Modified 14 August 2012 by Alarus Modified 3 December 2013 by Matthijs Kooijman */ #include "Arduino.h" #include "HardwareSerial.h" #include "HardwareSerial_private.h" // Each HardwareSerial is defined in its own file, sine the linker pulls // in the entire file when any element inside is used. --gc-sections can // additionally cause unused symbols to be dropped, but ISRs have the // "used" attribute so are never dropped and they keep the // HardwareSerial instance in as well. Putting each instance in its own // file prevents the linker from pulling in any unused instances in the // first place. #if defined(HAVE_HWSERIAL0) #if defined(USART_RX_vect) ISR(USART_RX_vect) #elif defined(USART0_RX_vect) ISR(USART0_RX_vect) #elif defined(USART_RXC_vect) ISR(USART_RXC_vect) // ATmega8 #else #error "Don't know what the Data Received vector is called for Serial" #endif { Serial._rx_complete_irq(); } #if defined(UART0_UDRE_vect) ISR(UART0_UDRE_vect) #elif defined(UART_UDRE_vect) ISR(UART_UDRE_vect) #elif defined(USART0_UDRE_vect) ISR(USART0_UDRE_vect) #elif defined(USART_UDRE_vect) ISR(USART_UDRE_vect) #else #error "Don't know what the Data Register Empty vector is called for Serial" #endif { Serial._tx_udr_empty_irq(); } #if defined(UBRRH) && defined(UBRRL) HardwareSerial Serial(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR); #else HardwareSerial Serial(&UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0); #endif // Function that can be weakly referenced by serialEventRun to prevent // pulling in this file if it's not otherwise used. uint8_t Serial0_available() { return Serial.available(); } #endif // HAVE_HWSERIAL0
[ "torworx@gmail.com" ]
torworx@gmail.com
dec02c27cb19dc23c547d9b5cb1afc9703382700
46d12703bc79140473a46bb7b063f25029a1b7fa
/LaFarra/Tienda.cpp
cec6064de4ba38d9b0280bf4d2ce81164aa81838
[]
no_license
Estefaniahurtadog12/POO
bcf8785e754e061b0cb07e8db1b4d813902d4b8b
d88e62f19df80b25fdedf53eca70dce4f52ddf46
refs/heads/main
2023-07-25T07:39:37.888812
2021-09-08T22:44:38
2021-09-08T22:44:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,952
cpp
#include <iostream> #include "Tienda.h" // Constructor por defecto Tienda::Tienda() { this->nombre = "La Farra"; this->contCodFactura = 1; TipoProducto licor("Licor", 0.19); TipoProducto snack("Snacks", 0.16); Producto productoUno(licor, "Cerveza", 2500, 1800, 100, 10); Producto productoDos(snack, "Papitas de limon margarita", 3000, 1000, 2, 50); Producto productoTres(snack, "Papitas de pollo margarita", 3000, 1000, 3, 50); // Inicializar valores de la tienda this->inventario[productoUno.getCodigo()] = productoUno; this->inventario[productoDos.getCodigo()] = productoDos; this->inventario[productoTres.getCodigo()] = productoTres; } bool Tienda::existeProductoPorCod(int codigo) { // True si el mapa retorna un iterador diferente al iterador de fin de contenedor, esto significa // que existe. False en caso contrario. if (this->inventario.find(codigo) != this->inventario.end()) { return true; } else { return false; } } void Tienda::agregarProducto() { string nombre; float costo; float precio; int codigo; cout << "Ingrese el nombre del producto : "; getline(cin, nombre); // Mejor instruccion para recibir cadenas do { cout << "Ingrese el costo de compra del producto : "; cin >> costo; cout << "Ingrese el precio al que va a vender el producto : "; cin >> precio; } while (costo < 0 || precio < 0); bool existeProducto = true; // controlara que no existan productos con codigo repetido do { cout << "Ingrese la identificacion del producto : "; cin >> codigo; if (existeProductoPorCod(codigo)) { existeProducto = false; } } while (existeProducto); // Terminada la validacion se agrega el producto Producto productoTemp; productoTemp.setNombre(nombre); productoTemp.setCosto(costo); productoTemp.setPrecio(precio); productoTemp.setCodigo(codigo); // Adición al mapa de productos inventario[codigo] = productoTemp; // Tambien se puede inventario.insert(std::pair<int, Producto>(codigo, productoTemp)); } void Tienda::agregarDetalle(float &totalIVA, float &totalSinIVA, float &totalGeneral, Factura &factura) { int codigo, cantidad; // Se busca el producto en el inventario. //Se pregunta hasta que se encuentre un producto con el codigo ingresado do { cout << "Ingrese el codigoProductoComprar \n"; cin >> codigo; } while (!existeProductoPorCod(codigo)); // while(existeProductoPorCod(codigo) == false); // Se dispone de inventario para la venta Producto productoTemp = this->inventario[codigo]; // Se obtiene del mapa. Existe pq ya se hizo esta validacion do { cout << "Cuantos productos quiere comprar \n"; cin >> cantidad; } while (cantidad <= 0 || cantidad > productoTemp.getCantUnidades()); // Cuando falla // Hago la venta float valorPagarIvaProd = cantidad * productoTemp.getTipoProducto().getIva() * productoTemp.getPrecio(); float valorPagarSinIVAProd = productoTemp.getPrecio() * cantidad; float valorTotalProd = valorPagarIvaProd + valorPagarSinIVAProd; // Agregan los datos al detalle de venta, aprovecho el constructor DetalleFactura detalle(productoTemp, cantidad, valorPagarSinIVAProd, valorPagarIvaProd, valorTotalProd); // Agrega informacion a la factura factura.agregarDetalle(detalle); // Actualizar el acumulado total de la venta totalIVA += valorPagarIvaProd; totalGeneral += valorTotalProd; totalSinIVA += valorPagarSinIVAProd; // Disminuir a la cantidad de unidades vendidas al producto vendido this->inventario[codigo].setCantUnidades(productoTemp.getCantUnidades() - cantidad); } void Tienda::vender() { float totalIVA = 0, totalGeneral = 0; float totalSinIVA = 0; int opc = 0; Factura factura; string fecha; cout << "Ingrese la fecha de venta \n"; cin >> fecha; factura.setFecha(fecha); // Asigno el codigo a la factura y luego actualizo el contador factura.setCod(this->contCodFactura++); do { cout << "Ingrese 1 para continuar la venta -1 para terminar \n"; cin >> opc; if (opc != -1) { // Se llama otra funcion que controla la adicion de productos // paso de parametros por referencia agregarDetalle(totalIVA, totalGeneral, totalSinIVA, factura); } } while (opc != -1); // -1 termina la venta // Se agregan los valores totales factura.setValorPagarSinIVA(totalSinIVA); factura.setValorTotalIVA(totalIVA); factura.setValorTotal(totalGeneral); // Se adiciona la factura a la coleccion para tener la lista de facturas facturas.push_back(factura); } void Tienda::mostrarFacturas() { for (vector<Factura>::iterator pFactura = facturas.begin(); pFactura != facturas.end(); pFactura++) { pFactura->mostrarFactura(); } } void Tienda::mostrarProductos() { for (map<int, Producto>::iterator pProducto = inventario.begin(); pProducto != inventario.end(); pProducto++) { Producto valor = pProducto->second; // Se obtiene el valor asociado al mapa valor.mostrarProducto(); } } string Tienda::getNombre() { return nombre; }
[ "lufe089@gmail.com" ]
lufe089@gmail.com
80fc147cb0e2b8f13d23b8e6f80193c12698df34
757f94f197c14c918f8038b262b45d90ad79c1d3
/src/params.hpp
91356ec2a2a6c397fde36c390d0b459de8d4ee59
[]
no_license
anhuipl2010/YOLOV3_ECO_tracking
5b9e90149d337831493df59cd9770e0a0f2b1176
3bc5b8626a54cd59c0d2922378a2caf9456d48f3
refs/heads/master
2020-06-23T23:50:43.278396
2019-04-01T02:49:39
2019-04-01T02:49:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,232
hpp
#ifndef PARAMS_H #define PARAMS_H #include <vector> #include <string> using std::vector; using std::string; //**** hog parameters cofiguration ***** struct hog_params { int cell_size; int compressed_dim; int nOrients; size_t nDim; float penalty; }; struct cn_params { bool use_cn; int cell_size; int compressed_dim; int nOrients; size_t nDim; float penalty; }; struct hog_feature { hog_params fparams; cv::Size img_input_sz; //*** input sample size ****** cv::Size img_sample_sz; //*** the size of sample ******* cv::Size data_sz_block1; //**** hog feature ***** }; struct cn_feature { cn_params fparams; cv::Size img_input_sz; //*** input sample size ****** cv::Size img_sample_sz; //*** the size of sample ******* cv::Size data_sz_block1; //**** hog feature ***** }; //*** ECO parameters configuration ***** struct eco_params { cn_feature cn_feat; hog_feature hog_feat; //***** img sample parameters ***** float search_area_scale; int min_image_sample_size; int max_image_sample_size; //***** Detection parameters ***** int refinement_iterations; // Number of iterations used to refine the resulting position in a frame int newton_iterations ; // The number of Newton iterations used for optimizing the detection score bool clamp_position; // Clamp the target position to be inside the image bool visualization; //***** Learning parameters float output_sigma_factor; // Label function sigma float learning_rate ; // Learning rate size_t nSamples; // Maximum number of stored training samples string sample_replace_strategy; // Which sample to replace when the memory is full bool lt_size; // The size of the long - term memory(where all samples have equal weight) int train_gap; // The number of intermediate frames with no training(0 corresponds to training every frame) int skip_after_frame; // After which frame number the sparse update scheme should start(1 is directly) bool use_detection_sample; // Use the sample that was extracted at the detection stage also for learning // Regularization window parameters bool use_reg_window; // Use spatial regularization or not double reg_window_min; // The minimum value of the regularization window double reg_window_edge; // The impact of the spatial regularization size_t reg_window_power; // The degree of the polynomial to use(e.g. 2 is a quadratic window) float reg_sparsity_threshold; // A relative threshold of which DFT coefficients that should be set to zero // Interpolation parameters string interpolation_method; // The kind of interpolation kernel float interpolation_bicubic_a; // The parameter for the bicubic interpolation kernel bool interpolation_centering; // Center the kernel at the feature sample bool interpolation_windowing; // Do additional windowing on the Fourier coefficients of the kernel // Scale parameters for the translation model // Only used if: params.use_scale_filter = false size_t number_of_scales ; // Number of scales to run the detector float scale_step; // The scale factor cv::Size init_sz; // Scale filter parameters bool use_scale_filter ; float scale_sigma_factor ; float scale_learning_rate ; int number_of_scales_filter ; int number_of_interp_scales; float scale_model_factor ; float scale_step_filter ; int scale_model_max_area ; string scale_feature ; string s_num_compressed_dim; float lambda ; bool do_poly_interp; //*** Conjugate Gradient parameters int CG_iter ; // The number of Conjugate Gradient iterations in each update after the first frame int init_CG_iter ; // The total number of Conjugate Gradient iterations used in the first frame int init_GN_iter ; // The number of Gauss - Newton iterations used in the first frame(only if the projection matrix is updated) bool CG_use_FR ; // Use the Fletcher - Reeves(true) or Polak - Ribiere(false) formula in the Conjugate Gradient bool CG_standard_alpha; // Use the standard formula for computing the step length in Conjugate Gradient int CG_forgetting_rate ; // Forgetting rate of the last conjugate direction float precond_data_param ; // Weight of the data term in the preconditioner float precond_reg_param ; // Weight of the regularization term in the preconditioner int precond_proj_param; // Weight of the projection matrix part in the preconditioner double projection_reg; // Regularization paremeter of the projection matrix }; #endif
[ "chengxinnn@outlook.com" ]
chengxinnn@outlook.com
fde340058c418c1ef72589852723eefcf3419bb7
ad6e3ddf624e444820972845ed70d84a7628dd0b
/Cpp/417.cpp
6470b8ab77817f17bf44bb428af3c92f702fe22d
[]
no_license
ZoeyeoZ/LeetCode-Program-Learning
4c1d422a0d10e03ebce4154a8a400f6523e0da22
5369d7ed4eaeaa95542244aad1bce598e01e1386
refs/heads/master
2021-07-13T18:27:43.634167
2019-01-27T00:33:48
2019-01-27T00:33:48
114,710,884
0
0
null
null
null
null
UTF-8
C++
false
false
1,550
cpp
//BFS class Solution { public: void helper(vector<vector<int>> matrix, vector<vector<bool>>& visited, queue<pair<int,int>>& q){ int n = matrix.size(); int m = matrix[0].size(); vector<vector<int>> moves={{-1,0},{0,-1},{1,0},{0,1}}; while (!q.empty()){ int x = q.front().first, y = q.front().second; q.pop(); for (auto move:moves){ int xx = x+move[0], yy = y+move[1]; if (xx<0 || xx>=n || yy<0 || yy>=m || visited[xx][yy] || matrix[xx][yy] < matrix[x][y]) continue; visited[xx][yy] = true; q.push(make_pair(xx,yy)); } } } vector<pair<int, int>> pacificAtlantic(vector<vector<int>>& matrix) { vector<pair<int, int>> ans; int n = matrix.size(); if (n==0) return ans; int m = matrix[0].size(); if (m==0) return ans; vector<vector<bool>> visited1(n,vector<bool>(m,false)); vector<vector<bool>> visited2(n,vector<bool>(m,false)); queue<pair<int,int>> q1, q2; for (int i=0;i<m;i++){ visited1[0][i] = true; q1.push(make_pair(0,i)); visited2[n-1][i] = true; q2.push(make_pair(n-1,i)); } for (int i=1;i<n;i++){ visited1[i][0] = true; q1.push(make_pair(i,0)); } for (int i=0;i<n-1;i++){ visited2[i][m-1] = true; q2.push(make_pair(i,m-1)); } helper(matrix, visited1, q1); helper(matrix, visited2, q2); for (int i=0;i<n;i++) for (int j=0;j<m;j++) if (visited1[i][j] && visited2[i][j]) ans.push_back(make_pair(i,j)); return ans; } };
[ "noreply@github.com" ]
ZoeyeoZ.noreply@github.com
f2d16dd925fc1595eee60be4f044e22d48e9625a
09d6ac331a06641136618c929970138cad1556b6
/include/yangavutil/video/YangYuvConvert.h
eae6a2fa5060710e2230f9104362483959ff6b4a
[ "MIT" ]
permissive
asdlei99/yangrecord2
2c69ef868922cc5153391561d9067f2d7c5b05b0
787eaca132df1e427f5fc5b4391db1436d481088
refs/heads/main
2023-06-27T10:14:04.303066
2021-07-28T11:47:14
2021-07-28T11:47:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,874
h
/* * YangYuvUtil.h * * Created on: 2020年10月8日 * Author: yang */ #ifndef YangYuvConvert_H_ #define YangYuvConvert_H_ //#include "yangutil/yangtype.h" #include "stdint.h" #include "yangutil/sys/YangLoadLib.h" #include "libyuv.h" using namespace libyuv; class YangYuvConvert { public: YangYuvConvert(); virtual ~YangYuvConvert(); //void rgbtonv12(); int yuy2tonv12(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeiht); int yuy2toi420(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeiht); int i420tonv12(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeiht); int i420tonv21(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeiht); int bgr24toyuy2(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeiht); int rgb24toI420(uint8_t* src_rgb24,uint8_t *dst,int width,int height); //I420ToRGB24 int I420torgb24(uint8_t* src_rgb24,uint8_t *dst,int width,int height); int nv12torgb24(uint8_t* src_rgb24,uint8_t *dst,int width,int height); int nv21torgb24(uint8_t* src_rgb24,uint8_t *dst,int width,int height); int argbtorgb24(uint8_t* src_argb, uint8_t *dst,int width,int height); int rgb24toargb(uint8_t *src_rgb24, uint8_t *dst, int width,int height); int scaleNv12(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeight,int dstWidth,int dstHeight,int mode=2); int scaleI420(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeight,int dstWidth,int dstHeight,int mode=2); int scaleYuy2(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeight,int dstWidth,int dstHeight,int mode=2); int scaleRgb(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeight,int dstWidth,int dstHeight,int mode=2); int scaleArgb(uint8_t* src,uint8_t *dst,int srcWidth,int srcHeight,int dstWidth,int dstHeight,int mode=2); private: YangLoadLib m_lib; void loadLib(); void unloadLib(); //I420ToNV12 int (*yang_YUY2ToNV12)(const uint8_t* src_yuy2, int src_stride_yuy2, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_uv, int dst_stride_uv, int width, int height); int (*yang_YUY2ToI420)(const uint8_t* src_yuy2, int src_stride_yuy2, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height); int (*yang_I420ToNV12)(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_uv, int dst_stride_uv, int width, int height); int (*yang_I420ToNV21)(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_vu, int dst_stride_vu, int width, int height); int (*yang_I420ToRGB24)(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_rgb24, int dst_stride_rgb24, int width, int height); int (*yang_NV12ToRGB24)(const uint8_t* src_y, int src_stride_y, const uint8_t* src_uv, int src_stride_uv, uint8_t* dst_rgb24, int dst_stride_rgb24, int width, int height); int (*yang_NV21ToRGB24)(const uint8_t* src_y, int src_stride_y, const uint8_t* src_vu, int src_stride_vu, uint8_t* dst_rgb24, int dst_stride_rgb24, int width, int height); int (*yang_ARGBToRGB24)(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_rgb24, int dst_stride_rgb24, int width, int height); int (*yang_RGB24ToARGB)(const uint8_t* src_rgb24, int src_stride_rgb24, uint8_t* dst_argb, int dst_stride_argb, int width, int height); int (*yang_RAWToARGB)(const uint8_t* src_raw, int src_stride_raw, uint8_t* dst_argb, int dst_stride_argb, int width, int height); int (*yang_RGB24ToI420)(const uint8_t* src_rgb24, int src_stride_rgb24, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height); int (*yang_NV12Scale)(const uint8_t* src_y, int src_stride_y, const uint8_t* src_uv, int src_stride_uv, int src_width, int src_height, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_uv, int dst_stride_uv, int dst_width, int dst_height, enum FilterMode filtering); int (*yang_I420Scale)(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, int src_width, int src_height, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int dst_width, int dst_height, enum FilterMode filtering); void (*yang_ScalePlane)(const uint8_t* src, int src_stride, int src_width, int src_height, uint8_t* dst, int dst_stride, int dst_width, int dst_height, enum FilterMode filtering); int (*yang_ARGBScale)(const uint8_t* src_argb, int src_stride_argb, int src_width, int src_height, uint8_t* dst_argb, int dst_stride_argb, int dst_width, int dst_height, enum FilterMode filtering); }; #endif /* YANGYUVUTIL_H_ */
[ "noreply@github.com" ]
asdlei99.noreply@github.com
76b9223868e81fdd7c6ac2f9382fa974d7ce3770
58bd6097e65226a63ad74a85303676b88db69ce1
/ControlTask_8/Task_8.cpp
43bab1940e89ba8573f16dce1a2441dc86a46a53
[]
no_license
WarBall/Tasks.Cpp
c50f334c12a846a9833c86307d8e62c9513573b0
f982ae09242b5c59752776711d1fa5503ed3e8c8
refs/heads/master
2023-06-28T12:40:38.857470
2021-08-01T19:52:07
2021-08-01T19:52:07
387,199,469
0
0
null
null
null
null
UTF-8
C++
false
false
226
cpp
#include "Time.h" #include <iostream> int main() { Time time1(1, 70, 63); time1.printTime(); Time time2(12, 53, 99); time2.printTime(); Time time3 = time3.addTime(time1, time2); time3.printTime(); }
[ "desik_t9@mail.ru" ]
desik_t9@mail.ru
9ba371fddc3727ed3dea4a092df61729b3a9dea1
be60bef9d1a71e4f3efaedd63115a45cd6346d1c
/ecommserver/app/http/httpserver/httpconnectionhandler.h
b85cd40a35dfa495892626b1103c353ff916e63e
[]
no_license
robertoborgesqt/ecommv1
73873abd4c50259a51c63a6382dd45e39d7b3f4b
0635092583790056b7c6ff6ce70a21a0e3a54abe
refs/heads/main
2023-07-10T07:07:20.434685
2021-08-24T20:19:03
2021-08-24T20:19:03
399,258,521
0
2
null
null
null
null
UTF-8
C++
false
false
3,245
h
/** @file @author Stefan Frings */ #ifndef HTTPCONNECTIONHANDLER_H #define HTTPCONNECTIONHANDLER_H #ifndef QT_NO_OPENSSL #include <QSslConfiguration> #endif #include <QTcpSocket> #include <QSettings> #include <QTimer> #include <QThread> #include "httpglobal.h" #include "httprequest.h" #include "httprequesthandler.h" namespace webserverspace { /** Alias type definition, for compatibility to different Qt versions */ #if QT_VERSION >= 0x050000 typedef qintptr tSocketDescriptor; #else typedef int tSocketDescriptor; #endif /** Alias for QSslConfiguration if OpenSSL is not supported */ #ifdef QT_NO_OPENSSL #define QSslConfiguration QObject #endif /** The connection handler accepts incoming connections and dispatches incoming requests to to a request mapper. Since HTTP clients can send multiple requests before waiting for the response, the incoming requests are queued and processed one after the other. <p> Example for the required configuration settings: <code><pre> readTimeout=60000 maxRequestSize=16000 maxMultiPartSize=1000000 </pre></code> <p> The readTimeout value defines the maximum time to wait for a complete HTTP request. @see HttpRequest for description of config settings maxRequestSize and maxMultiPartSize. */ class DECLSPEC HttpConnectionHandler : public QThread { Q_OBJECT Q_DISABLE_COPY(HttpConnectionHandler) public: /** Constructor. @param settings Configuration settings of the HTTP webserver @param requestHandler Handler that will process each incoming HTTP request @param sslConfiguration SSL (HTTPS) will be used if not NULL */ HttpConnectionHandler(QSettings* settings, HttpRequestHandler* requestHandler, QSslConfiguration* sslConfiguration=NULL); /** Destructor */ virtual ~HttpConnectionHandler(); /** Returns true, if this handler is in use. */ bool isBusy(); /** Mark this handler as busy */ void setBusy(); private: /** Configuration settings */ QSettings* settings; /** TCP socket of the current connection */ QTcpSocket* socket; /** Time for read timeout detection */ QTimer readTimer; /** Storage for the current incoming HTTP request */ HttpRequest* currentRequest; /** Dispatches received requests to services */ HttpRequestHandler* requestHandler; /** This shows the busy-state from a very early time */ bool busy; /** Configuration for SSL */ QSslConfiguration* sslConfiguration; /** Executes the threads own event loop */ void run(); /** Create SSL or TCP socket */ void createSocket(); public slots: /** Received from from the listener, when the handler shall start processing a new connection. @param socketDescriptor references the accepted connection. */ void handleConnection(tSocketDescriptor socketDescriptor); private slots: /** Received from the socket when a read-timeout occured */ void readTimeout(); /** Received from the socket when incoming data can be read */ void read(); /** Received from the socket when a connection has been closed */ void disconnected(); }; } // end of namespace #endif // HTTPCONNECTIONHANDLER_H
[ "rborges67@me.com" ]
rborges67@me.com
4ee03ce3de4d22a38b2891aa72d672d481af0a8a
331bb7bf14c3a4204f59b4bdb9ab714e4f693866
/OpenGL/src/VertexBuffer.cpp
75c72119d778e2dca653efa6f3303601b106cdd4
[]
no_license
woodsjs/cherno_opengl
1b37e0b3c238dfa0a897b9ac407ca69e795b182d
480ab1d1b57f5385c20508d12af4666e75e61ab3
refs/heads/main
2023-04-18T06:07:03.852238
2021-04-23T00:59:54
2021-04-23T00:59:54
352,333,020
0
0
null
null
null
null
UTF-8
C++
false
false
464
cpp
#include "VertexBuffer.h" VertexBuffer::VertexBuffer(const void* data, unsigned int size) { glGenBuffers(1, &m_RendererID); glBindBuffer(GL_ARRAY_BUFFER, m_RendererID); glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW); } VertexBuffer::~VertexBuffer() { glDeleteBuffers(1, &m_RendererID); } void VertexBuffer::Bind() const { glBindBuffer(GL_ARRAY_BUFFER, m_RendererID); } void VertexBuffer::Unbind() const { glBindBuffer(GL_ARRAY_BUFFER, 0); }
[ "jason@coder.haus" ]
jason@coder.haus
7ceb8ccafa2046a3b16f4ab9bb520658d97b6dca
5b641d7b69ba0d43bd224d19831ab67a5b101582
/talks/crosstalk/src/FindTwoPhoton/Class/FindTwoPhoton_DONT_TOUCH.cc
a926ba6ebca1b3157ed413ea56fd45af2e862373
[]
no_license
jpivarski-talks/1999-2006_gradschool-2
9d7a4e91bbde6dc7f472ea21253b32a0eca104e4
ca889b4d09814a226513e39625ae2f140c97b5d5
refs/heads/master
2022-11-19T11:37:55.623868
2020-07-25T01:19:32
2020-07-25T01:19:32
282,235,528
0
0
null
null
null
null
UTF-8
C++
false
false
1,329
cc
// -*- C++ -*- // // Package: FindTwoPhoton // Module: FindTwoPhoton_DONT_TOUCH // // Description: DONT TOUCH THIS FILE // // Definition of bind action // // Implementation: // // Author: Jim Pivarski // Created: Mon Jun 16 21:55:05 EDT 2003 // $Id$ // // Revision history // // $Log$ #include "Experiment/Experiment.h" // system include files #if defined(AMBIGUOUS_STRING_FUNCTIONS_BUG) #include <string> #endif /* AMBIGUOUS_STRING_FUNCTIONS_BUG */ // user include files #include "FindTwoPhoton/FindTwoPhoton.h" #include "Processor/Action.h" // STL classes // // constants, enums and typedefs // // ---- cvs-based strings (Id and Tag with which file was checked out) static const char* const kIdString = "$Id: processor_DONT_TOUCH.cc,v 1.5 1998/12/01 21:11:58 mkl Exp $"; static const char* const kTagString = "$Name: v06_08_00 $"; // // function definitions // // // static data member definitions // // // member functions // // ---------------- binding method to stream ------------------- void FindTwoPhoton::bind( ActionBase::ActionResult (FindTwoPhoton::*iMethod)( Frame& ), const Stream::Type& iStream ) { bindAction( iStream, new Action<FindTwoPhoton>( iMethod, this ) ); } // // const member functions // // // static member functions //
[ "jpivarski@gmail.com" ]
jpivarski@gmail.com
554fb872a22d12008556df7e9fcf6f65574ada85
782f5876711aecea8c414b5281d01290c626b2ab
/db/c.cc
ee8a4722b9c344bdf73af9f41ded5e69c93825e1
[ "BSD-3-Clause" ]
permissive
chronostore/leveldb
b1ca83755fbc053416bbaebc19a3c20364117665
fbe4e3af3f4e368e0779b6d75cd6005d67469aa2
refs/heads/master
2021-01-18T20:38:31.238871
2011-08-06T00:19:37
2011-08-06T00:19:37
2,127,531
1
1
null
null
null
null
UTF-8
C++
false
false
11,765
cc
// Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. #include "leveldb/c.h" #include <stdlib.h> #include <unistd.h> #include "leveldb/cache.h" #include "leveldb/comparator.h" #include "leveldb/db.h" #include "leveldb/env.h" #include "leveldb/iterator.h" #include "leveldb/options.h" #include "leveldb/status.h" #include "leveldb/write_batch.h" namespace leveldb { extern "C" { struct leveldb_t { DB* rep; }; struct leveldb_iterator_t { Iterator* rep; }; struct leveldb_writebatch_t { WriteBatch rep; }; struct leveldb_snapshot_t { const Snapshot* rep; }; struct leveldb_readoptions_t { ReadOptions rep; }; struct leveldb_writeoptions_t { WriteOptions rep; }; struct leveldb_options_t { Options rep; }; struct leveldb_cache_t { Cache* rep; }; struct leveldb_seqfile_t { SequentialFile* rep; }; struct leveldb_randomfile_t { RandomAccessFile* rep; }; struct leveldb_writablefile_t { WritableFile* rep; }; struct leveldb_logger_t { Logger* rep; }; struct leveldb_filelock_t { FileLock* rep; }; struct leveldb_comparator_t : public Comparator { void* state_; void (*destructor_)(void*); int (*compare_)( void*, const char* a, size_t alen, const char* b, size_t blen); const char* (*name_)(void*); virtual ~leveldb_comparator_t() { (*destructor_)(state_); } virtual int Compare(const Slice& a, const Slice& b) const { return (*compare_)(state_, a.data(), a.size(), b.data(), b.size()); } virtual const char* Name() const { return (*name_)(state_); } // No-ops since the C binding does not support key shortening methods. virtual void FindShortestSeparator(std::string*, const Slice&) const { } virtual void FindShortSuccessor(std::string* key) const { } }; struct leveldb_env_t { Env* rep; bool is_default; }; static bool SaveError(char** errptr, const Status& s) { assert(errptr != NULL); if (s.ok()) { return false; } else if (*errptr == NULL) { *errptr = strdup(s.ToString().c_str()); } else { // TODO(sanjay): Merge with existing error? free(*errptr); *errptr = strdup(s.ToString().c_str()); } return true; } static char* CopyString(const std::string& str) { char* result = reinterpret_cast<char*>(malloc(sizeof(char) * str.size())); memcpy(result, str.data(), sizeof(char) * str.size()); return result; } leveldb_t* leveldb_open( const leveldb_options_t* options, const char* name, char** errptr) { DB* db; if (SaveError(errptr, DB::Open(options->rep, std::string(name), &db))) { return NULL; } leveldb_t* result = new leveldb_t; result->rep = db; return result; } void leveldb_close(leveldb_t* db) { delete db->rep; delete db; } void leveldb_put( leveldb_t* db, const leveldb_writeoptions_t* options, const char* key, size_t keylen, const char* val, size_t vallen, char** errptr) { SaveError(errptr, db->rep->Put(options->rep, Slice(key, keylen), Slice(val, vallen))); } void leveldb_delete( leveldb_t* db, const leveldb_writeoptions_t* options, const char* key, size_t keylen, char** errptr) { SaveError(errptr, db->rep->Delete(options->rep, Slice(key, keylen))); } void leveldb_write( leveldb_t* db, const leveldb_writeoptions_t* options, leveldb_writebatch_t* batch, char** errptr) { SaveError(errptr, db->rep->Write(options->rep, &batch->rep)); } char* leveldb_get( leveldb_t* db, const leveldb_readoptions_t* options, const char* key, size_t keylen, size_t* vallen, char** errptr) { char* result = NULL; std::string tmp; Status s = db->rep->Get(options->rep, Slice(key, keylen), &tmp); if (s.ok()) { *vallen = tmp.size(); result = CopyString(tmp); } else { *vallen = 0; if (!s.IsNotFound()) { SaveError(errptr, s); } } return result; } leveldb_iterator_t* leveldb_create_iterator( leveldb_t* db, const leveldb_readoptions_t* options) { leveldb_iterator_t* result = new leveldb_iterator_t; result->rep = db->rep->NewIterator(options->rep); return result; } const leveldb_snapshot_t* leveldb_create_snapshot( leveldb_t* db) { leveldb_snapshot_t* result = new leveldb_snapshot_t; result->rep = db->rep->GetSnapshot(); return result; } void leveldb_release_snapshot( leveldb_t* db, const leveldb_snapshot_t* snapshot) { db->rep->ReleaseSnapshot(snapshot->rep); delete snapshot; } const char* leveldb_property_value( leveldb_t* db, const char* propname) { std::string tmp; if (db->rep->GetProperty(Slice(propname), &tmp)) { return CopyString(tmp); } else { return NULL; } } void leveldb_approximate_sizes( leveldb_t* db, int num_ranges, const char* const* range_start_key, const size_t* range_start_key_len, const char* const* range_limit_key, const size_t* range_limit_key_len, uint64_t* sizes) { Range* ranges = new Range[num_ranges]; for (int i = 0; i < num_ranges; i++) { ranges[i].start = Slice(range_start_key[i], range_start_key_len[i]); ranges[i].limit = Slice(range_limit_key[i], range_limit_key_len[i]); } db->rep->GetApproximateSizes(ranges, num_ranges, sizes); delete[] ranges; } void leveldb_destroy_db( const leveldb_options_t* options, const char* name, char** errptr) { SaveError(errptr, DestroyDB(name, options->rep)); } void leveldb_repair_db( const leveldb_options_t* options, const char* name, char** errptr) { SaveError(errptr, RepairDB(name, options->rep)); } void leveldb_iter_destroy(leveldb_iterator_t* iter) { delete iter->rep; delete iter; } unsigned char leveldb_iter_valid(const leveldb_iterator_t* iter) { return iter->rep->Valid(); } void leveldb_iter_seek_to_first(leveldb_iterator_t* iter) { iter->rep->SeekToFirst(); } void leveldb_iter_seek_to_last(leveldb_iterator_t* iter) { iter->rep->SeekToLast(); } void leveldb_iter_seek(leveldb_iterator_t* iter, const char* k, size_t klen) { iter->rep->Seek(Slice(k, klen)); } void leveldb_iter_next(leveldb_iterator_t* iter) { iter->rep->Next(); } void leveldb_iter_prev(leveldb_iterator_t* iter) { iter->rep->Prev(); } const char* leveldb_iter_key(const leveldb_iterator_t* iter, size_t* klen) { Slice s = iter->rep->key(); *klen = s.size(); return s.data(); } const char* leveldb_iter_value(const leveldb_iterator_t* iter, size_t* vlen) { Slice s = iter->rep->value(); *vlen = s.size(); return s.data(); } void leveldb_iter_get_error(const leveldb_iterator_t* iter, char** errptr) { SaveError(errptr, iter->rep->status()); } leveldb_writebatch_t* leveldb_writebatch_create() { return new leveldb_writebatch_t; } void leveldb_writebatch_destroy(leveldb_writebatch_t* b) { delete b; } void leveldb_writebatch_clear(leveldb_writebatch_t* b) { b->rep.Clear(); } void leveldb_writebatch_put( leveldb_writebatch_t* b, const char* key, size_t klen, const char* val, size_t vlen) { b->rep.Put(Slice(key, klen), Slice(val, vlen)); } void leveldb_writebatch_delete( leveldb_writebatch_t* b, const char* key, size_t klen) { b->rep.Delete(Slice(key, klen)); } void leveldb_writebatch_iterate( leveldb_writebatch_t* b, void* state, void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), void (*deleted)(void*, const char* k, size_t klen)) { class H : public WriteBatch::Handler { public: void* state_; void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen); void (*deleted_)(void*, const char* k, size_t klen); virtual void Put(const Slice& key, const Slice& value) { (*put_)(state_, key.data(), key.size(), value.data(), value.size()); } virtual void Delete(const Slice& key) { (*deleted_)(state_, key.data(), key.size()); } }; H handler; handler.state_ = state; handler.put_ = put; handler.deleted_ = deleted; b->rep.Iterate(&handler); } leveldb_options_t* leveldb_options_create() { return new leveldb_options_t; } void leveldb_options_destroy(leveldb_options_t* options) { delete options; } void leveldb_options_set_comparator( leveldb_options_t* opt, leveldb_comparator_t* cmp) { opt->rep.comparator = cmp; } void leveldb_options_set_create_if_missing( leveldb_options_t* opt, unsigned char v) { opt->rep.create_if_missing = v; } void leveldb_options_set_error_if_exists( leveldb_options_t* opt, unsigned char v) { opt->rep.error_if_exists = v; } void leveldb_options_set_paranoid_checks( leveldb_options_t* opt, unsigned char v) { opt->rep.paranoid_checks = v; } void leveldb_options_set_env(leveldb_options_t* opt, leveldb_env_t* env) { opt->rep.env = (env ? env->rep : NULL); } void leveldb_options_set_info_log(leveldb_options_t* opt, leveldb_logger_t* l) { opt->rep.info_log = (l ? l->rep : NULL); } void leveldb_options_set_write_buffer_size(leveldb_options_t* opt, size_t s) { opt->rep.write_buffer_size = s; } void leveldb_options_set_max_open_files(leveldb_options_t* opt, int n) { opt->rep.max_open_files = n; } void leveldb_options_set_cache(leveldb_options_t* opt, leveldb_cache_t* c) { opt->rep.block_cache = c->rep; } void leveldb_options_set_block_size(leveldb_options_t* opt, size_t s) { opt->rep.block_size = s; } void leveldb_options_set_block_restart_interval(leveldb_options_t* opt, int n) { opt->rep.block_restart_interval = n; } void leveldb_options_set_compression(leveldb_options_t* opt, int t) { opt->rep.compression = static_cast<CompressionType>(t); } leveldb_comparator_t* leveldb_comparator_create( void* state, void (*destructor)(void*), int (*compare)( void*, const char* a, size_t alen, const char* b, size_t blen), const char* (*name)(void*)) { leveldb_comparator_t* result = new leveldb_comparator_t; result->state_ = state; result->destructor_ = destructor; result->compare_ = compare; result->name_ = name; return result; } void leveldb_comparator_destroy(leveldb_comparator_t* cmp) { delete cmp; } leveldb_readoptions_t* leveldb_readoptions_create() { return new leveldb_readoptions_t; } void leveldb_readoptions_destroy(leveldb_readoptions_t* opt) { delete opt; } void leveldb_readoptions_set_verify_checksums( leveldb_readoptions_t* opt, unsigned char v) { opt->rep.verify_checksums = v; } void leveldb_readoptions_set_fill_cache( leveldb_readoptions_t* opt, unsigned char v) { opt->rep.fill_cache = v; } void leveldb_readoptions_set_snapshot( leveldb_readoptions_t* opt, const leveldb_snapshot_t* snap) { opt->rep.snapshot = (snap ? snap->rep : NULL); } leveldb_writeoptions_t* leveldb_writeoptions_create() { return new leveldb_writeoptions_t; } void leveldb_writeoptions_destroy(leveldb_writeoptions_t* opt) { delete opt; } void leveldb_writeoptions_set_sync( leveldb_writeoptions_t* opt, unsigned char v) { opt->rep.sync = v; } leveldb_cache_t* leveldb_cache_create_lru(size_t capacity) { leveldb_cache_t* c = new leveldb_cache_t; c->rep = NewLRUCache(capacity); return c; } void leveldb_cache_destroy(leveldb_cache_t* cache) { delete cache->rep; delete cache; } leveldb_env_t* leveldb_create_default_env() { leveldb_env_t* result = new leveldb_env_t; result->rep = Env::Default(); result->is_default = true; return result; } void leveldb_env_destroy(leveldb_env_t* env) { if (!env->is_default) delete env->rep; delete env; } } // end extern "C" }
[ "gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529" ]
gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529
1b6cbce5e974b84ac856721d2de0f84d61f350b5
ae8763b93c3c32ecb266891a85859c7e1b731f32
/WestWorld5/WestWorld5/Guest.cpp
d8bb67fde74e2522ec6b52dc00586e96f4795978
[]
no_license
Miapata/CSC215
98a6ade4a7355a21c489c1af97a8f1f09019f5cd
535bedab8822ad22c097cbc2d50882d75adef146
refs/heads/master
2020-03-17T20:39:26.933385
2018-06-28T06:44:36
2018-06-28T06:44:36
133,582,935
0
0
null
null
null
null
UTF-8
C++
false
false
180
cpp
#include "stdafx.h" #include "Guest.h" #include"Denizen.h" #include <iostream> using namespace std; void Guest::trueDeath() { cout << getName() << " is dying for reals!"<<endl; }
[ "MIAPATA@uat.edu" ]
MIAPATA@uat.edu
35dcd7c87f891b97031a7dfd764bc2a7db5d1a4d
a29a30550ce70f7fe7358bc2e91132b62721b383
/build/lin/obj/moc_pagemotorsettings.cpp
339940f38f7b59306ddbb135142dabe7bb8ef98f
[]
no_license
console-beaver/vesc_tool
2223cd0e119d3c6ea3b0d8388c6f5bfd09bb2e7e
ea1865aae233489a4298f97f5dabe8b34577e42e
refs/heads/master
2021-09-11T00:52:22.346906
2018-04-05T04:36:43
2018-04-05T04:36:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,565
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'pagemotorsettings.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.3) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../../pages/pagemotorsettings.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'pagemotorsettings.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.9.3. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_PageMotorSettings_t { QByteArrayData data[3]; char stringdata0[53]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_PageMotorSettings_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_PageMotorSettings_t qt_meta_stringdata_PageMotorSettings = { { QT_MOC_LITERAL(0, 0, 17), // "PageMotorSettings" QT_MOC_LITERAL(1, 18, 33), // "on_motorSetupWizardButton_cli..." QT_MOC_LITERAL(2, 52, 0) // "" }, "PageMotorSettings\0on_motorSetupWizardButton_clicked\0" "" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_PageMotorSettings[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 19, 2, 0x08 /* Private */, // slots: parameters QMetaType::Void, 0 // eod }; void PageMotorSettings::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { PageMotorSettings *_t = static_cast<PageMotorSettings *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->on_motorSetupWizardButton_clicked(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject PageMotorSettings::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_PageMotorSettings.data, qt_meta_data_PageMotorSettings, qt_static_metacall, nullptr, nullptr} }; const QMetaObject *PageMotorSettings::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *PageMotorSettings::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_PageMotorSettings.stringdata0)) return static_cast<void*>(this); return QWidget::qt_metacast(_clname); } int PageMotorSettings::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
[ "tlalexander@gmail.com" ]
tlalexander@gmail.com
7a03817bf52a3b08da9ad4cf2a6d8ad9f20750b2
5e8d200078e64b97e3bbd1e61f83cb5bae99ab6e
/main/source/src/protocols/pb_potential/SetupPoissonBoltzmannPotential.fwd.hh
d13b4af8a4652652811497c7128efab8c67b9885
[]
no_license
MedicaicloudLink/Rosetta
3ee2d79d48b31bd8ca898036ad32fe910c9a7a28
01affdf77abb773ed375b83cdbbf58439edd8719
refs/heads/master
2020-12-07T17:52:01.350906
2020-01-10T08:24:09
2020-01-10T08:24:09
232,757,729
2
6
null
null
null
null
UTF-8
C++
false
false
1,556
hh
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*- // vi: set ts=2 noet: // // (c) Copyright Rosetta Commons Member Institutions. // (c) This file is part of the Rosetta software suite and is made available under license. // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. // (c) For more information, see http://www.rosettacommons.org. Questions about this can be // (c) addressed to University of Washington CoMotion, email: license@uw.edu. /// @file protocols/pb_potential/PoissonBoltzmannPotential.fwd.hh /// @brief setupPoissonBoltzmannPotential class forward delcaration /// @author Sachko Honda (honda@apl.washington.edu) #ifndef INCLUDED_protocols_pb_potential_SetupPoissonBoltzmannPotential_FWD_HH #define INCLUDED_protocols_pb_potential_SetupPoissonBoltzmannPotential_FWD_HH #include <utility/pointer/owning_ptr.hh> #include <utility/pointer/access_ptr.hh> namespace core { namespace scoring { class SetupPoissonBoltzmannPotential; typedef utility::pointer::shared_ptr< SetupPoissonBoltzmannPotential > SetupPoissonBoltzmannPotentialOP; typedef utility::pointer::shared_ptr< SetupPoissonBoltzmannPotential const > SetupPoissonBoltzmannPotentialCOP; typedef utility::pointer::weak_ptr< SetupPoissonBoltzmannPotential > SetupPoissonBoltzmannPotentialAP; typedef utility::pointer::weak_ptr< SetupPoissonBoltzmannPotential const > SetupPoissonBoltzmannPotentialCAP; } } #endif // INCLUDED_protocols_pb_potential_SetupPoissonBoltzmannPotential_FWD_HH
[ "36790013+MedicaicloudLink@users.noreply.github.com" ]
36790013+MedicaicloudLink@users.noreply.github.com
3088533550dc4630d0250aa29e0a466826813625
645a7fdf468e107f62811de7a57b0be4b2c87936
/server/node_modules/opencv-build/opencv/build/modules/core/convert.vsx3.cpp
f5905361a3c341ec25e639880b68c5a151a3ad9b
[]
no_license
nnaboon/WebForRecNodejs
20acc1123f3473369b8f1a8456af0cbdf90bef22
83613dbb0515d8fb88c0871cd33fdc278d13b19c
refs/heads/main
2023-02-19T04:35:35.782345
2021-01-18T10:51:47
2021-01-18T10:51:47
330,635,487
0
0
null
null
null
null
UTF-8
C++
false
false
278
cpp
#include "/Users/naboon/Develop/wks/react_wks/camera_test2/server/node_modules/opencv-build/opencv/opencv/modules/core/src/precomp.hpp" #include "/Users/naboon/Develop/wks/react_wks/camera_test2/server/node_modules/opencv-build/opencv/opencv/modules/core/src/convert.simd.hpp"
[ "srisawasdina@gmail.com" ]
srisawasdina@gmail.com
55bf2cb666b28952b1f71e683b888c194760bc81
ec7acad8f079b37c5c855ceda374414240426e67
/eq-hmi20191219/dialog_truck_info.cpp
b935b62b6172c9f03fce833498baed279d98ca31
[]
no_license
chouer19/eqProj
145143e732608127776eaaf3aac755956a5ffbe7
0815fb46295ce70aafe8e1637863e2eb43e4d510
refs/heads/main
2023-06-30T12:51:26.200328
2021-08-02T01:42:14
2021-08-02T01:42:14
391,785,564
0
2
null
null
null
null
UTF-8
C++
false
false
2,755
cpp
#include "dialog_truck_info.h" #include "ui_dialog_truck_info.h" Dialog_truck_info::Dialog_truck_info(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog_truck_info) { ui->setupUi(this); QRect screenRect = QApplication::desktop()->availableGeometry(); move (screenRect.width()/2-this->width()/2, screenRect.height()/2-this->height()/2); this->setWindowFlags(Qt::FramelessWindowHint); timerId=startTimer(100); } Dialog_truck_info::~Dialog_truck_info() { delete ui; } void Dialog_truck_info::on_pushButton_stop_clicked() { Dialog_confirm *confirm =new Dialog_confirm(); SURRD_TRUCK_INFO_REQ _surrdTruckInfoReq=getSurrdTruckInfoReq(); QString _string =QString::fromStdString(_surrdTruckInfoReq.vehicleNum)+ "卡车紧急停车确认"; confirm->setConfirmInfo(_string); confirm->exec(); if(confirm->confirmed()) { SURRD_TRUCK_CTRL_REQ _surrTruckCtrlReq; _surrTruckCtrlReq.isNew=true; _surrTruckCtrlReq.vehicleNum=_surrdTruckInfoReq.vehicleNum; _surrTruckCtrlReq.ctrlType=0; sys->telecom->setSurrdTruckCtrlReq(_surrTruckCtrlReq); } else { } delete confirm; } void Dialog_truck_info::on_pushButton_close_clicked() { close(); } void Dialog_truck_info::timerEvent(QTimerEvent *event) { if(event->timerId()==timerId) { SURRD_TRUCK_INFO_REQ _surrdTruckInfoReq=getSurrdTruckInfoReq(); ui->label_vehicle_number->setText(QString::fromStdString(_surrdTruckInfoReq.vehicleNum)); getVehicleTask_respond_t _surrdTruckInfo=sys->telecom->getSurrdTruckInfo(); if(_surrdTruckInfo.code=="200") { ui->label_vehicle_task->setText(QString::fromStdString(_surrdTruckInfo.task_type)); ui->label_vehicle_load->setText(QString::fromStdString(_surrdTruckInfo.load_state)); } else { sys->telecom->setSurrdTruckInfoReq(_surrdTruckInfoReq); ui->label_vehicle_task->setText("获取中。。"); ui->label_vehicle_load->setText("获取中。。"); } } } void Dialog_truck_info::setSurrdTruckInfoReq(SURRD_TRUCK_INFO_REQ _surrdTruckInfoReq) { std::unique_lock<std::mutex> lck(m_mutex); surrdTruckInfoReq=_surrdTruckInfoReq; } SURRD_TRUCK_INFO_REQ Dialog_truck_info::getSurrdTruckInfoReq() { std::unique_lock<std::mutex> lck(m_mutex); return surrdTruckInfoReq; } SURRD_TRUCK_CTRL_REQ Dialog_truck_info::getSurrdTruckCtrlReq() { std::unique_lock<std::mutex> lck(m_mutex); return surrdTruckCtrlReq; } void Dialog_truck_info::setSurrdTruckCtrlReq(SURRD_TRUCK_CTRL_REQ _surrdTruckCtrlReq) { std::unique_lock<std::mutex> lck(m_mutex); surrdTruckCtrlReq=_surrdTruckCtrlReq; }
[ "xuec17@icloud.com" ]
xuec17@icloud.com
0c97e0e738c4e6054edb52fda21f9d19d57617f2
39c51a1d5e98e2761f9318fb080ec80ec2056c13
/Unit1.cpp
b3647f11e4e9d8a69be9775ec90f437fdd014363
[ "MIT" ]
permissive
EkaterinaNova/TRPO
1e38f7191d89f8f069651fde6fa83ff16d7d3fd5
a5f6866e6d8e12d749f27fb02ea37e4dc8a9b54a
refs/heads/main
2023-02-18T23:16:16.226204
2021-01-16T11:55:15
2021-01-16T11:55:15
322,257,309
0
0
null
null
null
null
UTF-8
C++
false
false
839
cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { Form1->Canvas->Brush->Color = clLime; Form1->Canvas->Pie(0,0, 20,20, 20,0, 0,0); Form1->Canvas->Brush->Color = clFuchsia; Form1->Canvas->Pie(40,40, 80,80, 0,0, 80,80); } //---------------------------------------------------------------------------
[ "noreply@github.com" ]
EkaterinaNova.noreply@github.com
672f637ddf95d63f52d9c0c9ec3368fce3b1c947
4220a8edb142338ac240e521705c8f3f99a151e9
/src/local_search.cpp
038c13eabdb7cb92798458bb3f60c5938d6612e3
[]
no_license
sergei-sl/CVRPTW-Solver
e4f80e8183b57a806190ee3f8527a13d46676907
0c91d2001ad0dd7b3bfb5ea750e5141adc69b552
refs/heads/master
2020-04-01T11:56:51.648718
2018-10-15T21:37:09
2018-10-15T21:37:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,798
cpp
#pragma once #include "local_search.h" #include <random> #include <algorithm> #include <iterator> bool TwoOpt(Problem& problem, Route& route) { if (route.size() < 4) return false; bool route_changed = false; for (size_t iteration = 0; iteration < 2; ++iteration) { label: bool change_made = false; Route best_route = route; Route old_route = route; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route.size() - 1; ++i) { for (size_t j = i + 1; j < route.size() - 1; ++j) { if (ProcedureTwoOpt(problem, route, i, j, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(route, false) || (problem.GetDistance(route) - problem.GetDistance(best_route) < -0.00001) ) { ProcedureTwoOpt(problem, route, i, j, gain, true); } else { best_gain = gain; change_made = true; route_changed = true; best_route = route; route = old_route; } } } } if (change_made) { route = best_route; goto label; } break; } return route_changed; } bool OrOpt(Problem& problem, Route& route) { if (route.size() < 4) return false; bool route_changed = false; for (size_t iteration = 0; iteration < 2; ++iteration) { label: bool change_made = false; Route best_route = route; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route.size() - 2; ++i) { for (size_t j = 1; j < route.size() - 1; ++j) { if (ProcedureOrOpt(problem, best_route, i, j, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(best_route, false)) { ProcedureOrOpt(problem, best_route, i, j, gain, true); } else { best_gain = gain; change_made = true; route_changed = true; } } } } if (change_made) { route = best_route; goto label; } break; } return route_changed; } bool Relocate(Problem& problem, Route& route1, Route& route2) { if (route1.size() < 3) return false; bool routes_changed = false; for (size_t iteration = 0; iteration < 2; ++iteration) { label: bool change_made = false; size_t best_index1 = -1; size_t best_index2 = -1; Route old_route1 = route1; Route old_route2 = route2; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route1.size() - 1; ++i) { for (size_t j = 0; j < route2.size() - 1; ++j) { if (ProcedureRelocate(problem, route1, route2, i, j, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(route1, true) || !problem.IsFeasible(route2, true)) { ProcedureRelocate(problem, route1, route2, i, j, gain, false, true); } else { best_gain = gain; best_index1 = i; best_index2 = j; change_made = true; routes_changed = true; route1 = old_route1; route2 = old_route2; } } } } if (change_made) { ProcedureRelocate(problem, route1, route2, best_index1, best_index2, gain); goto label; } break; } return routes_changed; } bool Exchange(Problem& problem, Route& route1, Route& route2) { if (route1.size() < 3 || route2.size() < 3) return false; bool routes_changed = false; for (size_t iteration = 0; iteration < 2; ++iteration) { label: bool change_made = false; size_t best_index1 = -1; size_t best_index2 = -1; Route old_route1 = route1; Route old_route2 = route2; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route1.size() - 1; ++i) { for (size_t j = 1; j < route2.size() - 1; ++j) { if (ProcedureExchange(problem, route1, route2, i, j, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(route1, true) || !problem.IsFeasible(route2, true) || (problem.GetDistance(route1) - problem.GetDistance(old_route1) + problem.GetDistance(route2) - problem.GetDistance(old_route2) < -0.00001)) { ProcedureExchange(problem, route1, route2, i, j, gain, false, true); } else { best_gain = gain; best_index1 = i; best_index2 = j; change_made = true; routes_changed = true; route1 = old_route1; route2 = old_route2; } } } } if (change_made) { ProcedureExchange(problem, route1, route2, best_index1, best_index2, gain); goto label; } break; } return routes_changed; } bool CrossExchange(Problem& problem, Route& route1, Route& route2) { if (route1.size() < 3 || route2.size() < 3 || route1.size() < 4 && route2.size() < 4) return false; bool routes_changed = false; for (size_t segment_size2 = 5; segment_size2 >= 2; --segment_size2) { for (size_t segment_size1 = segment_size2; segment_size1 >= 1; --segment_size1) { label: bool change_made = false; size_t best_index1 = -1; size_t best_index2 = -1; Route old_route1 = route1; Route old_route2 = route2; double best_gain = 0.0; double gain = 0.0; for (size_t i = 1; i < route1.size() - 1; ++i) { for (size_t j = 1; j < route2.size() - 1; ++j) { if (ProcedureCrossExchange(problem, route1, route2, i, j, segment_size1, segment_size2, gain)) { if ((best_gain - gain) > 0.0001 || !problem.IsFeasible(route1, true) || !problem.IsFeasible(route2, true)) { ProcedureCrossExchange(problem, route1, route2, i, j, segment_size1, segment_size2, gain, true); } else { best_gain = gain; best_index1 = i; best_index2 = j; change_made = true; routes_changed = true; route1 = old_route1; route2 = old_route2; } } } } if (change_made) { ProcedureCrossExchange(problem, route1, route2, best_index1, best_index2, segment_size1, segment_size2, gain); goto label; } break; } } return routes_changed; } bool LocalSearchTwoOpt(Problem& problem, Solution & solution) { bool change_made = false; for (auto& route : solution) { change_made |= TwoOpt(problem, route); } return change_made; } bool LocalSearchOrOpt(Problem& problem, Solution & solution) { bool change_made = false; for (auto& route : solution) { change_made |= OrOpt(problem, route); } return change_made; } bool LocalSearchRelocate(Problem& problem, Solution & solution) { size_t interations = 0; bool change_made = false; label: interations++; bool not_local_optimum = false; for (auto& route1 : solution) { for (auto& route2 : solution) { not_local_optimum |= Relocate(problem, route1, route2); } } if (not_local_optimum) { change_made = true; if (interations > solution.size()) goto label; } return change_made; } bool LocalSearchExchange(Problem& problem, Solution & solution) { size_t interations = 0; bool change_made = false; label: interations++; bool not_local_optimum = false; for (auto& route1 : solution) { for (auto& route2 : solution) { not_local_optimum |= Exchange(problem, route1, route2); } } if (not_local_optimum) { change_made = true; if (interations > 5) goto label; } return change_made; } bool LocalSearchCrossExchange(Problem& problem, Solution & solution) { size_t interations = 0; bool change_made = false; label: interations++; bool not_local_optimum = false; for (auto& route1 : solution) { for (auto& route2 : solution) { not_local_optimum |= CrossExchange(problem, route1, route2); } } if (not_local_optimum) { change_made = true; if (interations > 5) goto label; } return change_made; } bool MakeLocalSearchWithOperation(LocalSearchOperations operation_type, Problem& problem, Solution & solution) { switch (operation_type) { case LocalSearchOperations::OperationTwoOpt: return LocalSearchTwoOpt(problem, solution); case LocalSearchOperations::OperationOrOpt: return LocalSearchOrOpt(problem, solution); case LocalSearchOperations::OperationRelocate: return LocalSearchRelocate(problem, solution); case LocalSearchOperations::OperationExchange: return LocalSearchExchange(problem, solution); case LocalSearchOperations::OperationCrossExchange: return LocalSearchCrossExchange(problem, solution); default: return false; } } bool LocalSearch(Problem& problem, Solution & solution) { std::vector<LocalSearchOperations> operations; operations.push_back(LocalSearchOperations::OperationTwoOpt); operations.push_back(LocalSearchOperations::OperationOrOpt); operations.push_back(LocalSearchOperations::OperationExchange); operations.push_back(LocalSearchOperations::OperationRelocate); operations.push_back(LocalSearchOperations::OperationCrossExchange); std::random_device rd; std::mt19937 g(rd()); std::shuffle(operations.begin(), operations.end(), g); operations.push_back(LocalSearchOperations::OperationOrOpt); operations.push_back(LocalSearchOperations::OperationTwoOpt); bool modified = false; bool not_local_optimum = true; size_t iterations = 0; while (not_local_optimum && iterations<10) { iterations++; not_local_optimum = false; for (auto operation : operations) { not_local_optimum |= MakeLocalSearchWithOperation(operation, problem, solution); modified |= not_local_optimum; } std::shuffle(operations.begin(), operations.end(), g); } return modified; }
[ "sergeisl95@yandex.ru" ]
sergeisl95@yandex.ru
e32bc6caeff908c748c7e75c175d3b799a193365
45d300db6d241ecc7ee0bda2d73afd011e97cf28
/OTCDerivativesCalculatorModule/Project_Cpp/lib_static/FpmlSerialized/GenClass/fpml-asset-5-4/ExchangeTradedContract.hpp
0caca004b5482341cb751bd6a70aef3259407584
[]
no_license
fagan2888/OTCDerivativesCalculatorModule
50076076f5634ffc3b88c52ef68329415725e22d
e698e12660c0c2c0d6899eae55204d618d315532
refs/heads/master
2021-05-30T03:52:28.667409
2015-11-27T06:57:45
2015-11-27T06:57:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,577
hpp
// ExchangeTradedContract.hpp #ifndef FpmlSerialized_ExchangeTradedContract_hpp #define FpmlSerialized_ExchangeTradedContract_hpp #include <fpml-asset-5-4/ExchangeTraded.hpp> #include <built_in_type/XsdTypePositiveInteger.hpp> #include <built_in_type/XsdTypeString.hpp> #include <fpml-shared-5-4/AdjustableOrRelativeDate.hpp> namespace FpmlSerialized { class ExchangeTradedContract : public ExchangeTraded { public: ExchangeTradedContract(TiXmlNode* xmlNode); bool isMultiplier(){return this->multiplierIsNull_;} boost::shared_ptr<XsdTypePositiveInteger> getMultiplier(); std::string getMultiplierIDRef(){return multiplierIDRef_;} bool isContractReference(){return this->contractReferenceIsNull_;} boost::shared_ptr<XsdTypeString> getContractReference(); std::string getContractReferenceIDRef(){return contractReferenceIDRef_;} bool isExpirationDate(){return this->expirationDateIsNull_;} boost::shared_ptr<AdjustableOrRelativeDate> getExpirationDate(); std::string getExpirationDateIDRef(){return expirationDateIDRef_;} protected: boost::shared_ptr<XsdTypePositiveInteger> multiplier_; std::string multiplierIDRef_; bool multiplierIsNull_; boost::shared_ptr<XsdTypeString> contractReference_; std::string contractReferenceIDRef_; bool contractReferenceIsNull_; boost::shared_ptr<AdjustableOrRelativeDate> expirationDate_; std::string expirationDateIDRef_; bool expirationDateIsNull_; }; } //namespaceFpmlSerialized end #endif
[ "math.ansang@gmail.com" ]
math.ansang@gmail.com
987aad008647fc2fdf7521d2af939f718672595b
71a798687f8c83510cdc52ae769b71f31e5f95d0
/spoj/NHAY/main.cpp
3642d9a5f1150205694a915e00f370f618d73133
[]
no_license
shashank30071996/mycodes
210f59eaad81115898c044b85a2adeee3934155b
729010cd7ac77285f4c5b962f0ecd6e83096157a
refs/heads/master
2021-01-02T08:35:29.695258
2017-08-01T17:05:26
2017-08-01T17:05:26
99,024,466
0
0
null
null
null
null
UTF-8
C++
false
false
1,328
cpp
#include <bits/stdc++.h> using namespace std; void KMP(string pat,string txt,int m); void computelps(string pat,int *lps,int m); int main() { int m; string pat;string txt; while(scanf("%d",&m)!=EOF){ cin>>pat; cin>>txt; KMP(pat,txt,m); } } void KMP(string pat,string txt,int m) { int i=0,j=0;vector<int> loc; int lps[m]; computelps(pat,lps,m);int k=0; while(i<txt.length()) { if(txt[i]==pat[j]) { i++; j++; } if(j==m) { printf("%d\n",i-j); j=lps[j-1];k=1; loc.push_back(i-j); } else if(i<txt.length() && pat[j]!=txt[i]) { if(j!=0) j=lps[j-1]; else i=i+1; } } if(k==0) cout<<endl; cout<<endl; } void computelps(string pat,int *lps,int m) { int len=0; lps[0]=0; int i=1; while(i<m) { if(pat[len]==pat[i]) { len++; lps[i]=len;i++; } else{ if(len!=0) len=lps[len-1]; else { lps[i]=0;i++; } } } }
[ "singhshashank229@gmail.com" ]
singhshashank229@gmail.com
11ae714ac88a2569573f685843e77bfcfe0921d2
8f588242dc7ff6ff4e19d05022fea095b93fc070
/transportInc/System/construct/insertPlate.cxx
90ea9f23312c7bf1bd1e80f20e89ebb51a8819c5
[]
no_license
milocco/sinbad
fe768462b26b2cfa5f0bf4ea76d9ba211fb2fc13
60a9d3e6e4abf8f701a97ed4ba8b3c62d5d0c9b2
refs/heads/master
2021-01-15T23:11:57.499083
2016-02-14T23:31:59
2016-02-14T23:31:59
30,890,395
0
0
null
null
null
null
UTF-8
C++
false
false
9,120
cxx
/********************************************************************* CombLayer : MCNP(X) Input builder * File: construct/insertPlate.cxx * * Copyright (c) 2004-2015 by Stuart Ansell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ****************************************************************************/ #include <fstream> #include <iomanip> #include <iostream> #include <sstream> #include <cmath> #include <complex> #include <list> #include <vector> #include <set> #include <map> #include <string> #include <algorithm> #include <memory> #include "Exception.h" #include "FileReport.h" #include "GTKreport.h" #include "NameStack.h" #include "RegMethod.h" #include "OutputLog.h" #include "BaseVisit.h" #include "BaseModVisit.h" #include "support.h" #include "MatrixBase.h" #include "Matrix.h" #include "Vec3D.h" #include "Quaternion.h" #include "Surface.h" #include "surfIndex.h" #include "surfRegister.h" #include "objectRegister.h" #include "surfEqual.h" #include "Quadratic.h" #include "Plane.h" #include "Cylinder.h" #include "Line.h" #include "LineIntersectVisit.h" #include "Rules.h" #include "varList.h" #include "Code.h" #include "FuncDataBase.h" #include "HeadRule.h" #include "Object.h" #include "Qhull.h" #include "Simulation.h" #include "ModelSupport.h" #include "MaterialSupport.h" #include "generateSurf.h" #include "LinkUnit.h" #include "FixedComp.h" #include "ContainedComp.h" #include "insertPlate.h" namespace ModelSupport { insertPlate::insertPlate(const std::string& Key) : attachSystem::ContainedComp(),attachSystem::FixedComp(Key,6), ptIndex(ModelSupport::objectRegister::Instance().cell(Key)), cellIndex(ptIndex+31),populated(0), zAngle(0.0),xyAngle(0.0),defMat(0) /*! Constructor BUT ALL variable are left unpopulated. \param Key :: Name for item in search */ {} insertPlate::insertPlate(const insertPlate& A) : attachSystem::ContainedComp(A),attachSystem::FixedComp(A), ptIndex(A.ptIndex),cellIndex(A.cellIndex), populated(A.populated),zAngle(A.zAngle),xyAngle(A.xyAngle), width(A.width),height(A.height),depth(A.depth),defMat(A.defMat) /*! Copy constructor \param A :: insertPlate to copy */ {} insertPlate& insertPlate::operator=(const insertPlate& A) /*! Assignment operator \param A :: insertPlate to copy \return *this */ { if (this!=&A) { attachSystem::ContainedComp::operator=(A); attachSystem::FixedComp::operator=(A); cellIndex=A.cellIndex; populated=A.populated; zAngle=A.zAngle; xyAngle=A.xyAngle; width=A.width; height=A.height; depth=A.depth; defMat=A.defMat; } return *this; } insertPlate::~insertPlate() /*! Destructor */ {} void insertPlate::populate(const FuncDataBase& Control) /*! Populate all the variables \param Control :: Data Basex */ { ELog::RegMethod RegA("insertPlate","populate"); zAngle=Control.EvalVar<double>(keyName+"ZAngle"); xyAngle=Control.EvalVar<double>(keyName+"XYAngle"); width=Control.EvalVar<double>(keyName+"Width"); height=Control.EvalVar<double>(keyName+"Height"); depth=Control.EvalVar<double>(keyName+"Depth"); defMat=ModelSupport::EvalMat<int>(Control,keyName+"DefMat"); populated=1; return; } void insertPlate::createUnitVector(const Geometry::Vec3D& OG, const attachSystem::FixedComp& FC) /*! Create the unit vectors \param OG :: Origin \param LC :: LinearComponent to attach to */ { ELog::RegMethod RegA("insertPlate","createUnitVector"); FixedComp::createUnitVector(FC); createUnitVector(OG,X,Y,Z); return; } void insertPlate::createUnitVector(const Geometry::Vec3D& OG, const Geometry::Vec3D& XUnit, const Geometry::Vec3D& YUnit, const Geometry::Vec3D& ZUnit) /*! Create the unit vectors \param OG :: Origin \param XUnit :: Xdirection \param YUnit :: Xdirection \param ZUnit :: Xdirection */ { ELog::RegMethod RegA("insertPlate","createUnitVector<Vec>"); X=XUnit.unit(); Y=YUnit.unit(); Z=ZUnit.unit(); const Geometry::Quaternion Qz= Geometry::Quaternion::calcQRotDeg(zAngle,X); const Geometry::Quaternion Qxy= Geometry::Quaternion::calcQRotDeg(xyAngle,Z); Qz.rotate(Y); Qz.rotate(Z); Qxy.rotate(Y); Qxy.rotate(X); Qxy.rotate(Z); Origin=OG; return; } void insertPlate::createSurfaces() /*! Create all the surfaces */ { ELog::RegMethod RegA("insertPlate","createSurface"); ModelSupport::buildPlane(SMap,ptIndex+1,Origin-Y*depth/2.0,Y); ModelSupport::buildPlane(SMap,ptIndex+2,Origin+Y*depth/2.0,Y); ModelSupport::buildPlane(SMap,ptIndex+3,Origin-X*width/2.0,X); ModelSupport::buildPlane(SMap,ptIndex+4,Origin+X*width/2.0,X); ModelSupport::buildPlane(SMap,ptIndex+5,Origin-Z*height/2.0,Z); ModelSupport::buildPlane(SMap,ptIndex+6,Origin+Z*height/2.0,Z); return; } void insertPlate::createLinks() /*! Create link pointsx */ { ELog::RegMethod RegA("insertPlate","createLinks"); const double T[3]={depth,width,height}; const Geometry::Vec3D Dir[3]={Y,X,Z}; for(size_t i=0;i<6;i++) { const double SN((i%2) ? 1.0 : -1.0); FixedComp::setConnect(i,Origin+Dir[i/2]*T[i/2],Dir[i/2]*SN); FixedComp::setLinkSurf(i,SMap.realSurf(ptIndex+1+static_cast<int>(i))); } return; } void insertPlate::createObjects(Simulation& System) /*! Adds the Chip guide components \param System :: Simulation to create objects in */ { ELog::RegMethod RegA("insertPlate","createObjects"); std::string Out= ModelSupport::getComposite(SMap,ptIndex,"1 -2 3 -4 5 -6"); addOuterSurf(Out); if (defMat<0) System.addCell(MonteCarlo::Qhull(cellIndex++,0,0.0,Out)); else System.addCell(MonteCarlo::Qhull(cellIndex++,defMat,0.0,Out)); return; } void insertPlate::findObjects(const Simulation& System) /*! Insert the objects into the main simulation. It is separated from creation since we need to determine those object that need to have an exclude item added to them. \param System :: Simulation to add object to */ { ELog::RegMethod RegA("insertPlate","findObjects"); std::set<int> ICells; // Process all the corners MonteCarlo::Object* OPtr(System.findCell(Origin,0)); if (OPtr) ICells.insert(OPtr->getName()); for(int i=0;i<8;i++) { const double mX((i%2) ? -1.0 : 1.0); const double mY(((i>>1)%2) ? -1.0 : 1.0); const double mZ(((i>>2)%2) ? -1.0 : 1.0); Geometry::Vec3D TP(Origin); TP+=X*(mX*depth/2.0); TP+=Y*(mY*depth/2.0); TP+=Z*(mZ*depth/2.0); OPtr=System.findCell(TP,OPtr); if (OPtr) ICells.insert(OPtr->getName()); } for(const int IC : ICells) attachSystem::ContainedComp::addInsertCell(IC); return; } void insertPlate::setValues(const double XS,const double YS, const double ZS,const int Mat) /*! Set the values and populate flag \param XS :: X-size [width] \param YS :: Y-size [depth] \param ZS :: Z-size [height] \param Mat :: Material number */ { width=XS; depth=YS; height=ZS; defMat=Mat; populated=1; return; } void insertPlate::mainAll(Simulation& System) /*! Common part to createAll \param System :: Simulation */ { ELog::RegMethod RegA("insertPlate","mainAll"); createSurfaces(); createObjects(System); createLinks(); findObjects(System); insertObjects(System); return; } void insertPlate::createAll(Simulation& System,const Geometry::Vec3D& OG, const attachSystem::FixedComp& FC) /*! Generic function to create everything \param System :: Simulation item \param FC :: Linear component to set axis etc */ { ELog::RegMethod RegA("insertPlate","createAll"); if (!populated) populate(System.getDataBase()); createUnitVector(OG,FC); mainAll(System); return; } void insertPlate::createAll(Simulation& System,const Geometry::Vec3D& OG, const Geometry::Vec3D& Xunit, const Geometry::Vec3D& Yunit, const Geometry::Vec3D& Zunit) /*! Generic function to create everything \param System :: Simulation item \param OG :: Origin \param XUnit :: X-direction \param YUnit :: Y-direction \param ZUnit :: Z-direction */ { ELog::RegMethod RegA("insertPlate","createAll<vec>"); if (!populated) populate(System.getDataBase()); createUnitVector(OG,Xunit,Yunit,Zunit); mainAll(System); return; } } // NAMESPACE shutterSystem
[ "alberto.milocco@gmail.com" ]
alberto.milocco@gmail.com
24d0779ca65af0ea636b63ced2abdcf423599c5a
d1590021cb64d76623c5804d36cab12c24f1cb1a
/2020/day02.cpp
1bdf7286dff33f969a27f2b9f4d1793a73c0aee7
[]
no_license
evroon/adventofcode
697bff2650cfef2cc96e02aa303a539bfc74e4bd
ceffd754b2723dd3f7141eb754ab4384590e8a14
refs/heads/master
2022-12-13T12:53:45.298040
2022-12-06T21:32:09
2022-12-06T21:32:09
159,942,333
1
0
null
2022-11-09T18:13:25
2018-12-01T12:28:25
C++
UTF-8
C++
false
false
743
cpp
#include <iostream> #include <fstream> #include <stdlib.h> #include <vector> #include "manager.h" R day2_part2(std::ifstream& input) { std::string line; R occurences = 0; while (std::getline(input, line)) { int min = std::atoi(line.substr(0, line.find("-")).c_str()); std::string rest = line.substr(line.find("-")+1, line.size() - 1); int max = std::atoi(rest.substr(0, rest.find(" ")).c_str()); char c = rest.substr(rest.find(" ") + 1, rest.find(":") - 1)[0]; std::string password = line.substr(line.find(":") + 2, line.size() - 1); if ((password[min-1] == c) != (password[max-1] == c)) { occurences++; } } return occurences; } ADD_SOLUTION(2)
[ "erik.vroon22@gmail.com" ]
erik.vroon22@gmail.com
f026d8f08a6ae5356f4e5a6007780494f371e1b7
5963efb46c9bbef73ccb6744ab4a52b6ebd6b305
/Reference_Implementation/crypto_kem/ntru-hrss701/ntru01/enc/syn/systemc/AES256_ECB_ctx_RoundKey.h
fc1d50721fd864fc4fe8558fcce25335954f045b
[]
no_license
Deepsavani/Post-Quantum-Crypto---NTRU
a5c0324c0281a9890fc977eae55cc4432c5dd8bd
5494bd4af96998d4056a17ef425489cf45efbae7
refs/heads/master
2023-03-18T03:15:59.184060
2021-03-16T16:14:22
2021-03-16T16:14:22
348,408,223
0
0
null
null
null
null
UTF-8
C++
false
false
3,753
h
// ============================================================== // File generated on Sun Aug 23 21:46:48 EDT 2020 // Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC v2018.3 (64-bit) // SW Build 2405991 on Thu Dec 6 23:36:41 MST 2018 // IP Build 2404404 on Fri Dec 7 01:43:56 MST 2018 // Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // ============================================================== #ifndef __AES256_ECB_ctx_RoundKey_H__ #define __AES256_ECB_ctx_RoundKey_H__ #include <systemc> using namespace sc_core; using namespace sc_dt; #include <iostream> #include <fstream> struct AES256_ECB_ctx_RoundKey_ram : public sc_core::sc_module { static const unsigned DataWidth = 8; static const unsigned AddressRange = 240; static const unsigned AddressWidth = 8; //latency = 1 //input_reg = 1 //output_reg = 0 sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in <sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in<sc_logic> we0; sc_core::sc_in<sc_lv<DataWidth> > d0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in <sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in<sc_logic> we1; sc_core::sc_in<sc_lv<DataWidth> > d1; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; sc_lv<DataWidth> ram[AddressRange]; SC_CTOR(AES256_ECB_ctx_RoundKey_ram) { SC_METHOD(prc_write_0); sensitive<<clk.pos(); SC_METHOD(prc_write_1); sensitive<<clk.pos(); } void prc_write_0() { if (ce0.read() == sc_dt::Log_1) { if (we0.read() == sc_dt::Log_1) { if(address0.read().is_01() && address0.read().to_uint()<AddressRange) { ram[address0.read().to_uint()] = d0.read(); q0 = d0.read(); } else q0 = sc_lv<DataWidth>(); } else { if(address0.read().is_01() && address0.read().to_uint()<AddressRange) q0 = ram[address0.read().to_uint()]; else q0 = sc_lv<DataWidth>(); } } } void prc_write_1() { if (ce1.read() == sc_dt::Log_1) { if (we1.read() == sc_dt::Log_1) { if(address1.read().is_01() && address1.read().to_uint()<AddressRange) { ram[address1.read().to_uint()] = d1.read(); q1 = d1.read(); } else q1 = sc_lv<DataWidth>(); } else { if(address1.read().is_01() && address1.read().to_uint()<AddressRange) q1 = ram[address1.read().to_uint()]; else q1 = sc_lv<DataWidth>(); } } } }; //endmodule SC_MODULE(AES256_ECB_ctx_RoundKey) { static const unsigned DataWidth = 8; static const unsigned AddressRange = 240; static const unsigned AddressWidth = 8; sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in<sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in<sc_logic> we0; sc_core::sc_in<sc_lv<DataWidth> > d0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in<sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in<sc_logic> we1; sc_core::sc_in<sc_lv<DataWidth> > d1; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; AES256_ECB_ctx_RoundKey_ram* meminst; SC_CTOR(AES256_ECB_ctx_RoundKey) { meminst = new AES256_ECB_ctx_RoundKey_ram("AES256_ECB_ctx_RoundKey_ram"); meminst->address0(address0); meminst->ce0(ce0); meminst->q0(q0); meminst->we0(we0); meminst->d0(d0); meminst->address1(address1); meminst->ce1(ce1); meminst->q1(q1); meminst->we1(we1); meminst->d1(d1); meminst->reset(reset); meminst->clk(clk); } ~AES256_ECB_ctx_RoundKey() { delete meminst; } };//endmodule #endif
[ "deepsavani@deeps-mbp.myfiosgateway.com" ]
deepsavani@deeps-mbp.myfiosgateway.com
be2bb0f66c5a044b890db47d0bf81d0a13bea092
5105bdcb3fe6e73df70ebf77bb1a8343efb96425
/simd_helpers/simd_trimatrix.hpp
53c0ac5b2a32bcf07bcdbaed52d5d78ecae19860
[]
no_license
kmsmith137/simd_helpers
6b642040574bda8e4cddb4f138ed0349c56858bf
ba14240db3f6ff6d7dce824752076e208cf96140
refs/heads/master
2022-03-16T06:37:04.764112
2022-03-03T18:07:53
2022-03-03T18:07:53
75,947,098
4
1
null
2022-03-03T18:07:54
2016-12-08T14:55:18
C++
UTF-8
C++
false
false
7,426
hpp
#ifndef _SIMD_HELPERS_SIMD_TRIMATRIX_HPP #define _SIMD_HELPERS_SIMD_TRIMATRIX_HPP #if (__cplusplus < 201103) && !defined(__GXX_EXPERIMENTAL_CXX0X__) #error "This source file needs to be compiled with C++11 support (g++ -std=c++11)" #endif #include "core.hpp" #include "simd_ntuple.hpp" namespace simd_helpers { #if 0 } // pacify emacs c-mode #endif template<typename T, int S, int N> struct simd_trimatrix { simd_trimatrix<T,S,N-1> m; simd_ntuple<T,S,N> v; simd_trimatrix() { } simd_trimatrix(const simd_trimatrix<T,S,N-1> &m_, const simd_ntuple<T,S,N> &v_) : m(m_), v(v_) { } inline void setzero() { m.setzero(); v.setzero(); } inline void set_identity() { m.set_identity(); v.v.setzero(); v.x = 1; } inline void loadu(const T *p) { m.loadu(p); v.loadu(p+(N*(N-1)*S)/2); } inline void storeu(T *p) const { m.storeu(p); v.storeu(p+(N*(N-1)*S)/2); } inline simd_trimatrix<T,S,N> &operator+=(const simd_trimatrix<T,S,N> &t) { m += t.m; v += t.v; return *this; } inline simd_trimatrix<T,S,N> &operator-=(const simd_trimatrix<T,S,N> &t) { m -= t.m; v -= t.v; return *this; } inline simd_trimatrix<T,S,N> &operator*=(const simd_trimatrix<T,S,N> &t) { m *= t.m; v *= t.v; return *this; } inline simd_trimatrix<T,S,N> &operator/=(const simd_trimatrix<T,S,N> &t) { m /= t.m; v /= t.v; return *this; } inline simd_trimatrix<T,S,N> operator+(const simd_trimatrix<T,S,N> &t) const { simd_trimatrix<T,S,N> ret; ret.m = m + t.m; ret.v = v + t.v; return ret; } inline simd_trimatrix<T,S,N> operator-(const simd_trimatrix<T,S,N> &t) const { simd_trimatrix<T,S,N> ret; ret.m = m - t.m; ret.v = v - t.v; return ret; } inline simd_trimatrix<T,S,N> operator*(const simd_trimatrix<T,S,N> &t) const { simd_trimatrix<T,S,N> ret; ret.m = m * t.m; ret.v = v * t.v; return ret; } inline simd_trimatrix<T,S,N> operator/(const simd_trimatrix<T,S,N> &t) const { simd_trimatrix<T,S,N> ret; ret.m = m / t.m; ret.v = v / t.v; return ret; } // vertical_sum(): returns elementwise sum of all simd_t's in the triangular matrix inline simd_t<T,S> _vertical_sum(simd_t<T,S> x) const { return m._vertical_sum(x + v.vertical_sum()); } inline simd_t<T,S> vertical_sum() const { return m._vertical_sum(v.vertical_sum()); } inline void horizontal_sum_in_place() { m.horizontal_sum_in_place(); v.horizontal_sum_in_place(); } // sum(): returns sum of all scalar elements in the matrix inline T sum() const { return this->vertical_sum().sum(); } // In-register linear algebra inlines start here. inline simd_ntuple<T,S,N> multiply_symmetric(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret; ret.v = this->m.multiply_symmetric(t.v) + this->v.v * t.x; ret.x = this->v.vertical_dot(t); return ret; } inline void multiply_lower_in_place(simd_ntuple<T,S,N> &t) const { t.x = this->v.vertical_dot(t); this->m.multiply_lower_in_place(t.v); } inline void multiply_upper_in_place(simd_ntuple<T,S,N> &t) const { this->m.multiply_upper_in_place(t.v); t.v += this->v.v * t.x; t.x *= this->v.x; } inline void solve_lower_in_place(simd_ntuple<T,S,N> &t) const { this->m.solve_lower_in_place(t.v); t.x = this->v.v._vertical_dotn(t.v, t.x) / this->v.x; } inline void solve_upper_in_place(simd_ntuple<T,S,N> &t) const { t.x /= this->v.x; t.v -= this->v.v * t.x; this->m.solve_upper_in_place(t.v); } inline void cholesky_in_place() { m.cholesky_in_place(); m.solve_lower_in_place(v.v); simd_t<T,S> u = v.v._vertical_dotn(v.v, v.x); v.x = u.sqrt(); } inline void decholesky_in_place() { v.x = v.vertical_dot(v); m.multiply_lower_in_place(v.v); m.decholesky_in_place(); } // Returns 0xff.. if Cholesky factorization succeeded, 0 if poorly conditioned. inline smask_t<T,S> cholesky_in_place_checked(simd_t<T,S> epsilon) { smask_t<T,S> flags = m.cholesky_in_place_checked(epsilon); m.solve_lower_in_place(v.v); simd_t<T,S> u = v.v._vertical_dotn(v.v, v.x); simd_t<T,S> u0 = epsilon * v.x; flags = flags.bitwise_and(u.compare_gt(u0)); // This ensures that even when the Cholesky factorization is poorly conditioned, the // Cholesky factor can still be passed to solve_*_in_place() without generating NaN's u = blendv(flags, u, simd_t<T,S> (1.0)); v.x = u.sqrt(); return flags; } inline simd_ntuple<T,S,N> multiply_lower(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret = t; multiply_lower_in_place(ret); return ret; } inline simd_ntuple<T,S,N> multiply_upper(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret = t; multiply_upper_in_place(ret); return ret; } inline simd_ntuple<T,S,N> solve_lower(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret = t; solve_lower_in_place(ret); return ret; } inline simd_ntuple<T,S,N> solve_upper(const simd_ntuple<T,S,N> &t) const { simd_ntuple<T,S,N> ret = t; solve_upper_in_place(ret); return ret; } inline simd_trimatrix<T,S,N> cholesky() const { simd_trimatrix<T,S,N> ret = *this; ret.cholesky_in_place(); return ret; } inline simd_trimatrix<T,S,N> decholesky() const { simd_trimatrix<T,S,N> ret = *this; ret.decholesky_in_place(); return ret; } }; template<typename T, int S> struct simd_trimatrix<T,S,0> { inline void setzero() { } inline void loadu(const T *p) { } inline void storeu(T *p) const { } inline simd_trimatrix<T,S,0> &operator+=(const simd_trimatrix<T,S,0> &t) { return *this; } inline simd_trimatrix<T,S,0> &operator-=(const simd_trimatrix<T,S,0> &t) { return *this; } inline simd_trimatrix<T,S,0> &operator*=(const simd_trimatrix<T,S,0> &t) { return *this; } inline simd_trimatrix<T,S,0> &operator/=(const simd_trimatrix<T,S,0> &t) { return *this; } inline simd_trimatrix<T,S,0> operator+(const simd_trimatrix<T,S,0> &t) const { return simd_trimatrix<T,S,0>(); } inline simd_trimatrix<T,S,0> operator-(const simd_trimatrix<T,S,0> &t) const { return simd_trimatrix<T,S,0>(); } inline simd_trimatrix<T,S,0> operator*(const simd_trimatrix<T,S,0> &t) const { return simd_trimatrix<T,S,0>(); } inline simd_trimatrix<T,S,0> operator/(const simd_trimatrix<T,S,0> &t) const { return simd_trimatrix<T,S,0>(); } inline simd_t<T,S> _vertical_sum(simd_t<T,S> x) const { return x; } inline simd_ntuple<T,S,0> multiply_lower_in_place(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline simd_ntuple<T,S,0> multiply_upper_in_place(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline simd_ntuple<T,S,0> multiply_symmetric(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline simd_ntuple<T,S,0> solve_lower_in_place(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline simd_ntuple<T,S,0> solve_upper_in_place(const simd_ntuple<T,S,0> &t) const { return simd_ntuple<T,S,0> (); } inline void horizontal_sum_in_place() { } inline void cholesky_in_place() { } inline void decholesky_in_place() { } inline smask_t<T,S> cholesky_in_place_checked(simd_t<T,S> epsilon) { return smask_t<T,S>(-1); } }; } // namespace simd_helpers #endif // _SIMD_HELPERS_SIMD_TRIMATRIX_HPP
[ "kmsmith@perimeterinstitute.ca" ]
kmsmith@perimeterinstitute.ca
367bfd33f63c2a4e1e5d68067019fad2cff956d1
06d5fc42053e6449f8abc03ab2000267bf53c7ff
/ex8/boost.cpp
c5967b961233939dfe8c78d8fa61f51582dc8158
[]
no_license
GenosW/many_cores
15ce5733c2b8bdb8c1fa96d69d5bab719be1184b
cb0a36ecaccb9d8d6e8843416733de0b368abb0c
refs/heads/main
2023-02-21T23:23:05.757698
2021-01-24T13:27:22
2021-01-24T13:27:22
306,657,939
0
0
null
null
null
null
UTF-8
C++
false
false
4,304
cpp
#include <vector> #include <string> #include <algorithm> #include <numeric> #include <iostream> #include <fstream> #include <cstdlib> #include "timer.hpp" // boost #include <boost/compute/algorithm/transform.hpp> #include <boost/compute/algorithm/inner_product.hpp> #include <boost/compute/container/vector.hpp> #include <boost/compute/functional/math.hpp> namespace compute = boost::compute; // functions used: // inner_prod(): https://www.boost.org/doc/libs/1_65_1/libs/compute/doc/html/boost/compute/inner_product.html // DEFINES #define EX "ex8" #define CSV_NAME "ph_data_boost_ocl.csv" #define COUT #define NUM_TEST 5 #define N_MIN 10 #define N_MAX 10000000 //1e8 // //----------- Helper functions // template <template <typename, typename> class Container, typename ValueType, typename Allocator = std::allocator<ValueType>> double median(Container<ValueType, Allocator> data) { size_t size = data.size(); if (size == 0) return 0.; sort(data.begin(), data.end()); size_t mid = size / 2; return size % 2 == 0 ? (data[mid] + data[mid - 1]) / 2 : data[mid]; }; template <typename T> double median(T *array, size_t size) { if (size == 0) return 0.; sort(array, array + size); size_t mid = size / 2; return size % 2 == 0 ? (array[mid] + array[mid - 1]) / 2 : array[mid]; }; // //----------- functions for this program // double benchmark(compute::context& context, compute::command_queue& queue, size_t N, double x_init, double y_init, std::vector<double>& results) { Timer timer; timer.reset(); std::vector<double> x(N, x_init); std::vector<double> y(N, y_init); compute::vector<double> X(N, context); compute::vector<double> Y(N, context); compute::vector<double> TMP(N, context); compute::vector<double> TMP2(N, context); compute::copy(x.begin(), x.end(), X.begin(), queue); compute::copy(y.begin(), y.end(), Y.begin(), queue); results[0] = timer.get(); double dot; std::vector<double> tmp(NUM_TEST, 0.0); for (int iter = 0; iter < NUM_TEST; iter++) { timer.reset(); compute::transform(X.begin(), X.end(), Y.begin(), TMP.begin(), compute::plus<double>{}, queue); // I tried to reuse the vector X for the result of the last transform, // but it did not work properly. I assume, that the reason is that these // are asynchronous calls that can happen in parallel, // so it might happen that parts of X // are overwritten before the first is finished. // That seems weird... compute::transform(X.begin(), X.end(), Y.begin(), TMP2.begin(), compute::minus<double>{}, queue); dot = compute::inner_product(TMP.begin(), TMP.end(), TMP2.begin(), 0.0, queue); tmp[iter] = timer.get(); } results[1] = median(tmp); double true_dot = (x_init + y_init) * (x_init - y_init) * N; #ifdef COUT std::cout << "(x+y, x-y) = " << dot << " ?= " << true_dot << std::endl; std::cout << "Computation took " << results[1] << "s" << std::endl; #endif timer.reset(); results[3] = dot; results[2] = timer.get(); return dot; } int main(int argc, char const *argv[]) { // get default device and setup context compute::device device = compute::system::default_device(); compute::context context(device); std::cout << device.name() << std::endl; // print list of selected devices compute::command_queue queue(context, device); double x_init = 1., y_init = 2.; std::vector<double> results(4, 0.0); std::ofstream csv; std::string sep = ";"; std::string header = "N;vec_init_time;dot_time;memcpy_time;dot_result"; auto to_csv = [&csv, &sep] (double x) { csv << sep << x;}; csv.open(CSV_NAME, std::fstream::out | std::fstream::trunc); csv << header << std::endl; for (size_t N = N_MIN; N < 1+N_MAX; N*=10){ #ifdef COUT std::cout << "N: " << N << std::endl; #endif benchmark(context, queue, N, x_init, y_init, results); csv << N; std::for_each(results.begin(), results.end(), to_csv); csv << std::endl; } std::cout << "Data: https://gtx1080.360252.org/2020/" << EX << "/" << CSV_NAME; return EXIT_SUCCESS; }
[ "peter.anton.holzner@student.tuwien.ac.at" ]
peter.anton.holzner@student.tuwien.ac.at
78b3ead3b247720b2db601b5277611e02857d878
8ea53d45e88f919f94b7050bb2856e4d86d0329f
/Assignment4/bai4_1.cpp
48941a4bd4d383c26e8b209efd9cb2d9d16e5683
[]
no_license
newstar94/VyTDuong-LBEP
be4d53724743bd428330a7c6e475de43cb21a8b0
c47e9b6a99a340b8b10819eea40dce48d3afabcc
refs/heads/main
2023-05-08T07:39:49.930954
2021-06-05T09:04:22
2021-06-05T09:04:22
367,024,519
0
0
null
null
null
null
UTF-8
C++
false
false
152
cpp
#include <stdio.h> #include <math.h> int main(){ double s,n; s=0; n=0; while (n<100001){ s=s+n; n++; } printf("Tong day so la: %.0lf",s); }
[ "77623864+newstar94@users.noreply.github.com" ]
77623864+newstar94@users.noreply.github.com
c060a6b98f2ff592c9ae0a6eefd94a151e30fa43
772d932a0e5f6849227a38cf4b154fdc21741c6b
/CPP_Joc_Windows_Android/SH_Client_Win_Cpp_Cmake/App/src/base/component/IComponent_UIView.cpp
1241a87e5cc203a22966d56bd01ac8281f236116
[]
no_license
AdrianNostromo/CodeSamples
1a7b30fb6874f2059b7d03951dfe529f2464a3c0
a0307a4b896ba722dd520f49d74c0f08c0e0042c
refs/heads/main
2023-02-16T04:18:32.176006
2021-01-11T17:47:45
2021-01-11T17:47:45
328,739,437
0
0
null
null
null
null
UTF-8
C++
false
false
258
cpp
#include "IComponent_UIView.h" #include <base/exceptions/LogicException.h> #include "ComponentsHandler.h" int IComponent_UIView::COMPONENT_CATEGORY = GetNew_COMPONENT_CATEGORY(); int IComponent_UIView::getComponentCategory() { return COMPONENT_CATEGORY; }
[ "adriannostromo@gmail.com" ]
adriannostromo@gmail.com
1189e4b485078b58190df854540798cc7528d5e7
edfb435ee89eec4875d6405e2de7afac3b2bc648
/tags/selenium-2.0-rc-1/cpp/IEDriver/IEDriverServer.cpp
cd5570675f4124b69859e20a57c712fe7a4ff1b1
[ "Apache-2.0" ]
permissive
Escobita/selenium
6c1c78fcf0fb71604e7b07a3259517048e584037
f4173df37a79ab6dd6ae3f1489ae0cd6cc7db6f1
refs/heads/master
2021-01-23T21:01:17.948880
2012-12-06T22:47:50
2012-12-06T22:47:50
8,271,631
1
0
null
null
null
null
UTF-8
C++
false
false
22,307
cpp
// Copyright 2011 WebDriver committers // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "StdAfx.h" #include <regex> #include "IEDriverServer.h" #include "logging.h" namespace webdriver { IEDriverServer::IEDriverServer(int port) { // It's possible to set the log level at compile time using this: LOG::Level("FATAL"); LOG(INFO) << "Starting IE Driver server on port: " << port; this->port_ = port; this->PopulateCommandRepository(); } IEDriverServer::~IEDriverServer(void) { if (this->sessions_.size() > 0) { vector<std::wstring> session_ids; SessionMap::iterator it = this->sessions_.begin(); for (; it != this->sessions_.end(); ++it) { session_ids.push_back(it->first); } for (size_t index = 0; index < session_ids.size(); ++index) { this->ShutDownSession(session_ids[index]); } } } std::wstring IEDriverServer::CreateSession() { unsigned int thread_id = 0; HWND session_window_handle = NULL; HANDLE event_handle = ::CreateEvent(NULL, TRUE, FALSE, EVENT_NAME); HANDLE thread_handle = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, &Session::ThreadProc, reinterpret_cast<void*>(&session_window_handle), 0, &thread_id)); if (event_handle != NULL) { ::WaitForSingleObject(event_handle, INFINITE); ::CloseHandle(event_handle); } if (thread_handle != NULL) { ::CloseHandle(thread_handle); } ::SendMessage(session_window_handle, WD_INIT, static_cast<WPARAM>(this->port_), NULL); vector<TCHAR> window_text_buffer(37); ::GetWindowText(session_window_handle, &window_text_buffer[0], 37); std::wstring session_id = &window_text_buffer[0]; this->sessions_[session_id] = session_window_handle; return session_id; } void IEDriverServer::ShutDownSession(const std::wstring& session_id) { SessionMap::iterator it = this->sessions_.find(session_id); if (it != this->sessions_.end()) { DWORD process_id; DWORD thread_id = ::GetWindowThreadProcessId(it->second, &process_id); HANDLE thread_handle = ::OpenThread(SYNCHRONIZE, FALSE, thread_id); ::SendMessage(it->second, WM_CLOSE, NULL, NULL); if (thread_handle != NULL) { DWORD wait_result = ::WaitForSingleObject(thread_handle, 30000); if (wait_result != WAIT_OBJECT_0) { LOG(DEBUG) << "Waiting for thread to end returned " << wait_result; } ::CloseHandle(thread_handle); } this->sessions_.erase(session_id); } } std::wstring IEDriverServer::ReadRequestBody(struct mg_connection* conn, const struct mg_request_info* request_info) { std::wstring request_body = L""; int content_length = 0; for (int header_index = 0; header_index < 64; ++header_index) { if (request_info->http_headers[header_index].name == NULL) { break; } if (strcmp(request_info->http_headers[header_index].name, "Content-Length") == 0) { content_length = atoi(request_info->http_headers[header_index].value); break; } } if (content_length == 0) { request_body = L"{}"; } else { std::vector<char> input_buffer(content_length + 1); int bytes_read = 0; while (bytes_read < content_length) { bytes_read += mg_read(conn, &input_buffer[bytes_read], content_length - bytes_read); } input_buffer[content_length] = '\0'; int output_buffer_size = ::MultiByteToWideChar(CP_UTF8, 0, &input_buffer[0], -1, NULL, 0); vector<TCHAR> output_buffer(output_buffer_size); ::MultiByteToWideChar(CP_UTF8, 0, &input_buffer[0], -1, &output_buffer[0], output_buffer_size); request_body.append(&output_buffer[0], output_buffer_size); } return request_body; } int IEDriverServer::ProcessRequest(struct mg_connection* conn, const struct mg_request_info* request_info) { int return_code = NULL; std::string http_verb = request_info->request_method; std::wstring request_body = L"{}"; if (http_verb == "POST") { request_body = this->ReadRequestBody(conn, request_info); } if (strcmp(request_info->uri, "/") == 0) { this->SendWelcomePage(conn, request_info); return_code = 200; } else { std::wstring session_id = L""; std::wstring locator_parameters = L""; int command = this->LookupCommand(request_info->uri, http_verb, &session_id, &locator_parameters); if (command == NoCommand) { if (locator_parameters.size() != 0) { this->SendHttpMethodNotAllowed(conn, request_info, locator_parameters); } else { this->SendHttpNotImplemented(conn, request_info, "Command not implemented"); } } else { if (command == NewSession) { session_id = this->CreateSession(); } std::wstring serialized_response = L""; HWND session_window_handle = NULL; if (!this->LookupSession(session_id, &session_window_handle)) { // Hand-code the response for an invalid session id serialized_response = L"{ \"status\" : 404, \"sessionId\" : \"" + session_id + L"\", \"value\" : \"session " + session_id + L" does not exist\" }"; } else { // Compile the serialized JSON representation of the command by hand. std::wstringstream command_value_stream; command_value_stream << command; std::wstring command_value = command_value_stream.str(); std::wstring serialized_command = L"{ \"command\" : " + command_value + L", \"locator\" : " + locator_parameters + L", \"parameters\" : " + request_body + L" }"; bool session_is_valid = this->SendCommandToSession(session_window_handle, serialized_command, &serialized_response); if (!session_is_valid) { this->ShutDownSession(session_id); } } return_code = this->SendResponseToBrowser(conn, request_info, serialized_response); } } return return_code; } bool IEDriverServer::LookupSession(const std::wstring& session_id, HWND* session_window_handle) { SessionMap::iterator it = this->sessions_.find(session_id); if (it == this->sessions_.end()) { return false; } *session_window_handle = it->second; return true; } bool IEDriverServer::SendCommandToSession(const HWND& session_window_handle, const std::wstring& serialized_command, std::wstring* serialized_response) { // Sending a command consists of five actions: // 1. Setting the command to be executed // 2. Executing the command // 3. Waiting for the response to be populated // 4. Retrieving the response // 5. Retrieving whether the command sent caused the session to be ready for shutdown ::SendMessage(session_window_handle, WD_SET_COMMAND, NULL, reinterpret_cast<LPARAM>(serialized_command.c_str())); ::PostMessage(session_window_handle, WD_EXEC_COMMAND, NULL, NULL); int response_length = static_cast<int>(::SendMessage(session_window_handle, WD_GET_RESPONSE_LENGTH, NULL, NULL)); while (response_length == 0) { // Sleep a short time to prevent thread starvation on single-core machines. ::Sleep(10); response_length = static_cast<int>(::SendMessage(session_window_handle, WD_GET_RESPONSE_LENGTH, NULL, NULL)); } // Must add one to the length to handle the terminating character. std::vector<TCHAR> response_buffer(response_length + 1); ::SendMessage(session_window_handle, WD_GET_RESPONSE, NULL, reinterpret_cast<LPARAM>(&response_buffer[0])); *serialized_response = &response_buffer[0]; bool session_is_valid = ::SendMessage(session_window_handle, WD_IS_SESSION_VALID, NULL, NULL) != 0; return session_is_valid; } int IEDriverServer::SendResponseToBrowser(struct mg_connection* conn, const struct mg_request_info* request_info, const std::wstring& serialized_response) { int return_code = 0; if (serialized_response.size() > 0) { Response response; response.Deserialize(serialized_response); if (response.status_code() == 0) { this->SendHttpOk(conn, request_info, serialized_response); return_code = 200; } else if (response.status_code() == 303) { std::string location = response.value().asString(); response.SetResponse(SUCCESS, response.value()); this->SendHttpSeeOther(conn, request_info, location); return_code = 303; } else if (response.status_code() == 400) { this->SendHttpBadRequest(conn, request_info, serialized_response); return_code = 400; } else if (response.status_code() == 404) { this->SendHttpNotFound(conn, request_info, serialized_response); return_code = 404; } else if (response.status_code() == 501) { this->SendHttpNotImplemented(conn, request_info, "Command not implemented"); return_code = 501; } else { this->SendHttpInternalError(conn, request_info, serialized_response); return_code = 500; } } return return_code; } void IEDriverServer::SendWelcomePage(struct mg_connection* connection, const struct mg_request_info* request_info) { std::string page_body = SERVER_DEFAULT_PAGE; std::ostringstream out; out << "HTTP/1.1 200 OK\r\n" << "Content-Length: " << strlen(page_body.c_str()) << "\r\n" << "Content-Type: text/html; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << page_body << "\r\n"; } mg_write(connection, out.str().c_str(), out.str().size()); } // The standard HTTP Status codes are implemented below. Chrome uses // OK, See Other, Not Found, Method Not Allowed, and Internal Error. // Internal Error, HTTP 500, is used as a catch all for any issue // not covered in the JSON protocol. void IEDriverServer::SendHttpOk(struct mg_connection* connection, const struct mg_request_info* request_info, const std::wstring& body) { std::string narrow_body = CW2A(body.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 200 OK\r\n" << "Content-Length: " << strlen(narrow_body.c_str()) << "\r\n" << "Content-Type: application/json; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << narrow_body << "\r\n"; } mg_write(connection, out.str().c_str(), out.str().size()); } void IEDriverServer::SendHttpBadRequest(struct mg_connection* const connection, const struct mg_request_info* const request_info, const std::wstring& body) { std::string narrow_body = CW2A(body.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 400 Bad Request\r\n" << "Content-Length: " << strlen(narrow_body.c_str()) << "\r\n" << "Content-Type: application/json; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << narrow_body << "\r\n"; } mg_printf(connection, "%s", out.str().c_str()); } void IEDriverServer::SendHttpInternalError(struct mg_connection* connection, const struct mg_request_info* request_info, const std::wstring& body) { std::string narrow_body = CW2A(body.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 500 Internal Server Error\r\n" << "Content-Length: " << strlen(narrow_body.c_str()) << "\r\n" << "Content-Type: application/json; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << narrow_body << "\r\n"; } mg_write(connection, out.str().c_str(), out.str().size()); } void IEDriverServer::SendHttpNotFound(struct mg_connection* const connection, const struct mg_request_info* const request_info, const std::wstring& body) { std::string narrow_body = CW2A(body.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 404 Not Found\r\n" << "Content-Length: " << strlen(narrow_body.c_str()) << "\r\n" << "Content-Type: application/json; charset=UTF-8\r\n" << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" << "Accept-Ranges: bytes\r\n" << "Connection: close\r\n\r\n"; if (strcmp(request_info->request_method, "HEAD") != 0) { out << narrow_body << "\r\n"; } mg_printf(connection, "%s", out.str().c_str()); } void IEDriverServer::SendHttpMethodNotAllowed(struct mg_connection* connection, const struct mg_request_info* request_info, const std::wstring& allowed_methods) { std::string narrow_body = CW2A(allowed_methods.c_str(), CP_UTF8); std::ostringstream out; out << "HTTP/1.1 405 Method Not Allowed\r\n" << "Content-Type: text/html\r\n" << "Content-Length: 0\r\n" << "Allow: " << narrow_body << "\r\n\r\n"; mg_write(connection, out.str().c_str(), out.str().size()); } void IEDriverServer::SendHttpNotImplemented(struct mg_connection* connection, const struct mg_request_info* request_info, const std::string& body) { std::ostringstream out; out << "HTTP/1.1 501 Not Implemented\r\n" << "Content-Type: text/html\r\n" << "Content-Length: 0\r\n" << "Allow: " << body << "\r\n\r\n"; mg_write(connection, out.str().c_str(), out.str().size()); } void IEDriverServer::SendHttpSeeOther(struct mg_connection* connection, const struct mg_request_info* request_info, const std::string& location) { std::ostringstream out; out << "HTTP/1.1 303 See Other\r\n" << "Location: " << location << "\r\n" << "Content-Type: text/html\r\n" << "Content-Length: 0\r\n\r\n"; mg_write(connection, out.str().c_str(), out.str().size()); } int IEDriverServer::LookupCommand(const std::string& uri, const std::string& http_verb, std::wstring* session_id, std::wstring* locator) { int value = NoCommand; UrlMap::const_iterator it = this->commands_.begin(); for (; it != this->commands_.end(); ++it) { std::vector<std::string> locator_param_names; std::string url_candidate = it->first; size_t param_start_pos = url_candidate.find_first_of(":"); while (param_start_pos != std::string::npos) { size_t param_len = std::string::npos; size_t param_end_pos = url_candidate.find_first_of("/", param_start_pos); if (param_end_pos != std::string::npos) { param_len = param_end_pos - param_start_pos; } // Skip the colon std::string param_name = url_candidate.substr(param_start_pos + 1, param_len - 1); locator_param_names.push_back(param_name); if (param_name == "sessionid" || param_name == "id") { url_candidate.replace(param_start_pos, param_len, "([0-9a-fA-F-]+)"); } else { url_candidate.replace(param_start_pos, param_len, "([^/]+)"); } param_start_pos = url_candidate.find_first_of(":"); } std::string::const_iterator uri_start = uri.begin(); std::string::const_iterator uri_end = uri.end(); std::tr1::regex matcher("^" + url_candidate + "$"); std::tr1::match_results<std::string::const_iterator> matches; if (std::tr1::regex_search(uri_start, uri_end, matches, matcher)) { VerbMap::const_iterator verb_iterator = it->second.find(http_verb); if (verb_iterator != it->second.end()) { value = verb_iterator->second; std::string param = "{"; size_t param_count = locator_param_names.size(); for (unsigned int i = 0; i < param_count; i++) { if (i != 0) { param += ","; } std::string locator_param_value(matches[i + 1].first, matches[i + 1].second); param += " \"" + locator_param_names[i] + "\" : \"" + locator_param_value + "\""; if (locator_param_names[i] == "sessionid") { session_id->append(CA2W(locator_param_value.c_str(), CP_UTF8)); } } param += " }"; std::wstring wide_param(param.begin(), param.end()); locator->append(wide_param); break; } else { verb_iterator = it->second.begin(); for (; verb_iterator != it->second.end(); ++verb_iterator) { if (locator->size() != 0) { locator->append(L","); } locator->append(CA2W(verb_iterator->first.c_str(), CP_UTF8)); } } } } return value; } void IEDriverServer::PopulateCommandRepository() { this->commands_["/session"]["POST"] = NewSession; this->commands_["/session/:sessionid"]["GET"] = GetSessionCapabilities; this->commands_["/session/:sessionid"]["DELETE"] = Quit; this->commands_["/session/:sessionid/window_handle"]["GET"] = GetCurrentWindowHandle; this->commands_["/session/:sessionid/window_handles"]["GET"] = GetWindowHandles; this->commands_["/session/:sessionid/url"]["GET"] = GetCurrentUrl; this->commands_["/session/:sessionid/url"]["POST"] = Get; this->commands_["/session/:sessionid/forward"]["POST"] = GoForward; this->commands_["/session/:sessionid/back"]["POST"] = GoBack; this->commands_["/session/:sessionid/refresh"]["POST"] = Refresh; this->commands_["/session/:sessionid/speed"]["GET"] = GetSpeed; this->commands_["/session/:sessionid/speed"]["POST"] = SetSpeed; this->commands_["/session/:sessionid/execute"]["POST"] = ExecuteScript; this->commands_["/session/:sessionid/execute_async"]["POST"] = ExecuteAsyncScript; this->commands_["/session/:sessionid/screenshot"]["GET"] = Screenshot; this->commands_["/session/:sessionid/frame"]["POST"] = SwitchToFrame; this->commands_["/session/:sessionid/window"]["POST"] = SwitchToWindow; this->commands_["/session/:sessionid/window"]["DELETE"] = Close; this->commands_["/session/:sessionid/cookie"]["GET"] = GetAllCookies; this->commands_["/session/:sessionid/cookie"]["POST"] = AddCookie; this->commands_["/session/:sessionid/cookie"]["DELETE"] = DeleteAllCookies; this->commands_["/session/:sessionid/cookie/:name"]["DELETE"] = DeleteCookie; this->commands_["/session/:sessionid/source"]["GET"] = GetPageSource; this->commands_["/session/:sessionid/title"]["GET"] = GetTitle; this->commands_["/session/:sessionid/element"]["POST"] = FindElement; this->commands_["/session/:sessionid/elements"]["POST"] = FindElements; this->commands_["/session/:sessionid/timeouts/implicit_wait"]["POST"] = ImplicitlyWait; this->commands_["/session/:sessionid/timeouts/async_script"]["POST"] = SetAsyncScriptTimeout; this->commands_["/session/:sessionid/element/active"]["POST"] = GetActiveElement; this->commands_["/session/:sessionid/element/:id/element"]["POST"] = FindChildElement; this->commands_["/session/:sessionid/element/:id/elements"]["POST"] = FindChildElements; this->commands_["/session/:sessionid/element/:id"]["GET"] = DescribeElement; this->commands_["/session/:sessionid/element/:id/click"]["POST"] = ClickElement; this->commands_["/session/:sessionid/element/:id/text"]["GET"] = GetElementText; this->commands_["/session/:sessionid/element/:id/submit"]["POST"] = SubmitElement; this->commands_["/session/:sessionid/element/:id/value"]["GET"] = GetElementValue; this->commands_["/session/:sessionid/element/:id/value"]["POST"] = SendKeysToElement; this->commands_["/session/:sessionid/element/:id/name"]["GET"] = GetElementTagName; this->commands_["/session/:sessionid/element/:id/clear"]["POST"] = ClearElement; this->commands_["/session/:sessionid/element/:id/selected"]["GET"] = IsElementSelected; this->commands_["/session/:sessionid/element/:id/selected"]["POST"] = SetElementSelected; this->commands_["/session/:sessionid/element/:id/toggle"]["POST"] = ToggleElement; this->commands_["/session/:sessionid/element/:id/enabled"]["GET"] = IsElementEnabled; this->commands_["/session/:sessionid/element/:id/displayed"]["GET"] = IsElementDisplayed; this->commands_["/session/:sessionid/element/:id/location"]["GET"] = GetElementLocation; this->commands_["/session/:sessionid/element/:id/location_in_view"]["GET"] = GetElementLocationOnceScrolledIntoView; this->commands_["/session/:sessionid/element/:id/size"]["GET"] = GetElementSize; this->commands_["/session/:sessionid/element/:id/css/:propertyName"]["GET"] = GetElementValueOfCssProperty; this->commands_["/session/:sessionid/element/:id/attribute/:name"]["GET"] = GetElementAttribute; this->commands_["/session/:sessionid/element/:id/equals/:other"]["GET"] = ElementEquals; this->commands_["/session/:sessionid/element/:id/hover"]["POST"] = HoverOverElement; this->commands_["/session/:sessionid/element/:id/drag"]["POST"] = DragElement; this->commands_["/session/:sessionid/screenshot"]["GET"] = Screenshot; this->commands_["/session/:sessionid/accept_alert"]["POST"] = AcceptAlert; this->commands_["/session/:sessionid/dismiss_alert"]["POST"] = DismissAlert; this->commands_["/session/:sessionid/alert_text"]["GET"] = GetAlertText; this->commands_["/session/:sessionid/alert_text"]["POST"] = SendKeysToAlert; this->commands_["/session/:sessionid/modifier"]["POST"] = SendModifierKey; this->commands_["/session/:sessionid/moveto"]["POST"] = MouseMoveTo; this->commands_["/session/:sessionid/click"]["POST"] = MouseClick; this->commands_["/session/:sessionid/doubleclick"]["POST"] = MouseDoubleClick; this->commands_["/session/:sessionid/buttondown"]["POST"] = MouseButtonDown; this->commands_["/session/:sessionid/buttonup"]["POST"] = MouseButtonUp; /* commandDictionary.Add(DriverCommand.DefineDriverMapping, new CommandInfo(CommandInfo.PostCommand, "/config/drivers")); commandDictionary.Add(DriverCommand.SetBrowserVisible, new CommandInfo(CommandInfo.PostCommand, "/session/{sessionId}/visible")); commandDictionary.Add(DriverCommand.IsBrowserVisible, new CommandInfo(CommandInfo.GetCommand, "/session/{sessionId}/visible")); */ } } // namespace webdriver
[ "eran.mes@gmail.com@07704840-8298-11de-bf8c-fd130f914ac9" ]
eran.mes@gmail.com@07704840-8298-11de-bf8c-fd130f914ac9
de83464e4af98521a91b597bbcfa38aa6e9b828d
e60678d3bd87ba051f73772fe956271847bd09d5
/34-android-system-module/34-26-weidongshan_4_term_android/cpp_projects_weids_bak/cpp_projects/03th_ProgramStructure/06th/dog.cpp
c94acceff733ae7a5c9d11bc73fd3defa2009d06
[]
no_license
juyingguo/android-knowledge-principle-interview
da75682d97ab9353850567eb9d96f516a7d36328
368a3ce91bc9bd735d78985a8dd8925232f9b8c6
refs/heads/master
2023-04-15T06:18:36.200436
2023-03-21T13:39:29
2023-03-21T13:39:29
198,389,681
2
2
null
2022-09-01T23:10:43
2019-07-23T08:44:37
Java
UTF-8
C++
false
false
401
cpp
#include <iostream> #include "dog.h" namespace C { using namespace std; void Dog::setName(char *name) { this->name = name; } int Dog::setAge(int age) { if (age < 0 || age > 20) { this->age = 0; return -1; } this->age = age; return 0; } void Dog::printInfo(void) { cout<<"name = "<<name<<" age = "<<age<<endl; } void printVersion(void) { cout<<"Dog v1, by weidongshan"<<endl; } }
[ "juying2050@sina.cn" ]
juying2050@sina.cn
2a01fc2d9b743278cdb6b750deefdc1c6e31aa5e
119aeffc0718f28f16bfb1575139739021d2b5ef
/Cpp全/Cpp/C++练习/juzhen1.cpp
9b16f377f1090a8a614ccf2a8d4f70effd73db91
[]
no_license
bsyess/Anything
058c420564548e8198c180d197fcbb31d4509d8b
5da9ea8c26579fd4a61c4a846d24b9e3d95861a1
refs/heads/main
2023-02-17T19:20:43.057901
2021-01-14T14:13:40
2021-01-14T14:13:40
320,489,169
0
0
null
null
null
null
UTF-8
C++
false
false
973
cpp
#include<iostream> using namespace std; class Matrix { public: int a[10][10],n; Matrix(){}; }; istream & operator >>(istream &in,Matrix &m) { int i,j; in>>m.n; for(i=0;i<m.n;i++) { for(j=0;j<m.n;j++) { in>>m.a[i][j]; } } return in; } ostream & operator <<(ostream & out,Matrix &m) { int i,j; for(i=0;i<m.n;i++) { for(j=0;j<m.n;j++) { out<<m.a[i][j]; cout<<' '; } cout<<endl; } return out; } Matrix operator * (Matrix m1,Matrix m2) { int f[100]; Matrix m3; m3.n=m1.n; int i,j,k,sum=0; for(i=0;i<m1.n;i++) { for(j=0;j<m1.n;j++) { sum=0; for(k=0;k<m1.n;k++) { sum=sum+m1.a[i][k]*m2.a[k][j]; } m3.a[i][j]=sum; } } return m3; } int main() { Matrix m1,m2,m3; cin>>m1; cin>>m2; m3=m1*m2; cout<<m1; cout<<m2; cout<<m3; return 0; }
[ "noreply@github.com" ]
bsyess.noreply@github.com
11398fcd9b6e27be602fe664a2e4f2a805075841
ef9a782df42136ec09485cbdbfa8a56512c32530
/branches/Chickens/src/livestock/pullets.h
c749dc10141b4aaa4eab4ddf9c42d4f114f9875c
[]
no_license
penghuz/main
c24ca5f2bf13b8cc1f483778e72ff6432577c83b
26d9398309eeacbf24e3c5affbfb597be1cc8cd4
refs/heads/master
2020-04-22T15:59:50.432329
2017-11-23T10:30:22
2017-11-23T10:30:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,314
h
/****************************************************************************\ $URL$ $LastChangedDate$ $LastChangedRevision$ $LastChangedBy$ \****************************************************************************/ /****************************************************************************\ \****************************************************************************/ #ifndef PULLETS_H #define PULLETS_H #include "poultry.h" #include "../products/animalProduct.h" /****************************************************************************\ Class: pullets \****************************************************************************/ class pullets : public poultry { /* Attributes */ private: animalProduct* pulletsPrDay; /* Actions */ private: public: // Default Constructor pullets(); pullets(const char *aName,const int aIndex,const base * aOwner); // Destructor ~pullets(); // Other functions double feedingDays(); void Manure(manure* fluidManure, manure* solidManure); void DailyUpdate(); void ReceivePlan(char * FileName); void SetNumberPrYear (double aNumberPrYear){ poultry::SetNumberPrYear(aNumberPrYear);} virtual double GetSensibleHeatProduction(double weight, double n); }; #endif
[ "sai@agro.au.dk" ]
sai@agro.au.dk
727fe622abd40599079460362a90d4be30213f46
de7e771699065ec21a340ada1060a3cf0bec3091
/core/src/java/org/apache/lucene/codecs/blocktree/SegmentTermsEnumFrame.cpp
42fe22190d478ec12a1ef715bf9a84f1837b826c
[]
no_license
sraihan73/Lucene-
0d7290bacba05c33b8d5762e0a2a30c1ec8cf110
1fe2b48428dcbd1feb3e10202ec991a5ca0d54f3
refs/heads/master
2020-03-31T07:23:46.505891
2018-12-08T14:57:54
2018-12-08T14:57:54
152,020,180
7
0
null
null
null
null
UTF-8
C++
false
false
22,113
cpp
using namespace std; #include "SegmentTermsEnumFrame.h" #include "../../index/IndexOptions.h" #include "../../store/ByteArrayDataInput.h" #include "../../util/ArrayUtil.h" #include "../../util/BytesRef.h" #include "../BlockTermState.h" #include "SegmentTermsEnum.h" namespace org::apache::lucene::codecs::blocktree { using BlockTermState = org::apache::lucene::codecs::BlockTermState; using IndexOptions = org::apache::lucene::index::IndexOptions; using SeekStatus = org::apache::lucene::index::TermsEnum::SeekStatus; using ByteArrayDataInput = org::apache::lucene::store::ByteArrayDataInput; using ArrayUtil = org::apache::lucene::util::ArrayUtil; using BytesRef = org::apache::lucene::util::BytesRef; using FST = org::apache::lucene::util::fst::FST; SegmentTermsEnumFrame::SegmentTermsEnumFrame(shared_ptr<SegmentTermsEnum> ste, int ord) : ord(ord), state(ste->fr->parent->postingsReader->newTermState()), longs(std::deque<int64_t>(ste->fr->longsSize)), ste(ste) { this->state->totalTermFreq = -1; } void SegmentTermsEnumFrame::setFloorData(shared_ptr<ByteArrayDataInput> in_, shared_ptr<BytesRef> source) { constexpr int numBytes = source->length - (in_->getPosition() - source->offset); if (numBytes > floorData.size()) { floorData = std::deque<char>(ArrayUtil::oversize(numBytes, 1)); } System::arraycopy(source->bytes, source->offset + in_->getPosition(), floorData, 0, numBytes); floorDataReader->reset(floorData, 0, numBytes); numFollowFloorBlocks = floorDataReader->readVInt(); nextFloorLabel = floorDataReader->readByte() & 0xff; // if (DEBUG) { // System.out.println(" setFloorData fpOrig=" + fpOrig + " bytes=" + new // BytesRef(source.bytes, source.offset + in.getPosition(), numBytes) + " // numFollowFloorBlocks=" + numFollowFloorBlocks + " nextFloorLabel=" + // toHex(nextFloorLabel)); //} } int SegmentTermsEnumFrame::getTermBlockOrd() { return isLeafBlock ? nextEnt : state->termBlockOrd; } void SegmentTermsEnumFrame::loadNextFloorBlock() { // if (DEBUG) { // System.out.println(" loadNextFloorBlock fp=" + fp + " fpEnd=" + fpEnd); //} assert((arc == nullptr || isFloor, L"arc=" + arc + L" isFloor=" + StringHelper::toString(isFloor))); fp = fpEnd; nextEnt = -1; loadBlock(); } void SegmentTermsEnumFrame::loadBlock() { // Clone the IndexInput lazily, so that consumers // that just pull a TermsEnum to // seekExact(TermState) don't pay this cost: ste->initIndexInput(); if (nextEnt != -1) { // Already loaded return; } // System.out.println("blc=" + blockLoadCount); ste->in_->seek(fp); int code = ste->in_->readVInt(); entCount = static_cast<int>(static_cast<unsigned int>(code) >> 1); assert(entCount > 0); isLastInFloor = (code & 1) != 0; assert((arc == nullptr || (isLastInFloor || isFloor), L"fp=" + to_wstring(fp) + L" arc=" + arc + L" isFloor=" + StringHelper::toString(isFloor) + L" isLastInFloor=" + StringHelper::toString(isLastInFloor))); // TODO: if suffixes were stored in random-access // array structure, then we could do binary search // instead of linear scan to find target term; eg // we could have simple array of offsets // term suffixes: code = ste->in_->readVInt(); isLeafBlock = (code & 1) != 0; int numBytes = static_cast<int>(static_cast<unsigned int>(code) >> 1); if (suffixBytes.size() < numBytes) { suffixBytes = std::deque<char>(ArrayUtil::oversize(numBytes, 1)); } ste->in_->readBytes(suffixBytes, 0, numBytes); suffixesReader->reset(suffixBytes, 0, numBytes); /*if (DEBUG) { if (arc == null) { System.out.println(" loadBlock (next) fp=" + fp + " entCount=" + entCount + " prefixLen=" + prefix + " isLastInFloor=" + isLastInFloor + " leaf?=" + isLeafBlock); } else { System.out.println(" loadBlock (seek) fp=" + fp + " entCount=" + entCount + " prefixLen=" + prefix + " hasTerms?=" + hasTerms + " isFloor?=" + isFloor + " isLastInFloor=" + isLastInFloor + " leaf?=" + isLeafBlock); } }*/ // stats numBytes = ste->in_->readVInt(); if (statBytes.size() < numBytes) { statBytes = std::deque<char>(ArrayUtil::oversize(numBytes, 1)); } ste->in_->readBytes(statBytes, 0, numBytes); statsReader->reset(statBytes, 0, numBytes); metaDataUpto = 0; state->termBlockOrd = 0; nextEnt = 0; lastSubFP = -1; // TODO: we could skip this if !hasTerms; but // that's rare so won't help much // metadata numBytes = ste->in_->readVInt(); if (bytes.size() < numBytes) { bytes = std::deque<char>(ArrayUtil::oversize(numBytes, 1)); } ste->in_->readBytes(bytes, 0, numBytes); bytesReader->reset(bytes, 0, numBytes); // Sub-blocks of a single floor block are always // written one after another -- tail recurse: fpEnd = ste->in_->getFilePointer(); // if (DEBUG) { // System.out.println(" fpEnd=" + fpEnd); // } } void SegmentTermsEnumFrame::rewind() { // Force reload: fp = fpOrig; nextEnt = -1; hasTerms = hasTermsOrig; if (isFloor) { floorDataReader->rewind(); numFollowFloorBlocks = floorDataReader->readVInt(); assert(numFollowFloorBlocks > 0); nextFloorLabel = floorDataReader->readByte() & 0xff; } /* //System.out.println("rewind"); // Keeps the block loaded, but rewinds its state: if (nextEnt > 0 || fp != fpOrig) { if (DEBUG) { System.out.println(" rewind frame ord=" + ord + " fpOrig=" + fpOrig + " fp=" + fp + " hasTerms?=" + hasTerms + " isFloor?=" + isFloor + " nextEnt=" + nextEnt + " prefixLen=" + prefix); } if (fp != fpOrig) { fp = fpOrig; nextEnt = -1; } else { nextEnt = 0; } hasTerms = hasTermsOrig; if (isFloor) { floorDataReader.rewind(); numFollowFloorBlocks = floorDataReader.readVInt(); nextFloorLabel = floorDataReader.readByte() & 0xff; } assert suffixBytes != null; suffixesReader.rewind(); assert statBytes != null; statsReader.rewind(); metaDataUpto = 0; state.termBlockOrd = 0; // TODO: skip this if !hasTerms? Then postings // impl wouldn't have to write useless 0 byte postingsReader.resetTermsBlock(fieldInfo, state); lastSubFP = -1; } else if (DEBUG) { System.out.println(" skip rewind fp=" + fp + " fpOrig=" + fpOrig + " nextEnt=" + nextEnt + " ord=" + ord); } */ } bool SegmentTermsEnumFrame::next() { if (isLeafBlock) { nextLeaf(); return false; } else { return nextNonLeaf(); } } void SegmentTermsEnumFrame::nextLeaf() { // if (DEBUG) System.out.println(" frame.next ord=" + ord + " nextEnt=" + // nextEnt + " entCount=" + entCount); assert((nextEnt != -1 && nextEnt < entCount, L"nextEnt=" + to_wstring(nextEnt) + L" entCount=" + to_wstring(entCount) + L" fp=" + to_wstring(fp))); nextEnt++; suffix = suffixesReader->readVInt(); startBytePos = suffixesReader->getPosition(); ste->term_->setLength(prefix + suffix); ste->term_.grow(ste->term_->length()); suffixesReader->readBytes(ste->term_.bytes(), prefix, suffix); ste->termExists = true; } bool SegmentTermsEnumFrame::nextNonLeaf() { // if (DEBUG) System.out.println(" stef.next ord=" + ord + " nextEnt=" + // nextEnt + " entCount=" + entCount + " fp=" + suffixesReader.getPosition()); while (true) { if (nextEnt == entCount) { assert((arc == nullptr || (isFloor && isLastInFloor == false), L"isFloor=" + StringHelper::toString(isFloor) + L" isLastInFloor=" + StringHelper::toString(isLastInFloor))); loadNextFloorBlock(); if (isLeafBlock) { nextLeaf(); return false; } else { continue; } } assert((nextEnt != -1 && nextEnt < entCount, L"nextEnt=" + to_wstring(nextEnt) + L" entCount=" + to_wstring(entCount) + L" fp=" + to_wstring(fp))); nextEnt++; constexpr int code = suffixesReader->readVInt(); suffix = static_cast<int>(static_cast<unsigned int>(code) >> 1); startBytePos = suffixesReader->getPosition(); ste->term_->setLength(prefix + suffix); ste->term_.grow(ste->term_->length()); suffixesReader->readBytes(ste->term_.bytes(), prefix, suffix); if ((code & 1) == 0) { // A normal term ste->termExists = true; subCode = 0; state->termBlockOrd++; return false; } else { // A sub-block; make sub-FP absolute: ste->termExists = false; subCode = suffixesReader->readVLong(); lastSubFP = fp - subCode; // if (DEBUG) { // System.out.println(" lastSubFP=" + lastSubFP); //} return true; } } } void SegmentTermsEnumFrame::scanToFloorFrame(shared_ptr<BytesRef> target) { if (!isFloor || target->length <= prefix) { // if (DEBUG) { // System.out.println(" scanToFloorFrame skip: isFloor=" + isFloor + " // target.length=" + target.length + " vs prefix=" + prefix); // } return; } constexpr int targetLabel = target->bytes[target->offset + prefix] & 0xFF; // if (DEBUG) { // System.out.println(" scanToFloorFrame fpOrig=" + fpOrig + " // targetLabel=" + toHex(targetLabel) + " vs nextFloorLabel=" + // toHex(nextFloorLabel) + " numFollowFloorBlocks=" + numFollowFloorBlocks); // } if (targetLabel < nextFloorLabel) { // if (DEBUG) { // System.out.println(" already on correct block"); // } return; } assert(numFollowFloorBlocks != 0); int64_t newFP = fpOrig; while (true) { constexpr int64_t code = floorDataReader->readVLong(); newFP = fpOrig + (static_cast<int64_t>(static_cast<uint64_t>(code) >> 1)); hasTerms = (code & 1) != 0; // if (DEBUG) { // System.out.println(" label=" + toHex(nextFloorLabel) + " fp=" + // newFP + " hasTerms?=" + hasTerms + " numFollowFloor=" + // numFollowFloorBlocks); // } isLastInFloor = numFollowFloorBlocks == 1; numFollowFloorBlocks--; if (isLastInFloor) { nextFloorLabel = 256; // if (DEBUG) { // System.out.println(" stop! last block nextFloorLabel=" + // toHex(nextFloorLabel)); // } break; } else { nextFloorLabel = floorDataReader->readByte() & 0xff; if (targetLabel < nextFloorLabel) { // if (DEBUG) { // System.out.println(" stop! nextFloorLabel=" + // toHex(nextFloorLabel)); // } break; } } } if (newFP != fp) { // Force re-load of the block: // if (DEBUG) { // System.out.println(" force switch to fp=" + newFP + " oldFP=" + // fp); // } nextEnt = -1; fp = newFP; } else { // if (DEBUG) { // System.out.println(" stay on same fp=" + newFP); // } } } void SegmentTermsEnumFrame::decodeMetaData() { // if (DEBUG) System.out.println("\nBTTR.decodeMetadata seg=" + segment + " // mdUpto=" + metaDataUpto + " vs termBlockOrd=" + state.termBlockOrd); // lazily catch up on metadata decode: constexpr int limit = getTermBlockOrd(); bool absolute = metaDataUpto == 0; assert(limit > 0); // TODO: better API would be "jump straight to term=N"??? while (metaDataUpto < limit) { // TODO: we could make "tiers" of metadata, ie, // decode docFreq/totalTF but don't decode postings // metadata; this way caller could get // docFreq/totalTF w/o paying decode cost for // postings // TODO: if docFreq were bulk decoded we could // just skipN here: // stats state->docFreq = statsReader->readVInt(); // if (DEBUG) System.out.println(" dF=" + state.docFreq); if (ste->fr->fieldInfo->getIndexOptions() != IndexOptions::DOCS) { state->totalTermFreq = state->docFreq + statsReader->readVLong(); // if (DEBUG) System.out.println(" totTF=" + state.totalTermFreq); } // metadata for (int i = 0; i < ste->fr->longsSize; i++) { longs[i] = bytesReader->readVLong(); } ste->fr->parent->postingsReader->decodeTerm( longs, bytesReader, ste->fr->fieldInfo, state, absolute); metaDataUpto++; absolute = false; } state->termBlockOrd = metaDataUpto; } bool SegmentTermsEnumFrame::prefixMatches(shared_ptr<BytesRef> target) { for (int bytePos = 0; bytePos < prefix; bytePos++) { if (target->bytes[target->offset + bytePos] != ste->term_.byteAt(bytePos)) { return false; } } return true; } void SegmentTermsEnumFrame::scanToSubBlock(int64_t subFP) { assert(!isLeafBlock); // if (DEBUG) System.out.println(" scanToSubBlock fp=" + fp + " subFP=" + // subFP + " entCount=" + entCount + " lastSubFP=" + lastSubFP); assert nextEnt // == 0; if (lastSubFP == subFP) { // if (DEBUG) System.out.println(" already positioned"); return; } assert( (subFP < fp, L"fp=" + to_wstring(fp) + L" subFP=" + to_wstring(subFP))); constexpr int64_t targetSubCode = fp - subFP; // if (DEBUG) System.out.println(" targetSubCode=" + targetSubCode); while (true) { assert(nextEnt < entCount); nextEnt++; constexpr int code = suffixesReader->readVInt(); suffixesReader->skipBytes( static_cast<int>(static_cast<unsigned int>(code) >> 1)); if ((code & 1) != 0) { constexpr int64_t subCode = suffixesReader->readVLong(); if (targetSubCode == subCode) { // if (DEBUG) System.out.println(" match!"); lastSubFP = subFP; return; } } else { state->termBlockOrd++; } } } SeekStatus SegmentTermsEnumFrame::scanToTerm(shared_ptr<BytesRef> target, bool exactOnly) { return isLeafBlock ? scanToTermLeaf(target, exactOnly) : scanToTermNonLeaf(target, exactOnly); } SeekStatus SegmentTermsEnumFrame::scanToTermLeaf(shared_ptr<BytesRef> target, bool exactOnly) { // if (DEBUG) System.out.println(" scanToTermLeaf: block fp=" + fp + " // prefix=" + prefix + " nextEnt=" + nextEnt + " (of " + entCount + ") // target=" + brToString(target) + " term=" + brToString(term)); assert(nextEnt != -1); ste->termExists = true; subCode = 0; if (nextEnt == entCount) { if (exactOnly) { fillTerm(); } return SeekStatus::END; } assert(prefixMatches(target)); // Loop over each entry (term or sub-block) in this block: // nextTerm: while(nextEnt < entCount) { while (true) { nextEnt++; suffix = suffixesReader->readVInt(); // if (DEBUG) { // BytesRef suffixBytesRef = new BytesRef(); // suffixBytesRef.bytes = suffixBytes; // suffixBytesRef.offset = suffixesReader.getPosition(); // suffixBytesRef.length = suffix; // System.out.println(" cycle: term " + (nextEnt-1) + " (of " + // entCount + ") suffix=" + brToString(suffixBytesRef)); // } constexpr int termLen = prefix + suffix; startBytePos = suffixesReader->getPosition(); suffixesReader->skipBytes(suffix); constexpr int targetLimit = target->offset + (target->length < termLen ? target->length : termLen); int targetPos = target->offset + prefix; // Loop over bytes in the suffix, comparing to // the target int bytePos = startBytePos; while (true) { constexpr int cmp; constexpr bool stop; if (targetPos < targetLimit) { cmp = (suffixBytes[bytePos++] & 0xFF) - (target->bytes[targetPos++] & 0xFF); stop = false; } else { assert(targetPos == targetLimit); cmp = termLen - target->length; stop = true; } if (cmp < 0) { // Current entry is still before the target; // keep scanning if (nextEnt == entCount) { // We are done scanning this block goto nextTermBreak; } else { goto nextTermContinue; } } else if (cmp > 0) { // Done! Current entry is after target -- // return NOT_FOUND: fillTerm(); // if (DEBUG) System.out.println(" not found"); return SeekStatus::NOT_FOUND; } else if (stop) { // Exact match! // This cannot be a sub-block because we // would have followed the index to this // sub-block from the start: assert(ste->termExists); fillTerm(); // if (DEBUG) System.out.println(" found!"); return SeekStatus::FOUND; } } nextTermContinue:; } nextTermBreak: // It is possible (and OK) that terms index pointed us // at this block, but, we scanned the entire block and // did not find the term to position to. This happens // when the target is after the last term in the block // (but, before the next term in the index). EG // target could be foozzz, and terms index pointed us // to the foo* block, but the last term in this block // was fooz (and, eg, first term in the next block will // bee fop). // if (DEBUG) System.out.println(" block end"); if (exactOnly) { fillTerm(); } // TODO: not consistent that in the // not-exact case we don't next() into the next // frame here return SeekStatus::END; } SeekStatus SegmentTermsEnumFrame::scanToTermNonLeaf(shared_ptr<BytesRef> target, bool exactOnly) { // if (DEBUG) System.out.println(" scanToTermNonLeaf: block fp=" + fp + " // prefix=" + prefix + " nextEnt=" + nextEnt + " (of " + entCount + ") target=" // + brToString(target) + " term=" + brToString(target)); assert(nextEnt != -1); if (nextEnt == entCount) { if (exactOnly) { fillTerm(); ste->termExists = subCode == 0; } return SeekStatus::END; } assert(prefixMatches(target)); // Loop over each entry (term or sub-block) in this block: while (nextEnt < entCount) { nextEnt++; constexpr int code = suffixesReader->readVInt(); suffix = static_cast<int>(static_cast<unsigned int>(code) >> 1); // if (DEBUG) { // BytesRef suffixBytesRef = new BytesRef(); // suffixBytesRef.bytes = suffixBytes; // suffixBytesRef.offset = suffixesReader.getPosition(); // suffixBytesRef.length = suffix; // System.out.println(" cycle: " + ((code&1)==1 ? "sub-block" : // "term") + " " + (nextEnt-1) + " (of " + entCount + ") suffix=" + // brToString(suffixBytesRef)); //} constexpr int termLen = prefix + suffix; startBytePos = suffixesReader->getPosition(); suffixesReader->skipBytes(suffix); ste->termExists = (code & 1) == 0; if (ste->termExists) { state->termBlockOrd++; subCode = 0; } else { subCode = suffixesReader->readVLong(); lastSubFP = fp - subCode; } constexpr int targetLimit = target->offset + (target->length < termLen ? target->length : termLen); int targetPos = target->offset + prefix; // Loop over bytes in the suffix, comparing to // the target int bytePos = startBytePos; while (true) { constexpr int cmp; constexpr bool stop; if (targetPos < targetLimit) { cmp = (suffixBytes[bytePos++] & 0xFF) - (target->bytes[targetPos++] & 0xFF); stop = false; } else { assert(targetPos == targetLimit); cmp = termLen - target->length; stop = true; } if (cmp < 0) { // Current entry is still before the target; // keep scanning goto nextTermContinue; } else if (cmp > 0) { // Done! Current entry is after target -- // return NOT_FOUND: fillTerm(); // if (DEBUG) System.out.println(" maybe done exactOnly=" + // exactOnly + " ste.termExists=" + ste.termExists); if (!exactOnly && !ste->termExists) { // System.out.println(" now pushFrame"); // TODO this // We are on a sub-block, and caller wants // us to position to the next term after // the target, so we must recurse into the // sub-frame(s): ste->currentFrame = ste->pushFrame(nullptr, ste->currentFrame->lastSubFP, termLen); ste->currentFrame->loadBlock(); while (ste->currentFrame->next()) { ste->currentFrame = ste->pushFrame( nullptr, ste->currentFrame->lastSubFP, ste->term_->length()); ste->currentFrame->loadBlock(); } } // if (DEBUG) System.out.println(" not found"); return SeekStatus::NOT_FOUND; } else if (stop) { // Exact match! // This cannot be a sub-block because we // would have followed the index to this // sub-block from the start: assert(ste->termExists); fillTerm(); // if (DEBUG) System.out.println(" found!"); return SeekStatus::FOUND; } } nextTermContinue:; } nextTermBreak: // It is possible (and OK) that terms index pointed us // at this block, but, we scanned the entire block and // did not find the term to position to. This happens // when the target is after the last term in the block // (but, before the next term in the index). EG // target could be foozzz, and terms index pointed us // to the foo* block, but the last term in this block // was fooz (and, eg, first term in the next block will // bee fop). // if (DEBUG) System.out.println(" block end"); if (exactOnly) { fillTerm(); } // TODO: not consistent that in the // not-exact case we don't next() into the next // frame here return SeekStatus::END; } void SegmentTermsEnumFrame::fillTerm() { constexpr int termLength = prefix + suffix; ste->term_->setLength(termLength); ste->term_.grow(termLength); System::arraycopy(suffixBytes, startBytePos, ste->term_.bytes(), prefix, suffix); } } // namespace org::apache::lucene::codecs::blocktree
[ "smamunr@fedora.localdomain" ]
smamunr@fedora.localdomain
68c93b16f9e4a99cff2675eb8731d261e8e014e9
8f3f67b62569a2104bb534486cac0aca019dd223
/include/SDIMCompiler/ScopingBlock.hpp
fe0b751e9e32807d726d982beb45f3b1f76e9692
[ "MIT" ]
permissive
DamienHenderson/SDIM
872122b64d9f0055af25f578cc9292fc32a47f88
623ac00402a68a504451c3b7c76cd16fde2fa57e
refs/heads/master
2020-04-19T03:22:54.326678
2019-05-30T03:22:17
2019-05-30T03:22:17
167,932,615
0
0
null
null
null
null
UTF-8
C++
false
false
1,079
hpp
#pragma once #include "Types.hpp" #include <unordered_map> #include <string> namespace SDIM { // Scoping block // has it's own set of key value pairs of strings to variables // each scoping block is completely self contained // variables in scopes closer to the current scoping block have precedence over variables in higher scopes (for example variables in function scope have precedence over variables in global scope) class ScopingBlock { public: ScopingBlock(const std::string& scope_name) : scope_name_(scope_name) {} ~ScopingBlock() {} /// returns true if the variable was successfully added /// returns false if the variable was not added bool AddVariable(const std::string& var_name, const Variable& var); /// Returns the current value of a variable /// If the variable doesn't exist the variable will have it's type set to unknown Variable GetVariable(const std::string& var_name); void PrintScope() const; std::string GetName() const; private: std::unordered_map<std::string, Variable> variables_; std::string scope_name_; }; }
[ "damien.henderson97@gmail.com" ]
damien.henderson97@gmail.com
3880b95823533733f57be0432ef23e78c1cf9bff
c93ac2f725f4ea1e09ec3178dee52de56a41783a
/SPOJ/BC.cpp
d6139012ee4e7d87eccdeb1bc77482d5daf77ce6
[]
no_license
TheStranger512/Competitive-Programming-Stuff
4b51f140907c044616c28b14db28e881ee9d2f41
66824e816b1f3ee113e29444dab3506a668c437d
refs/heads/master
2021-01-21T01:26:36.676309
2014-01-22T08:18:01
2014-01-22T08:18:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,164
cpp
/* Solved * 9935. Break the Chocolate * File: BC.cpp * Author: Andy Y.F. Huang * Created on September 30, 2012, 12:30 PM */ #include <cstdio> #include <iostream> #include <cmath> #include <algorithm> #include <stack> #include <vector> #include <queue> #include <string> #include <cstring> #include <fstream> #include <set> #include <map> #include <sstream> #include <deque> #include <cassert> #ifdef AZN #include "Azn.cpp" #endif using namespace std; /** * Solved * @author Andy Y.F. Huang */ namespace BC { void solve(int test_num) { int a, b, c; scanf("%d %d %d", &a, &b, &c); long long vol = 1LL * a * b * c; int cuts = 0; while (a > 1 || b > 1 || c > 1) { int high = max(a, max(b, c)); if (high == a) a = (a + 1) >> 1; else if (high == b) b = (b + 1) >> 1; else c = (c + 1) >> 1; cuts++; } printf("Case #%d: %lld %d\n", test_num, vol - 1, cuts); } void solve() { #ifdef AZN freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int tests; scanf("%d", &tests); for (int i = 1; i <= tests; i++) solve(i); } } int main() { BC::solve(); return 0; }
[ "huang.yf.andy@live.ca" ]
huang.yf.andy@live.ca
848d7e370c013bb7fda11f5aafe760406fbadbc0
cdf069f16596a61d39d51e739cc8454deb132b38
/Framework/MeshContainer.h
c9232a0a253261bee045eb21088683cbe533bfea
[]
no_license
YutaTachibana0310/hackathon0729
bfcb944d628fd3eaaaab80d242b18d10b190ba9a
b05f1324758351b4faafab2b28a5ddb650d51d27
refs/heads/master
2020-06-25T09:09:50.555342
2019-07-29T08:01:18
2019-07-29T08:01:18
199,267,811
0
0
null
2019-07-29T06:45:42
2019-07-28T09:32:36
C++
SHIFT_JIS
C++
false
false
1,242
h
//===================================== // //メッシュコンテナヘッダ[MeshContainer.h] //Author:GP12B332 21 立花雄太 // //===================================== #ifndef _MESHCONTAINER_H_ #define _MESHCONTAINER_H_ #include "../main.h" /************************************** マクロ定義 ***************************************/ /************************************** クラス定義 ***************************************/ class MeshContainer { public: MeshContainer(); //コンストラクタ ~MeshContainer(); //デストラクタ HRESULT Load(const char* filePath); //Xファイルの読み込み void Release(); //モデルデータを解放 void Draw(); //モデルを描画 void GetMaterial(unsigned id, D3DMATERIAL9 *pOut); //マテリアル取得 void GetTexture(unsigned id, LPDIRECT3DTEXTURE9 *pOut); //テクスチャ取得 DWORD GetMaterialNum(); //マテリアル数取得 void SetMaterialColor(D3DXCOLOR& color); void SetMaterialAlpha(float alpha); private: LPD3DXMESH mesh; //メッシュデータ D3DMATERIAL9* materials; //マテリアル情報 LPDIRECT3DTEXTURE9 *textures; //テクスチャ DWORD materialNum; //マテリアル数 }; #endif
[ "yuta.tachibana0310@gmail.com" ]
yuta.tachibana0310@gmail.com
24da316d0ca01b5796c3b78957daa40d9823e0b6
5f8d9d61075c2f3e604b3ad21eb20a7b5b581184
/Project4/MapLoader.cpp
9dfeda72aced785120ad4f4d34918a5636af01c7
[]
no_license
olivergoch/Computer-Science-32
16d85f03bcd2d69c24538920c13bf186151231b1
a281bc292bb9dace9f8939a9af90fd0511603f94
refs/heads/master
2020-03-27T21:30:16.120638
2018-09-03T04:14:55
2018-09-03T04:14:55
147,149,959
0
0
null
null
null
null
UTF-8
C++
false
false
2,956
cpp
#include "provided.h" #include <string> #include <vector> #include <fstream> using namespace std; class MapLoaderImpl { public: MapLoaderImpl(); ~MapLoaderImpl(); bool load(string mapFile); size_t getNumSegments() const; bool getSegment(size_t segNum, StreetSegment& seg) const; private: vector<StreetSegment> m_segs; int m_numSegs; }; MapLoaderImpl::MapLoaderImpl() { m_numSegs = 0; } MapLoaderImpl::~MapLoaderImpl() { } bool MapLoaderImpl::load(string mapFile) { ifstream infile(mapFile); if(!infile) { return false; exit(1); } string line; int lineNum = 0; //total number of attractions int totalAttract = 0; //current number of attractions int numOfAttract = 0; while (getline(infile, line)) { if(lineNum == 0){ StreetSegment newSeg; m_segs.push_back(newSeg); m_segs[m_numSegs].streetName = line; lineNum++; } else if(lineNum == 1) { GeoCoord start(line.substr(0,10), line.substr(12,12)); GeoCoord end(line.substr(25, 10), line.substr(36, 12)); m_segs[m_numSegs].segment.start = start; m_segs[m_numSegs].segment.end = end; lineNum++; } else if(lineNum == 2) { totalAttract = stoi(line); if(totalAttract == 0) { lineNum = 0; m_numSegs++; } else lineNum++; } else if(lineNum > 2) { m_segs[m_numSegs].attractions.push_back(*new Attraction); size_t pos = line.find('|'); m_segs[m_numSegs].attractions[numOfAttract].name = line.substr(0, pos); GeoCoord place(line.substr(pos+1, 10), line.substr(pos+13, 12)); m_segs[m_numSegs].attractions[numOfAttract].geocoordinates = place; numOfAttract++; if(numOfAttract == totalAttract) { lineNum = 0; m_numSegs++; numOfAttract = 0; } } } return true; } size_t MapLoaderImpl::getNumSegments() const { return m_numSegs; } bool MapLoaderImpl::getSegment(size_t segNum, StreetSegment &seg) const { if(segNum >= m_numSegs) return false; seg = m_segs[segNum]; return true; } //******************** MapLoader functions ************************************ // These functions simply delegate to MapLoaderImpl's functions. // You probably don't want to change any of this code. MapLoader::MapLoader() { m_impl = new MapLoaderImpl; } MapLoader::~MapLoader() { delete m_impl; } bool MapLoader::load(string mapFile) { return m_impl->load(mapFile); } size_t MapLoader::getNumSegments() const { return m_impl->getNumSegments(); } bool MapLoader::getSegment(size_t segNum, StreetSegment& seg) const { return m_impl->getSegment(segNum, seg); }
[ "the.oliver.goch@gmail.com" ]
the.oliver.goch@gmail.com
63a2de36c2206c235110b5c98e01c34a320ea358
0e40a0486826825c2c8adba9a538e16ad3efafaf
/S3DWrapper10/Commands/CreateDepthStencilState.h
4f5751791465a803eedf0db965b1a142f7beb4f1
[ "MIT" ]
permissive
iraqigeek/iZ3D
4c45e69a6e476ad434d5477f21f5b5eb48336727
ced8b3a4b0a152d0177f2e94008918efc76935d5
refs/heads/master
2023-05-25T19:04:06.082744
2020-12-28T03:27:55
2020-12-28T03:27:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,461
h
#pragma once #include "Command.h" #include <memory.h> namespace Commands { class CreateDepthStencilState : public CommandWithAllocator<CreateDepthStencilState> { public: CreateDepthStencilState() { CommandId = idCreateDepthStencilState; } CreateDepthStencilState(const D3D10_DDI_DEPTH_STENCIL_DESC* pDepthStencilDesc, D3D10DDI_HDEPTHSTENCILSTATE hDepthStencilState, D3D10DDI_HRTDEPTHSTENCILSTATE hRTDepthStencilState) { CommandId = idCreateDepthStencilState; memcpy(&DepthStencilDesc_, pDepthStencilDesc, sizeof(D3D10_DDI_DEPTH_STENCIL_DESC)); hDepthStencilState_ = hDepthStencilState; hRTDepthStencilState_ = hRTDepthStencilState; } virtual void Execute ( D3DDeviceWrapper *pWrapper ); virtual bool WriteToFile ( D3DDeviceWrapper *pWrapper ) const; virtual bool WriteToFileSimple( D3DDeviceWrapper *pWrapper ) const { return WriteToFile(pWrapper); } virtual bool ReadFromFile(); void BuildCommand(CDumpState *ds); public: D3D10_DDI_DEPTH_STENCIL_DESC DepthStencilDesc_; D3D10DDI_HDEPTHSTENCILSTATE hDepthStencilState_; D3D10DDI_HRTDEPTHSTENCILSTATE hRTDepthStencilState_; CREATES(hDepthStencilState_); }; } VOID ( APIENTRY CreateDepthStencilState )( D3D10DDI_HDEVICE hDevice, CONST D3D10_DDI_DEPTH_STENCIL_DESC* pDepthStencilDesc, D3D10DDI_HDEPTHSTENCILSTATE hDepthStencilState, D3D10DDI_HRTDEPTHSTENCILSTATE hRTDepthStencilState );
[ "github@bo3b.net" ]
github@bo3b.net
1da93f3476ab0f1d84350766d9bd6f032d6dadf4
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/angle/src/libANGLE/renderer/metal/renderermtl_utils.h
54615ce89c4889ae7be36b40cb4cda51945961e5
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
1,346
h
// // Copyright 2023 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // renderermtl_utils: // Helper methods pertaining to the Metal backend. // #ifndef LIBANGLE_RENDERER_METAL_RENDERERMTL_UTILS_H_ #define LIBANGLE_RENDERER_METAL_RENDERERMTL_UTILS_H_ #include <cstdint> #include <limits> #include <map> #include "GLSLANG/ShaderLang.h" #include "common/angleutils.h" #include "common/utilities.h" #include "libANGLE/angletypes.h" namespace rx { namespace mtl { template <int cols, int rows> struct SetFloatUniformMatrixMetal { static void Run(unsigned int arrayElementOffset, unsigned int elementCount, GLsizei countIn, GLboolean transpose, const GLfloat *value, uint8_t *targetData); }; // Helper method to de-tranpose a matrix uniform for an API query, Metal Version void GetMatrixUniformMetal(GLenum type, GLfloat *dataOut, const GLfloat *source, bool transpose); template <typename NonFloatT> void GetMatrixUniformMetal(GLenum type, NonFloatT *dataOut, const NonFloatT *source, bool transpose); } // namespace mtl } // namespace rx #endif
[ "jengelh@inai.de" ]
jengelh@inai.de
a954b1a96105b2fe465e357652c4bd711a8cee77
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/tsan/interception/interception_win.h
4590013019e375a41817fc088a06463012d34b3b
[ "MIT" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C++
false
false
3,463
h
//===-- interception_linux.h ------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file is a part of AddressSanitizer, an address sanity checker. // // Windows-specific interception methods. //===----------------------------------------------------------------------===// #if SANITIZER_WINDOWS #if !defined(INCLUDED_FROM_INTERCEPTION_LIB) # error "interception_win.h should be included from interception library only" #endif #ifndef INTERCEPTION_WIN_H #define INTERCEPTION_WIN_H namespace __interception { // All the functions in the OverrideFunction() family return true on success, // false on failure (including "couldn't find the function"). // Overrides a function by its address. bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func = 0); // Overrides a function in a system DLL or DLL CRT by its exported name. bool OverrideFunction(const char *name, uptr new_func, uptr *orig_old_func = 0); // Windows-only replacement for GetProcAddress. Useful for some sanitizers. uptr InternalGetProcAddress(void *module, const char *func_name); // Overrides a function only when it is called from a specific DLL. For example, // this is used to override calls to HeapAlloc/HeapFree from ucrtbase without // affecting other third party libraries. bool OverrideImportedFunction(const char *module_to_patch, const char *imported_module, const char *function_name, uptr new_function, uptr *orig_old_func); #if !SANITIZER_WINDOWS64 // Exposed for unittests bool OverrideFunctionWithDetour( uptr old_func, uptr new_func, uptr *orig_old_func); #endif // Exposed for unittests bool OverrideFunctionWithRedirectJump( uptr old_func, uptr new_func, uptr *orig_old_func); bool OverrideFunctionWithHotPatch( uptr old_func, uptr new_func, uptr *orig_old_func); bool OverrideFunctionWithTrampoline( uptr old_func, uptr new_func, uptr *orig_old_func); // Exposed for unittests void TestOnlyReleaseTrampolineRegions(); } // namespace __interception #if defined(INTERCEPTION_DYNAMIC_CRT) #define INTERCEPT_FUNCTION_WIN(func) \ ::__interception::OverrideFunction(#func, \ (::__interception::uptr)WRAP(func), \ (::__interception::uptr *)&REAL(func)) #else #define INTERCEPT_FUNCTION_WIN(func) \ ::__interception::OverrideFunction((::__interception::uptr)func, \ (::__interception::uptr)WRAP(func), \ (::__interception::uptr *)&REAL(func)) #endif #define INTERCEPT_FUNCTION_VER_WIN(func, symver) INTERCEPT_FUNCTION_WIN(func) #define INTERCEPT_FUNCTION_DLLIMPORT(user_dll, provider_dll, func) \ ::__interception::OverrideImportedFunction( \ user_dll, provider_dll, #func, (::__interception::uptr)WRAP(func), \ (::__interception::uptr *)&REAL(func)) #endif // INTERCEPTION_WIN_H #endif // SANITIZER_WINDOWS
[ "andrew@ziglang.org" ]
andrew@ziglang.org
63b68925ce1d6919caca4ba1e2205dcf64e1cf56
928775398b79b42c42fb20b5622b6f1a9d653b2b
/config-generic.h
5143710b74556b397295616d116e6db0294b1882
[ "MIT" ]
permissive
davidchisnall/azure-freebsd-minimal
5f55a874d6904453a7b1f4306886ea25e13990ad
9b41e81a2f38e7ce9fcd05d3ad69f138aa2e9ece
refs/heads/main
2023-08-27T22:32:35.388360
2021-10-16T11:49:13
2021-10-16T11:49:13
393,779,072
1
0
null
null
null
null
UTF-8
C++
false
false
18,362
h
// Copyright David Chisnall // SPDX-License-Identifier: MIT #pragma once #include <algorithm> #include <assert.h> #include <chrono> #include <initializer_list> #include <optional> #include <string_view> #include <ucl.h> #include <unordered_map> #include <utility> #include <stdio.h> #ifndef CONFIG_DETAIL_NAMESPACE # define CONFIG_DETAIL_NAMESPACE config::detail #endif #ifdef __clang__ # define CONFIG_LIFETIME_BOUND [[clang::lifetimebound]] #else # define CONFIG_LIFETIME_BOUND #endif namespace CONFIG_DETAIL_NAMESPACE { /** * Smart pointer to a UCL object, manages the lifetime of the object. */ class UCLPtr { /** * The UCL object that this manages a reference to. */ const ucl_object_t *obj = nullptr; public: /** * Default constructor, points to nothing. */ UCLPtr() {} /** * Construct from a raw UCL object pointer. This does not take * ownership of the reference, the underlying object must have unref'd * if this is called with an owning reference. */ UCLPtr(const ucl_object_t *o) : obj(ucl_object_ref(o)) {} /** * Copy constructor, increments the reference count of the underlying * object. */ UCLPtr(const UCLPtr &o) : obj(ucl_object_ref(o.obj)) {} /** * Move constructor, takes ownership of the underlying reference. */ UCLPtr(UCLPtr &&o) : obj(o.obj) { o.obj = nullptr; } /** * Destructor. Drops the reference to the UCL object. */ ~UCLPtr() { ucl_object_unref(const_cast<ucl_object_t *>(obj)); } /** * Assignment operator. Replaces currently managed object with a new * one. */ UCLPtr &operator=(const ucl_object_t *o) { o = ucl_object_ref(o); ucl_object_unref(const_cast<ucl_object_t *>(obj)); obj = o; return *this; } /** * Copy assignment operator. */ UCLPtr &operator=(const UCLPtr o) { return (*this = o.obj); } /** * Implicit conversion operator, returns the underlying object. */ operator const ucl_object_t *() const { return obj; } /** * Comparison operator. Returns true if `o` is a different UCL object * to the one that this manages. */ bool operator!=(const ucl_object_t *o) { return obj != o; } /** * Look up a property in this object by name and return a smart pointer * to the new object. */ UCLPtr operator[](const char *key) const { return ucl_object_lookup(obj, key); } }; /** * Range. Exposes a UCL collection as an iterable range of type `T`, with * `Adaptor` used to convert from the underlying UCL object to `T`. If * `IterateProperties` is true then this iterates over the properties of an * object, rather than just over UCL arrays. */ template<typename T, typename Adaptor = T, bool IterateProperties = false> class Range { /** * The array that this will iterate over. */ UCLPtr array; /** * The kind of iteration that this will perform. */ enum ucl_iterate_type iterate_type; /** * Iterator type for this range. */ class Iter { /** * The current iterator. */ ucl_object_iter_t iter{nullptr}; /** * The current object in the iteration. */ UCLPtr obj; /** * The array that we're iterating over. */ UCLPtr array; /** * The kind of iteration. */ enum ucl_iterate_type iterate_type; public: /** * Default constructor. Compares equal to the end iterator from any * range. */ Iter() : iter(nullptr), obj(nullptr), array(nullptr) {} /** * These iterators cannot be copy constructed. */ Iter(const Iter &) = delete; /** * These iterators cannot be move constructed. */ Iter(Iter &&) = delete; /** * Constructor, passed an object to iterate over and the kind of * iteration to perform. */ Iter(const ucl_object_t *arr, const ucl_iterate_type type) : array(arr), iterate_type(type) { // If this is not an array and we are not iterating over // properties then treat this as a collection of one object. if (!IterateProperties && (ucl_object_type(array) != UCL_ARRAY)) { array = nullptr; obj = arr; return; } iter = ucl_object_iterate_new(array); ++(*this); } /** * Arrow operator, uses `Adaptor` to expose the underlying object * as if it were of type `T`. */ T operator->() { return Adaptor(obj); } /** * Dereference operator, uses `Adaptor` to expose the underlying * object as if it were of type `T`. */ T operator*() { return Adaptor(obj); } /** * Non-equality comparison, used to terminate range-based for * loops. Compares the current iterated object. This is typically * a comparison against `nullptr` from the iterator at the end of a * range. */ bool operator!=(const Iter &other) { return obj != other.obj; } /** * Pre-increment operator, advances the iteration point. If we * have reached the end then the object will be `nullptr`. */ Iter &operator++() { if (iter == nullptr) { obj = nullptr; } else { obj = ucl_object_iterate_safe(iter, iterate_type); } return *this; } /** * Destructor, frees any iteration state. */ ~Iter() { if (iter != nullptr) { ucl_object_iterate_free(iter); } } }; public: /** * Constructor. Constructs a range from an object. The second * argument specifies whether this should iterate over implicit arrays, * explicit arrays, or both. */ Range(const ucl_object_t * arr, const ucl_iterate_type type = UCL_ITERATE_BOTH) : array(arr), iterate_type(type) { } /** * Returns an iterator to the start of the range. */ Iter begin() { return {array, iterate_type}; } /** * Returns an iterator to the end of the range. */ Iter end() { return {}; } /** * Returns true if this is an empty range. */ bool empty() { return (array == nullptr) || (ucl_object_type(array) == UCL_NULL); } }; /** * String view adaptor exposes a UCL object as a string view. * * Adaptors are intended to be short-lived, created only as temporaries, * and must not outlive the object that they are adapting. */ class StringViewAdaptor { /** * Non-owning pointer to the UCL object that this adaptor is wrapping. */ const ucl_object_t *obj; public: /** * Constructor, captures a non-owning reference to a UCL object. */ StringViewAdaptor(const ucl_object_t *o) : obj(o) {} /** * Implicit cast operator. Returns a string view representing the * object. */ operator std::string_view() { const char *cstr = ucl_object_tostring(obj); if (cstr != nullptr) { return cstr; } return std::string_view("", 0); } }; /** * Duration adaptor, exposes a UCL object as a duration. * * Adaptors are intended to be short-lived, created only as temporaries, * and must not outlive the object that they are adapting. */ class DurationAdaptor { /** * Non-owning pointer to the UCL object that this adaptor is wrapping. */ const ucl_object_t *obj; public: /** * Constructor, captures a non-owning reference to the underling UCL * object. */ DurationAdaptor(const ucl_object_t *o) : obj(o) {} /** * Implicit cast operator, returns the underlying object as a duration * in seconds. */ operator std::chrono::seconds() { assert(ucl_object_type(obj) == UCL_TIME); return std::chrono::seconds( static_cast<long long>(ucl_object_todouble(obj))); } }; /** * Generic adaptor for number types. Templated with the type of the number * and the UCL function required to convert to a type that can represent * the value. * * Adaptors are intended to be short-lived, created only as temporaries, * and must not outlive the object that they are adapting. */ template<typename NumberType, auto (*Conversion)(const ucl_object_t *) = ucl_object_toint> class NumberAdaptor { /** * Non-owning pointer to the UCL object that this adaptor is wrapping. */ const ucl_object_t *obj; public: /** * Constructor, captures a non-owning reference to the underling UCL * object. */ NumberAdaptor(const ucl_object_t *o) : obj(o) {} /** * Implicit conversion operator, returns the object represented as a * `NumberType`. */ operator NumberType() { return static_cast<NumberType>(Conversion(obj)); } }; using UInt64Adaptor = NumberAdaptor<uint64_t>; using UInt32Adaptor = NumberAdaptor<uint32_t>; using UInt16Adaptor = NumberAdaptor<uint16_t>; using UInt8Adaptor = NumberAdaptor<uint8_t>; using Int64Adaptor = NumberAdaptor<int64_t>; using Int32Adaptor = NumberAdaptor<int32_t>; using Int16Adaptor = NumberAdaptor<int16_t>; using Int8Adaptor = NumberAdaptor<int8_t>; using BoolAdaptor = NumberAdaptor<bool, ucl_object_toboolean>; using FloatAdaptor = NumberAdaptor<float, ucl_object_todouble>; using DoubleAdaptor = NumberAdaptor<double, ucl_object_todouble>; /** * String for use in C++20 templates as a literal value. */ template<size_t N> struct StringLiteral { /** * Constructor, takes a string literal and provides an object that can * be used as a template parameter. */ constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); } /** * Implicit conversion, exposes the object as a string view. */ operator std::string_view() const { // Strip out the null terminator return {value, N - 1}; } /** * Implicit conversion, exposes the object as a C string. */ operator const char *() const { return value; } /** * Storage for the string. Template arguments are compared by * structural equality and so two instances of this class will compare * equal for the purpose of template instantiation of this array * contains the same set of characters. */ char value[N]; }; /** * A key-value pair of a string and an `enum` value defined in a way that * allows them to be used as template argument literals. The template * arguments should never be specified directly, they should be inferred by * calling the constructor. */ template<size_t Size, typename EnumType> struct Enum { /** * Constructor, takes a string literal defining a name and the `enum` * value that this maps to as arguments. */ constexpr Enum(const char (&str)[Size], EnumType e) : val(e) { std::copy_n(str, Size - 1, key_buffer); } /** * Internal storage for the key. Object literals in template arguments * are compared by structural equality so two instances of this refer * to the same type if they have the same character sequence here, the * same `enum` type and the same value in `val`. */ char key_buffer[Size - 1] = {0}; /** * The `enum` value that this key-value pair maps to. */ EnumType val; /** * Expose the key as a string view. */ constexpr std::string_view key() const { // Strip out the null terminator return {key_buffer, Size - 1}; } }; /** * Compile-time map from strings to `enum` values. Created by providing a * list of `Enum` object literals as template parameters. */ template<Enum... kvp> class EnumValueMap { /** * The type of a tuple of all of the key-value pairs in this map. */ using KVPs = std::tuple<decltype(kvp)...>; /** * The key-value pairs. */ static constexpr KVPs kvps{kvp...}; /** * The type of a value. All of the key-value pairs must refer to the * same `enum` type. */ using Value = std::remove_reference_t<decltype(std::get<0>(kvps).val)>; /** * Look up a key. This is `constexpr` and can be compile-time * evaluated. The template parameter is the index into the key-value * pair list to look. If the lookup fails, then this will recursively * invoke the same method on the next key-value pair. * * This is currently a linear scan, so if this is * evaluated at run time then it will be O(n). In the intended use, * `n` is small and the values of the keys are sufficiently small that * the comparison can be 1-2 instructions. Compilers seem to generate * very good code for this after inlining. */ template<size_t Element> static constexpr Value lookup(std::string_view key) noexcept { static_assert( std::is_same_v< Value, std::remove_reference_t<decltype(std::get<Element>(kvps).val)>>, "All entries must use the same enum value"); // Re if (key == std::get<Element>(kvps).key()) { return std::get<Element>(kvps).val; } if constexpr (Element + 1 < std::tuple_size_v<KVPs>) { return lookup<Element + 1>(key); } else { return static_cast<Value>(-1); } } public: /** * Looks up an `enum` value by name. This can be called at compile * time. */ static constexpr Value get(std::string_view key) noexcept { return lookup<0>(key); } }; /** * Adaptor for `enum`s. This is instantiated with the type of the `enum` * and a `EnumValueMap` that maps from strings to `enum` values. */ template<typename EnumType, typename Map> class EnumAdaptor { /** * Non-owning pointer to the UCL object that this adaptor is wrapping. */ const ucl_object_t *obj; public: /** * Constructor, captures a non-owning pointer to the underlying object. */ EnumAdaptor(const ucl_object_t *o) : obj(o) {} /** * Implicit conversion, extracts the string value and converts it to an * `enum` using the compile-time map provided as the second template * parameter. */ operator EnumType() { return Map::get(ucl_object_tostring(obj)); } }; /** * Class representing a compile-time mapping from a string to a type. This * is used to generate compile-time maps from keys to types. */ template<StringLiteral Key, typename Adaptor> struct NamedType { /** * Given a UCL object, construct an `Adaptor` from that object. */ static Adaptor construct(const ucl_object_t *obj) { return Adaptor{obj}; } /** * Return the key as a string view. */ static constexpr std::string_view key() { return Key; } }; /** * Named type adaptor. This is used to represent UCL objects that have a * field whose name describes their type. The template parameters are the * name of the key that defines the type and a list of `NamedType`s that * represent the set of valid values and the types that they represent. * * This exposes a visitor interface, where callbacks for each of the * possible types can be provided, giving a match-like API. */ template<StringLiteral KeyName, typename... Types> class NamedTypeAdaptor { /** * The underlying object that this represents. */ UCLPtr obj; /** * A type describing all of the string-to-type maps as a tuple. */ using TypesAsTuple = std::tuple<Types...>; /** * Implementation of the visitor. Recursive template that inspects * each of the possible values in the names map and invokes the visitor * with the matching type. */ template<typename T, size_t I = 0> constexpr void visit_impl(std::string_view key, T &&v) { if (key == std::tuple_element_t<I, TypesAsTuple>::key()) { return v(std::tuple_element_t<I, TypesAsTuple>::construct(obj)); } if constexpr (I + 1 < std::tuple_size_v<TypesAsTuple>) { return visit_impl<T, I + 1>(key, std::forward<T &&>(v)); } } /** * Dispatch helper. This is instantiated with an array of lambdas, one * for each matched type. It will expose all of their call operators * as different overloads. * * Taken from an example on cppreference.com. */ template<class... Fs> struct Dispatcher : Fs... { using Fs::operator()...; }; public: /** * Constructor, captures a non-owning reference to a UCL object. */ NamedTypeAdaptor(const ucl_object_t *o) : obj(o) {} /** * Visit. Can be called in two configurations, either with a single * visitor class, or with an array of lambdas each taking one of the * possible types as its sole argument. * * Either the explicit visitor or the lambda must cover all cases. * This can be done with an `auto` parameter overload as the fallback. * * WARNING: This cannot be called with a visitor class *and* lambdas, * because it will attempt to copy the visitor and so any state will * not be updated. */ template<typename... Visitors> auto visit(Visitors &&...visitors) { /** * If this is called with a single visitor, use it directly. */ if constexpr (sizeof...(Visitors) == 1) { return visit_impl(StringViewAdaptor(obj[KeyName]), visitors...); } else { return visit_impl(StringViewAdaptor(obj[KeyName]), Dispatcher{visitors...}); } } /** * Visit. This should be called with a list of lambdas as the * argument. Each lambda should take one of the types. Unlike the * `visit` method, this does not need to cover all cases. Any cases * that are not handled will be silently ignored. */ template<typename... Visitors> auto visit_some(Visitors &&...visitors) { return visit_impl(StringViewAdaptor(obj[KeyName]), Dispatcher{visitors..., [](auto &&) {}}); } }; /** * Property adaptor. Wraps some other adaptor for the value and also * provides an accessor for the key. */ template<typename Adaptor> class PropertyAdaptor : public Adaptor { public: /** * Constructor, captures a non-owning reference to a UCL object. */ PropertyAdaptor(const ucl_object_t *o) : Adaptor(o) {} /** * Provide the key as a string view. */ std::string_view key() { return ucl_object_key(Adaptor::obj); } }; /** * Helper to construct a value with an adaptor if it exists. If `o` is not * null, uses `Adaptor` to construct an instance of `T`. Returns an * `optional<T>`, where the value is present if `o` is not null. */ template<typename Adaptor, typename T = Adaptor> std::optional<T> make_optional(const ucl_object_t *o) { if (o == nullptr) { return {}; } return Adaptor(o); } } // namespace CONFIG_DETAIL_NAMESPACE
[ "David.Chisnall@microsoft.com" ]
David.Chisnall@microsoft.com
53d8f229799b9cffd83d8f7f6a7459457a46a0b2
768bda36062ffa1a5c6357b28cb8367f9b2be1ed
/AbleClass/CreadFile.cpp
e8e368057f8a0f5a2d3634afdb8b9471cc190458
[]
no_license
djia99/creadIWB
446f9c77c5e97c3774a8fd3efdf9a66e82a64f1c
6fd0b41f42b29df61dac7952249db8715de076b1
refs/heads/master
2020-04-16T22:52:46.243102
2019-01-16T07:07:53
2019-01-16T07:07:53
165,988,118
0
0
null
null
null
null
UTF-8
C++
false
false
5,395
cpp
#include "stdafx.h" #include "CreadFile.h" CCreadFile::CCreadFile() : m_nWrittenSize(0) { m_strYearMonth = _T(""); m_strDay = _T(""); memset(m_strFileName, 0, MAX_PATH * sizeof(char)); memset(m_strFilePath, 0, MAX_PATH * sizeof(char)); m_pFile = NULL; m_nDay = 0; m_bSeekEnd = FALSE; } CCreadFile::~CCreadFile() { } void CCreadFile::MakeDirectory(TCHAR *full_path) { TCHAR temp[MAX_PATH], *sp; lstrcpy(temp, full_path); sp = temp; while ((sp = _tcschr(sp, _T('\\')))) { if (sp > temp && *(sp - 1) != ':') { *sp = _T('\0'); WIN32_FIND_DATA wfd; memset(&wfd, 0, sizeof(wfd)); HANDLE hFirstFile = FindFirstFile(temp, (LPWIN32_FIND_DATA)&wfd); if (hFirstFile == INVALID_HANDLE_VALUE) { _tmkdir(temp); } else { FindClose(hFirstFile); } *sp = _T('\\'); } sp++; } } void CCreadFile::SetPath(TCHAR* pFileName, TCHAR* path) { USES_CONVERSION; COleDateTime timeNow = COleDateTime::GetCurrentTime(); CString strFileName = _T(""); CString strFilePath = _T(""); m_strYearMonth = timeNow.Format(_T("%Y%m")); m_strDay = timeNow.Format(_T("%d")); strFileName.Format(_T("%s_%s.bin"), timeNow.Format(_T("%Y%m%d_%H%M%S")), pFileName); strFilePath.Format(_T("%s\\%s\\%s\\%s"), path, m_strYearMonth, m_strDay, strFileName); int nIndex = 0; HANDLE hFirstFile; WIN32_FIND_DATA wfd; memset(&wfd, 0, sizeof(wfd)); hFirstFile = FindFirstFile(strFilePath, (LPWIN32_FIND_DATA)&wfd); while (hFirstFile != INVALID_HANDLE_VALUE) { FindClose(hFirstFile); if (nIndex > 10) break; strFileName.Format(_T("%s_%s(%d).bin"), timeNow.Format(_T("%Y%m%d_%H%M%S")), pFileName, ++nIndex); strFilePath.Format(_T("%s\\%s\\%s\\%s"), path, m_strYearMonth, m_strDay, strFileName); hFirstFile = FindFirstFile(strFilePath, (LPWIN32_FIND_DATA)&wfd); } if (timeNow.GetDay() != m_nDay) { m_nDay = timeNow.GetDay(); MakeDirectory((LPWSTR)strFilePath.operator LPCWSTR()); } strcpy_s(m_strFileName, W2A(strFileName)); strcpy_s(m_strFilePath, W2A(strFilePath)); } void CCreadFile::SetRefPath(TCHAR* pFileName, TCHAR* path) { USES_CONVERSION; COleDateTime timeNow = COleDateTime::GetCurrentTime(); CString strFileName = _T(""); CString strFilePath = _T(""); m_strYearMonth = timeNow.Format(_T("%Y%m")); m_strDay = timeNow.Format(_T("%d")); strFileName.Format(_T("%s_%s.bin"), timeNow.Format(_T("%Y%m%d_%H%M%S")), pFileName); strFilePath.Format(_T("%s\\reference\\%s"), path, strFileName); int nIndex = 0; HANDLE hFirstFile; WIN32_FIND_DATA wfd; memset(&wfd, 0, sizeof(wfd)); hFirstFile = FindFirstFile(strFilePath, (LPWIN32_FIND_DATA)&wfd); while (hFirstFile != INVALID_HANDLE_VALUE) { FindClose(hFirstFile); if (nIndex > 10) break; strFileName.Format(_T("%s_%s(%d).bin"), timeNow.Format(_T("%Y%m%d_%H%M%S")), pFileName, ++nIndex); strFilePath.Format(_T("%s\\reference\\%s"), path, strFileName); hFirstFile = FindFirstFile(strFilePath, (LPWIN32_FIND_DATA)&wfd); } if (timeNow.GetDay() != m_nDay) { m_nDay = timeNow.GetDay(); MakeDirectory((LPWSTR)strFilePath.operator LPCWSTR()); } strcpy_s(m_strFileName, W2A(strFileName)); strcpy_s(m_strFilePath, W2A(strFilePath)); } BOOL CCreadFile::CreateNewFile(TCHAR* pFileName, TCHAR* pPath) { USES_CONVERSION; if (m_pFile != NULL) fclose(m_pFile); SetPath(pFileName, pPath); //char filename[MAX_PATH]; //_itoa_s(m_nFileNumber++, filename, 10); //strcpy_s(m_strFilePath, W2A(pPath)); //strcat_s(m_strFilePath, "\\"); //strcat_s(m_strFilePath, filename); //strcpy_s(m_strFileName, filename); fopen_s(&m_pFile, m_strFilePath, "wb"); m_nWrittenSize = 0; //fwrite(&m_nWrittenSize, 1, sizeof(unsigned long long), m_pFile); if (m_pFile == NULL) return FALSE; return TRUE; } BOOL CCreadFile::CreateRefFile(TCHAR* pFileName, TCHAR* pPath) { USES_CONVERSION; if (m_pFile != NULL) fclose(m_pFile); SetRefPath(pFileName, pPath); fopen_s(&m_pFile, m_strFilePath, "wb"); m_nWrittenSize = 0; if (m_pFile == NULL) return FALSE; return TRUE; } void CCreadFile::CloseFile() { fpos_t filepos = 0; //fsetpos(m_pFile, &filepos); //fwrite(&m_nWrittenSize, 1, sizeof(unsigned long long), m_pFile); if (m_pFile != NULL) fclose(m_pFile); //CloseHandle(m_pFile); m_pFile = NULL; } void CCreadFile::SaveDat(void* pBuff, size_t bufSize) { m_nWrittenSize += bufSize; fwrite(pBuff, bufSize, bufSize, m_pFile); return; } void CCreadFile::SaveBlock(double* pBuff, int bufSize) { m_nWrittenSize += bufSize; fwrite(pBuff, 1, bufSize * sizeof(double), m_pFile); return; } void CCreadFile::SaveBlockByte(BYTE* pBuff, int bufSize) { m_nWrittenSize += bufSize; fwrite(pBuff, 1, bufSize * sizeof(BYTE), m_pFile); return; } BOOL CCreadFile::OpenFile(TCHAR* pFilePath) { if (m_pFile != NULL) fclose(m_pFile); _tfopen_s(&m_pFile, pFilePath, _T("rb")); if (m_pFile == NULL) return FALSE; return TRUE; } size_t CCreadFile::ReadBlock(double* pBuff, int bufSize) { if (m_pFile == NULL) return 0; size_t ret = fread_s(pBuff, sizeof(double) * bufSize, sizeof(double), bufSize, m_pFile); //if (ret <= sizeof(double) * bufSize) { if (ret < (size_t)bufSize) { m_bSeekEnd = TRUE; SeekSet(); } return ret; }
[ "noreply@github.com" ]
djia99.noreply@github.com
7e8e716368ba2637eefc312a437c2fb190ee2010
2ba2e7b90f2582f67790e7515a34610b94b80010
/common/strings/rebase.cc
23a8a037e535ba60bc435cab2984a25b7f2c28af
[ "Apache-2.0" ]
permissive
antmicro/verible
8354b0d3523bd66c58be9cf3a9bc2c9359734277
9f59b14270d62945521fd7e93de1f304ad9c4a28
refs/heads/master
2023-07-22T22:18:03.579585
2023-05-19T17:01:34
2023-05-19T17:01:34
221,144,955
1
2
Apache-2.0
2023-02-17T08:58:07
2019-11-12T06:21:02
C++
UTF-8
C++
false
false
1,085
cc
// Copyright 2017-2020 The Verible Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "common/strings/rebase.h" #include "common/util/logging.h" namespace verible { void RebaseStringView(absl::string_view* src, absl::string_view dest) { CHECK_EQ(*src, dest) << "RebaseStringView() is only valid when the " "new text referenced matches the old text."; *src = dest; } void RebaseStringView(absl::string_view* src, const char* dest) { RebaseStringView(src, absl::string_view(dest, src->length())); } } // namespace verible
[ "h.zeller@acm.org" ]
h.zeller@acm.org
4764164789b35e5d9e541b92a09bc153306b6fea
dde31782e6e39cf6dcbff2a4bbea46e75091693a
/src/pagespeed/kernel/base/string_util.cc
a042975da76f45202bee7af1f333987350f4933e
[]
no_license
apache/incubator-pagespeed-debian
02a320a67860118b22be3019428d3acf176fc59c
0202964b14afc20ea2a17a21444bb5be3e3c8c1c
refs/heads/master
2023-07-02T21:15:01.888831
2023-04-21T06:58:40
2023-04-21T14:55:52
78,453,135
3
5
null
2023-04-21T14:55:53
2017-01-09T17:43:02
C++
UTF-8
C++
false
false
20,638
cc
/* * Copyright 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Author: jmarantz@google.com (Joshua Marantz) #include "pagespeed/kernel/base/string_util.h" #include <algorithm> #include <cstddef> #include <cstdlib> #include <vector> #include "pagespeed/kernel/base/string.h" namespace net_instaweb { bool StringToDouble(const char* in, double* out) { char* endptr; *out = strtod(in, &endptr); if (endptr != in) { while (IsHtmlSpace(*endptr)) ++endptr; } // Ignore range errors from strtod. The values it // returns on underflow and overflow are the right // fallback in a robust setting. return *in != '\0' && *endptr == '\0'; } GoogleString StrCat(StringPiece a, StringPiece b) { GoogleString res; res.reserve(a.size() + b.size()); a.AppendToString(&res); b.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c) { GoogleString res; res.reserve(a.size() + b.size() + c.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size() + e.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); e.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size() + e.size() + f.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); e.AppendToString(&res); f.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); e.AppendToString(&res); f.AppendToString(&res); g.AppendToString(&res); return res; } GoogleString StrCat(StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g, StringPiece h) { GoogleString res; res.reserve(a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size() + h.size()); a.AppendToString(&res); b.AppendToString(&res); c.AppendToString(&res); d.AppendToString(&res); e.AppendToString(&res); f.AppendToString(&res); g.AppendToString(&res); h.AppendToString(&res); return res; } namespace internal { GoogleString StrCatNineOrMore(const StringPiece* a, ...) { GoogleString res; va_list args; va_start(args, a); size_t size = a->size(); while (const StringPiece* arg = va_arg(args, const StringPiece*)) { size += arg->size(); } res.reserve(size); va_end(args); va_start(args, a); a->AppendToString(&res); while (const StringPiece* arg = va_arg(args, const StringPiece*)) { arg->AppendToString(&res); } va_end(args); return res; } } // namespace internal void StrAppend(GoogleString* target, StringPiece a, StringPiece b) { target->reserve(target->size() + a.size() + b.size()); a.AppendToString(target); b.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c) { target->reserve(target->size() + a.size() + b.size() + c.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size() + f.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); f.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); f.AppendToString(target); g.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g, StringPiece h) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size() + h.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); f.AppendToString(target); g.AppendToString(target); h.AppendToString(target); } void StrAppend(GoogleString* target, StringPiece a, StringPiece b, StringPiece c, StringPiece d, StringPiece e, StringPiece f, StringPiece g, StringPiece h, StringPiece i) { target->reserve(target->size() + a.size() + b.size() + c.size() + d.size() + e.size() + f.size() + g.size() + h.size() + i.size()); a.AppendToString(target); b.AppendToString(target); c.AppendToString(target); d.AppendToString(target); e.AppendToString(target); f.AppendToString(target); g.AppendToString(target); h.AppendToString(target); i.AppendToString(target); } void SplitStringPieceToVector(StringPiece sp, StringPiece separators, StringPieceVector* components, bool omit_empty_strings) { size_t prev_pos = 0; size_t pos = 0; while ((pos = sp.find_first_of(separators, pos)) != StringPiece::npos) { if (!omit_empty_strings || (pos > prev_pos)) { components->push_back(sp.substr(prev_pos, pos - prev_pos)); } ++pos; prev_pos = pos; } if (!omit_empty_strings || (prev_pos < sp.size())) { components->push_back(sp.substr(prev_pos, prev_pos - sp.size())); } } void SplitStringUsingSubstr(StringPiece full, StringPiece substr, StringPieceVector* result) { StringPiece::size_type begin_index = 0; while (true) { const StringPiece::size_type end_index = full.find(substr, begin_index); if (end_index == StringPiece::npos) { const StringPiece term = full.substr(begin_index); result->push_back(term); return; } const StringPiece term = full.substr(begin_index, end_index - begin_index); if (!term.empty()) { result->push_back(term); } begin_index = end_index + substr.size(); } } void BackslashEscape(StringPiece src, StringPiece to_escape, GoogleString* dest) { dest->reserve(dest->size() + src.size()); for (const char *p = src.data(), *end = src.data() + src.size(); p != end; ++p) { if (to_escape.find(*p) != StringPiece::npos) { dest->push_back('\\'); } dest->push_back(*p); } } GoogleString CEscape(StringPiece src) { int len = src.length(); const char* read = src.data(); const char* end = read + len; int used = 0; char* dest = new char[len * 4 + 1]; for (; read != end; ++read) { unsigned char ch = static_cast<unsigned char>(*read); switch (ch) { case '\n': dest[used++] = '\\'; dest[used++] = 'n'; break; case '\r': dest[used++] = '\\'; dest[used++] = 'r'; break; case '\t': dest[used++] = '\\'; dest[used++] = 't'; break; case '\"': dest[used++] = '\\'; dest[used++] = '\"'; break; case '\'': dest[used++] = '\\'; dest[used++] = '\''; break; case '\\': dest[used++] = '\\'; dest[used++] = '\\'; break; default: if (ch < 32 || ch >= 127) { base::snprintf(dest + used, 5, "\\%03o", ch); // NOLINT used += 4; } else { dest[used++] = ch; } break; } } GoogleString final(dest, used); delete[] dest; return final; } // From src/third_party/protobuf/src/google/protobuf/stubs/strutil.h // but we don't need any other aspect of protobufs so we don't want to // incur the link cost. bool HasPrefixString(StringPiece str, StringPiece prefix) { return str.starts_with(prefix); } // From src/third_party/protobuf/src/google/protobuf/stubs/strutil.h // but we don't need any other aspect of protobufs so we don't want to // incur the link cost. void UpperString(GoogleString* s) { GoogleString::iterator end = s->end(); for (GoogleString::iterator i = s->begin(); i != end; ++i) { *i = UpperChar(*i); } } void LowerString(GoogleString* s) { GoogleString::iterator end = s->end(); for (GoogleString::iterator i = s->begin(); i != end; ++i) { *i = LowerChar(*i); } } // ---------------------------------------------------------------------- // GlobalReplaceSubstring() // Replaces all instances of a substring in a string. Returns the // number of replacements. // // NOTE: The string pieces must not overlap s. // ---------------------------------------------------------------------- int GlobalReplaceSubstring(StringPiece substring, StringPiece replacement, GoogleString* s) { CHECK(s != NULL); if (s->empty()) return 0; GoogleString tmp; int num_replacements = 0; size_t pos = 0; for (size_t match_pos = s->find(substring.data(), pos, substring.length()); match_pos != GoogleString::npos; pos = match_pos + substring.length(), match_pos = s->find(substring.data(), pos, substring.length())) { ++num_replacements; // Append the original content before the match. tmp.append(*s, pos, match_pos - pos); // Append the replacement for the match. tmp.append(replacement.begin(), replacement.end()); } // Append the content after the last match. If no replacements were made, the // original string is left untouched. if (num_replacements > 0) { tmp.append(*s, pos, s->length() - pos); s->swap(tmp); } return num_replacements; } // Erase shortest substrings in string bracketed by left and right. int GlobalEraseBracketedSubstring(StringPiece left, StringPiece right, GoogleString* string) { int deletions = 0; size_t keep_start = 0; size_t keep_end = string->find(left.data(), keep_start, left.size()); if (keep_end == GoogleString::npos) { // Fast path without allocation for no occurrences of left. return 0; } GoogleString result; result.reserve(string->size()); while (keep_end != GoogleString::npos) { result.append(*string, keep_start, keep_end - keep_start); keep_start = string->find(right.data(), keep_end + left.size(), right.size()); if (keep_start == GoogleString::npos) { keep_start = keep_end; break; } keep_start += right.size(); ++deletions; keep_end = string->find(left.data(), keep_start, left.size()); } result.append(*string, keep_start, string->size() - keep_start); string->swap(result); string->reserve(string->size()); // shrink_to_fit, C++99-style return deletions; } GoogleString JoinStringStar(const ConstStringStarVector& vector, StringPiece delim) { GoogleString result; if (vector.size() > 0) { // Precompute resulting length so we can reserve() memory in one shot. int length = delim.size() * (vector.size() - 1); for (ConstStringStarVector::const_iterator iter = vector.begin(); iter < vector.end(); ++iter) { length += (*iter)->size(); } result.reserve(length); // Now combine everything. for (ConstStringStarVector::const_iterator iter = vector.begin(); iter < vector.end(); ++iter) { if (iter != vector.begin()) { result.append(delim.data(), delim.size()); } result.append(**iter); } } return result; } bool StringCaseStartsWith(StringPiece str, StringPiece prefix) { return ((str.size() >= prefix.size()) && (0 == StringCaseCompare(prefix, str.substr(0, prefix.size())))); } bool StringCaseEndsWith(StringPiece str, StringPiece suffix) { return ((str.size() >= suffix.size()) && (0 == StringCaseCompare(suffix, str.substr(str.size() - suffix.size())))); } bool StringEqualConcat(StringPiece str, StringPiece first, StringPiece second) { return (str.size() == first.size() + second.size()) && str.starts_with(first) && str.ends_with(second); } StringPiece PieceAfterEquals(StringPiece piece) { size_t index = piece.find("="); if (index != piece.npos) { ++index; StringPiece ret = piece; ret.remove_prefix(index); TrimWhitespace(&ret); return ret; } return StringPiece(piece.data(), 0); } int CountCharacterMismatches(StringPiece s1, StringPiece s2) { int s1_length = s1.size(); int s2_length = s2.size(); int mismatches = 0; for (int i = 0, n = std::min(s1_length, s2_length); i < n; ++i) { mismatches += s1[i] != s2[i]; } return mismatches + std::abs(s1_length - s2_length); } void ParseShellLikeString(StringPiece input, std::vector<GoogleString>* output) { output->clear(); for (size_t index = 0; index < input.size();) { const char ch = input[index]; if (ch == '"' || ch == '\'') { // If we see a quoted section, treat it as a single item even if there are // spaces in it. const char quote = ch; ++index; // skip open quote output->push_back(""); GoogleString& part = output->back(); for (; index < input.size() && input[index] != quote; ++index) { if (input[index] == '\\') { ++index; // skip backslash if (index >= input.size()) { break; } } part.push_back(input[index]); } ++index; // skip close quote } else if (!IsHtmlSpace(ch)) { // Without quotes, items are whitespace-separated. output->push_back(""); GoogleString& part = output->back(); for (; index < input.size() && !IsHtmlSpace(input[index]); ++index) { part.push_back(input[index]); } } else { // Ignore whitespace (outside of quotes). ++index; } } } int CountSubstring(StringPiece text, StringPiece substring) { int number_of_occurrences = 0; size_t pos = 0; for (size_t match_pos = text.find(substring, pos); match_pos != StringPiece::npos; pos = match_pos + 1, match_pos = text.find(substring, pos)) { number_of_occurrences++; } return number_of_occurrences; } stringpiece_ssize_type FindIgnoreCase( StringPiece haystack, StringPiece needle) { stringpiece_ssize_type pos = 0; while (haystack.size() >= needle.size()) { if (StringCaseStartsWith(haystack, needle)) { return pos; } ++pos; haystack.remove_prefix(1); } return StringPiece::npos; } // In-place StringPiece whitespace trimming. This mutates the StringPiece. bool TrimLeadingWhitespace(StringPiece* str) { // We use stringpiece_ssize_type to avoid signedness problems. stringpiece_ssize_type size = str->size(); stringpiece_ssize_type trim = 0; while (trim != size && IsHtmlSpace(str->data()[trim])) { ++trim; } str->remove_prefix(trim); return (trim > 0); } bool TrimTrailingWhitespace(StringPiece* str) { // We use stringpiece_ssize_type to avoid signedness problems. stringpiece_ssize_type rightmost = str->size(); while (rightmost != 0 && IsHtmlSpace(str->data()[rightmost - 1])) { --rightmost; } if (rightmost != str->size()) { str->remove_suffix(str->size() - rightmost); return true; } return false; } bool TrimWhitespace(StringPiece* str) { // We *must* trim *both* leading and trailing spaces, so we use the // non-shortcut bitwise | on the boolean results. return TrimLeadingWhitespace(str) | TrimTrailingWhitespace(str); } namespace { bool TrimCasePattern(StringPiece pattern, StringPiece* str) { bool did_something = false; if (StringCaseStartsWith(*str, pattern)) { str->remove_prefix(pattern.size()); did_something = true; } if (StringCaseEndsWith(*str, pattern)) { str->remove_suffix(pattern.size()); did_something = false; } return did_something; } } // namespace void TrimQuote(StringPiece* str) { TrimWhitespace(str); if (str->starts_with("\"") || str->starts_with("'")) { str->remove_prefix(1); } if (str->ends_with("\"") || str->ends_with("'")) { str->remove_suffix(1); } TrimWhitespace(str); } void TrimUrlQuotes(StringPiece* str) { TrimWhitespace(str); bool cont = true; // Unwrap a string with an arbitrary nesting of real and URL percent-encoded // quotes. We do this one layer at a time, always removing backslashed // quotes before removing un-backslashed quotes. while (cont) { cont = (TrimCasePattern("%5C%27", str) || // \" TrimCasePattern("%5C%22", str) || // \' TrimCasePattern("%27", str) || // " TrimCasePattern("%22", str) || // ' TrimCasePattern("\"", str) || TrimCasePattern("'", str)); } TrimWhitespace(str); } // TODO(jmarantz): This is a very slow implementation. But strncasecmp // will fail test StringCaseTest.Locale. If this shows up as a performance // bottleneck then an SSE implementation would be better. int StringCaseCompare(StringPiece s1, StringPiece s2) { for (int i = 0, n = std::min(s1.size(), s2.size()); i < n; ++i) { unsigned char c1 = UpperChar(s1[i]); unsigned char c2 = UpperChar(s2[i]); if (c1 < c2) { return -1; } else if (c1 > c2) { return 1; } } if (s1.size() < s2.size()) { return -1; } else if (s1.size() > s2.size()) { return 1; } return 0; } bool MemCaseEqual(const char* s1, size_t size1, const char* s2, size_t size2) { if (size1 != size2) { return false; } for (; size1 != 0; --size1, ++s1, ++s2) { if (UpperChar(*s1) != UpperChar(*s2)) { return false; } } return true; } bool SplitStringPieceToIntegerVector(StringPiece src, StringPiece separators, std::vector<int>* ints) { StringPieceVector values; SplitStringPieceToVector( src, separators, &values, true /* omit_empty_strings */); ints->clear(); int v; for (int i = 0, n = values.size(); i < n; ++i) { if (StringToInt(values[i], &v)) { ints->push_back(v); } else { ints->clear(); return false; } } return true; } } // namespace net_instaweb
[ "morlovich@google.com" ]
morlovich@google.com
b37bcff6cbdfc524dc36bd98e7e90849d50f560d
357fe03065b6cb5e15272f0f426e2bfaec39b004
/2020-21-1/algo II/codes/minta/bruteforce.cpp
31b4d5893371927e3d3d9f0f651f75445bbff962
[]
no_license
imdonix/elte-ik-bsc
f2101456dac556264ee5bed0650829bf9522fbaa
126181bebcf9af323b54222a2177eb8dbb797144
refs/heads/master
2023-07-30T23:36:03.440246
2022-05-17T21:25:57
2022-05-17T21:25:57
219,555,437
6
4
null
2021-11-17T22:07:07
2019-11-04T17:15:05
C++
UTF-8
C++
false
false
801
cpp
#include <iostream> #include <string> #include <vector> void print_results(std::vector<int> S) { std::cout << "Talalatok:"; for (int i = 0; i < S.size(); i++) { std::cout << " " << S[i]; } std::cout << std::endl; } void Bruteforce(const std::string& T, const std::string& P) { std::cout << "Bruteforce algoritmus" << std::endl << std::endl; std::vector<int> S; int n = T.length(), m = P.length(); for (int i = 0; i <= n - m; i++) { int j = 0; while (j < m && T[i+j] == P[j]) { j++; } if (j == m) { S.push_back(i); } } print_results(S); } int main() { std::string txt("ADABACACACABADABABADABABA"); std::string pat("ADABABA"); Bruteforce(txt, pat); return 0; }
[ "tamas.donix@gmail.com" ]
tamas.donix@gmail.com
260f9098c4a0b2b5a0d516371ad5578cdfac05e7
74dda91e9469dd2b95f5f1448ac7ac36b2624f8a
/case_Dziekson/0/p
0bd05f02559921ea9d59187584ec3fae894d550e
[]
no_license
DomDziekan/Obliczenia-Inzynierskie-w-chmurze
fa87735170342bd46b6b90cf0aadc956e7882823
b1eb2ebaa87671b5c1ce41694a63d67e793711ee
refs/heads/master
2020-04-20T21:55:42.116565
2019-02-07T18:53:45
2019-02-07T18:53:45
169,123,050
0
0
null
null
null
null
UTF-8
C++
false
false
1,043
/*--------------------------------*- C++ -*----------------------------------*| ========= | | | \ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \ / O peration | Version: 2.0.1 | | \ / A nd | Web: www.OpenFOAM.com | | \/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField uniform 0; boundaryField { in { type zeroGradient; } out { type fixedValue; value uniform 0; } walls { type zeroGradient; } si { type symmetryPlane; } }
[ "noreply@github.com" ]
DomDziekan.noreply@github.com
65af69b3a62a2cefb728a24d7cdb00f293047b4c
0e8f68043c4349175c7a877aa0b89201c1fe1c76
/leetcode/Discuss/027.Serialization.Deserialization.of.a.Binary.Tree.II.cpp
5ba16454fee09742c3fbe908f9d9f343a194f1be
[]
no_license
jiabailie/Algorithm
f26f0d9f5e4e4b1d42cee7d2150cfc49ca2c6faf
1357cccf698a98a32e7e03a84d697478b56e3fe5
refs/heads/master
2021-01-25T07:08:20.331355
2016-11-23T06:25:26
2016-11-23T06:25:26
9,423,405
0
0
null
null
null
null
UTF-8
C++
false
false
3,246
cpp
#include <cstdio> #include <iostream> #include <fstream> #include <vector> #include <cstring> #include <vld.h> using namespace std; struct TreeNode { int i_val; TreeNode *p_left; TreeNode *p_right; TreeNode() : i_val(0), p_left(0), p_right(0) {} TreeNode(int val) : i_val(val), p_left(0), p_right(0) {} TreeNode(const TreeNode &treeNode) : i_val(treeNode.i_val), p_left(treeNode.p_left), p_right(treeNode.p_right) {} TreeNode &operator=(const TreeNode &treeNode) { if(this != &treeNode) { this->i_val = treeNode.i_val; this->p_left = treeNode.p_left; this->p_right = treeNode.p_right; } return *this; } }; // whether the next char is splitting token inline bool isToken(char c, string &token) { for(string::iterator it = token.begin(); it != token.end(); ++it) { if(c == (*it)) { return true; } } return false; } // whether the next word is number or not inline bool isNumber(string &str) { if(str.size() == 0) { return false; } for(int i = 0; i < str.size(); ++i) { if(str[i] < '0' || str[i] > '9') { return false; } } return true; } // transfer a string to integer int str2int(string &str) { int ret = 0; for(int i = 0; i < str.size(); ++i) { ret = ret * 10 + (str[i] - '0'); } return ret; } // read text from file // here, the text in file is // 30 10 50 # # # 20 45 # # 35 # # vector<string> readFile(ifstream &in, string &token) { if(!in.is_open()) { cout << "Error during opening the file." << endl; exit(1); } char c; string word; vector<string> vec_Str; while(in.get(c)) { if(!isToken(c, token)) { word.push_back(c); continue; } if(word.length() > 0) { vec_Str.push_back(string(word.begin(), word.end())); word.clear(); } } if(word.length() > 0) { vec_Str.push_back(string(word.begin(), word.end())); } return vec_Str; } // Deserialize the binary tree TreeNode *DeserializeTree(int &cur, vector<string> &vec_SerialTree) { if(cur < 0 || cur >= vec_SerialTree.size() || vec_SerialTree.size() == 0 || !isNumber(vec_SerialTree[cur])) { return 0; } TreeNode *p_Node = new TreeNode(str2int(vec_SerialTree[cur])); cur = cur + 1; p_Node->p_left = DeserializeTree(cur, vec_SerialTree); cur = cur + 1; p_Node->p_right = DeserializeTree(cur, vec_SerialTree); return p_Node; } // Serialize the binary tree void SerializeTree(TreeNode *p_Root, ostream &out) { if(!p_Root) { out << "# "; } else { out << p_Root->i_val << " "; SerializeTree(p_Root->p_left, out); SerializeTree(p_Root->p_right, out); } } // Release the resources void DestroyTree(TreeNode **p_Root) { if(!p_Root || !(*p_Root)) { return; } DestroyTree(&((*p_Root)->p_left)); DestroyTree(&((*p_Root)->p_right)); delete *p_Root; p_Root = 0; } int main() { string token(" "); ifstream in("D:/Lab/clab/file/1.txt"); ofstream out("D:/Lab/clab/file/2.txt"); vector<string> vec_SerialTree = readFile(in, token); int cur = 0; TreeNode *p_Root = DeserializeTree(cur, vec_SerialTree); if(out) { SerializeTree(p_Root, out); } DestroyTree(&p_Root); return 0; }
[ "spotlightyrg@gmail.com" ]
spotlightyrg@gmail.com
711d1a5a1d7e264265d76bc1a8d8f2a479916e16
efc9f7ce45fd208d6ed43c41ea9a6ed8b4664feb
/src/libs/SGAL/lib/geometries/Tex_coord_array.cpp
719f9d341626352df01de84ee5ece1e1574fc61d
[]
no_license
efifogel/sgal
312d604e879240baae60e82faa87acc637a38542
bb3ebcb1c06aff311f3ea095f50e02cc6bd2983e
refs/heads/master
2020-03-27T22:15:31.407935
2018-09-03T13:38:10
2018-09-03T13:38:10
147,217,311
4
0
null
null
null
null
UTF-8
C++
false
false
1,673
cpp
// Copyright (c) 2013 Israel. // All rights reserved. // // This file is part of SGAL; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; version 2.1 of the // License. See the file LICENSE.LGPL distributed with SGAL. // // 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. // // Author(s) : Efi Fogel <efifogel@gmail.com> #include <iostream> #include <sstream> #include "SGAL/Tex_coord_array.hpp" #include "SGAL/Element.hpp" #include "SGAL/Container_proto.hpp" SGAL_BEGIN_NAMESPACE //! The node prototype. Container_proto* Tex_coord_array::s_prototype(nullptr); //! \brief initializes the node prototype. void Tex_coord_array::init_prototype() { if (s_prototype) return; s_prototype = new Container_proto(Container::get_prototype()); } //! \brief deletes the node prototype. void Tex_coord_array::delete_prototype() { delete s_prototype; s_prototype = NULL; } //! \brief obtains the node prototype. Container_proto* Tex_coord_array::get_prototype() { if (s_prototype == NULL) Tex_coord_array::init_prototype(); return s_prototype; } //! \brief sets the attributes of the object extracted from an input file. void Tex_coord_array::set_attributes(Element* elem) { Container::set_attributes(elem); // Remove all the deleted attributes: elem->delete_marked(); } SGAL_END_NAMESPACE
[ "efifogel@gmail.com" ]
efifogel@gmail.com
29bac6eb072cda6fa0fb39475862ac1f3edf5d20
7fa6aa899c62125789da0368c3cbd514cd7def10
/PagedLOD/Tests/UnitTests/TestCase_3002/test.cpp
25ef21dd679448ad90213c5b206006fba520d774
[]
no_license
xiaoqiye/RFPagedLOD
f78e72d537319101063980a98b675eec13f37b32
aa0eefe17955cef5144874612d0d37f34b2f21fc
refs/heads/master
2022-11-21T20:18:59.908851
2020-07-26T12:21:31
2020-07-26T12:21:31
255,565,532
0
0
null
null
null
null
UTF-8
C++
false
false
1,886
cpp
#include "pch.h" #include "MockData.h" TEST(TestMeshLURList, TestPushTileNode) { auto LRUList = MockData::createMeshLRUList(); //1 insert LRUList.push(SSplayElement("Tile_1_3.bin", 400, 400)); LRUList.push(SSplayElement("Tile_1_2_1.bin", 300, 200)); LRUList.push(SSplayElement("Tile_1_2_0.bin", 200, 200)); LRUList.push(SSplayElement("Tile_1_1.bin", 100, 100)); //1_1->1_2_0->1_2_1->1_3; memsize = 1700 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1700); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_1_1.bin"); //2 update LRUList.push(SSplayElement("Tile_1_2_0.bin", 200, 200)); LRUList.push(SSplayElement("Tile_1_3.bin", 400, 400)); //1_3->1_2_0->1_1->1_2_1; memsize = 1700 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1700); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_1_3.bin"); //3 delete LRUList.push(SSplayElement("Tile_2_2_0.bin", 400, 200)); //2_2_0->1_3->1_2_0->1_1; memsize = 2000 EXPECT_EQ(LRUList.getCurrentMemorySize(), 2000); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_2_2_0.bin"); EXPECT_EQ(LRUList.getBackNode().MeshName, "Tile_1_1.bin"); LRUList.push(SSplayElement("Tile_2_2_1.bin", 500, 200)); //2_2_1->2_2_0->1_3; memsize = 1900 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1900); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_2_2_1.bin"); EXPECT_EQ(LRUList.getBackNode().MeshName, "Tile_1_3.bin"); LRUList.push(SSplayElement("Tile_1_3.bin", 400, 400)); //1_3->2_2_0->2_2_1; memsize = 1900 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1900); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_1_3.bin"); EXPECT_EQ(LRUList.getBackNode().MeshName, "Tile_2_2_1.bin"); LRUList.push(SSplayElement("Tile_3_3.bin", 800, 100)); //3_3->1_3; memsize = 1700 EXPECT_EQ(LRUList.getCurrentMemorySize(), 1700); EXPECT_EQ(LRUList.getFrontNode().MeshName, "Tile_3_3.bin"); EXPECT_EQ(LRUList.getBackNode().MeshName, "Tile_1_3.bin"); }
[ "806707499@qq.com" ]
806707499@qq.com
bfaf862660651a6e89249f4d705084e413f2ae9f
4e70b3c405ac56c985f61b6394591fae98563eb0
/configuration.cpp
fcf8c7c00dd6869eb80146375fd20a4d96ae5cc2
[]
no_license
chrisschuette/GL.Minimizer
06c6833f26d8d3a907a7e85e44c5277a8788e504
aed4339e8025295c1156c7df56a90dd70cb2cf80
refs/heads/master
2021-01-25T07:28:15.472121
2014-06-28T10:39:32
2014-06-28T10:39:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,169
cpp
/* * File: Configuration.cpp * Author: chris * * Created on January 2, 2012, 2:32 PM */ #include "configuration.h" #include "exception.h" #include "utils.h" #include "luainterpreter.h" #include <iostream> #include <sstream> using namespace basic; bool Configuration::s_registered = scripting::LuaInterpreter::getInstance().addRegisterFunction(Configuration::Register); void Configuration::Register() { #ifndef LUADISABLED scripting::LuaInterpreter& luaInterpreter = scripting::LuaInterpreter::getInstance(); if(!luaInterpreter.isClassRegistered("Configuration")) { luabind::module(luaInterpreter.getL()) [ luabind::class_< Configuration >("Configuration") .def("readFile", &Configuration::readFile) .def("addSetting", &Configuration::addSetting) .def("editSetting", &Configuration::editSetting) .def("getDouble", &Configuration::getDouble) .def("getBool", &Configuration::getBool) .def("getInteger", &Configuration::getInteger) .def("getString", &Configuration::getString) //dictionary ]; luaInterpreter.setClassRegistered("Configuration"); } #endif } std::auto_ptr<Configuration> Configuration::m_instancePtr(0); Configuration& Configuration::getInstance() { if(m_instancePtr.get() == 0) { m_instancePtr = std::auto_ptr<Configuration>(new Configuration); } return *m_instancePtr.get(); } Configuration::Configuration() : Named("Configuration") { } void Configuration::readFile(std::string configFile) { try { m_configuration.readFile(configFile.c_str()); } catch (libconfig::SettingTypeException& ste) { ERROR(std::string("invalid type for ") + std::string(ste.getPath())); } catch(libconfig::SettingNotFoundException& snfe) { ERROR(std::string("setting not found: ") + snfe.getPath()); } catch (libconfig::ParseException& pe) { ERROR(std::string("unable to parse config file ") + pe.getFile() + " at line " + utils::toString(pe.getLine())); } catch(libconfig::FileIOException& fioe) { ERROR("Unable to read file " + configFile) } catch (...) { throw; // someone will be interested in this } } void Configuration::addSetting(std::string path, std::string name, std::string value) { libconfig::Setting& group = m_configuration.lookup(path); libconfig::Setting& setting = group.add(name, libconfig::Setting::TypeString); setting = value; } void Configuration::editSetting(std::string path, std::string name, double value) { std::string fullpath = ""; if(path != "") fullpath = path + "."; fullpath += name; libconfig::Setting& setting = m_configuration.lookup(fullpath); setting = value; } double Configuration::getDouble(std::string path) { return m_configuration.lookup(path); } bool Configuration::getBool(std::string path) { return m_configuration.lookup(path); } int Configuration::getInteger(std::string path) { return m_configuration.lookup(path); } std::string Configuration::getString(std::string path){ return m_configuration.lookup(path); } Configuration::~Configuration() { }
[ "mail@christophschuette.com" ]
mail@christophschuette.com
cecf04243930bf73b99295818f8167dc73848408
9e7ad0241ab120559af94050a1e31c62f1d63941
/addons/ofxRaycaster/example-segment-intersection/src/ofApp.h
6b65952d4497607612f56de41984d22dd4d3fb12
[]
no_license
nickdchee/CityBuilderRTS
d27117ab7aa7ac672d1d5cc83556752cbbfc77a2
16e77418bdbae36cb0f01e22bf8a340ab894365b
refs/heads/master
2020-04-16T17:38:59.848644
2019-01-29T08:08:19
2019-01-29T08:08:19
165,784,090
1
0
null
2019-01-20T16:52:31
2019-01-15T04:15:49
C++
UTF-8
C++
false
false
811
h
#pragma once #include "ofMain.h" #include "ofxRaycaster.h" class ofApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void mouseEntered(int x, int y); void mouseExited(int x, int y); void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); void drawLegend(glm::vec2 rayOrig, glm::vec2 intersection,bool intersects); ofxraycaster::Ray<glm::vec2> ray; ofxraycaster::Plane<glm::vec2> plane; glm::vec2 p1 = glm::vec2(700, 80); glm::vec2 p2 = glm::vec2(900, 600); };
[ "tiganov@ualberta.ca" ]
tiganov@ualberta.ca
32d23bdc35819faea861565dc2c47cebf243ae0f
71e5b5cd3b6834fa1f342b991dffb7212816274b
/ldr/ldr.ino
4be4ac35397d6740d272480feaa1b589311efde1
[ "Apache-2.0" ]
permissive
trcclub/Basic-Arduino-Projects
b222296509cb5830c6ab91468696d99f0b8fe35d
230cbad2fd8008f529ee5b983c66c3e8fb264e41
refs/heads/master
2022-06-01T02:00:38.371728
2020-04-22T17:39:43
2020-04-22T17:39:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
227
ino
int sensorPin=A0;//select the inputpin for LDR int sensorValue=0; void setup() { Serial.begin(9600); } void loop(){ sensorValue = analogRead(sensorPin); Serial.print("sensorValue"); Serial.println(sensorValue); delay(250); }
[ "thameemk612@gmail.com" ]
thameemk612@gmail.com
166983321fd345be2f23756dd9eb5c173ff36f0b
5e9c396ea5d81dce62ef4e6f260db21385608922
/src/chrono_vehicle/tracked_vehicle/track_shoe/TrackShoeSinglePin.cpp
662719708ee0afb9888a706b36fe4223ec05d57d
[ "BSD-3-Clause" ]
permissive
gvvynplaine/chrono
357b30f896eb6c1dcabcebd0d88f10fab3faff20
a3c0c8735eb069d5c845a7b508a048b58e022ce0
refs/heads/develop
2023-01-05T08:43:13.115419
2020-07-09T08:24:34
2020-07-09T08:24:34
278,308,549
0
0
BSD-3-Clause
2020-10-30T12:17:47
2020-07-09T08:33:24
null
UTF-8
C++
false
false
6,892
cpp
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Single-pin track shoe constructed with data from file (JSON format). // // ============================================================================= #include "chrono/assets/ChTriangleMeshShape.h" #include "chrono_vehicle/ChVehicleModelData.h" #include "chrono_vehicle/tracked_vehicle/track_shoe/TrackShoeSinglePin.h" #include "chrono_vehicle/utils/ChUtilsJSON.h" #include "chrono_thirdparty/filesystem/path.h" using namespace rapidjson; namespace chrono { namespace vehicle { // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- TrackShoeSinglePin::TrackShoeSinglePin(const std::string& filename) : ChTrackShoeSinglePin(""), m_has_mesh(false) { Document d = ReadFileJSON(filename); if (d.IsNull()) return; Create(d); GetLog() << "Loaded JSON: " << filename.c_str() << "\n"; } TrackShoeSinglePin::TrackShoeSinglePin(const rapidjson::Document& d) : ChTrackShoeSinglePin(""), m_has_mesh(false) { Create(d); } void TrackShoeSinglePin::Create(const rapidjson::Document& d) { // Invoke base class method. ChPart::Create(d); // Read shoe body geometry and mass properties assert(d.HasMember("Shoe")); m_shoe_height = d["Shoe"]["Height"].GetDouble(); m_shoe_pitch = d["Shoe"]["Pitch"].GetDouble(); m_shoe_mass = d["Shoe"]["Mass"].GetDouble(); m_shoe_inertia = ReadVectorJSON(d["Shoe"]["Inertia"]); // Read location of guide pin center (for detracking control) m_pin_center = ReadVectorJSON(d["Guide Pin Center"]); // Read contact data assert(d.HasMember("Contact")); assert(d["Contact"].HasMember("Cylinder Material")); assert(d["Contact"].HasMember("Shoe Materials")); assert(d["Contact"].HasMember("Cylinder Shape")); assert(d["Contact"].HasMember("Shoe Shapes")); assert(d["Contact"]["Shoe Materials"].IsArray()); assert(d["Contact"]["Shoe Shapes"].IsArray()); // Read contact material information (defer creating the materials until CreateContactMaterials) m_cyl_mat_info = ReadMaterialInfoJSON(d["Contact"]["Cylinder Material"]); int num_mats = d["Contact"]["Shoe Materials"].Size(); for (int i = 0; i < num_mats; i++) { MaterialInfo minfo = ReadMaterialInfoJSON(d["Contact"]["Shoe Materials"][i]); m_shoe_mat_info.push_back(minfo); } // Read geometric collison data m_cyl_radius = d["Contact"]["Cylinder Shape"]["Radius"].GetDouble(); m_front_cyl_loc = d["Contact"]["Cylinder Shape"]["Front Offset"].GetDouble(); m_rear_cyl_loc = d["Contact"]["Cylinder Shape"]["Rear Offset"].GetDouble(); int num_shapes = d["Contact"]["Shoe Shapes"].Size(); for (int i = 0; i < num_shapes; i++) { const Value& shape = d["Contact"]["Shoe Shapes"][i]; std::string type = shape["Type"].GetString(); int matID = shape["Material Index"].GetInt(); assert(matID >= 0 && matID < num_mats); if (type.compare("BOX") == 0) { ChVector<> pos = ReadVectorJSON(shape["Location"]); ChQuaternion<> rot = ReadQuaternionJSON(shape["Orientation"]); ChVector<> dims = ReadVectorJSON(shape["Dimensions"]); m_coll_boxes.push_back(BoxShape(pos, rot, dims, matID)); } else if (type.compare("CYLINDER") == 0) { ChVector<> pos = ReadVectorJSON(shape["Location"]); ChQuaternion<> rot = ReadQuaternionJSON(shape["Orientation"]); double radius = shape["Radius"].GetDouble(); double length = shape["Length"].GetDouble(); m_coll_cylinders.push_back(CylinderShape(pos, rot, radius, length, matID)); } } // Read visualization data if (d.HasMember("Visualization")) { if (d["Visualization"].HasMember("Mesh")) { m_meshFile = d["Visualization"]["Mesh"].GetString(); m_has_mesh = true; } if (d["Visualization"].HasMember("Primitives")) { assert(d["Visualization"]["Primitives"].IsArray()); int num_shapes = d["Visualization"]["Primitives"].Size(); for (int i = 0; i < num_shapes; i++) { const Value& shape = d["Visualization"]["Primitives"][i]; std::string type = shape["Type"].GetString(); if (type.compare("BOX") == 0) { ChVector<> pos = ReadVectorJSON(shape["Location"]); ChQuaternion<> rot = ReadQuaternionJSON(shape["Orientation"]); ChVector<> dims = ReadVectorJSON(shape["Dimensions"]); m_vis_boxes.push_back(BoxShape(pos, rot, dims)); } else if (type.compare("CYLINDER") == 0) { ChVector<> pos = ReadVectorJSON(shape["Location"]); ChQuaternion<> rot = ReadQuaternionJSON(shape["Orientation"]); double radius = shape["Radius"].GetDouble(); double length = shape["Length"].GetDouble(); m_vis_cylinders.push_back(CylinderShape(pos, rot, radius, length)); } } } } } void TrackShoeSinglePin::CreateContactMaterials(ChContactMethod contact_method) { m_cyl_material = m_cyl_mat_info.CreateMaterial(contact_method); for (auto minfo : m_shoe_mat_info) { m_shoe_materials.push_back(minfo.CreateMaterial(contact_method)); } } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- void TrackShoeSinglePin::AddVisualizationAssets(VisualizationType vis) { if (vis == VisualizationType::MESH && m_has_mesh) { auto trimesh = chrono_types::make_shared<geometry::ChTriangleMeshConnected>(); trimesh->LoadWavefrontMesh(vehicle::GetDataFile(m_meshFile), false, false); auto trimesh_shape = chrono_types::make_shared<ChTriangleMeshShape>(); trimesh_shape->SetMesh(trimesh); trimesh_shape->SetName(filesystem::path(m_meshFile).stem()); trimesh_shape->SetStatic(true); m_shoe->AddAsset(trimesh_shape); } else { ChTrackShoeSinglePin::AddVisualizationAssets(vis); } } } // end namespace vehicle } // end namespace chrono
[ "serban@wisc.edu" ]
serban@wisc.edu
f261c6aab6aaf1707ad00245a1180d01e8d80a52
e27d9e460c374473e692f58013ca692934347ef1
/drafts/quickSpectrogram_2/libraries/liblsl/external/lslboost/spirit/home/phoenix/object/construct.hpp
a278872d71753b23f52406af9732eff0a821a753
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
thoughtworksarts/Dual_Brains
84a0edf69d95299021daf4af9311aed5724a2e84
a7a6586b91a280950693b427d8269bd68bf8a7ab
refs/heads/master
2021-09-18T15:50:51.397078
2018-07-16T23:20:18
2018-07-16T23:20:18
119,759,649
3
0
null
2018-07-16T23:14:34
2018-02-01T00:09:16
HTML
UTF-8
C++
false
false
2,573
hpp
/*============================================================================= Copyright (c) 2001-2007 Joel de Guzman Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.lslboost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef PHOENIX_OBJECT_CONSTRUCT_HPP #define PHOENIX_OBJECT_CONSTRUCT_HPP #include <lslboost/spirit/home/phoenix/core/compose.hpp> #include <lslboost/preprocessor/repetition/enum_params_with_a_default.hpp> namespace lslboost { namespace phoenix { namespace detail { template <typename T> struct construct_eval { template <typename Env, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( PHOENIX_COMPOSITE_LIMIT, typename T, fusion::void_)> struct result { typedef T type; }; template <typename RT, typename Env> static RT eval(Env const& /*env*/) { return RT(); } template <typename RT, typename Env, typename A0> static RT eval(Env const& env, A0& _0) { return RT(_0.eval(env)); } template <typename RT , typename Env, typename A0, typename A1> static RT eval(Env const& env, A0& _0, A1& _1) { return RT(_0.eval(env), _1.eval(env)); } // Bring in the rest of the evals #include <lslboost/spirit/home/phoenix/object/detail/construct_eval.hpp> }; } template <typename T> inline actor<typename as_composite<detail::construct_eval<T> >::type> construct() { return compose<detail::construct_eval<T> >(); } template <typename T, typename A0> inline actor<typename as_composite<detail::construct_eval<T>, A0>::type> construct(A0 const& _0) { return compose<detail::construct_eval<T> >(_0); } template <typename T, typename A0, typename A1> inline actor<typename as_composite<detail::construct_eval<T>, A0, A1>::type> construct(A0 const& _0, A1 const& _1) { return compose<detail::construct_eval<T> >(_0, _1); } // Bring in the rest of the new_ functions #include <lslboost/spirit/home/phoenix/object/detail/construct.hpp> }} #endif
[ "gabriel.ibagon@gmail.com" ]
gabriel.ibagon@gmail.com
b367509d880debf451309c520306dc9492177831
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5631572862566400_1/C++/psir/bffs.cpp
49020311517c0529e5564d03d6a2dd435d1e0bf7
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
3,067
cpp
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstdio> #include <map> #include <cstdlib> #include <cstring> #include <fstream> #include <set> #define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i)) #define FORC(it,cont) for(__typeof(cont.begin()) it=(cont).begin(); it!=(cont).end();++(it)) #define VI vector<int> #define VS vector<string> #define maxN 2000 using namespace std; vector< VI > adj; vector< VI > dabl; int visited[maxN]; int visited2[maxN]; VI cycle; set<int> S; void extract_cycle(int pos, int last) { //cout << pos << " " << last << endl; cycle.push_back(pos); if( pos == last ) return; extract_cycle(visited[pos],last); return; } void dfs(int pos) { //cout << pos << endl; //system("pause"); FOR(j,0,adj[pos].size()) { int pnew = adj[pos][j]; if (visited[pos] == pnew ) continue; if( visited[pnew] == -5 ) { visited[adj[pos][j]] = pos; dfs(adj[pos][j]); } else if(cycle.size() == 0) { extract_cycle(pos,pnew); } } //cout << pos << endl; //system("pause"); FOR(j,0,dabl[pos].size()) { int pnew = dabl[pos][j]; if( visited[pnew]!= -5 && cycle.size() == 0) { extract_cycle(pos,pnew); } } return; } int dfs2(int pos,int parent) { int sol = 0; FOR(i,0,adj[pos].size()) { int pnew = adj[pos][i]; if(S.count(pnew) == 0 && pnew != parent ) sol = max(sol, 1 + dfs2(pnew,pos)); } return sol; } int main() { int T,N; ifstream fcin("in.txt",ios::in); FILE* fout; fout = fopen("out.txt","w"); fcin >> T; FOR(tc,0,T) { //cout << "test " << tc << endl; // system("pause"); fcin >> N; VI x(N); FOR(i,0,N) {fcin >> x[i]; --x[i];} adj.resize(0); adj.resize(N); dabl.resize(0); dabl.resize(N); FOR(i,0,N) { if( x[i] < i && x[x[i]] == i ) { dabl[i].push_back(x[i]); dabl[x[i]].push_back(i); } else { adj[i].push_back(x[i]); adj[x[i]].push_back(i); } } FOR(i,0,N) { visited[i] = -5; visited2[i] = -5; } VI CL; VI TS; FOR(i,0,N) if( visited[i] == -5 ) { // cout << "start at " << i << " of " << N << endl; cycle.resize(0); visited[i] = -1; dfs(i); int csize = cycle.size(); if (csize > 2 ) { CL.push_back(csize); TS.push_back(csize); continue; } S.clear(); FOR(j,0,cycle.size()) S.insert(cycle[j]); VI maxdepth(cycle.size()); FOR(j,0,cycle.size()) maxdepth[j] = dfs2(cycle[j],cycle[j]); sort(maxdepth.begin(),maxdepth.end()); int depth = maxdepth[csize-1] + maxdepth[csize -2]; CL.push_back(csize); TS.push_back(csize + depth); } int maxC = 0; int TS2 = 0; FOR(i,0,CL.size()) { maxC = max(maxC,CL[i]); if( CL[i] == 2 ) TS2 += TS[i]; } int res = max(maxC,TS2); fprintf(fout,"Case #%d: %d\n",tc+1,res); } fcin.close(); return 0; }
[ "alexandra1.back@gmail.com" ]
alexandra1.back@gmail.com
9b5c494c80cc3db7ddb7592d1fb97c92155b5528
0733126cd332199e01982462c5a282c49e33a9cf
/Algorithm/cpp/67.AddBinary.cpp
b2fa5263f871bcafbbfa081c7c7eb7b5ddcc8fc9
[ "MIT" ]
permissive
741zxc606/LeetCodePractices
70d271f70a4ecc5e2506dc842c5f610dd5eea1b7
6a87edf601ecc52d627b1a5e19b96983fc37bc92
refs/heads/master
2021-06-04T20:24:52.674715
2019-12-31T08:16:55
2019-12-31T08:16:55
95,416,039
0
0
null
2019-01-10T03:01:22
2017-06-26T06:37:02
C++
UTF-8
C++
false
false
1,026
cpp
/* * 67.Add Binary * Given two binary strings,return their sum(also a binary string). * For example, * a = "11" * b = "1" * return "100" */ #include <iostream> #include <string> #include <vector> using namespace std; class Solution { public: string addBinary(string a, string b) { int alen = a.size(); int blen = b.size(); bool carry = false; string result; while (alen>0||blen>0) { int abit = alen <= 0 ? 0 : a[alen - 1] - '0'; int bbit = blen <= 0 ? 0 : b[blen - 1] - '0'; int cbit = carry ? 1 : 0; result.insert(result.begin(), '0' + ((abit + bbit + cbit) & 1)); carry = (abit+bbit+cbit>1); alen--; blen--; } if (carry) { result.insert(result.begin(), '1'); } return result; } }; int main() { string a = "1"; string b = "11"; Solution s; cout << a << "+" << b << "=" << s.addBinary(a, b) << endl; return 0; }
[ "noreply@github.com" ]
741zxc606.noreply@github.com
30c29ee641f1f979c8f265d6906064860003f7be
fb9a9e720c116281da77d77bc8648e7f010322a3
/01-1/Betweenadder/betweenAdder.cpp
b1efee65ff7319b773a5901faaf79c734c239107
[]
no_license
Jelcream/Cpp_study
fac6e706e6f903ace237cebac56bf4ab9eac6673
c3b073b1630bd97c2fd7617f37feed3ba971612d
refs/heads/master
2023-03-30T06:07:32.207733
2021-04-05T16:20:59
2021-04-05T16:20:59
354,875,840
0
0
null
null
null
null
UHC
C++
false
false
447
cpp
#include <iostream> int main() { int val1, val2; int result = 0; std::cout<<"두 개의 숫자입력: "; std::cin>>val1>>val2; if(val1 < val2) { for (int i = val1+1; i<val2; i++) { result+=i; } } else { for(int i = val2+1; i<val1;i++) { result+=i; } } std::cout<<"두 수 사이의 정수 합: "<<result<<std::endl; return 0; }
[ "43948280+Jelcream@users.noreply.github.com" ]
43948280+Jelcream@users.noreply.github.com
6df387db2ba225a9ed5171f331368c03a90bdcfa
fe402a0d7dcbedf88f68aed85e531b5a9c519dd8
/spring10/evilsnakes/enemy.h
47321de7e472f406493a37f6a6fd093358ee7a8e
[]
no_license
ericx2x/csundergradhomework
1e12c68ffeb50406648238142cc0abe29735e1a1
486bcd8c09e7bba39953e2509e61045ff4adbff3
refs/heads/master
2021-06-09T12:47:09.025877
2016-12-13T23:32:14
2016-12-13T23:32:14
76,407,145
2
0
null
null
null
null
UTF-8
C++
false
false
843
h
/*********************************************************/ /* Programmer: Michael Staub */ /* */ /* File Name: enemy.h */ /* */ /* Date: 2/28/2010 */ /*********************************************************/ #ifndef ENEMY_H #define ENEMY_H #include "sprite.h" class Level ; class Character ; class Enemy : public Sprite { public: Enemy( Level *l, DrawEngine *de, int s_index, float x = 1, float y = 1, int i_lives = 1 ) ; void addGoal( Character *g ) ; bool move( float x, float y ) ; void idleUpdate( void ) ; protected: void simulateAI( void ) ; Character *goal ; } ; #endif
[ "ericjlima@gmail.com" ]
ericjlima@gmail.com
48702dbfe46eb357ccff793bd750038900df46fe
1ee5f4a7d365db72ab3dc5d87a16d4f64debe5e3
/Source/SourceStringChecker.h
cf2f81b9f87f04c3981b188718fcb4ddf5b7dc07
[]
no_license
Bigstorm20008/FileConverter
9fe4f409811f155b80c82f69877cabf2616875b5
effc773eadd48ae56575d0397c6f862e44a18a35
refs/heads/master
2020-03-28T02:18:31.427612
2018-09-09T05:42:24
2018-09-09T05:42:24
147,561,434
0
1
null
null
null
null
UTF-8
C++
false
false
597
h
#ifndef SOURCE_STRING_CHECKER_H #define SOURCE_STRING_CHECKER_H #include <string> class SourceStringChecker { public: SourceStringChecker(); ~SourceStringChecker(); bool isCorrectString(const std::wstring& sourceString); const std::wstring& getUnixTimeStamp()const; const std::wstring& getBid()const; const std::wstring& getAsk()const; private: const wchar_t m_limiter; const size_t m_correctTimeStampLenght; std::wstring m_unixTimeStamp; std::wstring m_bid; std::wstring m_ask; bool checkTimeStamp()const; bool checkBidAndAsk()const; }; #endif // !SOURCE_STRING_CHECKER_H
[ "bigstorm@3g.ua" ]
bigstorm@3g.ua
2f87390fa07a68a5beca58140f5c8ea4cbb46a75
b7ee9ac14d6981e18fa1b19214366878a4884a42
/Projects/Irrlicht/Source/SoftwareDriver2_helper.h
2185b23f8111402926cb82842b338a38d91ec967
[ "MIT" ]
permissive
skylicht-lab/skylicht-engine
89d51b4240ca6ed5a7f15b413df5711288580e9e
ff0e875581840efd15503cdfa49f112b6adade98
refs/heads/master
2023-09-01T02:23:45.865965
2023-08-29T08:21:41
2023-08-29T08:21:41
220,988,542
492
46
MIT
2023-06-05T10:18:45
2019-11-11T13:34:56
C++
UTF-8
C++
false
false
8,303
h
// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h /* History: - changed behavior for log2 textures ( replaced multiplies by shift ) */ #ifndef __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ #define __S_VIDEO_2_SOFTWARE_HELPER_H_INCLUDED__ #include "irrMath.h" #include "SMaterial.h" namespace irr { // supporting different packed pixel needs many defines... typedef u32 tVideoSample; #define MASK_A 0xFF000000 #define MASK_R 0x00FF0000 #define MASK_G 0x0000FF00 #define MASK_B 0x000000FF #define SHIFT_A 24 #define SHIFT_R 16 #define SHIFT_G 8 #define SHIFT_B 0 #define COLOR_MAX 0xFF #define COLOR_MAX_LOG2 8 #define COLOR_BRIGHT_WHITE 0xFFFFFFFF #define VIDEO_SAMPLE_GRANULARITY 2 // ----------------------- Generic ---------------------------------- //! a more useful memset for pixel // (standard memset only works with 8-bit values) inline void memset32(void * dest, const u32 value, u32 bytesize) { u32 * d = (u32*) dest; u32 i; // loops unrolled to reduce the number of increments by factor ~8. i = bytesize >> (2 + 3); while (i) { d[0] = value; d[1] = value; d[2] = value; d[3] = value; d[4] = value; d[5] = value; d[6] = value; d[7] = value; d += 8; i -= 1; } i = (bytesize >> 2 ) & 7; while (i) { d[0] = value; d += 1; i -= 1; } } //! a more useful memset for pixel // (standard memset only works with 8-bit values) inline void memset16(void * dest, const u16 value, u32 bytesize) { u16 * d = (u16*) dest; u32 i; // loops unrolled to reduce the number of increments by factor ~8. i = bytesize >> (1 + 3); while (i) { d[0] = value; d[1] = value; d[2] = value; d[3] = value; d[4] = value; d[5] = value; d[6] = value; d[7] = value; d += 8; --i; } i = (bytesize >> 1 ) & 7; while (i) { d[0] = value; ++d; --i; } } /* use biased loop counter --> 0 byte copy is forbidden */ REALINLINE void memcpy32_small ( void * dest, const void *source, u32 bytesize ) { u32 c = bytesize >> 2; do { ((u32*) dest ) [ c-1 ] = ((u32*) source) [ c-1 ]; } while ( --c ); } // integer log2 of a float ieee 754. TODO: non ieee floating point static inline s32 s32_log2_f32( f32 f) { u32 x = IR ( f ); return ((x & 0x7F800000) >> 23) - 127; } static inline s32 s32_log2_s32(u32 x) { return s32_log2_f32( (f32) x); } static inline s32 s32_abs(s32 x) { s32 b = x >> 31; return (x ^ b ) - b; } //! conditional set based on mask and arithmetic shift REALINLINE u32 if_mask_a_else_b ( const u32 mask, const u32 a, const u32 b ) { return ( mask & ( a ^ b ) ) ^ b; } // ------------------ Video--------------------------------------- /*! Pixel = dest * ( 1 - alpha ) + source * alpha alpha [0;256] */ REALINLINE u32 PixelBlend32 ( const u32 c2, const u32 c1, u32 alpha ) { u32 srcRB = c1 & 0x00FF00FF; u32 srcXG = c1 & 0x0000FF00; u32 dstRB = c2 & 0x00FF00FF; u32 dstXG = c2 & 0x0000FF00; u32 rb = srcRB - dstRB; u32 xg = srcXG - dstXG; rb *= alpha; xg *= alpha; rb >>= 8; xg >>= 8; rb += dstRB; xg += dstXG; rb &= 0x00FF00FF; xg &= 0x0000FF00; return rb | xg; } /*! Pixel = dest * ( 1 - alpha ) + source * alpha alpha [0;32] */ inline u16 PixelBlend16 ( const u16 c2, const u32 c1, const u16 alpha ) { const u16 srcRB = c1 & 0x7C1F; const u16 srcXG = c1 & 0x03E0; const u16 dstRB = c2 & 0x7C1F; const u16 dstXG = c2 & 0x03E0; u32 rb = srcRB - dstRB; u32 xg = srcXG - dstXG; rb *= alpha; xg *= alpha; rb >>= 5; xg >>= 5; rb += dstRB; xg += dstXG; rb &= 0x7C1F; xg &= 0x03E0; return (u16)(rb | xg); } /* Pixel = c0 * (c1/31). c0 Alpha retain */ inline u16 PixelMul16 ( const u16 c0, const u16 c1) { return (u16)((( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 ) | (( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 ) | (( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 ) | (c0 & 0x8000)); } /* Pixel = c0 * (c1/31). */ inline u16 PixelMul16_2 ( u16 c0, u16 c1) { return (u16)(( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 | ( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 | ( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 | ( c0 & c1 & 0x8000)); } /* Pixel = c0 * (c1/255). c0 Alpha Retain */ REALINLINE u32 PixelMul32 ( const u32 c0, const u32 c1) { return (c0 & 0xFF000000) | (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); } /* Pixel = c0 * (c1/255). */ REALINLINE u32 PixelMul32_2 ( const u32 c0, const u32 c1) { return (( ( (c0 & 0xFF000000) >> 16 ) * ( (c1 & 0xFF000000) >> 16 ) ) & 0xFF000000 ) | (( ( (c0 & 0x00FF0000) >> 12 ) * ( (c1 & 0x00FF0000) >> 12 ) ) & 0x00FF0000 ) | (( ( (c0 & 0x0000FF00) * (c1 & 0x0000FF00) ) >> 16 ) & 0x0000FF00 ) | (( ( (c0 & 0x000000FF) * (c1 & 0x000000FF) ) >> 8 ) & 0x000000FF); } /* Pixel = clamp ( c0 + c1, 0, 255 ) */ REALINLINE u32 PixelAdd32 ( const u32 c2, const u32 c1) { u32 sum = ( c2 & 0x00FFFFFF ) + ( c1 & 0x00FFFFFF ); u32 low_bits = ( c2 ^ c1 ) & 0x00010101; s32 carries = ( sum - low_bits ) & 0x01010100; u32 modulo = sum - carries; u32 clamp = carries - ( carries >> 8 ); return modulo | clamp; } #if 0 // 1 - Bit Alpha Blending inline u16 PixelBlend16 ( const u16 destination, const u16 source ) { if((source & 0x8000) == 0x8000) return source; // The source is visible, so use it. else return destination; // The source is transparent, so use the destination. } // 1 - Bit Alpha Blending 16Bit SIMD inline u32 PixelBlend16_simd ( const u32 destination, const u32 source ) { switch(source & 0x80008000) { case 0x80008000: // Both source pixels are visible return source; case 0x80000000: // Only the first source pixel is visible return (source & 0xFFFF0000) | (destination & 0x0000FFFF); case 0x00008000: // Only the second source pixel is visible. return (destination & 0xFFFF0000) | (source & 0x0000FFFF); default: // Neither source pixel is visible. return destination; } } #else // 1 - Bit Alpha Blending inline u16 PixelBlend16 ( const u16 c2, const u16 c1 ) { u16 mask = ((c1 & 0x8000) >> 15 ) + 0x7fff; return (c2 & mask ) | ( c1 & ~mask ); } // 1 - Bit Alpha Blending 16Bit SIMD inline u32 PixelBlend16_simd ( const u32 c2, const u32 c1 ) { u32 mask = ((c1 & 0x80008000) >> 15 ) + 0x7fff7fff; return (c2 & mask ) | ( c1 & ~mask ); } #endif /*! Pixel = dest * ( 1 - SourceAlpha ) + source * SourceAlpha */ inline u32 PixelBlend32 ( const u32 c2, const u32 c1 ) { // alpha test u32 alpha = c1 & 0xFF000000; if ( 0 == alpha ) return c2; if ( 0xFF000000 == alpha ) { return c1; } alpha >>= 24; // add highbit alpha, if ( alpha > 127 ) alpha += 1; alpha += ( alpha >> 7); u32 srcRB = c1 & 0x00FF00FF; u32 srcXG = c1 & 0x0000FF00; u32 dstRB = c2 & 0x00FF00FF; u32 dstXG = c2 & 0x0000FF00; u32 rb = srcRB - dstRB; u32 xg = srcXG - dstXG; rb *= alpha; xg *= alpha; rb >>= 8; xg >>= 8; rb += dstRB; xg += dstXG; rb &= 0x00FF00FF; xg &= 0x0000FF00; return (c1 & 0xFF000000) | rb | xg; } // some 2D Defines struct AbsRectangle { s32 x0; s32 y0; s32 x1; s32 y1; }; //! 2D Intersection test inline bool intersect ( AbsRectangle &dest, const AbsRectangle& a, const AbsRectangle& b) { dest.x0 = core::s32_max( a.x0, b.x0 ); dest.y0 = core::s32_max( a.y0, b.y0 ); dest.x1 = core::s32_min( a.x1, b.x1 ); dest.y1 = core::s32_min( a.y1, b.y1 ); return dest.x0 < dest.x1 && dest.y0 < dest.y1; } // some 1D defines struct sIntervall { s32 start; s32 end; }; // returning intersection width inline s32 intervall_intersect_test( const sIntervall& a, const sIntervall& b) { return core::s32_min( a.end, b.end ) - core::s32_max( a.start, b.start ); } } // end namespace irr #endif
[ "hongduc.pr@gmail.com" ]
hongduc.pr@gmail.com
7d42abb775f6a53c122d5c8f2124163100221058
55ae9643ce366b1d5e05328703cd82af5bf2bde3
/3019.cpp
fabec7b20320cb975178ef54993e05bc6fa5d936
[]
no_license
thextroid/edunote
486a9030cc60e1aca454d55d8228babe4d7cedf8
8fe6ac5929ce3fc322a2196ab716d4cc9136786e
refs/heads/master
2021-01-19T21:40:43.428088
2017-04-19T01:59:11
2017-04-19T01:59:11
88,685,790
0
0
null
null
null
null
UTF-8
C++
false
false
414
cpp
#include <iostream> #include <stdio.h> #define abs(a) (a)<0? -(a):(a) using namespace std; int main(){ freopen("data.in","r",stdin); freopen("data.out","w",stdout); int NT,n; int v[51]; scanf("%d",&NT); while(NT--){ scanf("%d",&n); for(int i = 0 ;i < n;++i) scanf("%d",&v[i]); int diff=0; for(int i = 0 ; i< n;++i) if(v[i]!=i+1) diff+= abs(i+1-v[i]); printf("%d\n", diff); } return 0; }
[ "thexfer@gmail.com" ]
thexfer@gmail.com
db3fd5cd898473c2e716c47b7068fe11a66d86da
cc5a7ff1651b7f744096b963b706da193c9fda64
/ch1_DP1/9095.cpp
f7f7a0c5cec085726ae2fd33f5c9cd0ca096165e
[]
no_license
Taeu/Algo
bc80a0c7c12b6e80b72c5510bb8601c73e46996e
8aa5d7c72bcd52b6c6c66460e1a69dd018f6f1f5
refs/heads/master
2020-03-10T19:15:16.344175
2019-07-04T09:00:33
2019-07-04T09:00:33
129,544,183
0
0
null
null
null
null
UTF-8
C++
false
false
384
cpp
#include<vector> #include<iostream> using namespace std; #pragma warning(disable:4996) int dp[1001]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; dp[1] = 1; dp[2] = 2; dp[3] = 4; for (int i = 4; i < 12; i++) { dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]; } while (n--) { int num; cin >> num; cout << dp[num] << '\n'; } return 0; }
[ "specia1ktu@gmail.com" ]
specia1ktu@gmail.com
2dfe461e3d84346201040bdb3c1a9a205ed01958
0df59ab0f0e41625b93e9860bb2c7d61b7127cef
/algoritmoGeneticoCPlusPlus/teste.h
ed0c7ab8d238bbce130edd7a651ea4fbc4f0eae6
[]
no_license
RichardUlissesGabriel/tcc-algoritmo-genetico
3a5a95fa66562f48c370a8f08a878f6e877b55c1
d0ad3058111ac46ce58bcbd06bb38d1d5c76c0c7
refs/heads/master
2023-01-30T04:56:03.814396
2020-12-14T23:56:19
2020-12-14T23:56:19
321,500,986
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
976
h
#pragma once #include <string> #include <vector> #include <map> using namespace std; class teste{ private: string nomeTeste; string nomeFileSaida; //vetor de parametros, cada elemento é um conjunto de parametros map<string, int> conjuntoParams; public: teste(); ~teste(); string getNomeTeste(); string getNomeFileSaida(); map<string, int>& getConjuntoParams(); void setNomeTeste(string); void setNomeFileSaida(string); void setConjuntoParams(map<string, int>); }; class conjuntoTestes { private: int id; string nomeConjuntoTeste; string nomeFileSaida; vector<teste> conjuntoTeste; public: conjuntoTestes(); ~conjuntoTestes(); int getId(); string getNomeConjuntoTeste(); string getNomeFileSaida(); vector<teste>& getConjuntoTeste(); void setId(int); void setNomeConjuntoTeste(string); void setconjuntoTeste(vector<teste>); void addTeste(teste); void setNomeFileSaida(string); };
[ "rick_gabriel2009@hotmail.com" ]
rick_gabriel2009@hotmail.com
1cb16f60ae9d45d53867db08b50eb9c9b46db20e
005eb1edbcef8e69a7f203642c4a849f27d82668
/2261/main.cpp
747770707b52c82a891ec2dc3293ecc06f9082ab
[]
no_license
JustinLiu1998/ECNU-Online-Judge
3dc2e1fe899f4ff7d64decafc5f21508b8bab40d
c57d4343334c5c15b48e6ce09882ec8092e07672
refs/heads/master
2022-04-07T14:05:06.856405
2020-02-25T13:28:36
2020-02-25T13:28:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,883
cpp
// // main.cpp // 2261 // // Created by 刘靖迪 on 2017/9/18. // Copyright © 2017年 刘靖迪. All rights reserved. // #include <iostream> #include <cstring> using namespace std; int power (int n, int prime, int e) { int ans=0; while (n / prime) { n /= prime; ans += n; } return ans/e; } int main(int argc, const char * argv[]) { int prime[168]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997}; int a[168]; int T, cas=0; cin >> T; while (T--) { int b, n; cin >> b >> n; if (n == 1) { cout << "Scenario #" << ++cas << ":" << endl << "0" << endl << endl; continue; } memset(a, 0, sizeof(a)); int i=0; while (b != 1) { if (b % prime[i] == 0) { while (b % prime[i] == 0) { a[i]++; b /= prime[i]; } } i++; } int tem, min=1e9; for (int j=0; j<i; j++) { if (a[j]) { tem = power(n, prime[j], a[j]); if (tem < min) min = tem; } } cout << "Scenario #" << ++cas << ":\n"; cout << min << endl << endl; } return 0; }
[ "liujingdiljd@icloud.com" ]
liujingdiljd@icloud.com
b6d1ae100c4b12d58497a1eaad56b48cb81c983b
c732666c24d86e0da4cd2c1ee12619e9c514e818
/offline/01_03/02-14/1654.cpp
13d2c8ada4c13da6beb6b7997db7ce669f3af75e
[]
no_license
Algostu/boradori
032f71e9e58163d3e188856629a5de4afaa87b30
939d60e8652074e26ba08252217f7788cae9063c
refs/heads/master
2023-04-22T03:57:26.823917
2021-04-06T23:09:36
2021-04-06T23:09:36
263,754,451
0
0
null
null
null
null
UTF-8
C++
false
false
864
cpp
// Created on 강한결의 iPad. #include <bits/stdc++.h> using namespace std; inline long long splitN(vector<int> &arr, int N){ long long sum = 0; int size = arr.size(); for(int i=0; i<size; i++){ sum += arr[i] / N; } return sum; } int main() { int k, n; cin >> k >> n; vector<int> arr(k); int max_val = 0; for(int i=0; i<k; i++){ scanf("%d", &arr[i]); max_val = max(max_val, arr[i]); } int m = 1; long long l = 2; long long r = max_val; int size = arr.size(); while(l <= r){ long long c_m = (l + r)/2; long long t = 0; for(int i=0; i<size; i++){ t += arr[i]/c_m; } if(t >= n){ m = c_m; l = c_m+1; } else { r = c_m-1; } } cout << m << "\n"; return 0; }
[ "consistant1y@ajou.ac.kr" ]
consistant1y@ajou.ac.kr
cffa2092ab5e08861aa438506ca0fea668b0babb
c67ed12eae84af574406e453106b7d898ff47dc7
/chap02/Exer02_35.cpp
b5ed3a275f16d6ad777e7194ae1f76d2ed6a57cb
[ "Apache-2.0" ]
permissive
chihyang/CPP_Primer
8374396b58ea0e1b0f4c4adaf093a7c0116a6901
9e268d46e9582d60d1e9c3d8d2a41c1e7b83293b
refs/heads/master
2022-09-16T08:54:59.465691
2022-09-03T17:25:59
2022-09-03T17:25:59
43,039,810
58
23
Apache-2.0
2023-01-14T07:06:19
2015-09-24T02:25:47
C++
UTF-8
C++
false
false
408
cpp
#include<iostream> int main() { const int i =42; auto j = i; // int const auto &k = i; // const reference(or say, reference to const) auto *p = &i; // pointer to const, const of i is not ignored, so it's const int * const auto j2 = i, &k2 = i; // j2, const int; i, const reference std::cout << j << " " << k << " " << *p << " " << j2 << " " << k2 << " " << std::endl; return 0; }
[ "chihyanghsin@gmail.com" ]
chihyanghsin@gmail.com
13b3ed05554dd766bf91ac84b3e2edecb486548b
0e8d03dca67ab0c0f884e4d23a2ff98a24e9c4c9
/codeforces/515div3-a.cpp
ace69605929d2bb05c97073751dbc78a8b8e6e18
[]
no_license
abhihacker02/Competitive-Coding
c735c0db8a22d26d7f943061baac3fcbdda80418
55ba9789a19b687453845860d535e3a7b5271aec
refs/heads/master
2020-06-21T02:29:04.492324
2019-07-17T13:28:58
2019-07-17T13:28:58
197,323,377
0
0
null
null
null
null
UTF-8
C++
false
false
1,680
cpp
#include<bits/stdc++.h> using namespace std; //using namespace __gnu_pbds; //typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t; #define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define mp make_pair #define mt make_tuple #define pb push_back #define SUM(v) accumulate(v.begin(),v.end(),lli(0)) #define rev(n) for(int i=n;i>=0;i--) #define FOR0(n) for(int i=0;i<n;i++) #define FOR(a,n) for(int i=a;i<n;i++) #define FORQ(a,n) for(int i=a;i<=n;i++) #define inf 1000000009 #define inff 0x3f3f3f3f #define sz(a) int((a).size()) #define all(c) c.begin(), c.end() #define ff first #define ss second #define endl "\n" #define mod 1000000007 #define mem(ar,x) memset(ar,x,sizeof ar) #define present(container, element) (container.find(element) != container.end()) #define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c)) #define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d) #define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c)) #define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d) typedef long long int lli; typedef pair<int,int> pii; typedef pair<int,pii>ppii; typedef vector<int>vi; typedef vector<vi>vvi; typedef vector<pii>vpii; const int N=100005; int dr8[]={0,0,1,-1,1,1,-1,-1}; int dc8[]={1,-1,0,0,-1,1,-1,1}; int dr4[]={0,1,-1,0}; int dc4[]={1,0,0,-1}; int main(){ fast int t; cin>>t; while(t--){ int L,v,l,r; cin>>L>>v>>l>>r; int n=L/v; int del; //int del=(r-l-1)/v; //if(l%v==0) del++; //if(r!=l&&r%v==0) del++; del=(r/v)-(l-1)/v; cout<<n-del<<endl; } }
[ "noreply@github.com" ]
abhihacker02.noreply@github.com
db61f3de0417c3cc4b3ed4571c7f94071e8d4af3
8cf32b4cbca07bd39341e1d0a29428e420b492a6
/contracts/libc++/upstream/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp
78090344684003b947e775308c9aab6751315c55
[ "NCSA", "MIT" ]
permissive
cubetrain/CubeTrain
e1cd516d5dbca77082258948d3c7fc70ebd50fdc
b930a3e88e941225c2c54219267f743c790e388f
refs/heads/master
2020-04-11T23:00:50.245442
2018-12-17T16:07:16
2018-12-17T16:07:16
156,970,178
0
0
null
null
null
null
UTF-8
C++
false
false
709
cpp
//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <random> // template<class RealType = double> // class weibull_distribution // weibull_distribution(const weibull_distribution&); #include <random> #include <cassert> void test1() { typedef std::weibull_distribution<> D; D d1(20, 1.75); D d2 = d1; assert(d1 == d2); } int main() { test1(); }
[ "1848@shanchain.com" ]
1848@shanchain.com
6767b3cf9937418c1ae894221d24ce4fd5504510
239e2373f459d08b3eabd7e99242c1f756dc97f3
/logdevice/ops/ldquery/tables/LogGroups.cpp
d7b45659450a4a160a23ebe4753db51c5d395120
[ "BSD-3-Clause" ]
permissive
zhengxiaochuan-3/LogDevice
edb04140e1906f281faf26f6789ddd26db3a2cc3
01e2302a382db1d87f934e305c8cc74ffc0a24a4
refs/heads/master
2020-07-06T22:44:08.337104
2019-08-19T10:05:17
2019-08-19T10:07:21
203,161,120
1
0
NOASSERTION
2019-08-19T11:41:10
2019-08-19T11:41:09
null
UTF-8
C++
false
false
5,081
cpp
/** * Copyright (c) 2017-present, Facebook, Inc. and its affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #include "logdevice/ops/ldquery/tables/LogGroups.h" #include <folly/Conv.h> #include <folly/json.h> #include "../Table.h" #include "../Utils.h" #include "logdevice/common/configuration/Configuration.h" #include "logdevice/common/configuration/ReplicationProperty.h" #include "logdevice/common/configuration/UpdateableConfig.h" #include "logdevice/common/debug.h" #include "logdevice/lib/ClientImpl.h" using facebook::logdevice::Configuration; namespace facebook { namespace logdevice { namespace ldquery { namespace tables { TableColumns LogGroups::getColumns() const { return { {"name", DataType::TEXT, "Name of the log group."}, {"logid_lo", DataType::LOGID, "Defines the lower bound (inclusive) of the range of log ids in this " "log group."}, {"logid_hi", DataType::LOGID, "Defines the upper bound (inclusive) of the range of log ids in this " "log group."}, {"replication_property", DataType::TEXT, "Replication property configured for this log group."}, {"synced_copies", DataType::INTEGER, "Number of copies that must be acknowledged by storage nodes are synced " "to disk before the record is acknowledged to the client as fully " "appended."}, {"max_writes_in_flight", DataType::INTEGER, "The largest number of records not released for delivery that the " "sequencer allows to be outstanding."}, {"backlog_duration_sec", DataType::INTEGER, "Time-based retention of records of logs in that log group. If null or " "zero, this log group does not use time-based retention."}, {"storage_set_size", DataType::INTEGER, "Size of the storage set for logs in that log group. The storage set " "is the set of shards that may hold data for a log."}, {"delivery_latency", DataType::INTEGER, "For logs in that log group, maximum amount of time that we can delay " "delivery of newly written records. This option increases delivery " "latency but improves server and client performance."}, {"scd_enabled", DataType::INTEGER, "Indicates whether the Single Copy Delivery optimization is enabled for " "this log group. This efficiency optimization allows only one copy of " "each record to be served to readers."}, {"custom_fields", DataType::TEXT, "Custom text field provided by the user."}, }; } std::shared_ptr<TableData> LogGroups::getData(QueryContext& ctx) { auto result = std::make_shared<TableData>(); auto full_client = ld_ctx_->getFullClient(); ld_check(full_client); ClientImpl* client_impl = static_cast<ClientImpl*>(full_client.get()); auto config = client_impl->getConfig()->get(); auto add_row = [&](const std::string name, logid_range_t range) { auto log = config->getLogGroupByIDShared(range.first); ld_check(log); auto log_attrs = log->attrs(); ColumnValue custom; if (log_attrs.extras().hasValue() && (*log_attrs.extras()).size() > 0) { folly::dynamic extra_attrs = folly::dynamic::object; for (const auto& it : log_attrs.extras().value()) { extra_attrs[it.first] = it.second; } custom = folly::toJson(extra_attrs); } ReplicationProperty rprop = ReplicationProperty::fromLogAttributes(log_attrs); // This should remain the first ColumnValue as expected by the code below. result->cols["name"].push_back(name); result->cols["logid_lo"].push_back(s(range.first.val_)); result->cols["logid_hi"].push_back(s(range.second.val_)); result->cols["replication_property"].push_back(rprop.toString()); result->cols["synced_copies"].push_back(s(*log_attrs.syncedCopies())); result->cols["max_writes_in_flight"].push_back( s(*log_attrs.maxWritesInFlight())); result->cols["backlog_duration_sec"].push_back( s(*log_attrs.backlogDuration())); result->cols["storage_set_size"].push_back(s(*log_attrs.nodeSetSize())); result->cols["delivery_latency"].push_back(s(*log_attrs.deliveryLatency())); result->cols["scd_enabled"].push_back(s(*log_attrs.scdEnabled())); result->cols["custom_fields"].push_back(custom); }; // If the query contains a constraint on the group name, we can efficiently // find the log group using getLogRangeByName(). std::string expr; if (columnHasEqualityConstraint(0, ctx, expr)) { logid_range_t range = config->logsConfig()->getLogRangeByName(expr); if (range.first != LOGID_INVALID) { add_row(expr, range); } } else { auto ranges = config->logsConfig()->getLogRangesByNamespace(""); for (auto& r : ranges) { add_row(s(r.first), r.second); } } return result; } }}}} // namespace facebook::logdevice::ldquery::tables
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
8616cd8024f931c0daae2555fbcb3027ba1779dc
01ec5fae952211e0a0ab29dfb49a0261a8510742
/backup/source/cpp/[1121]将数组分成几个递增序列.cpp
682e3261a9144f8b5931619d7c448aad77125899
[]
no_license
algoboy101/LeetCodeCrowdsource
5cbf3394087546f9051c493b1613b5587c52056b
25e93171fa16d6af5ab0caec08be943d2fdd7c2e
refs/heads/master
2021-02-20T00:18:51.225422
2020-06-21T09:04:24
2020-06-21T09:04:24
245,323,834
10
4
null
2020-03-09T02:23:39
2020-03-06T03:43:27
C++
UTF-8
C++
false
false
888
cpp
//给你一个 非递减 的正整数数组 nums 和整数 K,判断该数组是否可以被分成一个或几个 长度至少 为 K 的 不相交的递增子序列。 // // // // 示例 1: // // 输入:nums = [1,2,2,3,3,4,4], K = 3 //输出:true //解释: //该数组可以分成两个子序列 [1,2,3,4] 和 [2,3,4],每个子序列的长度都至少是 3。 // // // 示例 2: // // 输入:nums = [5,6,6,7,8], K = 3 //输出:false //解释: //没有办法根据条件来划分数组。 // // // // // 提示: // // // 1 <= nums.length <= 10^5 // 1 <= K <= nums.length // 1 <= nums[i] <= 10^5 // // Related Topics 数学 //leetcode submit region begin(Prohibit modification and deletion) class Solution { public: bool canDivideIntoSubsequences(vector<int>& nums, int K) { } }; //leetcode submit region end(Prohibit modification and deletion)
[ "chenwenwen0210@126.com" ]
chenwenwen0210@126.com
866029caeb3f341d798cf6bfa5d73c3448c139cb
b78fc2c6f75020a534a5fd62cd75549fecd73f77
/lib/string_utils.cpp
ef7386f84434d5d760597bec0eac078109820f68
[]
no_license
mrdooz/world
a59b5204bdbc12edaaf255d6cdadb6326f199551
7782ed26200bee2ef0ae6e506241fd8610b603fd
refs/heads/master
2021-01-10T06:14:46.035579
2015-11-16T02:14:29
2015-11-16T02:14:29
45,221,867
0
0
null
null
null
null
UTF-8
C++
false
false
3,491
cpp
#include "string_utils.hpp" #include <stdint.h> using namespace std; namespace world { string ToString(char const* const format, ...) { #ifdef _WIN32 va_list arg; va_start(arg, format); const int len = _vscprintf(format, arg) + 1; char* buf = (char*)_alloca(len); vsprintf_s(buf, len, format, arg); va_end(arg); return string(buf); #else static char buf[4 * 1024]; va_list arg; va_start(arg, format); vsprintf(buf, format, arg); string res(buf); va_end(arg); return res; #endif } #ifdef _WIN32 string WideCharToUtf8(const WCHAR* str) { int len = (int)wcslen(str); char* buf = (char*)_alloca(len * 2 + 1); int res = WideCharToMultiByte(CP_UTF8, 0, str, len, buf, len * 2 + 1, NULL, NULL); if (res == 0) return false; buf[res] = '\0'; return string(buf); } bool WideCharToUtf8(LPCOLESTR unicode, int len, string* str) { if (!unicode) return false; char* buf = (char*)_alloca(len * 2 + 1); int res = WideCharToMultiByte(CP_UTF8, 0, unicode, len, buf, len * 2 + 1, NULL, NULL); if (res == 0) return false; buf[res] = '\0'; *str = string(buf); return true; } #endif string Trim(const string& str) { int leading = 0, trailing = 0; while (isspace((uint8_t)str[leading])) leading++; const size_t end = str.size() - 1; while (isspace((uint8_t)str[end - trailing])) trailing++; return leading || trailing ? str.substr(leading, str.size() - (leading + trailing)) : str; } bool StartsWith(const char* str, const char* sub_str) { const size_t len_a = strlen(str); const size_t len_b = strlen(sub_str); if (len_a < len_b) return false; for (; *sub_str; ++str, ++sub_str) { if (*sub_str != *str) return false; } return true; } bool StartsWith(const string& str, const string& sub_str) { const size_t len_a = str.size(); const size_t len_b = sub_str.size(); if (len_a < len_b) return false; for (size_t i = 0; i < len_b; ++i) { if (sub_str[i] != str[i]) return false; } return true; } #ifdef _WIN32 wstring Utf8ToWide(const char* str) { int len = (int)strlen(str); WCHAR* buf = (WCHAR*)_alloca((len + 1) * 2); wstring res; if (MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, (len + 1) * 2)) { res = wstring(buf); } else { int err = GetLastError(); } return res; } #endif //------------------------------------------------------------------------------ vector<string> StringSplit(const string& str, char delim) { vector<string> res; const char* start = str.c_str(); const char* end = str.c_str() + str.size(); const char* cur = start; const char* prevStart = start; while (cur != end) { if (*cur == delim) { res.push_back(string(prevStart, cur - prevStart)); prevStart = cur + 1; } cur++; } if (prevStart < end) { res.push_back(string(prevStart, cur - prevStart)); } return res; } //------------------------------------------------------------------------------ std::string StringJoin(const std::vector<std::string>& v, const std::string& delim) { string res; size_t cnt = v.size(); for (size_t i = 0; i < cnt; ++i) { res += v[i]; if (i != cnt - 1) res += delim; } return res; } }
[ "magnus.osterlind@gmail.com" ]
magnus.osterlind@gmail.com
62f8a88d8ea63c077e9336e5ce6429e445ace5aa
d05383f9f471b4e0691a7735aa1ca50654704c8b
/CPP2MIssues/SampleClass686.cpp
169e8ab2423e5fa61bbe6a647e17af80d4179f57
[]
no_license
KetkiT/CPP2MIssues
d2186a78beeb36312cc1a756a005d08043e27246
82664377d0f0047d84e6c47e9380d1bafa840d19
refs/heads/master
2021-08-26T07:27:00.804769
2017-11-22T07:29:45
2017-11-22T07:29:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
50,048
cpp
class SampleClass686{ public: void m1() { int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); int *ptr = new int (10); } };
[ "ketki.thosar@acellere.com" ]
ketki.thosar@acellere.com
e4f9283d1f122b5342e17a597ce18e4d26591a3c
5e0e71cfae09eaac12d8fe929eda9b1d0630764e
/AADC/src/aadcUser/MarkerDetector/stdafx.h
8bb5f6de2e3aea58f255edc4c9d42488236292d6
[ "BSD-2-Clause" ]
permissive
viettung92/AADC
418232e01587757e17e036f146167e037fef069c
ac25f2a7e66ef9d8f9430921baf6ddcac97d6540
refs/heads/master
2020-10-02T02:25:24.123886
2020-01-15T14:57:53
2020-01-15T14:57:53
227,669,243
1
0
null
null
null
null
UTF-8
C++
false
false
2,202
h
/********************************************************************* Copyright (c) 2018 Audi Autonomous Driving Cup. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: ?This product includes software developed by the Audi AG and its contributors for Audi Autonomous Driving Cup.? 4. Neither the name of Audi 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 AUDI AG 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 AUDI AG OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************/ #pragma once #ifdef WIN32 #include <windows.h> #endif //adtf #include <adtf3.h> #include <adtf_platform_inc.h> #include <a_utils_platform_inc.h> #include <adtf_systemsdk.h> #include <stdlib.h> #include <opencv2/opencv.hpp> #include <opencv2/aruco.hpp> #include <aadc_structs.h> #include <aadc_user_structs.h> //user includes #include <aadc_types.h> using namespace std;
[ "hoang.viettung@gmx.de" ]
hoang.viettung@gmx.de
742b82d140ef9dc0d6bd463ee9b262c4a323357a
0ce9c7737c67548001d757eb4f3225b693f1619b
/src/Raster_Reader.cpp
58caea814741e7bc225082ce37da394bd6ad0c13
[]
no_license
welarfao/Fire-rs-internship
808a6c8ce66882599d542ffca59ed6ad8cf9eb15
1c0fc8e2778e7bdf5dc35cd0147d8ecd22eb89f7
refs/heads/master
2020-03-27T22:20:52.766353
2018-09-03T15:22:07
2018-09-03T15:22:07
147,223,114
0
0
null
null
null
null
UTF-8
C++
false
false
5,523
cpp
#include "Raster_Reader.h" Raster_Reader::Raster_Reader( ){ } Raster_Reader::Raster_Reader( const std::string& path){ GDALAllRegister() ; /*Once the drivers are registered, the application should call the free standing GDALOpen() function to open a dataset, passing the name of the dataset and the access desired (GA_ReadOnly or GA_Update).*/ /// get a DEM file gDataSet = (GDALDataset * ) GDALOpen( path.c_str() , GA_ReadOnly); ///check if data is present if (gDataSet == NULL){ cerr<< "No data found"; //break ; }; nCols = gDataSet->GetRasterXSize(); nRows = gDataSet->GetRasterYSize(); nBands = gDataSet->GetRasterCount(); no_data_value = gDataSet->GetRasterBand(1)->GetNoDataValue(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////// //this function fetches the values of :originX, originY, pWidth, pHeightusing GDAL geotransform ; void Raster_Reader::geoTransform() { if( gDataSet->GetGeoTransform(gTransform) == CE_None ){ //position of the top left x originX = gTransform[0]; //position of top left y originY = gTransform[3]; //the pixel width //west-east pixel resolution pWidth = gTransform[1]; //the pixel height//north-south pixel resolution (negative value) pHeight = gTransform[5]; max_east = originX + nCols*gTransform[1]; max_west = originX ; max_north = originY; max_south = originY + nRows*gTransform[5]; }else{ cerr<<"DEM error : no transform can be fetched"; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string Raster_Reader::get_projection(){ return gDataSet->GetProjectionRef(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Raster_Reader::Put_Raster_invector(){ GDALRasterBand *poBand; poBand = gDataSet->GetRasterBand( 1 ); float maxH=0; float minH=10000; float *Buffer; int nXSize = poBand->GetXSize(); //read row data and store in vector for(int i=0; i < nRows; i++){ //buffer to read row:creates a free space in the memory with the size we order Buffer = (float *) CPLMalloc(sizeof(float)*nXSize); // read a row poBand ->RasterIO(GF_Read, 0, i, nXSize, 1, Buffer, nXSize, 1, GDT_Float32, 0, 0); for (int j=0; j< nCols; ++j){ RasterData.push_back(Buffer[j]); maxH = max(maxH,Buffer[j]); if( Buffer[j] != poBand->GetNoDataValue()){ minH = min(minH,Buffer[j]); } } CPLFree(Buffer); } maxheight = maxH; minheight = minH; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Raster_Reader::Put_in_Raster(cv::Mat FP,string gdal_result_path) { GDALDriver *poDriver; const char *pszFormat = "GTiff"; poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); char **papszOptions = NULL; GDALDataset *poDstDS; poDstDS = poDriver->Create( gdal_result_path.c_str(), nCols, nRows,1, GDT_Float32 ,papszOptions ); poDstDS->SetGeoTransform( gTransform); poDstDS->SetProjection( gDataSet->GetProjectionRef() ); GDALRasterBand *poBand; poBand = poDstDS->GetRasterBand(1); float *Buffer; for(int i=0; i < nRows; i++){ Buffer = (float *) CPLMalloc(sizeof(float)*nCols); for (int j=0; j< nCols; ++j){ Buffer[j] =FP.at<uchar>(i,j); } poBand->RasterIO(GF_Write , 0, i, nCols, 1, Buffer, nCols, 1, GDT_Float32 , 0, 0); } GDALClose( (GDALDatasetH) poDstDS ); CPLFree(Buffer); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Point2D Raster_Reader::get_World_coord(float col , float row ){ Point2D point; point.x = originX + col*gTransform[1] + row*gTransform[2]; point.y = originY + col*gTransform[4] + row*gTransform[5]; return point; } /////////////////////////////////////////////////////////////////////////////////////////// Pixel Raster_Reader::get_pixel(double x , double y ){ /* X = originX + col*geoTransform[1] + row*geoTransform[2]; Y = originY + col*geoTransform[4] + row*geoTransform[5]; we consider that we won t have any rotation ,so the equations become : X = originX + col*geoTransform[1] ; Y = originY + row*geoTransform[5]; */ Pixel pix; pix.col = (int) ((x - originX ) / gTransform[1]) ; pix.row = (int) ((y - originY) / gTransform[5]) ; return pix ; } //////////////////////////////////////////////////////// double Raster_Reader::get_height(size_t col , size_t row ){ /* RasterData=[ (# # # # ... # # # nCols values)first row / (# # # # ... # # # nCols values )second row / ..............(# # # # ... # # # nCols values)last row which is the row number nRows] so to get to the row number y we multiply it with number of cols ,and then we add the position of the the colonne x we need to be exqctly at the position (x,y) of the matrix */ size_t cpt = 0 ; cpt = nCols*row + col ; return RasterData[cpt] ; } //////////////////////////////////////////////////////////////////////////////////////////// Raster_Reader::~Raster_Reader() { if (gDataSet != NULL){ GDALClose(gDataSet); } }
[ "welarfao@laas.fr" ]
welarfao@laas.fr
afba313b38f9188acd995d6e894ae782a099d92f
653709022e7a5c93c7091ccc4d9ec17a518820b3
/DirectXFramework/Graphics2/BoundingVolume.h
383b24d2fd6954f1efc7cdef473d9449c3551f28
[]
no_license
ShayyP/Graphics-2-Coursework
cf99071a472091b17e960977e722839bbc9cd9dc
3e0ac4a16320e96630298bfecc998221fd850ac5
refs/heads/master
2022-06-17T22:22:14.298664
2020-05-10T16:31:01
2020-05-10T16:31:01
240,533,313
0
0
null
null
null
null
UTF-8
C++
false
false
1,040
h
#pragma once #include "core.h" #include "DirectXCore.h" #include <vector> #include "Structs.h" using namespace std; // Base class for bounding volumes, has virtual methods that are overridden by child classes class BoundingVolume : public enable_shared_from_this<BoundingVolume> { public: BoundingVolume() { XMStoreFloat4x4(&_combinedWorldTransformation, XMMatrixIdentity()); } virtual bool IsIntersecting(shared_ptr<BoundingVolume> otherVolume) { return false; } virtual float IsIntersectingRay(XMVECTOR origin, XMVECTOR direction) { return false; } virtual void Update(FXMMATRIX& worldTransformation) {} virtual void Render() {}; XMFLOAT4X4 GetCombinedWorldTransformation() { return _combinedWorldTransformation; } vector<WireframeVertex> GetVertices() { return _vertices; } vector<UINT> GetIndices() { return _indices; } float GetMaxSize() { return _maxSize; } protected: XMFLOAT4X4 _combinedWorldTransformation; vector<WireframeVertex> _vertices; vector<UINT> _indices; float _maxSize = 0.0f; };
[ "shayp2000@gmail.com" ]
shayp2000@gmail.com
f208fe64e10922f4127ce82544d841edb7761c8e
01a42b69633daf62a2eb3bb70c5b1b6e2639aa5f
/SCUM_Sexy_Jeans_Shorts_02_functions.cpp
e6131ce2fabe7b1fb0bfa6bef4d203571cfa1480
[]
no_license
Kehczar/scum_sdk
45db80e46dac736cc7370912ed671fa77fcb95cf
8d1770b44321a9d0b277e4029551f39b11f15111
refs/heads/master
2022-07-25T10:06:20.892750
2020-05-21T11:45:36
2020-05-21T11:45:36
265,826,541
1
0
null
null
null
null
UTF-8
C++
false
false
3,196
cpp
// Scum 3.79.22573 (UE 4.24) #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace Classes { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function ConZ.ClothesItem.UpdateMaterialParamsOnClients // () void ASexy_Jeans_Shorts_02_C::UpdateMaterialParamsOnClients() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.UpdateMaterialParamsOnClients"); ASexy_Jeans_Shorts_02_C_UpdateMaterialParamsOnClients_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.ClothesItem.SetDirtiness // () // Parameters: // float* dirtiness (Parm, ZeroConstructor, IsPlainOldData) void ASexy_Jeans_Shorts_02_C::SetDirtiness(float* dirtiness) { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.SetDirtiness"); ASexy_Jeans_Shorts_02_C_SetDirtiness_Params params; params.dirtiness = dirtiness; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.ClothesItem.OnRep_MaterialParameters // () void ASexy_Jeans_Shorts_02_C::OnRep_MaterialParameters() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.OnRep_MaterialParameters"); ASexy_Jeans_Shorts_02_C_OnRep_MaterialParameters_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.ClothesItem.GetWarmth // () // Parameters: // int ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) int ASexy_Jeans_Shorts_02_C::GetWarmth() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.GetWarmth"); ASexy_Jeans_Shorts_02_C_GetWarmth_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.ClothesItem.GetCapacityY // () // Parameters: // int ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) int ASexy_Jeans_Shorts_02_C::GetCapacityY() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.GetCapacityY"); ASexy_Jeans_Shorts_02_C_GetCapacityY_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.ClothesItem.GetCapacityX // () // Parameters: // int ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) int ASexy_Jeans_Shorts_02_C::GetCapacityX() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.ClothesItem.GetCapacityX"); ASexy_Jeans_Shorts_02_C_GetCapacityX_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "65712402+Kehczar@users.noreply.github.com" ]
65712402+Kehczar@users.noreply.github.com
4baa3758359665b3ca2f7202abdb4460e2b72126
b956eb9be02f74d81176bc58d585f273accf73fb
/aladdin/audio/Sound.h
0b8f7ea1c21f0a1df4922be162ecfbc05981f84a
[ "MIT" ]
permissive
Khuongnb/game-aladdin
b9b1c439d14658ca9d67d5c6fe261ec27084b2e9
74b13ffcd623de0d6f799b0669c7e8917eef3b14
refs/heads/master
2020-05-05T10:20:05.616126
2019-04-07T09:05:11
2019-04-07T09:05:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
762
h
#ifndef __ALADDIN_AUDIO_SOUND_H__ #define __ALADDIN_AUDIO_SOUND_H__ #include "AudioInclude.h" NAMESPACE_ALA { ALA_CLASS_HEADER_2(Sound, ala::Initializable, ala::Releasable) private: std::string _sourceFile; public: Sound( const std::string& sourceFile ); virtual ~Sound(); public: void initialize() override; void release() override; const std::string& getSourceFile() const; // =================================================== // Platform specific // =================================================== private: CSound* _cSound; public: CSound* getCSound() const; void setCSound( CSound* cSound ); bool isPlaying() const; private: void initCSound(); void releaseCSound(); }; } #endif //!__ALADDIN_AUDIO_SOUND_H__
[ "khuongnb1997@gmail.com" ]
khuongnb1997@gmail.com
783fc3cd1c5421ac9e2fc132756c161c07388069
a06515f4697a3dbcbae4e3c05de2f8632f8d5f46
/corpus/taken_from_cppcheck_tests/stolen_10725.cpp
ab83292c58601c24314184208008b7b23b8d1cfc
[]
no_license
pauldreik/fuzzcppcheck
12d9c11bcc182cc1f1bb4893e0925dc05fcaf711
794ba352af45971ff1f76d665b52adeb42dcab5f
refs/heads/master
2020-05-01T01:55:04.280076
2019-03-22T21:05:28
2019-03-22T21:05:28
177,206,313
0
0
null
null
null
null
UTF-8
C++
false
false
112
cpp
void f(int x) { int ret; switch (x) { case 123: ret = 1; break; } ret = 3; }
[ "github@pauldreik.se" ]
github@pauldreik.se
8e52c41b4ef6752e827ee75e017dcdaf79d44b63
a48b49c869283d4fbd6902f30c6df0fa922bfdb6
/oldSocialHat/SocialHat.ino
032c45fd1779c38fa356ba60c5320acf4c074522
[]
no_license
jakeschievink/SocialHat
2fbb941afa6eb19bfedd8bc508ca61918946bb11
33c94832649d4f14c504e353b2ba3f27bc25fceb
refs/heads/master
2020-05-18T01:06:11.810953
2014-11-01T23:19:55
2014-11-01T23:19:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,227
ino
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <EEPROM.h> #include "EEPROMAnything.h" #include "Scroll.h" #include "Pictures.cpp" Scroll scrollscreen(9, 10, 11, 13, 12); char message[200]; bool imagedisplayed = false; bool interTrigger = false; typedef enum {SCROLL, IMAGE} mode; const int buttonPin = 8; const unsigned char* pictures[] = {oledtest, Google, CopyLeft}; uint pictureCounter = 0; mode currentmode = SCROLL; void setup() { Serial.begin(9600); pinMode(buttonPin, INPUT); attachInterrupt(buttonPin, stateChange, HIGH); scrollscreen.init(); EEPROM_readAnything(1, message); scrollscreen.setMessage(message); Serial.println(message); } void loop() { if(currentmode == SCROLL){ scrollscreen.startScroll(); checkSerial(); } if(currentmode == IMAGE && !imagedisplayed){ displayImage(); imagedisplayed = true; } if(interTrigger == true){ delay(10); interTrigger = false; imagedisplayed = false; if(currentmode == IMAGE){ currentmode = SCROLL; }else{ currentmode = IMAGE; } } } void displayImage(){ scrollscreen.disp.clearDisplay(); scrollscreen.disp.drawBitmap(0,0, pictures[pictureCounter], 128, 64, 1); if(pictureCounter < (sizeof(pictures)/ sizeof(pictures[0]))-1){ pictureCounter++; }else{ pictureCounter=0; } scrollscreen.disp.display(); } void stateChange(){ interTrigger = true; } void checkSerial(){ bool firstRead = false; char option; char tmpMsg[200]; if(Serial.available() > 0){ if(!firstRead){ option = Serial.read(); firstRead = true; Serial.println(option); } recieveChars().toCharArray(tmpMsg, 100); Serial.print(tmpMsg); scrollscreen.setMessage(tmpMsg); Serial.println(EEPROM_writeAnything(1, tmpMsg)); } } String recieveChars(){ String content = ""; char character; while(Serial.available()) { character = Serial.read(); content.concat(character); Serial.println((byte)character); } if(content != ""){ return content; } }
[ "jakeschievink@gmail.com" ]
jakeschievink@gmail.com
bd6f6e2d7f8647c6251e2bcdf5cf39da0f45eeac
8465159705a71cede7f2e9970904aeba83e4fc6c
/src_change_the_layout/modules/IEC61131-3/Conversion/BYTE/F_BYTE_TO_WORD.h
5231045cb24368637df36a289a3acba93d9a0a6e
[]
no_license
TuojianLYU/forte_IO_OPCUA_Integration
051591b61f902258e3d0d6608bf68e2302f67ac1
4a3aed7b89f8a7d5f9554ac5937cf0a93607a4c6
refs/heads/main
2023-08-20T16:17:58.147635
2021-10-27T05:34:43
2021-10-27T05:34:43
419,704,624
1
0
null
null
null
null
UTF-8
C++
false
false
1,841
h
/******************************************************************************* * Copyright (c) 2011 ACIN * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Monika Wenger * - initial API and implementation and/or initial documentation *******************************************************************************/ #ifndef _F_BYTE_TO_WORD_H_ #define _F_BYTE_TO_WORD_H_ #include <funcbloc.h> class FORTE_F_BYTE_TO_WORD: public CFunctionBlock{ DECLARE_FIRMWARE_FB(FORTE_F_BYTE_TO_WORD) private: static const CStringDictionary::TStringId scm_anDataInputNames[]; static const CStringDictionary::TStringId scm_anDataInputTypeIds[]; CIEC_BYTE &st_IN() { return *static_cast<CIEC_BYTE*>(getDI(0)); }; static const CStringDictionary::TStringId scm_anDataOutputNames[]; static const CStringDictionary::TStringId scm_anDataOutputTypeIds[]; CIEC_WORD &st_OUT() { return *static_cast<CIEC_WORD*>(getDO(0)); }; static const TEventID scm_nEventREQID = 0; static const TForteInt16 scm_anEIWithIndexes[]; static const TDataIOID scm_anEIWith[]; static const CStringDictionary::TStringId scm_anEventInputNames[]; static const TEventID scm_nEventCNFID = 0; static const TForteInt16 scm_anEOWithIndexes[]; static const TDataIOID scm_anEOWith[]; static const CStringDictionary::TStringId scm_anEventOutputNames[]; static const SFBInterfaceSpec scm_stFBInterfaceSpec; FORTE_FB_DATA_ARRAY(1, 1, 1, 0); void executeEvent(int pa_nEIID); public: FUNCTION_BLOCK_CTOR(FORTE_F_BYTE_TO_WORD){ }; virtual ~FORTE_F_BYTE_TO_WORD(){}; }; #endif //close the ifdef sequence from the beginning of the file
[ "tuojianlyu@gmail.com" ]
tuojianlyu@gmail.com
2a8fae1a8ed8c2dc5f464711bb82a26f1dc2bab1
5a8b9a20f7c498981eb4ea33c1cba4b9554440b4
/Xindows/src/site/text/selrensv.h
9522be36edd1bd9f2c8eef281799775a838b306a
[]
no_license
mensong/IE5.5_vs2008
82ae91b3e45d312589b6fb461ceef5608dfb2f6b
6149654180d0f422355e38b0c5d8e84e6e8c6a0c
refs/heads/master
2022-05-01T07:32:15.727457
2018-11-14T03:07:51
2018-11-14T03:07:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,623
h
#ifndef __XINDOWS_SITE_TEXT_SELRENSV_H__ #define __XINDOWS_SITE_TEXT_SELRENSV_H__ int OldCompare ( IMarkupPointer * p1, IMarkupPointer * p2 ); struct PointerSegment { CMarkupPointer* _pStart; CMarkupPointer* _pEnd; HIGHLIGHT_TYPE _HighlightType; int _cpStart; int _cpEnd; BOOL _fFiredSelectionNotify; // Has the SelectionNotification been fired on this segment }; struct HighlightSegment { int _cpStart; int _cpEnd; DWORD _dwHighlightType; }; #define WM_BEGINSELECTION (WM_USER+1201) // Posted by Selection to say we've begun a selection #define START_TEXT_SELECTION 1 #define START_CONTROL_SELECTION 2 class CSelectionRenderingServiceProvider { public: DECLARE_MEMCLEAR_NEW_DELETE() CSelectionRenderingServiceProvider(CDocument* pDoc); ~CSelectionRenderingServiceProvider(); // ISelectionRenderServices Interface STDMETHOD(AddSegment)( IMarkupPointer* pStart, IMarkupPointer* pEnd, HIGHLIGHT_TYPE HighlightType, int* iSegmentIndex); STDMETHOD(AddElementSegment)( IHTMLElement* pElement, int* iSegmentIndex); STDMETHOD(MovePointersToSegment)( int iSegmentIndex, IMarkupPointer* pStart, IMarkupPointer* pEnd); STDMETHOD(GetElementSegment)( int iSegmentIndex, IHTMLElement** ppElement); STDMETHOD(MoveSegmentToPointers)( int iSegmentIndex, IMarkupPointer* pStart, IMarkupPointer* pEnd, HIGHLIGHT_TYPE HighlightType); STDMETHOD(SetElementSegment)( int iSegmentIndex, IHTMLElement* pElement); STDMETHOD( GetSegmentCount)( int* piSegmentCount, SELECTION_TYPE* peType); STDMETHOD(ClearSegment)( int iSegmentIndex, BOOL fInvalidate); STDMETHOD(ClearSegments)(BOOL fInvalidate); STDMETHOD(ClearElementSegments)(); VOID GetSelectionChunksForLayout( CFlowLayout* pFlowLayout, CPtrAry<HighlightSegment*>* paryHighlight, int* pCpMin, int* pCpMax); HRESULT InvalidateSegment( CMarkupPointer* pStart, CMarkupPointer*pEnd, CMarkupPointer* pNewStart, CMarkupPointer* pNewEnd , BOOL fSelected, BOOL fFireOM=TRUE); HRESULT UpdateSegment( CMarkupPointer* pOldStart, CMarkupPointer* pOldEnd, CMarkupPointer* pNewStart, CMarkupPointer* pNewEnd); BOOL IsElementSelected(CElement* pElement); CElement* GetSelectedElement(int iElementIndex); HRESULT GetFlattenedSelection( int iSegmentIndex, int& cpStart, int& cpEnd, SELECTION_TYPE& eType); VOID HideSelection(); VOID ShowSelection(); VOID InvalidateSelection(BOOL fSelectionOn, BOOL fFireOM); private: VOID ConstructSelectionRenderCache(); BOOL IsLayoutCompletelyEnclosed( CLayout* pLayout, CMarkupPointer* pStart, CMarkupPointer* pEnd); CDocument* _pDoc; CPtrAry<PointerSegment*>* _parySegment; // Array of all segments CPtrAry<CElement*>* _paryElementSegment; // Array of Element Segments. HRESULT NotifyBeginSelection(WPARAM wParam); long _lContentsVersion; // Use this to compare when we need to invalidate BOOL _fSelectionVisible:1; // Is Selection Visible ? BOOL _fPendingInvalidate:1; // Pending Invalidation. BOOL _fPendingFireOM:1; // Value for fFireOM on Pending Inval. BOOL _fInUpdateSegment:1; // Are we updating the segments. }; #endif //__XINDOWS_SITE_TEXT_SELRENSV_H__
[ "mail0668@gmail.com" ]
mail0668@gmail.com
e15e0190faaa4749c2d9e144a8a911437b95660a
8291fc32d222d7cd8f4ff8cd3179ce63181cafdc
/cpp_module_05/ex03/Bureaucrat.cpp
170580d0c0001a99d6c9b7df852d2b3fc7552173
[]
no_license
FrenkenFlores/CPP_Module
d09d5b15ee79053c2d817492e9b9102fb0b56078
8d9458cb02bd2c4e67febe9df46d502772e6d627
refs/heads/main
2023-04-10T08:11:56.738638
2021-04-14T22:22:41
2021-04-14T22:22:41
344,802,483
0
0
null
null
null
null
UTF-8
C++
false
false
3,215
cpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Bureaucrat.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: fflores <fflores@student.21-school.ru> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/03/30 06:06:24 by fflores #+# #+# */ /* Updated: 2021/03/30 06:06:25 by fflores ### ########.fr */ /* */ /* ************************************************************************** */ #include "Bureaucrat.hpp" Bureaucrat::Bureaucrat() { std::cout << "Default constructor called " << std::endl; return; } Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name), _grade(grade) { if (_grade < 1) throw GradeTooHighException(); else if (_grade > 150) throw GradeTooLowException(); std::cout << "Constructor called " << std::endl; return; } Bureaucrat::Bureaucrat(const Bureaucrat &src) : _name(src.getName()), _grade(src.getGrade()){ if (_grade < 1) throw GradeTooHighException(); else if (_grade > 150) throw GradeTooLowException(); std::cout << "Copy constructor called " << std::endl; return; } Bureaucrat & Bureaucrat::operator=(const Bureaucrat &rhs) { _grade = rhs._grade; if (_grade < 1) throw GradeTooHighException(); else if (_grade > 150) throw GradeTooLowException(); std::cout << "Assignation operator called " << std::endl; return (*this); } std::ostream & operator<<(std::ostream &out, const Bureaucrat &src) { out << "<" << src.getName() << "> has grade <" << src.getGrade() << ">" << std::endl; return (out); } Bureaucrat::~Bureaucrat() { std::cout << "Destructor called " << std::endl; return; } std::string Bureaucrat::getName() const{ return (_name); } int Bureaucrat::getGrade() const{ return (_grade); } void Bureaucrat::setGrade(int grade) { _grade = grade; return ; } void Bureaucrat::incrementGrade() { _grade--; if (_grade < 1) throw GradeTooHighException(); std::cout << "Grade been incremented and it equals " << getGrade() << std::endl; return; } void Bureaucrat::decrementGrade() { _grade++; if (_grade > 150) throw GradeTooLowException(); std::cout << "Grade been decremented and it equals " << getGrade() << std::endl; return; } void Bureaucrat::signForm(Form &form) { if (_grade <= form.getSignGrade()) { form.beSigned(*this); std::cout << "<" << _name << "> signs <" << form.getTarget() << ">" << std::endl; } else std::cout << "<" << _name << "> can't sign <" << form.getTarget() << "> because the form needs a higher grade" << std::endl; return; } void Bureaucrat::executeForm(Form const &form) { try { std::cout << "<" << _name << "> executes <" << form.getTarget() << ">" << std::endl; form.execute(*this); } catch(const std::exception& e) { std::cout << e.what() << std::endl; } }
[ "saifualdin.evloev@gmail.com" ]
saifualdin.evloev@gmail.com
bf9274f25d4fd06e54a9cd469ad293b8a3eb6e2a
9eed36ccf2be5585685f9531e595c1d14fd8ef76
/extern/3rd/PcapPlusPlus-19.12/Pcap++/src/RawSocketDevice.cpp
c44590723929610ba0b9e6913a62f40b132eb6cb
[ "WTFPL", "Unlicense" ]
permissive
Cyweb-unknown/eft-packet-1
756ab75b96e658a0b2044e09389b7a06d285c971
925da44fc1f49e4fe6b17e79248714ada4ea451d
refs/heads/master
2022-10-27T11:47:09.454465
2020-06-13T14:41:43
2020-06-13T14:41:43
272,038,457
1
1
WTFPL
2020-06-13T15:46:17
2020-06-13T15:46:16
null
UTF-8
C++
false
false
13,573
cpp
#include "RawSocketDevice.h" #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) #include <winsock2.h> #include <ws2tcpip.h> #endif #ifdef LINUX #include <fcntl.h> #include <errno.h> #include <unistd.h> #include <linux/if_ether.h> #include <netpacket/packet.h> #include <ifaddrs.h> #include <net/if.h> #endif #include <string.h> #include "Logger.h" #include "IpUtils.h" #include "SystemUtils.h" #include "Packet.h" #include "EthLayer.h" namespace pcpp { #define RAW_SOCKET_BUFFER_LEN 65536 #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) #ifndef SIO_RCVALL /* SIO_RCVALL defined on w2k and later. Not defined in Mingw32 */ /* 0x98000001 = _WSAIOW(IOC_VENDOR,1) */ # define SIO_RCVALL 0x98000001 #endif // SIO_RCVALL class WinSockInitializer { private: static bool m_IsInitialized; public: static void initialize() { if (m_IsInitialized) return; // Load Winsock WSADATA wsaData; int res = WSAStartup(MAKEWORD(2,2), &wsaData); if (res != 0) { LOG_ERROR("WSAStartup failed with error code: %d", res); m_IsInitialized = false; } m_IsInitialized = true; } }; bool WinSockInitializer::m_IsInitialized = false; #endif // defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) struct SocketContainer { #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) SOCKET fd; #elif LINUX int fd; int interfaceIndex; std::string interfaceName; #endif }; RawSocketDevice::RawSocketDevice(const IPAddress& interfaceIP) : IDevice(), m_Socket(NULL) { #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) WinSockInitializer::initialize(); m_InterfaceIP = interfaceIP.clone(); m_SockFamily = (m_InterfaceIP->getType() == IPAddress::IPv4AddressType ? IPv4 : IPv6); #elif LINUX m_InterfaceIP = interfaceIP.clone(); m_SockFamily = Ethernet; #else m_InterfaceIP = NULL; m_SockFamily = Ethernet; #endif } RawSocketDevice::~RawSocketDevice() { close(); if (m_InterfaceIP != NULL) delete m_InterfaceIP; } RawSocketDevice::RecvPacketResult RawSocketDevice::receivePacket(RawPacket& rawPacket, bool blocking, int timeout) { #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) if (!isOpened()) { LOG_ERROR("Device is not open"); return RecvError; } SOCKET fd = ((SocketContainer*)m_Socket)->fd; char* buffer = new char[RAW_SOCKET_BUFFER_LEN]; memset(buffer, 0, RAW_SOCKET_BUFFER_LEN); // value of 0 timeout means disabling timeout if (timeout < 0) timeout = 0; u_long blockingMode = (blocking? 0 : 1); ioctlsocket(fd, FIONBIO, &blockingMode); DWORD timeoutVal = timeout * 1000; setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeoutVal, sizeof(timeoutVal)); //recvfrom(fd, buffer, RAW_SOCKET_BUFFER_LEN, 0, (struct sockaddr*)&sockAddr,(socklen_t*)&sockAddrLen); int bufferLen = recv(fd, buffer, RAW_SOCKET_BUFFER_LEN, 0); if (bufferLen < 0) { delete [] buffer; int errorCode = 0; RecvPacketResult error = getError(errorCode); if (error == RecvError) LOG_ERROR("Error reading from recvfrom. Error code is %d", errorCode); return error; } if (bufferLen > 0) { timeval time; gettimeofday(&time, NULL); rawPacket.setRawData((const uint8_t*)buffer, bufferLen, time, LINKTYPE_DLT_RAW1); return RecvSuccess; } LOG_ERROR("Buffer length is zero"); delete [] buffer; return RecvError; #elif LINUX if (!isOpened()) { LOG_ERROR("Device is not open"); return RecvError; } int fd = ((SocketContainer*)m_Socket)->fd; char* buffer = new char[RAW_SOCKET_BUFFER_LEN]; memset(buffer, 0, RAW_SOCKET_BUFFER_LEN); // value of 0 timeout means disabling timeout if (timeout < 0) timeout = 0; // set blocking or non-blocking flag int flags = fcntl(fd, F_GETFL, 0); if (flags == -1) { LOG_ERROR("Cannot get socket flags"); return RecvError; } flags = (blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK)); if (fcntl(fd, F_SETFL, flags) != 0) { LOG_ERROR("Cannot set socket non-blocking flag"); return RecvError; } // set timeout on socket struct timeval timeoutVal; timeoutVal.tv_sec = timeout; timeoutVal.tv_usec = 0; setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeoutVal, sizeof(timeoutVal)); int bufferLen = recv(fd, buffer, RAW_SOCKET_BUFFER_LEN, 0); if (bufferLen < 0) { delete [] buffer; int errorCode = errno; RecvPacketResult error = getError(errorCode); if (error == RecvError) LOG_ERROR("Error reading from recvfrom. Error code is %d", errorCode); return error; } if (bufferLen > 0) { timeval time; gettimeofday(&time, NULL); rawPacket.setRawData((const uint8_t*)buffer, bufferLen, time, LINKTYPE_ETHERNET); return RecvSuccess; } LOG_ERROR("Buffer length is zero"); delete [] buffer; return RecvError; #else LOG_ERROR("Raw socket are not supported on this platform"); return RecvError; #endif } int RawSocketDevice::receivePackets(RawPacketVector& packetVec, int timeout, int& failedRecv) { if (!isOpened()) { LOG_ERROR("Device is not open"); return 0; } long curSec, curNsec; clockGetTime(curSec, curNsec); int packetCount = 0; failedRecv = 0; long timeoutSec = curSec + timeout; while (curSec < timeoutSec) { RawPacket* rawPacket = new RawPacket(); if (receivePacket(*rawPacket, true, timeoutSec-curSec) == RecvSuccess) { packetVec.pushBack(rawPacket); packetCount++; } else { failedRecv++; delete rawPacket; } clockGetTime(curSec, curNsec); } return packetCount; } bool RawSocketDevice::sendPacket(const RawPacket* rawPacket) { #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) LOG_ERROR("Sending packets with raw socket are not supported on Windows"); return 0; #elif LINUX if (!isOpened()) { LOG_ERROR("Device is not open"); return false; } Packet packet((RawPacket*)rawPacket, OsiModelDataLinkLayer); if (!packet.isPacketOfType(pcpp::Ethernet)) { LOG_ERROR("Can't send non-Ethernet packets"); return false; } int fd = ((SocketContainer*)m_Socket)->fd; sockaddr_ll addr; memset(&addr, 0, sizeof(struct sockaddr_ll)); addr.sll_family = htons(PF_PACKET); addr.sll_protocol = htons(ETH_P_ALL); addr.sll_halen = 6; addr.sll_ifindex = ((SocketContainer*)m_Socket)->interfaceIndex; EthLayer* ethLayer = packet.getLayerOfType<EthLayer>(); MacAddress dstMac = ethLayer->getDestMac(); dstMac.copyTo((uint8_t*)&(addr.sll_addr)); if (::sendto(fd, ((RawPacket*)rawPacket)->getRawData(), ((RawPacket*)rawPacket)->getRawDataLen(), 0, (struct sockaddr*)&addr, sizeof(addr)) == -1) { LOG_ERROR("Failed to send packet. Error was: '%s'", strerror(errno)); return false; } return true; #else LOG_ERROR("Raw socket are not supported on this platform"); return 0; #endif } int RawSocketDevice::sendPackets(const RawPacketVector& packetVec) { #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) LOG_ERROR("Sending packets with raw socket are not supported on Windows"); return false; #elif LINUX if (!isOpened()) { LOG_ERROR("Device is not open"); return 0; } int fd = ((SocketContainer*)m_Socket)->fd; sockaddr_ll addr; memset(&addr, 0, sizeof(struct sockaddr_ll)); addr.sll_family = htons(PF_PACKET); addr.sll_protocol = htons(ETH_P_ALL); addr.sll_halen = 6; addr.sll_ifindex = ((SocketContainer*)m_Socket)->interfaceIndex; int sendCount = 0; for (RawPacketVector::ConstVectorIterator iter = packetVec.begin(); iter != packetVec.end(); iter++) { Packet packet(*iter, OsiModelDataLinkLayer); if (!packet.isPacketOfType(pcpp::Ethernet)) { LOG_DEBUG("Can't send non-Ethernet packets"); continue; } EthLayer* ethLayer = packet.getLayerOfType<EthLayer>(); MacAddress dstMac = ethLayer->getDestMac(); dstMac.copyTo((uint8_t*)&(addr.sll_addr)); if (::sendto(fd, (*iter)->getRawData(), (*iter)->getRawDataLen(), 0, (struct sockaddr*)&addr, sizeof(addr)) == -1) { LOG_DEBUG("Failed to send packet. Error was: '%s'", strerror(errno)); continue; } sendCount++; } return sendCount; #else LOG_ERROR("Raw socket are not supported on this platform"); return false; #endif } bool RawSocketDevice::open() { #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) if (!m_InterfaceIP->isValid()) { LOG_ERROR("IP address is not valid"); return false; } int family = (m_SockFamily == IPv4 ? AF_INET : AF_INET6); SOCKET fd = socket(family, SOCK_RAW, IPPROTO_IP); if ((int)fd == SOCKET_ERROR) { int error = WSAGetLastError(); std::string additionalMessage = ""; if (error == WSAEACCES) additionalMessage = ", you may not be running with administrative privileges which is required for opening raw sockets on Windows"; LOG_ERROR("Failed to create raw socket. Error code was %d%s", error, additionalMessage.c_str()); return false; } void* localAddr = NULL; struct sockaddr_in localAddrIPv4; struct sockaddr_in6 localAddrIPv6; size_t localAddrSize = 0; if (m_SockFamily == IPv4) { localAddrIPv4.sin_family = family; int res = inet_pton(family, m_InterfaceIP->toString().c_str(), &localAddrIPv4.sin_addr.s_addr); if (res <= 0) { LOG_ERROR("inet_pton failed, probably IP address provided is in bad format"); closesocket(fd); return false; } localAddrIPv4.sin_port = 0; // Any local port will do localAddr = &localAddrIPv4; localAddrSize = sizeof(localAddrIPv4); } else { localAddrIPv6.sin6_family = family; int res = inet_pton(AF_INET6, m_InterfaceIP->toString().c_str(), &localAddrIPv6.sin6_addr.s6_addr); if (res <= 0) { LOG_ERROR("inet_pton failed, probably IP address provided is in bad format"); closesocket(fd); return false; } localAddrIPv6.sin6_port = 0; // Any local port will do localAddrIPv6.sin6_scope_id = 0; localAddr = &localAddrIPv6; localAddrSize = sizeof(localAddrIPv6); } if (bind(fd, (struct sockaddr *)localAddr, localAddrSize) == SOCKET_ERROR) { LOG_ERROR("Failed to bind to interface. Error code was '%d'", WSAGetLastError()); closesocket(fd); return false; } int n = 1; DWORD dwBytesRet; if (WSAIoctl(fd, SIO_RCVALL, &n, sizeof(n), NULL, 0, &dwBytesRet, NULL, NULL) == SOCKET_ERROR) { LOG_ERROR("Call to WSAIotcl(%ul) failed with error code %d", SIO_RCVALL, WSAGetLastError()); closesocket(fd); return false; } m_Socket = new SocketContainer(); ((SocketContainer*)m_Socket)->fd = fd; m_DeviceOpened = true; return true; #elif LINUX if (!m_InterfaceIP->isValid()) { LOG_ERROR("IP address is not valid"); return false; } int fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (fd < 0) { LOG_ERROR("Failed to create raw socket. Error code was %d", errno); return false; } // find interface name and index from IP address struct ifaddrs* addrs; getifaddrs(&addrs); std::string ifaceName = ""; int ifaceIndex = -1; for (struct ifaddrs* curAddr = addrs; curAddr != NULL; curAddr = curAddr->ifa_next) { if (curAddr->ifa_addr && (curAddr->ifa_flags & IFF_UP)) { if (curAddr->ifa_addr->sa_family == AF_INET) { struct sockaddr_in* sockAddr = (struct sockaddr_in*)(curAddr->ifa_addr); char addrAsCharArr[32]; inet_ntop(curAddr->ifa_addr->sa_family, (void *)&(sockAddr->sin_addr), addrAsCharArr, sizeof(addrAsCharArr)); if (!strcmp(m_InterfaceIP->toString().c_str(), addrAsCharArr)) { ifaceName = curAddr->ifa_name; ifaceIndex = if_nametoindex(curAddr->ifa_name); } } else if (curAddr->ifa_addr->sa_family == AF_INET6) { struct sockaddr_in6* sockAddr = (struct sockaddr_in6*)(curAddr->ifa_addr); char addrAsCharArr[40]; inet_ntop(curAddr->ifa_addr->sa_family, (void *)&(sockAddr->sin6_addr), addrAsCharArr, sizeof(addrAsCharArr)); if (!strcmp(m_InterfaceIP->toString().c_str(), addrAsCharArr)) { ifaceName = curAddr->ifa_name; ifaceIndex = if_nametoindex(curAddr->ifa_name); } } } } freeifaddrs(addrs); if (ifaceName == "" || ifaceIndex < 0) { LOG_ERROR("Cannot detect interface name or index from IP address"); ::close(fd); return false; } // bind raw socket to interface struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifaceName.c_str()); if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr)) == -1) { LOG_ERROR("Cannot bind raw socket to interface '%s'", ifaceName.c_str()); ::close(fd); return false; } m_Socket = new SocketContainer(); ((SocketContainer*)m_Socket)->fd = fd; ((SocketContainer*)m_Socket)->interfaceIndex = ifaceIndex; ((SocketContainer*)m_Socket)->interfaceName = ifaceName; m_DeviceOpened = true; return true; #else LOG_ERROR("Raw socket are not supported on this platform"); return false; #endif } void RawSocketDevice::close() { if (m_Socket != NULL && isOpened()) { SocketContainer* sockContainer = (SocketContainer*)m_Socket; #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) closesocket(sockContainer->fd); #elif LINUX ::close(sockContainer->fd); #endif delete sockContainer; m_Socket = NULL; m_DeviceOpened = false; } } RawSocketDevice::RecvPacketResult RawSocketDevice::getError(int& errorCode) const { #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV) errorCode = WSAGetLastError(); if (errorCode == WSAEWOULDBLOCK) return RecvWouldBlock; if (errorCode == WSAETIMEDOUT) return RecvTimeout; return RecvError; #elif LINUX if ((errorCode == EAGAIN) || (errorCode == EWOULDBLOCK)) return RecvWouldBlock; return RecvError; #else return RecvError; #endif } }
[ "koraydemirci86@gmail.com" ]
koraydemirci86@gmail.com
542621f05afd4050dfdb14ed0478d45627db6e3e
4a2c47d8a84a821235dcdda8d898ff82aea54238
/opcn2.h
ab63b004f00314fafb30eee227d6c745b91ecf8b
[]
no_license
iamczar/opcn2-Arduino
3d3b2ca4f25376903af5b69f6498b9299bf8ea23
3be64397e00d437dd1856a7da9376621c078f382
refs/heads/master
2020-05-16T06:48:06.324850
2019-04-22T20:11:00
2019-04-22T20:11:00
182,858,708
0
0
null
2019-04-22T19:59:51
2019-04-22T19:59:50
null
UTF-8
C++
false
false
3,894
h
/* opcn2.h - Library for operating the Alphasense OPC-N2 Particle counter. Created by David H Hagan, March 2016. Modified by Marcelo Yungaicela, May 2017 Released with an MIT license. */ #ifndef Opcn2_h #define Opcn2_h // Includes struct Status { int fanON; int laserON; int fanDAC; int laserDAC; }; struct Firmware { int major; int minor; }; struct HistogramData { double bin0; double bin1; double bin2; double bin3; double bin4; double bin5; double bin6; double bin7; double bin8; double bin9; double bin10; double bin11; double bin12; double bin13; double bin14; double bin15; // Mass Time-of-Flight float bin1MToF; float bin3MToF; float bin5MToF; float bin7MToF; // Sample Flow Rate float sfr; // Either the Temperature or Pressure unsigned long temp_pressure; // Sampling Period float period; // Checksum unsigned int checksum; float pm1; float pm25; float pm10; }; struct PMData { float pm1; float pm25; float pm10; }; struct ConfigVars { // Bin Boundaries int bb0; int bb1; int bb2; int bb3; int bb4; int bb5; int bb6; int bb7; int bb8; int bb9; int bb10; int bb11; int bb12; int bb13; int bb14; // Bin Particle Volume (floats) float bpv0; float bpv1; float bpv2; float bpv3; float bpv4; float bpv5; float bpv6; float bpv7; float bpv8; float bpv9; float bpv10; float bpv11; float bpv12; float bpv13; float bpv14; float bpv15; // Bin Particle Densities (floats) float bpd0; float bpd1; float bpd2; float bpd3; float bpd4; float bpd5; float bpd6; float bpd7; float bpd8; float bpd9; float bpd10; float bpd11; float bpd12; float bpd13; float bpd14; float bpd15; // Bin Sample Volume Weightings (floats) float bsvw0; float bsvw1; float bsvw2; float bsvw3; float bsvw4; float bsvw5; float bsvw6; float bsvw7; float bsvw8; float bsvw9; float bsvw10; float bsvw11; float bsvw12; float bsvw13; float bsvw14; float bsvw15; // Gain Scaling Coefficient float gsc; // Sample Flow Rate (ml/s) float sfr; // LaserDAC 8 bit int unsigned int laser_dac; unsigned int fan_dac; // Time of Flight to Sample Flow Rate Conversion Factor unsigned int tof_sfr; }; struct ConfigVars2 { int AMSamplingInterval; int AMIntervalCount; int AMFanOnIdle; int AMLaserOnIdle; int AMMaxDataArraysInFile; int AMOnlySavePMData; }; class OPCN2 { private: // attributes uint8_t _CS; int _fv; // methods uint16_t _16bit_int(byte MSB, byte LSB); bool _compare_arrays(byte array1[], byte array2[], int length); float _calculate_float(byte val0, byte val1, byte val2, byte val3); uint32_t _32bit_int(byte val0, byte val1, byte val2, byte val3); public: OPCN2(uint8_t chip_select); // attributes Firmware firm_ver; // methods bool ping(); bool on(); bool off(); bool write_config_variables(byte values[]); bool write_config_variables2(byte values[]); bool write_serial_number_string(byte values[]); bool save_config_variables(); bool enter_bootloader(); bool set_fan_power(uint8_t value); bool set_laser_power(uint8_t value); bool toggle_fan(bool state); bool toggle_laser(bool state); String read_information_string(); String read_serial_number(); Firmware read_firmware_version(); Status read_status(); ConfigVars read_configuration_variables(); ConfigVars2 read_configuration_variables2(); PMData read_pm_data(); HistogramData read_histogram(bool convert_to_conc = true); }; #endif
[ "n.marceloy@gmail.com" ]
n.marceloy@gmail.com
f0802552d0b0fc2d1584640a80db77bc248a1ff1
d9b19ff32fd930a8e87fc5226e8e4d09dd1e4a52
/simParams.cpp
d35df207775a71c657d67e5ee6f3fe76428a6e88
[]
no_license
yyy910805/cme213
26f49052fe189762bcc5061105ec51e2564b48ca
81f78e41e9404b2d74b28fb3338f93f72c7a067c
refs/heads/master
2021-01-02T16:54:07.051824
2020-02-11T08:32:32
2020-02-11T08:32:32
239,710,552
0
0
null
null
null
null
UTF-8
C++
false
false
2,296
cpp
#include <fstream> #include <iostream> #include <cassert> #include <stdlib.h> #include "simParams.h" simParams::simParams(const char* filename) { std::ifstream ifs(filename); if(!ifs.good()) { std::cerr << "Couldn't open parameter file!" << std::endl; exit(1); } ifs >> nx_ >> ny_; assert(nx_ > 0); assert(ny_ > 0); ifs >> lx_ >> ly_; assert(lx_ > 0); assert(ly_ > 0); ifs >> iters_; assert(iters_ >= 0); ifs >> order_; assert(order_ == 2 || order_ == 4 || order_ == 8); ifs.close(); borderSize_ = 0; if(order_ == 2) { borderSize_ = 1; } else if(order_ == 4) { borderSize_ = 2; } else if(order_ == 8) { borderSize_ = 4; } assert(borderSize_ == 1 || borderSize_ == 2 || borderSize_ == 4); gx_ = nx_ + 2 * borderSize_; gy_ = ny_ + 2 * borderSize_; assert(gx_ > 2 * borderSize_); assert(gy_ > 2 * borderSize_); dx_ = lx_ / (gx_ - 1); dy_ = ly_ / (gy_ - 1); calcDtCFL(); } void simParams::calcDtCFL() { //check cfl number and make sure it is ok if(order_ == 2) { //make sure we come in just under the limit dt_ = (.5 - .01) * (dx_ * dx_ * dy_ * dy_) / (dx_ * dx_ + dy_ * dy_); xcfl_ = (dt_) / (dx_ * dx_); ycfl_ = (dt_) / (dy_ * dy_); } else if(order_ == 4) { dt_ = (.5 - .01) * (12 * dx_ * dx_ * dy_ * dy_) / (16 * (dx_ * dx_ + dy_ * dy_)); xcfl_ = (dt_) / (12 * dx_ * dx_); ycfl_ = (dt_) / (12 * dy_ * dy_); } else if(order_ == 8) { dt_ = (.5 - .01) * (5040 * dx_ * dx_ * dy_ * dy_) / (8064 * (dx_ * dx_ + dy_ * dy_)); xcfl_ = (dt_) / (5040 * dx_ * dx_); ycfl_ = (dt_) / (5040 * dy_ * dy_); } else { std::cerr << "Unsupported discretization order." << std::endl; exit(1); } assert(xcfl_ > 0); assert(ycfl_ > 0); } size_t simParams::calcBytes() const { int stencilWords = 0; assert(order_ == 2 || order_ == 4 || order_ == 8); if(order_ == 2) { stencilWords = 6; } else if(order_ == 4) { stencilWords = 10; } else if(order_ == 8) { stencilWords = 18; } return (size_t)iters_ * nx_ * ny_ * stencilWords * sizeof(float); }
[ "noreply@github.com" ]
yyy910805.noreply@github.com
c163b77ddc758f80373ae592dfdd1532e1285514
7acc4c004ab9865b9ddd2ffdbe1075bcecbf519a
/tetrixwindow.cpp
721065a7cab3089d780f398a3214b80aa4dafd10
[]
no_license
m17saitou/QTetris
8d84e4faaca4f7b4cfe4f700c51eacaf73457a65
ccc25f034ba455ff4682da3606b95924e161d93f
refs/heads/master
2020-08-31T01:07:57.230127
2019-11-02T00:44:09
2019-11-02T00:44:09
218,542,039
0
0
null
null
null
null
UTF-8
C++
false
false
5,384
cpp
/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** BSD License Usage ** Alternatively, you may use this file under the terms of the BSD license ** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "tetrixboard.h" #include "tetrixwindow.h" #include <QCoreApplication> #include <QGridLayout> #include <QLabel> #include <QLCDNumber> #include <QPushButton> //! [0] TetrixWindow::TetrixWindow(QWidget *parent) : QWidget(parent), board(new TetrixBoard) { //! [0] nextPieceLabel = new QLabel; nextPieceLabel->setFrameStyle(QFrame::Box | QFrame::Raised); nextPieceLabel->setAlignment(Qt::AlignCenter); board->setNextPieceLabel(nextPieceLabel); //! [1] scoreLcd = new QLCDNumber(5); scoreLcd->setSegmentStyle(QLCDNumber::Filled); //! [1] levelLcd = new QLCDNumber(2); levelLcd->setSegmentStyle(QLCDNumber::Filled); linesLcd = new QLCDNumber(5); linesLcd->setSegmentStyle(QLCDNumber::Filled); //! [2] startButton = new QPushButton(tr("&Start")); startButton->setFocusPolicy(Qt::NoFocus); quitButton = new QPushButton(tr("&Quit")); quitButton->setFocusPolicy(Qt::NoFocus); pauseButton = new QPushButton(tr("&Pause")); //! [2] //! [3] pauseButton->setFocusPolicy(Qt::NoFocus); //! [3] //! [4] connect(startButton, &QPushButton::clicked, board, &TetrixBoard::start); //! [4] //! [5] connect(quitButton , &QPushButton::clicked, qApp, &QCoreApplication::quit); connect(pauseButton, &QPushButton::clicked, board, &TetrixBoard::pause); #if __cplusplus >= 201402L connect(board, &TetrixBoard::scoreChanged, scoreLcd, qOverload<int>(&QLCDNumber::display)); connect(board, &TetrixBoard::levelChanged, levelLcd, qOverload<int>(&QLCDNumber::display)); connect(board, &TetrixBoard::linesRemovedChanged, linesLcd, qOverload<int>(&QLCDNumber::display)); #else connect(board, &TetrixBoard::scoreChanged, scoreLcd, QOverload<int>::of(&QLCDNumber::display)); connect(board, &TetrixBoard::levelChanged, levelLcd, QOverload<int>::of(&QLCDNumber::display)); connect(board, &TetrixBoard::linesRemovedChanged, linesLcd, QOverload<int>::of(&QLCDNumber::display)); #endif //! [5] //! [6] QGridLayout *layout = new QGridLayout; layout->addWidget(createLabel(tr("NEXT")), 0, 0); layout->addWidget(nextPieceLabel, 1, 0); layout->addWidget(createLabel(tr("LEVEL")), 2, 0); layout->addWidget(levelLcd, 3, 0); layout->addWidget(startButton, 4, 0); layout->addWidget(board, 0, 1, 6, 1); layout->addWidget(createLabel(tr("SCORE")), 0, 2); layout->addWidget(scoreLcd, 1, 2); layout->addWidget(createLabel(tr("LINES REMOVED")), 2, 2); layout->addWidget(linesLcd, 3, 2); layout->addWidget(quitButton, 4, 2); layout->addWidget(pauseButton, 5, 2); setLayout(layout); setWindowTitle(tr("QTetris")); resize(550, 370); } //! [6] //! [7] QLabel *TetrixWindow::createLabel(const QString &text) { QLabel *label = new QLabel(text); label->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); return label; } //! [7]
[ "m17saitou@gmail.com" ]
m17saitou@gmail.com
9b168f4fe8f8e6c11c94e10ea7224f7d98e6b974
b39c7014415ea7904e1786e381a2a724eb91cb6e
/Codesignal/The Core/Book Market/isUnstablePair.cpp
60c5d5e67d9dcab8aebf230085f11b5758ab1cff
[]
no_license
chidihn/Learn-cpp
e217d2a722d49226269b8fa727ca1e909714fc12
682d44edb14d75d700bd7ec50ee1b61d52ed67fe
refs/heads/master
2020-08-06T00:15:33.650474
2019-10-01T06:37:23
2019-10-01T06:37:23
212,767,703
3
0
null
2019-10-04T08:20:17
2019-10-04T08:20:17
null
UTF-8
C++
false
false
342
cpp
// Như return #include <iostream> using namespace std; bool isUnstablePair(string a, string b) { string c, d; for (char i : a) c += tolower(i); for (char i : b) d += tolower(i); return (a < b && c > d) || (a > b && c < d); } int main() { cout << boolalpha << isUnstablePair("aa", "AAB"); return 0; }
[ "trvathin@gmail.com" ]
trvathin@gmail.com
79cd3ca002ada3a3a9ffaf694479eed71249d196
827405b8f9a56632db9f78ea6709efb137738b9d
/CodingWebsites/LeetCode/CPP/Volume1/11.cpp
65bab5bc7aac7006c42ee04fca36729ba295dc7e
[]
no_license
MingzhenY/code-warehouse
2ae037a671f952201cf9ca13992e58718d11a704
d87f0baa6529f76e41a448b8056e1f7ca0ab3fe7
refs/heads/master
2020-03-17T14:59:30.425939
2019-02-10T17:12:36
2019-02-10T17:12:36
133,694,119
0
0
null
null
null
null
UTF-8
C++
false
false
2,955
cpp
#include <cstdlib> #include <cstdio> #include <iostream> #include <queue> #include <algorithm> #include <vector> #include <cstring> using namespace std; class Solution { private: int n; vector<int> ST; struct A{ int id,a; A(){} A(int id,int a):id(id),a(a){} bool operator < (const A & B)const{ return a < B.a; } }; vector<A> Rank; public: int maxArea(vector<int>& height) { n = height.size(); //Sort By Height Rank = vector<A>(n); for(int i = 0 ; i < n ; ++i) Rank[i] = A(i+1,height[i]); sort(Rank.begin(),Rank.end()); //for(int i = 0 ; i < n ; ++i){ // printf("Rank[%d] = (%d,%d)\n",i,Rank[i].id,Rank[i].a); //} //Solve By Segment Tree ST_Init(); ST_Build(1,n,1); //printf("Build Done\n"); int Max = 0; for(int i = 0 ; i < n ; ++i){ //printf("i=%d\n",i); //Record Answer int LeftMost = ST_QueryLeft(1,n,1); //printf("Left Done\n"); int RightMost = ST_QueryRight(1,n,1); //printf("id = %d (L,R) = (%d,%d)\n",Rank[i].id,LeftMost,RightMost); int CurMax = Rank[i].a * max(Rank[i].id - LeftMost,RightMost - Rank[i].id); //printf("CurMax = %d\n",CurMax); Max = max(Max,CurMax); //Delete Number ST_Update(Rank[i].id,1,n,1); } ST_Clear(); return Max; } void ST_Init(){ ST = vector<int>(n << 2); } void ST_Build(int l,int r,int rt){ if(l == r){ ST[rt] = 1; return; } int m = (l + r) >> 1; ST_Build(l,m,rt << 1); ST_Build(m + 1 , r , rt << 1 | 1); ST[rt] = ST[rt << 1] + ST[rt << 1 | 1]; } void ST_Update(int X,int l,int r,int rt){ if(l == r){ ST[rt] --; return; } int m = (l + r) >> 1; if(X <= m) ST_Update(X,l,m,rt << 1); else ST_Update(X,m + 1, r, rt << 1 | 1); ST[rt]--; } int ST_QueryLeft(int l,int r,int rt){ //query the position of the leftmost 1 if(l == r) return l; int m = (l + r) >> 1; if(ST[rt << 1] > 0) return ST_QueryLeft(l,m,rt << 1); else return ST_QueryLeft(m + 1, r, rt << 1 | 1); } int ST_QueryRight(int l,int r,int rt){ //query the position of the rightmost 1 if(l == r) return l; int m = (l + r) >> 1; if(ST[rt << 1 | 1] > 0) return ST_QueryRight(m + 1, r, rt << 1 | 1); else return ST_QueryRight(l, m, rt << 1); } void ST_Clear(){ ST.clear(); } void Test(){ vector<int> V; V.push_back(1); V.push_back(2); V.push_back(4); V.push_back(3); cout<<maxArea(V)<<endl; } }; int main(){ Solution S; S.Test(); return 0; }
[ "mingzhenyan@yahoo.com" ]
mingzhenyan@yahoo.com
694e370c5ac4b7fb9ea81c1c650ba561a066095d
2b4bd3b3a18759c1d25476bda3be3f8aee8ca371
/PAT/Advanced/1008.cpp
fb4bf740bf6430018f4512e6212a2964eaf86d48
[]
no_license
cusion/Algorithm
54318d208e1c8aaece9053b98d8641e279c63444
8c826399285aa3fee88031fe84a610a56c542147
refs/heads/master
2016-09-10T18:35:43.740494
2014-10-14T06:57:28
2014-10-14T06:57:28
16,759,961
1
0
null
null
null
null
UTF-8
C++
false
false
366
cpp
#include <cstdio> #include <iostream> using namespace std; int main() { int n; cin >> n; int req; int cur = 0; int time = 0; for (int i = 0; i < n; ++i) { scanf("%d", &req); if (req == cur) { time += 5; } else if (req < cur) { time += (cur-req)*4 + 5; } else { time += (req-cur)*6 + 5; } cur = req; } cout << time << endl; return 0; }
[ "kuixiong@gmail.com" ]
kuixiong@gmail.com
fc9cfb96b5077731a05df4c864ec915e9704957d
e5b48f9f4669f050d6fd699e7f4f4566c9c52402
/GroupEntry.cpp
14ebc5e8784cec3e5d936f9b78d67f9fca6790ee
[]
no_license
sayrun/SOboe
f3b3a6e6fb789098d9482651d903eacff5d4f931
787348ce2b6ffaa21219fc41e350750290bad2f7
refs/heads/master
2021-01-10T04:02:46.603279
2016-04-08T21:47:59
2016-04-08T21:47:59
50,247,995
0
0
null
null
null
null
UTF-8
C++
false
false
2,253
cpp
#include "stdafx.h" #include "SOboe.h" #include "GroupEntry.h" BOOL CGroupData::SetGroupData( const GROUPDATA* pstGroupData, int nSize) { if( NULL == pstGroupData)return FALSE; if( nSize < pstGroupData->nSize)return FALSE; if( _GROUPSTRUCT_VER100 < pstGroupData->unStructVersion)return FALSE; m_nParentGroup = pstGroupData->nParentGroup; m_nGroupStatus = pstGroupData->nGroupStatus; m_cStrGroupName = &( ( LPCSTR)pstGroupData)[ pstGroupData->nOffsetGroupName]; if( m_cStrGroupName.IsEmpty()) { m_nParentGroup = -1; return FALSE; } return TRUE; } BOOL CEntryData::SetEntryData( const ENTRYDATA* pstEntryData, int nSize) { if( NULL == pstEntryData)return FALSE; if( nSize < pstEntryData->nSize)return FALSE; if( _ENTRYSTRUCT_VER100 < pstEntryData->unStructVersion)return FALSE; if( m_pstEntryData) { free( m_pstEntryData); m_pstEntryData = NULL; m_nEntryDataSize = 0; } m_pstEntryData = ( ENTRYDATA*)malloc( nSize); if( m_pstEntryData) { m_nEntryDataSize = nSize; CopyMemory( m_pstEntryData, pstEntryData, nSize); return TRUE; } return FALSE; } BOOL CEntryData::operator==( const CEntryData& cEntryData) const { if( NULL == m_pstEntryData && NULL == cEntryData.m_pstEntryData)return TRUE; if( NULL == m_pstEntryData)return FALSE; if( NULL == cEntryData.m_pstEntryData)return FALSE; // if( m_pstEntryData->nSize != cEntryData.m_pstEntryData->nSize)return FALSE; if( GetNxlID() != cEntryData.GetNxlID())return FALSE; CSOboeApp* pcSOboe = ( CSOboeApp*)AfxGetApp(); ASSERT( pcSOboe); CNetExLib* pcNetExLib; pcNetExLib = pcSOboe->GetNetExLib( pcSOboe->FindNxlID( GetNxlID())); if( pcNetExLib) { return pcNetExLib->CompareEntryData( *this, cEntryData); } return FALSE; } const CEntryData& CEntryData::operator=( const CEntryData& cEntryData) { if( m_pstEntryData) { free( m_pstEntryData); m_pstEntryData = NULL; m_nEntryDataSize = 0; } if( NULL != cEntryData.m_pstEntryData) { if( 0 < cEntryData.m_nEntryDataSize) { m_pstEntryData = ( ENTRYDATA*)malloc( cEntryData.m_nEntryDataSize); if( m_pstEntryData) { m_nEntryDataSize = cEntryData.m_nEntryDataSize; CopyMemory( m_pstEntryData, cEntryData.m_pstEntryData, cEntryData.m_nEntryDataSize); } } } return *this; }
[ "sayrun@hotmail.co.jp" ]
sayrun@hotmail.co.jp
e521583358cd02e95c53306d6597579fc0363c12
90cef3c0759f9463da3d6bb79834ee7793678166
/opengesnative/src/main/jni/nativeDraw.cpp
028fe5cf41a6a2c93764ece0b9e20a64dd5d4487
[]
no_license
Linus-Smith/OpengGL-ES
86dccad34c823563b9215b4edd93a9cd6bdb9d0b
def9d5b7428d4db34e8249d5bc58fc455fc88ee1
refs/heads/master
2021-01-11T03:59:05.322698
2017-09-05T12:10:53
2017-09-05T12:10:53
71,265,255
0
0
null
null
null
null
UTF-8
C++
false
false
1,833
cpp
#include "nativeDraw.h" #include "common/esUtil.h" void onSurfaceCreated() { mProgram = esLoadProgram(vShader, fShader); shIndex.mvpMatrix = glGetUniformLocation(mProgram, "uMVPMatrix"); shIndex.position = glGetAttribLocation(mProgram, "aPosition"); shIndex.color = glGetAttribLocation(mProgram, "aColor"); mModeMatrix = (ESMatrix *) malloc(sizeof(ESMatrix)); mPMatrox = (ESMatrix *) malloc(sizeof(ESMatrix)); esMatrixLoadIdentity(mModeMatrix); esMatrixLoadIdentity(mPMatrox); bufferId = (GLuint *) malloc(BUFFER_COUNT); vaoId = (GLuint *)malloc(VAO_COUNT); glGenBuffers(BUFFER_COUNT, bufferId); glBindBuffer(GL_ARRAY_BUFFER, bufferId[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(shaderData), shaderData, GL_STATIC_DRAW); } void onSurfaceChanged(JNIEnv env, jobject obj, int width, int height) { LOGD("onSurfaceChanged %d %d", width, height); glViewport(0, 0, width, height); glGenVertexArrays(VAO_COUNT, vaoId); GLfloat rea = width / height; esOrtho(mPMatrox, -rea, rea, -1, 1, 1, 10); ESMatrix * mvpMatrix = (ESMatrix *) malloc(sizeof(ESMatrix)); esMatrixLoadIdentity(mvpMatrix); esMatrixMultiply(mvpMatrix, mModeMatrix, mPMatrox); glUniform4fv(shIndex.mvpMatrix, 1, ( GLfloat * ) &mvpMatrix->m[0][0]); glBindVertexArray(vaoId[0]); glBindBuffer(GL_ARRAY_BUFFER, bufferId[0]); glEnableVertexAttribArray(shIndex.position); glVertexAttribPointer(shIndex.position, 3, GL_FLOAT, GL_FALSE, sizeof(shaderData[0]), 0); glVertexAttrib4f(shIndex.color, 1.0f, 0.4f, 0.6f, 0.4f); glBindVertexArray(0); } void onDrawFrame() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(mProgram); glBindVertexArray(vaoId[0]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindVertexArray(0); }
[ "chyangbast@yeah.net" ]
chyangbast@yeah.net
d64caeb017e88dc89ce02f04189ed456dc358910
941576c946628eeda4424c450396598908be2094
/ChakraDemoApp/Chakra.h
69c81f725d2ddec5910ce28b087b4f0a62dda7fe
[]
no_license
mslavchev/chakra-wp81
6f4b8e6a7dc7536a87dce31d65d3822b331bd06d
951de7277183c88e593544849e32e013537483ad
refs/heads/master
2016-08-07T19:48:53.691951
2014-09-10T13:26:14
2014-09-10T13:26:14
23,870,194
0
0
null
null
null
null
UTF-8
C++
false
false
223
h
#include "jsrt.h" namespace ChakraDemoApp { class Chakra { public: Chakra(); Platform::String^ GetGreeting(); ~Chakra(); private: JsRuntimeHandle m_runtime; JsContextRef m_context; }; }
[ "meslav@hotmail.com" ]
meslav@hotmail.com
cf76cbcac9d51ccce976f98a8cef5e4de243234c
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/CMake/CMake-old-new/CMake-old-new-joern/Kitware_CMake_old_new_old_function_1439.cpp
f1d4b8115fc2b3b92633bac69f823f486335d936
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,146
cpp
int cmCTest::CoverageDirectory() { std::cout << "Performing coverage" << std::endl; std::vector<std::string> files; std::vector<std::string> cfiles; std::vector<std::string> cdirs; bool done = false; std::string::size_type cc; std::string glob; std::map<std::string, std::string> allsourcefiles; std::map<std::string, std::string> allbinaryfiles; std::string start_time = ::CurrentTime(); // Find all source files. std::string sourceDirectory = m_DartConfiguration["SourceDirectory"]; if ( sourceDirectory.size() == 0 ) { std::cerr << "Cannot find SourceDirectory key in the DartConfiguration.tcl" << std::endl; return 1; } cdirs.push_back(sourceDirectory); while ( !done ) { if ( cdirs.size() <= 0 ) { break; } glob = cdirs[cdirs.size()-1] + "/*"; //std::cout << "Glob: " << glob << std::endl; cdirs.pop_back(); if ( cmSystemTools::SimpleGlob(glob, cfiles, 1) ) { for ( cc = 0; cc < cfiles.size(); cc ++ ) { allsourcefiles[cmSystemTools::GetFilenameName(cfiles[cc])] = cfiles[cc]; } } if ( cmSystemTools::SimpleGlob(glob, cfiles, -1) ) { for ( cc = 0; cc < cfiles.size(); cc ++ ) { if ( cfiles[cc] != "." && cfiles[cc] != ".." ) { cdirs.push_back(cfiles[cc]); } } } } // find all binary files cdirs.push_back(cmSystemTools::GetCurrentWorkingDirectory()); while ( !done ) { if ( cdirs.size() <= 0 ) { break; } glob = cdirs[cdirs.size()-1] + "/*"; //std::cout << "Glob: " << glob << std::endl; cdirs.pop_back(); if ( cmSystemTools::SimpleGlob(glob, cfiles, 1) ) { for ( cc = 0; cc < cfiles.size(); cc ++ ) { allbinaryfiles[cmSystemTools::GetFilenameName(cfiles[cc])] = cfiles[cc]; } } if ( cmSystemTools::SimpleGlob(glob, cfiles, -1) ) { for ( cc = 0; cc < cfiles.size(); cc ++ ) { if ( cfiles[cc] != "." && cfiles[cc] != ".." ) { cdirs.push_back(cfiles[cc]); } } } } std::map<std::string, std::string>::iterator sit; for ( sit = allbinaryfiles.begin(); sit != allbinaryfiles.end(); sit ++ ) { const std::string& fname = sit->second; //std::cout << "File: " << fname << std::endl; if ( strcmp(fname.substr(fname.size()-3, 3).c_str(), ".da") == 0 ) { files.push_back(fname); } } if ( files.size() == 0 ) { std::cout << "Cannot find any coverage information files (.da)" << std::endl; return 1; } std::ofstream log; if (!this->OpenOutputFile("Temporary", "Coverage.log", log)) { std::cout << "Cannot open log file" << std::endl; return 1; } log.close(); if (!this->OpenOutputFile(m_CurrentTag, "Coverage.xml", log)) { std::cout << "Cannot open log file" << std::endl; return 1; } std::string opath = m_ToplevelPath + "/Testing/Temporary/Coverage"; cmSystemTools::MakeDirectory(opath.c_str()); for ( cc = 0; cc < files.size(); cc ++ ) { std::string command = "gcov -l \"" + files[cc] + "\""; std::string output; int retVal = 0; //std::cout << "Run gcov on " << files[cc] << std::flush; //std::cout << " --- Run [" << command << "]" << std::endl; bool res = true; if ( !m_ShowOnly ) { res = cmSystemTools::RunCommand(command.c_str(), output, retVal, opath.c_str(), m_Verbose); } if ( res && retVal == 0 ) { //std::cout << " - done" << std::endl; } else { //std::cout << " - fail" << std::endl; } } files.clear(); glob = opath + "/*"; if ( !cmSystemTools::SimpleGlob(glob, cfiles, 1) ) { std::cout << "Cannot found any coverage files" << std::endl; return 1; } std::map<std::string, std::vector<std::string> > sourcefiles; for ( cc = 0; cc < cfiles.size(); cc ++ ) { std::string& fname = cfiles[cc]; //std::cout << "File: " << fname << std::endl; if ( strcmp(fname.substr(fname.size()-5, 5).c_str(), ".gcov") == 0 ) { files.push_back(fname); std::string::size_type pos = fname.find(".da."); if ( pos != fname.npos ) { pos += 4; std::string::size_type epos = fname.size() - pos - strlen(".gcov"); std::string nf = fname.substr(pos, epos); //std::cout << "Substring: " << nf << std::endl; if ( allsourcefiles.find(nf) != allsourcefiles.end() || allbinaryfiles.find(nf) != allbinaryfiles.end() ) { std::vector<std::string> &cvec = sourcefiles[nf]; cvec.push_back(fname); } } } } for ( cc = 0; cc < files.size(); cc ++ ) { //std::cout << "File: " << files[cc] << std::endl; } std::map<std::string, std::vector<std::string> >::iterator it; cmCTest::tm_CoverageMap coverageresults; log << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" << "<Site BuildName=\"" << m_DartConfiguration["BuildName"] << "\" BuildStamp=\"" << m_CurrentTag << "-" << this->GetTestModelString() << "\" Name=\"" << m_DartConfiguration["Site"] << "\">\n" << "<Coverage>\n" << "\t<StartDateTime>" << start_time << "</StartDateTime>" << std::endl; int total_tested = 0; int total_untested = 0; for ( it = sourcefiles.begin(); it != sourcefiles.end(); it ++ ) { //std::cerr << "Source file: " << it->first << std::endl; std::vector<std::string> &gfiles = it->second; for ( cc = 0; cc < gfiles.size(); cc ++ ) { //std::cout << "\t" << gfiles[cc] << std::endl; std::ifstream ifile(gfiles[cc].c_str()); if ( !ifile ) { std::cout << "Cannot open file: " << gfiles[cc].c_str() << std::endl; } ifile.seekg (0, std::ios::end); int length = ifile.tellg(); ifile.seekg (0, std::ios::beg); char *buffer = new char [ length + 1 ]; ifile.read(buffer, length); buffer [length] = 0; //std::cout << "Read: " << buffer << std::endl; std::vector<cmStdString> lines; cmSystemTools::Split(buffer, lines); delete [] buffer; cmCTest::cmCTestCoverage& cov = coverageresults[it->first]; std::vector<int>& covlines = cov.m_Lines; if ( cov.m_FullPath == "" ) { covlines.insert(covlines.begin(), lines.size(), -1); if ( allsourcefiles.find(it->first) != allsourcefiles.end() ) { cov.m_FullPath = allsourcefiles[it->first]; } else if ( allbinaryfiles.find(it->first) != allbinaryfiles.end() ) { cov.m_FullPath = allbinaryfiles[it->first]; } cov.m_AbsolutePath = cov.m_FullPath; std::string src_dir = m_DartConfiguration["SourceDirectory"]; if ( src_dir[src_dir.size()-1] != '/' ) { src_dir = src_dir + "/"; } std::string::size_type spos = cov.m_FullPath.find(src_dir); if ( spos == 0 ) { cov.m_FullPath = std::string("./") + cov.m_FullPath.substr(src_dir.size()); } else { //std::cerr << "Compare -- " << cov.m_FullPath << std::endl; //std::cerr << " -- " << src_dir << std::endl; continue; } } for ( cc = 0; cc < lines.size(); cc ++ ) { std::string& line = lines[cc]; std::string sub = line.substr(0, strlen(" ######")); int count = atoi(sub.c_str()); if ( sub.compare(" ######") == 0 ) { if ( covlines[cc] == -1 ) { covlines[cc] = 0; } cov.m_UnTested ++; //std::cout << "Untested - "; } else if ( count > 0 ) { if ( covlines[cc] == -1 ) { covlines[cc] = 0; } cov.m_Tested ++; covlines[cc] += count; //std::cout << "Tested[" << count << "] - "; } //std::cout << line << std::endl; } } } //std::cerr << "Finalizing" << std::endl; cmCTest::tm_CoverageMap::iterator cit; int ccount = 0; std::ofstream cfileoutput; int cfileoutputcount = 0; char cfileoutputname[100]; std::string local_start_time = ::CurrentTime(); std::string local_end_time; for ( cit = coverageresults.begin(); cit != coverageresults.end(); cit ++ ) { if ( ccount == 100 ) { local_end_time = ::CurrentTime(); cfileoutput << "\t<EndDateTime>" << local_end_time << "</EndDateTime>\n" << "</CoverageLog>\n" << "</Site>" << std::endl; cfileoutput.close(); std::cout << "Close file: " << cfileoutputname << std::endl; ccount = 0; } if ( ccount == 0 ) { sprintf(cfileoutputname, "CoverageLog-%d.xml", cfileoutputcount++); std::cout << "Open file: " << cfileoutputname << std::endl; if (!this->OpenOutputFile(m_CurrentTag, cfileoutputname, cfileoutput)) { std::cout << "Cannot open log file: " << cfileoutputname << std::endl; return 1; } local_start_time = ::CurrentTime(); cfileoutput << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" << "<Site BuildName=\"" << m_DartConfiguration["BuildName"] << "\" BuildStamp=\"" << m_CurrentTag << "-" << this->GetTestModelString() << "\" Site=\"" << m_DartConfiguration["Site"] << "\">\n" << "<CoverageLog>\n" << "\t<StartDateTime>" << local_start_time << "</StartDateTime>" << std::endl; } //std::cerr << "Final process of Source file: " << cit->first << std::endl; cmCTest::cmCTestCoverage &cov = cit->second; std::ifstream ifile(cov.m_AbsolutePath.c_str()); if ( !ifile ) { std::cerr << "Cannot open file: " << cov.m_FullPath.c_str() << std::endl; } ifile.seekg (0, std::ios::end); int length = ifile.tellg(); ifile.seekg (0, std::ios::beg); char *buffer = new char [ length + 1 ]; ifile.read(buffer, length); buffer [length] = 0; //std::cout << "Read: " << buffer << std::endl; std::vector<cmStdString> lines; cmSystemTools::Split(buffer, lines); delete [] buffer; cfileoutput << "\t<File Name=\"" << cit->first << "\" FullPath=\"" << cov.m_FullPath << std::endl << "\">\n" << "\t\t<Report>" << std::endl; for ( cc = 0; cc < lines.size(); cc ++ ) { cfileoutput << "\t\t<Line Number=\"" << static_cast<int>(cc) << "\" Count=\"" << cov.m_Lines[cc] << "\">" << cmCTest::MakeXMLSafe(lines[cc]) << "</Line>" << std::endl; } cfileoutput << "\t\t</Report>\n" << "\t</File>" << std::endl; total_tested += cov.m_Tested; total_untested += cov.m_UnTested; float cper = 0; float cmet = 0; if ( total_tested + total_untested > 0 ) { cper = (100 * static_cast<float>(cov.m_Tested)/ static_cast<float>(cov.m_Tested + cov.m_UnTested)); cmet = ( static_cast<float>(cov.m_Tested + 10) / static_cast<float>(cov.m_Tested + cov.m_UnTested + 10)); } char cmbuff[100]; char cpbuff[100]; sprintf(cmbuff, "%.2f", cmet); sprintf(cpbuff, "%.2f", cper); log << "\t<File Name=\"" << cit->first << "\" FullPath=\"" << cov.m_FullPath << "\" Covered=\"" << (cmet>0?"true":"false") << "\">\n" << "\t\t<LOCTested>" << cov.m_Tested << "</LOCTested>\n" << "\t\t<LOCUnTested>" << cov.m_UnTested << "</LOCUnTested>\n" << "\t\t<PercentCoverage>" << cpbuff << "</PercentCoverage>\n" << "\t\t<CoverageMetric>" << cmbuff << "</CoverageMetric>\n" << "\t</File>" << std::endl; ccount ++; } if ( ccount > 0 ) { local_end_time = ::CurrentTime(); cfileoutput << "\t<EndDateTime>" << local_end_time << "</EndDateTime>\n" << "</CoverageLog>\n" << "</Site>" << std::endl; cfileoutput.close(); } int total_lines = total_tested + total_untested; float percent_coverage = 100 * static_cast<float>(total_tested) / static_cast<float>(total_lines); if ( total_lines == 0 ) { percent_coverage = 0; } std::string end_time = ::CurrentTime(); char buffer[100]; sprintf(buffer, "%.2f", percent_coverage); log << "\t<LOCTested>" << total_tested << "</LOCTested>\n" << "\t<LOCUntested>" << total_untested << "</LOCUntested>\n" << "\t<LOC>" << total_lines << "</LOC>\n" << "\t<PercentCoverage>" << buffer << "</PercentCoverage>\n" << "\t<EndDateTime>" << end_time << "</EndDateTime>\n" << "</Coverage>\n" << "</Site>" << std::endl; std::cout << "\tCovered LOC: " << total_tested << std::endl << "\tNot covered LOC: " << total_untested << std::endl << "\tTotal LOC: " << total_lines << std::endl << "\tPercentage Coverage: " << percent_coverage << "%" << std::endl; return 1; }
[ "993273596@qq.com" ]
993273596@qq.com
574c65bb4faab48d825cce120665c99823c7f7b4
ac1c9fbc1f1019efb19d0a8f3a088e8889f1e83c
/out/release/gen/v8/torque-generated/src/objects/feedback-cell-tq-csa.cc
20681e8daf91dbea734a1cfd6aac204d90f41885
[ "BSD-3-Clause" ]
permissive
xueqiya/chromium_src
5d20b4d3a2a0251c063a7fb9952195cda6d29e34
d4aa7a8f0e07cfaa448fcad8c12b29242a615103
refs/heads/main
2022-07-30T03:15:14.818330
2021-01-16T16:47:22
2021-01-16T16:47:22
330,115,551
1
0
null
null
null
null
UTF-8
C++
false
false
15,607
cc
#include "src/builtins/builtins-array-gen.h" #include "src/builtins/builtins-bigint-gen.h" #include "src/builtins/builtins-collections-gen.h" #include "src/builtins/builtins-constructor-gen.h" #include "src/builtins/builtins-data-view-gen.h" #include "src/builtins/builtins-iterator-gen.h" #include "src/builtins/builtins-promise-gen.h" #include "src/builtins/builtins-promise.h" #include "src/builtins/builtins-proxy-gen.h" #include "src/builtins/builtins-regexp-gen.h" #include "src/builtins/builtins-string-gen.h" #include "src/builtins/builtins-typed-array-gen.h" #include "src/builtins/builtins-utils-gen.h" #include "src/builtins/builtins.h" #include "src/codegen/code-factory.h" #include "src/heap/factory-inl.h" #include "src/objects/arguments.h" #include "src/objects/bigint.h" #include "src/objects/elements-kind.h" #include "src/objects/free-space.h" #include "src/objects/js-break-iterator.h" #include "src/objects/js-collator.h" #include "src/objects/js-date-time-format.h" #include "src/objects/js-display-names.h" #include "src/objects/js-generator.h" #include "src/objects/js-list-format.h" #include "src/objects/js-locale.h" #include "src/objects/js-number-format.h" #include "src/objects/js-objects.h" #include "src/objects/js-plural-rules.h" #include "src/objects/js-promise.h" #include "src/objects/js-regexp-string-iterator.h" #include "src/objects/js-relative-time-format.h" #include "src/objects/js-segment-iterator.h" #include "src/objects/js-segmenter.h" #include "src/objects/js-weak-refs.h" #include "src/objects/objects.h" #include "src/objects/ordered-hash-table.h" #include "src/objects/property-array.h" #include "src/objects/property-descriptor-object.h" #include "src/objects/source-text-module.h" #include "src/objects/stack-frame-info.h" #include "src/objects/synthetic-module.h" #include "src/objects/template-objects.h" #include "src/torque/runtime-support.h" #include "torque-generated/src/builtins/array-copywithin-tq-csa.h" #include "torque-generated/src/builtins/array-every-tq-csa.h" #include "torque-generated/src/builtins/array-filter-tq-csa.h" #include "torque-generated/src/builtins/array-find-tq-csa.h" #include "torque-generated/src/builtins/array-findindex-tq-csa.h" #include "torque-generated/src/builtins/array-foreach-tq-csa.h" #include "torque-generated/src/builtins/array-from-tq-csa.h" #include "torque-generated/src/builtins/array-isarray-tq-csa.h" #include "torque-generated/src/builtins/array-join-tq-csa.h" #include "torque-generated/src/builtins/array-lastindexof-tq-csa.h" #include "torque-generated/src/builtins/array-map-tq-csa.h" #include "torque-generated/src/builtins/array-of-tq-csa.h" #include "torque-generated/src/builtins/array-reduce-right-tq-csa.h" #include "torque-generated/src/builtins/array-reduce-tq-csa.h" #include "torque-generated/src/builtins/array-reverse-tq-csa.h" #include "torque-generated/src/builtins/array-shift-tq-csa.h" #include "torque-generated/src/builtins/array-slice-tq-csa.h" #include "torque-generated/src/builtins/array-some-tq-csa.h" #include "torque-generated/src/builtins/array-splice-tq-csa.h" #include "torque-generated/src/builtins/array-unshift-tq-csa.h" #include "torque-generated/src/builtins/array-tq-csa.h" #include "torque-generated/src/builtins/base-tq-csa.h" #include "torque-generated/src/builtins/bigint-tq-csa.h" #include "torque-generated/src/builtins/boolean-tq-csa.h" #include "torque-generated/src/builtins/builtins-string-tq-csa.h" #include "torque-generated/src/builtins/collections-tq-csa.h" #include "torque-generated/src/builtins/cast-tq-csa.h" #include "torque-generated/src/builtins/convert-tq-csa.h" #include "torque-generated/src/builtins/console-tq-csa.h" #include "torque-generated/src/builtins/data-view-tq-csa.h" #include "torque-generated/src/builtins/frames-tq-csa.h" #include "torque-generated/src/builtins/frame-arguments-tq-csa.h" #include "torque-generated/src/builtins/growable-fixed-array-tq-csa.h" #include "torque-generated/src/builtins/internal-coverage-tq-csa.h" #include "torque-generated/src/builtins/iterator-tq-csa.h" #include "torque-generated/src/builtins/math-tq-csa.h" #include "torque-generated/src/builtins/number-tq-csa.h" #include "torque-generated/src/builtins/object-fromentries-tq-csa.h" #include "torque-generated/src/builtins/object-tq-csa.h" #include "torque-generated/src/builtins/promise-abstract-operations-tq-csa.h" #include "torque-generated/src/builtins/promise-all-tq-csa.h" #include "torque-generated/src/builtins/promise-all-element-closure-tq-csa.h" #include "torque-generated/src/builtins/promise-constructor-tq-csa.h" #include "torque-generated/src/builtins/promise-finally-tq-csa.h" #include "torque-generated/src/builtins/promise-misc-tq-csa.h" #include "torque-generated/src/builtins/promise-race-tq-csa.h" #include "torque-generated/src/builtins/promise-reaction-job-tq-csa.h" #include "torque-generated/src/builtins/promise-resolve-tq-csa.h" #include "torque-generated/src/builtins/promise-then-tq-csa.h" #include "torque-generated/src/builtins/promise-jobs-tq-csa.h" #include "torque-generated/src/builtins/proxy-constructor-tq-csa.h" #include "torque-generated/src/builtins/proxy-delete-property-tq-csa.h" #include "torque-generated/src/builtins/proxy-get-property-tq-csa.h" #include "torque-generated/src/builtins/proxy-get-prototype-of-tq-csa.h" #include "torque-generated/src/builtins/proxy-has-property-tq-csa.h" #include "torque-generated/src/builtins/proxy-is-extensible-tq-csa.h" #include "torque-generated/src/builtins/proxy-prevent-extensions-tq-csa.h" #include "torque-generated/src/builtins/proxy-revocable-tq-csa.h" #include "torque-generated/src/builtins/proxy-revoke-tq-csa.h" #include "torque-generated/src/builtins/proxy-set-property-tq-csa.h" #include "torque-generated/src/builtins/proxy-set-prototype-of-tq-csa.h" #include "torque-generated/src/builtins/proxy-tq-csa.h" #include "torque-generated/src/builtins/reflect-tq-csa.h" #include "torque-generated/src/builtins/regexp-exec-tq-csa.h" #include "torque-generated/src/builtins/regexp-match-all-tq-csa.h" #include "torque-generated/src/builtins/regexp-match-tq-csa.h" #include "torque-generated/src/builtins/regexp-replace-tq-csa.h" #include "torque-generated/src/builtins/regexp-search-tq-csa.h" #include "torque-generated/src/builtins/regexp-source-tq-csa.h" #include "torque-generated/src/builtins/regexp-split-tq-csa.h" #include "torque-generated/src/builtins/regexp-test-tq-csa.h" #include "torque-generated/src/builtins/regexp-tq-csa.h" #include "torque-generated/src/builtins/string-endswith-tq-csa.h" #include "torque-generated/src/builtins/string-html-tq-csa.h" #include "torque-generated/src/builtins/string-iterator-tq-csa.h" #include "torque-generated/src/builtins/string-pad-tq-csa.h" #include "torque-generated/src/builtins/string-repeat-tq-csa.h" #include "torque-generated/src/builtins/string-replaceall-tq-csa.h" #include "torque-generated/src/builtins/string-slice-tq-csa.h" #include "torque-generated/src/builtins/string-startswith-tq-csa.h" #include "torque-generated/src/builtins/string-substring-tq-csa.h" #include "torque-generated/src/builtins/string-substr-tq-csa.h" #include "torque-generated/src/builtins/symbol-tq-csa.h" #include "torque-generated/src/builtins/torque-internal-tq-csa.h" #include "torque-generated/src/builtins/typed-array-createtypedarray-tq-csa.h" #include "torque-generated/src/builtins/typed-array-every-tq-csa.h" #include "torque-generated/src/builtins/typed-array-filter-tq-csa.h" #include "torque-generated/src/builtins/typed-array-find-tq-csa.h" #include "torque-generated/src/builtins/typed-array-findindex-tq-csa.h" #include "torque-generated/src/builtins/typed-array-foreach-tq-csa.h" #include "torque-generated/src/builtins/typed-array-from-tq-csa.h" #include "torque-generated/src/builtins/typed-array-of-tq-csa.h" #include "torque-generated/src/builtins/typed-array-reduce-tq-csa.h" #include "torque-generated/src/builtins/typed-array-reduceright-tq-csa.h" #include "torque-generated/src/builtins/typed-array-set-tq-csa.h" #include "torque-generated/src/builtins/typed-array-slice-tq-csa.h" #include "torque-generated/src/builtins/typed-array-some-tq-csa.h" #include "torque-generated/src/builtins/typed-array-sort-tq-csa.h" #include "torque-generated/src/builtins/typed-array-subarray-tq-csa.h" #include "torque-generated/src/builtins/typed-array-tq-csa.h" #include "torque-generated/src/ic/handler-configuration-tq-csa.h" #include "torque-generated/src/objects/allocation-site-tq-csa.h" #include "torque-generated/src/objects/api-callbacks-tq-csa.h" #include "torque-generated/src/objects/arguments-tq-csa.h" #include "torque-generated/src/objects/cell-tq-csa.h" #include "torque-generated/src/objects/code-tq-csa.h" #include "torque-generated/src/objects/contexts-tq-csa.h" #include "torque-generated/src/objects/data-handler-tq-csa.h" #include "torque-generated/src/objects/debug-objects-tq-csa.h" #include "torque-generated/src/objects/descriptor-array-tq-csa.h" #include "torque-generated/src/objects/embedder-data-array-tq-csa.h" #include "torque-generated/src/objects/feedback-cell-tq-csa.h" #include "torque-generated/src/objects/feedback-vector-tq-csa.h" #include "torque-generated/src/objects/fixed-array-tq-csa.h" #include "torque-generated/src/objects/foreign-tq-csa.h" #include "torque-generated/src/objects/free-space-tq-csa.h" #include "torque-generated/src/objects/heap-number-tq-csa.h" #include "torque-generated/src/objects/heap-object-tq-csa.h" #include "torque-generated/src/objects/intl-objects-tq-csa.h" #include "torque-generated/src/objects/js-array-buffer-tq-csa.h" #include "torque-generated/src/objects/js-array-tq-csa.h" #include "torque-generated/src/objects/js-collection-iterator-tq-csa.h" #include "torque-generated/src/objects/js-collection-tq-csa.h" #include "torque-generated/src/objects/js-generator-tq-csa.h" #include "torque-generated/src/objects/js-objects-tq-csa.h" #include "torque-generated/src/objects/js-promise-tq-csa.h" #include "torque-generated/src/objects/js-proxy-tq-csa.h" #include "torque-generated/src/objects/js-regexp-string-iterator-tq-csa.h" #include "torque-generated/src/objects/js-regexp-tq-csa.h" #include "torque-generated/src/objects/js-weak-refs-tq-csa.h" #include "torque-generated/src/objects/literal-objects-tq-csa.h" #include "torque-generated/src/objects/map-tq-csa.h" #include "torque-generated/src/objects/microtask-tq-csa.h" #include "torque-generated/src/objects/module-tq-csa.h" #include "torque-generated/src/objects/name-tq-csa.h" #include "torque-generated/src/objects/oddball-tq-csa.h" #include "torque-generated/src/objects/ordered-hash-table-tq-csa.h" #include "torque-generated/src/objects/primitive-heap-object-tq-csa.h" #include "torque-generated/src/objects/promise-tq-csa.h" #include "torque-generated/src/objects/property-array-tq-csa.h" #include "torque-generated/src/objects/property-cell-tq-csa.h" #include "torque-generated/src/objects/property-descriptor-object-tq-csa.h" #include "torque-generated/src/objects/prototype-info-tq-csa.h" #include "torque-generated/src/objects/regexp-match-info-tq-csa.h" #include "torque-generated/src/objects/scope-info-tq-csa.h" #include "torque-generated/src/objects/script-tq-csa.h" #include "torque-generated/src/objects/shared-function-info-tq-csa.h" #include "torque-generated/src/objects/source-text-module-tq-csa.h" #include "torque-generated/src/objects/stack-frame-info-tq-csa.h" #include "torque-generated/src/objects/string-tq-csa.h" #include "torque-generated/src/objects/struct-tq-csa.h" #include "torque-generated/src/objects/synthetic-module-tq-csa.h" #include "torque-generated/src/objects/template-objects-tq-csa.h" #include "torque-generated/src/objects/template-tq-csa.h" #include "torque-generated/src/wasm/wasm-objects-tq-csa.h" #include "torque-generated/test/torque/test-torque-tq-csa.h" #include "torque-generated/third_party/v8/builtins/array-sort-tq-csa.h" namespace v8 { namespace internal { TNode<HeapObject> LoadFeedbackCellValue_0(compiler::CodeAssemblerState* state_, TNode<FeedbackCell> p_o) { compiler::CodeAssembler ca_(state_); compiler::CodeAssemblerParameterizedLabel<FeedbackCell> block0(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<FeedbackCell, HeapObject> block2(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); ca_.Goto(&block0, p_o); if (block0.is_used()) { TNode<FeedbackCell> tmp0; ca_.Bind(&block0, &tmp0); TNode<IntPtrT> tmp1; USE(tmp1); tmp1 = FromConstexpr_intptr_constexpr_int31_0(state_, 4); TNode<HeapObject>tmp2 = CodeStubAssembler(state_).LoadReference<HeapObject>(CodeStubAssembler::Reference{tmp0, tmp1}); ca_.Goto(&block2, tmp0, tmp2); } TNode<FeedbackCell> tmp3; TNode<HeapObject> tmp4; ca_.Bind(&block2, &tmp3, &tmp4); return TNode<HeapObject>{tmp4}; } void StoreFeedbackCellValue_0(compiler::CodeAssemblerState* state_, TNode<FeedbackCell> p_o, TNode<HeapObject> p_v) { compiler::CodeAssembler ca_(state_); compiler::CodeAssemblerParameterizedLabel<FeedbackCell, HeapObject> block0(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<FeedbackCell, HeapObject> block2(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); ca_.Goto(&block0, p_o, p_v); if (block0.is_used()) { TNode<FeedbackCell> tmp0; TNode<HeapObject> tmp1; ca_.Bind(&block0, &tmp0, &tmp1); TNode<IntPtrT> tmp2; USE(tmp2); tmp2 = FromConstexpr_intptr_constexpr_int31_0(state_, 4); CodeStubAssembler(state_).StoreReference<HeapObject>(CodeStubAssembler::Reference{tmp0, tmp2}, tmp1); ca_.Goto(&block2, tmp0, tmp1); } TNode<FeedbackCell> tmp3; TNode<HeapObject> tmp4; ca_.Bind(&block2, &tmp3, &tmp4); } TNode<Int32T> LoadFeedbackCellInterruptBudget_0(compiler::CodeAssemblerState* state_, TNode<FeedbackCell> p_o) { compiler::CodeAssembler ca_(state_); compiler::CodeAssemblerParameterizedLabel<FeedbackCell> block0(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<FeedbackCell, Int32T> block2(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); ca_.Goto(&block0, p_o); if (block0.is_used()) { TNode<FeedbackCell> tmp0; ca_.Bind(&block0, &tmp0); TNode<IntPtrT> tmp1; USE(tmp1); tmp1 = FromConstexpr_intptr_constexpr_int31_0(state_, 8); TNode<Int32T>tmp2 = CodeStubAssembler(state_).LoadReference<Int32T>(CodeStubAssembler::Reference{tmp0, tmp1}); ca_.Goto(&block2, tmp0, tmp2); } TNode<FeedbackCell> tmp3; TNode<Int32T> tmp4; ca_.Bind(&block2, &tmp3, &tmp4); return TNode<Int32T>{tmp4}; } void StoreFeedbackCellInterruptBudget_0(compiler::CodeAssemblerState* state_, TNode<FeedbackCell> p_o, TNode<Int32T> p_v) { compiler::CodeAssembler ca_(state_); compiler::CodeAssemblerParameterizedLabel<FeedbackCell, Int32T> block0(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<FeedbackCell, Int32T> block2(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); ca_.Goto(&block0, p_o, p_v); if (block0.is_used()) { TNode<FeedbackCell> tmp0; TNode<Int32T> tmp1; ca_.Bind(&block0, &tmp0, &tmp1); TNode<IntPtrT> tmp2; USE(tmp2); tmp2 = FromConstexpr_intptr_constexpr_int31_0(state_, 8); CodeStubAssembler(state_).StoreReference<Int32T>(CodeStubAssembler::Reference{tmp0, tmp2}, tmp1); ca_.Goto(&block2, tmp0, tmp1); } TNode<FeedbackCell> tmp3; TNode<Int32T> tmp4; ca_.Bind(&block2, &tmp3, &tmp4); } } // namespace internal } // namespace v8
[ "xueqi@zjmedia.net" ]
xueqi@zjmedia.net
4d90c4a8dac2d0b07f1a223cccae144c9f7b269d
a090af918e3ec59140027dbddd54aa4ca1c73910
/codechef/oct_maandi.cpp
80351d171d5d8906dab9a9287ccca4ea91ecbd75
[]
no_license
nitesh-147/Programming-Problem-Solution
b739e2a3c9cfeb2141baf1d34e43eac0435ecb2a
df7d53e0863954ddf358539d23266b28d5504212
refs/heads/master
2023-03-16T00:37:10.236317
2019-11-28T18:11:33
2019-11-28T18:11:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,817
cpp
#include <cstring> #include <cassert> #include <vector> #include <list> #include <queue> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <fstream> #include <climits> /**********TYPE CASTING**********/ #define LL long long #define L long #define D double #define LD long double #define S string #define I int #define ULL unsigned long long #define q queue<int> #define vi vector<int> #define vl vector<long> /**********INPUT**********/ #define si(a) scanf("%d",&a) #define sl(a) scanf("%ld",&a) #define s1(a) scanf("%d",&a) #define s2(a,b) scanf("%d%d",&a,&b) #define s3(a,b,c) scanf("%d%d%d",&a,&b,&c) #define sll(a) scanf("%lld",&a) #define sd(a) scanf("%lf",&a) #define ss(a) scanf("%s",&a) #define gc() getchar() /**********OUTPUT**********/ #define p1(a) printf("%d\n",a) #define p2(a,b) printf("%d %d\n",a,b) #define pll(a) printf("%lld\n",a) #define pd(a) printf("%.10lf\n",a) #define pcs(a,n) printf("Case %d: %d\n",a,n) #define nl() printf("\n") /**********LOOP**********/ #define REV(i,e,s) for(i=e;i>=s;i--) #define FOR(i,a,b) for(i=a;i<b;i++) #define loop(n) for(int o=1;o<=n;o++) /********** min/max *******/ #define max(a,b) a>b?a:b #define min(a,b) a<b?a:b #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) mix(a,max(b,c)) #define max4(a,b,c,d) max(max(a,b),max(c,d)) #define min4(a,b,c,d) min(min(a,b),min(c,d)) /**********SHORTCUT**********/ #define len(a) a.length() #define SET(a,x) memset(a,x,sizeof a) #define VI vector<int> #define PB push_back #define SZ size() #define CLR clear() #define PB(A) push_back(A) #define clr(a,b) memset(a,b,sizeof(a)) /**********CONSTANT**********/ #define MIN INT_MIN #define PI 2acos(-1.0) #define INF 2<<15 #define MOD 1000000007 #define MAX 1000001 using namespace std; /* LL gcd(LL a,LL b) { if(b==0)return a; return gcd(b,a%b); } LL bigmod(LL p,LL e,LL M) { if(e==0)return 1; if(e%2==0) { LL t=bigmod(p,e/2,M); return (t*t)%M; } return (bigmod(p,e-1,M)*p)%M; } LL modinverse(LL a,LL M) { return bigmod(a,M-2,M); } bool is_prime[MAX]; L prime[MAX]; bool sieve() { long i,j; prime[0]=2; int k=1; int sq=(sqrt(MAX)); for(i=3; i<=sq; i+=2) { if(!is_prime[i]) { for(j=i*i; j<=MAX; j+=(2*i)) is_prime[j]=1; } } for(j=3; j<=MAX; j+=2) { if(!is_prime[j]) { prime[k++]=j; } } } long NOD(long n) { int i,j,k; long sq=sqrt(n); long res=1; for(i=0; prime[i]<=sq; i++) { int cnt=1; if(n%prime[i]==0) { while(n%prime[i]==0) { cnt++; n=n/prime[i]; if(n==1) break; } res*=cnt; sq=sqrt(n); } } if(n>1) res*=2; return res; } */ bool go(LL n) { while(n>0) { int rem=n%10; if(rem==7 || rem==4) return true; n=n/10; } return false; } int main() { // FILE * fin, * fout; // fin=fopen("input.txt","r"); // fout=fopen("output.txt","w"); int i,j,k; LL n; I t; scanf("%d",&t); while(t--) { scanf("%lld",&n); LL sq=sqrt(n); LL cnt=0; for(i=1; i<=sq; i++) { if(n%i==0) { bool get=go(i); if(get) cnt++; get=go(n/i); if(get) cnt++; } } printf("%ld\n",cnt); } return 0; }
[ "milonju01@gmail.com" ]
milonju01@gmail.com
c005e6c7cdd8311ccc4c13d140066dab9832c50d
ade02ce99c8ee41a9c5267985516be106c50605a
/fit_scripts/parton_350_bukinFit.cpp
9c486be8c82a55789cc8bf92d84a203fbea27e2c
[]
no_license
KomalTauqeer/madanalysis5_ALP
800e1ff92e6430f464ec9fc6d2d135c5b52ff91b
d4550892b33b66ff57d4681a855edd6dd1a04911
refs/heads/master
2020-07-29T09:10:21.194207
2019-09-20T11:07:04
2019-09-20T11:07:04
209,741,122
0
0
null
null
null
null
UTF-8
C++
false
false
4,014
cpp
#include <TFile.h> #include <TCanvas.h> #include <TF1.h> #include <TH1F.h> void parton_350_bukinFit() { Double_t bukin(Double_t *x, Double_t *par); TFile *file = new TFile("/afs/cern.ch/work/k/ktauqeer/private/MadGraph/madanalysis5/rootFiles/parton_level_350.root","READ"); TFile *f1 = new TFile("/afs/cern.ch/work/k/ktauqeer/private/MadGraph/madanalysis5/rootFiles_fit/parton_level_350.root","RECREATE"); TCanvas* c1 = new TCanvas("c1"); TH1F* hist; file -> GetObject("hist_350",hist); hist -> Sumw2(); Double_t x = {1.}; Double_t par[6] = {1.,120.,20.-0.2,0.01,0.01}; TF1* f = new TF1("fit",bukin,250,500,6); f -> SetParameters(2.,371.5,84.83,-0.2,0.01,0.01); //TF1* f = new TF1("gauss","gausn",72,88); //f -> SetParameters(3,81.93,22.31); hist -> Fit("fit","R"); // Cosmetics gStyle -> SetOptStat(0); //gStyle-> SetOptFit(1100); //gStyle-> SetStatW(0.6); //gStyle-> SetStatH(0.6); hist -> SetTitle(""); hist -> GetXaxis() -> SetRangeUser(250,500); hist -> GetXaxis() -> SetTitle("M_{jj} [GeV]"); hist -> GetXaxis() -> SetTitleSize(0.05); hist -> GetXaxis() -> SetTitleOffset(0.8); hist -> GetYaxis() -> SetTitle("Events / (10 GeV)"); hist -> GetYaxis() -> SetTitleSize(0.05); hist -> GetYaxis() -> SetTitleOffset(0.9); hist -> SetMarkerStyle(20); hist -> SetMarkerSize(0.85); hist -> SetLineColor(1); hist -> SetLineWidth(1); hist -> Draw("PE1X0"); f -> SetFillStyle(1001); f -> Draw("fc same"); hist -> Draw("PE1X0 same"); auto leg = new TLegend(0.7,0.7,0.85,0.85); leg->AddEntry(hist,"MC data","P"); leg->AddEntry(f,"Bukin fit","l"); leg->Draw("same"); auto tbox = new TPaveText(0.7,0.4,0.85,0.6,"blNDC"); tbox -> SetFillStyle(0); tbox -> SetBorderSize(0); tbox -> SetTextAlign(12); tbox -> SetTextSize(0.030); tbox -> AddText(Form("#chi^{2}_{#nu}=%4.2f/%d",f->GetChisquare(),f->GetNDF())); tbox -> AddText(Form("#mu=%4.2f",f->GetParameter(1))); tbox -> AddText(Form("#sigma=%4.2f",f->GetParameter(2))); tbox -> Draw("same"); c1 -> SaveAs("parton_level_350_fit.pdf"); hist -> Write(); cout << "chi square = " << f -> GetChisquare() << endl; cout << "mean = " << f -> GetParameter(1) << endl; cout << "sigma = " << f -> GetParameter(2) << endl; //c1 -> SaveAs("fitted_histogram.pdf"); //file -> Close(); return; } Double_t bukin(Double_t *x, Double_t *par) { Double_t xx =x[0]; Double_t norm = par[0]; //100. Double_t x0 = par[1]; //120. Double_t sigma = par[2]; //20. Double_t xi = par[3]; //-0.2 Double_t rhoL = par[4]; //0.01 Double_t rhoR = par[5]; //0.01 double r1=0,r2=0,r3=0,r4=0,r5=0,hp=0; double x1 = 0,x2 = 0; double fit_result = 0; double consts = 2*sqrt(2*log(2.)); hp=sigma*consts; r3=log(2.); r4=sqrt(TMath::Power(xi,2)+1); r1=xi/r4; if(TMath::Abs(xi) > exp(-6.)){ r5=xi/log(r4+xi); } else r5=1; x1 = x0 + (hp / 2) * (r1-1); x2 = x0 + (hp / 2) * (r1+1); //--- Left Side if(xx < x1) { r2=rhoL*TMath::Power((xx-x1)/(x0-x1),2)-r3 + 4 * r3 * (xx-x1)/hp * r5 * r4/TMath::Power((r4-xi),2 ); } //--- Center else if(xx < x2) { if(TMath::Abs(xi) > exp(-6.)) { r2=log(1 + 4 * xi * r4 * (xx-x0)/hp)/log(1+2*xi*(xi-r4)); r2=-r3*(TMath::Power(r2,2)); } else { r2=-4*r3*TMath::Power(((xx-x0)/hp),2); } } //--- Right Side else { r2=rhoR*TMath::Power((xx-x2)/(x0-x2),2)-r3 - 4 * r3 * (xx-x2)/hp * r5 * r4/TMath::Power((r4+xi),2); } if(TMath::Abs(r2) > 100) { fit_result = 0; } else { //---- Normalize the result fit_result = exp(r2); } return norm*fit_result; }
[ "ktauqeer@lxplus791.cern.ch" ]
ktauqeer@lxplus791.cern.ch
654fc6c409a75b6e4b2c6588696e1ec9e7ac16ad
b7f3edb5b7c62174bed808079c3b21fb9ea51d52
/media/test/fake_encrypted_media.h
9e1e643a0ceefe7f2d482dc1cf398ce498904631
[ "BSD-3-Clause" ]
permissive
otcshare/chromium-src
26a7372773b53b236784c51677c566dc0ad839e4
64bee65c921db7e78e25d08f1e98da2668b57be5
refs/heads/webml
2023-03-21T03:20:15.377034
2020-11-16T01:40:14
2020-11-16T01:40:14
209,262,645
18
21
BSD-3-Clause
2023-03-23T06:20:07
2019-09-18T08:52:07
null
UTF-8
C++
false
false
2,835
h
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_TEST_FAKE_ENCRYPTED_MEDIA_H_ #define MEDIA_TEST_FAKE_ENCRYPTED_MEDIA_H_ #include "media/base/cdm_context.h" #include "media/base/content_decryption_module.h" namespace media { class AesDecryptor; // Note: Tests using this class only exercise the DecryptingDemuxerStream path. // They do not exercise the Decrypting{Audio|Video}Decoder path. class FakeEncryptedMedia { public: // Defines the behavior of the "app" that responds to EME events. class AppBase { public: virtual ~AppBase() {} virtual void OnSessionMessage(const std::string& session_id, CdmMessageType message_type, const std::vector<uint8_t>& message, AesDecryptor* decryptor) = 0; virtual void OnSessionClosed(const std::string& session_id) = 0; virtual void OnSessionKeysChange(const std::string& session_id, bool has_additional_usable_key, CdmKeysInfo keys_info) = 0; virtual void OnSessionExpirationUpdate(const std::string& session_id, base::Time new_expiry_time) = 0; virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8_t>& init_data, AesDecryptor* decryptor) = 0; }; FakeEncryptedMedia(AppBase* app); ~FakeEncryptedMedia(); CdmContext* GetCdmContext(); // Callbacks for firing session events. Delegate to |app_|. void OnSessionMessage(const std::string& session_id, CdmMessageType message_type, const std::vector<uint8_t>& message); void OnSessionClosed(const std::string& session_id); void OnSessionKeysChange(const std::string& session_id, bool has_additional_usable_key, CdmKeysInfo keys_info); void OnSessionExpirationUpdate(const std::string& session_id, base::Time new_expiry_time); void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8_t>& init_data); private: class TestCdmContext : public CdmContext { public: TestCdmContext(Decryptor* decryptor); Decryptor* GetDecryptor() final; private: Decryptor* decryptor_; }; scoped_refptr<AesDecryptor> decryptor_; TestCdmContext cdm_context_; std::unique_ptr<AppBase> app_; DISALLOW_COPY_AND_ASSIGN(FakeEncryptedMedia); }; } // namespace media #endif // MEDIA_TEST_FAKE_ENCRYPTED_MEDIA_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
289c1f2ff3f6911d758c6c39ad0b836400c70e00
a2111a80faf35749d74a533e123d9da9da108214
/raw/pmbs12/pmsb13-data-20120615/trunk/sandbox/arsenew/apps/msplazer/stellar_routines.h
06a3e04c4cd8e64ccbde67c5af8329ff7bdf096a
[ "MIT", "BSD-3-Clause" ]
permissive
bkahlert/seqan-research
f2c550d539f511825842a60f6b994c1f0a3934c2
21945be863855077eec7cbdb51c3450afcf560a3
refs/heads/master
2022-12-24T13:05:48.828734
2015-07-01T01:56:22
2015-07-01T01:56:22
21,610,669
1
0
null
null
null
null
UTF-8
C++
false
false
22,103
h
// ========================================================================== // msplazer // ========================================================================== // Copyright (c) 2011, Kathrin Trappe, FU Berlin // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of Knut Reinert or the FU Berlin 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 KNUT REINERT OR THE FU BERLIN BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // // ========================================================================== // Author: Kathrin Trappe <kathrin.trappe@fu-berlin.de> // ========================================================================== #ifndef SANDBOX_KTRAPPE_APPS_MSPLAZER_STELLAR_ROUTINES_H_ #define SANDBOX_KTRAPPE_APPS_MSPLAZER_STELLAR_ROUTINES_H_ #define BREAKPOINT_DEBUG #include <seqan/basic.h> #include <seqan/sequence.h> #include <seqan/stream.h> #include "../../../../core/apps/stellar/stellar.h" using namespace seqan; //Compare StellarMatches using in order of priority (1) read begin, (2) read end position, (3) chromosome begin, (4) chromosome end pos template< typename TSequence, typename TId> struct CompareStellarMatches{ bool operator() (StellarMatch<TSequence, TId> const & match1, StellarMatch<TSequence, TId> const & match2) const { if(match1.begin2 != match2.begin2) return match1.begin2 < match2.begin2; if(match1.end2 != match2.end2) return match1.end2 < match2.end2; if(match1.begin1 != match2.begin1) return match1.begin1 < match2.begin1; //if(match1.end1 != match2.end1) return match1.end1 < match2.end1; } }; /////////////////////////////////////////////////////////////////////////////// //Wrapper functions to get Stellar matches template <typename TSequence, typename TMatches> void _getStellarMatches(StringSet<TSequence> & queries, StringSet<TSequence> & databases, StringSet<CharString> & databaseIDs, StellarOptions & stellarOptions, TMatches & stellarMatches){ //Finder typedef Finder<TSequence, Swift<SwiftLocal> > TFinder; // typedef Finder<TSequence, Swift<SwiftLocal> > TFinder; //Using Stellars structure for queries typedef Index<StringSet<TSequence, Dependent<> >, IndexQGram<SimpleShape, OpenAddressing> > TQGramIndex; //typedef Index<StringSet<TSequence, Dependent<> >, IndexQGram<SimpleShape> > TQGramIndex; TQGramIndex qgramIndex(queries); //stellarOptions.qGram = 4; resize(indexShape(qgramIndex), stellarOptions.qGram); // cargo(qgramIndex).abundanceCut = stellarOptions.qgramAbundanceCut; //pattern /* //Using FragmenStore typedef Index<StringSet<TSequence, Owner<ConcatDirect<> > >, IndexQGram<SimpleShape, OpenAddressing> > TQGramIndexFrSt; TQGramIndexFrSt qgramIndexFrSt(fragments.readSeqStore); stellarOptions.qGram = 4; resize(indexShape(qgramIndexFrSt), stellarOptions.qGram); typedef Pattern<TQGramIndexFrSt, Swift<SwiftLocal> > TPatternFrSt; TPatternFrSt swiftPatternFrSt(qgramIndexFrSt); std::cout << "FrStPattern: " << value(host(needle(swiftPatternFrSt)),0) << std::endl; // Construct index std::cout << "Constructing index..." << std::endl; indexRequire(qgramIndexFrSt, QGramSADir()); std::cout << std::endl; */ //Using Stellars structure for queries typedef Pattern<TQGramIndex, Swift<SwiftLocal> > TPattern; TPattern swiftPattern(qgramIndex); //std::cout << "Pattern: " << value(host(needle(swiftPattern)),0) << std::endl; // Construct index std::cout << "Constructing index..." << std::endl; indexRequire(qgramIndex, QGramSADir()); std::cout << std::endl; //Call Stellar for each database sequence double start = sysTime(); for(unsigned i = 0; i < length(databases); ++i){ //Using long stellar() to calculate stellarMatches on + strand if(stellarOptions.forward){ TFinder swiftFinder(databases[i], stellarOptions.minRepeatLength, stellarOptions.maxRepeatPeriod); stellar(swiftFinder, swiftPattern, stellarOptions.epsilon, stellarOptions.minLength, stellarOptions.xDrop, stellarOptions.disableThresh, stellarOptions.compactThresh, stellarOptions.numMatches, stellarOptions.verbose, databaseIDs[i], true, stellarMatches, AllLocal()); } // - strand if(stellarOptions.reverse){ reverseComplement(databases[i]); TFinder revSwiftFinder(databases[i], stellarOptions.minRepeatLength, stellarOptions.maxRepeatPeriod); stellar(revSwiftFinder, swiftPattern, stellarOptions.epsilon, stellarOptions.minLength, stellarOptions.xDrop, stellarOptions.disableThresh, stellarOptions.compactThresh, stellarOptions.numMatches, stellarOptions.verbose, databaseIDs[i], false, stellarMatches, AllLocal()); reverseComplement(databases[i]); } } std::cout << "TIME stellar " << (sysTime() - start) << "s" << std::endl; } //Alignment Score using _analyzeAlignment(row0, row1, alignLen, matchNumber) from stellar_output.h //matchNumber and alignLen reset within _analyzeAlignment template < typename TSequence, typename TId, typename TValue > void _getScore(StellarMatch<TSequence, TId> & match, TValue & alignLen, TValue & matchNumber, TValue & alignDistance){ if(!match.orientation) reverseComplement(infix(source(match.row1),match.begin1,match.end1)); _analyzeAlignment(match.row1, match.row2, alignLen, matchNumber); alignDistance = alignLen - matchNumber; if(!match.orientation) reverseComplement(infix(source(match.row1),match.begin1,match.end1)); } //Transforms coordinates of a stellar match onto the other strand template <typename TMatch> void _transformCoordinates(TMatch & match){ //setClippedBeginPosition(match.row1, length(source(match.row1)) - match.end1); //setClippedEndPosition(match.row1, length(source(match.row1)) - match.begin1); //std::cerr << "Chr length: " << length(source(match.row1)) << std::endl; match.row1.clipped_source_begin = length(source(match.row1)) - match.end1; match.row1.clipped_source_end = length(source(match.row1)) - match.begin1; match.begin1 = clippedBeginPosition(match.row1); match.end1 = clippedEndPosition(match.row1); } //Computes distance score for each match and stores is in distanceScores //Note: Matches are being sorted within this function //Note also: StellarMatches of the reverse Strand are being modified, in the sense that they correspond to the right positions within the forward strand template < typename TScoreAlloc, typename TSequence, typename TId> void _getMatchDistanceScore( StringSet <QueryMatches <StellarMatch <TSequence, TId> > > & stellarMatches, String<TScoreAlloc> & distanceScores, bool internalStellarCall){ typedef StellarMatch<TSequence, TId> TMatch; typedef typename Size<typename TMatch::TAlign>::Type TSize; typedef typename Iterator<String<TMatch> >::Type TIterator; //Calculating distance score of each match using Stellars _analayzeAlignment function int matchNumber, alignLen, alignDistance; for(TSize i = 0; i < length(stellarMatches); ++i){ TScoreAlloc & matchDistanceScores = distanceScores[i]; resize(matchDistanceScores, length(stellarMatches[i].matches)); //Sorting matches according to query begin position (begin2) std::sort(begin(stellarMatches[i].matches), end(stellarMatches[i].matches), CompareStellarMatches<TSequence, TId>()); TIterator itStellarMatches = begin(stellarMatches[i].matches); TIterator itEndStellarMatches = end(stellarMatches[i].matches); TSize matchIndex = 0; for(;itStellarMatches < itEndStellarMatches;goNext(itStellarMatches)){ if(internalStellarCall && !(*itStellarMatches).orientation){ //coordinate transformation (setClippedPosition does not work here) _transformCoordinates(*itStellarMatches); } //Compute edit distance score _getScore(*itStellarMatches, alignLen, matchNumber, alignDistance); matchDistanceScores[matchIndex] = alignDistance; ++matchIndex; } } } template <typename TMatch, typename TPos> void _trimMatchBegin(TMatch & stMatch, TPos const & splitPos, TPos const & projSplitPos){ setClippedBeginPosition(stMatch.row2, projSplitPos); if(stMatch.orientation) setClippedBeginPosition(stMatch.row1, splitPos); else{ TPos diff = splitPos - clippedBeginPosition(stMatch.row1); _transformCoordinates(stMatch); setClippedBeginPosition(stMatch.row1, stMatch.begin1 + diff); stMatch.begin1 = clippedBeginPosition(stMatch.row1); _transformCoordinates(stMatch); } stMatch.begin1 = clippedBeginPosition(stMatch.row1); stMatch.begin2 = clippedBeginPosition(stMatch.row2); } template <typename TMatch, typename TPos> void _trimMatchEnd(TMatch & stMatch, TPos & splitPos, TPos & projSplitPos){ setClippedEndPosition(stMatch.row2, projSplitPos); if(stMatch.orientation) setClippedEndPosition(stMatch.row1, splitPos); else{ TPos diff = clippedEndPosition(stMatch.row1) - splitPos; _transformCoordinates(stMatch); setClippedEndPosition(stMatch.row1, stMatch.end1 - diff); stMatch.end1 = clippedEndPosition(stMatch.row1); _transformCoordinates(stMatch); } stMatch.end1 = clippedEndPosition(stMatch.row1); stMatch.end2 = clippedEndPosition(stMatch.row2); } //TODO Restructure template <typename TSequence, typename TId, typename TBreakpoint> void _getStellarIndel(StellarMatch<TSequence, TId> & match, String<TBreakpoint> & globalStellarIndels, TId const & queryId, TSequence & query){ //std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl; typedef typename Infix<TSequence>::Type TInfix; typedef typename TBreakpoint::TPos TPos; //typedef typename StellarMatch<TSequence, TId>::TRow TRow; typedef Align<TInfix> TAlign; typedef typename Row<TAlign>::Type TRow; bool gapOpen = true; TPos startSeqPos, endSeqPos, indelStart, pos; indelStart = 0; //Match refinement int matchNumber, alignLen, score; Score<int> scoreType(1,-2,-2,-5); /* std::cerr << "Trying to build infices: " << length(match.row1) << " begin1: " << match.begin1 << " clippedBegin: " << clippedBeginPosition(match.row1) << " end1: " << match.end1 << " clippedEnd: " << clippedEndPosition(match.row1) << std::endl; */ TInfix seq1, seq2; seq1 = infix(source(match.row1), match.begin1, match.end1); seq2 = infix(query, match.begin2, match.end2); if(!match.orientation) reverseComplement(seq1); TAlign align; resize(rows(align), 2); setSource(row(align, 0), seq1); setSource(row(align, 1), seq2); StringSet<TInfix> seqs; appendValue(seqs, seq1); appendValue(seqs, seq2); _analyzeAlignment(match.row1, match.row2, alignLen, matchNumber); score = alignLen - matchNumber; //Refine match using banded global alignment with affine gap score if(score > 0){ globalAlignment(align, seqs, scoreType, -score, score, BandedGotoh()); //std::cout << align << std::endl; } TRow & rowDB = row(align, 0); TRow & rowRead = row(align, 1); //Insertions for(pos = 0; pos < std::max(endPosition(rowDB), endPosition(rowRead)); ++pos){ //Look for gap in rowDB if(isGap(rowDB,pos)){ //Keep track if it is the first gap, i.e. the beginning of the insertion if(gapOpen){ gapOpen = false; indelStart = pos; //std::cerr << "indelStart: " << indelStart << " gapopen " << gapOpen << std::endl; } }else{ //If an insertion just closed, i.e. !gapOpen, save the insertion in a breakpoint if(!gapOpen){ //Get breakpoint position (note, in case of an insertion start=end) startSeqPos = toSourcePosition(rowDB, indelStart) + match.begin1; TPos readStartPos = toSourcePosition(rowRead, indelStart) + match.begin2; TPos readEndPos = toSourcePosition(rowRead, pos) + match.begin2; TBreakpoint bp(match.id, match.id, match.orientation, match.orientation, startSeqPos, startSeqPos, readStartPos, readEndPos, queryId); //get insertion sequence TPos bPos = toSourcePosition(rowRead, indelStart); TPos ePos = toSourcePosition(rowRead, pos); if(bPos > ePos) std::swap(bPos, ePos); TInfix inSeq = infix(query, bPos, ePos); setSVType(bp, static_cast<TId>("insertion")); setInsertionSeq(bp, inSeq); //_insertBreakpoint(globalStellarIndels, bp); //std::cerr << bp << std::endl; //reset gapOpen gapOpen = true; } } } //Get insertion at the end of the match if(!gapOpen){ //Get breakpoint position (note, in case of an insertion start=end) startSeqPos = toSourcePosition(rowDB, indelStart) + match.begin1; TPos readStartPos = toSourcePosition(rowRead, indelStart) + match.begin2; TPos readEndPos = toSourcePosition(rowRead, pos) + match.begin2; TBreakpoint bp(match.id, match.id, match.orientation, match.orientation, startSeqPos, startSeqPos, readStartPos, readEndPos, queryId); //get insertion sequence TPos bPos = toSourcePosition(rowRead, indelStart) + match.begin2; TPos ePos = toSourcePosition(rowRead, pos) + match.begin2; if(bPos > ePos) std::swap(bPos, ePos); TInfix inSeq = infix(query, bPos, ePos); setSVType(bp, static_cast<TId>("insertion")); setInsertionSeq(bp, inSeq); _insertBreakpoint(globalStellarIndels, bp); //reset gapOpen gapOpen = true; } //Deletions for(pos = 0; pos < std::max(endPosition(rowDB), endPosition(rowRead)); ++pos){ //Look for gap in rowRead if(isGap(rowRead,pos)){ if(gapOpen){ gapOpen = false; indelStart = pos; } }else{ if(!gapOpen){ //Get breakpoint positions startSeqPos = toSourcePosition(rowDB, indelStart) + match.begin1; endSeqPos = toSourcePosition(rowDB, pos) + match.begin1; if(startSeqPos > endSeqPos) std::swap(startSeqPos, endSeqPos); TPos readStartPos = toSourcePosition(rowRead, indelStart) + match.begin2; TPos readEndPos = toSourcePosition(rowRead, pos) + match.begin2; TBreakpoint bp(match.id, match.id, match.orientation, match.orientation, startSeqPos, endSeqPos, readStartPos, readEndPos, queryId); setSVType(bp, static_cast<TId>("deletion")); _insertBreakpoint(globalStellarIndels, bp); gapOpen = true; } } } //Get deletion at the end of the match if(!gapOpen){ startSeqPos = toSourcePosition(rowDB, indelStart) + match.begin1; endSeqPos = toSourcePosition(rowDB, pos) + match.begin1; if(startSeqPos > endSeqPos) std::swap(startSeqPos, endSeqPos); TPos readStartPos = toSourcePosition(rowRead, indelStart) + match.begin2; TPos readEndPos = toSourcePosition(rowRead, pos) + match.begin2; TBreakpoint bp(match.id, match.id, match.orientation, match.orientation, startSeqPos, endSeqPos, readStartPos, readEndPos, queryId); setSVType(bp, static_cast<TId>("deletion")); _insertBreakpoint(globalStellarIndels, bp); gapOpen = true; } if(!match.orientation) reverseComplement(seq1); } template<typename TId> bool _checkUniqueId(TId const & sId, TId const & id, StringSet<TId> & ids, StringSet<TId> & sQueryIds){ bool unique = true; for(unsigned j = 0; j < length(sQueryIds); ++j){ if(sId == sQueryIds[j]){ std::cout << "Found nonunique sequence ID!" << std::endl; std::cout << ids[j] << std::endl; std::cout << id << std::endl; std::cout << "###########################" << std::endl; unique = false; } } return unique; } /////////////////////////////////////////////////////////////////////////////// //Functions taken from Stellar code for writing Stellar parameters and read files /////////////////////////////////////////////////////////////////////////////// // Imports sequences from a file, // stores them in the StringSet seqs and their identifiers in the StringSet ids template<typename TSequence, typename TId> inline bool _importSequences(CharString const & fileName, CharString const & name, StringSet<TSequence> & seqs, StringSet<TId> & ids) { MultiSeqFile multiSeqFile; if (!open(multiSeqFile.concat, toCString(fileName), OPEN_RDONLY)) { std::cerr << "Failed to open " << name << " file." << std::endl; return false; } StringSet<TId> sQueryIds; AutoSeqFormat format; guessFormat(multiSeqFile.concat, format); split(multiSeqFile, format); unsigned seqCount = length(multiSeqFile); reserve(seqs, seqCount, Exact()); reserve(ids, seqCount, Exact()); TSequence seq; TId id; TId sId; unsigned counter = 0; for(unsigned i = 0; i < seqCount; ++i) { assignSeq(seq, multiSeqFile[i], format); assignSeqId(id, multiSeqFile[i], format); appendValue(seqs, seq, Generous()); appendValue(ids, id, Generous()); _getShortId(id, sId); if(!_checkUniqueId(sId, id, ids, sQueryIds)) ++counter; appendValue(sQueryIds, sId); } std::cout << "Loaded " << seqCount << " " << name << " sequence" << ((seqCount>1)?"s.":".") << std::endl; if(counter > 0) std::cout << "Found " << counter << " nonunique sequence IDs" << std::endl; return true; } /////////////////////////////////////////////////////////////////////////////// // Calculates parameters from parameters in options object and writes them to std::cout void _writeCalculatedParams(StellarOptions & options) { //IOREV _notio_ int errMinLen = (int) floor(options.epsilon * options.minLength); int n = (int) ceil((errMinLen + 1) / options.epsilon); int errN = (int) floor(options.epsilon * n); unsigned smin = (unsigned) _min(ceil((double)(options.minLength-errMinLen)/(errMinLen+1)), ceil((double)(n-errN)/(errN+1))); std::cout << "Calculated parameters:" << std::endl; if (options.qGram == (unsigned)-1) { options.qGram = (unsigned)_min(smin, 32u); std::cout << " k-mer length: " << options.qGram << std::endl; } int threshold = (int) _max(1, (int) _min((n + 1) - options.qGram * (errN + 1), (options.minLength + 1) - options.qGram * (errMinLen + 1))); int overlap = (int) floor((2 * threshold + options.qGram - 3) / (1 / options.epsilon - options.qGram)); int distanceCut = (threshold - 1) + options.qGram * overlap + options.qGram; int logDelta = _max(4, (int) ceil(log((double)overlap + 1) / log(2.0))); int delta = 1 << logDelta; std::cout << " s^min : " << smin << std::endl; std::cout << " threshold : " << threshold << std::endl; std::cout << " distance cut: " << distanceCut << std::endl; std::cout << " delta : " << delta << std::endl; std::cout << " overlap : " << overlap << std::endl; std::cout << std::endl; } /////////////////////////////////////////////////////////////////////////////// // Writes user specified parameters from options object to std::cout template<typename TOptions> void _writeSpecifiedParams(TOptions & options) { //IOREV _notio_ // Output user specified parameters std::cout << "User specified parameters:" << std::endl; std::cout << " minimal match length : " << options.minLength << std::endl; std::cout << " maximal error rate (epsilon) : " << options.epsilon << std::endl; std::cout << " maximal x-drop : " << options.xDrop << std::endl; if (options.qGram != (unsigned)-1) std::cout << " k-mer (q-gram) length : " << options.qGram << std::endl; std::cout << " search forward strand : " << ((options.forward)?"yes":"no") << std::endl; std::cout << " search reverse complement : " << ((options.reverse)?"yes":"no") << std::endl; std::cout << std::endl; std::cout << " verification strategy : " << options.fastOption << std::endl; if (options.disableThresh != (unsigned)-1) { std::cout << " disable queries with more than : " << options.disableThresh << " matches" << std::endl; } std::cout << " maximal number of matches : " << options.numMatches << std::endl; std::cout << " duplicate removal every : " << options.compactThresh << std::endl; if (options.maxRepeatPeriod != 1 || options.minRepeatLength != 1000) { std::cout << " max low complexity repeat period : " << options.maxRepeatPeriod << std::endl; std::cout << " min low complexity repeat length : " << options.minRepeatLength << std::endl; } if (options.qgramAbundanceCut != 1) { std::cout << " q-gram abundance cut ratio : " << options.qgramAbundanceCut << std::endl; } std::cout << std::endl; } /////////////////////////////////////////////////////////////////////////////// // Writes file name from options object to std::cout template<typename TOptions> void _writeFileNames(TOptions & options) { //IOREV _notio_ std::cout << "Database file : " << options.databaseFile << std::endl; std::cout << "Query file : " << options.queryFile << std::endl; std::cout << "Output file : " << options.outputFile << std::endl; std::cout << "Output format : " << options.outputFormat << std::endl; if (options.disableThresh != (unsigned)-1) { std::cout << "Disabled queries: " << options.disabledQueriesFile << std::endl; } std::cout << std::endl; } #endif // #ifndef SANDBOX_MY_SANDBOX_APPS_MSPLAZER_STELLAR_ROUTINES_H_
[ "mail@bkahlert.com" ]
mail@bkahlert.com
3fcd6504c751ebdb71b7f16eca03ca6e31373112
43a2fbc77f5cea2487c05c7679a30e15db9a3a50
/Cpp/External (Offsets Only)/SDK/Title_CollectorOfLegendaryVillainousSkulls_functions.cpp
021f9c3931668c2a45e25d0c5bf33586c2c80493
[]
no_license
zH4x/SoT-Insider-SDK
57e2e05ede34ca1fd90fc5904cf7a79f0259085c
6bff738a1b701c34656546e333b7e59c98c63ad7
refs/heads/main
2023-06-09T23:10:32.929216
2021-07-07T01:34:27
2021-07-07T01:34:27
383,638,719
0
0
null
null
null
null
UTF-8
C++
false
false
603
cpp
// Name: SoT-Insider, Version: 1.102.2382.0 #include "../pch.h" /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Functions //--------------------------------------------------------------------------- void UTitle_CollectorOfLegendaryVillainousSkulls_C::AfterRead() { UTitleDesc::AfterRead(); } void UTitle_CollectorOfLegendaryVillainousSkulls_C::BeforeDelete() { UTitleDesc::BeforeDelete(); } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "Massimo.linker@gmail.com" ]
Massimo.linker@gmail.com
8326e5f9f6e80d5749438a935eb9e1be5347b437
8bd9ac901535033737a70fa5f677a2d23114aabf
/STL/priority.cpp
81bbd343c7b81aabe6fda91f3840c71f28141fe9
[]
no_license
Double-Wen/CPlus
5657c3e6a73d113fcc5d6f017668534924641654
b24fe08f8f254c1da4b6c23b45b78004b98fd1d4
refs/heads/master
2022-11-14T20:45:40.686160
2020-07-15T15:46:51
2020-07-15T15:46:51
258,478,082
1
0
null
null
null
null
UTF-8
C++
false
false
482
cpp
#include <iostream> #include <queue> using namespace std; int main() { priority_queue<int> q; q.push(5); q.push(1); q.push(3); q.push(6); for(int i=0; i<4; i++) { cout << q.top() << endl; //注意优先队列和传统队列不同, //它是用堆而不是线性结构来维护的, //所以它只有top来取堆顶元素 //而不是传统的线性结构的front和back q.pop(); } return 0; }
[ "tcliuwenwen@126.com" ]
tcliuwenwen@126.com
936f28c3971ae60176f3dfe89bcb7a577d87d2fb
efdd5a69e84d75d5c906c43de6efb335c80aecb9
/src/Index.re
e81c6860eba7ee5aaf678f52d63704606d53857d
[]
no_license
kennetpostigo/mangosnake
c5d713e82dc99dd79178ed2a6aa9aa2277f42205
3bf01ed1a21416089dcbf8f096fbf8ef92e84860
refs/heads/master
2021-09-06T07:38:33.706976
2018-02-03T21:43:02
2018-02-03T21:43:02
120,058,501
1
0
null
null
null
null
UTF-8
C++
false
false
52
re
ReactDOMRe.renderToElementWithId(<Canvas />, "app");
[ "kennetfpostigo@gmail.com" ]
kennetfpostigo@gmail.com