blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
a464655d07208c3c17149869a5cf76668e5196c0
8ba702464e18013ff2dba9211084f5b656c4609e
/xayagame/sqlitestorage_tests.cpp
80717691766719ecad1505b861a8f73c73075a2b
[ "MIT" ]
permissive
Ampakinetic/libxayagame
cdfec37be21b9baec039b0aca927280b9af5a346
733f242371f3dd9acf3b3056932f544787dbde14
refs/heads/master
2023-04-27T22:48:09.638320
2021-05-21T09:59:33
2021-05-21T09:59:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,512
cpp
// Copyright (C) 2018-2020 The Xaya developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "sqlitestorage.hpp" #include "storage_tests.hpp" #include "testutils.hpp" #include "xayautil/hash.hpp" #include <gtest/gtest.h> #include <atomic> #include <chrono> #include <cstdio> #include <limits> #include <memory> #include <thread> namespace xaya { namespace { /* ************************************************************************** */ /** * Simple utility subclass of SQLiteStorage, which makes it default * constructible with an in-memory database. */ class InMemorySQLiteStorage : public SQLiteStorage { public: InMemorySQLiteStorage () : SQLiteStorage (":memory:") {} }; INSTANTIATE_TYPED_TEST_CASE_P (SQLite, BasicStorageTests, InMemorySQLiteStorage); INSTANTIATE_TYPED_TEST_CASE_P (SQLite, PruningStorageTests, InMemorySQLiteStorage); INSTANTIATE_TYPED_TEST_CASE_P (SQLite, TransactingStorageTests, InMemorySQLiteStorage); /* ************************************************************************** */ class SQLiteStatementTests : public testing::Test { protected: SQLiteDatabase db; SQLiteStatementTests () : db("foo", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY) { db.Execute (R"( CREATE TABLE `test` (`int` INTEGER NULL, `text` TEXT NULL, `blob` BLOB NULL); )"); } /** * Tests a "roundtrip" of storing a value into our test database * with a prepared statement parameter bind, and then extracting * it again to test that the binding and extraction works. */ template <typename T> void Roundtrip (const std::string& column, const T& val) { auto stmt = db.Prepare (R"( INSERT INTO `test` (`)" + column + R"(`) VALUES (?1) )"); stmt.Bind (1, val); stmt.Execute (); stmt = db.PrepareRo (R"( SELECT `)" + column + R"(` FROM `test` )"); ASSERT_TRUE (stmt.Step ()); EXPECT_EQ (stmt.Get<T> (0), val); ASSERT_FALSE (stmt.Step ()); stmt = db.Prepare (R"( DELETE FROM `test` )"); stmt.Execute (); } }; TEST_F (SQLiteStatementTests, BindExtract) { Roundtrip<int> ("int", 0); Roundtrip<int> ("int", 123); Roundtrip<int> ("int", -5); Roundtrip<unsigned> ("int", 0); Roundtrip<unsigned> ("int", 1 << 20); Roundtrip<int64_t> ("int", 0); Roundtrip<int64_t> ("int", std::numeric_limits<int64_t>::min ()); Roundtrip<int64_t> ("int", std::numeric_limits<int64_t>::max ()); Roundtrip<uint64_t> ("int", 0); Roundtrip<uint64_t> ("int", std::numeric_limits<int64_t>::max ()); Roundtrip<bool> ("int", false); Roundtrip<bool> ("int", true); Roundtrip<std::string> ("text", ""); Roundtrip<std::string> ("text", "foobar"); Roundtrip<std::string> ("text", u8"äöü"); Roundtrip<std::string> ("text", std::string ("abc\0def", 7)); uint256 zero; zero.SetNull (); Roundtrip<uint256> ("blob", zero); Roundtrip<uint256> ("blob", SHA256::Hash ("foobar")); } TEST_F (SQLiteStatementTests, BindCheckNull) { auto stmt = db.Prepare (R"( INSERT INTO `test` (`int`, `text`) VALUES (1, ?1), (2, ?2) )"); stmt.Bind<std::string> (1, "foo"); stmt.Bind<std::string> (2, "wrong"); stmt.BindNull (2); stmt.Execute (); stmt = db.PrepareRo (R"( SELECT `text` FROM `test` ORDER BY `int` )"); ASSERT_TRUE (stmt.Step ()); ASSERT_FALSE (stmt.IsNull (0)); EXPECT_EQ (stmt.Get<std::string> (0), "foo"); ASSERT_TRUE (stmt.Step ()); EXPECT_TRUE (stmt.IsNull (0)); ASSERT_FALSE (stmt.Step ()); } TEST_F (SQLiteStatementTests, BindExtractBlob) { std::string binary; for (int i = 0; i <= 0xFF; ++i) binary.push_back (static_cast<char> (i)); auto stmt = db.Prepare (R"( INSERT INTO `test` (`int`, `blob`) VALUES (1, ?1), (2, ?2) )"); stmt.BindBlob (1, ""); stmt.BindBlob (2, binary); stmt.Execute (); stmt = db.PrepareRo (R"( SELECT `blob` FROM `test` ORDER BY `int` )"); ASSERT_TRUE (stmt.Step ()); EXPECT_EQ (stmt.GetBlob (0), ""); ASSERT_TRUE (stmt.Step ()); EXPECT_EQ (stmt.GetBlob (0), binary); ASSERT_FALSE (stmt.Step ()); } TEST_F (SQLiteStatementTests, Reset) { auto stmt = db.Prepare (R"( INSERT INTO `test` (`int`, `text`) VALUES (1, 'foo'), (1, 'bar'), (2, 'baz') )"); stmt.Execute (); stmt = db.PrepareRo (R"( SELECT `text` FROM `test` WHERE `int` = ?1 ORDER BY `text` )"); stmt.Bind (1, 1); for (int i = 0; i < 10; ++i) { stmt.Reset (); ASSERT_TRUE (stmt.Step ()); EXPECT_EQ (stmt.Get<std::string> (0), "bar"); ASSERT_TRUE (stmt.Step ()); EXPECT_EQ (stmt.Get<std::string> (0), "foo"); ASSERT_FALSE (stmt.Step ()); } stmt.Reset (); stmt.Bind (1, 2); ASSERT_TRUE (stmt.Step ()); EXPECT_EQ (stmt.Get<std::string> (0), "baz"); ASSERT_FALSE (stmt.Step ()); } TEST_F (SQLiteStatementTests, ConcurrentStatementUse) { /* In this test, we ensure that the statement cache is able to handle both concurrent threads accessing the database and also a single thread using a single statement twice at the same time (which should yield two independent sqlite3_stmt's). */ constexpr unsigned numThreads = 10; auto stmt = db.Prepare (R"( INSERT INTO `test` (`int`) VALUES (1), (2), (3) )"); stmt.Execute (); const std::string sql = R"( SELECT `int` FROM `test` ORDER BY `int` )"; constexpr auto waitTime = std::chrono::milliseconds (100); using Clock = std::chrono::steady_clock; const auto before = Clock::now (); std::vector<std::thread> threads; for (unsigned i = 0; i < numThreads; ++i) threads.emplace_back ([this, waitTime, &sql] () { auto stmt1 = db.PrepareRo (sql); ASSERT_TRUE (stmt1.Step ()); ASSERT_EQ (stmt1.Get<int64_t> (0), 1); auto stmt2 = db.PrepareRo (sql); for (int j = 1; j <= 3; ++j) { ASSERT_TRUE (stmt2.Step ()); ASSERT_EQ (stmt2.Get<int64_t> (0), j); } std::this_thread::sleep_for (waitTime); ASSERT_TRUE (stmt1.Step ()); ASSERT_EQ (stmt1.Get<int64_t> (0), 2); ASSERT_TRUE (stmt1.Step ()); ASSERT_EQ (stmt1.Get<int64_t> (0), 3); ASSERT_FALSE (stmt1.Step ()); ASSERT_FALSE (stmt2.Step ()); }); for (auto& t : threads) t.join (); const auto after = Clock::now (); CHECK (after - before < 2 * waitTime); } /* ************************************************************************** */ /** * Tests for SQLiteStorage with a temporary on-disk database file (instead of * just an in-memory database). They verify explicitly that data is persisted * for a second instantiation of SQLiteStorage that uses the same file. */ class PersistentSQLiteStorageTests : public testing::Test { protected: /** Example uint256 value for use as block hash in the test. */ uint256 hash; /** Example game state value. */ const GameStateData state = "some game state"; /** Example undo data value. */ const UndoData undo = "some undo data"; /** Name of the temporary file used for the database. */ std::string filename; PersistentSQLiteStorageTests () { CHECK (hash.FromHex ("99" + std::string (62, '0'))); filename = std::tmpnam (nullptr); LOG (INFO) << "Using temporary database file: " << filename; } ~PersistentSQLiteStorageTests () { LOG (INFO) << "Cleaning up temporary file: " << filename; std::remove (filename.c_str ()); } }; TEST_F (PersistentSQLiteStorageTests, PersistsData) { { SQLiteStorage storage(filename); storage.Initialise (); storage.BeginTransaction (); storage.SetCurrentGameState (hash, state); storage.AddUndoData (hash, 42, undo); storage.CommitTransaction (); } { SQLiteStorage storage(filename); storage.Initialise (); uint256 h; ASSERT_TRUE (storage.GetCurrentBlockHash (h)); EXPECT_TRUE (h == hash); EXPECT_EQ (storage.GetCurrentGameState (), state); UndoData val; ASSERT_TRUE (storage.GetUndoData (hash, val)); EXPECT_EQ (val, undo); } } TEST_F (PersistentSQLiteStorageTests, ClearWithOnDiskFile) { SQLiteStorage storage(filename); storage.Initialise (); storage.BeginTransaction (); storage.SetCurrentGameState (hash, state); storage.AddUndoData (hash, 42, undo); storage.CommitTransaction (); uint256 h; UndoData val; EXPECT_TRUE (storage.GetCurrentBlockHash (h)); EXPECT_TRUE (storage.GetUndoData (hash, val)); storage.Clear (); EXPECT_FALSE (storage.GetCurrentBlockHash (h)); EXPECT_FALSE (storage.GetUndoData (hash, val)); } /* ************************************************************************** */ class SQLiteStorageSnapshotTests : public PersistentSQLiteStorageTests { protected: class Storage : public SQLiteStorage { public: using SQLiteStorage::SQLiteStorage; using SQLiteStorage::GetDatabase; using SQLiteStorage::GetSnapshot; }; /** * Expects that the current game state as seen by the given database * matches the given value. The empty value matches "no state". */ void ExpectDatabaseState (const SQLiteDatabase& db, const std::string& value) { auto stmt = db.PrepareRo (R"( SELECT `value` FROM `xayagame_current` WHERE `key` = 'gamestate' )"); if (!stmt.Step ()) { EXPECT_EQ (value, "") << "No state in the database, expected " << value; return; } EXPECT_EQ (stmt.Get<std::string> (0), value); CHECK (!stmt.Step ()); } }; TEST_F (SQLiteStorageSnapshotTests, SnapshotNotSupported) { Storage storage(":memory:"); storage.Initialise (); EXPECT_EQ (storage.GetSnapshot (), nullptr); } TEST_F (SQLiteStorageSnapshotTests, SnapshotsAreReadonly) { Storage storage(filename); storage.Initialise (); auto snapshot = storage.GetSnapshot (); ASSERT_NE (snapshot, nullptr); auto stmt = snapshot->Prepare (R"( INSERT INTO `xayagame_current` (`key`, `value`) VALUES ('foo', 'bar') )"); EXPECT_EQ (sqlite3_step (*stmt), SQLITE_READONLY); } TEST_F (SQLiteStorageSnapshotTests, MultipleSnapshots) { Storage storage(filename); storage.Initialise (); storage.BeginTransaction (); auto s1 = storage.GetSnapshot (); storage.SetCurrentGameState (hash, "first"); storage.CommitTransaction (); auto s2 = storage.GetSnapshot (); storage.BeginTransaction (); storage.SetCurrentGameState (hash, "second"); auto s3 = storage.GetSnapshot (); storage.CommitTransaction (); auto s4 = storage.GetSnapshot (); ExpectDatabaseState (*s1, ""); ExpectDatabaseState (*s2, "first"); ExpectDatabaseState (*s3, "first"); ExpectDatabaseState (*s4, "second"); ExpectDatabaseState (storage.GetDatabase (), "second"); } TEST_F (SQLiteStorageSnapshotTests, CloseWaitsForOutstandingSnapshots) { Storage storage(filename); storage.Initialise (); storage.BeginTransaction (); storage.SetCurrentGameState (hash, "state"); storage.CommitTransaction (); auto s1 = storage.GetSnapshot (); auto s2 = storage.GetSnapshot (); std::atomic<bool> done(false); auto clearJob = std::make_unique<std::thread> ([&] () { storage.Clear (); done = true; }); SleepSome (); ExpectDatabaseState (*s1, "state"); ExpectDatabaseState (*s2, "state"); EXPECT_FALSE (done); s1.reset (); s2.reset (); clearJob->join (); ExpectDatabaseState (storage.GetDatabase (), ""); } TEST_F (SQLiteStorageSnapshotTests, StatementsMustAllBeDestructed) { Storage storage(filename); storage.Initialise (); storage.BeginTransaction (); storage.SetCurrentGameState (hash, "state"); storage.CommitTransaction (); auto s = storage.GetSnapshot (); auto stmt = s->PrepareRo (R"( SELECT * FROM `xayagame_current` )"); /* Destructing the database while the statement is still around should CHECK fail. At the end of the test scope, the statement will be destructed before the snapshot, which is fine. */ EXPECT_DEATH (s.reset (), "statement is still in use"); } /* ************************************************************************** */ } // anonymous namespace } // namespace xaya
[ "d@domob.eu" ]
d@domob.eu
a2211c90b4053103923e7fd0379bb793baff8e73
ba5d1d776888be6ae9688d850f0445d80973ee8f
/public/soundsystem/snd_device.h
fa855897a2a9486fd6d1cb4a37c2ab367272e26a
[ "MIT" ]
permissive
BerntA/tfo-code
eb127b86111dce2b6f66e98c9476adc9ddbbd267
b82efd940246af8fe90cb76fa6a96bba42c277b7
refs/heads/master
2023-08-17T06:57:13.107323
2023-08-09T18:37:54
2023-08-09T18:37:54
41,260,457
16
5
MIT
2023-05-29T23:35:33
2015-08-23T17:52:50
C++
UTF-8
C++
false
false
4,100
h
//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: // // $Workfile: $ // $Date: $ // $NoKeywords: $ //===========================================================================// #ifndef SND_DEVICE_H #define SND_DEVICE_H #ifdef _WIN32 #pragma once #endif #include "tier0/platform.h" //----------------------------------------------------------------------------- // 4.28 fixed point stuff for real-time resampling //----------------------------------------------------------------------------- #define FIX_BITS 28 #define FIX_SCALE (1 << FIX_BITS) #define FIX_MASK ((1 << FIX_BITS)-1) #define FIX_FLOAT(a) ((int)((a) * FIX_SCALE)) #define FIX(a) (((int)(a)) << FIX_BITS) #define FIX_INTPART(a) (((int)(a)) >> FIX_BITS) #define FIX_FRACTION(a,b) (FIX(a)/(b)) #define FIX_FRACPART(a) ((a) & FIX_MASK) typedef unsigned int fixedint; //----------------------------------------------------------------------------- // sound rate defines //----------------------------------------------------------------------------- #define SOUND_DMA_SPEED 44100 // hardware playback rate #define SOUND_11k 11025 // 11khz sample rate #define SOUND_22k 22050 // 22khz sample rate #define SOUND_44k 44100 // 44khz sample rate #define SOUND_ALL_RATES 1 // mix all sample rates //----------------------------------------------------------------------------- // Information about the channel //----------------------------------------------------------------------------- struct channel_t { int leftvol; int rightvol; float pitch; }; //----------------------------------------------------------------------------- // The audio device is responsible for mixing //----------------------------------------------------------------------------- abstract_class IAudioDevice { public: // Add a virtual destructor to silence the clang warning. // This is harmless but not important since the only derived class // doesn't have a destructor. virtual ~IAudioDevice() {} // This initializes the sound hardware. true on success, false on failure virtual bool Init( void ) = 0; // This releases all sound hardware virtual void Shutdown( void ) = 0; // device parameters virtual const char *DeviceName( void ) const = 0; virtual int DeviceChannels( void ) const = 0; // 1 = mono, 2 = stereo virtual int DeviceSampleBits( void ) const = 0; // bits per sample (8 or 16) virtual int DeviceSampleBytes( void ) const = 0; // above / 8 virtual int DeviceSampleRate( void ) const = 0; // Actual DMA speed virtual int DeviceSampleCount( void ) const = 0; // Total samples in buffer // Called each time a new paint buffer is mixed (may be multiple times per frame) virtual void MixBegin( void ) = 0; // Main mixing routines virtual void Mix8Mono( channel_t *pChannel, char *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0; virtual void Mix8Stereo( channel_t *pChannel, char *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0; virtual void Mix16Mono( channel_t *pChannel, short *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0; virtual void Mix16Stereo( channel_t *pChannel, short *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0; // Size of the paint buffer in samples virtual int PaintBufferSampleCount( void ) const = 0; // Adds a mixer to be mixed virtual void AddSource( CAudioMixer *pSource ) = 0; // Stops all sounds virtual void StopSounds( void ) = 0; // Updates sound mixing virtual void Update( float time ) = 0; // Resets the device virtual void Flush( void ) = 0; virtual int FindSourceIndex( CAudioMixer *pSource ) = 0; virtual CAudioMixer *GetMixerForSource( CAudioSource *source ) = 0; virtual void FreeChannel( int channelIndex ) = 0; }; #endif // SND_DEVICE_H
[ "bernta1@msn.com" ]
bernta1@msn.com
13cdb74d373f3a36d11e2194954cc4ed1ba625a2
1af6b09e9c1aaefbf568c5fea9d3e93c7af92db5
/study/src/designmode/decorate.hpp
d6a369244d56e67306fd128800281d1ba259ac7f
[]
no_license
csdchen/git-blog
51d7a7638adc375553e0ee0a44423f719c79404e
aff542f5b6b81d88234ca7e8c979e70bc82e8d2a
refs/heads/master
2022-12-08T04:19:23.338608
2022-12-05T01:46:10
2022-12-05T01:46:10
228,734,267
0
0
null
null
null
null
GB18030
C++
false
false
1,657
hpp
#pragma once class Stream { public: virtual ~Stream() {} virtual void Read() = 0; virtual void Seek() = 0; virtual void Write() = 0; }; class FileStream { public: virtual void Read() { //读文件流 } virtual void Seek() { //定位文件流 } virtual void Write() { //写文件流 } }; //扩展操作 class FileBufferStream : FileStream { virtual void Read() { // 缓冲 // ... FileStream::Read(); } virtual void Seek() { // 缓冲 // ... FileStream::Seek(); } virtual void Write() { // 缓冲 // ... FileStream::Write(); } }; class CryptoFileStream :public FileStream { public: virtual void Read() { //额外的加密操作... FileStream::Read(); } virtual void Seek() { //额外的加密操作... FileStream::Seek(); } virtual void Write() { //额外的加密操作... FileStream::Write(); } }; class DecoratorStream { protected: DecoratorStream(Stream* stream) :m_stream(stream) {} protected: Stream* m_stream; }; class BufferStream : DecoratorStream { public: BufferStream(Stream* stream) :DecoratorStream(stream) {} virtual void Read() { // 缓冲 // ... m_stream->Read(); } virtual void Seek() { // 缓冲 // ... m_stream->Seek(); } virtual void Write() { // 缓冲 // ... m_stream->Read(); } }; class CryptoStream : public DecoratorStream { public: CryptoStream(Stream* stream) :DecoratorStream(stream) { } virtual char Read() { //额外的加密操作... m_stream->Read(); } virtual void Seek() { //额外的加密操作... m_stream->Seek(); } virtual void Write() { //额外的加密操作... m_stream->Write(); } };
[ "mrchenshangjin@163.com" ]
mrchenshangjin@163.com
62dd10709396f30f02497716de8ec81ae1380841
eec48c4b68c2c29f7c5d5253ec1c69d49515b8c2
/Old/Variation/Variation/Variation.cpp
39f834df1d68a850a63144dea438bd95dc124278
[]
no_license
nadarb/Competitive-Coding
e3465f8582f55ee5916a876fe82160ecffe920b3
a550734621780c4e4a9f4d427e09750b1386bd25
refs/heads/master
2021-06-11T10:15:15.927406
2016-12-23T15:14:46
2016-12-23T15:14:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
633
cpp
// Variation.cpp : Defines the entry point for the console application. // url : https://www.codechef.com/ZCOPRAC/problems/ZCO15002 #include <stdio.h> #include <iostream> #include <cmath> #include <algorithm> #include <functional> #include <vector> using namespace std; int main() { long N, K, i, j; long long ans; scanf("%ld%ld", &N, &K); vector<long> ip(N); for (i = 0;i < N;i++) { scanf("%ld", &ip[i]); } ans = 0; sort(ip.begin(), ip.end()); i = 0; j = 1; while (j < N&&i <= j) { while (j < N&&ip[j] - ip[i] < K) { j++; } if (j < N) ans += (N - j); i++; } printf("%lld\n", ans); return 0; }
[ "balaraveen nadar" ]
balaraveen nadar
d382a9f7f2bb3284f479a916127d0cb11eb15144
3148665ee67af72a30788750b06c7b8f5f2531b5
/matrix2x2.cpp
7f68a6df4714e2b835a7968191fb1f9b095e95ec
[]
no_license
UA-CSC433-Fall2018/matrix2d
621b688500c78abe04ed3855634be5dd0d00af5f
7d976c70cdf60d3ea53d0b40d5a5586f78533a1b
refs/heads/master
2020-03-31T10:08:14.129674
2018-10-09T00:03:00
2018-10-09T00:03:00
152,123,628
0
0
null
null
null
null
UTF-8
C++
false
false
4,015
cpp
/// /// \file vec2.cpp /// \brief 2D matrix class /// \author Joshua A. Levine <josh@email.arizona.edu> /// \date 10/08/18 /// /// This code defines a simple matrix2x2 class with some of the basic /// operations for arithmetic and utility functions. It builds on the /// two-dimensional vector class vec2.h /// /* *********************************************************************** Copyright (C) 2018, Joshua A. Levine University of Arizona 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 "matrix2x2.h" #include <cmath> #include <cstdio> matrix2x2::matrix2x2() { data[0] = vec2(); data[1] = vec2(); } matrix2x2::matrix2x2(const float* m) { data[0][0] = m[0]; data[0][1] = m[1]; data[1][0] = m[2]; data[1][1] = m[3]; } matrix2x2::matrix2x2(const matrix2x2& m) { data[0] = m[0]; data[1] = m[1]; } matrix2x2& matrix2x2::operator=(const matrix2x2& rhs) { data[0] = rhs[0]; data[1] = rhs[1]; return *this; } vec2& matrix2x2::operator[](int row) { return data[row]; } vec2 matrix2x2::operator[](int row) const { return data[row]; } matrix2x2 matrix2x2::transpose() const { matrix2x2 out; out.data[0] = vec2(data[0][0], data[1][0]); out.data[1] = vec2(data[0][1], data[1][1]); return out; } void matrix2x2::identity() { data[0] = vec2(1,0); data[1] = vec2(0,1); } void matrix2x2::clear() { data[0] = vec2(0,0); data[1] = vec2(0,0); } matrix2x2 matrix2x2::operator+(const matrix2x2& m) const { matrix2x2 out; out.data[0] = data[0] + m.data[0]; out.data[1] = data[1] + m.data[1]; return out; } matrix2x2 matrix2x2::operator-(const matrix2x2& m) const { matrix2x2 out; out.data[0] = data[0] - m.data[0]; out.data[1] = data[1] - m.data[1]; return out; } matrix2x2 matrix2x2::operator-() const { matrix2x2 out; out.data[0] = -data[0]; out.data[1] = -data[1]; return out; } matrix2x2 matrix2x2::operator*(const float f) const { matrix2x2 out; out.data[0] = data[0]*f; out.data[1] = data[1]*f; return out; } matrix2x2 operator*(const float f, const matrix2x2& m) { return m*f; } matrix2x2 matrix2x2::operator/(const float f) const { matrix2x2 out; out.data[0] = data[0]/f; out.data[1] = data[1]/f; return out; } vec2 matrix2x2::operator*(const vec2& v) const { vec2 out; out[0] = (*this)[0].dot(v); out[1] = (*this)[1].dot(v); return out; } matrix2x2 matrix2x2::operator*(const matrix2x2& m) const { matrix2x2 out; matrix2x2 T = m.transpose(); out.data[0][0] = (*this)[0].dot(T[0]); out.data[0][1] = (*this)[0].dot(T[1]); out.data[1][0] = (*this)[1].dot(T[0]); out.data[1][1] = (*this)[1].dot(T[1]); return out; } matrix2x2::operator std::string() const { std::string str = (*this)[0]; str = str + "\n" + (std::string) (*this)[1]; return str; } std::ostream& operator<<(std::ostream& os, const matrix2x2& m) { os << (std::string) m; return os; }
[ "joshua.a.levine@gmail.com" ]
joshua.a.levine@gmail.com
ee3df10f3f174681c503762696efa93860116df0
6bf99811d80e0ed3f7a93df015bb38342ab57467
/source/Scaleform.hpp
8192f926365629fde3800e72ce228a9ea299a500
[ "Zlib" ]
permissive
quickfingerz/scripthookvdotnet
ab22bbf46c27a38ec09f1851b6d67dec1a7f3e4f
5cc06e605b577feb9be0aa1e13ae8450e39e5a6c
refs/heads/master
2021-01-17T20:52:40.196681
2015-06-06T13:37:22
2015-06-06T13:37:22
36,217,447
0
0
null
2015-05-25T07:45:17
2015-05-25T07:45:16
null
UTF-8
C++
false
false
942
hpp
#pragma once #include "Vector3.hpp" namespace GTA { using namespace System::Collections::Generic; public ref class ScaleformArgumentTXD sealed { public: ScaleformArgumentTXD(System::String ^s) : txd(s) { } System::String ^txd; }; public ref class Scaleform sealed { public: Scaleform::Scaleform(int handle) : mHandle(handle) { } Scaleform::Scaleform() { } property int Handle { int get(); } bool Load(System::String ^scaleformID); void CallFunction(System::String ^function, ... array<Object^> ^arguments); void Render2D(); void Render2DScreenSpace(System::Drawing::PointF location, System::Drawing::PointF size); void Render3D(GTA::Math::Vector3 position, GTA::Math::Vector3 rotation, GTA::Math::Vector3 scale); void Render3DAdditive(GTA::Math::Vector3 position, GTA::Math::Vector3 rotation, GTA::Math::Vector3 scale); private: int mHandle; System::String ^mScaleformID; }; }
[ "mlgthatsme@hotmail.com.au" ]
mlgthatsme@hotmail.com.au
2cf603fd7589913217bef3b77e4279eacd1877d1
b7388fa0fe9912e8b24a62fe9255f698af17079b
/test/prefix_sum/RecursiveParallel/RecursiveParallelPrefixSum.h
67800c085abd8796c5853f2ec119825306156904
[]
no_license
ginkgo/AMP-LockFreeSkipList
2764b4f528ac6969f21ee3fd0e2ba2444d36e04c
dc68750f5c9fd6d2491e656161ac7c8073f5389c
refs/heads/master
2021-01-20T07:50:51.818369
2014-07-01T01:21:04
2014-07-01T01:21:04
20,526,178
3
0
null
null
null
null
UTF-8
C++
false
false
2,803
h
/* * RecursiveParallelPrefixSum.h * * Created on: Jun 28, 2012 * Author: Martin Wimmer * License: Boost Software License 1.0 */ #ifndef RECURSIVEPARALLELPREFIXSUM_H_ #define RECURSIVEPARALLELPREFIXSUM_H_ #include <iostream> #include <pheet/pheet.h> #include "RecursiveParallelPrefixSumOffsetTask.h" #include "RecursiveParallelPrefixSumPerformanceCounters.h" namespace pheet { template <class Pheet, size_t BlockSize> class RecursiveParallelPrefixSumImpl : public Pheet::Task { public: typedef RecursiveParallelPrefixSumImpl<Pheet, BlockSize> Self; typedef RecursiveParallelPrefixSumOffsetTask<Pheet, BlockSize> OffsetTask; typedef RecursiveParallelPrefixSumPerformanceCounters<Pheet> PerformanceCounters; RecursiveParallelPrefixSumImpl(unsigned int* data, size_t length) :data(data), length(length), step(1), root(true) { } RecursiveParallelPrefixSumImpl(unsigned int* data, size_t length, size_t step, bool root) :data(data), length(length), step(step), root(root) { } RecursiveParallelPrefixSumImpl(unsigned int* data, size_t length, PerformanceCounters& pc) :data(data), length(length), step(1), root(true), pc(pc) { } RecursiveParallelPrefixSumImpl(unsigned int* data, size_t length, size_t step, bool root, PerformanceCounters& pc) :data(data), length(length), step(step), root(root), pc(pc) { } virtual ~RecursiveParallelPrefixSumImpl() {} virtual void operator()() { if(length <= BlockSize) { for(size_t i = 1; i < length; ++i) { data[i*step] += data[(i - 1)*step]; } } else { size_t num_blocks = ((length - 1) / BlockSize) + 1; size_t half = BlockSize * (num_blocks >> 1); if(root) { {typename Pheet::Finish f; Pheet::template spawn<Self>(data, half, step, false, pc); Pheet::template spawn<Self>(data + half*step, length - half, step, false, pc); } //std::cout << data[1024] << std::endl; if(num_blocks > 2) Pheet::template finish<Self>(data + (BlockSize - 1)*step, num_blocks - 1, BlockSize * step, true, pc); // std::cout << data[1024] << std::endl; Pheet::template call<OffsetTask>(data + (BlockSize*step), length - BlockSize, step); } else { Pheet::template spawn<Self>(data, half, step, false, pc); Pheet::template spawn<Self>(data + half*step, length - half, step, false, pc); } } } static char const name[]; private: unsigned int* data; size_t length; size_t step; bool root; PerformanceCounters pc; }; template <class Pheet, size_t BlockSize> char const RecursiveParallelPrefixSumImpl<Pheet, BlockSize>::name[] = "RecursiveParallelPrefixSum"; template <class Pheet> using RecursiveParallelPrefixSum = RecursiveParallelPrefixSumImpl<Pheet, 4096>; } /* namespace pheet */ #endif /* RECURSIVEPARALLELPREFIXSUM_H_ */
[ "weber.t@cg.tuwien.at" ]
weber.t@cg.tuwien.at
dfc08b0d60a9e1aaadd940af404e40687c66d815
829b3f2d0ae685d01fe097c03bf5c1976cbc4723
/mediasoup/UtilsC.hpp
d48290d3c3c05f5e90aa384aa0a2c51af1c5d0a8
[ "Apache-2.0" ]
permissive
liyoung1992/mediasoup-sfu-cpp
f0f0321f8974beb1f4263c9e658402620d82385f
b76564e068626b0d675f5486e56da3d69151e287
refs/heads/main
2023-08-21T21:40:51.710022
2021-10-14T06:29:18
2021-10-14T06:29:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,712
hpp
#ifndef MSC_UTILS_HPP #define MSC_UTILS_HPP #include <cstdint> // uint32_t #include <ctime> // generator seed #include <random> // generators header #include <set> #include <sstream> // istringstream #include <string> #include <vector> namespace mediasoupclient { namespace UtilsC { template<typename T> T getRandomInteger(T min, T max); std::string getRandomInteger(size_t len); std::vector<std::string> split(const std::string& s, char delimiter); std::string join(const std::vector<std::string>& v, char delimiter); std::string join(const std::vector<uint32_t>& v, char delimiter); // https://stackoverflow.com/a/447307/4827838. bool isInt(const std::string& str); bool isFloat(const std::string& str); int toInt(const std::string& str); float toFloat(const std::string& str); /* Inline utils implementations */ template<typename T> inline T getRandomInteger(T min, T max) { // Seed with time. static unsigned int seed = time(nullptr); // Engine based on the Mersenne Twister 19937 (64 bits). static std::mt19937_64 rng(seed); // Uniform distribution for integers in the [min, max) range. std::uniform_int_distribution<T> dis(min, max); return dis(rng); } inline std::string getRandomString(size_t len) { /* clang-format off */ static std::vector<char> chars = { '0','1','2','3','4','5','6','7','8','9', 'a','b','c','d','e','f','g','h','i','j', 'k','l','m','n','o','p','q','r','s','t', 'u','v','w','x','y','z', 'A','B','C','D','E','F','G','H','I','J', 'K','L','M','N','O','P','Q','R','S','T', 'U','V','W','X','Y','Z' }; /* clang-format on */ // Seed with time. static unsigned int seed = (unsigned int)time(nullptr); // Engine based on the Mersenne Twister 19937 (64 bits). static std::mt19937_64 rng(seed); // Uniform distribution for integers in the [min, max) range. std::uniform_int_distribution<std::string::size_type> dis(0, chars.size() - 1); std::string s; s.reserve(len); while ((len--) != 0u) s += chars[dis(rng)]; return s; } inline std::vector<std::string> split(const std::string& s, char delimiter) { std::vector<std::string> tokens; std::string token; std::istringstream tokenStream(s); while (std::getline(tokenStream, token, delimiter)) { tokens.push_back(token); } return tokens; } inline std::string join(const std::vector<std::string>& v, char delimiter) { std::string s; auto it = v.begin(); for (; it != v.end(); ++it) { s += *it; if (it != v.end() - 1) s += delimiter; } return s; } inline std::string join(const std::vector<uint32_t>& v, char delimiter) { std::string s; auto it = v.begin(); for (; it != v.end(); ++it) { s += std::to_string(*it); if (it != v.end() - 1) s += delimiter; } return s; } inline bool isInt(const std::string& str) { std::istringstream iss(str); int64_t l; iss >> std::noskipws >> l; return iss.eof() && !iss.fail(); } inline bool isFloat(const std::string& str) { std::istringstream iss(str); float f; iss >> std::noskipws >> f; return iss.eof() && !iss.fail(); } inline int toInt(const std::string& str) { std::istringstream iss(str); int64_t ll; iss >> std::noskipws >> ll; if (iss.eof() && !iss.fail()) return (int)std::stoll(str); return 0; } inline float toFloat(const std::string& str) { std::istringstream iss(str); double d; iss >> std::noskipws >> d; if (iss.eof() && !iss.fail()) return (float)std::stod(str); return 0.0f; } } // namespace Utils } // namespace mediasoupclient #endif
[ "yanhua133@126.com" ]
yanhua133@126.com
2b0ec516f0268822237e2536c9b8169f96cf46f7
049a513af55e9af3849616b54f7613ebfba0e260
/LBCards/BLACKPILLHUB/I2CRPT_I2CIO8Blink/I2CRPT_I2CIO8Blink.ino
5b7d15e0ef31ce1f2b051039c43ffb20f5664dd5
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
farukmenguc/lb-Arduino-Code
d087b79620be2ebff447e6a27b5e4ad8f2ce7975
70f33db4717ea5ed1d33ff79c1516344959c7dbb
refs/heads/master
2023-08-05T11:11:44.528540
2021-09-20T00:25:03
2021-09-20T00:25:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,585
ino
//////////////////////////////////////////////////////////////////////// // I2CRPT_I2CIO8Blink Example code // Blink LED //////////////////////////////////////////////////////////////////////// // Hardware // Arduino NANO Breakout board // http://land-boards.com/blwiki/index.php?title=NANO-BKOUT // or STM32 Blue Pill board // http://land-boards.com/blwiki/index.php?title=STM32 // I2C Repeater // http://land-boards.com/blwiki/index.php?title=I2C-RPT // I2CIO-8 - I2C Expander with 4 LEDs/4 jumpers // http://land-boards.com/blwiki/index.php?title=I2CIO-8 //////////////////////////////////////////////////////////////////////// // 2019-03-03 - Tested with SMT32F103C Blue Pill // 2020-01-30 - Built for STM32F4XX board //////////////////////////////////////////////////////////////////////// #include <Wire.h> #include "LandBoards_I2CIO8.h" #include "LandBoards_I2CRPT01.h" LandBoards_I2CIO8 myI2CIO8; LandBoards_I2CRPT01 mux; //////////////////////////////////////////////////////////////////////// // setup() //////////////////////////////////////////////////////////////////////// void setup() { uint8_t port; mux.begin(0); // start the mux mux.setI2CChannel(1); myI2CIO8.begin(0); // use default address 0 myI2CIO8.pinMode(0, OUTPUT); } //////////////////////////////////////////////////////////////////////// // loop() // flip the pin #0 up and down //////////////////////////////////////////////////////////////////////// void loop() { myI2CIO8.writeLED(LED0, LOW); delay(250); myI2CIO8.writeLED(LED0, HIGH); delay(250); }
[ "doug@douglasgilliland.com" ]
doug@douglasgilliland.com
366988e4d7eb1b92dd9966e18b5b4eb4b55c2c44
07b21352f483fefbc7ee10f11a018b47da7cb3be
/Augmented_climbing_wall/Cliker.h
04e69dcf087bbcf583f2ef024fbf9aa18dfb6c33
[]
no_license
kurortnik00/Augmented_climbing_wall
aa80a972ee6100c9753a98d0cca9b900154482aa
f1b633657c65b722daa01baa9cdc0e6be96c8f33
refs/heads/master
2020-09-14T07:46:38.211464
2019-12-25T10:23:06
2019-12-25T10:23:06
223,068,679
0
1
null
2019-12-25T10:46:30
2019-11-21T02:15:48
C++
UTF-8
C++
false
false
2,074
h
#pragma once #include "stdafx.h" #include "body_tracker.h" #include "Kinect.h" #include "mainWindow.h" #include "server.h" #include <fstream> #include <sstream> #include <string> class Cliker { public: //Cliker(); //~Cliker(); static void Init(); static void reInit(); static void load(std::string path); static bool getClik(sf::Vector2f center, float radius, bool buttonPress, myServer::GAMES game); static bool getClik(float x, float y, float height, float width); static BodyTracker &getKinectApplication(); static float kinectTranform_X_Cordinates(float x); static float kinectTranform_Y_Cordinates(float y); static void increaseTrashHold(float increaseValue); static sf::Vector2f _sumValue; static sf::Vector2f _multValue; static float _trashHold; static std::vector<sf::Vector2f> additional_sumValue_SmashIt; static std::vector<sf::Vector2f> additional_sumValue_Labyrinth; static std::vector<sf::Vector2f> additional_sumValue_Aerohokey; static std::vector<sf::Vector2f> additional_multValue_SmashIt; static std::vector<sf::Vector2f> additional_multValue_Labyrinth; static std::vector<sf::Vector2f> additional_multValue_Aerohokey; private: bool Update(sf::Event& event, sf::Vector2f center); static bool _kinectControl; static float dist2(sf::Vector2f const& p1, sf::Vector2f const& p2); enum tracking_Type { allJoints, mainPointAvarage, allJointsTimeAvarage, mainPointTimeAvarage }; static bool kinectUpdateActions(int joint_Count, tracking_Type tT, sf::Vector2f center, float radius, myServer::GAMES game); //depth from sensor where interaction starts static BodyTracker kinectApplication; static sf::Vector2f joint_xy; static float joint_z; static sf::Clock delayClock; enum { SPINEBASE, SPINEMID, NECK, HEAD, SHOULDERLEFT, ELBOWLEFT, WRISTLEFT, HANDLEFT, SHOULDERRIGHT, ELBOWRIGHT, WRISTRIGHT, HANDRIGHT, HIPLEFT, KNEELEFT, ANKLELEFT, FOOTLEFT, HIPRIGHT, KNEERIGHT, ANKLERIGHT, FOOTRIGHT, SPINESHOULDER, HANDTIPLEFT, THUMBLEFT, HANDTIPRIGHT, THUMBRIGHT, }; };
[ "kurortnik00@gmail.com" ]
kurortnik00@gmail.com
9eb1d139b4c853a4301d4b9f0dcf1392cf08b155
16ee97007e8c05bb661338a7e7386763c8d99d55
/ccvt_optimizer.h
d27eddd9192a82ed07288499e583ff5143affcba
[]
no_license
yuemos/Graduation-Project
9ac2ccff2bf20f820ce1ca9d84c041602a3e95dd
8064bcd27c0047ff3c50d16eb2e3fb3ba4c4bfcb
refs/heads/master
2023-05-01T20:24:58.341734
2021-05-23T06:35:17
2021-05-23T06:35:17
369,978,233
0
0
null
null
null
null
UTF-8
C++
false
false
25,952
h
#pragma once #ifndef CCVT_OPTIMIZER_H #define CCVT_OPTIMIZER_H #include <algorithm> #include <assert.h> #include <limits> #include <list> #include <math.h> #include <map> #include <list> #include <queue> #include <vector> namespace ccvt { template<class Site, class Point, class Metric> class Optimizer { private: struct Entry; /* The initialization of the optimizer uses a kd-tree to initially assign the points to the sites. A faster method is to use the ordinary Voronoi tessellation for that matter. However, the kd-tree is used because it can easily be implemented for the n-dimensional case. */ class KdTree {//KdTree public: KdTree(std::vector<Entry> &entries, const Metric& metric, const int dimensions) : dimensions_(dimensions), root_(NULL), metric_(metric), lastNearestNeighborNode_(NULL) { if (!entries.empty()) { std::vector<Entry*> entriesPtr(entries.size()); for (int i = 0; i < static_cast<int>(entriesPtr.size()); ++i) { entriesPtr[i] = &entries[i]; } build(root_, entriesPtr, 0, static_cast<int>(entriesPtr.size() - 1), 0); } } ~KdTree() { if (root_ != NULL) { delete root_; } } bool empty() { return root_ == NULL || root_->disabled; } Entry* nearest_neighbor(const Point& point) { if (root_ == NULL || root_->disabled) { return NULL; } double minDistance = std::numeric_limits<double>::max(); NearestNeighborResult result = nearest_neighbor(root_, point, 0, minDistance); lastNearestNeighborNode_ = result.first; return result.second; } void disable_last_nearest_neighbor_node() { if (lastNearestNeighborNode_ != NULL) { lastNearestNeighborNode_->disabled = true; Node* parentNode = lastNearestNeighborNode_->parent; while (parentNode != NULL && parentNode->left->disabled && parentNode->right->disabled) { parentNode->disabled = true; parentNode = parentNode->parent; } lastNearestNeighborNode_ = NULL; } } private: KdTree(const KdTree& kdTree); KdTree& operator=(const KdTree& kdTree); struct Node { Node() : median(0), left(NULL), right(NULL), entry(NULL), parent(NULL), disabled(false) { } ~Node() { if (left != NULL) { delete left; } if (right != NULL) { delete right; } } double median; Node* left; Node* right; Entry* entry; Node* parent; bool disabled; }; typedef std::pair<Node*, Entry*> NearestNeighborResult; struct Less { Less(int dimension) : dimension(dimension) { } bool operator()(const Entry* p1, const Entry* p2) { return p1->site->location[dimension] < p2->site->location[dimension]; } int dimension; }; void build(Node*& node, std::vector<Entry*>& entries, const int min, const int max, const int depth) { node = new Node(); if (min == max) { node->entry = entries[min]; return; } std::sort(entries.begin() + min, entries.begin() + max + 1, Less(depth % dimensions_));//��Χ��������dimensions int medianIndex = (min + max) / 2; node->median = (entries[medianIndex]->site->location[depth % dimensions_] + entries[medianIndex + 1]->site->location[depth % dimensions_]) / 2; build(node->left, entries, min, medianIndex, depth + 1); build(node->right, entries, medianIndex + 1, max, depth + 1); node->left->parent = node; node->right->parent = node; } NearestNeighborResult nearest_neighbor(Node* node, const Point& point, const int depth, double& minDistance) { if (node->disabled) { return NearestNeighborResult(reinterpret_cast<Node*>(NULL), reinterpret_cast<Entry*>(NULL)); } if (node->entry != NULL) { minDistance = metric_.distance(point, node->entry->site->location); return NearestNeighborResult(node, node->entry); } Node* child; double otherDistance; if (point[depth % dimensions_] <= node->median) { child = node->left; otherDistance = node->median - point[depth % dimensions_]; } else { child = node->right; otherDistance = point[depth % dimensions_] - node->median; } NearestNeighborResult result = nearest_neighbor(child, point, depth + 1, minDistance); if (minDistance > otherDistance) { double newMinDistance = minDistance; Node* otherChild = node->left; if (otherChild == child) { otherChild = node->right; } NearestNeighborResult newResult = nearest_neighbor(otherChild, point, depth + 1, newMinDistance); if (newMinDistance < minDistance) { result = newResult; minDistance = newMinDistance; } } return result; } const int dimensions_; Node* root_; const Metric& metric_; Node* lastNearestNeighborNode_; }; public: Optimizer() { } void clear() { entries_.clear(); mapping_.clear(); sites_.clear(); metric_ = Metric(); } void initialize(typename std::list<Site>& sites, typename std::list<Point>& points, const Metric& metric) { clear(); metric_ = metric; int sitesSize = static_cast<int>(sites.size()); sites_.reserve(sitesSize);//锟斤拷锟斤拷站锟斤拷锟斤拷目锟斤拷锟节达拷占锟?锟斤拷锟芥储锟斤拷锟斤拷锟斤拷锟斤拷站锟斤拷 entries_.reserve(sitesSize);// int sumCapacities = 0; for (int i = 0; i < sitesSize; ++i) { Site& site = sites.front(); sumCapacities += site.capacity; if (site.capacity > 0) { sites_.push_back(site); entries_.push_back(Entry(&sites_.back())); mapping_.insert(std::make_pair(site.id, &entries_.back())); } sites.pop_front(); } assert(sumCapacities == points.size()); // the sum of the site capacities must be equal to the number of points sites_.resize(sites_.size());//锟斤拷锟斤拷站锟斤拷锟斤拷锟斤拷锟斤拷占锟节达拷锟叫? entries_.resize(entries_.size()); KdTree kdTree(entries_, metric_, Point::D);//锟斤拷锟斤拷Kd锟斤拷 while (!points.empty() && !kdTree.empty()) { const Point& point = points.back(); //std::cout << point.x << " " << point.y << std::endl; Entry* entry = kdTree.nearest_neighbor(point); entry->points.push_back(point); if (static_cast<int>(entry->points.size()) == entry->site->capacity) { entry->points.resize(entry->points.size()); kdTree.disable_last_nearest_neighbor_node(); } points.pop_back(); } for (unsigned int i = 0; i < entries_.size(); ++i) { entries_[i].energy = 0; int pointsSize = static_cast<int>(entries_[i].points.size()); for (int j = 0; j < pointsSize; ++j) { entries_[i].energy += energy(entries_[i].points[j], entries_[i].site); } entries_[i].update(metric_); } } bool optimize(const bool centroidalize) { int entriesSize = static_cast<int>(entries_.size()); std::vector<bool> stability(entriesSize, true); for (int i = 0; i < entriesSize; ++i) { for (int j = i + 1; j < entriesSize; ++j) { Entry* entry1 = &entries_[i]; Entry* entry2 = &entries_[j]; // if (entry1->stable && entry2->stable) { // std::cout << "OK-" << std::endl; // } if (entry1->stable && entry2->stable || metric_.distance(entry1->bounding.center, entry2->bounding.center) > entry1->bounding.radius + entry2->bounding.radius) { continue; } if (entry1->points.size() > entry2->points.size()) { std::swap(entry1, entry2); } Site* site1 = entry1->site; Site* site2 = entry2->site; //std::cout << site1->location.x << " " << site2->location.x << std::endl; std::vector<Point>* points1 = &entry1->points; std::vector<Point>* points2 = &entry2->points; double maxSquaredRadius = std::max(entry1->bounding.squaredRadius, entry2->bounding.squaredRadius); //printf("%d %d %f\n", i, j, maxSquaredRadius); typename Candidate::Vector candidates1(points1->size()); int size = static_cast<int>(points1->size()); int count = 0; double testE = 0; for (int k = 0; k < size; ++k) { Point& point = (*points1)[k]; if (metric_.distance_square(point, entry2->bounding.center) <= maxSquaredRadius) { candidates1[count++] = Candidate(&point, energy(point, site1), energy(point, site2)); //forecast the next location and calculate the max deltaE Point p(point.x, point.y); testE = std::max(testE, energy(p, site1) - energy(p, site2)); } } if (count == 0) { continue; } candidates1.resize(count); std::make_heap(candidates1.begin(), candidates1.end()); //std::cout << "OK1"<<std::endl; double minEnergy = -(candidates1.front().energySelf - candidates1.front().energyOther); //std::cout << minEnergy << std::endl; typename Candidate::Vector candidates2(points2->size()); size = static_cast<int>(points2->size()); count = 0; for (int k = 0; k < size; ++k) { Point& point = (*points2)[k]; if (metric_.distance_square(point, entry1->bounding.center) <= maxSquaredRadius) { double eSelf = energy(point, site2); double eOther = energy(point, site1); if (eSelf - eOther > minEnergy) { candidates2[count++] = Candidate(&point, eSelf, eOther); Point p(point.x, point.y); testE = std::max(testE, eSelf - eOther); } } } if (count == 0) { continue; } candidates2.resize(count); std::make_heap(candidates2.begin(), candidates2.end()); //std::cout << "OK2" << std::endl; int maxSwaps = static_cast<int>(std::min(candidates1.size(), candidates2.size())); int swaps; for (swaps = 0; swaps < maxSwaps; ++swaps) { Candidate& candidate1 = candidates1.front(); Candidate& candidate2 = candidates2.front(); if (candidate1.energySelf - candidate1.energyOther + candidate2.energySelf - candidate2.energyOther <= 0) { break; } std::swap(*candidate1.point, *candidate2.point); entry1->energy += candidate2.energyOther - candidate1.energySelf; entry2->energy += candidate1.energyOther - candidate2.energySelf; std::pop_heap(candidates1.begin(), candidates1.end() - swaps); std::pop_heap(candidates2.begin(), candidates2.end() - swaps); } if (swaps > 0) { num_swap += swaps; stability[i] = false; stability[j] = false; if (centroidalize) { entry1->site->location = metric_.centroid(entry1->site->location, entry1->points); entry2->site->location = metric_.centroid(entry2->site->location, entry2->points); } entry1->update(metric_); entry2->update(metric_); } } } bool stable = true; for (int i = 0; i < entriesSize; ++i) { entries_[i].stable = stability[i]; stable &= stability[i]; } return stable; } double energy() const { double e = 0; int entriesSize = static_cast<int>(entries_.size()); for (int i = 0; i < entriesSize; ++i) { e += entries_[i].energy; } return e; } inline double site_energy(const int id) const { typename Entry::MapPtr::const_iterator it = mapping_.find(id); if (it == mapping_.end()) { return 0; } return it->second->energy; } inline const std::vector<Point>* site_points(const int id) const { typename Entry::MapPtr::const_iterator it = mapping_.find(id); if (it == mapping_.end()) { return NULL; } return &it->second->points; } inline bool site_stable(const int id) const { typename Entry::MapPtr::const_iterator it = mapping_.find(id); return it == mapping_.end() || it->second->stable; } inline const std::vector<Site>& sites() { return sites_; } inline const double x_of_sites(int id) { return entries_[id].site->location.x; } inline const double y_of_sites(int id) { return entries_[id].site->location.y; } inline const std::vector<Point>& entryPoint(int id) { return entries_[id].points; } inline void update_site_location(const int id, const Point& location) { typename Entry::MapPtr::const_iterator it = mapping_.find(id); typename Entry::MapPtr::const_iterator it = mapping_.find(id); if (it != mapping_.end()) { it->second->site->location = location; it->second->update(metric_); } } inline void updatePointFather() { int entriesSize = static_cast<int>(entries_.size()); for (int i = 0; i < entriesSize; i++) { Entry* entry = &entries_[i]; std::vector<Point>* points = &entry->points; int size = static_cast<int>(points->size()); for (int j = 0; j < size; j++) { Point& point = (*points)[j]; point.changeFather(entry->site -> id); //std::cout << (*points)[j].getFather() << std::endl; } } } inline void updatePointLocation() { int entriesSize = static_cast<int>(entries_.size()); for (int i = 0; i < entriesSize; i++) { Entry* entry = &entries_[i]; entry->stable = false; std::vector<Point>* points = &entry->points; int size = static_cast<int>(points->size()); for (int j = 0; j < size; j++) { Point& point = (*points)[j]; //std::cout << point.x << " " << point.y << "||"; point.update(); checkBox(point,10.0/100); //std::cout << point.father << std::endl; //std::cout << point.x << " " << point.y << std::endl; } } } inline int getSwapNumber() { int num = num_swap; num_swap = 0; return num; } inline void initializeGird(const int n,const double L) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { Grids.push_back(Grid(i, j, L)); } } } inline void clear2() { for (int i = 0; i < Grids.size(); i++) { std::vector<std::vector<Point2>>().swap(Grids[i].points); } std::priority_queue<SitePair>().swap(sitePairs); std::vector<SitePairPoints>().swap(sitePairsPoints); } inline void checkBox(const Point2 p,const double L) { int n = Grids.size(); n = sqrt(n); int x = (int)(p.x / L); //std::cout << p.x<<" "<<p.y<<" "<<L << " "; if (x < 0) { x = 0; } if (x > n - 1) { x = n - 1; } int y = (int)(p.y / L); if (y < 0) { y = 0; } if (y > n-1) { y = n-1; } Grids[x*n + y].input(p); //std::cout << x << " " << y << " "; //std::cout << x * n + y << std::endl; } inline void checkOrder() { //扫描一遍所有的格子,把有两个以上格子的点提出来 for (int i = 0; i < Grids.size(); i++) { if (Grids[i].used < 2) { continue; } std::vector<std::vector<Point2>> p=Grids[i].points; int num_p = static_cast<int>(p.size()); //std::cout << i<<" "<<num_p << std::endl; for (int j = 0; j < num_p; j++) { for (int k = j + 1; k < num_p; k++) { //std::cout << j << " " << k << std::endl; std::vector<Point2> points1 = p[j]; std::vector<Point2> points2 = p[k]; if (points1.size() > points2.size()) { std::swap(points1, points2); } int site1 = points1.front().father; int site2 = points2.front().father; int num = checkSitePair(site1, site2); if (num == -1) { SitePairPoints spp(site1, site2); for (int l = 0; l < points1.size(); l++) { spp.points1.push_back(points1[l]); } for (int l = 0; l < points2.size(); l++) { spp.points2.push_back(points2[l]); } sitePairsPoints.push_back(spp); } else { for (int l = 0; l < points1.size(); l++) { sitePairsPoints[num].points1.push_back(points1[l]); } for (int l = 0; l < points2.size(); l++) { sitePairsPoints[num].points2.push_back(points2[l]); } } } } } int sitePairsPointsSize = static_cast<int>(sitePairsPoints.size()); for (int i = 0; i < sitePairsPointsSize; i++) { Entry* entry1 = &entries_[sitePairsPoints[i].site1]; Entry* entry2 = &entries_[sitePairsPoints[i].site2]; Site* site1 = entry1->site; Site* site2 = entry2->site; std::vector<Point2>* points1 = &sitePairsPoints[i].points1; std::vector<Point2>* points2 = &sitePairsPoints[i].points2; typename Candidate::Vector candidates1(points1->size()); int size = static_cast<int>(points1->size()); for (int l = 0; l < size; l++) { Point& point = (*points1)[l]; candidates1[l] = Candidate(&point, energy(point, site1), energy(point, site2)); } std::make_heap(candidates1.begin(), candidates1.end()); double minEnergy = -(candidates1.front().energySelf - candidates1.front().energyOther); typename Candidate::Vector candidates2(points2->size()); size = static_cast<int>(points2->size()); for (int l = 0; l < size; l++) { Point& point = (*points2)[l]; double eSelf = energy(point, site2); double eOther = energy(point, site1); if (eSelf - eOther > minEnergy) { candidates2[l] = Candidate(&point, eSelf, eOther); } } std::make_heap(candidates2.begin(), candidates2.end()); int maxSwaps = static_cast<int>(std::min(candidates1.size(), candidates2.size())); int swaps = 0; double deltaEnergy = 0; for (swaps = 0; swaps < maxSwaps; swaps++) { Candidate& candidate1 = candidates1.front(); Candidate& candidate2 = candidates2.front(); if (candidate1.energySelf - candidate1.energyOther + candidate2.energySelf - candidate2.energyOther <= 0) { break; } deltaEnergy += candidate1.energySelf - candidate1.energyOther + candidate2.energySelf - candidate2.energyOther; std::pop_heap(candidates1.begin(), candidates1.end() - swaps); std::pop_heap(candidates2.begin(), candidates2.end() - swaps); } SitePair sp(sitePairsPoints[i].site1, sitePairsPoints[i].site2, deltaEnergy); sitePairs.push(sp); } } inline int checkSitePair(const int site1, const int site2) { for (int i = 0; i < sitePairsPoints.size(); i++) { SitePairPoints spp = sitePairsPoints[i]; if (spp.site1 == site1 && spp.site2 == site2) { return i; } } return -1; } inline bool myOptimize() { std::vector<bool> stability(entries_.size(), true); std::priority_queue<SitePair> sps; while (!sitePairs.empty()) { SitePair sp = sitePairs.top(); sitePairs.pop(); sps.push(sp); Entry* entry1 = &entries_[sp.site1]; Entry* entry2 = &entries_[sp.site2]; if (entry1->stable && entry2->stable || metric_.distance(entry1->bounding.center, entry2->bounding.center) > entry1->bounding.radius + entry2->bounding.radius) { continue; } if (entry1->points.size() > entry2->points.size()) { std::swap(entry1, entry2); } Site* site1 = entry1->site; Site* site2 = entry2->site; //std::cout << site1->location.x << " " << site2->location.x << std::endl; std::vector<Point>* points1 = &entry1->points; std::vector<Point>* points2 = &entry2->points; double maxSquaredRadius = std::max(entry1->bounding.squaredRadius, entry2->bounding.squaredRadius); //printf("%d %d %f\n", i, j, maxSquaredRadius); typename Candidate::Vector candidates1(points1->size()); int size = static_cast<int>(points1->size()); int count = 0; for (int k = 0; k < size; ++k) { Point& point = (*points1)[k]; if (metric_.distance_square(point, entry2->bounding.center) <= maxSquaredRadius) { candidates1[count++] = Candidate(&point, energy(point, site1), energy(point, site2)); } } if (count == 0) { continue; } candidates1.resize(count); std::make_heap(candidates1.begin(), candidates1.end()); //std::cout << "OK1"<<std::endl; double minEnergy = -(candidates1.front().energySelf - candidates1.front().energyOther); //std::cout << minEnergy << std::endl; typename Candidate::Vector candidates2(points2->size()); size = static_cast<int>(points2->size()); count = 0; for (int k = 0; k < size; ++k) { Point& point = (*points2)[k]; if (metric_.distance_square(point, entry1->bounding.center) <= maxSquaredRadius) { double eSelf = energy(point, site2); double eOther = energy(point, site1); if (eSelf - eOther > minEnergy) { candidates2[count++] = Candidate(&point, eSelf, eOther); } } } if (count == 0) { continue; } candidates2.resize(count); std::make_heap(candidates2.begin(), candidates2.end()); //std::cout << "OK2" << std::endl; int maxSwaps = static_cast<int>(std::min(candidates1.size(), candidates2.size())); int swaps; for (swaps = 0; swaps < maxSwaps; ++swaps) { Candidate& candidate1 = candidates1.front(); Candidate& candidate2 = candidates2.front(); if (candidate1.energySelf - candidate1.energyOther + candidate2.energySelf - candidate2.energyOther <= 0) { break; } std::swap(*candidate1.point, *candidate2.point); entry1->energy += candidate2.energyOther - candidate1.energySelf; entry2->energy += candidate1.energyOther - candidate2.energySelf; std::pop_heap(candidates1.begin(), candidates1.end() - swaps); std::pop_heap(candidates2.begin(), candidates2.end() - swaps); } if (swaps > 0) { num_swap += swaps; stability[sp.site1] = false; stability[sp.site2] = false; entry1->update(metric_); entry2->update(metric_); } } bool stable = true; for (int i = 0; i < entries_.size(); ++i) { entries_[i].stable = stability[i]; stable &= stability[i]; } std::swap(sps, sitePairs); return stable; } private: public: struct Bounding { Bounding() : radius(0), squaredRadius(0) { } Bounding(const Point& center, const double radius) : center(center), radius(radius), squaredRadius(radius * radius) { } void update(const Point& site, const typename std::vector<Point>& points, const Metric& metric) { center = site; squaredRadius = 0; int pointsSize = static_cast<int>(points.size()); for (int i = 0; i < pointsSize; ++i) { squaredRadius = std::max(squaredRadius, metric.distance_square(center, points[i])); //printf("(%d,%d) (%d,%d) %d\n", center.x,center.y,points[i].x,points[i].y,metric.distance_square(center, points[i])); } radius = sqrt(squaredRadius); } Point center; double radius; double squaredRadius; }; struct Entry { typedef std::map<int, Entry*> MapPtr; typedef std::vector<Entry> Vector; Entry() : site(NULL), stable(false) { } Entry(Site *const site) : bounding(site->location, 0), site(site), stable(false) { } void update(const Metric& metric) { stable = false; bounding.update(site->location, points, metric); } Bounding bounding; std::vector<Point> points; Site* site; bool stable; double energy; }; struct Candidate { typedef std::vector<Candidate> Vector; Candidate() : point(NULL), energySelf(0), energyOther(0) { } Candidate(Point *const point, const double energySelf, const double energyOther) : point(point), energySelf(energySelf), energyOther(energyOther) { } inline bool operator<(const Candidate& candidate) const { return energySelf - energyOther < candidate.energySelf - candidate.energyOther; } Point* point; double energySelf; double energyOther; }; //The grid stores the points allocated to this grid struct Grid { int num_x, num_y; int used; double L; std::vector<std::vector<Point2>> points; Grid(const int x, const int y, const double L) :num_x(x), num_y(y), L(L), used(0) { } void input(const Point2 p) { if (used != 0) { for (int i = 0; i < points.size(); i++) { if (points[i][0].father == p.father) { points[i].push_back(p); return; } } used++; std::vector<Point2> vp; vp.push_back(p); points.push_back(vp); } else { used++; std::vector<Point2> vp; vp.push_back(p); points.push_back(vp); } } }; struct SitePair { int site1, site2; double deltaE; SitePair(const int site1, const int site2,const double deltaE) :site1(site1), site2(site2), deltaE(deltaE) { } inline bool operator<(const SitePair& sitePair) const { return deltaE < sitePair.deltaE; } }; struct SitePairPoints { int site1, site2; std::vector<Point2> points1; std::vector<Point2> points2; SitePairPoints(const int site1, const int site2) :site1(site1), site2(site2) { } }; inline double energy(const Point& point, const Site *const site) const { return metric_.distance_square(point, site->location); } int num_swap = 0; Metric metric_; typename Entry::Vector entries_; typename Entry::MapPtr mapping_; typename std::vector<Site> sites_; std::vector<Grid> Grids; std::priority_queue<SitePair> sitePairs;//site std::vector<SitePairPoints> sitePairsPoints; }; } #endif // CCVT_OPTIMIZER_H
[ "noreply@github.com" ]
yuemos.noreply@github.com
4cfe7e7d420a62339fa7bfd6282c1193e8979ffd
8424d627b1e9367fe1c2bc6e6796791f8c4b7783
/265/265.old.cpp
20967638873943f1249f2b8fb28198576a2e216d
[]
no_license
lld2006/my-c---practice-project
72d309f378dea1aaf16ffedf161962684ef25aef
c7e133c79528340f40f1a7192a89956bcc11dd00
refs/heads/master
2020-12-25T17:37:28.171658
2018-01-21T08:15:49
2018-01-21T08:15:49
2,707,121
0
0
null
null
null
null
UTF-8
C++
false
false
1,252
cpp
#include <cstdio> #include <vector> #include <cassert> #include "../lib/typedef.h" using namespace std; int ndig = 5; int maxp = 32; int mod = 16; i64 searchCircle(vector<int> bvec, vector<int> flags, int pcurr, int cvalue){ i64 sum = 0; if(pcurr == maxp -1){ for(int i =0; i< ndig -1; ++i){ cvalue %= mod; cvalue *= 2; if(flags[cvalue] == 1) return 0; flags[cvalue] = 1; } for(unsigned int i = 0; i< bvec.size(); ++i){ sum *= 2; sum += bvec[i]; } return sum; } ++pcurr; int ct = cvalue% mod; ct *= 2; for(int i = 0; i < 2; ++i){ int ct2 = ct + i; if(flags[ct2]) continue; vector<int> ft(flags); vector<int> bt(bvec); ft[ct2] = 1; bt[pcurr] = i; sum += searchCircle(bt, ft, pcurr, ct2); } return sum; } int main(){ vector<int> flags; flags.resize(32,0); flags[0] = 1; flags[1] = 1; vector<int> bvec; bvec.resize(maxp, 0); bvec[ndig] = 1; // the initial setup part is done // start from 0 1 the rest need to search; i64 sum = searchCircle(bvec, flags, ndig, 1); printf("%lld\n", sum); }
[ "txdqpal@hotmail.com" ]
txdqpal@hotmail.com
7de246ad61477ecb5e159c8620bc9e9cf0104d49
19164bf117ecb486c94311cb8b2936309b363514
/Leetcode/Unique_email_addresses.cpp
48ae4c8edc0ce1afeb585bcaaef03c89dcba25a0
[]
no_license
geekyanurag/Coding-Interview-Preparation
10a3b5d9c2a9b71483846c0f51751cef24baa2e4
24f11e8ddc9c7c573aa961a9ebb3afd16234a27b
refs/heads/master
2021-05-25T13:01:20.680206
2021-04-27T06:41:28
2021-04-27T06:41:28
253,764,719
0
0
null
null
null
null
UTF-8
C++
false
false
707
cpp
class Solution { public: int numUniqueEmails(vector<string>& emails) { unordered_map<string, int>mp; for(int i =0; i<emails.size(); i++){ string s; int x = emails[i].find('@'); // int y = emails[i].find('+'); for(int j = 0; j<emails[i].length(); j++){ if(emails[i][j] == '.') continue; if(emails[i][j] == '+' || emails[i][j] == '@') break; s += emails[i][j]; } for(int k = x; k < emails[i].length(); k++) s += emails[i][k]; mp[s]++; } int res = mp.size(); return res; } };
[ "34518493+geekyanurag@users.noreply.github.com" ]
34518493+geekyanurag@users.noreply.github.com
97a2c97d7ffc583f3a76504e714cd2d9c2a103a0
911ea9deb0418b350531ebed386567c3c784b37d
/HeroscapeEditor/TileHive6.cpp
4a3b1af20b2c0bcb1acc88808246be4a34a55659
[]
no_license
dkniffin/virtualscape
7088ca22a2815f7c1ba22d43671dd192eea77d32
7c80625e1b152fb1e7836c83d4165cf79eca1c7d
refs/heads/master
2020-12-31T03:26:12.985542
2014-03-11T16:51:11
2014-03-11T16:51:11
17,637,322
5
0
null
null
null
null
UTF-8
C++
false
false
3,731
cpp
// TileHive6.cpp : implementation file // #include "StdAfx.h" #include "Game3DView.h" #include "TileHive6.h" #include "HeroscapeEditor3DView.h" // The constructor // CTileHive6::CTileHive6() { m_NbTile = 6; m_TileHeight = TILE3D_ZHEIGHT2; m_Type = TYPE_HIVE*1000+m_NbTile; m_TileColor = RGB(193,121,65); Init(); } // The destructor // CTileHive6::~CTileHive6() { } // Get a copy of this tile // CTile* CTileHive6::GetCopy() { return new CTileHive6; } // When the rotation change // void CTileHive6::OnRotationChange() { int CurrentPos = 0; switch( m_CurrentRotation ) { case 0: case 3: m_TilePosition[CurrentPos].x = 0; m_TilePosition[CurrentPos++].y = 0; m_TilePosition[CurrentPos].x = 1; m_TilePosition[CurrentPos++].y = 0; m_TilePosition[CurrentPos].x = 2; m_TilePosition[CurrentPos++].y = 0; m_TilePosition[CurrentPos].x = -1; m_TilePosition[CurrentPos++].y = 1; m_TilePosition[CurrentPos].x = 0; m_TilePosition[CurrentPos++].y = 1; m_TilePosition[CurrentPos].x = 1; m_TilePosition[CurrentPos++].y = 1; break; case 1: case 4: m_TilePosition[CurrentPos].x = 0; m_TilePosition[CurrentPos++].y = 0; m_TilePosition[CurrentPos].x = 1; m_TilePosition[CurrentPos++].y = 0; m_TilePosition[CurrentPos].x = 0; m_TilePosition[CurrentPos++].y = 1; m_TilePosition[CurrentPos].x = 1; m_TilePosition[CurrentPos++].y = 1; m_TilePosition[CurrentPos].x = 1; m_TilePosition[CurrentPos++].y = 2; m_TilePosition[CurrentPos].x = 2; m_TilePosition[CurrentPos++].y = 2; break; case 2: case 5: m_TilePosition[CurrentPos].x = 0; m_TilePosition[CurrentPos++].y = 0; m_TilePosition[CurrentPos].x = -1; m_TilePosition[CurrentPos++].y = 1; m_TilePosition[CurrentPos].x = 0; m_TilePosition[CurrentPos++].y = 1; m_TilePosition[CurrentPos].x = -1; m_TilePosition[CurrentPos++].y = 2; m_TilePosition[CurrentPos].x = 0; m_TilePosition[CurrentPos++].y = 2; m_TilePosition[CurrentPos].x = -1; m_TilePosition[CurrentPos++].y = 3; break; } } // Render a tile (3D view) // void CTileHive6::Render1( void* pView, bool ForShadow, bool BindTexture ) { double TileExplode = 1.00; // Call the base class CTile::Render1( pView, ForShadow, BindTexture ); glMatrixMode(GL_MODELVIEW); glPushMatrix(); if( m_PosY%2==1 ) { if( m_TilePosition[0].y%2==0 ) glTranslated( (m_PosX+m_TilePosition[0].x)*TILE3D_WIDTH*TileExplode+TILE3D_X3, -(m_PosY+m_TilePosition[0].y)*TILE3D_HEIGHT*TileExplode, m_PosZ*TILE3D_ZHEIGHT*TileExplode ); else glTranslated( (m_PosX+m_TilePosition[0].x+1)*TILE3D_WIDTH*TileExplode, -(m_PosY+m_TilePosition[0].y)*TILE3D_HEIGHT*TileExplode, m_PosZ*TILE3D_ZHEIGHT*TileExplode ); } else { if( m_TilePosition[0].y%2==1 ) glTranslated( (m_PosX+m_TilePosition[0].x)*TILE3D_WIDTH*TileExplode+TILE3D_X3, -(m_PosY+m_TilePosition[0].y)*TILE3D_HEIGHT*TileExplode, m_PosZ*TILE3D_ZHEIGHT*TileExplode ); else glTranslated( (m_PosX+m_TilePosition[0].x)*TILE3D_WIDTH*TileExplode, -(m_PosY+m_TilePosition[0].y)*TILE3D_HEIGHT*TileExplode, m_PosZ*TILE3D_ZHEIGHT*TileExplode ); } switch( m_CurrentRotation ) { case 0: break; case 1: glTranslated( TILE3D_WIDTH, 0, 0 ); glRotated( -60, 0, 0, 1 ); break; case 2: glTranslated( TILE3D_WIDTH*.5, -TILE3D_Y1*2+TILE3D_Y2, 0 ); glRotated( -120, 0, 0, 1 ); break; case 3: glTranslated( TILE3D_WIDTH*1.5, -TILE3D_Y1*2+TILE3D_Y2, 0 ); glRotated( -180, 0, 0, 1 ); break; case 4: glTranslated( TILE3D_WIDTH, -TILE3D_HEIGHT*2, 0 ); glRotated( -240, 0, 0, 1 ); break; case 5: glTranslated( -TILE3D_WIDTH, 2*(-TILE3D_Y1*2+TILE3D_Y2), 0 ); glRotated( -300, 0, 0, 1 ); break; } ((CHeroscapeEditor3DView*) pView)->m_pHive6->Render( BindTexture ); glPopMatrix(); }
[ "oddityoverseer13@gmail.com" ]
oddityoverseer13@gmail.com
1412f755ab4d1234111f2ee3eb35040772f80545
0bfca409c1cc3fee16e7f8688b610775fd4d2b75
/CardEight.cpp
926274ea18104223095a366807b6aad21c966848
[]
no_license
Engineer-mostafa/Monopolyy-Game
a7ed610a0ae9338f1c8f6e1e1bb1bf9c6731ff76
f74d1af410df9ebb1a2058c7edc4c4aba61355e8
refs/heads/master
2020-10-01T05:41:03.259223
2019-12-20T18:54:08
2019-12-20T18:54:08
227,469,489
0
0
null
null
null
null
UTF-8
C++
false
false
1,396
cpp
#include "CardEight.h" #include "Grid.h" #include "Player.h" CardEight::CardEight(const CellPosition & pos) : Card(pos) // set the cell position of the card { cardNumber = 8; // set the inherited cardNumber data member with the card number (1 here) prevent[0] = 1; prevent[1] = 1; prevent[2] = 1; prevent[3] = 1; } CardEight::CardEight() { Num_Of_Cardes++; } CardEight::~CardEight(void) { Num_Of_Cardes--; } void CardEight::ReadCardParameters(Grid * pGrid) { ///TODO: Implement this function as mentioned in the guideline steps (numbered below) below } void CardEight::Apply(Grid* pGrid, Player* pPlayer) { ///TODO: Implement this function as mentioned in the guideline steps (numbered below) below // == Here are some guideline steps (numbered below) (numbered below) to implement this function == // Call Apply() of the base class Card to print the message that you reached this card number if (prevent[pGrid->GetcurrPlayerNumber()] == 1) Card::Apply(pGrid, pPlayer); } void CardEight::Save(ofstream &OutFile, int i, int Type) { if (i == 0 && Type == 2) OutFile << Num_Of_Cardes << endl; if (Type == 2) OutFile << GetCardNumber() << " " << position.GetCellNum() << endl; return; } int CardEight::IsPrevented(int playernum) { if (prevent[playernum] == 1) return prevent[playernum]--; if (prevent[playernum] == 0) return prevent[playernum]++; }
[ "abdomagdodz@gmail.com" ]
abdomagdodz@gmail.com
30ecb1fd7ebbb1b96825bbbd2d4d7d142fe207e6
4d6bf26f4d9a43082f87e177c1a2ac6c9662c288
/Chapter 14/Programming challenge/15/Odometer.h
1babc401b02bca3dc3b64bf7a5bf8cbdf7fa653c
[]
no_license
Miao4382/Starting-Out-with-Cplusplus
08d13d75fdb741be59a398b76275c5ee394840ca
dd3a1eadcf403ae57a68183987fc24fbfac0517f
refs/heads/master
2020-05-24T23:22:49.978761
2019-05-20T18:40:01
2019-05-20T18:40:01
187,513,299
2
0
null
null
null
null
UTF-8
C++
false
false
728
h
#ifndef ODOMETER_H #define ODOMETER_H class Fuel_gauge; class Odometer { private: int mileage; int gallon_mile; //hold the mileage of current fuel cycle, if it is >= fuel_economy, subtract fuel_economy and decrease fuel gauge by 1 (24 mile per gallon) static int fuel_economy; //24 mile per gallon static int max_mileage; //999999 public: /* Constructor */ Odometer(int m = 10000) { mileage = m; gallon_mile = 0; } /* Accessor */ int GetMileage() const { return mileage; } /* Mutator */ // increase mileage by 1, if mileage > 999999, mileage -= 999999; Check fuel first before do the increment. If gallon_mile >= 24 after increment, burn 1 gallon fuel void Increment(Fuel_gauge& f); }; #endif
[ "33183267+Miao4382@users.noreply.github.com" ]
33183267+Miao4382@users.noreply.github.com
111237398036b2ff3a664309fba0e8095af0e710
5d222e9eb564ae817816a562d6982c0167eca6b2
/大一/实验室/栈、队列/非诚勿扰.cpp
9ae8ba288848a0bfee6b01f1d3f24942aab91f86
[]
no_license
pure-xiaojie/acmCode
00c811796de44d4a0316c22f1a7956d2dc868e19
5c1932ba5fa7c3d141ae7f5294004c862102a4b7
refs/heads/master
2021-02-14T19:55:02.546355
2020-08-11T13:54:09
2020-08-11T13:54:09
244,829,610
0
0
null
null
null
null
UTF-8
C++
false
false
1,160
cpp
#include<stdio.h> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<cstdlib> #include<queue> using namespace std; int main() { int k,i,a; cin >> a; for (k=0; k<a; k++) { queue<string> q[21]; printf("Case #%d:\n",k+1); int n,m=0; cin >> n; for (i=0; i<n; i++) { char s[20]; cin >> s; int j; if (s[0]=='A') { cin >> s >>j; m++; cout << m << endl; q[j].push(s); } else { cin >>j; while ( j<=20 && q[j].empty() ) j++; if ( j==21 || q[j].empty() ) printf("WAIT...\n"); else { const char *str1; string str2; str2=q[j].front(); str1=str2.c_str(); cout << str1 << endl; q[j].pop(); m--; } } } } return 0; }
[ "1952175699@qq.com" ]
1952175699@qq.com
afff5747607a70d451dff47e08e3705b94b204ca
0d8911e70e2b56eaee8b65a18b41c4614b600831
/poly_class.h
6ae6721c5904f66b9f9c8cddfad826a0ef0a58e5
[]
no_license
thetabow/Polynomial_calculator
5738f1fbc893c0146101d6985787e0d4264ca2ee
af428ddef4ec551f84a03e87c6cc04937be2df61
refs/heads/master
2021-07-22T17:48:43.887640
2017-11-03T04:17:59
2017-11-03T04:17:59
107,882,964
0
0
null
null
null
null
UTF-8
C++
false
false
1,462
h
/* ----------------------------------------------------------------------------------------------------------- FILE NAME: poly_class.h DESCRITION: header file for Polynomial project PURPOSE: includes Polynomial class header file into poly_class.cpp USAGE: no parameters needed EXAMPLES: ./Polynomial PARAMETERS: none EXIT CODES: 0 for success, otherwise means it failed COMPILATION: use command 'make' to compile most updated version NOTES: MODIFICATION HISTORY: Author: Date: Version: -------------------------------------------------------------------------------------------------------------- Zuriah Quinton 10-16-17 slow start to setting up the class and various files Zuriah Quinton 10-20-17 finalize work on v1: input output, add and subtract works, derivative functional, display works, still using vector class Zuriah Quinton 10-21-17 long division, scalar multiplication, integration, polynomial multiplication all implemented Zuriah Quinton 10-22-17 replaced display_poly with << operator Zuriah Quinton 10-23-17 realized long division is broken, added +=, -=, <<=, >>= to facilitate long division process...fixed long division Zuriah Quinton 11-2-17 finalizing everything after a week and a half of little changes ------------------------------------------------------------------------------------------------------------*/ #include "Polynomial.h" #include <iostream> #include <vector>
[ "zuriah_quinton@mail.tmcc.edu" ]
zuriah_quinton@mail.tmcc.edu
c894e367184b011513083cdbbc40b7cef39fbdb2
b669094d27d471ab82bd25220ee22fc0867465cb
/tool/res_build/src/togo/tool_res_build/resource_compiler.cpp
4a30a238930172e46f306348394e34aca80a5204
[ "MIT" ]
permissive
komiga/togo
9f26af22f3cc4dc535d30d886deb294ebf717ba9
7a366fc02e87c8480f008aa110516e4b04f8d73b
refs/heads/master
2021-01-23T21:18:15.402108
2020-11-07T06:35:14
2020-11-07T06:35:14
21,193,515
27
1
null
null
null
null
UTF-8
C++
false
false
749
cpp
#line 2 "togo/tool_res_build/resource_compiler.cpp" /** @copyright MIT license; see @ref index or the accompanying LICENSE file. */ #include <togo/tool_res_build/config.hpp> #include <togo/tool_res_build/types.hpp> #include <togo/tool_res_build/resource_compiler.hpp> #include <togo/tool_res_build/compiler_manager.hpp> namespace togo { namespace tool_res_build { /// Register standard resource compilers. void resource_compiler::register_standard( CompilerManager& cm, GfxCompiler& gfx_compiler ) { resource_compiler::register_test(cm); resource_compiler::register_shader_prelude(cm); resource_compiler::register_shader(cm); resource_compiler::register_render_config(cm, gfx_compiler); } } // namespace tool_res_build } // namespace togo
[ "me@komiga.com" ]
me@komiga.com
81355634ae2834d9bbceb58edae3f398c33288a4
bdb7d942c19561a8ded767779c409c231a29d4ac
/engine/PainterCursor.cpp
976e89a62660db4974fd69a4bdca6bd99fefe424
[]
no_license
edolphin-ydf/char_game_engine
d1b8040f82a08d32b7398e3274c610f9cc5c7535
e8fb630afe00529da34346946247fc49f5e19fd7
refs/heads/master
2021-01-22T11:10:57.051190
2017-02-08T10:59:48
2017-02-08T10:59:48
55,417,558
0
1
null
null
null
null
UTF-8
C++
false
false
2,353
cpp
#include "PainterCursor.h" #include <curses.h> #include <math.h> #include <stdio.h> namespace edolphin { PainterCursor::PainterCursor (){ } PainterCursor::~PainterCursor () { } bool PainterCursor::init() { initscr(); if (!has_colors()) { return false; } use_default_colors(); // black backgroupd and white forground noecho(); // no echo with input cbreak(); // no need for cr return true; } void PainterCursor::destory() { endwin(); } void PainterCursor::clean() { erase(); } void PainterCursor::refresh() { ::refresh(); } void PainterCursor::drawPoint(Point2D point) { drawPoint(point.x, point.y); } void PainterCursor::drawPoint(int x, int y) { mvaddch(y, x, '*'); } void PainterCursor::drawLine(Point2D begin, Point2D end) { Point2D tmp = end - begin; double k = (double)tmp.y / (double)tmp.x; for (int i=0; i<= tmp.x; ++i) { int y = round(k * i) + begin.y; int x = i + begin.x; drawPoint(x, y); } } void PainterCursor::drawRectangle(Point2D p1, Point2D p2) { int width = p2.x - p1.x; int height = p2.y - p1.y; mvvline(p1.y, p1.x, '|', height); mvvline(p1.y, p2.x, '|', height); mvhline(p1.y, p1.x, '-', width); mvhline(p2.y, p1.x, '-', width); } void PainterCursor::drawCircles(Point2D point, int r) { } void PainterCursor::drawText(Point2D point, std::string text) { mvprintw(point.y, point.x, text.c_str()); } void PainterCursor::drawPicture(Point2D position, int width, int height, BYTE *data) { for (int i = 0; i < height; ++i) { mvprintw(position.y + i, position.x, (char*)(data + width * i)); } } void PainterCursor::drawPicture(Point2D position, Picture *picture) { drawPicture(position, picture->getWidth(), picture->getHeight(), picture->getData()); } Color PainterCursor::getBackgroundColor() { return _backgroundColor; } Color PainterCursor::getForegroundColor() { return _foregroundColor; } void PainterCursor::setColorPair(Color foreground, Color background) { _foregroundColor = foreground; _backgroundColor = background; } void PainterCursor::setBackgroundColor(Color background) { _backgroundColor = background; } void PainterCursor::setForegroundColor(Color foreground) { _foregroundColor = foreground; } Size PainterCursor::getViewSize() { //int width, height; //getmaxyx(stdscr, height, width); //return Size(width, height); return Size(268, 56); } }
[ "shisanbihua@126.com" ]
shisanbihua@126.com
83f685baebda240453f192b880196772c44a2b97
0e40a0486826825c2c8adba9a538e16ad3efafaf
/lib/boost/include/boost/mpl/vector/vector0.hpp
7dbbd1c999db54f0538def00ae862e4d9e18e4cd
[ "MIT" ]
permissive
iraqigeek/iZ3D
4c45e69a6e476ad434d5477f21f5b5eb48336727
ced8b3a4b0a152d0177f2e94008918efc76935d5
refs/heads/master
2023-05-25T19:04:06.082744
2020-12-28T03:27:55
2020-12-28T03:27:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,254
hpp
#ifndef BOOST_MPL_VECTOR_VECTOR0_HPP_INCLUDED #define BOOST_MPL_VECTOR_VECTOR0_HPP_INCLUDED // Copyright Aleksey Gurtovoy 2000-2004 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/mpl for documentation. // $Id: vector0.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ // $Date: 2008-10-11 10:19:02 +0400 (Ñá, 11 îêò 2008) $ // $Revision: 49267 $ #include <boost/mpl/vector/aux_/at.hpp> #include <boost/mpl/vector/aux_/front.hpp> #include <boost/mpl/vector/aux_/push_front.hpp> #include <boost/mpl/vector/aux_/pop_front.hpp> #include <boost/mpl/vector/aux_/push_back.hpp> #include <boost/mpl/vector/aux_/pop_back.hpp> #include <boost/mpl/vector/aux_/back.hpp> #include <boost/mpl/vector/aux_/clear.hpp> #include <boost/mpl/vector/aux_/O1_size.hpp> #include <boost/mpl/vector/aux_/size.hpp> #include <boost/mpl/vector/aux_/empty.hpp> #include <boost/mpl/vector/aux_/item.hpp> #include <boost/mpl/vector/aux_/iterator.hpp> #include <boost/mpl/vector/aux_/vector0.hpp> #include <boost/mpl/vector/aux_/begin_end.hpp> #include <boost/mpl/vector/aux_/tag.hpp> #endif // BOOST_MPL_VECTOR_VECTOR0_HPP_INCLUDED
[ "github@bo3b.net" ]
github@bo3b.net
271cbbf0b458f4bfd288241c18a3f1fa89ae67f4
faf57a4070a8e93e2957264946c401e6fa3843d9
/src/version.h
39d93d6eb14b82b6c44103042638e5231e228e8d
[ "MIT" ]
permissive
DeepCoin/build
97d59774651edd9248fac64d8e5c066c461a3971
bf455686c5c16f4b79159d1693ac45da322a4bdf
refs/heads/master
2021-01-15T10:07:33.406105
2014-01-15T05:01:56
2014-01-15T05:01:56
16,031,446
2
1
null
null
null
null
UTF-8
C++
false
false
1,578
h
// Copyright (c) 2012 The Bitcoin developers // Copyright (c) 2012 ApeCoin Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_VERSION_H #define BITCOIN_VERSION_H #include <string> // // client versioning // // These need to be macro's, as version.cpp's voodoo requires it #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 1 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 0 static const int CLIENT_VERSION = 1000000 * CLIENT_VERSION_MAJOR + 10000 * CLIENT_VERSION_MINOR + 100 * CLIENT_VERSION_REVISION + 1 * CLIENT_VERSION_BUILD; extern const std::string CLIENT_NAME; extern const std::string CLIENT_BUILD; extern const std::string CLIENT_DATE; // // network protocol versioning // static const int PROTOCOL_VERSION = 60001; // earlier versions not supported as of Feb 2012, and are disconnected static const int MIN_PROTO_VERSION = 209; // nTime field added to CAddress, starting with this version; // if possible, avoid requesting addresses nodes older than this static const int CADDR_TIME_VERSION = 31402; // only request blocks from nodes outside this range of versions static const int NOBLKS_VERSION_START = 32000; static const int NOBLKS_VERSION_END = 32400; // BIP 0031, pong message, is enabled for all versions AFTER this one static const int BIP0031_VERSION = 60000; #endif
[ "filthcoin@gmail.com" ]
filthcoin@gmail.com
47dd5f1a7446fb1b38340a2fe6dd69acbdb7f840
f55eab7f9e2e07488ee8939a68234ed8befc0494
/testsystem/resultsdialog.h
882e70f8b684ab1d6d0f8939b5220988e13e82f4
[]
no_license
tmkplus/tmkplus
1e5bc36df6c54d85561f386775be99d85f8450c5
0a6ae93fcf732fa99dca101eb0c30c438163e389
refs/heads/master
2020-09-19T20:39:18.414703
2019-11-26T22:05:05
2019-11-26T22:05:05
224,292,199
0
0
null
null
null
null
UTF-8
C++
false
false
523
h
#ifndef RESULTSDIALOG_H #define RESULTSDIALOG_H #include <QDialog> #include <QCloseEvent> namespace Ui { class ResultsDialog; } class ResultsDialog : public QDialog { Q_OBJECT public: explicit ResultsDialog(QWidget *parent = 0, QString whereToSaveScreenshot = ""); ~ResultsDialog(); QString screenshotPath; void SetTextBoxText(QString text); private slots: void on_pushButton_clicked(); void closeEvent(QCloseEvent * cev); private: Ui::ResultsDialog *ui; }; #endif // RESULTSDIALOG_H
[ "d1911463@urhen.com" ]
d1911463@urhen.com
b2aa65f46420ac4d310772e87dd26520d1bfcc3d
94b89cd09b4ab7e8ef33bbf66ea3be42a5a6e186
/gameplugin/doudizhu/game/GameLogic.cpp
8375213d78b0481f7ec5dfcc1cce80ce5e843878
[]
no_license
xcschina/Chessserver-devmain
72c4da345ec1e673919e02b4bb44e2430548a354
38543a2f95b5734c1a6d4b83ee7b89fe81576e02
refs/heads/master
2020-06-17T07:47:57.361591
2018-12-18T08:18:51
2018-12-18T08:18:51
null
0
0
null
null
null
null
GB18030
C++
false
false
40,466
cpp
#include "StdAfx.h" #include "GameLogic.h" ////////////////////////////////////////////////////////////////////////////////// //静态变量 //索引变量 const BYTE cbIndexCount=5; //扑克数据 const BYTE CGameLogic::m_cbCardData[FULL_COUNT]= { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D, //方块 A - K 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D, //梅花 A - K 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D, //红桃 A - K 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D, //黑桃 A - K 0x4E,0x4F, }; ////////////////////////////////////////////////////////////////////////////////// //构造函数 CGameLogic::CGameLogic() { } //析构函数 CGameLogic::~CGameLogic() { } //获取类型 BYTE CGameLogic::GetCardType(const BYTE cbCardData[], BYTE cbCardCount) { //简单牌型 switch (cbCardCount) { case 0: //空牌 { return CT_ERROR; } case 1: //单牌 { return CT_SINGLE; } case 2: //对牌火箭 { //牌型判断 if ((cbCardData[0]==0x4F)&&(cbCardData[1]==0x4E)) return CT_MISSILE_CARD; if (GetCardLogicValue(cbCardData[0])==GetCardLogicValue(cbCardData[1])) return CT_DOUBLE; return CT_ERROR; } } //分析扑克 tagAnalyseResult AnalyseResult; AnalysebCardData(cbCardData,cbCardCount,AnalyseResult); //四牌判断 if (AnalyseResult.cbBlockCount[3]>0) { //牌型判断 if ((AnalyseResult.cbBlockCount[3]==1)&&(cbCardCount==4)) return CT_BOMB_CARD; if ((AnalyseResult.cbBlockCount[3]==1)&&(cbCardCount==6)) return CT_FOUR_TAKE_ONE; if ((AnalyseResult.cbBlockCount[3]==1)&&(cbCardCount==8)&&(AnalyseResult.cbBlockCount[1]==2)) return CT_FOUR_TAKE_TWO; return CT_ERROR; } //三牌判断 if (AnalyseResult.cbBlockCount[2]>0) { //连牌判断 if (AnalyseResult.cbBlockCount[2]>1) { //变量定义 BYTE cbCardData=AnalyseResult.cbCardData[2][0]; BYTE cbFirstLogicValue=GetCardLogicValue(cbCardData); //错误过虑 if (cbFirstLogicValue>=15) return CT_ERROR; //连牌判断 for (BYTE i=1;i<AnalyseResult.cbBlockCount[2];i++) { BYTE cbCardData=AnalyseResult.cbCardData[2][i*3]; if (cbFirstLogicValue!=(GetCardLogicValue(cbCardData)+i)) return CT_ERROR; } } else if( cbCardCount == 3 ) return CT_THREE; //牌形判断 if (AnalyseResult.cbBlockCount[2]*3==cbCardCount) return CT_THREE_LINE; if (AnalyseResult.cbBlockCount[2]*4==cbCardCount) return CT_THREE_TAKE_ONE; if ((AnalyseResult.cbBlockCount[2]*5==cbCardCount)&&(AnalyseResult.cbBlockCount[1]==AnalyseResult.cbBlockCount[2])) return CT_THREE_TAKE_TWO; return CT_ERROR; } //两张类型 if (AnalyseResult.cbBlockCount[1]>=3) { //变量定义 BYTE cbCardData=AnalyseResult.cbCardData[1][0]; BYTE cbFirstLogicValue=GetCardLogicValue(cbCardData); //错误过虑 if (cbFirstLogicValue>=15) return CT_ERROR; //连牌判断 for (BYTE i=1;i<AnalyseResult.cbBlockCount[1];i++) { BYTE cbCardData=AnalyseResult.cbCardData[1][i*2]; if (cbFirstLogicValue!=(GetCardLogicValue(cbCardData)+i)) return CT_ERROR; } //二连判断 if ((AnalyseResult.cbBlockCount[1]*2)==cbCardCount) return CT_DOUBLE_LINE; return CT_ERROR; } //单张判断 if ((AnalyseResult.cbBlockCount[0]>=5)&&(AnalyseResult.cbBlockCount[0]==cbCardCount)) { //变量定义 BYTE cbCardData=AnalyseResult.cbCardData[0][0]; BYTE cbFirstLogicValue=GetCardLogicValue(cbCardData); //错误过虑 if (cbFirstLogicValue>=15) return CT_ERROR; //连牌判断 for (BYTE i=1;i<AnalyseResult.cbBlockCount[0];i++) { BYTE cbCardData=AnalyseResult.cbCardData[0][i]; if (cbFirstLogicValue!=(GetCardLogicValue(cbCardData)+i)) return CT_ERROR; } return CT_SINGLE_LINE; } return CT_ERROR; } //排列扑克 VOID CGameLogic::SortCardList(BYTE cbCardData[], BYTE cbCardCount, BYTE cbSortType) { //数目过虑 if (cbCardCount==0) return; if (cbSortType==ST_CUSTOM) return; //转换数值 BYTE cbSortValue[MAX_COUNT]; for (BYTE i=0;i<cbCardCount;i++) cbSortValue[i]=GetCardLogicValue(cbCardData[i]); //排序操作 bool bSorted=true; BYTE cbSwitchData=0,cbLast=cbCardCount-1; do { bSorted=true; for (BYTE i=0;i<cbLast;i++) { if ((cbSortValue[i]<cbSortValue[i+1])|| ((cbSortValue[i]==cbSortValue[i+1])&&(cbCardData[i]<cbCardData[i+1]))) { //设置标志 bSorted=false; //扑克数据 cbSwitchData=cbCardData[i]; cbCardData[i]=cbCardData[i+1]; cbCardData[i+1]=cbSwitchData; //排序权位 cbSwitchData=cbSortValue[i]; cbSortValue[i]=cbSortValue[i+1]; cbSortValue[i+1]=cbSwitchData; } } cbLast--; } while(bSorted==false); //数目排序 if (cbSortType==ST_COUNT) { //变量定义 BYTE cbCardIndex=0; //分析扑克 tagAnalyseResult AnalyseResult; AnalysebCardData(&cbCardData[cbCardIndex],cbCardCount-cbCardIndex,AnalyseResult); //提取扑克 for (BYTE i=0;i<CountArray(AnalyseResult.cbBlockCount);i++) { //拷贝扑克 BYTE cbIndex=CountArray(AnalyseResult.cbBlockCount)-i-1; CopyMemory(&cbCardData[cbCardIndex],AnalyseResult.cbCardData[cbIndex],AnalyseResult.cbBlockCount[cbIndex]*(cbIndex+1)*sizeof(BYTE)); //设置索引 cbCardIndex+=AnalyseResult.cbBlockCount[cbIndex]*(cbIndex+1)*sizeof(BYTE); } } return; } //混乱扑克 VOID CGameLogic::RandCardList(BYTE cbCardBuffer[], BYTE cbBufferCount) { //混乱准备 BYTE cbCardData[CountArray(m_cbCardData)]; CopyMemory(cbCardData,m_cbCardData,sizeof(m_cbCardData)); //混乱扑克 BYTE cbRandCount=0,cbPosition=0; do { cbPosition=rand()%(cbBufferCount-cbRandCount); cbCardBuffer[cbRandCount++]=cbCardData[cbPosition]; cbCardData[cbPosition]=cbCardData[cbBufferCount-cbRandCount]; } while (cbRandCount<cbBufferCount); return; } //删除扑克 bool CGameLogic::RemoveCardList(const BYTE cbRemoveCard[], BYTE cbRemoveCount, BYTE cbCardData[], BYTE cbCardCount) { //检验数据 ASSERT(cbRemoveCount<=cbCardCount); //定义变量 BYTE cbDeleteCount=0,cbTempCardData[MAX_COUNT]; if (cbCardCount>CountArray(cbTempCardData)) return false; CopyMemory(cbTempCardData,cbCardData,cbCardCount*sizeof(cbCardData[0])); //置零扑克 for (BYTE i=0;i<cbRemoveCount;i++) { for (BYTE j=0;j<cbCardCount;j++) { if (cbRemoveCard[i]==cbTempCardData[j]) { cbDeleteCount++; cbTempCardData[j]=0; break; } } } if (cbDeleteCount!=cbRemoveCount) return false; ZeroMemory(cbCardData,cbCardCount*sizeof(cbCardData[0])); //清理扑克 BYTE cbCardPos=0; for (BYTE i=0;i<cbCardCount;i++) { if (cbTempCardData[i]!=0) cbCardData[cbCardPos++]=cbTempCardData[i]; } return true; } //删除扑克 bool CGameLogic::RemoveCard(const BYTE cbRemoveCard[], BYTE cbRemoveCount, BYTE cbCardData[], BYTE cbCardCount) { //检验数据 ASSERT(cbRemoveCount<=cbCardCount); //定义变量 BYTE cbDeleteCount=0,cbTempCardData[MAX_COUNT]; if (cbCardCount>CountArray(cbTempCardData)) return false; CopyMemory(cbTempCardData,cbCardData,cbCardCount*sizeof(cbCardData[0])); //置零扑克 for (BYTE i=0;i<cbRemoveCount;i++) { for (BYTE j=0;j<cbCardCount;j++) { if (cbRemoveCard[i]==cbTempCardData[j]) { cbDeleteCount++; cbTempCardData[j]=0; break; } } } if (cbDeleteCount!=cbRemoveCount) return false; //清理扑克 BYTE cbCardPos=0; for (BYTE i=0;i<cbCardCount;i++) { if (cbTempCardData[i]!=0) cbCardData[cbCardPos++]=cbTempCardData[i]; } return true; } //排列扑克 VOID CGameLogic::SortOutCardList(BYTE cbCardData[], BYTE cbCardCount) { //获取牌型 BYTE cbCardType = GetCardType(cbCardData,cbCardCount); if( cbCardType == CT_THREE_TAKE_ONE || cbCardType == CT_THREE_TAKE_TWO ) { //分析牌 tagAnalyseResult AnalyseResult = {}; AnalysebCardData( cbCardData,cbCardCount,AnalyseResult ); cbCardCount = AnalyseResult.cbBlockCount[2]*3; CopyMemory( cbCardData,AnalyseResult.cbCardData[2],sizeof(BYTE)*cbCardCount ); for( int i = CountArray(AnalyseResult.cbBlockCount)-1; i >= 0; i-- ) { if( i == 2 ) continue; if( AnalyseResult.cbBlockCount[i] > 0 ) { CopyMemory( &cbCardData[cbCardCount],AnalyseResult.cbCardData[i], sizeof(BYTE)*(i+1)*AnalyseResult.cbBlockCount[i] ); cbCardCount += (i+1)*AnalyseResult.cbBlockCount[i]; } } } else if( cbCardType == CT_FOUR_TAKE_ONE || cbCardType == CT_FOUR_TAKE_TWO ) { //分析牌 tagAnalyseResult AnalyseResult = {}; AnalysebCardData( cbCardData,cbCardCount,AnalyseResult ); cbCardCount = AnalyseResult.cbBlockCount[3]*4; CopyMemory( cbCardData,AnalyseResult.cbCardData[3],sizeof(BYTE)*cbCardCount ); for( int i = CountArray(AnalyseResult.cbBlockCount)-1; i >= 0; i-- ) { if( i == 3 ) continue; if( AnalyseResult.cbBlockCount[i] > 0 ) { CopyMemory( &cbCardData[cbCardCount],AnalyseResult.cbCardData[i], sizeof(BYTE)*(i+1)*AnalyseResult.cbBlockCount[i] ); cbCardCount += (i+1)*AnalyseResult.cbBlockCount[i]; } } } return; } //逻辑数值 BYTE CGameLogic::GetCardLogicValue(BYTE cbCardData) { //扑克属性 BYTE cbCardColor=GetCardColor(cbCardData); BYTE cbCardValue=GetCardValue(cbCardData); if(cbCardValue<=0 || cbCardValue>(MASK_VALUE&0x4f)) return 0 ; ASSERT(cbCardValue>0 && cbCardValue<=(MASK_VALUE&0x4f)); //转换数值 if (cbCardColor==0x40) return cbCardValue+2; return (cbCardValue<=2)?(cbCardValue+13):cbCardValue; } //对比扑克 bool CGameLogic::CompareCard(const BYTE cbFirstCard[], const BYTE cbNextCard[], BYTE cbFirstCount, BYTE cbNextCount) { //获取类型 BYTE cbNextType=GetCardType(cbNextCard,cbNextCount); BYTE cbFirstType=GetCardType(cbFirstCard,cbFirstCount); //类型判断 if (cbNextType==CT_ERROR) return false; if (cbNextType==CT_MISSILE_CARD) return true; //炸弹判断 if ((cbFirstType!=CT_BOMB_CARD)&&(cbNextType==CT_BOMB_CARD)) return true; if ((cbFirstType==CT_BOMB_CARD)&&(cbNextType!=CT_BOMB_CARD)) return false; //规则判断 if ((cbFirstType!=cbNextType)||(cbFirstCount!=cbNextCount)) return false; //开始对比 switch (cbNextType) { case CT_SINGLE: case CT_DOUBLE: case CT_THREE: case CT_SINGLE_LINE: case CT_DOUBLE_LINE: case CT_THREE_LINE: case CT_BOMB_CARD: { //获取数值 BYTE cbNextLogicValue=GetCardLogicValue(cbNextCard[0]); BYTE cbFirstLogicValue=GetCardLogicValue(cbFirstCard[0]); //对比扑克 return cbNextLogicValue>cbFirstLogicValue; } case CT_THREE_TAKE_ONE: case CT_THREE_TAKE_TWO: { //分析扑克 tagAnalyseResult NextResult; tagAnalyseResult FirstResult; AnalysebCardData(cbNextCard,cbNextCount,NextResult); AnalysebCardData(cbFirstCard,cbFirstCount,FirstResult); //获取数值 BYTE cbNextLogicValue=GetCardLogicValue(NextResult.cbCardData[2][0]); BYTE cbFirstLogicValue=GetCardLogicValue(FirstResult.cbCardData[2][0]); //对比扑克 return cbNextLogicValue>cbFirstLogicValue; } case CT_FOUR_TAKE_ONE: case CT_FOUR_TAKE_TWO: { //分析扑克 tagAnalyseResult NextResult; tagAnalyseResult FirstResult; AnalysebCardData(cbNextCard,cbNextCount,NextResult); AnalysebCardData(cbFirstCard,cbFirstCount,FirstResult); //获取数值 BYTE cbNextLogicValue=GetCardLogicValue(NextResult.cbCardData[3][0]); BYTE cbFirstLogicValue=GetCardLogicValue(FirstResult.cbCardData[3][0]); //对比扑克 return cbNextLogicValue>cbFirstLogicValue; } } return false; } //构造扑克 BYTE CGameLogic::MakeCardData(BYTE cbValueIndex, BYTE cbColorIndex) { return (cbColorIndex<<4)|(cbValueIndex+1); } //分析扑克 VOID CGameLogic::AnalysebCardData(const BYTE cbCardData[], BYTE cbCardCount, tagAnalyseResult & AnalyseResult) { //设置结果 ZeroMemory(&AnalyseResult,sizeof(AnalyseResult)); //扑克分析 for (BYTE i=0;i<cbCardCount;i++) { //变量定义 BYTE cbSameCount=1,cbCardValueTemp=0; BYTE cbLogicValue=GetCardLogicValue(cbCardData[i]); //搜索同牌 for (BYTE j=i+1;j<cbCardCount;j++) { //获取扑克 if (GetCardLogicValue(cbCardData[j])!=cbLogicValue) break; //设置变量 cbSameCount++; } if(cbSameCount > 4) { ASSERT(FALSE); //设置结果 ZeroMemory(&AnalyseResult, sizeof(AnalyseResult)); return; } //设置结果 BYTE cbIndex=AnalyseResult.cbBlockCount[cbSameCount-1]++; for (BYTE j=0;j<cbSameCount;j++) AnalyseResult.cbCardData[cbSameCount-1][cbIndex*cbSameCount+j]=cbCardData[i+j]; //设置索引 i+=cbSameCount-1; } return; } //分析分布 VOID CGameLogic::AnalysebDistributing(const BYTE cbCardData[], BYTE cbCardCount, tagDistributing & Distributing) { //设置变量 ZeroMemory(&Distributing,sizeof(Distributing)); //设置变量 for (BYTE i=0;i<cbCardCount;i++) { if (cbCardData[i]==0) continue; //获取属性 BYTE cbCardColor=GetCardColor(cbCardData[i]); BYTE cbCardValue=GetCardValue(cbCardData[i]); //分布信息 Distributing.cbCardCount++; Distributing.cbDistributing[cbCardValue-1][cbIndexCount]++; Distributing.cbDistributing[cbCardValue-1][cbCardColor>>4]++; } return; } //出牌搜索 BYTE CGameLogic::SearchOutCard( const BYTE cbHandCardData[], BYTE cbHandCardCount, const BYTE cbTurnCardData[], BYTE cbTurnCardCount, tagSearchCardResult *pSearchCardResult ) { //设置结果 ASSERT( pSearchCardResult != NULL ); if( pSearchCardResult == NULL ) return 0; ZeroMemory(pSearchCardResult,sizeof(tagSearchCardResult)); //变量定义 BYTE cbResultCount = 0; tagSearchCardResult tmpSearchCardResult = {}; //构造扑克 BYTE cbCardData[MAX_COUNT]; BYTE cbCardCount=cbHandCardCount; CopyMemory(cbCardData,cbHandCardData,sizeof(BYTE)*cbHandCardCount); //排列扑克 SortCardList(cbCardData,cbCardCount,ST_ORDER); //获取类型 BYTE cbTurnOutType=GetCardType(cbTurnCardData,cbTurnCardCount); //出牌分析 switch (cbTurnOutType) { case CT_ERROR: //错误类型 { //提取各种牌型一组 ASSERT( pSearchCardResult ); if( !pSearchCardResult ) return 0; //是否一手出完 if( GetCardType(cbCardData,cbCardCount) != CT_ERROR ) { pSearchCardResult->cbCardCount[cbResultCount] = cbCardCount; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],cbCardData, sizeof(BYTE)*cbCardCount ); cbResultCount++; } //如果最小牌不是单牌,则提取 BYTE cbSameCount = 0; if( cbCardCount > 1 && GetCardValue(cbCardData[cbCardCount-1]) == GetCardValue(cbCardData[cbCardCount-2]) ) { cbSameCount = 1; pSearchCardResult->cbResultCard[cbResultCount][0] = cbCardData[cbCardCount-1]; BYTE cbCardValue = GetCardValue(cbCardData[cbCardCount-1]); for( int i = cbCardCount-2; i >= 0; i-- ) { if( GetCardValue(cbCardData[i]) == cbCardValue ) { pSearchCardResult->cbResultCard[cbResultCount][cbSameCount++] = cbCardData[i]; } else break; } pSearchCardResult->cbCardCount[cbResultCount] = cbSameCount; cbResultCount++; } //单牌 BYTE cbTmpCount = 0; if( cbSameCount != 1 ) { cbTmpCount = SearchSameCard( cbCardData,cbCardCount,0,1,&tmpSearchCardResult ); if( cbTmpCount > 0 ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); cbResultCount++; } } //对牌 if( cbSameCount != 2 ) { cbTmpCount = SearchSameCard( cbCardData,cbCardCount,0,2,&tmpSearchCardResult ); if( cbTmpCount > 0 ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); cbResultCount++; } } //三条 if( cbSameCount != 3 ) { cbTmpCount = SearchSameCard( cbCardData,cbCardCount,0,3,&tmpSearchCardResult ); if( cbTmpCount > 0 ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); cbResultCount++; } } //三带一单 cbTmpCount = SearchTakeCardType( cbCardData,cbCardCount,0,3,1,&tmpSearchCardResult ); if( cbTmpCount > 0 ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); cbResultCount++; } //三带一对 cbTmpCount = SearchTakeCardType( cbCardData,cbCardCount,0,3,2,&tmpSearchCardResult ); if( cbTmpCount > 0 ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); cbResultCount++; } //单连 cbTmpCount = SearchLineCardType( cbCardData,cbCardCount,0,1,0,&tmpSearchCardResult ); if( cbTmpCount > 0 ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); cbResultCount++; } //连对 cbTmpCount = SearchLineCardType( cbCardData,cbCardCount,0,2,0,&tmpSearchCardResult ); if( cbTmpCount > 0 ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); cbResultCount++; } //三连 cbTmpCount = SearchLineCardType( cbCardData,cbCardCount,0,3,0,&tmpSearchCardResult ); if( cbTmpCount > 0 ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); cbResultCount++; } ////飞机 //cbTmpCount = SearchThreeTwoLine( cbCardData,cbCardCount,&tmpSearchCardResult ); //if( cbTmpCount > 0 ) //{ // pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; // CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], // sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); // cbResultCount++; //} //炸弹 if( cbSameCount != 4 ) { cbTmpCount = SearchSameCard( cbCardData,cbCardCount,0,4,&tmpSearchCardResult ); if( cbTmpCount > 0 ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[0]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[0], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[0] ); cbResultCount++; } } //搜索火箭 if ((cbCardCount>=2)&&(cbCardData[0]==0x4F)&&(cbCardData[1]==0x4E)) { //设置结果 pSearchCardResult->cbCardCount[cbResultCount] = 2; pSearchCardResult->cbResultCard[cbResultCount][0] = cbCardData[0]; pSearchCardResult->cbResultCard[cbResultCount][1] = cbCardData[1]; cbResultCount++; } pSearchCardResult->cbSearchCount = cbResultCount; return cbResultCount; } case CT_SINGLE: //单牌类型 case CT_DOUBLE: //对牌类型 case CT_THREE: //三条类型 { //变量定义 BYTE cbReferCard=cbTurnCardData[0]; BYTE cbSameCount = 1; if( cbTurnOutType == CT_DOUBLE ) cbSameCount = 2; else if( cbTurnOutType == CT_THREE ) cbSameCount = 3; //搜索相同牌 cbResultCount = SearchSameCard( cbCardData,cbCardCount,cbReferCard,cbSameCount,pSearchCardResult ); break; } case CT_SINGLE_LINE: //单连类型 case CT_DOUBLE_LINE: //对连类型 case CT_THREE_LINE: //三连类型 { //变量定义 BYTE cbBlockCount = 1; if( cbTurnOutType == CT_DOUBLE_LINE ) cbBlockCount = 2; else if( cbTurnOutType == CT_THREE_LINE ) cbBlockCount = 3; BYTE cbLineCount = cbTurnCardCount/cbBlockCount; //搜索边牌 cbResultCount = SearchLineCardType( cbCardData,cbCardCount,cbTurnCardData[0],cbBlockCount,cbLineCount,pSearchCardResult ); break; } case CT_THREE_TAKE_ONE: //三带一单 case CT_THREE_TAKE_TWO: //三带一对 { //效验牌数 if( cbCardCount < cbTurnCardCount ) break; //如果是三带一或三带二 if( cbTurnCardCount == 4 || cbTurnCardCount == 5 ) { BYTE cbTakeCardCount = cbTurnOutType==CT_THREE_TAKE_ONE?1:2; //搜索三带牌型 cbResultCount = SearchTakeCardType( cbCardData,cbCardCount,cbTurnCardData[2],3,cbTakeCardCount,pSearchCardResult ); } else { //变量定义 BYTE cbBlockCount = 3; BYTE cbLineCount = cbTurnCardCount/(cbTurnOutType==CT_THREE_TAKE_ONE?4:5); BYTE cbTakeCardCount = cbTurnOutType==CT_THREE_TAKE_ONE?1:2; //搜索连牌 BYTE cbTmpTurnCard[MAX_COUNT] = {}; CopyMemory( cbTmpTurnCard,cbTurnCardData,sizeof(BYTE)*cbTurnCardCount ); SortOutCardList( cbTmpTurnCard,cbTurnCardCount ); cbResultCount = SearchLineCardType( cbCardData,cbCardCount,cbTmpTurnCard[0],cbBlockCount,cbLineCount,pSearchCardResult ); //提取带牌 bool bAllDistill = true; for( BYTE i = 0; i < cbResultCount; i++ ) { BYTE cbResultIndex = cbResultCount-i-1; //变量定义 BYTE cbTmpCardData[MAX_COUNT]; BYTE cbTmpCardCount = cbCardCount; //删除连牌 CopyMemory( cbTmpCardData,cbCardData,sizeof(BYTE)*cbCardCount ); VERIFY( RemoveCard( pSearchCardResult->cbResultCard[cbResultIndex],pSearchCardResult->cbCardCount[cbResultIndex], cbTmpCardData,cbTmpCardCount ) ); cbTmpCardCount -= pSearchCardResult->cbCardCount[cbResultIndex]; //分析牌 tagAnalyseResult TmpResult = {}; AnalysebCardData( cbTmpCardData,cbTmpCardCount,TmpResult ); //提取牌 BYTE cbDistillCard[MAX_COUNT] = {}; BYTE cbDistillCount = 0; for( BYTE j = cbTakeCardCount-1; j < CountArray(TmpResult.cbBlockCount); j++ ) { if( TmpResult.cbBlockCount[j] > 0 ) { if( j+1 == cbTakeCardCount && TmpResult.cbBlockCount[j] >= cbLineCount ) { BYTE cbTmpBlockCount = TmpResult.cbBlockCount[j]; CopyMemory( cbDistillCard,&TmpResult.cbCardData[j][(cbTmpBlockCount-cbLineCount)*(j+1)], sizeof(BYTE)*(j+1)*cbLineCount ); cbDistillCount = (j+1)*cbLineCount; break; } else { for( BYTE k = 0; k < TmpResult.cbBlockCount[j]; k++ ) { BYTE cbTmpBlockCount = TmpResult.cbBlockCount[j]; CopyMemory( &cbDistillCard[cbDistillCount],&TmpResult.cbCardData[j][(cbTmpBlockCount-k-1)*(j+1)], sizeof(BYTE)*cbTakeCardCount ); cbDistillCount += cbTakeCardCount; //提取完成 if( cbDistillCount == cbTakeCardCount*cbLineCount ) break; } } } //提取完成 if( cbDistillCount == cbTakeCardCount*cbLineCount ) break; } //提取完成 if( cbDistillCount == cbTakeCardCount*cbLineCount ) { //复制带牌 BYTE cbCount = pSearchCardResult->cbCardCount[cbResultIndex]; CopyMemory( &pSearchCardResult->cbResultCard[cbResultIndex][cbCount],cbDistillCard, sizeof(BYTE)*cbDistillCount ); pSearchCardResult->cbCardCount[cbResultIndex] += cbDistillCount; } //否则删除连牌 else { bAllDistill = false; pSearchCardResult->cbCardCount[cbResultIndex] = 0; } } //整理组合 if( !bAllDistill ) { pSearchCardResult->cbSearchCount = cbResultCount; cbResultCount = 0; for( BYTE i = 0; i < pSearchCardResult->cbSearchCount; i++ ) { if( pSearchCardResult->cbCardCount[i] != 0 ) { tmpSearchCardResult.cbCardCount[cbResultCount] = pSearchCardResult->cbCardCount[i]; CopyMemory( tmpSearchCardResult.cbResultCard[cbResultCount],pSearchCardResult->cbResultCard[i], sizeof(BYTE)*pSearchCardResult->cbCardCount[i] ); cbResultCount++; } } tmpSearchCardResult.cbSearchCount = cbResultCount; CopyMemory( pSearchCardResult,&tmpSearchCardResult,sizeof(tagSearchCardResult) ); } } break; } case CT_FOUR_TAKE_ONE: //四带两单 case CT_FOUR_TAKE_TWO: //四带两双 { BYTE cbTakeCount = cbTurnOutType==CT_FOUR_TAKE_ONE?1:2; BYTE cbTmpTurnCard[MAX_COUNT] = {}; CopyMemory( cbTmpTurnCard,cbTurnCardData,sizeof(BYTE)*cbTurnCardCount ); SortOutCardList( cbTmpTurnCard,cbTurnCardCount ); //搜索带牌 cbResultCount = SearchTakeCardType( cbCardData,cbCardCount,cbTmpTurnCard[0],4,cbTakeCount,pSearchCardResult ); break; } } //搜索炸弹 if ((cbCardCount>=4)&&(cbTurnOutType!=CT_MISSILE_CARD)) { //变量定义 BYTE cbReferCard = 0; if (cbTurnOutType==CT_BOMB_CARD) cbReferCard=cbTurnCardData[0]; //搜索炸弹 BYTE cbTmpResultCount = SearchSameCard( cbCardData,cbCardCount,cbReferCard,4,&tmpSearchCardResult ); for( BYTE i = 0; i < cbTmpResultCount; i++ ) { pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[i]; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSearchCardResult.cbResultCard[i], sizeof(BYTE)*tmpSearchCardResult.cbCardCount[i] ); cbResultCount++; } } //搜索火箭 if (cbTurnOutType!=CT_MISSILE_CARD&&(cbCardCount>=2)&&(cbCardData[0]==0x4F)&&(cbCardData[1]==0x4E)) { //设置结果 pSearchCardResult->cbCardCount[cbResultCount] = 2; pSearchCardResult->cbResultCard[cbResultCount][0] = cbCardData[0]; pSearchCardResult->cbResultCard[cbResultCount][1] = cbCardData[1]; cbResultCount++; } pSearchCardResult->cbSearchCount = cbResultCount; return cbResultCount; } //同牌搜索 BYTE CGameLogic::SearchSameCard( const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbSameCardCount, tagSearchCardResult *pSearchCardResult ) { //设置结果 if( pSearchCardResult ) ZeroMemory(pSearchCardResult,sizeof(tagSearchCardResult)); BYTE cbResultCount = 0; //构造扑克 BYTE cbCardData[MAX_COUNT]; BYTE cbCardCount=cbHandCardCount; CopyMemory(cbCardData,cbHandCardData,sizeof(BYTE)*cbHandCardCount); //排列扑克 SortCardList(cbCardData,cbCardCount,ST_ORDER); //分析扑克 tagAnalyseResult AnalyseResult = {}; AnalysebCardData( cbCardData,cbCardCount,AnalyseResult ); BYTE cbReferLogicValue = cbReferCard==0?0:GetCardLogicValue(cbReferCard); BYTE cbBlockIndex = cbSameCardCount-1; do { for( BYTE i = 0; i < AnalyseResult.cbBlockCount[cbBlockIndex]; i++ ) { BYTE cbIndex = (AnalyseResult.cbBlockCount[cbBlockIndex]-i-1)*(cbBlockIndex+1); if( GetCardLogicValue(AnalyseResult.cbCardData[cbBlockIndex][cbIndex]) > cbReferLogicValue ) { if( pSearchCardResult == NULL ) return 1; ASSERT( cbResultCount < CountArray(pSearchCardResult->cbCardCount) ); //复制扑克 CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],&AnalyseResult.cbCardData[cbBlockIndex][cbIndex], cbSameCardCount*sizeof(BYTE) ); pSearchCardResult->cbCardCount[cbResultCount] = cbSameCardCount; cbResultCount++; } } cbBlockIndex++; }while( cbBlockIndex < CountArray(AnalyseResult.cbBlockCount) ); if( pSearchCardResult ) pSearchCardResult->cbSearchCount = cbResultCount; return cbResultCount; } //带牌类型搜索(三带一,四带一等) BYTE CGameLogic::SearchTakeCardType( const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbSameCount, BYTE cbTakeCardCount, tagSearchCardResult *pSearchCardResult ) { //设置结果 if( pSearchCardResult ) ZeroMemory(pSearchCardResult,sizeof(tagSearchCardResult)); BYTE cbResultCount = 0; //效验 ASSERT( cbSameCount == 3 || cbSameCount == 4 ); ASSERT( cbTakeCardCount == 1 || cbTakeCardCount == 2 ); if( cbSameCount != 3 && cbSameCount != 4 ) return cbResultCount; if( cbTakeCardCount != 1 && cbTakeCardCount != 2 ) return cbResultCount; //长度判断 if( cbSameCount == 4 && cbHandCardCount<cbSameCount+cbTakeCardCount*2 || cbHandCardCount < cbSameCount+cbTakeCardCount ) return cbResultCount; //构造扑克 BYTE cbCardData[MAX_COUNT]; BYTE cbCardCount=cbHandCardCount; CopyMemory(cbCardData,cbHandCardData,sizeof(BYTE)*cbHandCardCount); //排列扑克 SortCardList(cbCardData,cbCardCount,ST_ORDER); //搜索同张 tagSearchCardResult SameCardResult = {}; BYTE cbSameCardResultCount = SearchSameCard( cbCardData,cbCardCount,cbReferCard,cbSameCount,&SameCardResult ); if( cbSameCardResultCount > 0 ) { //分析扑克 tagAnalyseResult AnalyseResult; AnalysebCardData(cbCardData,cbCardCount,AnalyseResult); //需要牌数 BYTE cbNeedCount = cbSameCount+cbTakeCardCount; if( cbSameCount == 4 ) cbNeedCount += cbTakeCardCount; //提取带牌 for( BYTE i = 0; i < cbSameCardResultCount; i++ ) { bool bMerge = false; for( BYTE j = cbTakeCardCount-1; j < CountArray(AnalyseResult.cbBlockCount); j++ ) { for( BYTE k = 0; k < AnalyseResult.cbBlockCount[j]; k++ ) { //从小到大 BYTE cbIndex = (AnalyseResult.cbBlockCount[j]-k-1)*(j+1); //过滤相同牌 if( GetCardValue(SameCardResult.cbResultCard[i][0]) == GetCardValue(AnalyseResult.cbCardData[j][cbIndex]) ) continue; //复制带牌 BYTE cbCount = SameCardResult.cbCardCount[i]; CopyMemory( &SameCardResult.cbResultCard[i][cbCount],&AnalyseResult.cbCardData[j][cbIndex], sizeof(BYTE)*cbTakeCardCount ); SameCardResult.cbCardCount[i] += cbTakeCardCount; if( SameCardResult.cbCardCount[i] < cbNeedCount ) continue; if( pSearchCardResult == NULL ) return 1; //复制结果 CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],SameCardResult.cbResultCard[i], sizeof(BYTE)*SameCardResult.cbCardCount[i] ); pSearchCardResult->cbCardCount[cbResultCount] = SameCardResult.cbCardCount[i]; cbResultCount++; bMerge = true; //下一组合 break; } if( bMerge ) break; } } } if( pSearchCardResult ) pSearchCardResult->cbSearchCount = cbResultCount; return cbResultCount; } //连牌搜索 BYTE CGameLogic::SearchLineCardType( const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbBlockCount, BYTE cbLineCount, tagSearchCardResult *pSearchCardResult ) { //设置结果 if( pSearchCardResult ) ZeroMemory(pSearchCardResult,sizeof(tagSearchCardResult)); BYTE cbResultCount = 0; //定义变量 BYTE cbLessLineCount = 0; if( cbLineCount == 0 ) { if( cbBlockCount == 1 ) cbLessLineCount = 5; else if( cbBlockCount == 2 ) cbLessLineCount = 3; else cbLessLineCount = 2; } else cbLessLineCount = cbLineCount; BYTE cbReferIndex = 2; if( cbReferCard != 0 ) { ASSERT( GetCardLogicValue(cbReferCard)-cbLessLineCount>=2 ); cbReferIndex = GetCardLogicValue(cbReferCard)-cbLessLineCount+1; } //超过A if( cbReferIndex+cbLessLineCount > 14 ) return cbResultCount; //长度判断 if( cbHandCardCount < cbLessLineCount*cbBlockCount ) return cbResultCount; //构造扑克 BYTE cbCardData[MAX_COUNT]; BYTE cbCardCount=cbHandCardCount; CopyMemory(cbCardData,cbHandCardData,sizeof(BYTE)*cbHandCardCount); //排列扑克 SortCardList(cbCardData,cbCardCount,ST_ORDER); //分析扑克 tagDistributing Distributing = {}; AnalysebDistributing(cbCardData,cbCardCount,Distributing); //搜索顺子 BYTE cbTmpLinkCount = 0; BYTE cbValueIndex = cbReferIndex; for (cbValueIndex=cbReferIndex;cbValueIndex<13;cbValueIndex++) { //继续判断 if ( Distributing.cbDistributing[cbValueIndex][cbIndexCount]<cbBlockCount ) { if( cbTmpLinkCount < cbLessLineCount ) { cbTmpLinkCount=0; continue; } else cbValueIndex--; } else { cbTmpLinkCount++; //寻找最长连 if( cbLineCount == 0 ) continue; } if( cbTmpLinkCount >= cbLessLineCount ) { if( pSearchCardResult == NULL ) return 1; ASSERT( cbResultCount < CountArray(pSearchCardResult->cbCardCount) ); //复制扑克 BYTE cbCount = 0; for( BYTE cbIndex = cbValueIndex+1-cbTmpLinkCount; cbIndex <= cbValueIndex; cbIndex++ ) { BYTE cbTmpCount = 0; for (BYTE cbColorIndex=0;cbColorIndex<4;cbColorIndex++) { for( BYTE cbColorCount = 0; cbColorCount < Distributing.cbDistributing[cbIndex][3-cbColorIndex]; cbColorCount++ ) { pSearchCardResult->cbResultCard[cbResultCount][cbCount++]=MakeCardData(cbIndex,3-cbColorIndex); if( ++cbTmpCount == cbBlockCount ) break; } if( cbTmpCount == cbBlockCount ) break; } } //设置变量 pSearchCardResult->cbCardCount[cbResultCount] = cbCount; cbResultCount++; if( cbLineCount != 0 ) { cbTmpLinkCount--; } else { cbTmpLinkCount = 0; } } } //特殊顺子 if( cbTmpLinkCount >= cbLessLineCount-1 && cbValueIndex == 13 ) { if( Distributing.cbDistributing[0][cbIndexCount] >= cbBlockCount || cbTmpLinkCount >= cbLessLineCount ) { if( pSearchCardResult == NULL ) return 1; ASSERT( cbResultCount < CountArray(pSearchCardResult->cbCardCount) ); //复制扑克 BYTE cbCount = 0; BYTE cbTmpCount = 0; for( BYTE cbIndex = cbValueIndex-cbTmpLinkCount; cbIndex < 13; cbIndex++ ) { cbTmpCount = 0; for (BYTE cbColorIndex=0;cbColorIndex<4;cbColorIndex++) { for( BYTE cbColorCount = 0; cbColorCount < Distributing.cbDistributing[cbIndex][3-cbColorIndex]; cbColorCount++ ) { pSearchCardResult->cbResultCard[cbResultCount][cbCount++]=MakeCardData(cbIndex,3-cbColorIndex); if( ++cbTmpCount == cbBlockCount ) break; } if( cbTmpCount == cbBlockCount ) break; } } //复制A if( Distributing.cbDistributing[0][cbIndexCount] >= cbBlockCount ) { cbTmpCount = 0; for (BYTE cbColorIndex=0;cbColorIndex<4;cbColorIndex++) { for( BYTE cbColorCount = 0; cbColorCount < Distributing.cbDistributing[0][3-cbColorIndex]; cbColorCount++ ) { pSearchCardResult->cbResultCard[cbResultCount][cbCount++]=MakeCardData(0,3-cbColorIndex); if( ++cbTmpCount == cbBlockCount ) break; } if( cbTmpCount == cbBlockCount ) break; } } //设置变量 pSearchCardResult->cbCardCount[cbResultCount] = cbCount; cbResultCount++; } } if( pSearchCardResult ) pSearchCardResult->cbSearchCount = cbResultCount; return cbResultCount; } //搜索飞机 BYTE CGameLogic::SearchThreeTwoLine( const BYTE cbHandCardData[], BYTE cbHandCardCount, tagSearchCardResult *pSearchCardResult ) { //设置结果 if( pSearchCardResult ) ZeroMemory(pSearchCardResult,sizeof(tagSearchCardResult)); //变量定义 tagSearchCardResult tmpSearchResult = {}; tagSearchCardResult tmpSingleWing = {}; tagSearchCardResult tmpDoubleWing = {}; BYTE cbTmpResultCount = 0; //搜索连牌 cbTmpResultCount = SearchLineCardType( cbHandCardData,cbHandCardCount,0,3,0,&tmpSearchResult ); if( cbTmpResultCount > 0 ) { //提取带牌 for( BYTE i = 0; i < cbTmpResultCount; i++ ) { //变量定义 BYTE cbTmpCardData[MAX_COUNT]; BYTE cbTmpCardCount = cbHandCardCount; //不够牌 if( cbHandCardCount-tmpSearchResult.cbCardCount[i] < tmpSearchResult.cbCardCount[i]/3 ) { BYTE cbNeedDelCount = 3; while( cbHandCardCount+cbNeedDelCount-tmpSearchResult.cbCardCount[i] < (tmpSearchResult.cbCardCount[i]-cbNeedDelCount)/3 ) cbNeedDelCount += 3; //不够连牌 if( (tmpSearchResult.cbCardCount[i]-cbNeedDelCount)/3 < 2 ) { //废除连牌 continue; } //拆分连牌 RemoveCard( tmpSearchResult.cbResultCard[i],cbNeedDelCount,tmpSearchResult.cbResultCard[i], tmpSearchResult.cbCardCount[i] ); tmpSearchResult.cbCardCount[i] -= cbNeedDelCount; } if( pSearchCardResult == NULL ) return 1; //删除连牌 CopyMemory( cbTmpCardData,cbHandCardData,sizeof(BYTE)*cbHandCardCount ); VERIFY( RemoveCard( tmpSearchResult.cbResultCard[i],tmpSearchResult.cbCardCount[i], cbTmpCardData,cbTmpCardCount ) ); cbTmpCardCount -= tmpSearchResult.cbCardCount[i]; //组合飞机 BYTE cbNeedCount = tmpSearchResult.cbCardCount[i]/3; ASSERT( cbNeedCount <= cbTmpCardCount ); BYTE cbResultCount = tmpSingleWing.cbSearchCount++; CopyMemory( tmpSingleWing.cbResultCard[cbResultCount],tmpSearchResult.cbResultCard[i], sizeof(BYTE)*tmpSearchResult.cbCardCount[i] ); CopyMemory( &tmpSingleWing.cbResultCard[cbResultCount][tmpSearchResult.cbCardCount[i]], &cbTmpCardData[cbTmpCardCount-cbNeedCount],sizeof(BYTE)*cbNeedCount ); tmpSingleWing.cbCardCount[i] = tmpSearchResult.cbCardCount[i]+cbNeedCount; //不够带翅膀 if( cbTmpCardCount < tmpSearchResult.cbCardCount[i]/3*2 ) { BYTE cbNeedDelCount = 3; while( cbTmpCardCount+cbNeedDelCount-tmpSearchResult.cbCardCount[i] < (tmpSearchResult.cbCardCount[i]-cbNeedDelCount)/3*2 ) cbNeedDelCount += 3; //不够连牌 if( (tmpSearchResult.cbCardCount[i]-cbNeedDelCount)/3 < 2 ) { //废除连牌 continue; } //拆分连牌 RemoveCard( tmpSearchResult.cbResultCard[i],cbNeedDelCount,tmpSearchResult.cbResultCard[i], tmpSearchResult.cbCardCount[i] ); tmpSearchResult.cbCardCount[i] -= cbNeedDelCount; //重新删除连牌 CopyMemory( cbTmpCardData,cbHandCardData,sizeof(BYTE)*cbHandCardCount ); VERIFY( RemoveCard( tmpSearchResult.cbResultCard[i],tmpSearchResult.cbCardCount[i], cbTmpCardData,cbTmpCardCount ) ); cbTmpCardCount = cbHandCardCount-tmpSearchResult.cbCardCount[i]; } //分析牌 tagAnalyseResult TmpResult = {}; AnalysebCardData( cbTmpCardData,cbTmpCardCount,TmpResult ); //提取翅膀 BYTE cbDistillCard[MAX_COUNT] = {}; BYTE cbDistillCount = 0; BYTE cbLineCount = tmpSearchResult.cbCardCount[i]/3; for( BYTE j = 1; j < CountArray(TmpResult.cbBlockCount); j++ ) { if( TmpResult.cbBlockCount[j] > 0 ) { if( j+1 == 2 && TmpResult.cbBlockCount[j] >= cbLineCount ) { BYTE cbTmpBlockCount = TmpResult.cbBlockCount[j]; CopyMemory( cbDistillCard,&TmpResult.cbCardData[j][(cbTmpBlockCount-cbLineCount)*(j+1)], sizeof(BYTE)*(j+1)*cbLineCount ); cbDistillCount = (j+1)*cbLineCount; break; } else { for( BYTE k = 0; k < TmpResult.cbBlockCount[j]; k++ ) { BYTE cbTmpBlockCount = TmpResult.cbBlockCount[j]; CopyMemory( &cbDistillCard[cbDistillCount],&TmpResult.cbCardData[j][(cbTmpBlockCount-k-1)*(j+1)], sizeof(BYTE)*2 ); cbDistillCount += 2; //提取完成 if( cbDistillCount == 2*cbLineCount ) break; } } } //提取完成 if( cbDistillCount == 2*cbLineCount ) break; } //提取完成 if( cbDistillCount == 2*cbLineCount ) { //复制翅膀 cbResultCount = tmpDoubleWing.cbSearchCount++; CopyMemory( tmpDoubleWing.cbResultCard[cbResultCount],tmpSearchResult.cbResultCard[i], sizeof(BYTE)*tmpSearchResult.cbCardCount[i] ); CopyMemory( &tmpDoubleWing.cbResultCard[cbResultCount][tmpSearchResult.cbCardCount[i]], cbDistillCard,sizeof(BYTE)*cbDistillCount ); tmpDoubleWing.cbCardCount[i] = tmpSearchResult.cbCardCount[i]+cbDistillCount; } } //复制结果 for( BYTE i = 0; i < tmpDoubleWing.cbSearchCount; i++ ) { BYTE cbResultCount = pSearchCardResult->cbSearchCount++; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpDoubleWing.cbResultCard[i], sizeof(BYTE)*tmpDoubleWing.cbCardCount[i] ); pSearchCardResult->cbCardCount[cbResultCount] = tmpDoubleWing.cbCardCount[i]; } for( BYTE i = 0; i < tmpSingleWing.cbSearchCount; i++ ) { BYTE cbResultCount = pSearchCardResult->cbSearchCount++; CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],tmpSingleWing.cbResultCard[i], sizeof(BYTE)*tmpSingleWing.cbCardCount[i] ); pSearchCardResult->cbCardCount[cbResultCount] = tmpSingleWing.cbCardCount[i]; } } return pSearchCardResult==NULL?0:pSearchCardResult->cbSearchCount; } //////////////////////////////////////////////////////////////////////////////////
[ "po2656233@qq.com" ]
po2656233@qq.com
5bfb294098e921a34bfa651ff17731e938da6e43
d3131b2bfce7beb9216b616c755102f2625158a2
/src/glis/internal/fps.cpp
a1b56048449b59a515d5f94a12aacd937d77301d
[]
no_license
gitter-badger/GLIS
8175b18f7d8960cd19a853eebf690a07dd080d3a
00b0a2bf721bb6ff7612ba65334cf1216a152594
refs/heads/master
2022-11-27T08:35:40.782407
2020-08-13T13:18:35
2020-08-13T13:19:14
287,288,006
0
0
null
2020-08-13T13:29:37
2020-08-13T13:29:36
null
UTF-8
C++
false
false
695
cpp
#include <glis/internal/fps.hpp> #include <sys/time.h> // struct timeval, gettimeofday long GLIS_FPS::getCurrentTime(void) { struct timeval tv = {0}; gettimeofday(&tv, NULL); return tv.tv_sec * 1000. + tv.tv_usec / 1000.; } void GLIS_FPS::onFrameStart() { frameStartTime = getCurrentTime(); } void GLIS_FPS::onFrameEnd() { int frameLength = getCurrentTime() - frameStartTime; frameLengths.push(frameLength); queueAggregate += frameLength; while (queueAggregate > trackedTime) { int oldFrame = frameLengths.front(); frameLengths.pop(); queueAggregate -= oldFrame; } averageFps = frameLengths.size() / (trackedTime / 1000); }
[ "smallville7123@gmail.com" ]
smallville7123@gmail.com
a4b863ba9cf268f0daf29c1ffe13761403ac1579
e9a075c0619679913df292293b47e9e8ec292450
/lab3/ex2/ex2.cpp
9bb813863dfc7862823b15309bb7d21a038e5c6f
[]
no_license
RoyRyy/cpp
e34990c7c02718f338aa1b1b0138b1cd13ffe8cf
e8aeaecf2a95be9ea7f4ba8e704c34136fec624e
refs/heads/master
2020-12-26T19:37:27.249019
2020-09-18T01:53:54
2020-09-18T01:53:54
237,617,884
1
0
null
null
null
null
UTF-8
C++
false
false
357
cpp
#include <iostream> #include<string> using namespace std; int main() { char a[100], b[50]; int i=0, j=0; cout << "Please input string 1:" << endl; cin >> a; cout << "Please input string 2:"<< endl; cin >> b; while (a[i] != '\0') i++; while (b[j] != '\0') { a[i++] = b[j++]; a[i] = '\0'; } cout << a << endl; system("pause"); }
[ "2524380603@qq.com" ]
2524380603@qq.com
1631d993891819c8bd201364c1123489d934e2cc
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5631572862566400_0/C++/gvaibhav21/C.cpp
5917318cd0968db6759f369f55f1d605b46cf7f3
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,369
cpp
#include<bits/stdc++.h> using namespace std; #define sd(a) scanf("%d",&a) #define ss(a) scanf("%s",&a) #define sl(a) scanf("%lld",&a) #define clr(a) memset(a,0,sizeof(a)) #define debug(a) printf("check%d\n",a) #define F first #define S second #define MP make_pair #define PB push_back #define ll long long int bff[1010]; int mark[1010]; int Time[1010]; vector<int> v[1010]; int maxd; void dfs(int cur,int d) { mark[cur]=1; maxd=max(maxd,d); for(int i=0;i<v[cur].size();++i) if(!mark[v[cur][i]] && v[cur][i]!=bff[cur]) dfs(v[cur][i],d+1); } int main() { //freopen("C_1.in","r",stdin); //freopen("C_1.out","w",stdout); int t,i,j,k,n; sd(t); for(int tt=1;tt<=t;tt++) { sd(n); clr(mark); for(i=1;i<=n;++i) v[i].clear(); for(i=1;i<=n;++i) { sd(bff[i]); v[bff[i]].PB(i); } int cnt=0,maxx=-1,j=1; for(i=1;i<=n;++i) { if(mark[i]) continue; j++; int cur=i,c=0; while(true) { if(mark[cur]) { if(mark[cur]==j) { int cycle=c-Time[cur]+1; maxx=max(maxx,cycle); } break; } mark[cur]=j; Time[cur]=++c; cur=bff[cur]; } } clr(mark); for(i=1;i<=n;++i) { if(mark[i]) continue; if(bff[bff[i]]!=i) continue; cnt+=2; maxd=-1; dfs(i,0); cnt+=maxd; maxd=-1; dfs(bff[i],0); cnt+=maxd; } printf("Case #%d: %d\n",tt,max(maxx,cnt)); } }
[ "alexandra1.back@gmail.com" ]
alexandra1.back@gmail.com
d6456844b8458d37e4a294db0aea2f0b2634fff9
a1fbf16243026331187b6df903ed4f69e5e8c110
/cs/engine/layers/xrRenderDX10/3DFluid/dx103DFluidVolume.h
98981243e31e77158f715289ce5a59d152b5b4fa
[ "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
OpenXRay/xray-15
ca0031cf1893616e0c9795c670d5d9f57ca9beff
1390dfb08ed20997d7e8c95147ea8e8cb71f5e86
refs/heads/xd_dev
2023-07-17T23:42:14.693841
2021-09-01T23:25:34
2021-09-01T23:25:34
23,224,089
64
23
NOASSERTION
2019-04-03T17:50:18
2014-08-22T12:09:41
C++
UTF-8
C++
false
false
624
h
#ifndef dx103DFluidVolume_included #define dx103DFluidVolume_included #pragma once #include "dx103DFluidData.h" #include "../../xrRender/FBasicVisual.h" class dx103DFluidVolume : public dxRender_Visual { public: dx103DFluidVolume(); virtual ~dx103DFluidVolume(); virtual void Load( LPCSTR N, IReader *data, u32 dwFlags ); virtual void Render( float LOD ); // LOD - Level Of Detail [0.0f - min, 1.0f - max], Ignored ? virtual void Copy( dxRender_Visual *pFrom ); virtual void Release(); private: // For debug purpose only ref_geom m_Geom; dx103DFluidData m_FluidData; }; #endif // dx103DFluidVolume_included
[ "paul-kv@yandex.ru" ]
paul-kv@yandex.ru
6fbea92e7f36f02ed3fb709343090994a25367bd
9160d5980d55c64c2bbc7933337e5e1f4987abb0
/base/src/sgpp/base/operation/hash/OperationEvalModNakBsplineNaive.hpp
30f05c8098c7c17248bb9f0f3b9e184f1924a4df
[ "LicenseRef-scancode-generic-exception", "BSD-3-Clause" ]
permissive
SGpp/SGpp
55e82ecd95ac98efb8760d6c168b76bc130a4309
52f2718e3bbca0208e5e08b3c82ec7c708b5ec06
refs/heads/master
2022-08-07T12:43:44.475068
2021-10-20T08:50:38
2021-10-20T08:50:38
123,916,844
68
44
NOASSERTION
2022-06-23T08:28:45
2018-03-05T12:33:52
C++
UTF-8
C++
false
false
1,971
hpp
// Copyright (C) 2008-today The SG++ project // This file is part of the SG++ project. For conditions of distribution and // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org #ifndef OPERATIONEVALMODNAKBSPLINENAIVE_HPP #define OPERATIONEVALMODNAKBSPLINENAIVE_HPP #include <sgpp/globaldef.hpp> #include <sgpp/base/operation/hash/OperationEval.hpp> #include <sgpp/base/grid/GridStorage.hpp> #include <sgpp/base/operation/hash/common/basis/NakBsplineModifiedBasis.hpp> #include <sgpp/base/datatypes/DataVector.hpp> namespace sgpp { namespace base { /** * Operation for evaluating modified B-spline linear combinations on Noboundary grids with * not-a-knot boundary conditions. */ class OperationEvalModNakBsplineNaive : public OperationEval { public: /** * Constructor. * * @param storage storage of the sparse grid * @param degree B-spline degree */ OperationEvalModNakBsplineNaive(GridStorage& storage, size_t degree) : storage(storage), base(degree), pointInUnitCube(storage.getDimension()) { } /** * Destructor. */ ~OperationEvalModNakBsplineNaive() override { } /** * @param alpha coefficient vector * @param point evaluation point * @return value of the linear combination */ double eval(const DataVector& alpha, const DataVector& point) override; /** * @param alpha coefficient matrix (each column is a coefficient vector) * @param point evaluation point * @param[out] value values of linear combination */ void eval(const DataMatrix& alpha, const DataVector& point, DataVector& value) override; protected: /// storage of the sparse grid GridStorage& storage; /// 1D B-spline basis SNakBsplineModifiedBase base; /// untransformed evaluation point (temporary vector) DataVector pointInUnitCube; }; } // namespace base } // namespace sgpp #endif /* OPERATIONEVALMODNAKBSPLINENAIVE_HPP */
[ "julian.valentin@ipvs.uni-stuttgart.de" ]
julian.valentin@ipvs.uni-stuttgart.de
d1f662b81a09bab11acd4becce39f3a12998b585
94b3e44d2afd56628adfec64b556dc4d333882b0
/Count number of hops.cpp
ef5b16aee10708dc04070fbcb01a8411f57d49cd
[]
no_license
parasiitism/Dynamic-Programing-For-Interview
191f08e3f83c38255751297a9438f193353c5745
938a8a28d9fa8797b0dd98daa3943ade6e45e3cd
refs/heads/main
2022-12-25T07:13:53.524450
2020-10-06T13:27:33
2020-10-06T13:27:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,516
cpp
//Problem link: https://practice.geeksforgeeks.org/problems/count-number-of-hops/0/ //THIS IS A SIMPLE PROBLEM OF DP //DIFFERENCE FROM COIN CHAGE IS:🧐🧐 //In coin change, we consider 1 2 1 , 1 1 2 and 2 1 1 all same, //but here we have to count 3 for all the above cases seperately. //Explaination😋😋 //For counting the number of hops for 4, we add all the possible hops //for 3,2,1 we have 3 hops for 3, 2 hops for 2, 1 hop for 1, so for 4 there //are 3+2+1 7 hops //Similarly, if we take 5, see in recursion tree made below, for going through 4 //we can take either path from 3, from 2 , from 1 so 7 paths from going through //4 and rest we can also make 5 by 3+2, and ways of reaching 3 is 4 so now //number of ways reaching 5 becomes 7+4 i.e 11 //Now, we can still go to 5 by 2+3 and ways of reaching 2 is 2, so ways of //reaching 5 finally becomes 11+2=13ans. #include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int steps; cin>>steps; int dp[steps+1]; //We need to start for loop from 3 and declare rest of dp values //exclusively to avoid negative indexing error dp[0]=1; dp[1]=1; dp[2]=2; if(steps==1||steps==2) cout<<steps<<endl; else { for(int i=3;i<=steps;i++) { dp[i]=dp[i-1]+dp[i-2]+dp[i-3]; } cout<<dp[steps]<<endl; } } }
[ "noreply@github.com" ]
parasiitism.noreply@github.com
c6b5d99e50af49ad72ea7640f676f8692a0edc78
53a3313ef0effa5447114b5008ae4e81867a7d7d
/scanAndWriteRFIDsToFile/scanAndWriteRFIDsToFile.ino
fc6ca89f7a7732f7cb87858c568c8ee2597fe3ac
[]
no_license
abreuse/hackyouin
1c29aae4c198ee4ceb391e951d38e810b43f707b
754e5415d47b0f935dee39f7aba95705a7eb3935
refs/heads/master
2020-12-06T17:14:46.310841
2017-03-17T15:31:42
2017-03-17T15:31:42
95,567,876
1
0
null
2017-06-27T14:34:55
2017-06-27T14:34:55
null
UTF-8
C++
false
false
5,047
ino
#include <SPI.h> #include <MFRC522.h> #include <ESP8266WiFi.h> #include "Gsender.h" #include "FS.h" #include <vector> #define RST_PIN 2 // Configurable, see typical pin layout above #define SS_PIN 15 // Configurable, see typical pin layout above #pragma region Globals const char* ssid = "HotspotRFID"; // WIFI network name const char* password = "hotspotRFID"; // WIFI network password uint8_t connection_state = 0; // Connected to WIFI or not uint16_t reconnect_interval = 10000; // If not connected wait time to try again String mailAdr = "breusemanouanaesgi@gmail.com"; String pathFile = "/rfids.txt"; struct rfid { String UID; String type; }; std::vector<rfid> rfids; #pragma endregion Globals MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. char choice; void setup() { Serial.begin(115200); // Initialize serial communications with the PC SPIFFS.begin(); Serial.println("Please wait 30 secs for SPIFFS to be formatted"); //SPIFFS.format(); Serial.println("Spiffs formatted"); while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); } String convertUidToString(byte *buffer, byte bufferSize) { String UID = ""; for (byte i = 0; i < bufferSize; i++) { UID = UID + (buffer[i] < 0x10 ? " 0" : " "); UID = UID + (String(buffer[i], HEX)); Serial.print(buffer[i] < 0x10 ? " 0" : " "); Serial.print(buffer[i], HEX); } return UID; } void appendRFIDToFile(rfid scannedRfid, String pathFile) { File file = SPIFFS.open(pathFile, "a"); Serial.println("file : " + file); if (!file) { Serial.println("file open failed"); } Serial.println("====== Writing" + scannedRfid.UID + scannedRfid.type + "========="); file.println(scannedRfid.UID); file.println(scannedRfid.type); readUidsFromFile(pathFile); file.close(); } String readUidsFromFile(String pathFile) { String uids = " "; char c = ' '; File file = SPIFFS.open(pathFile, "r"); if (!file) { Serial.println("file open failed"); } while (file.available()) { c = file.read(); uids = uids + String(c); } Serial.println("read = " + uids); file.close(); return uids; } uint8_t WiFiConnect(const char* nSSID = nullptr, const char* nPassword = nullptr) { static uint16_t attempt = 0; Serial.print("Connecting to "); if(nSSID) { WiFi.begin(nSSID, nPassword); Serial.println(nSSID); } else { WiFi.begin(ssid, password); Serial.println(ssid); } uint8_t i = 0; while(WiFi.status()!= WL_CONNECTED && i++ < 50) { delay(200); Serial.print("."); } ++attempt; Serial.println(""); if(i == 51) { //timeout Serial.print("Connection: TIMEOUT on attempt: "); Serial.println(attempt); if(attempt % 2 == 0) Serial.println("Check if access point available or SSID and Password\r\n"); return false; } Serial.println("Connection: ESTABLISHED"); Serial.print("Got IP address: "); Serial.println(WiFi.localIP()); return true; } void loop() { scanRFID(); } void scanRFID() { //Serial.println("Waiting for card to scan..."); if ( ! mfrc522.PICC_IsNewCardPresent()) return; if ( ! mfrc522.PICC_ReadCardSerial()) return; rfid scannedRfid; scannedRfid.UID = ""; scannedRfid.type = ""; scannedRfid.UID = scannedRfid.UID + F("Card UID:"); scannedRfid.UID = scannedRfid.UID + convertUidToString(mfrc522.uid.uidByte, mfrc522.uid.size); scannedRfid.type = scannedRfid.type + F("PICC type: "); MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); scannedRfid.type = scannedRfid.type + mfrc522.PICC_GetTypeName(piccType); if(RfidAlreadyScanned(scannedRfid)) { return; } else { Serial.println("UID not found"); appendRFIDToFile(scannedRfid, pathFile); } } bool RfidAlreadyScanned(rfid scannedRfid) { for(int i = 0; i < rfids.size(); i++) { Serial.println("UID in array : " + rfids[i].UID); if(scannedRfid.UID == rfids[i].UID) { Serial.println("RFIDS already scanned"); return true; } } rfids.push_back(scannedRfid); return false; } void sendMail() { connection_state = WiFiConnect(); if (!connection_state) Awaits(); String RFIDS = readUidsFromFile(pathFile); Gsender *gsender = Gsender::Instance(); String subject = "Your RFIDS"; if (gsender->Subject(subject)->Send(mailAdr, RFIDS)) { Serial.println("Mail sent."); } else { Serial.print("Error sending message: "); Serial.println(gsender->getError()); } } void Awaits() { uint32_t ts = millis(); while(!connection_state) { delay(50); if(millis() > (ts + reconnect_interval) && !connection_state) { connection_state = WiFiConnect(); ts = millis(); } } }
[ "Alexis@MacBook-Pro-de-Alexis.local" ]
Alexis@MacBook-Pro-de-Alexis.local
a7c93a80e9a1944adf528b7bf63d3833873d0024
4e1190455394bb008b9299082cdbd236477e293a
/CodeForces/Rounds/578 (Div.2)/b.cpp
0c6d1425af62b6a59c33e576627d9fa552ebbe22
[]
no_license
Leonardosu/competitive_programming
64b62fc5a1731763a1bee0f99f9a9d7df15e9e8a
01ce1e4f3cb4dc3c5973774287f2e32f92418987
refs/heads/master
2023-08-04T06:27:26.384700
2023-07-24T19:47:57
2023-07-24T19:47:57
202,539,762
4
6
null
2022-10-25T00:24:54
2019-08-15T12:46:33
C++
UTF-8
C++
false
false
424
cpp
#include <bits/stdc++.h> #define N 110 using namespace std; int v[N],t; int n,m,k; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>t; while(t--) { cin>>n>>m>>k; bool impossible = false; for(int i=1;i<=n;++i) cin>>v[i]; for(int i=1;i<n;++i) { m+=v[i] - max(0,v[i+1]-k); if(m<0) { cout<<"NO\n"; impossible = true; break; } } if(!impossible) cout<<"YES\n"; } }
[ "leonardosu0@gmail.com" ]
leonardosu0@gmail.com
916958e8e9f97dc012a912c3e4e3daf4c1c985fa
5d9bbf92c9b35613f2944f24f4cc42d8e21d25de
/preS18/Networks/hw2/AStar.cpp
715d77205d1049811d6ca81b88a7f4c4453e9bb6
[]
no_license
nclewis96/school
da39dac89c4210d95a62d608146818e14821f8bf
cded9c5bd1a50359bf36d21faade30f758ba8718
refs/heads/master
2020-03-20T22:40:04.878767
2018-08-15T20:41:15
2018-08-15T20:41:15
137,809,315
0
0
null
null
null
null
UTF-8
C++
false
false
923
cpp
/******************************************** * Nathaniel Lewis * nlewis * CSCI 446 AI * Fall 2017 * Assignment 02 - Search * File - AStar.cpp ********************************************/ #include "AStar.h" #include "Town.h" #include <string> #include <stack> #include <map> #include <climits> #include <iostream> Town AStar::strategy(std::map<std::string, Town> newMap, std::stack<std::string> newFringe, std::stack<std::string> newPath){ int distance; std::string nextTown; int shortestDistance = INT_MAX; setPath(newPath) ; while(!newFringe.empty()) { distance = newMap[newFringe.top()].getSLD(); if(distance + pathCost() < shortestDistance){ shortestDistance = distance + pathCost(); nextTown = newFringe.top(); } newFringe.pop(); } return newMap[nextTown]; } AStar::AStar(std::map<std::string, Town> map, std::string startingTown): GenericSearch(map, startingTown) { }
[ "nlewis@mtech.edu" ]
nlewis@mtech.edu
41ca6abebfeb2c9ecb03e3bbfe07aeff78221b2b
29b81bdc013d76b057a2ba12e912d6d4c5b033ef
/boost/include/boost/python/to_python_value.hpp
52dba42eaff8714174efd9b45405b940afbfeef4
[]
no_license
GSIL-Monitor/third_dependences
864d2ad73955ffe0ce4912966a4f0d1c60ebd960
888ebf538db072a92d444a9e5aaa5e18b0f11083
refs/heads/master
2020-04-17T07:32:49.546337
2019-01-18T08:47:28
2019-01-18T08:47:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
129
hpp
version https://git-lfs.github.com/spec/v1 oid sha256:e4f04fc65f28ccb96f30f684bc9b0f91440483c2d28e97e8a3a73534e2d54683 size 5407
[ "you@example.com" ]
you@example.com
88c882f160888e3d279ff345ff4dbf0ebd65942b
87aba51b1f708b47d78b5c4180baf731d752e26d
/Replication/DataFileSystem/PRODUCT_SOURCE_CODE/itk/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DBalloonForceFilter.h
7d4116598d00ab527a3681a42fcb4ada94460782
[]
no_license
jstavr/Architecture-Relation-Evaluator
12c225941e9a4942e83eb6d78f778c3cf5275363
c63c056ee6737a3d90fac628f2bc50b85c6bd0dc
refs/heads/master
2020-12-31T05:10:08.774893
2016-05-14T16:09:40
2016-05-14T16:09:40
58,766,508
0
0
null
null
null
null
UTF-8
C++
false
false
4,510
h
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * 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. * *=========================================================================*/ /*========================================================================= * * Portions of this file are subject to the VTK Toolkit Version 3 copyright. * * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen * * For complete copyright, license and disclaimer of warranty information * please refer to the NOTICE file at the top of the ITK source tree. * *=========================================================================*/ #ifndef __itkDeformableSimplexMesh3DBalloonForceFilter_h #define __itkDeformableSimplexMesh3DBalloonForceFilter_h #include "itkDeformableSimplexMesh3DFilter.h" #include "itkMesh.h" #include "itkConstNeighborhoodIterator.h" #include "itkCovariantVector.h" #include <set> namespace itk { /** \class DeformableSimplexMesh3DBalloonForceFilter * \brief * Additional to its superclass this model adds an balloon force component to the * internal forces. * * The balloon force can be scaled, by setting the parameter kappa. * * \author Thomas Boettger. Division Medical and Biological Informatics, German Cancer Research Center, Heidelberg. * * \ingroup ITKDeformableMesh */ template< typename TInputMesh, typename TOutputMesh > class DeformableSimplexMesh3DBalloonForceFilter:public DeformableSimplexMesh3DFilter< TInputMesh, TOutputMesh > { public: /** Standard "Self" typedef. */ typedef DeformableSimplexMesh3DBalloonForceFilter Self; /** Standard "Superclass" typedef. */ typedef DeformableSimplexMesh3DFilter< TInputMesh, TOutputMesh > Superclass; /** Smart pointer typedef support */ typedef SmartPointer< Self > Pointer; typedef SmartPointer< const Self > ConstPointer; /** Method of creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(DeformableSimplexMesh3DBalloonForceFilter, DeformableSimplexMesh3DFilter); /** Some typedefs. */ typedef TInputMesh InputMeshType; typedef TOutputMesh OutputMeshType; typedef typename Superclass::PointType PointType; typedef typename Superclass::GradientIndexType GradientIndexType; typedef typename Superclass::GradientIndexValueType GradientIndexValueType; typedef typename Superclass::GradientImageType GradientImageType; /* Mesh pointer definition. */ typedef typename InputMeshType::Pointer InputMeshPointer; typedef typename OutputMeshType::Pointer OutputMeshPointer; typedef typename InputMeshType::PixelType PixelType; typedef Image< PixelType, 3 > GradientIntensityImageType; typedef typename GradientIntensityImageType::Pointer GradientIntensityImagePointer; itkSetMacro(Kappa, double); itkGetConstMacro(Kappa, double); protected: DeformableSimplexMesh3DBalloonForceFilter(); ~DeformableSimplexMesh3DBalloonForceFilter(); DeformableSimplexMesh3DBalloonForceFilter(const Self &) {} void operator=(const Self &) {} void PrintSelf(std::ostream & os, Indent indent) const; /** * Compute the external force component */ virtual void ComputeExternalForce(SimplexMeshGeometry *data,const GradientImageType *gradientImage); /** Parameters definitions. */ /** * scalar for balloon force */ double m_Kappa; }; // end of class } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkDeformableSimplexMesh3DBalloonForceFilter.hxx" #endif #endif //__itkDeformableSimplexMesh3DBalloonForceFilter_H
[ "jstavr2@gmail.com" ]
jstavr2@gmail.com
7a521cbc17db17efcdd317080996e144cd3edc2a
45e0fbd9a9dbcdd4fbe6aaa2fdb2aed296f81e33
/FindSecret/Classes/Native/System_Xml_System_Xml_Schema_XmlSchemaValidationExc816160496.h
04f9b2e9bd585a1afa8c520caea5d43f8ecb98cf
[ "MIT" ]
permissive
GodIsWord/NewFindSecret
d4a5d2d810ee1f9d6b3bc91168895cc808bac817
4f98f316d29936380f9665d6a6d89962d9ee5478
refs/heads/master
2020-03-24T09:54:50.239014
2018-10-27T05:22:11
2018-10-27T05:22:11
142,641,511
0
0
null
null
null
null
UTF-8
C++
false
false
608
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "System_Xml_System_Xml_Schema_XmlSchemaException3511258692.h" #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Xml.Schema.XmlSchemaValidationException struct XmlSchemaValidationException_t816160496 : public XmlSchemaException_t3511258692 { public: public: }; #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "zhangyide@9fbank.cc" ]
zhangyide@9fbank.cc
9298d8be312fcda2deb1b29d5edc52c64ee70d68
764236bd2d3984c68661a299269b15f4afc5c49e
/zcommon/src/zcommon/zservicelocator.h
559de3adf5ab9cddad91e02908080b14acc6c02b
[]
no_license
tamvh/HomeBackend
054ffef4ea41ad8a745d23ba274fc8ba5a6dae42
f7187702816f0480f049d413a9c35d37293195df
refs/heads/master
2020-12-24T09:55:10.030412
2016-11-10T06:39:17
2016-11-10T06:39:17
73,259,952
0
1
null
null
null
null
UTF-8
C++
false
false
866
h
#ifndef ZSERVICELOCATOR_H #define ZSERVICELOCATOR_H #include <map> class ZServiceLocator { public: static ZServiceLocator* instance(); public: enum class ServiceId : int32_t { UserManager, DeviceManager, DBProxy, MemCacheProxy, IDGenerator, SessionService, Worker, AdminManager }; public: template <typename T> T* get(ServiceId serviceId) const; void registerService(ServiceId serviceId, void* service); private: ZServiceLocator(); static ZServiceLocator* _instance; std::map<ServiceId, void*> _services; }; template <typename T> T* ZServiceLocator::get(ServiceId serviceId) const { auto iter = _services.find(serviceId); if (iter == _services.end()) { return 0; } return static_cast<T*> (iter->second); } #endif // ZSERVICELOCATOR_H
[ "huytamuit@gmail.com" ]
huytamuit@gmail.com
97505be8c6889b2694c82b031ac26958e47aa2a2
427f48b76d1b312cff7af2d9b535ea333e8d154e
/cpp/keyword_xor_eq.cpp
48523d5fc73418b82e21fae8a80672b1ee95d3a9
[ "MIT" ]
permissive
rpuntaie/c-examples
8925146dd1a59edb137c6240363e2794eccce004
385b3c792e5b39f81a187870100ed6401520a404
refs/heads/main
2023-05-31T15:29:38.919736
2021-06-28T16:53:07
2021-06-28T16:53:07
381,098,552
1
0
null
null
null
null
UTF-8
C++
false
false
749
cpp
/* g++ --std=c++20 -pthread -o ../_build/cpp/keyword_xor_eq.exe ./cpp/keyword_xor_eq.cpp && (cd ../_build/cpp/;./keyword_xor_eq.exe) https://en.cppreference.com/w/cpp/keyword/xor_eq */ #include <iostream> #include <bitset> using bin = std::bitset<8>; void show(bin z, const char* s, int n) { if (n == 0) std::cout << "┌────────────┬──────────┐\n"; if (n <= 2) std::cout << "│ " <<s<< " │ " <<z<<" │\n"; if (n == 2) std::cout << "└────────────┴──────────┘\n"; } int main() { bin x{ "01011010" }; show(x, "x ", 0); bin y{ "00111100" }; show(y, "y ", 1); x xor_eq y; show(x, "x xor_eq y", 2); }
[ "roland.puntaier@gmail.com" ]
roland.puntaier@gmail.com
361e42d27869d168cf0727e31350407ec644de88
f94aa5bd4d8814b57ae6713c1f69fa1e11bc6526
/TribesAscendSDK/HeaderDump/TribesGame__TrAward_Flag_Returns.h
92b2960b691e004b3122849d05703fcfad25d41f
[]
no_license
pixel5/TASDK
71980b727b86034771ea91c67f6c02116f47c245
0dc5e4524efed291fe7d8cf936fa64e0e37e4e82
refs/heads/master
2020-05-23T15:12:55.162796
2013-07-13T00:27:32
2013-07-13T00:27:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
902
h
#pragma once #define ADD_VAR( x, y, z ) ( ##x ) var_##y() \ { \ static ScriptProperty *script_property = ( ScriptProperty* )( ScriptObject::Find( #x " TribesGame.TrAward_Flag_Returns." #y ) ); \ return ( ##x( this, script_property->offset, z ) ); \ } #define ADD_STRUCT( x, y, z ) ( ##x ) var_##y() \ { \ static ScriptProperty *script_property = ( ScriptProperty* )( ScriptObject::Find( "StructProperty TribesGame.TrAward_Flag_Returns." #y ) ); \ return ( ##x( this, script_property->offset, z ) ); \ } #define ADD_OBJECT( x, y ) ( class x* ) var_##y() \ { \ static ScriptProperty *script_property = ( ScriptProperty* )( ScriptObject::Find( "ObjectProperty TribesGame.TrAward_Flag_Returns." #y ) ); \ return *( x** )( this + script_property->offset ); \ } namespace UnrealScript { class TrAward_Flag_Returns : public TrAward { public: }; } #undef ADD_VAR #undef ADD_STRUCT #undef ADD_OBJECT
[ "altimormc@gmail.com" ]
altimormc@gmail.com
f88c54878cce8f21c1b40d8067f8cb7785ab3451
39eb7c2f4f6dd1f0c63515f822f9a03cf8f7b5bc
/Assignment_2_5/Assignment_2_5.cpp
84c230562a74ec6342e34445ab03fa1e94fcf5bb
[]
no_license
maomaoto/OCW_C_Basic_Assignment
3d35900ad5b4719090bf8dde48dd5d14ccf0c8e8
0015199e9b8e2bbfbc9c4a48abf7f5752d468ae8
refs/heads/master
2021-01-10T07:54:04.790629
2016-03-21T03:52:57
2016-03-21T03:52:57
52,263,079
0
0
null
null
null
null
BIG5
C++
false
false
684
cpp
#include <iostream> using namespace std; /* 數組逆序重放 描述: 將一個數組中的值逆序重新存放。例如:原來順序為8,6,5,4,1,要求改為1,4,5,6,8 輸入: 輸入為兩行:第一行為數組中元素的個數 n (1<n<100),第二行是 n 個整數,每兩個整數之間用空格分隔。 輸出: 輸出為一行:輸出逆序後數組的整數,每兩個整數之間用空格分隔。 */ int main() { int n = 0; cin >> n; int a[100]; for (int i = 0; i < n; i++) { cin >> a[i]; } while ( n-- ) { cout << a[n]; if (n > 0) cout << " "; } return 0; }
[ "maomaoto@gmail.com" ]
maomaoto@gmail.com
941cd7e6796c2af5fb927ffd615e71c417e7e7de
72f29a1f42739b1f4d03515e6c23d541ccc2a482
/test/hash/fnvTest.cpp
32d319261d281687900fdf79d45e337523621bbe
[ "Apache-2.0" ]
permissive
zpooky/sputil
ec09ef1bb3d9fe9fac4e2d174729515672bef50a
30d7f0b2b07cecdc6657da30cf5c4ba52a9ed240
refs/heads/master
2022-08-27T09:13:06.982435
2022-08-10T20:41:49
2022-08-10T20:42:35
116,656,968
0
0
null
null
null
null
UTF-8
C++
false
false
34,216
cpp
/* * test_fnv - FNV test suite * * @(#) $Revision: 5.3 $ * @(#) $Id: test_fnv.c,v 5.3 2009/06/30 11:50:41 chongo Exp $ * @(#) $Source: /usr/local/src/cmd/fnv/RCS/test_fnv.c,v $ * *** * * Fowler/Noll/Vo hash * * The basis of this hash algorithm was taken from an idea sent * as reviewer comments to the IEEE POSIX P1003.2 committee by: * * Phong Vo (http://www.research.att.com/info/kpv/) * Glenn Fowler (http://www.research.att.com/~gsf/) * * In a subsequent ballot round: * * Landon Curt Noll (http://www.isthe.com/chongo/) * * improved on their algorithm. Some people tried this hash * and found that it worked rather well. In an EMail message * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash. * * FNV hashes are designed to be fast while maintaining a low * collision rate. The FNV speed allows one to quickly hash lots * of data while maintaining a reasonable collision rate. See: * * http://www.isthe.com/chongo/tech/comp/fnv/index.html * * for more details as well as other forms of the FNV hash. * *** * * Please do not copyright this code. This code is in the public domain. * * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * By: * chongo <Landon Curt Noll> /\oo/\ * http://www.isthe.com/chongo/ * * Share and Enjoy! :-) */ #include "gtest/gtest.h" #include <hash/fnv.h> #include <initializer_list> #define LEN(x) (sizeof(x)-1) /* FNV_TEST macro does not include trailing NUL byte in the test vector */ #define FNV_TEST(x) {x, LEN(x)} /* TEST0 macro includes the trailing NUL byte in the test vector */ #define FNV_TEST0(x) {x, sizeof(x)} /* REPEAT500 - repeat a string 500 times */ #define R500(x) R100(x)R100(x)R100(x)R100(x)R100(x) #define R100(x) R10(x)R10(x)R10(x)R10(x)R10(x)R10(x)R10(x)R10(x)R10(x)R10(x) #define R10(x) x x x x x x x x x x struct test_vector { const void *buf; /* start of test vector buffer */ int len; /* length of test vector */ }; struct fnv1a_64_test_vector { struct test_vector *test; /* test vector buffer to hash */ std::uint64_t fnv1a_64; /* expected FNV-1a 64 bit hash value */ }; struct fnv1a_32_test_vector { struct test_vector *test; /* test vector buffer to hash */ std::uint32_t fnv1a_32; /* expected FNV-1a 32 bit hash value */ }; struct test_vector fnv_test_str[] = { FNV_TEST(""), FNV_TEST("a"), FNV_TEST("b"), FNV_TEST("c"), FNV_TEST("d"), FNV_TEST("e"), FNV_TEST("f"), FNV_TEST("fo"), FNV_TEST("foo"), FNV_TEST("foob"), FNV_TEST("fooba"), FNV_TEST("foobar"), FNV_TEST0(""), FNV_TEST0("a"), FNV_TEST0("b"), FNV_TEST0("c"), FNV_TEST0("d"), FNV_TEST0("e"), FNV_TEST0("f"), FNV_TEST0("fo"), FNV_TEST0("foo"), FNV_TEST0("foob"), FNV_TEST0("fooba"), FNV_TEST0("foobar"), FNV_TEST("ch"), FNV_TEST("cho"), FNV_TEST("chon"), FNV_TEST("chong"), FNV_TEST("chongo"), FNV_TEST("chongo "), FNV_TEST("chongo w"), FNV_TEST("chongo wa"), FNV_TEST("chongo was"), FNV_TEST("chongo was "), FNV_TEST("chongo was h"), FNV_TEST("chongo was he"), FNV_TEST("chongo was her"), FNV_TEST("chongo was here"), FNV_TEST("chongo was here!"), FNV_TEST("chongo was here!\n"), FNV_TEST0("ch"), FNV_TEST0("cho"), FNV_TEST0("chon"), FNV_TEST0("chong"), FNV_TEST0("chongo"), FNV_TEST0("chongo "), FNV_TEST0("chongo w"), FNV_TEST0("chongo wa"), FNV_TEST0("chongo was"), FNV_TEST0("chongo was "), FNV_TEST0("chongo was h"), FNV_TEST0("chongo was he"), FNV_TEST0("chongo was her"), FNV_TEST0("chongo was here"), FNV_TEST0("chongo was here!"), FNV_TEST0("chongo was here!\n"), FNV_TEST("cu"), FNV_TEST("cur"), FNV_TEST("curd"), FNV_TEST("curds"), FNV_TEST("curds "), FNV_TEST("curds a"), FNV_TEST("curds an"), FNV_TEST("curds and"), FNV_TEST("curds and "), FNV_TEST("curds and w"), FNV_TEST("curds and wh"), FNV_TEST("curds and whe"), FNV_TEST("curds and whey"), FNV_TEST("curds and whey\n"), FNV_TEST0("cu"), FNV_TEST0("cur"), FNV_TEST0("curd"), FNV_TEST0("curds"), FNV_TEST0("curds "), FNV_TEST0("curds a"), FNV_TEST0("curds an"), FNV_TEST0("curds and"), FNV_TEST0("curds and "), FNV_TEST0("curds and w"), FNV_TEST0("curds and wh"), FNV_TEST0("curds and whe"), FNV_TEST0("curds and whey"), FNV_TEST0("curds and whey\n"), FNV_TEST("hi"), FNV_TEST0("hi"), FNV_TEST("hello"), FNV_TEST0("hello"), FNV_TEST("\xff\x00\x00\x01"), FNV_TEST("\x01\x00\x00\xff"), FNV_TEST("\xff\x00\x00\x02"), FNV_TEST("\x02\x00\x00\xff"), FNV_TEST("\xff\x00\x00\x03"), FNV_TEST("\x03\x00\x00\xff"), FNV_TEST("\xff\x00\x00\x04"), FNV_TEST("\x04\x00\x00\xff"), FNV_TEST("\x40\x51\x4e\x44"), FNV_TEST("\x44\x4e\x51\x40"), FNV_TEST("\x40\x51\x4e\x4a"), FNV_TEST("\x4a\x4e\x51\x40"), FNV_TEST("\x40\x51\x4e\x54"), FNV_TEST("\x54\x4e\x51\x40"), FNV_TEST("127.0.0.1"), FNV_TEST0("127.0.0.1"), FNV_TEST("127.0.0.2"), FNV_TEST0("127.0.0.2"), FNV_TEST("127.0.0.3"), FNV_TEST0("127.0.0.3"), FNV_TEST("64.81.78.68"), FNV_TEST0("64.81.78.68"), FNV_TEST("64.81.78.74"), FNV_TEST0("64.81.78.74"), FNV_TEST("64.81.78.84"), FNV_TEST0("64.81.78.84"), FNV_TEST("feedface"), FNV_TEST0("feedface"), FNV_TEST("feedfacedaffdeed"), FNV_TEST0("feedfacedaffdeed"), FNV_TEST("feedfacedeadbeef"), FNV_TEST0("feedfacedeadbeef"), FNV_TEST("line 1\nline 2\nline 3"), FNV_TEST("chongo <Landon Curt Noll> /\\../\\"), FNV_TEST0("chongo <Landon Curt Noll> /\\../\\"), FNV_TEST("chongo (Landon Curt Noll) /\\../\\"), FNV_TEST0("chongo (Landon Curt Noll) /\\../\\"), FNV_TEST("http://antwrp.gsfc.nasa.gov/apod/astropix.html"), FNV_TEST("http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash"), FNV_TEST("http://epod.usra.edu/"), FNV_TEST("http://exoplanet.eu/"), FNV_TEST("http://hvo.wr.usgs.gov/cam3/"), FNV_TEST("http://hvo.wr.usgs.gov/cams/HMcam/"), FNV_TEST("http://hvo.wr.usgs.gov/kilauea/update/deformation.html"), FNV_TEST("http://hvo.wr.usgs.gov/kilauea/update/images.html"), FNV_TEST("http://hvo.wr.usgs.gov/kilauea/update/maps.html"), FNV_TEST("http://hvo.wr.usgs.gov/volcanowatch/current_issue.html"), FNV_TEST("http://neo.jpl.nasa.gov/risk/"), FNV_TEST("http://norvig.com/21-days.html"), FNV_TEST("http://primes.utm.edu/curios/home.php"), FNV_TEST("http://slashdot.org/"), FNV_TEST("http://tux.wr.usgs.gov/Maps/155.25-19.5.html"), FNV_TEST("http://volcano.wr.usgs.gov/kilaueastatus.php"), FNV_TEST("http://www.avo.alaska.edu/activity/Redoubt.php"), FNV_TEST("http://www.dilbert.com/fast/"), FNV_TEST("http://www.fourmilab.ch/gravitation/orbits/"), FNV_TEST("http://www.fpoa.net/"), FNV_TEST("http://www.ioccc.org/index.html"), FNV_TEST("http://www.isthe.com/cgi-bin/number.cgi"), FNV_TEST("http://www.isthe.com/chongo/bio.html"), FNV_TEST("http://www.isthe.com/chongo/index.html"), FNV_TEST("http://www.isthe.com/chongo/src/calc/lucas-calc"), FNV_TEST("http://www.isthe.com/chongo/tech/astro/venus2004.html"), FNV_TEST("http://www.isthe.com/chongo/tech/astro/vita.html"), FNV_TEST("http://www.isthe.com/chongo/tech/comp/c/expert.html"), FNV_TEST("http://www.isthe.com/chongo/tech/comp/calc/index.html"), FNV_TEST("http://www.isthe.com/chongo/tech/comp/fnv/index.html"), FNV_TEST("http://www.isthe.com/chongo/tech/math/number/howhigh.html"), FNV_TEST("http://www.isthe.com/chongo/tech/math/number/number.html"), FNV_TEST("http://www.isthe.com/chongo/tech/math/prime/mersenne.html"), FNV_TEST("http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest"), FNV_TEST("http://www.lavarnd.org/cgi-bin/corpspeak.cgi"), FNV_TEST("http://www.lavarnd.org/cgi-bin/haiku.cgi"), FNV_TEST("http://www.lavarnd.org/cgi-bin/rand-none.cgi"), FNV_TEST("http://www.lavarnd.org/cgi-bin/randdist.cgi"), FNV_TEST("http://www.lavarnd.org/index.html"), FNV_TEST("http://www.lavarnd.org/what/nist-test.html"), FNV_TEST("http://www.macosxhints.com/"), FNV_TEST("http://www.mellis.com/"), FNV_TEST("http://www.nature.nps.gov/air/webcams/parks/havoso2alert/havoalert.cfm"), FNV_TEST("http://www.nature.nps.gov/air/webcams/parks/havoso2alert/timelines_24.cfm"), FNV_TEST("http://www.paulnoll.com/"), FNV_TEST("http://www.pepysdiary.com/"), FNV_TEST("http://www.sciencenews.org/index/home/activity/view"), FNV_TEST("http://www.skyandtelescope.com/"), FNV_TEST("http://www.sput.nl/~rob/sirius.html"), FNV_TEST("http://www.systemexperts.com/"), FNV_TEST("http://www.tq-international.com/phpBB3/index.php"), FNV_TEST("http://www.travelquesttours.com/index.htm"), FNV_TEST("http://www.wunderground.com/global/stations/89606.html"), FNV_TEST(R10("21701")), FNV_TEST(R10("M21701")), FNV_TEST(R10("2^21701-1")), FNV_TEST(R10("\x54\xc5")), FNV_TEST(R10("\xc5\x54")), FNV_TEST(R10("23209")), FNV_TEST(R10("M23209")), FNV_TEST(R10("2^23209-1")), FNV_TEST(R10("\x5a\xa9")), FNV_TEST(R10("\xa9\x5a")), FNV_TEST(R10("391581216093")), FNV_TEST(R10("391581*2^216093-1")), FNV_TEST(R10("\x05\xf9\x9d\x03\x4c\x81")), FNV_TEST(R10("FEDCBA9876543210")), FNV_TEST(R10("\xfe\xdc\xba\x98\x76\x54\x32\x10")), FNV_TEST(R10("EFCDAB8967452301")), FNV_TEST(R10("\xef\xcd\xab\x89\x67\x45\x23\x01")), FNV_TEST(R10("0123456789ABCDEF")), FNV_TEST(R10("\x01\x23\x45\x67\x89\xab\xcd\xef")), FNV_TEST(R10("1032547698BADCFE")), FNV_TEST(R10("\x10\x32\x54\x76\x98\xba\xdc\xfe")), FNV_TEST(R500("\x00")), FNV_TEST(R500("\x07")), FNV_TEST(R500("~")), FNV_TEST(R500("\x7f")), {NULL, 0} /* MUST BE LAST */ }; struct fnv1a_64_test_vector fnv1a_64_vector[] = { { &fnv_test_str[0], 0xcbf29ce484222325ULL }, { &fnv_test_str[1], 0xaf63dc4c8601ec8cULL }, { &fnv_test_str[2], 0xaf63df4c8601f1a5ULL }, { &fnv_test_str[3], 0xaf63de4c8601eff2ULL }, { &fnv_test_str[4], 0xaf63d94c8601e773ULL }, { &fnv_test_str[5], 0xaf63d84c8601e5c0ULL }, { &fnv_test_str[6], 0xaf63db4c8601ead9ULL }, { &fnv_test_str[7], 0x08985907b541d342ULL }, { &fnv_test_str[8], 0xdcb27518fed9d577ULL }, { &fnv_test_str[9], 0xdd120e790c2512afULL }, { &fnv_test_str[10], 0xcac165afa2fef40aULL }, { &fnv_test_str[11], 0x85944171f73967e8ULL }, { &fnv_test_str[12], 0xaf63bd4c8601b7dfULL }, { &fnv_test_str[13], 0x089be207b544f1e4ULL }, { &fnv_test_str[14], 0x08a61407b54d9b5fULL }, { &fnv_test_str[15], 0x08a2ae07b54ab836ULL }, { &fnv_test_str[16], 0x0891b007b53c4869ULL }, { &fnv_test_str[17], 0x088e4a07b5396540ULL }, { &fnv_test_str[18], 0x08987c07b5420ebbULL }, { &fnv_test_str[19], 0xdcb28a18fed9f926ULL }, { &fnv_test_str[20], 0xdd1270790c25b935ULL }, { &fnv_test_str[21], 0xcac146afa2febf5dULL }, { &fnv_test_str[22], 0x8593d371f738acfeULL }, { &fnv_test_str[23], 0x34531ca7168b8f38ULL }, { &fnv_test_str[24], 0x08a25607b54a22aeULL }, { &fnv_test_str[25], 0xf5faf0190cf90df3ULL }, { &fnv_test_str[26], 0xf27397910b3221c7ULL }, { &fnv_test_str[27], 0x2c8c2b76062f22e0ULL }, { &fnv_test_str[28], 0xe150688c8217b8fdULL }, { &fnv_test_str[29], 0xf35a83c10e4f1f87ULL }, { &fnv_test_str[30], 0xd1edd10b507344d0ULL }, { &fnv_test_str[31], 0x2a5ee739b3ddb8c3ULL }, { &fnv_test_str[32], 0xdcfb970ca1c0d310ULL }, { &fnv_test_str[33], 0x4054da76daa6da90ULL }, { &fnv_test_str[34], 0xf70a2ff589861368ULL }, { &fnv_test_str[35], 0x4c628b38aed25f17ULL }, { &fnv_test_str[36], 0x9dd1f6510f78189fULL }, { &fnv_test_str[37], 0xa3de85bd491270ceULL }, { &fnv_test_str[38], 0x858e2fa32a55e61dULL }, { &fnv_test_str[39], 0x46810940eff5f915ULL }, { &fnv_test_str[40], 0xf5fadd190cf8edaaULL }, { &fnv_test_str[41], 0xf273ed910b32b3e9ULL }, { &fnv_test_str[42], 0x2c8c5276062f6525ULL }, { &fnv_test_str[43], 0xe150b98c821842a0ULL }, { &fnv_test_str[44], 0xf35aa3c10e4f55e7ULL }, { &fnv_test_str[45], 0xd1ed680b50729265ULL }, { &fnv_test_str[46], 0x2a5f0639b3dded70ULL }, { &fnv_test_str[47], 0xdcfbaa0ca1c0f359ULL }, { &fnv_test_str[48], 0x4054ba76daa6a430ULL }, { &fnv_test_str[49], 0xf709c7f5898562b0ULL }, { &fnv_test_str[50], 0x4c62e638aed2f9b8ULL }, { &fnv_test_str[51], 0x9dd1a8510f779415ULL }, { &fnv_test_str[52], 0xa3de2abd4911d62dULL }, { &fnv_test_str[53], 0x858e0ea32a55ae0aULL }, { &fnv_test_str[54], 0x46810f40eff60347ULL }, { &fnv_test_str[55], 0xc33bce57bef63eafULL }, { &fnv_test_str[56], 0x08a24307b54a0265ULL }, { &fnv_test_str[57], 0xf5b9fd190cc18d15ULL }, { &fnv_test_str[58], 0x4c968290ace35703ULL }, { &fnv_test_str[59], 0x07174bd5c64d9350ULL }, { &fnv_test_str[60], 0x5a294c3ff5d18750ULL }, { &fnv_test_str[61], 0x05b3c1aeb308b843ULL }, { &fnv_test_str[62], 0xb92a48da37d0f477ULL }, { &fnv_test_str[63], 0x73cdddccd80ebc49ULL }, { &fnv_test_str[64], 0xd58c4c13210a266bULL }, { &fnv_test_str[65], 0xe78b6081243ec194ULL }, { &fnv_test_str[66], 0xb096f77096a39f34ULL }, { &fnv_test_str[67], 0xb425c54ff807b6a3ULL }, { &fnv_test_str[68], 0x23e520e2751bb46eULL }, { &fnv_test_str[69], 0x1a0b44ccfe1385ecULL }, { &fnv_test_str[70], 0xf5ba4b190cc2119fULL }, { &fnv_test_str[71], 0x4c962690ace2baafULL }, { &fnv_test_str[72], 0x0716ded5c64cda19ULL }, { &fnv_test_str[73], 0x5a292c3ff5d150f0ULL }, { &fnv_test_str[74], 0x05b3e0aeb308ecf0ULL }, { &fnv_test_str[75], 0xb92a5eda37d119d9ULL }, { &fnv_test_str[76], 0x73ce41ccd80f6635ULL }, { &fnv_test_str[77], 0xd58c2c132109f00bULL }, { &fnv_test_str[78], 0xe78baf81243f47d1ULL }, { &fnv_test_str[79], 0xb0968f7096a2ee7cULL }, { &fnv_test_str[80], 0xb425a84ff807855cULL }, { &fnv_test_str[81], 0x23e4e9e2751b56f9ULL }, { &fnv_test_str[82], 0x1a0b4eccfe1396eaULL }, { &fnv_test_str[83], 0x54abd453bb2c9004ULL }, { &fnv_test_str[84], 0x08ba5f07b55ec3daULL }, { &fnv_test_str[85], 0x337354193006cb6eULL }, { &fnv_test_str[86], 0xa430d84680aabd0bULL }, { &fnv_test_str[87], 0xa9bc8acca21f39b1ULL }, { &fnv_test_str[88], 0x6961196491cc682dULL }, { &fnv_test_str[89], 0xad2bb1774799dfe9ULL }, { &fnv_test_str[90], 0x6961166491cc6314ULL }, { &fnv_test_str[91], 0x8d1bb3904a3b1236ULL }, { &fnv_test_str[92], 0x6961176491cc64c7ULL }, { &fnv_test_str[93], 0xed205d87f40434c7ULL }, { &fnv_test_str[94], 0x6961146491cc5faeULL }, { &fnv_test_str[95], 0xcd3baf5e44f8ad9cULL }, { &fnv_test_str[96], 0xe3b36596127cd6d8ULL }, { &fnv_test_str[97], 0xf77f1072c8e8a646ULL }, { &fnv_test_str[98], 0xe3b36396127cd372ULL }, { &fnv_test_str[99], 0x6067dce9932ad458ULL }, { &fnv_test_str[100], 0xe3b37596127cf208ULL }, { &fnv_test_str[101], 0x4b7b10fa9fe83936ULL }, { &fnv_test_str[102], 0xaabafe7104d914beULL }, { &fnv_test_str[103], 0xf4d3180b3cde3edaULL }, { &fnv_test_str[104], 0xaabafd7104d9130bULL }, { &fnv_test_str[105], 0xf4cfb20b3cdb5bb1ULL }, { &fnv_test_str[106], 0xaabafc7104d91158ULL }, { &fnv_test_str[107], 0xf4cc4c0b3cd87888ULL }, { &fnv_test_str[108], 0xe729bac5d2a8d3a7ULL }, { &fnv_test_str[109], 0x74bc0524f4dfa4c5ULL }, { &fnv_test_str[110], 0xe72630c5d2a5b352ULL }, { &fnv_test_str[111], 0x6b983224ef8fb456ULL }, { &fnv_test_str[112], 0xe73042c5d2ae266dULL }, { &fnv_test_str[113], 0x8527e324fdeb4b37ULL }, { &fnv_test_str[114], 0x0a83c86fee952abcULL }, { &fnv_test_str[115], 0x7318523267779d74ULL }, { &fnv_test_str[116], 0x3e66d3d56b8caca1ULL }, { &fnv_test_str[117], 0x956694a5c0095593ULL }, { &fnv_test_str[118], 0xcac54572bb1a6fc8ULL }, { &fnv_test_str[119], 0xa7a4c9f3edebf0d8ULL }, { &fnv_test_str[120], 0x7829851fac17b143ULL }, { &fnv_test_str[121], 0x2c8f4c9af81bcf06ULL }, { &fnv_test_str[122], 0xd34e31539740c732ULL }, { &fnv_test_str[123], 0x3605a2ac253d2db1ULL }, { &fnv_test_str[124], 0x08c11b8346f4a3c3ULL }, { &fnv_test_str[125], 0x6be396289ce8a6daULL }, { &fnv_test_str[126], 0xd9b957fb7fe794c5ULL }, { &fnv_test_str[127], 0x05be33da04560a93ULL }, { &fnv_test_str[128], 0x0957f1577ba9747cULL }, { &fnv_test_str[129], 0xda2cc3acc24fba57ULL }, { &fnv_test_str[130], 0x74136f185b29e7f0ULL }, { &fnv_test_str[131], 0xb2f2b4590edb93b2ULL }, { &fnv_test_str[132], 0xb3608fce8b86ae04ULL }, { &fnv_test_str[133], 0x4a3a865079359063ULL }, { &fnv_test_str[134], 0x5b3a7ef496880a50ULL }, { &fnv_test_str[135], 0x48fae3163854c23bULL }, { &fnv_test_str[136], 0x07aaa640476e0b9aULL }, { &fnv_test_str[137], 0x2f653656383a687dULL }, { &fnv_test_str[138], 0xa1031f8e7599d79cULL }, { &fnv_test_str[139], 0xa31908178ff92477ULL }, { &fnv_test_str[140], 0x097edf3c14c3fb83ULL }, { &fnv_test_str[141], 0xb51ca83feaa0971bULL }, { &fnv_test_str[142], 0xdd3c0d96d784f2e9ULL }, { &fnv_test_str[143], 0x86cd26a9ea767d78ULL }, { &fnv_test_str[144], 0xe6b215ff54a30c18ULL }, { &fnv_test_str[145], 0xec5b06a1c5531093ULL }, { &fnv_test_str[146], 0x45665a929f9ec5e5ULL }, { &fnv_test_str[147], 0x8c7609b4a9f10907ULL }, { &fnv_test_str[148], 0x89aac3a491f0d729ULL }, { &fnv_test_str[149], 0x32ce6b26e0f4a403ULL }, { &fnv_test_str[150], 0x614ab44e02b53e01ULL }, { &fnv_test_str[151], 0xfa6472eb6eef3290ULL }, { &fnv_test_str[152], 0x9e5d75eb1948eb6aULL }, { &fnv_test_str[153], 0xb6d12ad4a8671852ULL }, { &fnv_test_str[154], 0x88826f56eba07af1ULL }, { &fnv_test_str[155], 0x44535bf2645bc0fdULL }, { &fnv_test_str[156], 0x169388ffc21e3728ULL }, { &fnv_test_str[157], 0xf68aac9e396d8224ULL }, { &fnv_test_str[158], 0x8e87d7e7472b3883ULL }, { &fnv_test_str[159], 0x295c26caa8b423deULL }, { &fnv_test_str[160], 0x322c814292e72176ULL }, { &fnv_test_str[161], 0x8a06550eb8af7268ULL }, { &fnv_test_str[162], 0xef86d60e661bcf71ULL }, { &fnv_test_str[163], 0x9e5426c87f30ee54ULL }, { &fnv_test_str[164], 0xf1ea8aa826fd047eULL }, { &fnv_test_str[165], 0x0babaf9a642cb769ULL }, { &fnv_test_str[166], 0x4b3341d4068d012eULL }, { &fnv_test_str[167], 0xd15605cbc30a335cULL }, { &fnv_test_str[168], 0x5b21060aed8412e5ULL }, { &fnv_test_str[169], 0x45e2cda1ce6f4227ULL }, { &fnv_test_str[170], 0x50ae3745033ad7d4ULL }, { &fnv_test_str[171], 0xaa4588ced46bf414ULL }, { &fnv_test_str[172], 0xc1b0056c4a95467eULL }, { &fnv_test_str[173], 0x56576a71de8b4089ULL }, { &fnv_test_str[174], 0xbf20965fa6dc927eULL }, { &fnv_test_str[175], 0x569f8383c2040882ULL }, { &fnv_test_str[176], 0xe1e772fba08feca0ULL }, { &fnv_test_str[177], 0x4ced94af97138ac4ULL }, { &fnv_test_str[178], 0xc4112ffb337a82fbULL }, { &fnv_test_str[179], 0xd64a4fd41de38b7dULL }, { &fnv_test_str[180], 0x4cfc32329edebcbbULL }, { &fnv_test_str[181], 0x0803564445050395ULL }, { &fnv_test_str[182], 0xaa1574ecf4642ffdULL }, { &fnv_test_str[183], 0x694bc4e54cc315f9ULL }, { &fnv_test_str[184], 0xa3d7cb273b011721ULL }, { &fnv_test_str[185], 0x577c2f8b6115bfa5ULL }, { &fnv_test_str[186], 0xb7ec8c1a769fb4c1ULL }, { &fnv_test_str[187], 0x5d5cfce63359ab19ULL }, { &fnv_test_str[188], 0x33b96c3cd65b5f71ULL }, { &fnv_test_str[189], 0xd845097780602bb9ULL }, { &fnv_test_str[190], 0x84d47645d02da3d5ULL }, { &fnv_test_str[191], 0x83544f33b58773a5ULL }, { &fnv_test_str[192], 0x9175cbb2160836c5ULL }, { &fnv_test_str[193], 0xc71b3bc175e72bc5ULL }, { &fnv_test_str[194], 0x636806ac222ec985ULL }, { &fnv_test_str[195], 0xb6ef0e6950f52ed5ULL }, { &fnv_test_str[196], 0xead3d8a0f3dfdaa5ULL }, { &fnv_test_str[197], 0x922908fe9a861ba5ULL }, { &fnv_test_str[198], 0x6d4821de275fd5c5ULL }, { &fnv_test_str[199], 0x1fe3fce62bd816b5ULL }, { &fnv_test_str[200], 0xc23e9fccd6f70591ULL }, { &fnv_test_str[201], 0xc1af12bdfe16b5b5ULL }, { &fnv_test_str[202], 0x39e9f18f2f85e221ULL }, { NULL, 0 } }; struct fnv1a_32_test_vector fnv1a_32_vector[] = { { &fnv_test_str[0], 0x811c9dc5UL }, { &fnv_test_str[1], 0xe40c292cUL }, { &fnv_test_str[2], 0xe70c2de5UL }, { &fnv_test_str[3], 0xe60c2c52UL }, { &fnv_test_str[4], 0xe10c2473UL }, { &fnv_test_str[5], 0xe00c22e0UL }, { &fnv_test_str[6], 0xe30c2799UL }, { &fnv_test_str[7], 0x6222e842UL }, { &fnv_test_str[8], 0xa9f37ed7UL }, { &fnv_test_str[9], 0x3f5076efUL }, { &fnv_test_str[10], 0x39aaa18aUL }, { &fnv_test_str[11], 0xbf9cf968UL }, { &fnv_test_str[12], 0x050c5d1fUL }, { &fnv_test_str[13], 0x2b24d044UL }, { &fnv_test_str[14], 0x9d2c3f7fUL }, { &fnv_test_str[15], 0x7729c516UL }, { &fnv_test_str[16], 0xb91d6109UL }, { &fnv_test_str[17], 0x931ae6a0UL }, { &fnv_test_str[18], 0x052255dbUL }, { &fnv_test_str[19], 0xbef39fe6UL }, { &fnv_test_str[20], 0x6150ac75UL }, { &fnv_test_str[21], 0x9aab3a3dUL }, { &fnv_test_str[22], 0x519c4c3eUL }, { &fnv_test_str[23], 0x0c1c9eb8UL }, { &fnv_test_str[24], 0x5f299f4eUL }, { &fnv_test_str[25], 0xef8580f3UL }, { &fnv_test_str[26], 0xac297727UL }, { &fnv_test_str[27], 0x4546b9c0UL }, { &fnv_test_str[28], 0xbd564e7dUL }, { &fnv_test_str[29], 0x6bdd5c67UL }, { &fnv_test_str[30], 0xdd77ed30UL }, { &fnv_test_str[31], 0xf4ca9683UL }, { &fnv_test_str[32], 0x4aeb9bd0UL }, { &fnv_test_str[33], 0xe0e67ad0UL }, { &fnv_test_str[34], 0xc2d32fa8UL }, { &fnv_test_str[35], 0x7f743fb7UL }, { &fnv_test_str[36], 0x6900631fUL }, { &fnv_test_str[37], 0xc59c990eUL }, { &fnv_test_str[38], 0x448524fdUL }, { &fnv_test_str[39], 0xd49930d5UL }, { &fnv_test_str[40], 0x1c85c7caUL }, { &fnv_test_str[41], 0x0229fe89UL }, { &fnv_test_str[42], 0x2c469265UL }, { &fnv_test_str[43], 0xce566940UL }, { &fnv_test_str[44], 0x8bdd8ec7UL }, { &fnv_test_str[45], 0x34787625UL }, { &fnv_test_str[46], 0xd3ca6290UL }, { &fnv_test_str[47], 0xddeaf039UL }, { &fnv_test_str[48], 0xc0e64870UL }, { &fnv_test_str[49], 0xdad35570UL }, { &fnv_test_str[50], 0x5a740578UL }, { &fnv_test_str[51], 0x5b004d15UL }, { &fnv_test_str[52], 0x6a9c09cdUL }, { &fnv_test_str[53], 0x2384f10aUL }, { &fnv_test_str[54], 0xda993a47UL }, { &fnv_test_str[55], 0x8227df4fUL }, { &fnv_test_str[56], 0x4c298165UL }, { &fnv_test_str[57], 0xfc563735UL }, { &fnv_test_str[58], 0x8cb91483UL }, { &fnv_test_str[59], 0x775bf5d0UL }, { &fnv_test_str[60], 0xd5c428d0UL }, { &fnv_test_str[61], 0x34cc0ea3UL }, { &fnv_test_str[62], 0xea3b4cb7UL }, { &fnv_test_str[63], 0x8e59f029UL }, { &fnv_test_str[64], 0x2094de2bUL }, { &fnv_test_str[65], 0xa65a0ad4UL }, { &fnv_test_str[66], 0x9bbee5f4UL }, { &fnv_test_str[67], 0xbe836343UL }, { &fnv_test_str[68], 0x22d5344eUL }, { &fnv_test_str[69], 0x19a1470cUL }, { &fnv_test_str[70], 0x4a56b1ffUL }, { &fnv_test_str[71], 0x70b8e86fUL }, { &fnv_test_str[72], 0x0a5b4a39UL }, { &fnv_test_str[73], 0xb5c3f670UL }, { &fnv_test_str[74], 0x53cc3f70UL }, { &fnv_test_str[75], 0xc03b0a99UL }, { &fnv_test_str[76], 0x7259c415UL }, { &fnv_test_str[77], 0x4095108bUL }, { &fnv_test_str[78], 0x7559bdb1UL }, { &fnv_test_str[79], 0xb3bf0bbcUL }, { &fnv_test_str[80], 0x2183ff1cUL }, { &fnv_test_str[81], 0x2bd54279UL }, { &fnv_test_str[82], 0x23a156caUL }, { &fnv_test_str[83], 0x64e2d7e4UL }, { &fnv_test_str[84], 0x683af69aUL }, { &fnv_test_str[85], 0xaed2346eUL }, { &fnv_test_str[86], 0x4f9f2cabUL }, { &fnv_test_str[87], 0x02935131UL }, { &fnv_test_str[88], 0xc48fb86dUL }, { &fnv_test_str[89], 0x2269f369UL }, { &fnv_test_str[90], 0xc18fb3b4UL }, { &fnv_test_str[91], 0x50ef1236UL }, { &fnv_test_str[92], 0xc28fb547UL }, { &fnv_test_str[93], 0x96c3bf47UL }, { &fnv_test_str[94], 0xbf8fb08eUL }, { &fnv_test_str[95], 0xf3e4d49cUL }, { &fnv_test_str[96], 0x32179058UL }, { &fnv_test_str[97], 0x280bfee6UL }, { &fnv_test_str[98], 0x30178d32UL }, { &fnv_test_str[99], 0x21addaf8UL }, { &fnv_test_str[100], 0x4217a988UL }, { &fnv_test_str[101], 0x772633d6UL }, { &fnv_test_str[102], 0x08a3d11eUL }, { &fnv_test_str[103], 0xb7e2323aUL }, { &fnv_test_str[104], 0x07a3cf8bUL }, { &fnv_test_str[105], 0x91dfb7d1UL }, { &fnv_test_str[106], 0x06a3cdf8UL }, { &fnv_test_str[107], 0x6bdd3d68UL }, { &fnv_test_str[108], 0x1d5636a7UL }, { &fnv_test_str[109], 0xd5b808e5UL }, { &fnv_test_str[110], 0x1353e852UL }, { &fnv_test_str[111], 0xbf16b916UL }, { &fnv_test_str[112], 0xa55b89edUL }, { &fnv_test_str[113], 0x3c1a2017UL }, { &fnv_test_str[114], 0x0588b13cUL }, { &fnv_test_str[115], 0xf22f0174UL }, { &fnv_test_str[116], 0xe83641e1UL }, { &fnv_test_str[117], 0x6e69b533UL }, { &fnv_test_str[118], 0xf1760448UL }, { &fnv_test_str[119], 0x64c8bd58UL }, { &fnv_test_str[120], 0x97b4ea23UL }, { &fnv_test_str[121], 0x9a4e92e6UL }, { &fnv_test_str[122], 0xcfb14012UL }, { &fnv_test_str[123], 0xf01b2511UL }, { &fnv_test_str[124], 0x0bbb59c3UL }, { &fnv_test_str[125], 0xce524afaUL }, { &fnv_test_str[126], 0xdd16ef45UL }, { &fnv_test_str[127], 0x60648bb3UL }, { &fnv_test_str[128], 0x7fa4bcfcUL }, { &fnv_test_str[129], 0x5053ae17UL }, { &fnv_test_str[130], 0xc9302890UL }, { &fnv_test_str[131], 0x956ded32UL }, { &fnv_test_str[132], 0x9136db84UL }, { &fnv_test_str[133], 0xdf9d3323UL }, { &fnv_test_str[134], 0x32bb6cd0UL }, { &fnv_test_str[135], 0xc8f8385bUL }, { &fnv_test_str[136], 0xeb08bfbaUL }, { &fnv_test_str[137], 0x62cc8e3dUL }, { &fnv_test_str[138], 0xc3e20f5cUL }, { &fnv_test_str[139], 0x39e97f17UL }, { &fnv_test_str[140], 0x7837b203UL }, { &fnv_test_str[141], 0x319e877bUL }, { &fnv_test_str[142], 0xd3e63f89UL }, { &fnv_test_str[143], 0x29b50b38UL }, { &fnv_test_str[144], 0x5ed678b8UL }, { &fnv_test_str[145], 0xb0d5b793UL }, { &fnv_test_str[146], 0x52450be5UL }, { &fnv_test_str[147], 0xfa72d767UL }, { &fnv_test_str[148], 0x95066709UL }, { &fnv_test_str[149], 0x7f52e123UL }, { &fnv_test_str[150], 0x76966481UL }, { &fnv_test_str[151], 0x063258b0UL }, { &fnv_test_str[152], 0x2ded6e8aUL }, { &fnv_test_str[153], 0xb07d7c52UL }, { &fnv_test_str[154], 0xd0c71b71UL }, { &fnv_test_str[155], 0xf684f1bdUL }, { &fnv_test_str[156], 0x868ecfa8UL }, { &fnv_test_str[157], 0xf794f684UL }, { &fnv_test_str[158], 0xd19701c3UL }, { &fnv_test_str[159], 0x346e171eUL }, { &fnv_test_str[160], 0x91f8f676UL }, { &fnv_test_str[161], 0x0bf58848UL }, { &fnv_test_str[162], 0x6317b6d1UL }, { &fnv_test_str[163], 0xafad4c54UL }, { &fnv_test_str[164], 0x0f25681eUL }, { &fnv_test_str[165], 0x91b18d49UL }, { &fnv_test_str[166], 0x7d61c12eUL }, { &fnv_test_str[167], 0x5147d25cUL }, { &fnv_test_str[168], 0x9a8b6805UL }, { &fnv_test_str[169], 0x4cd2a447UL }, { &fnv_test_str[170], 0x1e549b14UL }, { &fnv_test_str[171], 0x2fe1b574UL }, { &fnv_test_str[172], 0xcf0cd31eUL }, { &fnv_test_str[173], 0x6c471669UL }, { &fnv_test_str[174], 0x0e5eef1eUL }, { &fnv_test_str[175], 0x2bed3602UL }, { &fnv_test_str[176], 0xb26249e0UL }, { &fnv_test_str[177], 0x2c9b86a4UL }, { &fnv_test_str[178], 0xe415e2bbUL }, { &fnv_test_str[179], 0x18a98d1dUL }, { &fnv_test_str[180], 0xb7df8b7bUL }, { &fnv_test_str[181], 0x241e9075UL }, { &fnv_test_str[182], 0x063f70ddUL }, { &fnv_test_str[183], 0x0295aed9UL }, { &fnv_test_str[184], 0x56a7f781UL }, { &fnv_test_str[185], 0x253bc645UL }, { &fnv_test_str[186], 0x46610921UL }, { &fnv_test_str[187], 0x7c1577f9UL }, { &fnv_test_str[188], 0x512b2851UL }, { &fnv_test_str[189], 0x76823999UL }, { &fnv_test_str[190], 0xc0586935UL }, { &fnv_test_str[191], 0xf3415c85UL }, { &fnv_test_str[192], 0x0ae4ff65UL }, { &fnv_test_str[193], 0x58b79725UL }, { &fnv_test_str[194], 0xdea43aa5UL }, { &fnv_test_str[195], 0x2bb3be35UL }, { &fnv_test_str[196], 0xea777a45UL }, { &fnv_test_str[197], 0x8f21c305UL }, { &fnv_test_str[198], 0x5c9d0865UL }, { &fnv_test_str[199], 0xfa823dd5UL }, { &fnv_test_str[200], 0x21a27271UL }, { &fnv_test_str[201], 0x83c5c6d5UL }, { &fnv_test_str[202], 0x813b0881UL }, { NULL, 0 } }; TEST(fnvTest, test_fnv64a) { struct test_vector *t; int tstnum; for (t = fnv_test_str, tstnum = 1; t->buf != NULL; ++t, ++tstnum) { auto hval = fnv_1a::encode64(t->buf, t->len); // printf("%lu\n",hval); ASSERT_EQ(hval, fnv1a_64_vector[tstnum-1].fnv1a_64); } } TEST(fnvTest, test_fnv32a) { struct test_vector *t; int tstnum; for (t = fnv_test_str, tstnum = 1; t->buf != NULL; ++t, ++tstnum) { auto hval = fnv_1a::encode32(t->buf, t->len); // printf("%lu\n",hval); ASSERT_EQ(hval, fnv1a_32_vector[tstnum-1].fnv1a_32); } } TEST(fnvTest, test_fnv64a_other) { const char *str = "test"; auto hval = fnv_1a::encode64(str, 4); ASSERT_EQ(std::uint64_t{0xf9e6e6ef197c2b25ULL},hval); } static std::uint64_t enc(std::initializer_list<std::uint8_t> l) { std::uint8_t buff[20] = {0}; std::size_t length=0; for(auto b : l){ buff[length++]=b; } return fnv_1a::encode64(buff,length); } TEST(fnvTest, test_zero) { ASSERT_EQ(enc({0x07,0x1e,0x62,0x37,0x2c,0x02,0x40,0x42,0x14,0x69}), 0ULL); ASSERT_EQ(enc({0x0a, 0x4d, 0x3e, 0x21, 0x16, 0x68, 0x02, 0x0e, 0x0c, 0x6d} ),0ULL); ASSERT_EQ(enc({0x0a, 0x59, 0x59, 0x0e, 0x24, 0x44, 0x2a, 0x7b, 0x60, 0x70} ),0ULL); ASSERT_EQ(enc({0x0f, 0x73, 0x15, 0x07, 0x1b, 0x6f, 0x38, 0x4b, 0x17, 0x39} ),0ULL); ASSERT_EQ(enc({0x10, 0x28, 0x59, 0x4f, 0x6d, 0x07, 0x0f, 0x45, 0x3f, 0x2e} ),0ULL); ASSERT_EQ(enc({0x16, 0x43, 0x29, 0x25, 0x71, 0x1b, 0x5c, 0x65, 0x7a, 0x03} ),0ULL); ASSERT_EQ(enc({0x1c, 0x7f, 0x21, 0x5c, 0x2d, 0x09, 0x1a, 0x03, 0x7f, 0x69} ),0ULL); ASSERT_EQ(enc({0x21, 0x30, 0x49, 0x43, 0x3d, 0x56, 0x6c, 0x6f, 0x61, 0x59} ),0ULL); ASSERT_EQ(enc({0x26, 0x04, 0x5d, 0x12, 0x7c, 0x7d, 0x66, 0x61, 0x0c, 0x26} ),0ULL); ASSERT_EQ(enc({0x3d, 0x2e, 0x20, 0x68, 0x78, 0x22, 0x69, 0x58, 0x3c, 0x3b} ),0ULL); ASSERT_EQ(enc({0x3d, 0x66, 0x7f, 0x2f, 0x6e, 0x36, 0x53, 0x40, 0x30, 0x5d} ),0ULL); ASSERT_EQ(enc({0x42, 0x21, 0x21, 0x7b, 0x16, 0x0e, 0x2f, 0x65, 0x67, 0x25} ),0ULL); ASSERT_EQ(enc({0x46, 0x2e, 0x24, 0x74, 0x64, 0x6f, 0x3c, 0x01, 0x07, 0x24} ),0ULL); ASSERT_EQ(enc({0x51, 0x76, 0x58, 0x74, 0x4d, 0x3e, 0x40, 0x46, 0x70, 0x25} ),0ULL); ASSERT_EQ(enc({0x54, 0x14, 0x18, 0x68, 0x68, 0x4b, 0x14, 0x3c, 0x0a, 0x72} ),0ULL); ASSERT_EQ(enc({0x58, 0x59, 0x54, 0x4d, 0x5c, 0x4d, 0x45, 0x46, 0x0d, 0x7c} ),0ULL); ASSERT_EQ(enc({0x5f, 0x22, 0x6b, 0x57, 0x6b, 0x3d, 0x2d, 0x76, 0x24, 0x63} ),0ULL); ASSERT_EQ(enc({0x60, 0x22, 0x10, 0x0e, 0x59, 0x21, 0x65, 0x39, 0x7a, 0x69} ),0ULL); ASSERT_EQ(enc({0x65, 0x05, 0x78, 0x75, 0x4f, 0x47, 0x3a, 0x15, 0x6a, 0x23} ),0ULL); ASSERT_EQ(enc({0x65, 0x79, 0x15, 0x0c, 0x1d, 0x73, 0x32, 0x40, 0x5a, 0x26} ),0ULL); ASSERT_EQ(enc({0x67, 0x2c, 0x21, 0x55, 0x66, 0x46, 0x29, 0x7b, 0x68, 0x04} ),0ULL); ASSERT_EQ(enc({0x01, 0x1c, 0x4f, 0x49, 0x78, 0x7e, 0x12, 0x6e, 0x6d, 0x61} ),0ULL); ASSERT_EQ(enc({0x05, 0x46, 0x2b, 0x0d, 0x6f, 0x5f, 0x67, 0x1d, 0x63, 0x49} ),0ULL); ASSERT_EQ(enc({0x09, 0x1c, 0x11, 0x5b, 0x68, 0x01, 0x09, 0x23, 0x37, 0x48} ),0ULL); ASSERT_EQ(enc({0x09, 0x5c, 0x02, 0x44, 0x11, 0x06, 0x58, 0x5d, 0x27, 0x3f} ),0ULL); ASSERT_EQ(enc({0x13, 0x67, 0x10, 0x1b, 0x08, 0x30, 0x2a, 0x55, 0x71, 0x2a} ),0ULL); ASSERT_EQ(enc({0x20, 0x0e, 0x75, 0x1d, 0x51, 0x65, 0x72, 0x0a, 0x62, 0x0b} ),0ULL); ASSERT_EQ(enc({0x21, 0x41, 0x46, 0x17, 0x02, 0x63, 0x03, 0x5b, 0x5b, 0x76} ),0ULL); ASSERT_EQ(enc({0x22, 0x42, 0x59, 0x2e, 0x18, 0x0a, 0x14, 0x6f, 0x57, 0x72} ),0ULL); ASSERT_EQ(enc({0x2d, 0x64, 0x37, 0x3d, 0x74, 0x48, 0x18, 0x3e, 0x38, 0x4e} ),0ULL); ASSERT_EQ(enc({0x30, 0x5e, 0x64, 0x66, 0x59, 0x24, 0x65, 0x64, 0x5f, 0x06} ),0ULL); ASSERT_EQ(enc({0x31, 0x51, 0x18, 0x5b, 0x43, 0x5f, 0x3a, 0x6b, 0x60, 0x49} ),0ULL); ASSERT_EQ(enc({0x36, 0x48, 0x0e, 0x56, 0x31, 0x6f, 0x17, 0x59, 0x38, 0x0d} ),0ULL); ASSERT_EQ(enc({0x3d, 0x03, 0x4f, 0x76, 0x44, 0x69, 0x7b, 0x5b, 0x3d, 0x04} ),0ULL); ASSERT_EQ(enc({0x4d, 0x1a, 0x06, 0x77, 0x15, 0x33, 0x08, 0x4d, 0x01, 0x21} ),0ULL); ASSERT_EQ(enc({0x56, 0x1b, 0x0d, 0x31, 0x28, 0x39, 0x04, 0x09, 0x35, 0x63} ),0ULL); ASSERT_EQ(enc({0x56, 0x35, 0x71, 0x38, 0x31, 0x4a, 0x13, 0x14, 0x74, 0x53} ),0ULL); ASSERT_EQ(enc({0x5f, 0x01, 0x62, 0x60, 0x20, 0x4f, 0x4a, 0x62, 0x5c, 0x42} ),0ULL); ASSERT_EQ(enc({0x65, 0x68, 0x4f, 0x66, 0x68, 0x21, 0x3b, 0x07, 0x06, 0x02} ),0ULL); ASSERT_EQ(enc({0x69, 0x59, 0x67, 0x0c, 0x2a, 0x65, 0x07, 0x0d, 0x46, 0x0d} ),0ULL); ASSERT_EQ(enc({0x69, 0x5c, 0x69, 0x45, 0x1a, 0x78, 0x3f, 0x7b, 0x49, 0x21} ),0ULL); ASSERT_EQ(enc({0x6c, 0x03, 0x4c, 0x6c, 0x0f, 0x05, 0x4a, 0x4e, 0x7c, 0x1c} ),0ULL); ASSERT_EQ(enc({0x6c, 0x38, 0x33, 0x4a, 0x46, 0x30, 0x40, 0x15, 0x60, 0x63} ),0ULL); ASSERT_EQ(enc({0x6c, 0x55, 0x0c, 0x32, 0x30, 0x01, 0x28, 0x2f, 0x2d, 0x25} ),0ULL); ASSERT_EQ(enc({0x6e, 0x09, 0x5a, 0x3a, 0x1d, 0x2b, 0x63, 0x77, 0x16, 0x44} ),0ULL); ASSERT_EQ(enc({0x6e, 0x70, 0x20, 0x3e, 0x33, 0x19, 0x4a, 0x0f, 0x07, 0x77} ),0ULL); ASSERT_EQ(enc({0x7a, 0x47, 0x54, 0x16, 0x6e, 0x75, 0x42, 0x78, 0x2f, 0x48} ),0ULL); ASSERT_EQ(enc({0x7b, 0x3e, 0x68, 0x34, 0x5f, 0x71, 0x43, 0x2a, 0x13, 0x12} ),0ULL); }
[ "spooky.bender@gmail.com" ]
spooky.bender@gmail.com
d94386563ee44c70a75d0f1a785fc9f0ab7e1dbb
76fd027a7236973ab117d2689916b6b5bd134229
/src/compiler/js-call-reducer.cc
3a88a90c978102d9f08434a7d317ed068601a4ea
[ "BSD-3-Clause", "SunPro", "bzip2-1.0.6" ]
permissive
skynode/v8
13657e5b41cc4453a4a050087a129bc295b5adf6
0db2196612ab7f2f54782a6e2dbf05021d7a77ec
refs/heads/master
2021-01-19T08:20:26.528487
2017-05-09T10:53:55
2017-05-09T10:53:55
84,011,827
1
0
null
2017-05-09T10:53:57
2017-03-05T23:57:11
C++
UTF-8
C++
false
false
36,858
cc
// Copyright 2015 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/compiler/js-call-reducer.h" #include "src/code-factory.h" #include "src/code-stubs.h" #include "src/compilation-dependencies.h" #include "src/compiler/js-graph.h" #include "src/compiler/linkage.h" #include "src/compiler/node-matchers.h" #include "src/compiler/simplified-operator.h" #include "src/feedback-vector-inl.h" #include "src/ic/call-optimization.h" #include "src/objects-inl.h" namespace v8 { namespace internal { namespace compiler { Reduction JSCallReducer::Reduce(Node* node) { switch (node->opcode()) { case IrOpcode::kJSConstruct: return ReduceJSConstruct(node); case IrOpcode::kJSConstructWithSpread: return ReduceJSConstructWithSpread(node); case IrOpcode::kJSCall: return ReduceJSCall(node); case IrOpcode::kJSCallWithSpread: return ReduceJSCallWithSpread(node); default: break; } return NoChange(); } // ES6 section 22.1.1 The Array Constructor Reduction JSCallReducer::ReduceArrayConstructor(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); Node* target = NodeProperties::GetValueInput(node, 0); CallParameters const& p = CallParametersOf(node->op()); // Check if we have an allocation site from the CallIC. Handle<AllocationSite> site; if (p.feedback().IsValid()) { CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); Handle<Object> feedback(nexus.GetFeedback(), isolate()); if (feedback->IsAllocationSite()) { site = Handle<AllocationSite>::cast(feedback); } } // Turn the {node} into a {JSCreateArray} call. DCHECK_LE(2u, p.arity()); size_t const arity = p.arity() - 2; NodeProperties::ReplaceValueInput(node, target, 0); NodeProperties::ReplaceValueInput(node, target, 1); // TODO(bmeurer): We might need to propagate the tail call mode to // the JSCreateArray operator, because an Array call in tail call // position must always properly consume the parent stack frame. NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); return Changed(node); } // ES6 section 19.3.1.1 Boolean ( value ) Reduction JSCallReducer::ReduceBooleanConstructor(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); CallParameters const& p = CallParametersOf(node->op()); // Replace the {node} with a proper {JSToBoolean} operator. DCHECK_LE(2u, p.arity()); Node* value = (p.arity() == 2) ? jsgraph()->UndefinedConstant() : NodeProperties::GetValueInput(node, 2); Node* context = NodeProperties::GetContextInput(node); value = graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), value, context); ReplaceWithValue(node, value); return Replace(value); } // ES6 section 20.1.1 The Number Constructor Reduction JSCallReducer::ReduceNumberConstructor(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); CallParameters const& p = CallParametersOf(node->op()); // Turn the {node} into a {JSToNumber} call. DCHECK_LE(2u, p.arity()); Node* value = (p.arity() == 2) ? jsgraph()->ZeroConstant() : NodeProperties::GetValueInput(node, 2); NodeProperties::ReplaceValueInputs(node, value); NodeProperties::ChangeOp(node, javascript()->ToNumber()); return Changed(node); } // ES6 section 19.2.3.1 Function.prototype.apply ( thisArg, argArray ) Reduction JSCallReducer::ReduceFunctionPrototypeApply(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); Node* target = NodeProperties::GetValueInput(node, 0); CallParameters const& p = CallParametersOf(node->op()); // Tail calls to Function.prototype.apply are not properly supported // down the pipeline, so we disable this optimization completely for // tail calls (for now). if (p.tail_call_mode() == TailCallMode::kAllow) return NoChange(); Handle<JSFunction> apply = Handle<JSFunction>::cast(HeapObjectMatcher(target).Value()); size_t arity = p.arity(); DCHECK_LE(2u, arity); ConvertReceiverMode convert_mode = ConvertReceiverMode::kAny; if (arity == 2) { // Neither thisArg nor argArray was provided. convert_mode = ConvertReceiverMode::kNullOrUndefined; node->ReplaceInput(0, node->InputAt(1)); node->ReplaceInput(1, jsgraph()->UndefinedConstant()); } else if (arity == 3) { // The argArray was not provided, just remove the {target}. node->RemoveInput(0); --arity; } else if (arity == 4) { // Check if argArray is an arguments object, and {node} is the only value // user of argArray (except for value uses in frame states). Node* arg_array = NodeProperties::GetValueInput(node, 3); if (arg_array->opcode() != IrOpcode::kJSCreateArguments) return NoChange(); for (Edge edge : arg_array->use_edges()) { if (edge.from()->opcode() == IrOpcode::kStateValues) continue; if (!NodeProperties::IsValueEdge(edge)) continue; if (edge.from() == node) continue; return NoChange(); } // Check if the arguments can be handled in the fast case (i.e. we don't // have aliased sloppy arguments), and compute the {start_index} for // rest parameters. CreateArgumentsType const type = CreateArgumentsTypeOf(arg_array->op()); Node* frame_state = NodeProperties::GetFrameStateInput(arg_array); FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); int start_index = 0; // Determine the formal parameter count; Handle<SharedFunctionInfo> shared; if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); int formal_parameter_count = shared->internal_formal_parameter_count(); if (type == CreateArgumentsType::kMappedArguments) { // Mapped arguments (sloppy mode) that are aliased can only be handled // here if there's no side-effect between the {node} and the {arg_array}. // TODO(turbofan): Further relax this constraint. if (formal_parameter_count != 0) { Node* effect = NodeProperties::GetEffectInput(node); while (effect != arg_array) { if (effect->op()->EffectInputCount() != 1 || !(effect->op()->properties() & Operator::kNoWrite)) { return NoChange(); } effect = NodeProperties::GetEffectInput(effect); } } } else if (type == CreateArgumentsType::kRestParameter) { start_index = formal_parameter_count; } // Check if are applying to inlined arguments or to the arguments of // the outermost function. Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput); if (outer_state->opcode() != IrOpcode::kFrameState) { // Reduce {node} to a JSCallForwardVarargs operation, which just // re-pushes the incoming arguments and calls the {target}. node->RemoveInput(0); // Function.prototype.apply node->RemoveInput(2); // arguments NodeProperties::ChangeOp(node, javascript()->CallForwardVarargs( start_index, p.tail_call_mode())); return Changed(node); } // Get to the actual frame state from which to extract the arguments; // we can only optimize this in case the {node} was already inlined into // some other function (and same for the {arg_array}). FrameStateInfo outer_info = OpParameter<FrameStateInfo>(outer_state); if (outer_info.type() == FrameStateType::kArgumentsAdaptor) { // Need to take the parameters from the arguments adaptor. frame_state = outer_state; } // Remove the argArray input from the {node}. node->RemoveInput(static_cast<int>(--arity)); // Add the actual parameters to the {node}, skipping the receiver, // starting from {start_index}. Node* const parameters = frame_state->InputAt(kFrameStateParametersInput); for (int i = start_index + 1; i < parameters->InputCount(); ++i) { node->InsertInput(graph()->zone(), static_cast<int>(arity), parameters->InputAt(i)); ++arity; } // Drop the {target} from the {node}. node->RemoveInput(0); --arity; } else { return NoChange(); } // Change {node} to the new {JSCall} operator. NodeProperties::ChangeOp( node, javascript()->Call(arity, p.frequency(), VectorSlotPair(), convert_mode, p.tail_call_mode())); // Change context of {node} to the Function.prototype.apply context, // to ensure any exception is thrown in the correct context. NodeProperties::ReplaceContextInput( node, jsgraph()->HeapConstant(handle(apply->context(), isolate()))); // Try to further reduce the JSCall {node}. Reduction const reduction = ReduceJSCall(node); return reduction.Changed() ? reduction : Changed(node); } // ES6 section 19.2.3.3 Function.prototype.call (thisArg, ...args) Reduction JSCallReducer::ReduceFunctionPrototypeCall(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); CallParameters const& p = CallParametersOf(node->op()); Handle<JSFunction> call = Handle<JSFunction>::cast( HeapObjectMatcher(NodeProperties::GetValueInput(node, 0)).Value()); // Change context of {node} to the Function.prototype.call context, // to ensure any exception is thrown in the correct context. NodeProperties::ReplaceContextInput( node, jsgraph()->HeapConstant(handle(call->context(), isolate()))); // Remove the target from {node} and use the receiver as target instead, and // the thisArg becomes the new target. If thisArg was not provided, insert // undefined instead. size_t arity = p.arity(); DCHECK_LE(2u, arity); ConvertReceiverMode convert_mode; if (arity == 2) { // The thisArg was not provided, use undefined as receiver. convert_mode = ConvertReceiverMode::kNullOrUndefined; node->ReplaceInput(0, node->InputAt(1)); node->ReplaceInput(1, jsgraph()->UndefinedConstant()); } else { // Just remove the target, which is the first value input. convert_mode = ConvertReceiverMode::kAny; node->RemoveInput(0); --arity; } NodeProperties::ChangeOp( node, javascript()->Call(arity, p.frequency(), VectorSlotPair(), convert_mode, p.tail_call_mode())); // Try to further reduce the JSCall {node}. Reduction const reduction = ReduceJSCall(node); return reduction.Changed() ? reduction : Changed(node); } // ES6 section 19.2.3.6 Function.prototype [ @@hasInstance ] (V) Reduction JSCallReducer::ReduceFunctionPrototypeHasInstance(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); Node* receiver = NodeProperties::GetValueInput(node, 1); Node* object = (node->op()->ValueInputCount() >= 3) ? NodeProperties::GetValueInput(node, 2) : jsgraph()->UndefinedConstant(); Node* context = NodeProperties::GetContextInput(node); Node* frame_state = NodeProperties::GetFrameStateInput(node); Node* effect = NodeProperties::GetEffectInput(node); Node* control = NodeProperties::GetControlInput(node); // TODO(turbofan): If JSOrdinaryToInstance raises an exception, the // stack trace doesn't contain the @@hasInstance call; we have the // corresponding bug in the baseline case. Some massaging of the frame // state would be necessary here. // Morph this {node} into a JSOrdinaryHasInstance node. node->ReplaceInput(0, receiver); node->ReplaceInput(1, object); node->ReplaceInput(2, context); node->ReplaceInput(3, frame_state); node->ReplaceInput(4, effect); node->ReplaceInput(5, control); node->TrimInputCount(6); NodeProperties::ChangeOp(node, javascript()->OrdinaryHasInstance()); return Changed(node); } Reduction JSCallReducer::ReduceObjectGetPrototype(Node* node, Node* object) { Node* effect = NodeProperties::GetEffectInput(node); // Try to determine the {object} map. ZoneHandleSet<Map> object_maps; NodeProperties::InferReceiverMapsResult result = NodeProperties::InferReceiverMaps(object, effect, &object_maps); if (result != NodeProperties::kNoReceiverMaps) { Handle<Map> candidate_map( object_maps[0]->GetPrototypeChainRootMap(isolate())); Handle<Object> candidate_prototype(candidate_map->prototype(), isolate()); // We cannot deal with primitives here. if (candidate_map->IsPrimitiveMap()) return NoChange(); // Check if we can constant-fold the {candidate_prototype}. for (size_t i = 0; i < object_maps.size(); ++i) { Handle<Map> const object_map( object_maps[i]->GetPrototypeChainRootMap(isolate())); if (object_map->IsSpecialReceiverMap() || object_map->has_hidden_prototype() || object_map->prototype() != *candidate_prototype) { // We exclude special receivers, like JSProxy or API objects that // might require access checks here; we also don't want to deal // with hidden prototypes at this point. return NoChange(); } if (result == NodeProperties::kUnreliableReceiverMaps && !object_map->is_stable()) { return NoChange(); } } if (result == NodeProperties::kUnreliableReceiverMaps) { for (size_t i = 0; i < object_maps.size(); ++i) { dependencies()->AssumeMapStable(object_maps[i]); } } Node* value = jsgraph()->Constant(candidate_prototype); ReplaceWithValue(node, value); return Replace(value); } return NoChange(); } // ES6 section 19.1.2.11 Object.getPrototypeOf ( O ) Reduction JSCallReducer::ReduceObjectGetPrototypeOf(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); Node* object = (node->op()->ValueInputCount() >= 3) ? NodeProperties::GetValueInput(node, 2) : jsgraph()->UndefinedConstant(); return ReduceObjectGetPrototype(node, object); } // ES6 section B.2.2.1.1 get Object.prototype.__proto__ Reduction JSCallReducer::ReduceObjectPrototypeGetProto(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); Node* receiver = NodeProperties::GetValueInput(node, 1); return ReduceObjectGetPrototype(node, receiver); } // ES6 section 26.1.7 Reflect.getPrototypeOf ( target ) Reduction JSCallReducer::ReduceReflectGetPrototypeOf(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); Node* target = (node->op()->ValueInputCount() >= 3) ? NodeProperties::GetValueInput(node, 2) : jsgraph()->UndefinedConstant(); return ReduceObjectGetPrototype(node, target); } Reduction JSCallReducer::ReduceCallApiFunction( Node* node, Handle<FunctionTemplateInfo> function_template_info) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); CallParameters const& p = CallParametersOf(node->op()); int const argc = static_cast<int>(p.arity()) - 2; Node* receiver = (p.convert_mode() == ConvertReceiverMode::kNullOrUndefined) ? jsgraph()->HeapConstant(global_proxy()) : NodeProperties::GetValueInput(node, 1); Node* effect = NodeProperties::GetEffectInput(node); // CallApiCallbackStub expects the target in a register, so we count it out, // and counts the receiver as an implicit argument, so we count the receiver // out too. if (argc > CallApiCallbackStub::kArgMax) return NoChange(); // Infer the {receiver} maps, and check if we can inline the API function // callback based on those. ZoneHandleSet<Map> receiver_maps; NodeProperties::InferReceiverMapsResult result = NodeProperties::InferReceiverMaps(receiver, effect, &receiver_maps); if (result == NodeProperties::kNoReceiverMaps) return NoChange(); for (size_t i = 0; i < receiver_maps.size(); ++i) { Handle<Map> receiver_map = receiver_maps[i]; if (!receiver_map->IsJSObjectMap() || (!function_template_info->accept_any_receiver() && receiver_map->is_access_check_needed())) { return NoChange(); } // In case of unreliable {receiver} information, the {receiver_maps} // must all be stable in order to consume the information. if (result == NodeProperties::kUnreliableReceiverMaps) { if (!receiver_map->is_stable()) return NoChange(); } } // See if we can constant-fold the compatible receiver checks. CallOptimization call_optimization(function_template_info); if (!call_optimization.is_simple_api_call()) return NoChange(); CallOptimization::HolderLookup lookup; Handle<JSObject> api_holder = call_optimization.LookupHolderOfExpectedType(receiver_maps[0], &lookup); if (lookup == CallOptimization::kHolderNotFound) return NoChange(); for (size_t i = 1; i < receiver_maps.size(); ++i) { CallOptimization::HolderLookup lookupi; Handle<JSObject> holder = call_optimization.LookupHolderOfExpectedType( receiver_maps[i], &lookupi); if (lookup != lookupi) return NoChange(); if (!api_holder.is_identical_to(holder)) return NoChange(); } // Install stability dependencies for unreliable {receiver_maps}. if (result == NodeProperties::kUnreliableReceiverMaps) { for (size_t i = 0; i < receiver_maps.size(); ++i) { dependencies()->AssumeMapStable(receiver_maps[i]); } } // CallApiCallbackStub's register arguments: code, target, call data, holder, // function address. // TODO(turbofan): Consider introducing a JSCallApiCallback operator for // this and lower it during JSGenericLowering, and unify this with the // JSNativeContextSpecialization::InlineApiCall method a bit. Handle<CallHandlerInfo> call_handler_info( CallHandlerInfo::cast(function_template_info->call_code()), isolate()); Handle<Object> data(call_handler_info->data(), isolate()); CallApiCallbackStub stub(isolate(), argc, false); CallInterfaceDescriptor cid = stub.GetCallInterfaceDescriptor(); CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( isolate(), graph()->zone(), cid, cid.GetStackParameterCount() + argc + 1 /* implicit receiver */, CallDescriptor::kNeedsFrameState, Operator::kNoProperties, MachineType::AnyTagged(), 1); ApiFunction api_function(v8::ToCData<Address>(call_handler_info->callback())); Node* holder = lookup == CallOptimization::kHolderFound ? jsgraph()->HeapConstant(api_holder) : receiver; ExternalReference function_reference( &api_function, ExternalReference::DIRECT_API_CALL, isolate()); node->InsertInput(graph()->zone(), 0, jsgraph()->HeapConstant(stub.GetCode())); node->InsertInput(graph()->zone(), 2, jsgraph()->Constant(data)); node->InsertInput(graph()->zone(), 3, holder); node->InsertInput(graph()->zone(), 4, jsgraph()->ExternalConstant(function_reference)); node->ReplaceInput(5, receiver); NodeProperties::ChangeOp(node, common()->Call(call_descriptor)); return Changed(node); } Reduction JSCallReducer::ReduceSpreadCall(Node* node, int arity) { DCHECK(node->opcode() == IrOpcode::kJSCallWithSpread || node->opcode() == IrOpcode::kJSConstructWithSpread); // Do check to make sure we can actually avoid iteration. if (!isolate()->initial_array_iterator_prototype_map()->is_stable()) { return NoChange(); } Node* spread = NodeProperties::GetValueInput(node, arity); // Check if spread is an arguments object, and {node} is the only value user // of spread (except for value uses in frame states). if (spread->opcode() != IrOpcode::kJSCreateArguments) return NoChange(); for (Edge edge : spread->use_edges()) { if (edge.from()->opcode() == IrOpcode::kStateValues) continue; if (!NodeProperties::IsValueEdge(edge)) continue; if (edge.from() == node) continue; return NoChange(); } // Get to the actual frame state from which to extract the arguments; // we can only optimize this in case the {node} was already inlined into // some other function (and same for the {spread}). CreateArgumentsType type = CreateArgumentsTypeOf(spread->op()); Node* frame_state = NodeProperties::GetFrameStateInput(spread); Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput); if (outer_state->opcode() != IrOpcode::kFrameState) return NoChange(); FrameStateInfo outer_info = OpParameter<FrameStateInfo>(outer_state); if (outer_info.type() == FrameStateType::kArgumentsAdaptor) { // Need to take the parameters from the arguments adaptor. frame_state = outer_state; } FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); int start_index = 0; if (type == CreateArgumentsType::kMappedArguments) { // Mapped arguments (sloppy mode) cannot be handled if they are aliased. Handle<SharedFunctionInfo> shared; if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); if (shared->internal_formal_parameter_count() != 0) return NoChange(); } else if (type == CreateArgumentsType::kRestParameter) { Handle<SharedFunctionInfo> shared; if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); start_index = shared->internal_formal_parameter_count(); // Only check the array iterator protector when we have a rest object. if (!isolate()->IsArrayIteratorLookupChainIntact()) return NoChange(); // Add a code dependency on the array iterator protector. dependencies()->AssumePropertyCell(factory()->array_iterator_protector()); } dependencies()->AssumeMapStable( isolate()->initial_array_iterator_prototype_map()); node->RemoveInput(arity--); // Add the actual parameters to the {node}, skipping the receiver. Node* const parameters = frame_state->InputAt(kFrameStateParametersInput); for (int i = start_index + 1; i < state_info.parameter_count(); ++i) { node->InsertInput(graph()->zone(), static_cast<int>(++arity), parameters->InputAt(i)); } // TODO(turbofan): Collect call counts on spread call/construct and thread it // through here. if (node->opcode() == IrOpcode::kJSCallWithSpread) { NodeProperties::ChangeOp(node, javascript()->Call(arity + 1)); } else { NodeProperties::ChangeOp(node, javascript()->Construct(arity + 2)); } return Changed(node); } namespace { bool ShouldUseCallICFeedback(Node* node) { HeapObjectMatcher m(node); if (m.HasValue() || m.IsJSCreateClosure()) { // Don't use CallIC feedback when we know the function // being called, i.e. either know the closure itself or // at least the SharedFunctionInfo. return false; } else if (m.IsPhi()) { // Protect against endless loops here. Node* control = NodeProperties::GetControlInput(node); if (control->opcode() == IrOpcode::kLoop) return false; // Check if {node} is a Phi of nodes which shouldn't // use CallIC feedback (not looking through loops). int const value_input_count = m.node()->op()->ValueInputCount(); for (int n = 0; n < value_input_count; ++n) { if (ShouldUseCallICFeedback(node->InputAt(n))) return true; } return false; } return true; } } // namespace Reduction JSCallReducer::ReduceJSCall(Node* node) { DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); CallParameters const& p = CallParametersOf(node->op()); Node* target = NodeProperties::GetValueInput(node, 0); Node* control = NodeProperties::GetControlInput(node); Node* effect = NodeProperties::GetEffectInput(node); // Try to specialize JSCall {node}s with constant {target}s. HeapObjectMatcher m(target); if (m.HasValue()) { if (m.Value()->IsJSFunction()) { Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value()); Handle<SharedFunctionInfo> shared(function->shared(), isolate()); // Raise a TypeError if the {target} is a "classConstructor". if (IsClassConstructor(shared->kind())) { NodeProperties::ReplaceValueInputs(node, target); NodeProperties::ChangeOp( node, javascript()->CallRuntime( Runtime::kThrowConstructorNonCallableError, 1)); return Changed(node); } // Don't inline cross native context. if (function->native_context() != *native_context()) return NoChange(); // Check for known builtin functions. switch (shared->code()->builtin_index()) { case Builtins::kBooleanConstructor: return ReduceBooleanConstructor(node); case Builtins::kFunctionPrototypeApply: return ReduceFunctionPrototypeApply(node); case Builtins::kFunctionPrototypeCall: return ReduceFunctionPrototypeCall(node); case Builtins::kFunctionPrototypeHasInstance: return ReduceFunctionPrototypeHasInstance(node); case Builtins::kNumberConstructor: return ReduceNumberConstructor(node); case Builtins::kObjectGetPrototypeOf: return ReduceObjectGetPrototypeOf(node); case Builtins::kObjectPrototypeGetProto: return ReduceObjectPrototypeGetProto(node); case Builtins::kReflectGetPrototypeOf: return ReduceReflectGetPrototypeOf(node); default: break; } // Check for the Array constructor. if (*function == function->native_context()->array_function()) { return ReduceArrayConstructor(node); } if (!FLAG_runtime_stats && shared->IsApiFunction()) { Handle<FunctionTemplateInfo> function_template_info( FunctionTemplateInfo::cast(shared->function_data()), isolate()); return ReduceCallApiFunction(node, function_template_info); } } else if (m.Value()->IsJSBoundFunction()) { Handle<JSBoundFunction> function = Handle<JSBoundFunction>::cast(m.Value()); Handle<JSReceiver> bound_target_function( function->bound_target_function(), isolate()); Handle<Object> bound_this(function->bound_this(), isolate()); Handle<FixedArray> bound_arguments(function->bound_arguments(), isolate()); CallParameters const& p = CallParametersOf(node->op()); ConvertReceiverMode const convert_mode = (bound_this->IsNullOrUndefined(isolate())) ? ConvertReceiverMode::kNullOrUndefined : ConvertReceiverMode::kNotNullOrUndefined; size_t arity = p.arity(); DCHECK_LE(2u, arity); // Patch {node} to use [[BoundTargetFunction]] and [[BoundThis]]. NodeProperties::ReplaceValueInput( node, jsgraph()->Constant(bound_target_function), 0); NodeProperties::ReplaceValueInput(node, jsgraph()->Constant(bound_this), 1); // Insert the [[BoundArguments]] for {node}. for (int i = 0; i < bound_arguments->length(); ++i) { node->InsertInput( graph()->zone(), i + 2, jsgraph()->Constant(handle(bound_arguments->get(i), isolate()))); arity++; } NodeProperties::ChangeOp( node, javascript()->Call(arity, p.frequency(), VectorSlotPair(), convert_mode, p.tail_call_mode())); // Try to further reduce the JSCall {node}. Reduction const reduction = ReduceJSCall(node); return reduction.Changed() ? reduction : Changed(node); } // Don't mess with other {node}s that have a constant {target}. // TODO(bmeurer): Also support proxies here. return NoChange(); } // Extract feedback from the {node} using the CallICNexus. if (!p.feedback().IsValid()) return NoChange(); CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); if (nexus.IsUninitialized()) { // TODO(turbofan): Tail-calling to a CallIC stub is not supported. if (p.tail_call_mode() == TailCallMode::kAllow) return NoChange(); // Insert a CallIC here to collect feedback for uninitialized calls. int const arg_count = static_cast<int>(p.arity() - 2); Callable callable = CodeFactory::CallIC(isolate(), p.convert_mode()); CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( isolate(), graph()->zone(), callable.descriptor(), arg_count + 1, flags); Node* stub_code = jsgraph()->HeapConstant(callable.code()); Node* stub_arity = jsgraph()->Constant(arg_count); Node* slot_index = jsgraph()->Constant(FeedbackVector::GetIndex(p.feedback().slot())); Node* feedback_vector = jsgraph()->HeapConstant(p.feedback().vector()); node->InsertInput(graph()->zone(), 0, stub_code); node->InsertInput(graph()->zone(), 2, stub_arity); node->InsertInput(graph()->zone(), 3, slot_index); node->InsertInput(graph()->zone(), 4, feedback_vector); NodeProperties::ChangeOp(node, common()->Call(desc)); return Changed(node); } Handle<Object> feedback(nexus.GetFeedback(), isolate()); if (feedback->IsAllocationSite()) { // Retrieve the Array function from the {node}. Node* array_function = jsgraph()->HeapConstant( handle(native_context()->array_function(), isolate())); // Check that the {target} is still the {array_function}. Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, array_function); effect = graph()->NewNode(simplified()->CheckIf(), check, effect, control); // Turn the {node} into a {JSCreateArray} call. NodeProperties::ReplaceValueInput(node, array_function, 0); NodeProperties::ReplaceEffectInput(node, effect); return ReduceArrayConstructor(node); } else if (feedback->IsWeakCell()) { // Check if we want to use CallIC feedback here. if (!ShouldUseCallICFeedback(target)) return NoChange(); Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); if (cell->value()->IsJSFunction()) { Node* target_function = jsgraph()->Constant(handle(cell->value(), isolate())); // Check that the {target} is still the {target_function}. Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, target_function); effect = graph()->NewNode(simplified()->CheckIf(), check, effect, control); // Specialize the JSCall node to the {target_function}. NodeProperties::ReplaceValueInput(node, target_function, 0); NodeProperties::ReplaceEffectInput(node, effect); // Try to further reduce the JSCall {node}. Reduction const reduction = ReduceJSCall(node); return reduction.Changed() ? reduction : Changed(node); } } return NoChange(); } Reduction JSCallReducer::ReduceJSCallWithSpread(Node* node) { DCHECK_EQ(IrOpcode::kJSCallWithSpread, node->opcode()); SpreadWithArityParameter const& p = SpreadWithArityParameterOf(node->op()); DCHECK_LE(3u, p.arity()); int arity = static_cast<int>(p.arity() - 1); return ReduceSpreadCall(node, arity); } Reduction JSCallReducer::ReduceJSConstruct(Node* node) { DCHECK_EQ(IrOpcode::kJSConstruct, node->opcode()); ConstructParameters const& p = ConstructParametersOf(node->op()); DCHECK_LE(2u, p.arity()); int const arity = static_cast<int>(p.arity() - 2); Node* target = NodeProperties::GetValueInput(node, 0); Node* new_target = NodeProperties::GetValueInput(node, arity + 1); Node* effect = NodeProperties::GetEffectInput(node); Node* control = NodeProperties::GetControlInput(node); // Try to specialize JSConstruct {node}s with constant {target}s. HeapObjectMatcher m(target); if (m.HasValue()) { if (m.Value()->IsJSFunction()) { Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value()); // Raise a TypeError if the {target} is not a constructor. if (!function->IsConstructor()) { NodeProperties::ReplaceValueInputs(node, target); NodeProperties::ChangeOp( node, javascript()->CallRuntime( Runtime::kThrowConstructedNonConstructable)); return Changed(node); } // Don't inline cross native context. if (function->native_context() != *native_context()) return NoChange(); // Check for the ArrayConstructor. if (*function == function->native_context()->array_function()) { // Check if we have an allocation site. Handle<AllocationSite> site; if (p.feedback().IsValid()) { CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); Handle<Object> feedback(nexus.GetFeedback(), isolate()); if (feedback->IsAllocationSite()) { site = Handle<AllocationSite>::cast(feedback); } } // Turn the {node} into a {JSCreateArray} call. for (int i = arity; i > 0; --i) { NodeProperties::ReplaceValueInput( node, NodeProperties::GetValueInput(node, i), i + 1); } NodeProperties::ReplaceValueInput(node, new_target, 1); NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); return Changed(node); } } // Don't mess with other {node}s that have a constant {target}. // TODO(bmeurer): Also support optimizing bound functions and proxies here. return NoChange(); } if (!p.feedback().IsValid()) return NoChange(); CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); Handle<Object> feedback(nexus.GetFeedback(), isolate()); if (feedback->IsAllocationSite()) { // The feedback is an AllocationSite, which means we have called the // Array function and collected transition (and pretenuring) feedback // for the resulting arrays. This has to be kept in sync with the // implementation of the CallConstructStub. Handle<AllocationSite> site = Handle<AllocationSite>::cast(feedback); // Retrieve the Array function from the {node}. Node* array_function = jsgraph()->HeapConstant( handle(native_context()->array_function(), isolate())); // Check that the {target} is still the {array_function}. Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, array_function); effect = graph()->NewNode(simplified()->CheckIf(), check, effect, control); // Turn the {node} into a {JSCreateArray} call. NodeProperties::ReplaceEffectInput(node, effect); for (int i = arity; i > 0; --i) { NodeProperties::ReplaceValueInput( node, NodeProperties::GetValueInput(node, i), i + 1); } NodeProperties::ReplaceValueInput(node, new_target, 1); NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); return Changed(node); } else if (feedback->IsWeakCell()) { // Check if we want to use CallIC feedback here. if (!ShouldUseCallICFeedback(target)) return NoChange(); Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); if (cell->value()->IsJSFunction()) { Node* target_function = jsgraph()->Constant(handle(cell->value(), isolate())); // Check that the {target} is still the {target_function}. Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, target_function); effect = graph()->NewNode(simplified()->CheckIf(), check, effect, control); // Specialize the JSConstruct node to the {target_function}. NodeProperties::ReplaceValueInput(node, target_function, 0); NodeProperties::ReplaceEffectInput(node, effect); if (target == new_target) { NodeProperties::ReplaceValueInput(node, target_function, arity + 1); } // Try to further reduce the JSConstruct {node}. Reduction const reduction = ReduceJSConstruct(node); return reduction.Changed() ? reduction : Changed(node); } } return NoChange(); } Reduction JSCallReducer::ReduceJSConstructWithSpread(Node* node) { DCHECK_EQ(IrOpcode::kJSConstructWithSpread, node->opcode()); SpreadWithArityParameter const& p = SpreadWithArityParameterOf(node->op()); DCHECK_LE(3u, p.arity()); int arity = static_cast<int>(p.arity() - 2); return ReduceSpreadCall(node, arity); } Graph* JSCallReducer::graph() const { return jsgraph()->graph(); } Isolate* JSCallReducer::isolate() const { return jsgraph()->isolate(); } Factory* JSCallReducer::factory() const { return isolate()->factory(); } Handle<JSGlobalProxy> JSCallReducer::global_proxy() const { return handle(JSGlobalProxy::cast(native_context()->global_proxy()), isolate()); } CommonOperatorBuilder* JSCallReducer::common() const { return jsgraph()->common(); } JSOperatorBuilder* JSCallReducer::javascript() const { return jsgraph()->javascript(); } SimplifiedOperatorBuilder* JSCallReducer::simplified() const { return jsgraph()->simplified(); } } // namespace compiler } // namespace internal } // namespace v8
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
ff6c3bca28a9d1863bc339ad767c1c0add035428
5a60d60fca2c2b8b44d602aca7016afb625bc628
/aws-cpp-sdk-guardduty/source/model/UpdateMemberDetectorsResult.cpp
80cec6012b0e2371f805c856d6efc66dddc3bd7e
[ "Apache-2.0", "MIT", "JSON" ]
permissive
yuatpocketgems/aws-sdk-cpp
afaa0bb91b75082b63236cfc0126225c12771ed0
a0dcbc69c6000577ff0e8171de998ccdc2159c88
refs/heads/master
2023-01-23T10:03:50.077672
2023-01-04T22:42:53
2023-01-04T22:42:53
134,497,260
0
1
null
2018-05-23T01:47:14
2018-05-23T01:47:14
null
UTF-8
C++
false
false
1,325
cpp
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/guardduty/model/UpdateMemberDetectorsResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::GuardDuty::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; UpdateMemberDetectorsResult::UpdateMemberDetectorsResult() { } UpdateMemberDetectorsResult::UpdateMemberDetectorsResult(const Aws::AmazonWebServiceResult<JsonValue>& result) { *this = result; } UpdateMemberDetectorsResult& UpdateMemberDetectorsResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("unprocessedAccounts")) { Aws::Utils::Array<JsonView> unprocessedAccountsJsonList = jsonValue.GetArray("unprocessedAccounts"); for(unsigned unprocessedAccountsIndex = 0; unprocessedAccountsIndex < unprocessedAccountsJsonList.GetLength(); ++unprocessedAccountsIndex) { m_unprocessedAccounts.push_back(unprocessedAccountsJsonList[unprocessedAccountsIndex].AsObject()); } } return *this; }
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
37255147e284ca4d1f37f0e803854331d9c33dd0
83bacfbdb7ad17cbc2fc897b3460de1a6726a3b1
/third_party/WebKit/Source/web/PageWidgetDelegate.cpp
a0723ebf497619369acfcc5bbd582d8d75ce4d41
[ "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "Apache-2.0" ]
permissive
cool2528/miniblink49
d909e39012f2c5d8ab658dc2a8b314ad0050d8ea
7f646289d8074f098cf1244adc87b95e34ab87a8
refs/heads/master
2020-06-05T03:18:43.211372
2019-06-01T08:57:37
2019-06-01T08:59:56
192,294,645
2
0
Apache-2.0
2019-06-17T07:16:28
2019-06-17T07:16:27
null
UTF-8
C++
false
false
8,751
cpp
/* * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "web/PageWidgetDelegate.h" #include "core/frame/FrameView.h" #include "core/frame/LocalFrame.h" #include "core/input/EventHandler.h" #include "core/layout/LayoutView.h" #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" #include "core/page/AutoscrollController.h" #include "core/page/Page.h" #include "core/paint/TransformRecorder.h" #include "platform/Logging.h" #include "platform/graphics/GraphicsContext.h" #include "platform/graphics/paint/ClipRecorder.h" #include "platform/graphics/paint/DrawingRecorder.h" #include "platform/graphics/paint/SkPictureBuilder.h" #include "platform/transforms/AffineTransform.h" #include "public/web/WebInputEvent.h" #include "web/PageOverlayList.h" #include "web/WebInputEventConversion.h" #include "wtf/CurrentTime.h" namespace blink { void PageWidgetDelegate::animate(Page& page, double monotonicFrameBeginTime, LocalFrame& root) { RefPtrWillBeRawPtr<FrameView> view = root.view(); if (!view) return; page.autoscrollController().animate(monotonicFrameBeginTime); page.animator().serviceScriptedAnimations(monotonicFrameBeginTime); } void PageWidgetDelegate::layout(Page& page, LocalFrame& root) { page.animator().updateLayoutAndStyleForPainting(&root); } void PageWidgetDelegate::paint(Page& page, PageOverlayList* overlays, WebCanvas* canvas, const WebRect& rect, LocalFrame& root) { if (rect.isEmpty()) return; IntRect intRect(rect); SkPictureBuilder pictureBuilder(intRect); { GraphicsContext& paintContext = pictureBuilder.context(); // FIXME: device scale factor settings are layering violations and should not // be used within Blink paint code. float scaleFactor = page.deviceScaleFactor(); paintContext.setDeviceScaleFactor(scaleFactor); AffineTransform scale; scale.scale(scaleFactor); TransformRecorder scaleRecorder(paintContext, root, scale); IntRect dirtyRect(rect); FrameView* view = root.view(); if (view) { ClipRecorder clipRecorder(paintContext, root, DisplayItem::PageWidgetDelegateClip, LayoutRect(dirtyRect)); view->paint(&paintContext, dirtyRect); if (overlays) overlays->paintWebFrame(paintContext); } else if (!DrawingRecorder::useCachedDrawingIfPossible(paintContext, root, DisplayItem::PageWidgetDelegateBackgroundFallback)) { DrawingRecorder drawingRecorder(paintContext, root, DisplayItem::PageWidgetDelegateBackgroundFallback, dirtyRect); paintContext.fillRect(dirtyRect, Color::white); } } pictureBuilder.endRecording()->playback(canvas); } bool PageWidgetDelegate::handleInputEvent(PageWidgetEventHandler& handler, const WebInputEvent& event, LocalFrame* root) { switch (event.type) { // FIXME: WebKit seems to always return false on mouse events processing // methods. For now we'll assume it has processed them (as we are only // interested in whether keyboard events are processed). // FIXME: Why do we return true when there is no root or the root is // detached? case WebInputEvent::MouseMove: if (!root || !root->view()) return true; handler.handleMouseMove(*root, static_cast<const WebMouseEvent&>(event)); return true; case WebInputEvent::MouseLeave: if (!root || !root->view()) return true; handler.handleMouseLeave(*root, static_cast<const WebMouseEvent&>(event)); return true; case WebInputEvent::MouseDown: if (!root || !root->view()) return true; handler.handleMouseDown(*root, static_cast<const WebMouseEvent&>(event)); return true; case WebInputEvent::MouseUp: if (!root || !root->view()) return true; handler.handleMouseUp(*root, static_cast<const WebMouseEvent&>(event)); return true; case WebInputEvent::MouseWheel: if (!root || !root->view()) return false; return handler.handleMouseWheel(*root, static_cast<const WebMouseWheelEvent&>(event)); case WebInputEvent::RawKeyDown: case WebInputEvent::KeyDown: case WebInputEvent::KeyUp: return handler.handleKeyEvent(static_cast<const WebKeyboardEvent&>(event)); case WebInputEvent::Char: return handler.handleCharEvent(static_cast<const WebKeyboardEvent&>(event)); case WebInputEvent::GestureScrollBegin: case WebInputEvent::GestureScrollEnd: case WebInputEvent::GestureScrollUpdate: case WebInputEvent::GestureFlingStart: case WebInputEvent::GestureFlingCancel: case WebInputEvent::GestureTap: case WebInputEvent::GestureTapUnconfirmed: case WebInputEvent::GestureTapDown: case WebInputEvent::GestureShowPress: case WebInputEvent::GestureTapCancel: case WebInputEvent::GestureDoubleTap: case WebInputEvent::GestureTwoFingerTap: case WebInputEvent::GestureLongPress: case WebInputEvent::GestureLongTap: return handler.handleGestureEvent(static_cast<const WebGestureEvent&>(event)); case WebInputEvent::TouchStart: case WebInputEvent::TouchMove: case WebInputEvent::TouchEnd: case WebInputEvent::TouchCancel: if (!root || !root->view()) return false; return handler.handleTouchEvent(*root, static_cast<const WebTouchEvent&>(event)); case WebInputEvent::GesturePinchBegin: case WebInputEvent::GesturePinchEnd: case WebInputEvent::GesturePinchUpdate: // Touchscreen pinch events are currently not handled in main thread. Once they are, // these should be passed to |handleGestureEvent| similar to gesture scroll events. return false; default: return false; } } // ---------------------------------------------------------------- // Default handlers for PageWidgetEventHandler void PageWidgetEventHandler::handleMouseMove(LocalFrame& mainFrame, const WebMouseEvent& event) { mainFrame.eventHandler().handleMouseMoveEvent(PlatformMouseEventBuilder(mainFrame.view(), event)); } void PageWidgetEventHandler::handleMouseLeave(LocalFrame& mainFrame, const WebMouseEvent& event) { mainFrame.eventHandler().handleMouseLeaveEvent(PlatformMouseEventBuilder(mainFrame.view(), event)); } void PageWidgetEventHandler::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& event) { mainFrame.eventHandler().handleMousePressEvent(PlatformMouseEventBuilder(mainFrame.view(), event)); } void PageWidgetEventHandler::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& event) { mainFrame.eventHandler().handleMouseReleaseEvent(PlatformMouseEventBuilder(mainFrame.view(), event)); } bool PageWidgetEventHandler::handleMouseWheel(LocalFrame& mainFrame, const WebMouseWheelEvent& event) { return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(mainFrame.view(), event)); } bool PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFrame, const WebTouchEvent& event) { return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(mainFrame.view(), event)); } } // namespace blink
[ "22249030@qq.com" ]
22249030@qq.com
8e1d61e7153eaa8bf9afe295e38be14caf21e752
0f8965ca3ef310dc0ba47f383ebdcc1bcef3616a
/ext/TslGame_MULTI_HACK-master/PUBG 2.3.3/SDK/PUBG_SystemMessageWidget_functions.cpp
0338b1b98cfb0ce7d0f2094dfd376bcdeb3bc3bc
[]
no_license
sbaa2014/MFCApplication1
dc8f58200845ad6c51edb7aff72b3532ad63f532
ca6106582c77a55d50cfa209341dc424757d3978
refs/heads/master
2021-01-20T17:19:52.409004
2017-07-14T11:47:28
2017-07-14T11:47:28
95,742,921
5
3
null
null
null
null
UTF-8
C++
false
false
1,915
cpp
#pragma once // PUBG (Beta) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace Classes { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function SystemMessageWidget.SystemMessageWidget_C.AddMessage // (FUNC_Public, FUNC_BlueprintCallable, FUNC_BlueprintEvent) // Parameters: // class UMessageWidget_C* Message (CPF_Parm, CPF_ZeroConstructor, CPF_IsPlainOldData) void USystemMessageWidget_C::AddMessage(class UMessageWidget_C* Message) { static auto fn = UObject::FindObject<UFunction>("Function SystemMessageWidget.SystemMessageWidget_C.AddMessage"); struct { class UMessageWidget_C* Message; } params; params.Message = Message; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function SystemMessageWidget.SystemMessageWidget_C.DisplaySystemMessage // (FUNC_Public, FUNC_HasDefaults, FUNC_BlueprintCallable, FUNC_BlueprintEvent) // Parameters: // TEnumAsByte<enum class ESystemMessageType> MessageType (CPF_Parm, CPF_ZeroConstructor, CPF_IsPlainOldData) // struct FText Message (CPF_Parm) void USystemMessageWidget_C::DisplaySystemMessage(TEnumAsByte<enum class ESystemMessageType> MessageType, const struct FText& Message) { static auto fn = UObject::FindObject<UFunction>("Function SystemMessageWidget.SystemMessageWidget_C.DisplaySystemMessage"); struct { TEnumAsByte<enum class ESystemMessageType> MessageType; struct FText Message; } params; params.MessageType = MessageType; params.Message = Message; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "sbaa2009@gmail.com" ]
sbaa2009@gmail.com
c1fab5a4c0827d1790fec7c9fc8a1cb5c6772805
8faee0b01b9afed32bb5b7ef1ab0dcbc46788b5b
/source/src/objtools/alnmgr/unit_test/unit_test_alnmgr.cpp
006b1336bae0c03424dcefb95b848903a3e29ee4
[]
no_license
jackgopack4/pico-blast
5fe3fa1944b727465845e1ead1a3c563b43734fb
cde1bd03900d72d0246cb58a66b41e5dc17329dd
refs/heads/master
2021-01-14T12:31:05.676311
2014-05-17T19:22:05
2014-05-17T19:22:05
16,808,473
2
0
null
null
null
null
UTF-8
C++
false
false
37,451
cpp
/* $Id: unit_test_alnmgr.cpp 369976 2012-07-25 15:20:22Z grichenk $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Author: Aleksey Grichenko * * File Description: * Alignment Manager unit test. * * =========================================================================== */ #include <ncbi_pch.hpp> #include <corelib/ncbiapp.hpp> #include <corelib/test_boost.hpp> #include <serial/objistr.hpp> #include <objects/seqloc/Seq_id.hpp> #include <objects/general/Object_id.hpp> #include <objtools/alnmgr/aln_user_options.hpp> #include <objtools/alnmgr/aln_asn_reader.hpp> #include <objtools/alnmgr/aln_container.hpp> #include <objtools/alnmgr/aln_tests.hpp> #include <objtools/alnmgr/aln_stats.hpp> #include <objtools/alnmgr/pairwise_aln.hpp> #include <objtools/alnmgr/aln_serial.hpp> #include <objtools/alnmgr/sparse_aln.hpp> #include <objtools/alnmgr/aln_converters.hpp> #include <objtools/alnmgr/aln_builders.hpp> #include <objtools/alnmgr/sparse_ci.hpp> #include <objtools/alnmgr/aln_generators.hpp> #include <objtools/data_loaders/genbank/gbloader.hpp> #include <objmgr/object_manager.hpp> #include <objmgr/scope.hpp> #include <common/test_assert.h> /* This header must go last */ USING_NCBI_SCOPE; USING_SCOPE(objects); NCBITEST_INIT_CMDLINE(descrs) { descrs->AddFlag("print_exp", "Print expected values instead of testing"); } bool DumpExpected(void) { return CNcbiApplication::Instance()->GetArgs()["print_exp"]; } CScope& GetScope(void) { static CRef<CScope> s_Scope; if ( !s_Scope ) { CRef<CObjectManager> objmgr = CObjectManager::GetInstance(); CGBDataLoader::RegisterInObjectManager(*objmgr); s_Scope.Reset(new CScope(*objmgr)); s_Scope->AddDefaults(); } return *s_Scope; } // Helper function for loading alignments. Returns number of alignments loaded // into the container. The expected format is: // <int-number-of-alignments> // <Seq-align>+ size_t LoadAligns(CNcbiIstream& in, CAlnContainer& aligns, size_t limit = 0) { size_t num_aligns = 0; while ( !in.eof() ) { try { CRef<CSeq_align> align(new CSeq_align); in >> MSerial_AsnText >> *align; aligns.insert(*align); num_aligns++; if (limit > 0 && num_aligns >= limit) break; } catch (CIOException e) { break; } } return num_aligns; } // The aln_id_map argument is required because TScopeAlnStat keeps const // reference to the id-map. So, the map needs to be returned to the caller. CRef<TScopeAlnStats> InitAlnStats(const CAlnContainer& aligns, auto_ptr<TScopeAlnIdMap>& aln_id_map) { TScopeAlnSeqIdConverter id_conv(&GetScope()); TScopeIdExtract id_extract(id_conv); aln_id_map.reset(new TScopeAlnIdMap(id_extract, aligns.size())); ITERATE(CAlnContainer, aln_it, aligns) { aln_id_map->push_back(**aln_it); } CRef<TScopeAlnStats> aln_stats(new TScopeAlnStats(*aln_id_map)); return aln_stats; } void CheckPairwiseAln(CNcbiIstream& in_exp, const CPairwiseAln& pw, size_t aln_idx, int anchor, int row) { // For each alignment/anchor/row: // <int-align-index> <int-anchor_index> <int-row-index> <int-pairwise-flags> // <int-align-first-from> <int-align-first-to> <int-base-width> <Seq-id> // <int-align-second-from> <int-align-second-to> <int-base-width> <Seq-id> // For each CPairwiseAln element: // <int-first-from> <int-second-from> <int-len> <int-is-direct> // <int-insertions-count> // For each insertion: // <int-first-from> <int-second-from> <int-len> <int-is-direct> // For each iterator: // <int-first-from> <int-first-to> <int-second-from> <int-second-to> ... // ... <int-direct> <int-first-direct> <int-aligned> TSignedSeqPos first_from, first_to, second_from, second_to, len; int flags; if ( DumpExpected() ) { cout << aln_idx << " " << anchor << " " << row << " " << pw.GetFlags() << endl; cout << " " << pw.GetFirstFrom() << " " << pw.GetFirstTo() << " " << pw.GetFirstBaseWidth() << " " << MSerial_AsnText << pw.GetFirstId()->GetSeqId(); cout << " " << pw.GetSecondPosByFirstPos(pw.GetFirstFrom()) << " " << pw.GetSecondPosByFirstPos(pw.GetFirstTo()) << " " << pw.GetSecondBaseWidth() << " " << MSerial_AsnText << pw.GetSecondId()->GetSeqId(); } else { size_t expected_aln_idx; int expected_row, expected_anchor; int first_width, second_width; CSeq_id first_id, second_id; in_exp >> expected_aln_idx >> expected_anchor >> expected_row >> flags; in_exp >> first_from >> first_to >> first_width; in_exp >> MSerial_AsnText >> first_id; in_exp >> second_from >> second_to >> second_width; in_exp >> MSerial_AsnText >> second_id; BOOST_CHECK(in_exp.good()); BOOST_CHECK(aln_idx == expected_aln_idx); BOOST_CHECK(anchor == expected_anchor); BOOST_CHECK(row == expected_row); BOOST_CHECK(pw.GetFlags() == flags); BOOST_CHECK(pw.GetFirstId()->GetSeqId().Equals(first_id)); BOOST_CHECK(pw.GetSecondId()->GetSeqId().Equals(second_id)); BOOST_CHECK(pw.GetFirstBaseWidth() == first_width); BOOST_CHECK(pw.GetSecondBaseWidth() == second_width); BOOST_CHECK(pw.GetFirstFrom() == first_from); BOOST_CHECK(pw.GetFirstTo() == first_to); BOOST_CHECK(pw.GetSecondPosByFirstPos(pw.GetFirstFrom()) == second_from); BOOST_CHECK(pw.GetSecondPosByFirstPos(pw.GetFirstTo()) == second_to); } ITERATE(CPairwiseAln, rg_it, pw) { CAlignRange<TSignedSeqPos> rg = *rg_it; if ( DumpExpected() ) { cout << " " << rg_it->GetFirstFrom() << " " << rg_it->GetSecondFrom() << " " << rg_it->GetLength() << " " << (rg.IsDirect() ? 1 : 0) << endl; } else { in_exp >> first_from >> second_from >> len >> flags; BOOST_CHECK(in_exp.good()); BOOST_CHECK(rg_it->GetFirstFrom() == first_from); BOOST_CHECK(rg_it->GetSecondFrom() == second_from); BOOST_CHECK(rg_it->GetLength() == len); BOOST_CHECK(rg_it->IsDirect() == (flags != 0)); } } if ( DumpExpected() ) { cout << " " << pw.GetInsertions().size() << endl; } else { size_t ins_count; in_exp >> ins_count; BOOST_CHECK(in_exp.good()); BOOST_CHECK(pw.GetInsertions().size() == ins_count); } if (!pw.GetInsertions().empty()) { ITERATE(CPairwiseAln::TAlignRangeVector, gap, pw.GetInsertions()) { if ( DumpExpected() ) { cout << " " << gap->GetFirstFrom() << " " << gap->GetSecondFrom() << " " << gap->GetLength() << " " << (gap->IsDirect() ? 1 : 0) << endl; } else { in_exp >> first_from >> second_from >> len >> flags; BOOST_CHECK(in_exp.good()); BOOST_CHECK(gap->GetFirstFrom() == first_from); BOOST_CHECK(gap->GetSecondFrom() == second_from); BOOST_CHECK(gap->GetLength() == len); BOOST_CHECK(gap->IsDirect() == (flags != 0)); } } } } void CheckSparseAln(CNcbiIstream& in_exp, const CSparseAln& sparse, bool check_sequence) { // Format: // <dim> <numrows> <anchor row> // <aln-from> <aln-to> // For each row: // <row> <width> <seq-id> // <aln-from> <aln_to> <seq-from> <seq-to> <native-from> <native-to> // [<aln-sequence>] // [<row-sequence>] static const char* kGap = "<GAP>"; static const char* kNoData = "<NO SEQUENCE DATA>"; TSignedSeqPos expected_aln_from, expected_aln_to; if ( DumpExpected() ) { cout << sparse.GetDim() << " " << sparse.GetNumRows() << " " << sparse.GetAnchor() << endl; cout << sparse.GetAlnRange().GetFrom() << " " << sparse.GetAlnRange().GetTo() << endl; } else { int expected_dim, expected_numrows, expected_anchor; in_exp >> expected_dim >> expected_numrows >> expected_anchor; in_exp >> expected_aln_from >> expected_aln_to; BOOST_CHECK(in_exp.good()); BOOST_CHECK(sparse.GetDim() == expected_dim); BOOST_CHECK(sparse.GetNumRows() == expected_numrows); BOOST_CHECK(sparse.GetAnchor() == expected_anchor); BOOST_CHECK(sparse.GetAlnRange().GetFrom() == expected_aln_from); BOOST_CHECK(sparse.GetAlnRange().GetTo() == expected_aln_to); } for (CSparseAln::TDim row = 0; row < sparse.GetDim(); ++row) { if ( DumpExpected() ) { cout << row << " " << sparse.GetBaseWidth(row) << " " << MSerial_AsnText << sparse.GetSeqId(row); } else { int expected_row, expected_width; CSeq_id expected_id; in_exp >> expected_row >> expected_width >> MSerial_AsnText >> expected_id; BOOST_CHECK(in_exp.good()); BOOST_CHECK(row == expected_row); BOOST_CHECK(sparse.GetBaseWidth(row) == expected_width); BOOST_CHECK(sparse.GetSeqId(row).Equals(expected_id)); } CSparseAln::TRange rg = sparse.GetSeqRange(row); CSparseAln::TRange native_rg = sparse.AlnRangeToNativeSeqRange(row, rg); TSeqPos expected_seq_from, expected_seq_to, expected_native_from, expected_native_to; if ( DumpExpected() ) { cout << sparse.GetSeqAlnStart(row) << " " << sparse.GetSeqAlnStop(row) << " " << rg.GetFrom() << " " << rg.GetTo() << " " << native_rg.GetFrom() << " " << native_rg.GetTo() << endl; } else { in_exp >> expected_aln_from >> expected_aln_to >> expected_seq_from >> expected_seq_to >> expected_native_from >> expected_native_to; BOOST_CHECK(in_exp.good()); BOOST_CHECK(sparse.GetSeqAlnStart(row) == expected_aln_from); BOOST_CHECK(sparse.GetSeqAlnStop(row) == expected_aln_to); BOOST_CHECK(rg.GetFrom() == expected_seq_from); BOOST_CHECK(rg.GetTo() == expected_seq_to); BOOST_CHECK(native_rg.GetFrom() == expected_native_from); BOOST_CHECK(native_rg.GetTo() == expected_native_to); } if ( check_sequence ) { string aln_sequence, row_sequence; sparse.GetAlnSeqString(row, aln_sequence, CSparseAln::TSignedRange::GetWhole()); sparse.GetSeqString(row, row_sequence, CSparseAln::TRange::GetWhole()); if ( aln_sequence.empty() ) { aln_sequence = kNoData; } if ( row_sequence.empty() ) { row_sequence = kNoData; } if ( DumpExpected() ) { cout << aln_sequence << endl; cout << row_sequence << endl; } else { string expected_aln_sequence, expected_row_sequence; in_exp >> ws; getline(in_exp, expected_aln_sequence); getline(in_exp, expected_row_sequence); BOOST_CHECK(in_exp.good()); BOOST_CHECK(aln_sequence == expected_aln_sequence); BOOST_CHECK(row_sequence == expected_row_sequence); } } CSparse_CI sparse_ci(sparse, row, CSparse_CI::eAllSegments); for (; sparse_ci; ++sparse_ci) { const IAlnSegment& seg = *sparse_ci; CSparse_CI::TSignedRange aln_rg = seg.GetAlnRange(); CSparse_CI::TSignedRange seq_rg = seg.GetRange(); if ( DumpExpected() ) { cout << " " << seg.GetType() << " " << aln_rg.GetFrom() << " " << aln_rg.GetTo() << " " << seq_rg.GetFrom() << " " << seq_rg.GetTo() << endl; } else { unsigned expected_seg_type; TSignedSeqPos expected_seq_from, expected_seq_to; in_exp >> expected_seg_type >> expected_aln_from >> expected_aln_to >> expected_seq_from >> expected_seq_to; BOOST_CHECK(in_exp.good()); BOOST_CHECK(seg.GetType() == expected_seg_type); BOOST_CHECK(aln_rg.GetFrom() == expected_aln_from); BOOST_CHECK(aln_rg.GetTo() == expected_aln_to); BOOST_CHECK(seq_rg.GetFrom() == expected_seq_from); BOOST_CHECK(seq_rg.GetTo() == expected_seq_to); } if ( check_sequence ) { string aln_sequence, row_sequence; string expected_aln_sequence, expected_row_sequence; if ( !aln_rg.Empty() ) { sparse.GetAlnSeqString(row, aln_sequence, aln_rg); if ( aln_sequence.empty() ) { aln_sequence = kNoData; } } else { aln_sequence = kGap; } if ( !seq_rg.Empty() ) { sparse.GetSeqString(row, row_sequence, IAlnExplorer::TRange(seq_rg.GetFrom(), seq_rg.GetTo())); if ( row_sequence.empty() ) { row_sequence = kNoData; } } else { row_sequence = kGap; } if ( DumpExpected() ) { cout << aln_sequence << endl; cout << row_sequence << endl; } else { in_exp >> ws; getline(in_exp, expected_aln_sequence); getline(in_exp, expected_row_sequence); BOOST_CHECK(in_exp.good()); BOOST_CHECK(aln_sequence == expected_aln_sequence); BOOST_CHECK(row_sequence == expected_row_sequence); } } } } } BOOST_AUTO_TEST_CASE(s_TestLoadAlign) { cout << "Test CAlnContainer and CAlnStats..." << endl; CNcbiIfstream in_data("data/aligns1.asn"); CNcbiIfstream in_exp("data/expected01.txt"); // File format: // <int-number-of-alignments> // For each seq-id: // <int-base-width> <Seq-id> CAlnContainer aligns; size_t num_aligns = LoadAligns(in_data, aligns); if ( DumpExpected() ) { cout << num_aligns << endl; } else { size_t expected_num_aligns; in_exp >> expected_num_aligns; BOOST_CHECK(num_aligns == expected_num_aligns); } auto_ptr<TScopeAlnIdMap> aln_id_map; CRef<TScopeAlnStats> aln_stats = InitAlnStats(aligns, aln_id_map); if ( !DumpExpected() ) { BOOST_CHECK(aln_stats->GetAlnCount() == num_aligns); BOOST_CHECK(aln_stats->CanBeAnchored()); } ITERATE(TScopeAlnStats::TIdVec, id_it, aln_stats->GetIdVec()) { if ( DumpExpected() ) { cout << (*id_it)->GetBaseWidth() << " "; cout << MSerial_AsnText << (*id_it)->GetSeqId(); } else { int width; CSeq_id id; in_exp >> width; in_exp >> MSerial_AsnText >> id; BOOST_CHECK(id.Equals((*id_it)->GetSeqId())); BOOST_CHECK((*id_it)->GetBaseWidth() == width); } } } BOOST_AUTO_TEST_CASE(s_TestPairwiseAln) { cout << "Test CPairwiseAln..." << endl; CNcbiIfstream in_data("data/aligns1.asn"); CNcbiIfstream in_exp("data/expected02.txt"); // File format: // <int-number-of-alignments> // see CheckPairwiseAln CAlnContainer aligns; size_t num_aligns = LoadAligns(in_data, aligns); if ( DumpExpected() ) { cout << num_aligns << endl; } else { size_t expected_num_aligns; in_exp >> expected_num_aligns; BOOST_CHECK(num_aligns == expected_num_aligns); } auto_ptr<TScopeAlnIdMap> aln_id_map; CRef<TScopeAlnStats> aln_stats = InitAlnStats(aligns, aln_id_map); const TScopeAlnStats::TAlnVec& aln_vec = aln_stats->GetAlnVec(); // For each source alignment create a set of pairwise alignments. for (size_t aln_idx = 0; aln_idx < aln_vec.size(); ++aln_idx) { const CSeq_align& aln = *aln_vec[aln_idx]; // Use row 0 as anchor, get pairwise alignments with all other rows. const TScopeAlnStats::TIdVec& aln_ids = aln_stats->GetSeqIdsForAln(aln_idx); // Test two different anchor values. for (int anchor = 0; anchor < 2; anchor++) { TAlnSeqIdIRef anchor_id = aln_ids[anchor]; for (int row = 0; row < aln_stats->GetDimForAln(aln_idx); ++row) { if (row == anchor) continue; TAlnSeqIdIRef row_id = aln_ids[row]; CPairwiseAln pw(anchor_id, row_id, CPairwiseAln::fDefaultPolicy); ConvertSeqAlignToPairwiseAln(pw, aln, anchor, row, CAlnUserOptions::eBothDirections, &aln_ids); CheckPairwiseAln(in_exp, pw, aln_idx, anchor, row); for (CPairwise_CI seg(pw); seg; ++seg) { if ( DumpExpected() ) { cout << " " << seg.GetFirstRange().GetFrom() << " " << seg.GetFirstRange().GetTo() << " " << seg.GetSecondRange().GetFrom() << " " << seg.GetSecondRange().GetTo() << " " << (seg.IsDirect() ? 1 : 0) << " " << (seg.IsFirstDirect() ? 1 : 0) << " " << (seg.GetSegType() == CPairwise_CI::eAligned ? 1 : 0) << endl; } else { int direct, first_direct, aligned; TSignedSeqPos first_from, first_to, second_from, second_to; in_exp >> first_from >> first_to >> second_from >> second_to >> direct >> first_direct >> aligned; BOOST_CHECK(in_exp.good()); BOOST_CHECK(seg.GetFirstRange().GetFrom() == first_from); BOOST_CHECK(seg.GetFirstRange().GetTo() == first_to); BOOST_CHECK(seg.GetSecondRange().GetFrom() == second_from); BOOST_CHECK(seg.GetSecondRange().GetTo() == second_to); BOOST_CHECK(seg.IsDirect() == (direct != 0)); BOOST_CHECK(seg.IsFirstDirect() == (first_direct != 0)); BOOST_CHECK((seg.GetSegType() == CPairwise_CI::eAligned) == (aligned != 0)); } } } } } } BOOST_AUTO_TEST_CASE(s_TestPairwiseAlnRanged) { cout << "Test ranged CPairwise_CI..." << endl; CNcbiIfstream in_data("data/aligns1.asn"); CNcbiIfstream in_exp("data/expected03.txt"); // File format: // <int-number-of-alignments> // // For each alignment/anchor/row: // <int-align-index> <int-anchor_index> <int-row-index> <int-pairwise-flags> // <int-align-first-from> <int-align-first-to> <int-base-width> <Seq-id> // <int-align-second-from> <int-align-second-to> <int-base-width> <Seq-id> // For each CPairwiseAln element: // <int-first-from> <int-second-from> <int-len> <int-is-direct> // <int-insertions-count> // For each insertion: // <int-first-from> <int-second-from> <int-len> <int-is-direct> // For each iterator: // <int-first-from> <int-first-to> <int-second-from> <int-second-to> ... // ... <int-direct> <int-first-direct> <int-aligned> CAlnContainer aligns; size_t num_aligns = LoadAligns(in_data, aligns); if ( DumpExpected() ) { cout << num_aligns << endl; } else { size_t expected_num_aligns; in_exp >> expected_num_aligns; BOOST_CHECK(num_aligns == expected_num_aligns); } auto_ptr<TScopeAlnIdMap> aln_id_map; CRef<TScopeAlnStats> aln_stats = InitAlnStats(aligns, aln_id_map); const TScopeAlnStats::TAlnVec& aln_vec = aln_stats->GetAlnVec(); // For each source alignment create a set of pairwise alignments. for (size_t aln_idx = 0; aln_idx < aln_vec.size(); ++aln_idx) { const CSeq_align& aln = *aln_vec[aln_idx]; // Use row 0 as anchor, get pairwise alignments with all other rows. const TScopeAlnStats::TIdVec& aln_ids = aln_stats->GetSeqIdsForAln(aln_idx); // Test two different anchor values. for (int anchor = 0; anchor < 2; anchor++) { TAlnSeqIdIRef anchor_id = aln_ids[anchor]; for (int row = 0; row < aln_stats->GetDimForAln(aln_idx); ++row) { if (row == anchor) continue; TAlnSeqIdIRef row_id = aln_ids[row]; CPairwiseAln pw(anchor_id, row_id, CPairwiseAln::fDefaultPolicy); ConvertSeqAlignToPairwiseAln(pw, aln, anchor, row, CAlnUserOptions::eBothDirections, &aln_ids); TSignedSeqPos first_from, first_to, second_from, second_to; if ( DumpExpected() ) { cout << aln_idx << " " << anchor << " " << row << " " << pw.GetFlags() << endl; cout << " " << pw.GetFirstFrom() << " " << pw.GetFirstTo() << " " << pw.GetFirstBaseWidth() << " " << MSerial_AsnText << pw.GetFirstId()->GetSeqId(); cout << " " << pw.GetSecondPosByFirstPos(pw.GetFirstFrom()) << " " << pw.GetSecondPosByFirstPos(pw.GetFirstTo()) << " " << pw.GetSecondBaseWidth() << " " << MSerial_AsnText << pw.GetSecondId()->GetSeqId(); } else { size_t expected_aln_idx; int expected_row, expected_anchor; int first_width, second_width, flags; CSeq_id first_id, second_id; in_exp >> expected_aln_idx >> expected_anchor >> expected_row >> flags; in_exp >> first_from >> first_to >> first_width; in_exp >> MSerial_AsnText >> first_id; in_exp >> second_from >> second_to >> second_width; in_exp >> MSerial_AsnText >> second_id; BOOST_CHECK(in_exp.good()); BOOST_CHECK(aln_idx == expected_aln_idx); BOOST_CHECK(anchor == expected_anchor); BOOST_CHECK(row == expected_row); BOOST_CHECK(pw.GetFlags() == flags); BOOST_CHECK(pw.GetFirstId()->GetSeqId().Equals(first_id)); BOOST_CHECK(pw.GetSecondId()->GetSeqId().Equals(second_id)); BOOST_CHECK(pw.GetFirstBaseWidth() == first_width); BOOST_CHECK(pw.GetSecondBaseWidth() == second_width); BOOST_CHECK(pw.GetFirstFrom() == first_from); BOOST_CHECK(pw.GetFirstTo() == first_to); BOOST_CHECK(pw.GetSecondPosByFirstPos(pw.GetFirstFrom()) == second_from); BOOST_CHECK(pw.GetSecondPosByFirstPos(pw.GetFirstTo()) == second_to); } if (pw.size() < 2) continue; first_from = pw[1].GetFirstFrom() + 1; first_to = pw[pw.size() - 1].GetFirstFrom() - 2; CPairwise_CI::TSignedRange rg(first_from, first_to); for (CPairwise_CI seg(pw, rg); seg; ++seg) { if ( DumpExpected() ) { cout << " " << seg.GetFirstRange().GetFrom() << " " << seg.GetFirstRange().GetTo() << " " << seg.GetSecondRange().GetFrom() << " " << seg.GetSecondRange().GetTo() << " " << (seg.IsDirect() ? 1 : 0) << " " << (seg.IsFirstDirect() ? 1 : 0) << " " << (seg.GetSegType() == CPairwise_CI::eAligned ? 1 : 0) << endl; } else { int direct, first_direct, aligned; in_exp >> first_from >> first_to >> second_from >> second_to >> direct >> first_direct >> aligned; BOOST_CHECK(in_exp.good()); BOOST_CHECK(seg.GetFirstRange().GetFrom() == first_from); BOOST_CHECK(seg.GetFirstRange().GetTo() == first_to); BOOST_CHECK(seg.GetSecondRange().GetFrom() == second_from); BOOST_CHECK(seg.GetSecondRange().GetTo() == second_to); BOOST_CHECK(seg.IsDirect() == (direct != 0)); BOOST_CHECK(seg.IsFirstDirect() == (first_direct != 0)); BOOST_CHECK((seg.GetSegType() == CPairwise_CI::eAligned) == (aligned != 0)); } } } } } } BOOST_AUTO_TEST_CASE(s_TestAnchoredAln) { cout << "Test CAnchoredAln..." << endl; CNcbiIfstream in_data("data/aligns1.asn"); CNcbiIfstream in_exp("data/expected04.txt"); CAlnContainer aligns; size_t num_aligns = LoadAligns(in_data, aligns); if ( DumpExpected() ) { cout << num_aligns << endl; } else { size_t expected_num_aligns; in_exp >> expected_num_aligns; BOOST_CHECK(num_aligns == expected_num_aligns); } auto_ptr<TScopeAlnIdMap> aln_id_map; CRef<TScopeAlnStats> aln_stats = InitAlnStats(aligns, aln_id_map); for (size_t aln_idx = 0; aln_idx < aligns.size(); ++aln_idx) { for (int anchor = 0; anchor < aln_stats->GetDimForAln(aln_idx); ++anchor) { CAlnUserOptions user_options; CRef<CAnchoredAln> anchored_aln = CreateAnchoredAlnFromAln(*aln_stats, aln_idx, user_options, anchor); for (int row = 0; row < (int)anchored_aln->GetPairwiseAlns().size(); ++row) { CheckPairwiseAln(in_exp, *anchored_aln->GetPairwiseAlns()[row], aln_idx, anchored_aln->GetAnchorRow(), row); } } } } BOOST_AUTO_TEST_CASE(s_TestAnchoredAlnBuilt) { static const int kMergeFlags[] = { 0, CAlnUserOptions::fTruncateOverlaps, CAlnUserOptions::fAllowTranslocation, CAlnUserOptions::fUseAnchorAsAlnSeq, CAlnUserOptions::fAnchorRowFirst, CAlnUserOptions::fIgnoreInsertions }; cout << "Test built CAnchoredAln..." << endl; CNcbiIfstream in_data("data/aligns2.asn"); CNcbiIfstream in_exp("data/expected05.txt"); while (!in_data.eof() && in_data.good()) { size_t num_to_merge; in_data >> num_to_merge; if (num_to_merge == 0 || !in_data.good()) break; CAlnContainer aligns; size_t num_aligns = LoadAligns(in_data, aligns, num_to_merge); if ( DumpExpected() ) { cout << num_aligns << endl; } else { size_t expected_num_aligns; in_exp >> expected_num_aligns; BOOST_CHECK(num_aligns == expected_num_aligns); } auto_ptr<TScopeAlnIdMap> aln_id_map; CRef<TScopeAlnStats> aln_stats = InitAlnStats(aligns, aln_id_map); const TScopeAlnStats::TIdVec& aln_ids = aln_stats->GetAnchorIdVec(); for (size_t anchor_idx = 0; anchor_idx < aln_ids.size(); anchor_idx++) { TAlnSeqIdIRef anchor_id = aln_ids[anchor_idx]; CAlnUserOptions user_options; user_options.SetAnchorId(anchor_id); for (size_t flags_idx = 0; flags_idx < sizeof(kMergeFlags)/sizeof(kMergeFlags[0]); flags_idx++) { user_options.m_MergeFlags = kMergeFlags[flags_idx]; if ( DumpExpected() ) { cout << anchor_idx << " " << user_options.m_MergeFlags << endl; } else { size_t expected_anchor_idx; int expected_flags; in_exp >> expected_anchor_idx >> expected_flags; BOOST_CHECK(in_exp.good()); BOOST_CHECK(anchor_idx == expected_anchor_idx); BOOST_CHECK(user_options.m_MergeFlags == expected_flags); } TAnchoredAlnVec anchored_aln_vec; CreateAnchoredAlnVec(*aln_stats, anchored_aln_vec, user_options); CRef<CSeq_id> id(new CSeq_id); id->SetLocal().SetStr("pseudo-id"); TAlnSeqIdIRef pseudo_id(Ref(new CAlnSeqId(*id))); CAnchoredAln built_aln; BuildAln(anchored_aln_vec, built_aln, user_options, pseudo_id); for (int row = 0; row < (int)built_aln.GetPairwiseAlns().size(); ++row) { CheckPairwiseAln(in_exp, *built_aln.GetPairwiseAlns()[row], 0, built_aln.GetAnchorRow(), row); } } } } } BOOST_AUTO_TEST_CASE(s_TestSparseAlnCoords) { cout << "Test CSparseAln coordinates..." << endl; CNcbiIfstream in_data("data/aligns2.asn"); CNcbiIfstream in_exp("data/expected06.txt"); while (!in_data.eof() && in_data.good()) { size_t num_to_merge; in_data >> num_to_merge; if (num_to_merge == 0 || !in_data.good()) break; CAlnContainer aligns; size_t num_aligns = LoadAligns(in_data, aligns, num_to_merge); if ( DumpExpected() ) { cout << num_aligns << endl; } else { size_t expected_num_aligns; in_exp >> expected_num_aligns; BOOST_CHECK(num_aligns == expected_num_aligns); } auto_ptr<TScopeAlnIdMap> aln_id_map; CRef<TScopeAlnStats> aln_stats = InitAlnStats(aligns, aln_id_map); const TScopeAlnStats::TIdVec& aln_ids = aln_stats->GetAnchorIdVec(); for (size_t anchor_idx = 0; anchor_idx < aln_ids.size(); anchor_idx++) { TAlnSeqIdIRef anchor_id = aln_ids[anchor_idx]; CAlnUserOptions user_options; user_options.SetAnchorId(anchor_id); user_options.m_MergeFlags = CAlnUserOptions::fTruncateOverlaps; if ( DumpExpected() ) { cout << anchor_idx << " " << MSerial_AsnText << anchor_id->GetSeqId(); } else { size_t expected_anchor_idx; in_exp >> expected_anchor_idx; CSeq_id expected_anchor_id; in_exp >> MSerial_AsnText >> expected_anchor_id; BOOST_CHECK(in_exp.good()); BOOST_CHECK(anchor_idx == expected_anchor_idx); BOOST_CHECK(anchor_id->GetSeqId().Equals(expected_anchor_id)); } TAnchoredAlnVec anchored_aln_vec; CreateAnchoredAlnVec(*aln_stats, anchored_aln_vec, user_options); CRef<CSeq_id> id(new CSeq_id); id->SetLocal().SetStr("pseudo-id"); TAlnSeqIdIRef pseudo_id(Ref(new CAlnSeqId(*id))); CAnchoredAln built_aln; BuildAln(anchored_aln_vec, built_aln, user_options, pseudo_id); CSparseAln sparse_aln(built_aln, GetScope()); CheckSparseAln(in_exp, sparse_aln, false); } } } BOOST_AUTO_TEST_CASE(s_TestSparseAlnData) { cout << "Test CSparseAln sequence..." << endl; CNcbiIfstream in_data("data/aligns3.asn"); CNcbiIfstream in_exp("data/expected07.txt"); while (!in_data.eof() && in_data.good()) { size_t num_to_merge; in_data >> num_to_merge; if (num_to_merge == 0 || !in_data.good()) break; CAlnContainer aligns; size_t num_aligns = LoadAligns(in_data, aligns, num_to_merge); if ( DumpExpected() ) { cout << num_aligns << endl; } else { size_t expected_num_aligns; in_exp >> expected_num_aligns; BOOST_CHECK(num_aligns == expected_num_aligns); } auto_ptr<TScopeAlnIdMap> aln_id_map; CRef<TScopeAlnStats> aln_stats = InitAlnStats(aligns, aln_id_map); const TScopeAlnStats::TIdVec& aln_ids = aln_stats->GetAnchorIdVec(); for (size_t anchor_idx = 0; anchor_idx < aln_ids.size(); anchor_idx++) { TAlnSeqIdIRef anchor_id = aln_ids[anchor_idx]; CAlnUserOptions user_options; user_options.SetAnchorId(anchor_id); user_options.m_MergeFlags = CAlnUserOptions::fTruncateOverlaps; if ( DumpExpected() ) { cout << anchor_idx << " " << MSerial_AsnText << anchor_id->GetSeqId(); } else { size_t expected_anchor_idx; in_exp >> expected_anchor_idx; CSeq_id expected_anchor_id; in_exp >> MSerial_AsnText >> expected_anchor_id; BOOST_CHECK(in_exp.good()); BOOST_CHECK(anchor_idx == expected_anchor_idx); BOOST_CHECK(anchor_id->GetSeqId().Equals(expected_anchor_id)); } TAnchoredAlnVec anchored_aln_vec; CreateAnchoredAlnVec(*aln_stats, anchored_aln_vec, user_options); CRef<CSeq_id> id(new CSeq_id); id->SetLocal().SetStr("pseudo-id"); TAlnSeqIdIRef pseudo_id(Ref(new CAlnSeqId(*id))); CAnchoredAln built_aln; BuildAln(anchored_aln_vec, built_aln, user_options, pseudo_id); CSparseAln sparse_aln(built_aln, GetScope()); CheckSparseAln(in_exp, sparse_aln, true); CRef<CSeq_align> aln = CreateSeqAlignFromAnchoredAln(built_aln, CSeq_align::TSegs::e_Denseg, &GetScope()); BOOST_CHECK(aln); if ( DumpExpected() ) { cout << MSerial_AsnText << *aln; } else { CSeq_align expected_aln; in_exp >> MSerial_AsnText >> expected_aln; BOOST_CHECK(aln->Equals(expected_aln)); } } } } BOOST_AUTO_TEST_CASE(s_TestAlnTypes) { cout << "Test seq-align types..." << endl; CNcbiIfstream in_data("data/aligns4.asn"); CNcbiIfstream in_exp("data/expected08.txt"); CAlnContainer aligns; size_t num_aligns = LoadAligns(in_data, aligns); if ( DumpExpected() ) { cout << num_aligns << endl; } else { size_t expected_num_aligns; in_exp >> expected_num_aligns; BOOST_CHECK(num_aligns == expected_num_aligns); } auto_ptr<TScopeAlnIdMap> aln_id_map; CRef<TScopeAlnStats> aln_stats = InitAlnStats(aligns, aln_id_map); for (size_t aln_idx = 0; aln_idx < aligns.size(); ++aln_idx) { for (int anchor = 0; anchor < aln_stats->GetDimForAln(aln_idx); ++anchor) { // Special case - sparse-segs can be anchored only to the first row. if (aln_stats->GetAlnVec()[aln_idx]->GetSegs().IsSparse() && anchor > 0) { break; } CAlnUserOptions user_options; CRef<CAnchoredAln> anchored_aln = CreateAnchoredAlnFromAln(*aln_stats, aln_idx, user_options, anchor); for (int row = 0; row < (int)anchored_aln->GetPairwiseAlns().size(); ++row) { CheckPairwiseAln(in_exp, *anchored_aln->GetPairwiseAlns()[row], aln_idx, anchored_aln->GetAnchorRow(), row); } } } }
[ "jackgopack4@gmail.com" ]
jackgopack4@gmail.com
64bbd45ef69db9dc6a7443dafac5f72c43dc720f
8f567a4a63a631131ce3bc92a761074b9307520d
/div2C/scrap.cpp
0d32b6df2fcb9451930bd8200e162f8206cdaa34
[]
no_license
Schrodinger1926/A2OJ
bf2c8ab365f16e78649b5aa8f00d910b51726ff9
e0e6858c0172f8caca079f4aa75edebff742335e
refs/heads/master
2020-12-25T14:38:28.310091
2016-10-05T23:04:51
2016-10-05T23:04:51
65,757,829
0
0
null
null
null
null
UTF-8
C++
false
false
958
cpp
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <iomanip> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> using namespace std; // My templates struct reverse { bool operator()(const int &left, const int &right){ return (right < left); } }; struct custom { bool operator()(const pair<int,int> &left, const pair<int,int> &right){ return (left.first > right.first); } }; void solve(){ queue<int> myqueue; for (int i = 0; i < 10; ++i) { myqueue.push(i); } for (int i = 0; i < 10; ++i) { cout << myqueue.front() << ' '; myqueue.pop(); } cout << endl; } int main(int argc, char const *argv[]){ // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); solve(); return 0; }
[ "sidharth.sindhra@gmail.com" ]
sidharth.sindhra@gmail.com
314d648fea7983e71028dbbb5123db1884e50cbe
c2484df95f009d516bf042dca93857b43a292333
/codeforces/round355/a/main.cpp
15553c8acd8c07c5838ac95da374ffc918c7f149
[ "Apache-2.0" ]
permissive
seirion/code
545a78c1167ca92776070d61cd86c1c536cd109a
a59df98712c7eeceabc98f6535f7814d3a1c2c9f
refs/heads/master
2022-12-09T19:48:50.444088
2022-12-06T05:25:38
2022-12-06T05:25:38
17,619,607
14
4
null
null
null
null
UTF-8
C++
false
false
286
cpp
// http://codeforces.com/contest/677/problem/A // A. Vanya and Fence #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int r = n; while (n--) { int x; cin >> x; if (k < x) r++; } cout << r << endl; return 0; }
[ "neo.jang@hpcnt.com" ]
neo.jang@hpcnt.com
4cbfd5eac46234d40c8137d834507a816014a5f9
8312c4d936270b3319ebc374e58ed6b918414a88
/Goblin.h
4b6bb89b3e580181f5c225af0c68133999dea68b
[]
no_license
TumbleJamie/CardGame
1bd421fc2bf601d0018d9deb31a3d565b3109a0a
49d1d00faf787a45c064227db0436700e4d0d20c
refs/heads/master
2021-01-03T21:45:19.067939
2020-02-13T11:54:54
2020-02-13T11:54:54
240,248,445
0
0
null
null
null
null
UTF-8
C++
false
false
319
h
#pragma once #include "Card.h" class Goblin : public Card { public: int GetType(); string GetName(); int GetHealth(); int GetAttack(); void SetHealth(int enemyAttack); Goblin(); private: int type = 1; int health = 1; int attack = 2; string name = "Goblin"; };
[ "noreply@github.com" ]
TumbleJamie.noreply@github.com
35713578ec1e06fb08f996e813c1d5a99b3d87a3
92e979498ec13e4ef1f9ff140e12865b5082c1dd
/SDK/BP_ActionSpectatorCam_parameters.h
479cd43c8ffdd71931863f1bc4b081d44152166c
[]
no_license
ALEHACKsp/BlazingSails-SDK
ac1d98ff67983b9d8e9c527815f17233d045d44d
900cbb934dc85f7325f1fc8845b90def2298dc2d
refs/heads/master
2022-04-08T21:55:32.767942
2020-03-11T11:37:42
2020-03-11T11:37:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,005
h
#pragma once #include "../SDK.h" // Name: BlazingSails, Version: 1.481.81 #ifdef _MSC_VER #pragma pack(push, 0x8) #endif namespace SDK { //--------------------------------------------------------------------------- // Parameters //--------------------------------------------------------------------------- // Function BP_ActionSpectatorCam.BP_ActionSpectatorCam_C.UserConstructionScript struct ABP_ActionSpectatorCam_C_UserConstructionScript_Params { }; // Function BP_ActionSpectatorCam.BP_ActionSpectatorCam_C.StartAction struct ABP_ActionSpectatorCam_C_StartAction_Params { }; // Function BP_ActionSpectatorCam.BP_ActionSpectatorCam_C.ExecuteUbergraph_BP_ActionSpectatorCam struct ABP_ActionSpectatorCam_C_ExecuteUbergraph_BP_ActionSpectatorCam_Params { int EntryPoint; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "zp2kshield@gmail.com" ]
zp2kshield@gmail.com
c4705d1a2b154b92ca01f8b41615f12120cbc7de
032013d17b506b2eb732a535b9e42df148d9a75d
/src/plugins/azoth/interfaces/azoth/imessage.h
ad2cb6cc82af5b5731cfd1ce8554fcef2c85ba21
[ "BSL-1.0" ]
permissive
zhao07/leechcraft
55bb64d6eab590a69d92585150ae1af3d32ee342
4100c5bf3a260b8bc041c14902e2f7b74da638a3
refs/heads/master
2021-01-22T11:59:18.782462
2014-04-01T14:04:10
2014-04-01T14:04:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,104
h
/********************************************************************** * LeechCraft - modular cross-platform feature rich internet client. * Copyright (C) 2006-2014 Georg Rudoy * * Boost Software License - Version 1.0 - August 17th, 2003 * * Permission is hereby granted, free of charge, to any person or organization * obtaining a copy of the software and accompanying documentation covered by * this license (the "Software") to use, reproduce, display, distribute, * execute, and transmit the Software, and to prepare derivative works of the * Software, and to permit third-parties to whom the Software is furnished to * do so, all subject to the following: * * The copyright notices in the Software and this entire statement, including * the above license grant, this restriction and the following disclaimer, * must be included in all copies of the Software, in whole or in part, and * all derivative works of the Software, unless such copies or derivative * works are solely in the form of machine-executable object code generated by * a source language processor. * * 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **********************************************************************/ #pragma once #include <QString> #include <QDateTime> #include <QtPlugin> #include "messagebase.h" class QObject; namespace LeechCraft { namespace Azoth { class ICLEntry; /** @brief This interface is used to represent a message. * * Refer to the MessageType enum for the list of possible message * types that are covered by this interface. * * The message should not be sent upon creation, only call to Send() * should trigger the sending. * * This interface provides only more or less basic functionality. * Advanced features like delivery receipts and such, are in * IAdvancedMessage. * * Messages implementing this interface are expected to contain only * plain text bodies. If a message may also contain rich text, it * should implement the IRichTextMessage interface. * * @sa IAdvancedMessage, IRichTextMessage. */ class IMessage : public MessageBase { public: virtual ~IMessage () {}; /** @brief Represents the direction of the message. */ enum Direction { /** @brief The message is from the remote party to us. */ DIn, /** @brief The message is from us to the remote party. */ DOut }; /** @brief Represents possible message types. */ enum MessageType { /** @brief Standard one-to-one message. */ MTChatMessage, /** @brief Message in a multiuser conference. * * This kind of message is only for messages that originate * from participants and are human-generated. Thus, status * changes, topic changes and such should have a different * type. */ MTMUCMessage, /** @brief Status changes in a chat. * * This type of message contains information about * participant's status/presence changes. */ MTStatusMessage, /** @brief Various events in a chat. * * Messages of this type are for notifying about, for * example, topic changes, kicks, bans, etc. Generally, * there is no other part in such messages, so the message * of this type can return NULL from OtherPart(). */ MTEventMessage, /** @brief Other. */ MTServiceMessage }; /** @brief This enum is used for more precise classification of * chat types messages. * * The messages of some particular types may have additional * required properties used by the Azoth Core and other plugins * to establish proper context for the events. */ enum MessageSubType { /** This message is of subtype that doesn't correspond to * any other subtype of message. */ MSTOther, /** This message notifies about someone being just kicked. */ MSTKickNotification, /** This message notifies about someone being just banned. */ MSTBanNotification, /** @brief Represents status change of a participant in a * chat or MUC room. * * The corresponding MessageType is MTStatusMessage. * * Messages of this type should have the following dynamic * properties: * - Azoth/Nick, with a QString representing nick of the * participant that has changed its status. * - Azoth/TargetState, with a QString representing the * target state. The string is better obtained from the * State enum by the means of IProxyObject::StateToString * method. * - Azoth/StatusText, with a QString representing the new * status text of the participant. May be empty. */ MSTParticipantStatusChange, /** @brief Represents permission changes of a participant in * a chat or MUC room. */ MSTParticipantRoleAffiliationChange, /** @brief Notifies about participant joining to a MUC room. */ MSTParticipantJoin, /** @brief Notifies about participant leaving a MUC room. */ MSTParticipantLeave, /** @brief Notifies about participant in a MUC changing the * nick. */ MSTParticipantNickChange, /** @brief The participant has ended the conversation. */ MSTParticipantEndedConversation, /** @brief Notifies about changing subject in a MUC room. */ MSTRoomSubjectChange }; /** @brief Returns this message as a QObject. */ virtual QObject* GetQObject () = 0; /** @brief Sends the message. * * A message should never be sent except as the result of this * method. * * Please note that if the other part is a MUC, it should send * back this message with the "IN" direction set. */ virtual void Send () = 0; /** @brief Stores the message. * * After calling this function this message should be present in * the messages list returned by ICLEntry::GetAllMessages(), but * the message shouldn't be sent. * * @sa ICLEntry::GetAllMessages() */ virtual void Store () = 0; /** @brief Returns the direction of this message. * * @return The direction of this message. */ virtual Direction GetDirection () const = 0; /** @brief Returns the type of this message. * * @return The type of this message. */ virtual MessageType GetMessageType () const = 0; /** @brief Returns the subtype of this message. * * The subtype is used for more precise classification of * messages. * * @return The subtype of this message */ virtual MessageSubType GetMessageSubType () const = 0; /** @brief Returns the CL entry from which this message is. * * For normal, single user chats, this should always be equal to * the ICLEntry that was (and will be) used to send the message * back. * * For multiuser chats this should be equal to the contact list * representation of the participant that sent the message. * * The returned object must implement ICLEntry. * * @return The CL entry from which this message originates, * implementing ICLEntry. */ virtual QObject* OtherPart () const = 0; /** @brief Returns the parent CL entry of this message. * * This is the same that OtherPart() for single user chats. For * multiuser chats it should be the contact list entry * representing the MUC room. * * By default this function calls OtherPart() and returns its * result. * * The returned object must implement ICLEntry. * * @return The parent CL entry of this message, implementing * ICLEntry. */ virtual QObject* ParentCLEntry () const { return OtherPart (); } /** @brief The variant of the other part. * * If not applicable, a null string should be returned. * * @return The variant of the other part. */ virtual QString GetOtherVariant () const = 0; /** @brief Returns the body of the message. * * The body is expected to be a plain text string. All '<' and * '&' will be escaped. * * @return The body of the message. */ virtual QString GetBody () const = 0; /** @brief Updates the body of the message. * * The passed string is the plain text contents of the message. * * @param[in] body The new body of the message. */ virtual void SetBody (const QString& body) = 0; /** @brief Returns the timestamp of the message. * * @return The timestamp of the message. */ virtual QDateTime GetDateTime () const = 0; /** @brief Updates the timestamp of the message. * * @param[in] timestamp The new timestamp of the message. */ virtual void SetDateTime (const QDateTime& timestamp) = 0; }; } } Q_DECLARE_INTERFACE (LeechCraft::Azoth::IMessage, "org.Deviant.LeechCraft.Azoth.IMessage/1.0");
[ "0xd34df00d@gmail.com" ]
0xd34df00d@gmail.com
e6198beac1330fdffcd618d9231304b9c865ecc2
cd9256bdf7834c7723c7c36ad0cc87ff0ffbd4ad
/15666.cpp
2cc48b00b4ec5c7e9c203e8844dfc370a6580579
[]
no_license
surinoel/boj
23060000aeaaf789f0525d716d5ef048661d7b6c
2b3a007cf4efaafc196cdd7c745a375b3f88e7e7
refs/heads/master
2020-05-02T09:02:07.434285
2020-02-20T01:10:00
2020-02-20T01:10:00
177,858,962
0
1
null
null
null
null
UTF-8
C++
false
false
811
cpp
#include <vector> #include <iostream> #include <algorithm> using namespace std; int n, m; bool visit[9]; vector<int> num; vector<vector<int>> ans; void go(int idx, int maxcnt, vector<int> v) { if (maxcnt == m) { ans.push_back(v); return; } for (int i = idx; i < n; i++) { v.push_back(num[i]); go(i, maxcnt + 1, v); v.pop_back(); } return; } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; num.resize(n); for (int i = 0; i < n; i++) { cin >> num[i]; } sort(num.begin(), num.end()); go(0, 0, vector<int>()); sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); for (int i = 0; i < ans.size(); i++) { for (int j = 0; j < ans[i].size(); j++) { cout << ans[i][j] << ' '; } cout << '\n'; } return 0; }
[ "noreply@github.com" ]
surinoel.noreply@github.com
34eed5ef3cebe590abe2028e74f1315cf2bbc32f
3bcc2188ac43900cccbc0a164b23e1e7b8e16ba8
/linked list/linked list of strings forms a palindrome.cpp
a5f021c17690dd92c1ac38e5e94597c508134463
[]
no_license
NehalTiwari/coding-practice
869c05993a738da7b6a3e105d5f13c2b3ce2596d
1c776a3e50ff68480bdd613894e44f9884be7fe3
refs/heads/master
2023-01-05T22:17:20.672197
2020-11-09T01:26:11
2020-11-09T01:26:11
276,035,521
0
0
null
null
null
null
UTF-8
C++
false
false
564
cpp
//driver code ends here. /* The structure of linked list is the following struct Node { string data; Node* next; Node(int x){ data = x; next = NULL; } }; */ bool isPalindromeUtil(string s) { int length = s.length(); for (int i=0; i<length/2; i++) if (s[i] != s[length-i-1]) return false; return true; } bool compute(Node* root) { /*OM NAMAH SHIVAY!*/ string s=""; while(root!=NULL){ s.append(root->next); root=root->next; } return isPalindromeUtil(s); }
[ "noreply@github.com" ]
NehalTiwari.noreply@github.com
c7b6451e68e0c2c0e543afb63f1c1adc3bf85aa8
48d4370ef110fb9df39d5700ba0892e79f549adf
/stack.cpp
7d01922db45457bf8c723161673b6b75ed57d639
[]
no_license
tskrzypiec/stack_bubble_sort
cc4d31910d61d685ce6f181dc48de70aae6a6e65
60d3bf5402cbe08b7a14c32a7a2ee874baec516b
refs/heads/master
2021-05-07T21:41:18.088108
2017-12-14T21:09:25
2017-12-14T21:09:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,440
cpp
// Stos //Tomasz Skrzypiec #include <iostream> using namespace std; struct Stack { Stack(int size) { items = new int[size](); maxsize = size; //maksymalna wilkość tablicy top = 0; //wierzchołek stosu } ~Stack() { delete[] items; } int push(int x) //wrzucam liczbę na stos { int result = 0; if (top == maxsize) { cout << "overflow error" << endl; //stos przeładowany result = 1; } else { items[top] = x; top = top + 1; } return result; } int pop() //zdejmuję liczbę ze stosu { int result = 0; if (top == 0) { cout << "underflow error" << endl; //za dużo chcesz zabrać ze stosu result = 1; } else { top = top - 1; cout << "popped: " << items[top] << endl; items[top] = 0; // czyścimy tablice } return result; } int maxsize; int top; // zapamiętuje liczbę przedmiotów wrzuconych na stos do tej pory int *items; }; void printStackItems(Stack *stk) { for (int i = 0; i < stk->maxsize; ++i) { cout << stk->items[i] << " "; } cout << endl; } int main() { const int myStackSize = 3; Stack mystack(myStackSize); cout << "Testing myStack:" << endl; cout << "- size " << mystack.maxsize << endl; cout << "- push 1, 2, 3" << endl; printStackItems(&mystack); mystack.push(1); printStackItems(&mystack); mystack.push(2); printStackItems(&mystack); mystack.push(3); printStackItems(&mystack); cout << "- pop 2 times:" << endl; printStackItems(&mystack); mystack.pop(); printStackItems(&mystack); mystack.pop(); printStackItems(&mystack); cout << "- make overflow, push 4, 5, 6" << endl; printStackItems(&mystack); mystack.push(4); printStackItems(&mystack); mystack.push(5); printStackItems(&mystack); mystack.push(6); printStackItems(&mystack); cout << "- make underflow, pop 4 times:" << endl; printStackItems(&mystack); mystack.pop(); printStackItems(&mystack); mystack.pop(); printStackItems(&mystack); mystack.pop(); printStackItems(&mystack); mystack.pop(); printStackItems(&mystack); return 0; }
[ "noreply@github.com" ]
tskrzypiec.noreply@github.com
cbf99fac0e11fd7f0d2e6f82c192bc570fe0f96d
0e85fb2a771dafb5f52581de74a203f4c17ddd65
/S38_permutation.cpp
9e150e274e16d0c1c314385f9728b51f80be60d5
[]
no_license
ljtg24/Offer68
c0fe1097c8180d8ef284013f84613c341faec4b4
bba5752e124be3c19671a3c94e02c127f525fd4d
refs/heads/master
2020-06-29T00:09:58.906798
2019-09-02T02:19:50
2019-09-02T02:19:50
200,380,645
0
0
null
null
null
null
UTF-8
C++
false
false
777
cpp
#include <iostream> #include <cstdio> using std::cout; using std::endl; void permutationCore(char* pStr, char* pBegin) { if (*pBegin == '\0') { // cout << (*pStr) << endl; printf("%s\n", pStr); } else { for (char* pCh = pBegin; *pCh != '\0'; pCh++) { char temp = *pCh; *pCh = *pBegin; *pBegin = temp; permutationCore(pStr, pBegin+1); temp = *pCh; *pCh = *pBegin; *pBegin = temp; // 换回来,pCh+1与pBegin继续换 } } } void permutation(char* pStr) { if (pStr == nullptr) return; permutationCore(pStr, pStr); } int main() { char a[] = "abc"; char* pStr = a; permutation(pStr); return 0; }
[ "ljtg24@stu.xjtu.edu.cn" ]
ljtg24@stu.xjtu.edu.cn
0346f09562d4b455ea97dd4f356b9a870c4e4870
f0dbd5810669adc01bf40dbbfa16ef410dd6f67f
/exp-17.cpp
21b23a06b0c9c69e7c0c180a79995f1599911581
[]
no_license
ZuLove/CPP-Concurrency
e7a6d673e8af1384301f8bb996dbe6db8115d474
803266b3b13ed36d7e0df1bca92079ade329ebad
refs/heads/master
2021-05-28T20:44:05.063903
2015-06-16T09:56:28
2015-06-16T09:56:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
320
cpp
#include <iostream> #include <thread> void thread_function() { for(int i = -100; i < 0; i++) std::cout << "thread function: " << i << "\n"; } int main() { std::thread t(&thread_function); for(int i = 0; i < 100; i++) std::cout << "main thread: " << i << "\n"; t.join(); return 0; }
[ "249056903@qq.com" ]
249056903@qq.com
769f650ece0473e835b4ea7f1dd7d5cd2e518514
90047daeb462598a924d76ddf4288e832e86417c
/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
39c227ff44a1d8405d0f6116212b79433febf587
[ "BSD-3-Clause" ]
permissive
massbrowser/android
99b8c21fa4552a13c06bbedd0f9c88dd4a4ad080
a9c4371682c9443d6e1d66005d4db61a24a9617c
refs/heads/master
2022-11-04T21:15:50.656802
2017-06-08T12:31:39
2017-06-08T12:31:39
93,747,579
2
2
BSD-3-Clause
2022-10-31T10:34:25
2017-06-08T12:36:07
null
UTF-8
C++
false
false
40,675
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" #include <stddef.h> #include <algorithm> #include <memory> #include <string> #include <utility> #include <vector> #include "base/base64.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/files/file.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/sequenced_task_runner_helpers.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browsing_data/browsing_data_helper.h" #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/download/download_prefs.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/net/chrome_network_delegate.h" #include "chrome/browser/net/net_export_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/channel_info.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/url_constants.h" #include "chrome/grit/net_internals_resources.h" #include "components/net_log/chrome_net_log.h" #include "components/onc/onc_constants.h" #include "components/prefs/pref_member.h" #include "components/url_formatter/url_fixer.h" #include "components/version_info/version_info.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/browsing_data_remover.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_message_handler.h" #include "net/base/net_errors.h" #include "net/disk_cache/disk_cache.h" #include "net/dns/host_cache.h" #include "net/dns/host_resolver.h" #include "net/http/http_cache.h" #include "net/http/http_network_layer.h" #include "net/http/http_network_session.h" #include "net/http/http_server_properties.h" #include "net/http/http_stream_factory.h" #include "net/http/transport_security_state.h" #include "net/log/net_log.h" #include "net/log/net_log_capture_mode.h" #include "net/log/net_log_entry.h" #include "net/log/net_log_util.h" #include "net/log/write_to_file_net_log_observer.h" #include "net/proxy/proxy_service.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/system_logs/debug_log_writer.h" #include "chrome/browser/net/nss_context.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/debug_daemon_client.h" #include "chromeos/network/onc/onc_certificate_importer_impl.h" #include "chromeos/network/onc/onc_utils.h" #include "components/user_manager/user.h" #endif using base::Value; using content::BrowserThread; using content::WebContents; using content::WebUIMessageHandler; namespace { // Delay between when an event occurs and when it is passed to the Javascript // page. All events that occur during this period are grouped together and // sent to the page at once, which reduces context switching and CPU usage. const int kNetLogEventDelayMilliseconds = 100; // Returns the HostCache for |context|'s primary HostResolver, or NULL if // there is none. net::HostCache* GetHostResolverCache(net::URLRequestContext* context) { return context->host_resolver()->GetHostCache(); } std::string HashesToBase64String(const net::HashValueVector& hashes) { std::string str; for (size_t i = 0; i != hashes.size(); ++i) { if (i != 0) str += ","; str += hashes[i].ToString(); } return str; } bool Base64StringToHashes(const std::string& hashes_str, net::HashValueVector* hashes) { hashes->clear(); std::vector<std::string> vector_hash_str = base::SplitString( hashes_str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); for (size_t i = 0; i != vector_hash_str.size(); ++i) { std::string hash_str; base::RemoveChars(vector_hash_str[i], " \t\r\n", &hash_str); net::HashValue hash; // Skip past unrecognized hash algos // But return false on malformatted input if (hash_str.empty()) return false; if (hash_str.compare(0, 5, "sha1/") != 0 && hash_str.compare(0, 7, "sha256/") != 0) { continue; } if (!hash.FromString(hash_str)) return false; hashes->push_back(hash); } return true; } // Returns the http network session for |context| if there is one. // Otherwise, returns NULL. net::HttpNetworkSession* GetHttpNetworkSession( net::URLRequestContext* context) { if (!context->http_transaction_factory()) return nullptr; return context->http_transaction_factory()->GetSession(); } content::WebUIDataSource* CreateNetInternalsHTMLSource() { content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUINetInternalsHost); source->SetDefaultResource(IDR_NET_INTERNALS_INDEX_HTML); source->AddResourcePath("index.js", IDR_NET_INTERNALS_INDEX_JS); source->SetJsonPath("strings.js"); source->UseGzip(std::unordered_set<std::string>()); return source; } // This class receives javascript messages from the renderer. // Note that the WebUI infrastructure runs on the UI thread, therefore all of // this class's methods are expected to run on the UI thread. // // Since the network code we want to run lives on the IO thread, we proxy // almost everything over to NetInternalsMessageHandler::IOThreadImpl, which // runs on the IO thread. // // TODO(eroman): Can we start on the IO thread to begin with? class NetInternalsMessageHandler : public WebUIMessageHandler, public base::SupportsWeakPtr<NetInternalsMessageHandler> { public: NetInternalsMessageHandler(); ~NetInternalsMessageHandler() override; // WebUIMessageHandler implementation. void RegisterMessages() override; // Calls g_browser.receive in the renderer, passing in |command| and |arg|. // If the renderer is displaying a log file, the message will be ignored. void SendJavascriptCommand(const std::string& command, std::unique_ptr<base::Value> arg); // Javascript message handlers. void OnRendererReady(const base::ListValue* list); void OnClearBrowserCache(const base::ListValue* list); void OnGetPrerenderInfo(const base::ListValue* list); void OnGetHistoricNetworkStats(const base::ListValue* list); void OnGetSessionNetworkStats(const base::ListValue* list); void OnGetExtensionInfo(const base::ListValue* list); void OnGetDataReductionProxyInfo(const base::ListValue* list); #if defined(OS_CHROMEOS) void OnImportONCFile(const base::ListValue* list); void OnStoreDebugLogs(const base::ListValue* list); void OnStoreDebugLogsCompleted(const base::FilePath& log_path, bool succeeded); void OnSetNetworkDebugMode(const base::ListValue* list); void OnSetNetworkDebugModeCompleted(const std::string& subsystem, bool succeeded); // Callback to |GetNSSCertDatabaseForProfile| used to retrieve the database // to which user's ONC defined certificates should be imported. // It parses and imports |onc_blob|. void ImportONCFileToNSSDB(const std::string& onc_blob, const std::string& passcode, net::NSSCertDatabase* nssdb); // Called back by the CertificateImporter when a certificate import finished. // |previous_error| contains earlier errors during this import. void OnCertificatesImported( const std::string& previous_error, bool success, const net::CertificateList& onc_trusted_certificates); #endif private: class IOThreadImpl; // This is the "real" message handler, which lives on the IO thread. scoped_refptr<IOThreadImpl> proxy_; DISALLOW_COPY_AND_ASSIGN(NetInternalsMessageHandler); }; // This class is the "real" message handler. It is allocated and destroyed on // the UI thread. With the exception of OnAddEntry, OnWebUIDeleted, and // SendJavascriptCommand, its methods are all expected to be called from the IO // thread. OnAddEntry and SendJavascriptCommand can be called from any thread, // and OnWebUIDeleted can only be called from the UI thread. class NetInternalsMessageHandler::IOThreadImpl : public base::RefCountedThreadSafe< NetInternalsMessageHandler::IOThreadImpl, BrowserThread::DeleteOnUIThread>, public net::NetLog::ThreadSafeObserver { public: // Type for methods that can be used as MessageHandler callbacks. typedef void (IOThreadImpl::*MessageHandler)(const base::ListValue*); // Creates a proxy for |handler| that will live on the IO thread. // |handler| is a weak pointer, since it is possible for the // WebUIMessageHandler to be deleted on the UI thread while we were executing // on the IO thread. |io_thread| is the global IOThread (it is passed in as // an argument since we need to grab it from the UI thread). IOThreadImpl( const base::WeakPtr<NetInternalsMessageHandler>& handler, IOThread* io_thread, net::URLRequestContextGetter* main_context_getter); // Called on UI thread just after creation, to add a ContextGetter to // |context_getters_|. void AddRequestContextGetter(net::URLRequestContextGetter* context_getter); // Helper method to enable a callback that will be executed on the IO thread. static void CallbackHelper(MessageHandler method, scoped_refptr<IOThreadImpl> io_thread, const base::ListValue* list); // Called once the WebUI has been deleted (i.e. renderer went away), on the // IO thread. void Detach(); // Called when the WebUI is deleted. Prevents calling Javascript functions // afterwards. Called on UI thread. void OnWebUIDeleted(); //-------------------------------- // Javascript message handlers: //-------------------------------- void OnRendererReady(const base::ListValue* list); void OnGetNetInfo(const base::ListValue* list); void OnReloadProxySettings(const base::ListValue* list); void OnClearBadProxies(const base::ListValue* list); void OnClearHostResolverCache(const base::ListValue* list); void OnHSTSQuery(const base::ListValue* list); void OnHSTSAdd(const base::ListValue* list); void OnHSTSDelete(const base::ListValue* list); void OnCloseIdleSockets(const base::ListValue* list); void OnFlushSocketPools(const base::ListValue* list); #if defined(OS_WIN) void OnGetServiceProviders(const base::ListValue* list); #endif void OnSetCaptureMode(const base::ListValue* list); // NetLog::ThreadSafeObserver implementation: void OnAddEntry(const net::NetLogEntry& entry) override; // Helper that calls g_browser.receive in the renderer, passing in |command| // and |arg|. If the renderer is displaying a log file, the message will be // ignored. Note that this can be called from any thread. void SendJavascriptCommand(const std::string& command, std::unique_ptr<base::Value> arg); private: friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; friend class base::DeleteHelper<IOThreadImpl>; using ContextGetterList = std::vector<scoped_refptr<net::URLRequestContextGetter>>; ~IOThreadImpl() override; // Adds |entry| to the queue of pending log entries to be sent to the page via // Javascript. Must be called on the IO Thread. Also creates a delayed task // that will call PostPendingEntries, if there isn't one already. void AddEntryToQueue(std::unique_ptr<base::Value> entry); // Sends all pending entries to the page via Javascript, and clears the list // of pending entries. Sending multiple entries at once results in a // significant reduction of CPU usage when a lot of events are happening. // Must be called on the IO Thread. void PostPendingEntries(); // Adds entries with the states of ongoing URL requests. void PrePopulateEventList(); net::URLRequestContext* GetMainContext() { return main_context_getter_->GetURLRequestContext(); } // |info_sources| is an or'd together list of the net::NetInfoSources to // send information about. Information is sent to Javascript in the form of // a single dictionary with information about all requests sources. void SendNetInfo(int info_sources); // Pointer to the UI-thread message handler. Only access this from // the UI thread. base::WeakPtr<NetInternalsMessageHandler> handler_; // The global IOThread, which contains the global NetLog to observer. IOThread* io_thread_; // The main URLRequestContextGetter for the tab's profile. scoped_refptr<net::URLRequestContextGetter> main_context_getter_; // True if the Web UI has been deleted. This is used to prevent calling // Javascript functions after the Web UI is destroyed. On refresh, the // messages can end up being sent to the refreshed page, causing duplicate // or partial entries. // // This is only read and written to on the UI thread. bool was_webui_deleted_; // Log entries that have yet to be passed along to Javascript page. Non-NULL // when and only when there is a pending delayed task to call // PostPendingEntries. Read and written to exclusively on the IO Thread. std::unique_ptr<base::ListValue> pending_entries_; // Used for getting current status of URLRequests when net-internals is // opened. |main_context_getter_| is automatically added on construction. // Duplicates are allowed. ContextGetterList context_getters_; DISALLOW_COPY_AND_ASSIGN(IOThreadImpl); }; //////////////////////////////////////////////////////////////////////////////// // // NetInternalsMessageHandler // //////////////////////////////////////////////////////////////////////////////// NetInternalsMessageHandler::NetInternalsMessageHandler() {} NetInternalsMessageHandler::~NetInternalsMessageHandler() { if (proxy_) { proxy_->OnWebUIDeleted(); // Notify the handler on the IO thread that the renderer is gone. BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::BindOnce(&IOThreadImpl::Detach, proxy_)); } } void NetInternalsMessageHandler::RegisterMessages() { DCHECK_CURRENTLY_ON(BrowserThread::UI); Profile* profile = Profile::FromWebUI(web_ui()); proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), profile->GetRequestContext()); proxy_->AddRequestContextGetter( content::BrowserContext::GetDefaultStoragePartition(profile)-> GetMediaURLRequestContext()); #if BUILDFLAG(ENABLE_EXTENSIONS) proxy_->AddRequestContextGetter(profile->GetRequestContextForExtensions()); #endif web_ui()->RegisterMessageCallback( "notifyReady", base::Bind(&NetInternalsMessageHandler::OnRendererReady, base::Unretained(this))); web_ui()->RegisterMessageCallback( "getNetInfo", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnGetNetInfo, proxy_)); web_ui()->RegisterMessageCallback( "reloadProxySettings", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnReloadProxySettings, proxy_)); web_ui()->RegisterMessageCallback( "clearBadProxies", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnClearBadProxies, proxy_)); web_ui()->RegisterMessageCallback( "clearHostResolverCache", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnClearHostResolverCache, proxy_)); web_ui()->RegisterMessageCallback( "hstsQuery", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnHSTSQuery, proxy_)); web_ui()->RegisterMessageCallback( "hstsAdd", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnHSTSAdd, proxy_)); web_ui()->RegisterMessageCallback( "hstsDelete", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnHSTSDelete, proxy_)); web_ui()->RegisterMessageCallback( "closeIdleSockets", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnCloseIdleSockets, proxy_)); web_ui()->RegisterMessageCallback( "flushSocketPools", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnFlushSocketPools, proxy_)); #if defined(OS_WIN) web_ui()->RegisterMessageCallback( "getServiceProviders", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnGetServiceProviders, proxy_)); #endif web_ui()->RegisterMessageCallback( "setCaptureMode", base::Bind(&IOThreadImpl::CallbackHelper, &IOThreadImpl::OnSetCaptureMode, proxy_)); web_ui()->RegisterMessageCallback( "clearBrowserCache", base::Bind(&NetInternalsMessageHandler::OnClearBrowserCache, base::Unretained(this))); web_ui()->RegisterMessageCallback( "getPrerenderInfo", base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, base::Unretained(this))); web_ui()->RegisterMessageCallback( "getHistoricNetworkStats", base::Bind(&NetInternalsMessageHandler::OnGetHistoricNetworkStats, base::Unretained(this))); web_ui()->RegisterMessageCallback( "getSessionNetworkStats", base::Bind(&NetInternalsMessageHandler::OnGetSessionNetworkStats, base::Unretained(this))); web_ui()->RegisterMessageCallback( "getExtensionInfo", base::Bind(&NetInternalsMessageHandler::OnGetExtensionInfo, base::Unretained(this))); web_ui()->RegisterMessageCallback( "getDataReductionProxyInfo", base::Bind(&NetInternalsMessageHandler::OnGetDataReductionProxyInfo, base::Unretained(this))); #if defined(OS_CHROMEOS) web_ui()->RegisterMessageCallback( "importONCFile", base::Bind(&NetInternalsMessageHandler::OnImportONCFile, base::Unretained(this))); web_ui()->RegisterMessageCallback( "storeDebugLogs", base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogs, base::Unretained(this))); web_ui()->RegisterMessageCallback( "setNetworkDebugMode", base::Bind(&NetInternalsMessageHandler::OnSetNetworkDebugMode, base::Unretained(this))); #endif } void NetInternalsMessageHandler::SendJavascriptCommand( const std::string& command, std::unique_ptr<base::Value> arg) { std::unique_ptr<base::Value> command_value(new base::Value(command)); DCHECK_CURRENTLY_ON(BrowserThread::UI); if (arg) { web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive", *command_value.get(), *arg.get()); } else { web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive", *command_value.get()); } } void NetInternalsMessageHandler::OnRendererReady(const base::ListValue* list) { IOThreadImpl::CallbackHelper(&IOThreadImpl::OnRendererReady, proxy_, list); } void NetInternalsMessageHandler::OnClearBrowserCache( const base::ListValue* list) { content::BrowsingDataRemover* remover = Profile::GetBrowsingDataRemover(Profile::FromWebUI(web_ui())); remover->Remove(base::Time(), base::Time::Max(), content::BrowsingDataRemover::DATA_TYPE_CACHE, content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); // BrowsingDataRemover deletes itself. } void NetInternalsMessageHandler::OnGetPrerenderInfo( const base::ListValue* list) { DCHECK_CURRENTLY_ON(BrowserThread::UI); SendJavascriptCommand( "receivedPrerenderInfo", chrome_browser_net::GetPrerenderInfo(Profile::FromWebUI(web_ui()))); } void NetInternalsMessageHandler::OnGetHistoricNetworkStats( const base::ListValue* list) { DCHECK_CURRENTLY_ON(BrowserThread::UI); SendJavascriptCommand("receivedHistoricNetworkStats", chrome_browser_net::GetHistoricNetworkStats( Profile::FromWebUI(web_ui()))); } void NetInternalsMessageHandler::OnGetSessionNetworkStats( const base::ListValue* list) { DCHECK_CURRENTLY_ON(BrowserThread::UI); SendJavascriptCommand( "receivedSessionNetworkStats", chrome_browser_net::GetSessionNetworkStats(Profile::FromWebUI(web_ui()))); } void NetInternalsMessageHandler::OnGetExtensionInfo( const base::ListValue* list) { DCHECK_CURRENTLY_ON(BrowserThread::UI); SendJavascriptCommand( "receivedExtensionInfo", chrome_browser_net::GetExtensionInfo(Profile::FromWebUI(web_ui()))); } void NetInternalsMessageHandler::OnGetDataReductionProxyInfo( const base::ListValue* list) { DCHECK_CURRENTLY_ON(BrowserThread::UI); SendJavascriptCommand("receivedDataReductionProxyInfo", chrome_browser_net::GetDataReductionProxyInfo( Profile::FromWebUI(web_ui()))); } //////////////////////////////////////////////////////////////////////////////// // // NetInternalsMessageHandler::IOThreadImpl // //////////////////////////////////////////////////////////////////////////////// NetInternalsMessageHandler::IOThreadImpl::IOThreadImpl( const base::WeakPtr<NetInternalsMessageHandler>& handler, IOThread* io_thread, net::URLRequestContextGetter* main_context_getter) : handler_(handler), io_thread_(io_thread), main_context_getter_(main_context_getter), was_webui_deleted_(false) { DCHECK_CURRENTLY_ON(BrowserThread::UI); AddRequestContextGetter(main_context_getter); } NetInternalsMessageHandler::IOThreadImpl::~IOThreadImpl() { DCHECK_CURRENTLY_ON(BrowserThread::UI); } void NetInternalsMessageHandler::IOThreadImpl::AddRequestContextGetter( net::URLRequestContextGetter* context_getter) { DCHECK_CURRENTLY_ON(BrowserThread::UI); context_getters_.push_back(context_getter); } void NetInternalsMessageHandler::IOThreadImpl::CallbackHelper( MessageHandler method, scoped_refptr<IOThreadImpl> io_thread, const base::ListValue* list) { DCHECK_CURRENTLY_ON(BrowserThread::UI); // We need to make a copy of the value in order to pass it over to the IO // thread. |list_copy| will be deleted when the task is destroyed. The called // |method| cannot take ownership of |list_copy|. base::ListValue* list_copy = (list && list->GetSize()) ? list->DeepCopy() : nullptr; BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::BindOnce(method, io_thread, base::Owned(list_copy))); } void NetInternalsMessageHandler::IOThreadImpl::Detach() { DCHECK_CURRENTLY_ON(BrowserThread::IO); // Unregister with network stack to observe events. if (net_log()) net_log()->DeprecatedRemoveObserver(this); } void NetInternalsMessageHandler::IOThreadImpl::OnWebUIDeleted() { DCHECK_CURRENTLY_ON(BrowserThread::UI); was_webui_deleted_ = true; } void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( const base::ListValue* list) { DCHECK_CURRENTLY_ON(BrowserThread::IO); // If currently watching the NetLog, temporarily stop watching it and flush // pending events, so they won't appear before the status events created for // currently active network objects below. if (net_log()) { net_log()->DeprecatedRemoveObserver(this); PostPendingEntries(); } SendJavascriptCommand( "receivedConstants", net_log::ChromeNetLog::GetConstants( base::CommandLine::ForCurrentProcess()->GetCommandLineString(), chrome::GetChannelString())); PrePopulateEventList(); // Register with network stack to observe events. io_thread_->net_log()->DeprecatedAddObserver( this, net::NetLogCaptureMode::IncludeCookiesAndCredentials()); } void NetInternalsMessageHandler::IOThreadImpl::OnGetNetInfo( const base::ListValue* list) { DCHECK(list); int info_sources; if (!list->GetInteger(0, &info_sources)) return; SendNetInfo(info_sources); } void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( const base::ListValue* list) { DCHECK(!list); GetMainContext()->proxy_service()->ForceReloadProxyConfig(); // Cause the renderer to be notified of the new values. SendNetInfo(net::NET_INFO_PROXY_SETTINGS); } void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( const base::ListValue* list) { DCHECK(!list); GetMainContext()->proxy_service()->ClearBadProxiesCache(); // Cause the renderer to be notified of the new values. SendNetInfo(net::NET_INFO_BAD_PROXIES); } void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( const base::ListValue* list) { DCHECK(!list); net::HostCache* cache = GetHostResolverCache(GetMainContext()); if (cache) cache->clear(); // Cause the renderer to be notified of the new values. SendNetInfo(net::NET_INFO_HOST_RESOLVER); } void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( const base::ListValue* list) { // |list| should be: [<domain to query>]. std::string domain; CHECK(list->GetString(0, &domain)); auto result = base::MakeUnique<base::DictionaryValue>(); if (base::IsStringASCII(domain)) { net::TransportSecurityState* transport_security_state = GetMainContext()->transport_security_state(); if (transport_security_state) { net::TransportSecurityState::STSState static_sts_state; net::TransportSecurityState::PKPState static_pkp_state; const bool found_static = transport_security_state->GetStaticDomainState( domain, &static_sts_state, &static_pkp_state); if (found_static) { result->SetInteger("static_upgrade_mode", static_cast<int>(static_sts_state.upgrade_mode)); result->SetBoolean("static_sts_include_subdomains", static_sts_state.include_subdomains); result->SetDouble("static_sts_observed", static_sts_state.last_observed.ToDoubleT()); result->SetDouble("static_sts_expiry", static_sts_state.expiry.ToDoubleT()); result->SetBoolean("static_pkp_include_subdomains", static_pkp_state.include_subdomains); result->SetDouble("static_pkp_observed", static_pkp_state.last_observed.ToDoubleT()); result->SetDouble("static_pkp_expiry", static_pkp_state.expiry.ToDoubleT()); result->SetString("static_spki_hashes", HashesToBase64String(static_pkp_state.spki_hashes)); result->SetString("static_sts_domain", static_sts_state.domain); result->SetString("static_pkp_domain", static_pkp_state.domain); } net::TransportSecurityState::STSState dynamic_sts_state; net::TransportSecurityState::PKPState dynamic_pkp_state; const bool found_sts_dynamic = transport_security_state->GetDynamicSTSState(domain, &dynamic_sts_state); const bool found_pkp_dynamic = transport_security_state->GetDynamicPKPState(domain, &dynamic_pkp_state); if (found_sts_dynamic) { result->SetInteger("dynamic_upgrade_mode", static_cast<int>(dynamic_sts_state.upgrade_mode)); result->SetBoolean("dynamic_sts_include_subdomains", dynamic_sts_state.include_subdomains); result->SetDouble("dynamic_sts_observed", dynamic_sts_state.last_observed.ToDoubleT()); result->SetDouble("dynamic_sts_expiry", dynamic_sts_state.expiry.ToDoubleT()); result->SetString("dynamic_sts_domain", dynamic_sts_state.domain); } if (found_pkp_dynamic) { result->SetBoolean("dynamic_pkp_include_subdomains", dynamic_pkp_state.include_subdomains); result->SetDouble("dynamic_pkp_observed", dynamic_pkp_state.last_observed.ToDoubleT()); result->SetDouble("dynamic_pkp_expiry", dynamic_pkp_state.expiry.ToDoubleT()); result->SetString("dynamic_spki_hashes", HashesToBase64String(dynamic_pkp_state.spki_hashes)); result->SetString("dynamic_pkp_domain", dynamic_pkp_state.domain); } result->SetBoolean( "result", found_static || found_sts_dynamic || found_pkp_dynamic); } else { result->SetString("error", "no TransportSecurityState active"); } } else { result->SetString("error", "non-ASCII domain name"); } SendJavascriptCommand("receivedHSTSResult", std::move(result)); } void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd( const base::ListValue* list) { // |list| should be: [<domain to query>, <STS include subdomains>, <PKP // include subdomains>, <key pins>]. std::string domain; CHECK(list->GetString(0, &domain)); if (!base::IsStringASCII(domain)) { // Silently fail. The user will get a helpful error if they query for the // name. return; } bool sts_include_subdomains; CHECK(list->GetBoolean(1, &sts_include_subdomains)); bool pkp_include_subdomains; CHECK(list->GetBoolean(2, &pkp_include_subdomains)); std::string hashes_str; CHECK(list->GetString(3, &hashes_str)); net::TransportSecurityState* transport_security_state = GetMainContext()->transport_security_state(); if (!transport_security_state) return; base::Time expiry = base::Time::Now() + base::TimeDelta::FromDays(1000); net::HashValueVector hashes; if (!hashes_str.empty()) { if (!Base64StringToHashes(hashes_str, &hashes)) return; } transport_security_state->AddHSTS(domain, expiry, sts_include_subdomains); transport_security_state->AddHPKP(domain, expiry, pkp_include_subdomains, hashes, GURL()); } void NetInternalsMessageHandler::IOThreadImpl::OnHSTSDelete( const base::ListValue* list) { // |list| should be: [<domain to query>]. std::string domain; CHECK(list->GetString(0, &domain)); if (!base::IsStringASCII(domain)) { // There cannot be a unicode entry in the HSTS set. return; } net::TransportSecurityState* transport_security_state = GetMainContext()->transport_security_state(); if (!transport_security_state) return; transport_security_state->DeleteDynamicDataForHost(domain); } void NetInternalsMessageHandler::IOThreadImpl::OnFlushSocketPools( const base::ListValue* list) { DCHECK(!list); net::HttpNetworkSession* http_network_session = GetHttpNetworkSession(GetMainContext()); if (http_network_session) http_network_session->CloseAllConnections(); } void NetInternalsMessageHandler::IOThreadImpl::OnCloseIdleSockets( const base::ListValue* list) { DCHECK(!list); net::HttpNetworkSession* http_network_session = GetHttpNetworkSession(GetMainContext()); if (http_network_session) http_network_session->CloseIdleConnections(); } #if defined(OS_WIN) void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( const base::ListValue* list) { DCHECK(!list); SendJavascriptCommand("receivedServiceProviders", chrome_browser_net::GetWindowsServiceProviders()); } #endif #if defined(OS_CHROMEOS) void NetInternalsMessageHandler::ImportONCFileToNSSDB( const std::string& onc_blob, const std::string& passcode, net::NSSCertDatabase* nssdb) { const user_manager::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile( Profile::FromWebUI(web_ui())); if (!user) { std::string error = "User not found."; SendJavascriptCommand("receivedONCFileParse", base::MakeUnique<base::Value>(error)); return; } std::string error; onc::ONCSource onc_source = onc::ONC_SOURCE_USER_IMPORT; base::ListValue network_configs; base::DictionaryValue global_network_config; base::ListValue certificates; if (!chromeos::onc::ParseAndValidateOncForImport(onc_blob, onc_source, passcode, &network_configs, &global_network_config, &certificates)) { error = "Errors occurred during the ONC parsing. "; } std::string network_error; chromeos::onc::ImportNetworksForUser(user, network_configs, &network_error); if (!network_error.empty()) error += network_error; chromeos::onc::CertificateImporterImpl cert_importer( BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), nssdb); cert_importer.ImportCertificates( certificates, onc_source, base::Bind(&NetInternalsMessageHandler::OnCertificatesImported, AsWeakPtr(), error)); } void NetInternalsMessageHandler::OnCertificatesImported( const std::string& previous_error, bool success, const net::CertificateList& /* unused onc_trusted_certificates */) { std::string error = previous_error; if (!success) error += "Some certificates couldn't be imported. "; SendJavascriptCommand("receivedONCFileParse", base::MakeUnique<base::Value>(error)); } void NetInternalsMessageHandler::OnImportONCFile( const base::ListValue* list) { std::string onc_blob; std::string passcode; if (list->GetSize() != 2 || !list->GetString(0, &onc_blob) || !list->GetString(1, &passcode)) { NOTREACHED(); } GetNSSCertDatabaseForProfile( Profile::FromWebUI(web_ui()), base::Bind(&NetInternalsMessageHandler::ImportONCFileToNSSDB, AsWeakPtr(), onc_blob, passcode)); } void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) { DCHECK(list); SendJavascriptCommand("receivedStoreDebugLogs", base::MakeUnique<base::Value>("Creating log file...")); Profile* profile = Profile::FromWebUI(web_ui()); const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(profile); base::FilePath path = prefs->DownloadPath(); if (file_manager::util::IsUnderNonNativeLocalPath(profile, path)) path = prefs->GetDefaultDownloadDirectoryForProfile(); chromeos::DebugLogWriter::StoreLogs( path, true, // should_compress base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, AsWeakPtr())); } void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( const base::FilePath& log_path, bool succeeded) { std::string status; if (succeeded) status = "Created log file: " + log_path.BaseName().AsUTF8Unsafe(); else status = "Failed to create log file"; SendJavascriptCommand("receivedStoreDebugLogs", base::MakeUnique<base::Value>(status)); } void NetInternalsMessageHandler::OnSetNetworkDebugMode( const base::ListValue* list) { std::string subsystem; if (list->GetSize() != 1 || !list->GetString(0, &subsystem)) NOTREACHED(); chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()-> SetDebugMode( subsystem, base::Bind( &NetInternalsMessageHandler::OnSetNetworkDebugModeCompleted, AsWeakPtr(), subsystem)); } void NetInternalsMessageHandler::OnSetNetworkDebugModeCompleted( const std::string& subsystem, bool succeeded) { std::string status = succeeded ? "Debug mode is changed to " : "Failed to change debug mode to "; status += subsystem; SendJavascriptCommand("receivedSetNetworkDebugMode", base::MakeUnique<base::Value>(status)); } #endif // defined(OS_CHROMEOS) void NetInternalsMessageHandler::IOThreadImpl::OnSetCaptureMode( const base::ListValue* list) { std::string capture_mode_string; if (!list->GetString(0, &capture_mode_string)) { NOTREACHED(); return; } // Convert the string to a NetLogCaptureMode. net::NetLogCaptureMode mode; if (capture_mode_string == "IncludeSocketBytes") { mode = net::NetLogCaptureMode::IncludeSocketBytes(); } else if (capture_mode_string == "IncludeCookiesAndCredentials") { mode = net::NetLogCaptureMode::IncludeCookiesAndCredentials(); } else { NOTREACHED(); } net_log()->SetObserverCaptureMode(this, mode); } // Note that unlike other methods of IOThreadImpl, this function // can be called from ANY THREAD. void NetInternalsMessageHandler::IOThreadImpl::OnAddEntry( const net::NetLogEntry& entry) { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::BindOnce(&IOThreadImpl::AddEntryToQueue, this, base::Passed(entry.ToValue()))); } // Note that this can be called from ANY THREAD. void NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand( const std::string& command, std::unique_ptr<base::Value> arg) { if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { if (handler_ && !was_webui_deleted_) { // We check |handler_| in case it was deleted on the UI thread earlier // while we were running on the IO thread. handler_->SendJavascriptCommand(command, std::move(arg)); } return; } BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::BindOnce(&IOThreadImpl::SendJavascriptCommand, this, command, base::Passed(&arg))); } void NetInternalsMessageHandler::IOThreadImpl::AddEntryToQueue( std::unique_ptr<base::Value> entry) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!pending_entries_) { pending_entries_.reset(new base::ListValue()); BrowserThread::PostDelayedTask( BrowserThread::IO, FROM_HERE, base::BindOnce(&IOThreadImpl::PostPendingEntries, this), base::TimeDelta::FromMilliseconds(kNetLogEventDelayMilliseconds)); } pending_entries_->Append(std::move(entry)); } void NetInternalsMessageHandler::IOThreadImpl::PostPendingEntries() { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (pending_entries_) SendJavascriptCommand("receivedLogEntries", std::move(pending_entries_)); } void NetInternalsMessageHandler::IOThreadImpl::PrePopulateEventList() { // Using a set removes any duplicates. std::set<net::URLRequestContext*> contexts; for (const auto& getter : context_getters_) contexts.insert(getter->GetURLRequestContext()); contexts.insert(io_thread_->globals()->proxy_script_fetcher_context.get()); contexts.insert(io_thread_->globals()->system_request_context.get()); // Add entries for ongoing network objects. CreateNetLogEntriesForActiveObjects(contexts, this); } void NetInternalsMessageHandler::IOThreadImpl::SendNetInfo(int info_sources) { DCHECK_CURRENTLY_ON(BrowserThread::IO); SendJavascriptCommand("receivedNetInfo", net::GetNetInfo(GetMainContext(), info_sources)); } } // namespace //////////////////////////////////////////////////////////////////////////////// // // NetInternalsUI // //////////////////////////////////////////////////////////////////////////////// NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) : WebUIController(web_ui) { web_ui->AddMessageHandler(base::MakeUnique<NetInternalsMessageHandler>()); // Set up the chrome://net-internals/ source. Profile* profile = Profile::FromWebUI(web_ui); content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); }
[ "xElvis89x@gmail.com" ]
xElvis89x@gmail.com
1b5eff0ba157b4406dbe8573e670f6545fd25d79
90047daeb462598a924d76ddf4288e832e86417c
/remoting/host/desktop_session_win.cc
77b30603117f75a77d7081dc94a76e31d97b5946
[ "BSD-3-Clause" ]
permissive
massbrowser/android
99b8c21fa4552a13c06bbedd0f9c88dd4a4ad080
a9c4371682c9443d6e1d66005d4db61a24a9617c
refs/heads/master
2022-11-04T21:15:50.656802
2017-06-08T12:31:39
2017-06-08T12:31:39
93,747,579
2
2
BSD-3-Clause
2022-10-31T10:34:25
2017-06-08T12:36:07
null
UTF-8
C++
false
false
23,207
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "remoting/host/desktop_session_win.h" #include <sddl.h> #include <limits> #include <memory> #include <utility> #include "base/base_switches.h" #include "base/command_line.h" #include "base/files/file_path.h" #include "base/guid.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_checker.h" #include "base/timer/timer.h" #include "base/win/registry.h" #include "base/win/scoped_bstr.h" #include "base/win/scoped_comptr.h" #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_platform_file.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/host/chromoting_messages.h" #include "remoting/host/daemon_process.h" #include "remoting/host/desktop_session.h" #include "remoting/host/host_main.h" #include "remoting/host/ipc_constants.h" #include "remoting/host/sas_injector.h" #include "remoting/host/screen_resolution.h" // MIDL-generated declarations and definitions. #include "remoting/host/win/chromoting_lib.h" #include "remoting/host/win/host_service.h" #include "remoting/host/win/worker_process_launcher.h" #include "remoting/host/win/wts_session_process_delegate.h" #include "remoting/host/win/wts_terminal_monitor.h" #include "remoting/host/win/wts_terminal_observer.h" #include "remoting/host/worker_process_ipc_delegate.h" using base::win::ScopedHandle; namespace remoting { namespace { // The security descriptor of the daemon IPC endpoint. It gives full access // to SYSTEM and denies access by anyone else. const wchar_t kDaemonIpcSecurityDescriptor[] = SDDL_OWNER L":" SDDL_LOCAL_SYSTEM SDDL_GROUP L":" SDDL_LOCAL_SYSTEM SDDL_DACL L":(" SDDL_ACCESS_ALLOWED L";;" SDDL_GENERIC_ALL L";;;" SDDL_LOCAL_SYSTEM L")"; // The command line parameters that should be copied from the service's command // line to the desktop process. const char* kCopiedSwitchNames[] = { switches::kV, switches::kVModule }; // The default screen dimensions for an RDP session. const int kDefaultRdpScreenWidth = 1280; const int kDefaultRdpScreenHeight = 768; // RDC 6.1 (W2K8) supports dimensions of up to 4096x2048. const int kMaxRdpScreenWidth = 4096; const int kMaxRdpScreenHeight = 2048; // The minimum effective screen dimensions supported by Windows are 800x600. const int kMinRdpScreenWidth = 800; const int kMinRdpScreenHeight = 600; // Default dots per inch used by RDP is 96 DPI. const int kDefaultRdpDpi = 96; // The session attach notification should arrive within 30 seconds. const int kSessionAttachTimeoutSeconds = 30; // The default port number used for establishing an RDP session. const int kDefaultRdpPort = 3389; // Used for validating the required RDP registry values. const int kRdpConnectionsDisabled = 1; const int kNetworkLevelAuthEnabled = 1; const int kSecurityLayerTlsRequired = 2; // The values used to establish RDP connections are stored in the registry. const wchar_t kRdpSettingsKeyName[] = L"SYSTEM\\CurrentControlSet\\Control\\Terminal Server"; const wchar_t kRdpTcpSettingsKeyName[] = L"SYSTEM\\CurrentControlSet\\" L"Control\\Terminal Server\\WinStations\\RDP-Tcp"; const wchar_t kRdpPortValueName[] = L"PortNumber"; const wchar_t kDenyTsConnectionsValueName[] = L"fDenyTSConnections"; const wchar_t kNetworkLevelAuthValueName[] = L"UserAuthentication"; const wchar_t kSecurityLayerValueName[] = L"SecurityLayer"; webrtc::DesktopSize GetBoundedRdpDesktopSize(int width, int height) { return webrtc::DesktopSize( std::min(kMaxRdpScreenWidth, std::max(kMinRdpScreenWidth, width)), std::min(kMaxRdpScreenHeight, std::max(kMinRdpScreenHeight, height))); } // DesktopSession implementation which attaches to the host's physical console. // Receives IPC messages from the desktop process, running in the console // session, via |WorkerProcessIpcDelegate|, and monitors console session // attach/detach events via |WtsConsoleObserver|. class ConsoleSession : public DesktopSessionWin { public: // Same as DesktopSessionWin(). ConsoleSession( scoped_refptr<AutoThreadTaskRunner> caller_task_runner, scoped_refptr<AutoThreadTaskRunner> io_task_runner, DaemonProcess* daemon_process, int id, WtsTerminalMonitor* monitor); ~ConsoleSession() override; protected: // DesktopSession overrides. void SetScreenResolution(const ScreenResolution& resolution) override; // DesktopSessionWin overrides. void InjectSas() override; private: std::unique_ptr<SasInjector> sas_injector_; DISALLOW_COPY_AND_ASSIGN(ConsoleSession); }; // DesktopSession implementation which attaches to virtual RDP console. // Receives IPC messages from the desktop process, running in the console // session, via |WorkerProcessIpcDelegate|, and monitors console session // attach/detach events via |WtsConsoleObserver|. class RdpSession : public DesktopSessionWin { public: // Same as DesktopSessionWin(). RdpSession( scoped_refptr<AutoThreadTaskRunner> caller_task_runner, scoped_refptr<AutoThreadTaskRunner> io_task_runner, DaemonProcess* daemon_process, int id, WtsTerminalMonitor* monitor); ~RdpSession() override; // Performs the part of initialization that can fail. bool Initialize(const ScreenResolution& resolution); // Mirrors IRdpDesktopSessionEventHandler. void OnRdpConnected(); void OnRdpClosed(); protected: // DesktopSession overrides. void SetScreenResolution(const ScreenResolution& resolution) override; // DesktopSessionWin overrides. void InjectSas() override; private: // An implementation of IRdpDesktopSessionEventHandler interface that forwards // notifications to the owning desktop session. class EventHandler : public IRdpDesktopSessionEventHandler { public: explicit EventHandler(base::WeakPtr<RdpSession> desktop_session); virtual ~EventHandler(); // IUnknown interface. STDMETHOD_(ULONG, AddRef)() override; STDMETHOD_(ULONG, Release)() override; STDMETHOD(QueryInterface)(REFIID riid, void** ppv) override; // IRdpDesktopSessionEventHandler interface. STDMETHOD(OnRdpConnected)() override; STDMETHOD(OnRdpClosed)() override; private: ULONG ref_count_; // Points to the desktop session object receiving OnRdpXxx() notifications. base::WeakPtr<RdpSession> desktop_session_; // This class must be used on a single thread. base::ThreadChecker thread_checker_; DISALLOW_COPY_AND_ASSIGN(EventHandler); }; // Examines the system settings required to establish an RDP session. // This method returns false if the values are retrieved and any of them would // prevent us from creating an RDP connection. bool VerifyRdpSettings(); // Retrieves a DWORD value from the registry. Returns true on success. bool RetrieveDwordRegistryValue(const wchar_t* key_name, const wchar_t* value_name, DWORD* value); // Used to create an RDP desktop session. base::win::ScopedComPtr<IRdpDesktopSession> rdp_desktop_session_; // Used to match |rdp_desktop_session_| with the session it is attached to. std::string terminal_id_; base::WeakPtrFactory<RdpSession> weak_factory_; DISALLOW_COPY_AND_ASSIGN(RdpSession); }; ConsoleSession::ConsoleSession( scoped_refptr<AutoThreadTaskRunner> caller_task_runner, scoped_refptr<AutoThreadTaskRunner> io_task_runner, DaemonProcess* daemon_process, int id, WtsTerminalMonitor* monitor) : DesktopSessionWin(caller_task_runner, io_task_runner, daemon_process, id, monitor) { StartMonitoring(WtsTerminalMonitor::kConsole); } ConsoleSession::~ConsoleSession() { } void ConsoleSession::SetScreenResolution(const ScreenResolution& resolution) { // Do nothing. The screen resolution of the console session is controlled by // the DesktopSessionAgent instance running in that session. DCHECK(caller_task_runner()->BelongsToCurrentThread()); } void ConsoleSession::InjectSas() { DCHECK(caller_task_runner()->BelongsToCurrentThread()); if (!sas_injector_) sas_injector_ = SasInjector::Create(); if (!sas_injector_->InjectSas()) LOG(ERROR) << "Failed to inject Secure Attention Sequence."; } RdpSession::RdpSession( scoped_refptr<AutoThreadTaskRunner> caller_task_runner, scoped_refptr<AutoThreadTaskRunner> io_task_runner, DaemonProcess* daemon_process, int id, WtsTerminalMonitor* monitor) : DesktopSessionWin(caller_task_runner, io_task_runner, daemon_process, id, monitor), weak_factory_(this) { } RdpSession::~RdpSession() { } bool RdpSession::Initialize(const ScreenResolution& resolution) { DCHECK(caller_task_runner()->BelongsToCurrentThread()); if (!VerifyRdpSettings()) { LOG(ERROR) << "Could not create an RDP session due to invalid settings."; return false; } // Create the RDP wrapper object. HRESULT result = rdp_desktop_session_.CreateInstance( __uuidof(RdpDesktopSession)); if (FAILED(result)) { LOG(ERROR) << "Failed to create RdpSession object, 0x" << std::hex << result << std::dec << "."; return false; } ScreenResolution local_resolution = resolution; // If the screen resolution is not specified, use the default screen // resolution. if (local_resolution.IsEmpty()) { local_resolution = ScreenResolution( webrtc::DesktopSize(kDefaultRdpScreenWidth, kDefaultRdpScreenHeight), webrtc::DesktopVector(kDefaultRdpDpi, kDefaultRdpDpi)); } // Get the screen dimensions assuming the default DPI. webrtc::DesktopSize host_size = local_resolution.ScaleDimensionsToDpi( webrtc::DesktopVector(kDefaultRdpDpi, kDefaultRdpDpi)); // Make sure that the host resolution is within the limits supported by RDP. host_size = GetBoundedRdpDesktopSize(host_size.width(), host_size.height()); // Read the port number used by RDP. DWORD server_port = kDefaultRdpPort; if (RetrieveDwordRegistryValue(kRdpTcpSettingsKeyName, kRdpPortValueName, &server_port) && server_port > 65535) { LOG(ERROR) << "Invalid RDP port specified: " << server_port; return false; } // Create an RDP session. base::win::ScopedComPtr<IRdpDesktopSessionEventHandler> event_handler( new EventHandler(weak_factory_.GetWeakPtr())); terminal_id_ = base::GenerateGUID(); base::win::ScopedBstr terminal_id(base::UTF8ToUTF16(terminal_id_).c_str()); result = rdp_desktop_session_->Connect(host_size.width(), host_size.height(), kDefaultRdpDpi, kDefaultRdpDpi, terminal_id, server_port, event_handler.Get()); if (FAILED(result)) { LOG(ERROR) << "RdpSession::Create() failed, 0x" << std::hex << result << std::dec << "."; return false; } return true; } void RdpSession::OnRdpConnected() { DCHECK(caller_task_runner()->BelongsToCurrentThread()); StopMonitoring(); StartMonitoring(terminal_id_); } void RdpSession::OnRdpClosed() { DCHECK(caller_task_runner()->BelongsToCurrentThread()); TerminateSession(); } void RdpSession::SetScreenResolution(const ScreenResolution& resolution) { DCHECK(caller_task_runner()->BelongsToCurrentThread()); DCHECK(!resolution.IsEmpty()); webrtc::DesktopSize new_size = resolution.ScaleDimensionsToDpi( webrtc::DesktopVector(kDefaultRdpDpi, kDefaultRdpDpi)); new_size = GetBoundedRdpDesktopSize(new_size.width(), new_size.height()); rdp_desktop_session_->ChangeResolution(new_size.width(), new_size.height(), kDefaultRdpDpi, kDefaultRdpDpi); } void RdpSession::InjectSas() { DCHECK(caller_task_runner()->BelongsToCurrentThread()); rdp_desktop_session_->InjectSas(); } bool RdpSession::VerifyRdpSettings() { // Verify RDP connections are enabled. DWORD deny_ts_connections_flag = 0; if (RetrieveDwordRegistryValue(kRdpSettingsKeyName, kDenyTsConnectionsValueName, &deny_ts_connections_flag) && deny_ts_connections_flag == kRdpConnectionsDisabled) { LOG(ERROR) << "RDP Connections must be enabled."; return false; } // Verify Network Level Authentication is disabled. DWORD network_level_auth_flag = 0; if (RetrieveDwordRegistryValue(kRdpTcpSettingsKeyName, kNetworkLevelAuthValueName, &network_level_auth_flag) && network_level_auth_flag == kNetworkLevelAuthEnabled) { LOG(ERROR) << "Network Level Authentication for RDP must be disabled."; return false; } // Verify Security Layer is not set to TLS. It can be either of the other two // values, but forcing TLS will prevent us from establishing a connection. DWORD security_layer_flag = 0; if (RetrieveDwordRegistryValue(kRdpTcpSettingsKeyName, kSecurityLayerValueName, &security_layer_flag) && security_layer_flag == kSecurityLayerTlsRequired) { LOG(ERROR) << "RDP SecurityLayer must not be set to TLS."; return false; } return true; } bool RdpSession::RetrieveDwordRegistryValue(const wchar_t* key_name, const wchar_t* value_name, DWORD* value) { DCHECK(key_name); DCHECK(value_name); DCHECK(value); base::win::RegKey key(HKEY_LOCAL_MACHINE, key_name, KEY_READ); if (!key.Valid()) { LOG(WARNING) << "Failed to open key: " << key_name; return false; } if (key.ReadValueDW(value_name, value) != ERROR_SUCCESS) { LOG(WARNING) << "Failed to read registry value: " << value_name; return false; } return true; } RdpSession::EventHandler::EventHandler( base::WeakPtr<RdpSession> desktop_session) : ref_count_(0), desktop_session_(desktop_session) { } RdpSession::EventHandler::~EventHandler() { DCHECK(thread_checker_.CalledOnValidThread()); if (desktop_session_) desktop_session_->OnRdpClosed(); } ULONG STDMETHODCALLTYPE RdpSession::EventHandler::AddRef() { DCHECK(thread_checker_.CalledOnValidThread()); return ++ref_count_; } ULONG STDMETHODCALLTYPE RdpSession::EventHandler::Release() { DCHECK(thread_checker_.CalledOnValidThread()); if (--ref_count_ == 0) { delete this; return 0; } return ref_count_; } STDMETHODIMP RdpSession::EventHandler::QueryInterface(REFIID riid, void** ppv) { DCHECK(thread_checker_.CalledOnValidThread()); if (riid == IID_IUnknown || riid == IID_IRdpDesktopSessionEventHandler) { *ppv = static_cast<IRdpDesktopSessionEventHandler*>(this); AddRef(); return S_OK; } *ppv = nullptr; return E_NOINTERFACE; } STDMETHODIMP RdpSession::EventHandler::OnRdpConnected() { DCHECK(thread_checker_.CalledOnValidThread()); if (desktop_session_) desktop_session_->OnRdpConnected(); return S_OK; } STDMETHODIMP RdpSession::EventHandler::OnRdpClosed() { DCHECK(thread_checker_.CalledOnValidThread()); if (!desktop_session_) return S_OK; base::WeakPtr<RdpSession> desktop_session = desktop_session_; desktop_session_.reset(); desktop_session->OnRdpClosed(); return S_OK; } } // namespace // static std::unique_ptr<DesktopSession> DesktopSessionWin::CreateForConsole( scoped_refptr<AutoThreadTaskRunner> caller_task_runner, scoped_refptr<AutoThreadTaskRunner> io_task_runner, DaemonProcess* daemon_process, int id, const ScreenResolution& resolution) { return base::MakeUnique<ConsoleSession>(caller_task_runner, io_task_runner, daemon_process, id, HostService::GetInstance()); } // static std::unique_ptr<DesktopSession> DesktopSessionWin::CreateForVirtualTerminal( scoped_refptr<AutoThreadTaskRunner> caller_task_runner, scoped_refptr<AutoThreadTaskRunner> io_task_runner, DaemonProcess* daemon_process, int id, const ScreenResolution& resolution) { std::unique_ptr<RdpSession> session( new RdpSession(caller_task_runner, io_task_runner, daemon_process, id, HostService::GetInstance())); if (!session->Initialize(resolution)) return nullptr; return std::move(session); } DesktopSessionWin::DesktopSessionWin( scoped_refptr<AutoThreadTaskRunner> caller_task_runner, scoped_refptr<AutoThreadTaskRunner> io_task_runner, DaemonProcess* daemon_process, int id, WtsTerminalMonitor* monitor) : DesktopSession(daemon_process, id), caller_task_runner_(caller_task_runner), io_task_runner_(io_task_runner), monitor_(monitor), monitoring_notifications_(false) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); ReportElapsedTime("created"); } DesktopSessionWin::~DesktopSessionWin() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); StopMonitoring(); } void DesktopSessionWin::OnSessionAttachTimeout() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); LOG(ERROR) << "Session attach notification didn't arrived within " << kSessionAttachTimeoutSeconds << " seconds."; TerminateSession(); } void DesktopSessionWin::StartMonitoring(const std::string& terminal_id) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); DCHECK(!monitoring_notifications_); DCHECK(!session_attach_timer_.IsRunning()); ReportElapsedTime("started monitoring"); session_attach_timer_.Start( FROM_HERE, base::TimeDelta::FromSeconds(kSessionAttachTimeoutSeconds), this, &DesktopSessionWin::OnSessionAttachTimeout); monitoring_notifications_ = true; monitor_->AddWtsTerminalObserver(terminal_id, this); } void DesktopSessionWin::StopMonitoring() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); if (monitoring_notifications_) { ReportElapsedTime("stopped monitoring"); monitoring_notifications_ = false; monitor_->RemoveWtsTerminalObserver(this); } session_attach_timer_.Stop(); OnSessionDetached(); } void DesktopSessionWin::TerminateSession() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); StopMonitoring(); // This call will delete |this| so it should be at the very end of the method. daemon_process()->CloseDesktopSession(id()); } void DesktopSessionWin::OnChannelConnected(int32_t peer_pid) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); ReportElapsedTime("channel connected"); VLOG(1) << "IPC: daemon <- desktop (" << peer_pid << ")"; } bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); bool handled = true; IPC_BEGIN_MESSAGE_MAP(DesktopSessionWin, message) IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_DesktopAttached, OnDesktopSessionAgentAttached) IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_InjectSas, InjectSas) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() if (!handled) { LOG(ERROR) << "Received unexpected IPC type: " << message.type(); CrashDesktopProcess(FROM_HERE); } return handled; } void DesktopSessionWin::OnPermanentError(int exit_code) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); TerminateSession(); } void DesktopSessionWin::OnSessionAttached(uint32_t session_id) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); DCHECK(!launcher_); DCHECK(monitoring_notifications_); ReportElapsedTime("attached"); // Launch elevated on Win8+ to enable injection of Alt+Tab and Ctrl+Alt+Del. bool launch_elevated = base::win::GetVersion() >= base::win::VERSION_WIN8; // Get the name of the executable to run. |kDesktopBinaryName| specifies // uiAccess="true" in its manifest. base::FilePath desktop_binary; bool result; if (launch_elevated) { result = GetInstalledBinaryPath(kDesktopBinaryName, &desktop_binary); } else { result = GetInstalledBinaryPath(kHostBinaryName, &desktop_binary); } if (!result) { TerminateSession(); return; } session_attach_timer_.Stop(); std::unique_ptr<base::CommandLine> target( new base::CommandLine(desktop_binary)); target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeDesktop); // Copy the command line switches enabling verbose logging. target->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(), kCopiedSwitchNames, arraysize(kCopiedSwitchNames)); // Create a delegate capable of launching a process in a different session. std::unique_ptr<WtsSessionProcessDelegate> delegate( new WtsSessionProcessDelegate( io_task_runner_, std::move(target), launch_elevated, base::WideToUTF8(kDaemonIpcSecurityDescriptor))); if (!delegate->Initialize(session_id)) { TerminateSession(); return; } // Create a launcher for the desktop process, using the per-session delegate. launcher_.reset(new WorkerProcessLauncher(std::move(delegate), this)); session_id_ = session_id; } void DesktopSessionWin::OnSessionDetached() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); launcher_.reset(); session_id_ = UINT32_MAX; if (monitoring_notifications_) { ReportElapsedTime("detached"); session_attach_timer_.Start( FROM_HERE, base::TimeDelta::FromSeconds(kSessionAttachTimeoutSeconds), this, &DesktopSessionWin::OnSessionAttachTimeout); } } void DesktopSessionWin::OnDesktopSessionAgentAttached( const IPC::ChannelHandle& desktop_pipe) { if (!daemon_process()->OnDesktopSessionAgentAttached(id(), session_id_, desktop_pipe)) { CrashDesktopProcess(FROM_HERE); } } void DesktopSessionWin::CrashDesktopProcess( const tracked_objects::Location& location) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); launcher_->Crash(location); } void DesktopSessionWin::ReportElapsedTime(const std::string& event) { base::Time now = base::Time::Now(); std::string passed; if (!last_timestamp_.is_null()) { passed = base::StringPrintf(", %.2fs passed", (now - last_timestamp_).InSecondsF()); } base::Time::Exploded exploded; now.LocalExplode(&exploded); VLOG(1) << base::StringPrintf("session(%d): %s at %02d:%02d:%02d.%03d%s", id(), event.c_str(), exploded.hour, exploded.minute, exploded.second, exploded.millisecond, passed.c_str()); last_timestamp_ = now; } } // namespace remoting
[ "xElvis89x@gmail.com" ]
xElvis89x@gmail.com
fa37fb843a317a6e149bd1f4f61c49b125b6e3c6
e5b98edd817712e1dbcabd927cc1fee62c664fd7
/Classes/common/cutViewLayer/CutViewLayer.h
3ebd99327f6634ada4708ae21ec2ceb1675f03ef
[]
no_license
yuangu/project
1a49092221e502bd5f070d7de634e4415c6a2314
cc0b354aaa994c0ee2d20d1e3d74da492063945f
refs/heads/master
2020-05-02T20:09:06.234554
2018-12-18T01:56:36
2018-12-18T01:56:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
919
h
// // CutViewLayer.h // SuiTang // // Created by zhangxiaobin on 14-7-28. // // #ifndef __SuiTang__CutViewLayer__ #define __SuiTang__CutViewLayer__ #include "cocos2d.h" USING_NS_CC; class CutViewLayer:public Layer { public: CutViewLayer(); ~CutViewLayer(); virtual bool init(); virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override; void setCutRect(Rect rect); protected: void beforeDraw(); void onBeforeDraw(); void afterDraw(); void onAfterDraw(); Rect getViewRect(); protected: CustomCommand _beforeDrawCommand; CustomCommand _afterDrawCommand; Size _viewSize; Point _startPos; bool _clippingToBounds; /** * scissor rect for parent, just for restoring GL_SCISSOR_BOX */ Rect _parentScissorRect; bool _scissorRestored; }; #endif /* defined(__SuiTang__CutViewLayer__) */
[ "chenyanbin@ixianlai.com" ]
chenyanbin@ixianlai.com
7d01896cd6595d485bd5e87873eb5bf0f0f8b867
1a8ad862cba5a3a701a29dad8ef283ef3820a150
/337/D[ Book of Evil ].cpp
211104473b9bcf0f5bfdda2a302e3ce09e30d67a
[ "MIT" ]
permissive
iamjanvijay/codeforces-jvj_iit-submissions
4264ef259e3cd385281350798668b8958701e336
2a2aac7e93ca92e75887eff92361174aa36207c8
refs/heads/master
2021-06-24T17:21:51.719587
2017-09-02T14:20:45
2017-09-02T14:20:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,657
cpp
#include <bits/stdc++.h> using namespace std; #define sd(x) scanf("%d",&x) #define su(x) scanf("%u",&x) #define slld(x) scanf("%lld",&x) #define sc(x) scanf("%c",&x) #define ss(x) scanf("%s",x) #define sf(x) scanf("%f",&x) #define slf(x) scanf("%lf",&x) #define ll long long int #define mod(x,n) (x+n)%n #define pb push_back #define mp make_pair #define pii pair<int,int> #define vi vector<int> #define all(a) (a).begin(),(a).end() #define F first #define S second #define sz(x) (int)x.size() #define Mod 1000000007 vector<int> G[100007]; bool isInfec[100007]; int dpDown[100007]; int dpUp[100007]; void dfsDown(int cur, int par) { int i; if(isInfec[cur]) dpDown[cur] = 0; else dpDown[cur] = INT_MIN; for(i=0;i<sz(G[cur]);i++) { if( par!=G[cur][i] ) { dfsDown(G[cur][i], cur); if( dpDown[G[cur][i]] != INT_MIN ) { dpDown[cur] = max( dpDown[cur] , 1 + dpDown[G[cur][i]] ); } } } } void dfsUp(int cur, int par, int now) { int i, max1, max2, ind1, ind2, newnow; dpUp[cur] = now; ind1 = ind2 = 0; max2 = max1 = 0; for(i=0;i<sz(G[cur]);i++) { if( par!=G[cur][i] ) { if( dpDown[ G[cur][i] ] >= max1 ) { max2 = max1; ind2 = ind1; max1 = dpDown[ G[cur][i] ]; ind1 = G[cur][i]; } else { if(dpDown[ G[cur][i] ] >= max2 ) { max2 = dpDown[ G[cur][i] ]; ind2 = G[cur][i]; } } } } for(i=0;i<sz(G[cur]);i++) { if( par!=G[cur][i] ) { newnow = INT_MIN; if(isInfec[cur]) newnow = max(newnow, 1); if(now!=INT_MIN) { newnow = max(newnow, now+((now!=INT_MIN)?1:0) ); } if( ind1!=0 && G[cur][i] != ind1 ) { newnow = max(newnow, max1+((max1!=INT_MIN)?2:0) ); } if( ind2!=0 && G[cur][i] != ind2 ) { newnow = max(newnow, max2+((max1!=INT_MIN)?2:0) ); } dfsUp(G[cur][i], cur, newnow); } } } int main() { // freopen("input_file_name.in","r",stdin); // freopen("output_file_name.out","w",stdout); int i,j,k,l,m,n,x,y,z,a,b,c,d,r; // bool flag; // ll i,j,k,l,m,n,x,y,z,a,b,r; sd(n); sd(m); sd(d); for(i=0;i<m;i++) { sd(x); isInfec[x] = true; } for(i=0;i<n-1;i++) { sd(x); sd(y); G[x].pb(y); G[y].pb(x); } dfsDown(1, 1); dfsUp(1, 1, INT_MIN); // printf("-----------\n"); // for(i=1;i<=n;i++) // { // printf("%d ", dpUp[i] ); // } // printf("\n"); // for(i=1;i<=n;i++) // { // printf("%d ", dpDown[i] ); // } // printf("\n"); for(c=0,i=1;i<=n;i++) { if( max(dpUp[i], dpDown[i]) != INT_MIN && max(dpUp[i], dpDown[i]) <= d ) c++; } printf("%d\n", c ); return 0; }
[ "janvijay.singhcd.cse14@itbhu.ac.in" ]
janvijay.singhcd.cse14@itbhu.ac.in
412c3284f852ffbe96192675077c88ffef60e21a
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function14445/function14445_schedule_21/function14445_schedule_21.cpp
96fc5592235b3e500021698f570fbabb2f57cb88
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
882
cpp
#include <tiramisu/tiramisu.h> using namespace tiramisu; int main(int argc, char **argv){ tiramisu::init("function14445_schedule_21"); constant c0("c0", 128), c1("c1", 256), c2("c2", 1024); var i0("i0", 0, c0), i1("i1", 0, c1), i2("i2", 0, c2), i01("i01"), i02("i02"), i03("i03"), i04("i04"), i05("i05"), i06("i06"); input input00("input00", {i0, i2}, p_int32); computation comp0("comp0", {i0, i1, i2}, input00(i0, i2)); comp0.tile(i0, i1, i2, 32, 64, 32, i01, i02, i03, i04, i05, i06); comp0.parallelize(i01); buffer buf00("buf00", {128, 1024}, p_int32, a_input); buffer buf0("buf0", {128, 256, 1024}, p_int32, a_output); input00.store_in(&buf00); comp0.store_in(&buf0); tiramisu::codegen({&buf00, &buf0}, "../data/programs/function14445/function14445_schedule_21/function14445_schedule_21.o"); return 0; }
[ "ei_mekki@esi.dz" ]
ei_mekki@esi.dz
b67ba3feb7e82d3818efef0945e74f6ff7a1d08a
3159d77c2fc0828025bd0fb6f5d95c91fcbf4cd5
/cpp/cpp_exploration/std_allocator/main.cpp
69bcc6fc359b2e6c9d8ad356d3161027f0174543
[]
no_license
jcmana/playground
50384f4489a23c3a3bb6083bc619e95bd20b17ea
8cf9b9402d38184f1767c4683c6954ae63d818b8
refs/heads/master
2023-09-01T11:26:07.231711
2023-08-21T16:30:16
2023-08-21T16:30:16
152,144,627
1
0
null
2023-08-21T16:21:29
2018-10-08T20:47:39
C++
UTF-8
C++
false
false
1,070
cpp
#include <iostream> #include <set> #include <string> #include <memory> #include <functional> class data { public: data(const std::string & name) : m_name(name) { } ~data() { std::cout << "destructor for " << m_name << std::endl; } public: std::string m_name; }; bool operator < (const data & left, const data & right) { return left.m_name < right.m_name; } template <typename T> class deleting_allocator { public: using value_type = T; using size_type = std::size_t; using pointer = value_type *; public: pointer allocate(size_type n) { return (new sizeof(value_type) * n); } void deallocate(pointer p, size_type n) { delete p; } }; int main() { // by value: if (false) { std::set<data> dataset; // dataset.emplace("a"); dataset.insert(data("b")); // dataset.insert(std::move(data("c"))); } // by pointer: if (true) { std::set<data *, std::less<data *>, std::allocator<data *>> dataset; //dataset.emplace(new data("a")); dataset.insert(new data("b")); //dataset.insert(std::move(new data("c"))); } return 0; }
[ "jiri.manasek@tescan.com" ]
jiri.manasek@tescan.com
d2252221849b0298db8f6a9f84b6e76f06f165fb
14b6260099c955ac143d2d47dfae77e0d1a3a6c0
/Modul4/tugas.cpp
8dc123b92676a825354a03f0176aaa8b3afcb312
[]
no_license
afmaghribi/Praktikum-Prolan
b6e06a175dc480a6f7dc0d797487df9003b91130
4e12a9ee120e0a7a0168bf518721231760872583
refs/heads/master
2020-06-12T23:27:30.955065
2019-06-30T00:43:44
2019-06-30T00:43:44
194,460,198
0
0
null
null
null
null
UTF-8
C++
false
false
989
cpp
#include <iostream> #include <fstream> using namespace std; typedef struct{ char nama[20]; int nim; char kelas[20]; } Mahasiswa; int main(){ ofstream save; Mahasiswa mhs[2]; int i; cout << "----------------------\nAHMAD FAUZZAN MAGHRIBI\n----------------------\n\n"; for(i=0;i<2;i++){ cout << "Data ke-" << i+1 << endl; cout << "Nama : "; cin >> mhs[i].nama; cout << "NIM : "; cin >> mhs[i].nim; cout << "Kelas : "; cin >> mhs[i].kelas; } cout << "Data Mahasiswa\n"; cout << "|\tNama\t|\tNIM\t|\tKelas\t|\n"; for(i=0;i<2;i++){ cout << "|\t" << mhs[i].nama << "\t|\t" << mhs[i].nim << "\t|\t" << mhs[i].kelas << "\t|\n"; } save.open("17101044.ahm"); save << "Data Mahasiswa\n"; save << "|\tNama\t|\tNIM\t|\tKelas\t|\n"; for(i=0;i<2;i++){ save << "|\t" << mhs[i].nama << "\t|\t" << mhs[i].nim << "\t|\t" << mhs[i].kelas << "\t|\n"; } save.close(); return 0; }
[ "af.maghribi@gmail.com" ]
af.maghribi@gmail.com
07551e89a61f5f9a077af6d63850113f2e2117e1
64684646c96123397d60052d7d04bb370a182b42
/game/dragon3d-core/src/com/dragon3d/output/audio/Speaker.cc
e91f6c81aa9548569b798a69bda4b6b6546d7ab7
[]
no_license
yubing744/dragon
e6ca32726df8fe8e9e1d0586058b8628245efb55
eca9b4b6823c98ddc56ccedde486099653b13920
refs/heads/master
2020-05-22T09:11:15.052073
2017-01-02T01:30:53
2017-01-02T01:30:53
33,351,592
4
1
null
null
null
null
UTF-8
C++
false
false
1,599
cc
/* * Copyright 2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /********************************************************************** * Author: Owen Wu/wcw/yubing * Email: yubing744@163.com * Created: 2013/09/28 **********************************************************************/ #include <dragon/util/logging/Logger.h> #include <com/dragon3d/output/audio/Speaker.h> Import dragon::util::logging; Import com::dragon3d::output::audio; const Type* Speaker::TYPE = TypeOf<Speaker>(); static Logger* logger = Logger::getLogger(Speaker::TYPE, ERROR); Speaker::Speaker() { this->controller = new AudioOutputController(); } Speaker::~Speaker() { SafeDelete(this->controller); } void Speaker::init() { logger->info("init"); this->controller->init(); } int Speaker::queryStatus(int code) { return -1; } OutputController* Speaker::getOutputController() { return this->controller; } void* Speaker::getNativeData() { } void Speaker::destroy() { logger->info("destroy"); this->controller->destroy(); }
[ "yubing744@163.com" ]
yubing744@163.com
fe37baaab624f94c63485d5362bc8d9359e85298
5a5328c0ad39230779aa52c9ae57ec193b88941e
/tesseract4android/src/main/cpp/tesseract/src/src/ccmain/fixspace.cpp
dee79395b3023649f0c7ff341b6aee1e2a4782af
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
adaptech-cz/Tesseract4Android
66978579ccc80587b8a0ae3eebe79f152fa382cd
8ae584f54502d5457c8b9d62401eaa99551352c3
refs/heads/master
2023-07-21T16:49:39.617935
2023-07-18T12:13:29
2023-07-18T12:13:29
168,021,668
517
101
Apache-2.0
2021-03-29T11:52:21
2019-01-28T19:21:34
C
UTF-8
C++
false
false
30,244
cpp
/****************************************************************** * File: fixspace.cpp (Formerly fixspace.c) * Description: Implements a pass over the page res, exploring the alternative * spacing possibilities, trying to use context to improve the * word spacing * Author: Phil Cheatle * * (C) Copyright 1993, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. * **********************************************************************/ #include "fixspace.h" #include "blobs.h" // for TWERD, TBLOB, TESSLINE #include "boxword.h" // for BoxWord #include "errcode.h" // for ASSERT_HOST #include "normalis.h" // for kBlnXHeight, kBlnBaselineOffset #include "pageres.h" // for WERD_RES_IT, WERD_RES, WERD_RES_LIST #include "params.h" // for IntParam, StringParam, BoolParam, DoubleParam, ... #include "ratngs.h" // for WERD_CHOICE, FREQ_DAWG_PERM, NUMBER_PERM #include "rect.h" // for TBOX #include "stepblob.h" // for C_BLOB_IT, C_BLOB_LIST, C_BLOB #include "tesseractclass.h" // for Tesseract, TesseractStats, WordData #include "tessvars.h" // for debug_fp #include "tprintf.h" // for tprintf #include "unicharset.h" // for UNICHARSET #include "werd.h" // for WERD, W_EOL, W_FUZZY_NON, W_FUZZY_SP #include <tesseract/ocrclass.h> // for ETEXT_DESC #include <tesseract/unichar.h> // for UNICHAR_ID #include <cstdint> // for INT16_MAX, int16_t, int32_t namespace tesseract { class BLOCK; class ROW; #define PERFECT_WERDS 999 /********************************************************************** * c_blob_comparator() * * Blob comparator used to sort a blob list so that blobs are in increasing * order of left edge. **********************************************************************/ static int c_blob_comparator( // sort blobs const void *blob1p, // ptr to ptr to blob1 const void *blob2p // ptr to ptr to blob2 ) { const C_BLOB *blob1 = *reinterpret_cast<const C_BLOB *const *>(blob1p); const C_BLOB *blob2 = *reinterpret_cast<const C_BLOB *const *>(blob2p); return blob1->bounding_box().left() - blob2->bounding_box().left(); } /** * @name fix_fuzzy_spaces() * Walk over the page finding sequences of words joined by fuzzy spaces. Extract * them as a sublist, process the sublist to find the optimal arrangement of * spaces then replace the sublist in the ROW_RES. * * @param monitor progress monitor * @param word_count count of words in doc * @param[out] page_res */ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor, int32_t word_count, PAGE_RES *page_res) { BLOCK_RES_IT block_res_it; ROW_RES_IT row_res_it; WERD_RES_IT word_res_it_from; WERD_RES_IT word_res_it_to; WERD_RES *word_res; WERD_RES_LIST fuzzy_space_words; int16_t new_length; bool prevent_null_wd_fixsp; // DON'T process blobless wds int32_t word_index; // current word block_res_it.set_to_list(&page_res->block_res_list); word_index = 0; for (block_res_it.mark_cycle_pt(); !block_res_it.cycled_list(); block_res_it.forward()) { row_res_it.set_to_list(&block_res_it.data()->row_res_list); for (row_res_it.mark_cycle_pt(); !row_res_it.cycled_list(); row_res_it.forward()) { word_res_it_from.set_to_list(&row_res_it.data()->word_res_list); while (!word_res_it_from.at_last()) { word_res = word_res_it_from.data(); while (!word_res_it_from.at_last() && !(word_res->combination || word_res_it_from.data_relative(1)->word->flag(W_FUZZY_NON) || word_res_it_from.data_relative(1)->word->flag(W_FUZZY_SP))) { fix_sp_fp_word(word_res_it_from, row_res_it.data()->row, block_res_it.data()->block); word_res = word_res_it_from.forward(); word_index++; if (monitor != nullptr) { monitor->ocr_alive = true; monitor->progress = 90 + 5 * word_index / word_count; if (monitor->deadline_exceeded() || (monitor->cancel != nullptr && (*monitor->cancel)(monitor->cancel_this, stats_.dict_words))) { return; } } } if (!word_res_it_from.at_last()) { word_res_it_to = word_res_it_from; prevent_null_wd_fixsp = word_res->word->cblob_list()->empty(); if (check_debug_pt(word_res, 60)) { debug_fix_space_level.set_value(10); } word_res_it_to.forward(); word_index++; if (monitor != nullptr) { monitor->ocr_alive = true; monitor->progress = 90 + 5 * word_index / word_count; if (monitor->deadline_exceeded() || (monitor->cancel != nullptr && (*monitor->cancel)(monitor->cancel_this, stats_.dict_words))) { return; } } while (!word_res_it_to.at_last() && (word_res_it_to.data_relative(1)->word->flag(W_FUZZY_NON) || word_res_it_to.data_relative(1)->word->flag(W_FUZZY_SP))) { if (check_debug_pt(word_res, 60)) { debug_fix_space_level.set_value(10); } if (word_res->word->cblob_list()->empty()) { prevent_null_wd_fixsp = true; } word_res = word_res_it_to.forward(); } if (check_debug_pt(word_res, 60)) { debug_fix_space_level.set_value(10); } if (word_res->word->cblob_list()->empty()) { prevent_null_wd_fixsp = true; } if (prevent_null_wd_fixsp) { word_res_it_from = word_res_it_to; } else { fuzzy_space_words.assign_to_sublist(&word_res_it_from, &word_res_it_to); fix_fuzzy_space_list(fuzzy_space_words, row_res_it.data()->row, block_res_it.data()->block); new_length = fuzzy_space_words.length(); word_res_it_from.add_list_before(&fuzzy_space_words); for (; !word_res_it_from.at_last() && new_length > 0; new_length--) { word_res_it_from.forward(); } } if (test_pt) { debug_fix_space_level.set_value(0); } } fix_sp_fp_word(word_res_it_from, row_res_it.data()->row, block_res_it.data()->block); // Last word in row } } } } void Tesseract::fix_fuzzy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK *block) { int16_t best_score; WERD_RES_LIST current_perm; int16_t current_score; bool improved = false; best_score = eval_word_spacing(best_perm); // default score dump_words(best_perm, best_score, 1, improved); if (best_score != PERFECT_WERDS) { initialise_search(best_perm, current_perm); } while ((best_score != PERFECT_WERDS) && !current_perm.empty()) { match_current_words(current_perm, row, block); current_score = eval_word_spacing(current_perm); dump_words(current_perm, current_score, 2, improved); if (current_score > best_score) { best_perm.clear(); best_perm.deep_copy(&current_perm, &WERD_RES::deep_copy); best_score = current_score; improved = true; } if (current_score < PERFECT_WERDS) { transform_to_next_perm(current_perm); } } dump_words(best_perm, best_score, 3, improved); } void initialise_search(WERD_RES_LIST &src_list, WERD_RES_LIST &new_list) { WERD_RES_IT src_it(&src_list); WERD_RES_IT new_it(&new_list); WERD_RES *src_wd; WERD_RES *new_wd; for (src_it.mark_cycle_pt(); !src_it.cycled_list(); src_it.forward()) { src_wd = src_it.data(); if (!src_wd->combination) { new_wd = WERD_RES::deep_copy(src_wd); new_wd->combination = false; new_wd->part_of_combo = false; new_it.add_after_then_move(new_wd); } } } void Tesseract::match_current_words(WERD_RES_LIST &words, ROW *row, BLOCK *block) { WERD_RES_IT word_it(&words); WERD_RES *word; // Since we are not using PAGE_RES to iterate over words, we need to update // prev_word_best_choice_ before calling classify_word_pass2(). prev_word_best_choice_ = nullptr; for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) { word = word_it.data(); if ((!word->part_of_combo) && (word->box_word == nullptr)) { WordData word_data(block, row, word); SetupWordPassN(2, &word_data); classify_word_and_language(2, nullptr, &word_data); } prev_word_best_choice_ = word->best_choice; } } /** * @name eval_word_spacing() * The basic measure is the number of characters in contextually confirmed * words. (I.e the word is done) * If all words are contextually confirmed the evaluation is deemed perfect. * * Some fiddles are done to handle "1"s as these are VERY frequent causes of * fuzzy spaces. The problem with the basic measure is that "561 63" would score * the same as "56163", though given our knowledge that the space is fuzzy, and * that there is a "1" next to the fuzzy space, we need to ensure that "56163" * is preferred. * * The solution is to NOT COUNT the score of any word which has a digit at one * end and a "1Il" as the character the other side of the space. * * Conversely, any character next to a "1" within a word is counted as a * positive score. Thus "561 63" would score 4 (3 chars in a numeric word plus 1 * side of the "1" joined). "56163" would score 7 - all chars in a numeric word * + 2 sides of a "1" joined. * * The joined 1 rule is applied to any word REGARDLESS of contextual * confirmation. Thus "PS7a71 3/7a" scores 1 (neither word is contexutally * confirmed. The only score is from the joined 1. "PS7a713/7a" scores 2. * */ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { WERD_RES_IT word_res_it(&word_res_list); int16_t total_score = 0; int16_t word_count = 0; int16_t done_word_count = 0; int i; int16_t offset; int16_t prev_word_score = 0; bool prev_word_done = false; bool prev_char_1 = false; // prev ch a "1/I/l"? bool prev_char_digit = false; // prev ch 2..9 or 0 const char *punct_chars = "!\"`',.:;"; bool prev_char_punct = false; do { // current word WERD_RES *word = word_res_it.data(); bool word_done = fixspace_thinks_word_done(word); word_count++; if (word->tess_failed) { total_score += prev_word_score; if (prev_word_done) { done_word_count++; } prev_word_score = 0; prev_char_1 = false; prev_char_digit = false; prev_word_done = false; } else { /* Can we add the prev word score and potentially count this word? Yes IF it didn't end in a 1 when the first char of this word is a digit AND it didn't end in a digit when the first char of this word is a 1 */ auto word_len = word->reject_map.length(); bool current_word_ok_so_far = false; if (!((prev_char_1 && digit_or_numeric_punct(word, 0)) || (prev_char_digit && ((word_done && word->best_choice->unichar_lengths().c_str()[0] == 1 && word->best_choice->unichar_string()[0] == '1') || (!word_done && conflict_set_I_l_1.contains(word->best_choice->unichar_string()[0])))))) { total_score += prev_word_score; if (prev_word_done) { done_word_count++; } current_word_ok_so_far = word_done; } if (current_word_ok_so_far) { prev_word_done = true; prev_word_score = word_len; } else { prev_word_done = false; prev_word_score = 0; } /* Add 1 to total score for every joined 1 regardless of context and rejtn */ for (i = 0, prev_char_1 = false; i < word_len; i++) { bool current_char_1 = word->best_choice->unichar_string()[i] == '1'; if (prev_char_1 || (current_char_1 && (i > 0))) { total_score++; } prev_char_1 = current_char_1; } /* Add 1 to total score for every joined punctuation regardless of context and rejtn */ if (tessedit_prefer_joined_punct) { for (i = 0, offset = 0, prev_char_punct = false; i < word_len; offset += word->best_choice->unichar_lengths()[i++]) { bool current_char_punct = strchr(punct_chars, word->best_choice->unichar_string()[offset]) != nullptr; if (prev_char_punct || (current_char_punct && i > 0)) { total_score++; } prev_char_punct = current_char_punct; } } prev_char_digit = digit_or_numeric_punct(word, word_len - 1); for (i = 0, offset = 0; i < word_len - 1; offset += word->best_choice->unichar_lengths()[i++]) { ; } prev_char_1 = ((word_done && (word->best_choice->unichar_string()[offset] == '1')) || (!word_done && conflict_set_I_l_1.contains(word->best_choice->unichar_string()[offset]))); } /* Find next word */ do { word_res_it.forward(); } while (word_res_it.data()->part_of_combo); } while (!word_res_it.at_first()); total_score += prev_word_score; if (prev_word_done) { done_word_count++; } if (done_word_count == word_count) { return PERFECT_WERDS; } else { return total_score; } } bool Tesseract::digit_or_numeric_punct(WERD_RES *word, int char_position) { int i; int offset; for (i = 0, offset = 0; i < char_position; offset += word->best_choice->unichar_lengths()[i++]) { ; } return ( word->uch_set->get_isdigit(word->best_choice->unichar_string().c_str() + offset, word->best_choice->unichar_lengths()[i]) || (word->best_choice->permuter() == NUMBER_PERM && numeric_punctuation.contains(word->best_choice->unichar_string().c_str()[offset]))); } /** * @name transform_to_next_perm() * Examines the current word list to find the smallest word gap size. Then walks * the word list closing any gaps of this size by either inserted new * combination words, or extending existing ones. * * The routine COULD be limited to stop it building words longer than N blobs. * * If there are no more gaps then it DELETES the entire list and returns the * empty list to cause termination. */ void transform_to_next_perm(WERD_RES_LIST &words) { WERD_RES_IT word_it(&words); WERD_RES_IT prev_word_it(&words); WERD_RES *word; WERD_RES *prev_word; WERD_RES *combo; WERD *copy_word; int16_t prev_right = -INT16_MAX; TBOX box; int16_t gap; int16_t min_gap = INT16_MAX; for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) { word = word_it.data(); if (!word->part_of_combo) { box = word->word->bounding_box(); if (prev_right > -INT16_MAX) { gap = box.left() - prev_right; if (gap < min_gap) { min_gap = gap; } } prev_right = box.right(); } } if (min_gap < INT16_MAX) { prev_right = -INT16_MAX; // back to start word_it.set_to_list(&words); // Note: we can't use cycle_pt due to inserted combos at start of list. for (; (prev_right == -INT16_MAX) || !word_it.at_first(); word_it.forward()) { word = word_it.data(); if (!word->part_of_combo) { box = word->word->bounding_box(); if (prev_right > -INT16_MAX) { gap = box.left() - prev_right; if (gap <= min_gap) { prev_word = prev_word_it.data(); if (prev_word->combination) { combo = prev_word; } else { /* Make a new combination and insert before * the first word being joined. */ copy_word = new WERD; *copy_word = *(prev_word->word); // deep copy combo = new WERD_RES(copy_word); combo->combination = true; combo->x_height = prev_word->x_height; prev_word->part_of_combo = true; prev_word_it.add_before_then_move(combo); } combo->word->set_flag(W_EOL, word->word->flag(W_EOL)); if (word->combination) { combo->word->join_on(word->word); // Move blobs to combo // old combo no longer needed delete word_it.extract(); } else { // Copy current wd to combo combo->copy_on(word); word->part_of_combo = true; } combo->done = false; combo->ClearResults(); } else { prev_word_it = word_it; // catch up } } prev_right = box.right(); } } } else { words.clear(); // signal termination } } void Tesseract::dump_words(WERD_RES_LIST &perm, int16_t score, int16_t mode, bool improved) { WERD_RES_IT word_res_it(&perm); if (debug_fix_space_level > 0) { if (mode == 1) { stats_.dump_words_str = ""; for (word_res_it.mark_cycle_pt(); !word_res_it.cycled_list(); word_res_it.forward()) { if (!word_res_it.data()->part_of_combo) { stats_.dump_words_str += word_res_it.data()->best_choice->unichar_string(); stats_.dump_words_str += ' '; } } } if (debug_fix_space_level > 1) { switch (mode) { case 1: tprintf("EXTRACTED (%d): \"", score); break; case 2: tprintf("TESTED (%d): \"", score); break; case 3: tprintf("RETURNED (%d): \"", score); break; } for (word_res_it.mark_cycle_pt(); !word_res_it.cycled_list(); word_res_it.forward()) { if (!word_res_it.data()->part_of_combo) { tprintf("%s/%1d ", word_res_it.data()->best_choice->unichar_string().c_str(), static_cast<int>(word_res_it.data()->best_choice->permuter())); } } tprintf("\"\n"); } else if (improved) { tprintf("FIX SPACING \"%s\" => \"", stats_.dump_words_str.c_str()); for (word_res_it.mark_cycle_pt(); !word_res_it.cycled_list(); word_res_it.forward()) { if (!word_res_it.data()->part_of_combo) { tprintf("%s/%1d ", word_res_it.data()->best_choice->unichar_string().c_str(), static_cast<int>(word_res_it.data()->best_choice->permuter())); } } tprintf("\"\n"); } } } bool Tesseract::fixspace_thinks_word_done(WERD_RES *word) { if (word->done) { return true; } /* Use all the standard pass 2 conditions for mode 5 in set_done() in reject.c BUT DON'T REJECT IF THE WERD IS AMBIGUOUS - FOR SPACING WE DON'T CARE WHETHER WE HAVE of/at on/an etc. */ if (fixsp_done_mode > 0 && (word->tess_accepted || (fixsp_done_mode == 2 && word->reject_map.reject_count() == 0) || fixsp_done_mode == 3) && (strchr(word->best_choice->unichar_string().c_str(), ' ') == nullptr) && ((word->best_choice->permuter() == SYSTEM_DAWG_PERM) || (word->best_choice->permuter() == FREQ_DAWG_PERM) || (word->best_choice->permuter() == USER_DAWG_PERM) || (word->best_choice->permuter() == NUMBER_PERM))) { return true; } else { return false; } } /** * @name fix_sp_fp_word() * Test the current word to see if it can be split by deleting noise blobs. If * so, do the business. * Return with the iterator pointing to the same place if the word is unchanged, * or the last of the replacement words. */ void Tesseract::fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row, BLOCK *block) { WERD_RES *word_res; WERD_RES_LIST sub_word_list; WERD_RES_IT sub_word_list_it(&sub_word_list); int16_t blob_index; int16_t new_length; float junk; word_res = word_res_it.data(); if (word_res->word->flag(W_REP_CHAR) || word_res->combination || word_res->part_of_combo || !word_res->word->flag(W_DONT_CHOP)) { return; } blob_index = worst_noise_blob(word_res, &junk); if (blob_index < 0) { return; } if (debug_fix_space_level > 1) { tprintf("FP fixspace working on \"%s\"\n", word_res->best_choice->unichar_string().c_str()); } word_res->word->rej_cblob_list()->sort(c_blob_comparator); sub_word_list_it.add_after_stay_put(word_res_it.extract()); fix_noisy_space_list(sub_word_list, row, block); new_length = sub_word_list.length(); word_res_it.add_list_before(&sub_word_list); for (; !word_res_it.at_last() && new_length > 1; new_length--) { word_res_it.forward(); } } void Tesseract::fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK *block) { int16_t best_score; WERD_RES_IT best_perm_it(&best_perm); WERD_RES_LIST current_perm; WERD_RES_IT current_perm_it(&current_perm); WERD_RES *old_word_res; int16_t current_score; bool improved = false; best_score = fp_eval_word_spacing(best_perm); // default score dump_words(best_perm, best_score, 1, improved); old_word_res = best_perm_it.data(); // Even deep_copy doesn't copy the underlying WERD unless its combination // flag is true!. old_word_res->combination = true; // Kludge to force deep copy current_perm_it.add_to_end(WERD_RES::deep_copy(old_word_res)); old_word_res->combination = false; // Undo kludge break_noisiest_blob_word(current_perm); while (best_score != PERFECT_WERDS && !current_perm.empty()) { match_current_words(current_perm, row, block); current_score = fp_eval_word_spacing(current_perm); dump_words(current_perm, current_score, 2, improved); if (current_score > best_score) { best_perm.clear(); best_perm.deep_copy(&current_perm, &WERD_RES::deep_copy); best_score = current_score; improved = true; } if (current_score < PERFECT_WERDS) { break_noisiest_blob_word(current_perm); } } dump_words(best_perm, best_score, 3, improved); } /** * break_noisiest_blob_word() * Find the word with the blob which looks like the worst noise. * Break the word into two, deleting the noise blob. */ void Tesseract::break_noisiest_blob_word(WERD_RES_LIST &words) { WERD_RES_IT word_it(&words); WERD_RES_IT worst_word_it; float worst_noise_score = 9999; int worst_blob_index = -1; // Noisiest blob of noisiest wd int blob_index; // of wds noisiest blob float noise_score; // of wds noisiest blob WERD_RES *word_res; C_BLOB_IT blob_it; C_BLOB_IT rej_cblob_it; C_BLOB_LIST new_blob_list; C_BLOB_IT new_blob_it; C_BLOB_IT new_rej_cblob_it; WERD *new_word; int16_t start_of_noise_blob; int16_t i; for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) { blob_index = worst_noise_blob(word_it.data(), &noise_score); if (blob_index > -1 && worst_noise_score > noise_score) { worst_noise_score = noise_score; worst_blob_index = blob_index; worst_word_it = word_it; } } if (worst_blob_index < 0) { words.clear(); // signal termination return; } /* Now split the worst_word_it */ word_res = worst_word_it.data(); /* Move blobs before noise blob to a new bloblist */ new_blob_it.set_to_list(&new_blob_list); blob_it.set_to_list(word_res->word->cblob_list()); for (i = 0; i < worst_blob_index; i++, blob_it.forward()) { new_blob_it.add_after_then_move(blob_it.extract()); } start_of_noise_blob = blob_it.data()->bounding_box().left(); delete blob_it.extract(); // throw out noise blob new_word = new WERD(&new_blob_list, word_res->word); new_word->set_flag(W_EOL, false); word_res->word->set_flag(W_BOL, false); word_res->word->set_blanks(1); // After break new_rej_cblob_it.set_to_list(new_word->rej_cblob_list()); rej_cblob_it.set_to_list(word_res->word->rej_cblob_list()); for (; (!rej_cblob_it.empty() && (rej_cblob_it.data()->bounding_box().left() < start_of_noise_blob)); rej_cblob_it.forward()) { new_rej_cblob_it.add_after_then_move(rej_cblob_it.extract()); } auto *new_word_res = new WERD_RES(new_word); new_word_res->combination = true; worst_word_it.add_before_then_move(new_word_res); word_res->ClearResults(); } int16_t Tesseract::worst_noise_blob(WERD_RES *word_res, float *worst_noise_score) { float noise_score[512]; int min_noise_blob; // 1st contender int max_noise_blob; // last contender int non_noise_count; int worst_noise_blob; // Worst blob float small_limit = kBlnXHeight * fixsp_small_outlines_size; float non_noise_limit = kBlnXHeight * 0.8; if (word_res->rebuild_word == nullptr) { return -1; // Can't handle cube words. } // Normalised. auto blob_count = word_res->box_word->length(); ASSERT_HOST(blob_count <= 512); if (blob_count < 5) { return -1; // too short to split } /* Get the noise scores for all blobs */ #ifndef SECURE_NAMES if (debug_fix_space_level > 5) { tprintf("FP fixspace Noise metrics for \"%s\": ", word_res->best_choice->unichar_string().c_str()); } #endif for (unsigned i = 0; i < blob_count && i < word_res->rebuild_word->NumBlobs(); i++) { TBLOB *blob = word_res->rebuild_word->blobs[i]; if (word_res->reject_map[i].accepted()) { noise_score[i] = non_noise_limit; } else { noise_score[i] = blob_noise_score(blob); } if (debug_fix_space_level > 5) { tprintf("%1.1f ", noise_score[i]); } } if (debug_fix_space_level > 5) { tprintf("\n"); } /* Now find the worst one which is far enough away from the end of the word */ non_noise_count = 0; int i; for (i = 0; static_cast<unsigned>(i) < blob_count && non_noise_count < fixsp_non_noise_limit; i++) { if (noise_score[i] >= non_noise_limit) { non_noise_count++; } } if (non_noise_count < fixsp_non_noise_limit) { return -1; } min_noise_blob = i; non_noise_count = 0; for (i = blob_count - 1; i >= 0 && non_noise_count < fixsp_non_noise_limit; i--) { if (noise_score[i] >= non_noise_limit) { non_noise_count++; } } if (non_noise_count < fixsp_non_noise_limit) { return -1; } max_noise_blob = i; if (min_noise_blob > max_noise_blob) { return -1; } *worst_noise_score = small_limit; worst_noise_blob = -1; for (auto i = min_noise_blob; i <= max_noise_blob; i++) { if (noise_score[i] < *worst_noise_score) { worst_noise_blob = i; *worst_noise_score = noise_score[i]; } } return worst_noise_blob; } float Tesseract::blob_noise_score(TBLOB *blob) { TBOX box; // BB of outline int16_t outline_count = 0; int16_t max_dimension; int16_t largest_outline_dimension = 0; for (TESSLINE *ol = blob->outlines; ol != nullptr; ol = ol->next) { outline_count++; box = ol->bounding_box(); if (box.height() > box.width()) { max_dimension = box.height(); } else { max_dimension = box.width(); } if (largest_outline_dimension < max_dimension) { largest_outline_dimension = max_dimension; } } if (outline_count > 5) { // penalise LOTS of blobs largest_outline_dimension *= 2; } box = blob->bounding_box(); if (box.bottom() > kBlnBaselineOffset * 4 || box.top() < kBlnBaselineOffset / 2) { // Lax blob is if high or low largest_outline_dimension /= 2; } return largest_outline_dimension; } void fixspace_dbg(WERD_RES *word) { TBOX box = word->word->bounding_box(); const bool show_map_detail = false; int16_t i; box.print(); tprintf(" \"%s\" ", word->best_choice->unichar_string().c_str()); tprintf("Blob count: %d (word); %d/%d (rebuild word)\n", word->word->cblob_list()->length(), word->rebuild_word->NumBlobs(), word->box_word->length()); word->reject_map.print(debug_fp); tprintf("\n"); if (show_map_detail) { tprintf("\"%s\"\n", word->best_choice->unichar_string().c_str()); for (i = 0; word->best_choice->unichar_string()[i] != '\0'; i++) { tprintf("**** \"%c\" ****\n", word->best_choice->unichar_string()[i]); word->reject_map[i].full_print(debug_fp); } } tprintf("Tess Accepted: %s\n", word->tess_accepted ? "TRUE" : "FALSE"); tprintf("Done flag: %s\n\n", word->done ? "TRUE" : "FALSE"); } /** * fp_eval_word_spacing() * Evaluation function for fixed pitch word lists. * * Basically, count the number of "nice" characters - those which are in tess * acceptable words or in dict words and are not rejected. * Penalise any potential noise chars */ int16_t Tesseract::fp_eval_word_spacing(WERD_RES_LIST &word_res_list) { WERD_RES_IT word_it(&word_res_list); WERD_RES *word; int16_t score = 0; float small_limit = kBlnXHeight * fixsp_small_outlines_size; for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) { word = word_it.data(); if (word->rebuild_word == nullptr) { continue; // Can't handle cube words. } if (word->done || word->tess_accepted || word->best_choice->permuter() == SYSTEM_DAWG_PERM || word->best_choice->permuter() == FREQ_DAWG_PERM || word->best_choice->permuter() == USER_DAWG_PERM || safe_dict_word(word) > 0) { auto num_blobs = word->rebuild_word->NumBlobs(); UNICHAR_ID space = word->uch_set->unichar_to_id(" "); for (unsigned i = 0; i < word->best_choice->length() && i < num_blobs; ++i) { TBLOB *blob = word->rebuild_word->blobs[i]; if (word->best_choice->unichar_id(i) == space || blob_noise_score(blob) < small_limit) { score -= 1; // penalise possibly erroneous non-space } else if (word->reject_map[i].accepted()) { score++; } } } } if (score < 0) { score = 0; } return score; } } // namespace tesseract
[ "posel@adaptech.cz" ]
posel@adaptech.cz
0224a353a22f8e0dfd292e8cc83169c4532af9e7
d939ea588d1b215261b92013e050993b21651f9a
/iotvideo/src/v20201215/model/DescribeFirmwareTaskDistributionRequest.cpp
0038b7f099ff88c3e9f982ae652099a607e01787
[ "Apache-2.0" ]
permissive
chenxx98/tencentcloud-sdk-cpp
374e6d1349f8992893ded7aa08f911dd281f1bda
a9e75d321d96504bc3437300d26e371f5f4580a0
refs/heads/master
2023-03-27T05:35:50.158432
2021-03-26T05:18:10
2021-03-26T05:18:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,335
cpp
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <tencentcloud/iotvideo/v20201215/model/DescribeFirmwareTaskDistributionRequest.h> #include <tencentcloud/core/utils/rapidjson/document.h> #include <tencentcloud/core/utils/rapidjson/writer.h> #include <tencentcloud/core/utils/rapidjson/stringbuffer.h> using namespace TencentCloud::Iotvideo::V20201215::Model; using namespace rapidjson; using namespace std; DescribeFirmwareTaskDistributionRequest::DescribeFirmwareTaskDistributionRequest() : m_productIDHasBeenSet(false), m_firmwareVersionHasBeenSet(false), m_taskIdHasBeenSet(false) { } string DescribeFirmwareTaskDistributionRequest::ToJsonString() const { Document d; d.SetObject(); Document::AllocatorType& allocator = d.GetAllocator(); if (m_productIDHasBeenSet) { Value iKey(kStringType); string key = "ProductID"; iKey.SetString(key.c_str(), allocator); d.AddMember(iKey, Value(m_productID.c_str(), allocator).Move(), allocator); } if (m_firmwareVersionHasBeenSet) { Value iKey(kStringType); string key = "FirmwareVersion"; iKey.SetString(key.c_str(), allocator); d.AddMember(iKey, Value(m_firmwareVersion.c_str(), allocator).Move(), allocator); } if (m_taskIdHasBeenSet) { Value iKey(kStringType); string key = "TaskId"; iKey.SetString(key.c_str(), allocator); d.AddMember(iKey, m_taskId, allocator); } StringBuffer buffer; Writer<StringBuffer> writer(buffer); d.Accept(writer); return buffer.GetString(); } string DescribeFirmwareTaskDistributionRequest::GetProductID() const { return m_productID; } void DescribeFirmwareTaskDistributionRequest::SetProductID(const string& _productID) { m_productID = _productID; m_productIDHasBeenSet = true; } bool DescribeFirmwareTaskDistributionRequest::ProductIDHasBeenSet() const { return m_productIDHasBeenSet; } string DescribeFirmwareTaskDistributionRequest::GetFirmwareVersion() const { return m_firmwareVersion; } void DescribeFirmwareTaskDistributionRequest::SetFirmwareVersion(const string& _firmwareVersion) { m_firmwareVersion = _firmwareVersion; m_firmwareVersionHasBeenSet = true; } bool DescribeFirmwareTaskDistributionRequest::FirmwareVersionHasBeenSet() const { return m_firmwareVersionHasBeenSet; } uint64_t DescribeFirmwareTaskDistributionRequest::GetTaskId() const { return m_taskId; } void DescribeFirmwareTaskDistributionRequest::SetTaskId(const uint64_t& _taskId) { m_taskId = _taskId; m_taskIdHasBeenSet = true; } bool DescribeFirmwareTaskDistributionRequest::TaskIdHasBeenSet() const { return m_taskIdHasBeenSet; }
[ "tencentcloudapi@tenent.com" ]
tencentcloudapi@tenent.com
4d4b611b33c099cff4e16f18194c333c100d3c1d
3cf9f927fbc747090091642d37fb803b606b7e2f
/ext/include/Spriter/objectinfo/spriteobjectinfo.h
16f80b69680d0b0abbec3f9ea51ff5cdecdde347
[]
no_license
Breush/evilly-evil-villains
d734dd7ce97c727fab8e4a67097170ef7f381d22
f499963e9c2cfdc7c4fed42ca7b8c3d2bc7ecbe9
refs/heads/master
2022-07-09T18:24:18.996382
2022-06-22T07:08:38
2022-06-22T07:08:38
29,420,434
0
0
null
null
null
null
UTF-8
C++
false
false
1,325
h
#ifndef SPRITEOBJECTINFO_H #define SPRITEOBJECTINFO_H #include "universalobjectinterface.h" #include "../override/imagefile.h" #include "angleinfo.h" namespace SpriterEngine { class SpriteObjectInfo final : public UniversalObjectInterface { public: SpriteObjectInfo(); point getPosition() override; real getAngle() override; point getScale() override; real getAlpha() override; point getPivot() override; ImageFile *getImage() override; void setPosition(const point &newPosition) override; void setAngle(real newAngle) override; void setScale(const point &newScale) override; void setAlpha(real newAlpha) override; void setPivot(const point &newPivot) override; void setImage(ImageFile *newImageFile) override; void setSpin(int newSpin) override; void setToBlendedLinear(UniversalObjectInterface * aObject, UniversalObjectInterface * bObject, real t, real blendRatio) override; void render(sf::RenderTarget& target, sf::RenderStates& states, const sf::Color& tiltColor) override; private: point position; AngleInfo angle; point scale; real alpha; point pivot; ImageFile *imageFile; }; } #endif // SPRITEOBJECTINFO_H
[ "alexis.breust@gmail.com" ]
alexis.breust@gmail.com
ea0df07072987c45779d70dda0e9055a8bd61f69
5a24631e5bf7162a3ce2789b72dba9d794b54c08
/Conv1.cpp
eaa6ac668a9edf586c662e55a330bf71e2da0a70
[]
no_license
Ngangolo/Exo_gestion_annuaire
92c6c17453412ffa0b6f9f052a95934fee7898e6
8f568d1479828422fd65d1d23254fb0a79121dcb
refs/heads/main
2023-03-06T10:06:26.789380
2021-02-17T01:22:40
2021-02-17T01:22:40
339,572,325
0
0
null
null
null
null
UTF-8
C++
false
false
5,627
cpp
#include<stdio.h> #include<stdlib.h> #include<time.h> void convheureminuteseconde(float *heure,float *minute, float *seconde); void convheureminute(float *heure,float *minute); void convheureseconde(float *heure, float *seconde); void convminuteheureseconde(float *minute, float *heure, float *seconde); void convminuteheure(float *minute, float *heure); void convminuteseconde(float *minute,float*seconde); void convsecondeheureminute(float *seconde,float *heure, float *minute); void convsecondeheure(float *seconde, float *heure); void convsecondeminute(float *seconde, float *minute); float heure, minute,seconde; int main(int argc,char *argv[]){ system("color 5f"); int choix; int ko,A,B; time_t kone; struct tm instant; time(&kone); instant=*localtime(&kone); printf("..........bienvenue chez kone......\n"); printf(" date du jour\n"); printf("%d/%d/%d ; %d:%d:%d\n",instant.tm_mday,instant.tm_mon+1,instant.tm_year+1900, instant.tm_hour,instant.tm_min,instant.tm_sec); printf("---------------------------------------\n"); do { printf("menu de convertion:\n"); printf("1. si tu veux convertir des heures\n"); printf("2. si tu veux convertir des minutes\n"); printf("3. si tu veux convertir des secondes\n"); printf("4. quitter le programme\n"); printf("votre choix:\t"); scanf("%d",&choix); } while(choix<1||choix>4); switch(choix) { case 1: printf("donner le nombre d'heure a convertir\n"); scanf("%f",&heure); break; case 2: printf("donner le nombre de minutes a convertir\n"); scanf("%f",&minute); break; case 3: printf("donner le nombre de seconde a convertir\n"); scanf("%f",&seconde); break; case 4: printf("programme terminee!!\n"); break; default: printf("faites un choix\n"); break; } if(choix==1) { do { printf("menu de convertion des heures:\n"); printf("1. si tu veux convertir en minutes\n"); printf("2. si tu veux convertir en secondes\n"); printf("3. si tu veux convertir en minutes et en secondes\n"); printf("4. quitter\n"); printf("faites votre choix:\n"); scanf("%d",&ko); switch(ko) { case 1: convheureminute(&heure,&minute); printf("%f heure font %f minute ",heure,minute); break; case 2: convheureseconde(&heure,&seconde); printf("%f heure font %f seconde",heure,seconde); break; case 3: convheureminuteseconde(&heure,&minute,&seconde); printf("%f heure font %f minute ou %f seconde",heure,minute,seconde); break; case 4: printf("partie terminee!"); break; default: printf("faites un bon choix!!!\n"); break; } } while(ko<1||ko>4); } else if(choix==2){ do { printf("menu de convertion des minutes:\n"); printf("1. si tu veux convertir en heure\n"); printf("2. si tu veux convertir en secondes\n"); printf("3. si tu veux convertir en heure et en secondes\n"); printf("4. quitter\n"); printf("faites votre choix:\n"); scanf("%d",&A); switch(A) { case 1: convminuteheure(&minute,&heure); printf("%f minute font %f heure ",minute,heure); break; case 2: convminuteseconde(&minute,&seconde); printf("%f minute font %f seconde",minute,seconde); break; case 3: convminuteheureseconde(&minute,&heure,&seconde); printf("%f minute font %f heure ou %f seconde",minute,heure,seconde); break; case 4: printf("partie terminee!"); break; default: printf("faites un bon choix!!!\n"); break; } } while(A<1||A>4); } else if (choix==3) { do { printf("menu de convertion des secondes:\n"); printf("1. si tu veux convertir en heure\n"); printf("2. si tu veux convertir en minute\n"); printf("3. si tu veux convertir en heure et en minute\n"); printf("4. quitter\n"); printf("faites votre choix:\n"); scanf("%d",&B); switch(B) { case 1: convsecondeheure(&seconde,&heure); printf("%f seconde font %f heure ",seconde,heure); break; case 2: convsecondeminute(&seconde,&minute); printf("%f seconde font %f minute",seconde,minute); break; case 3: convsecondeheureminute(&seconde,&heure,&minute); printf("%f seconde font %f heure ou %f minute",seconde,heure,minute); break; case 4: printf("partie terminee!"); break; default: printf("faites un bon choix!!!\n"); break; } } while(B<1||B>4); } return 0; } void convheureminuteseconde(float *heure,float *minute,float *seconde){ *minute= *heure*60; *seconde= *heure*3600; } void convminuteheureseconde(float *minute, float *heure, float *seconde){ *heure= *minute/60; *seconde= *minute*60; } void convsecondeheureminute(float *seconde, float *heure, float *minute){ *heure= *seconde/3600; *minute= *seconde/60; } void convheureminute(float *heure,float *minute){ *minute= *heure*60; } void convheureseconde(float *heure, float *seconde){ *seconde= *heure*3600; } void convminuteheure(float *minute, float *heure){ *heure= *minute/60; } void convminuteseconde(float *minute, float *seconde){ *seconde= *minute*60; } void convsecondeheure(float *seconde, float *heure){ *heure= *seconde/3600; } void convsecondeminute(float *seconde, float *minute){ *minute= *seconde/60; }
[ "noreply@github.com" ]
Ngangolo.noreply@github.com
5ea947e2458829c0d54368ff84791d1368d779fb
784b2bd9fe9fc57848087c0d4b3e53108e9e4bf1
/Offsets.cpp
cd3a48f4ace0487ff22074cf4a7662da6436de4c
[]
no_license
Snipeon/LGSbatt-rainmeter
8248be50c61cf48f7eaaeab92d1dcf6d3fc1df15
f790dda87e28e5c8cd6bf58873290c34bb9e4540
refs/heads/master
2021-01-20T07:57:34.518586
2017-05-05T17:52:40
2017-05-05T17:52:40
90,075,371
5
1
null
null
null
null
UTF-8
C++
false
false
714
cpp
#include <stdio.h> #include <windows.h> int main() { int value, offno; UINT_PTR offset; char text[32] = {0}; FILE *f = fopen("Offset.txt", "w"); if (!f) { printf("Error opening file!\n"); exit(1); } printf("Enter the base address offset:"); scanf("%x", &offset); printf("Enter the number of pointer offsets:"); scanf("%d", &value); fprintf(f, "%d\n%d\n", value, offset); for(offno = 0; offno < value - 1; offno++) { printf("Enter offset %d:", offno); scanf("%x", &offset); fprintf(f, "%d\n", offset); } printf("Enter offset %d:", offno); scanf("%x", &offset); fprintf(f, "%d", offset); fclose(f); return 0; }
[ "noreply@github.com" ]
Snipeon.noreply@github.com
20c49f889ec8276af612bc6d9f4dca939c5cc410
f97bf7fd79fb74ec37eb1a9f19e4d2672f763794
/SDL_OpenGL/Source/Mesh/MeshTriangle.h
47925e8ea84fae644d0e30f07d421593ee98f456
[]
no_license
arch1en/SDL_OpenGL
670d8164cf42f5aaccf02b6071fc7f02d621aa20
279d37f95e089b96696606125d2f34f5f69144b4
refs/heads/master
2021-01-25T07:39:57.316898
2016-12-04T01:27:03
2016-12-04T01:27:03
34,952,467
1
0
null
null
null
null
UTF-8
C++
false
false
403
h
//////////////////////////////////////// // // @project : Arch1eN Engine // @name : Mesh Triangle // @author : Artur Ostrowski // @usage : Hardcoded triangle mesh for testing purposes. // @version : 1.0.0 // //////////////////////////////////////// #pragma once #include "../stdafx.cpp" #include "MeshBase.h" class MeshTriangle : public MeshBase { public: MeshTriangle(); };
[ "archienx@gmail.com" ]
archienx@gmail.com
fba0b4fccc52926d8e8c411f2df2e28d6ab64231
9870e11c26c15aec3cc13bc910e711367749a7ff
/SPOJ/sp_3370.cpp
982c6d0bf61c3c4a0c476cd835aa36458a1ee69e
[]
no_license
liuq901/code
56eddb81972d00f2b733121505555b7c7cbc2544
fcbfba70338d3d10bad2a4c08f59d501761c205a
refs/heads/master
2021-01-15T23:50:10.570996
2016-01-16T16:14:18
2016-01-16T16:14:18
12,918,517
1
1
null
null
null
null
UTF-8
C++
false
false
605
cpp
#include <cstdio> #include <cstdlib> int a[100001]; int main() { void sort(int,int); int x; while (scanf("%d",&x)!=EOF) a[++a[0]]=x; sort(1,a[0]); for (int i=1;i<a[0];i++) printf("%d ",a[i]); printf("%d\n",a[a[0]]); system("pause"); return(0); } void sort(int l,int r) { int i,j,x; i=l,j=r; x=a[l+r>>1]; while (i<=j) { while (a[i]<x) i++; while (a[j]>x) j--; if (i<=j) { int t; t=a[i],a[i]=a[j],a[j]=t; i++,j--; } } if (i<r) sort(i,r); if (l<j) sort(l,j); }
[ "liuq901@163.com" ]
liuq901@163.com
5989f4fbc3b0b9aa7a57d83dc148377dc1cda3bb
5530a434ac05339fbc57d2da5ff86e065ebae17b
/LandScape.h
a988af22d6fab6f57c313d44337329aa74aa431e
[]
no_license
Klyta/12
55243333d810135a899eef2ff1ffc4eb9769bef0
76d32140b68a6a0270bfa73331a7d892330bb0c0
refs/heads/master
2021-01-06T14:39:24.825396
2020-02-18T13:14:10
2020-02-18T13:14:10
241,364,389
0
0
null
null
null
null
UTF-8
C++
false
false
92
h
#pragma once #include<string> class LandScape { public: std::string LandScape; };
[ "noreply@github.com" ]
Klyta.noreply@github.com
65a6c042f1444c2130112ba98f01472bb3c05de7
8dc6cf092fa6c20b441427d7bb261262bfc39cae
/Hmwk/Assignment 4/Gaddis_8thEd_Ch5_Prob4_Calories Burned/src/CaloriesBurnedain.cpp
51228537b25c0f86074a05831ce073b5caa28834
[]
no_license
lb2799264/BadescuLucy_CIS5_42375
eb4a53d2b4d8170955718a994ec18f388780a528
3bf2255426d3b975d2873660a03eaa7695f2e43f
refs/heads/master
2021-04-12T08:15:45.172597
2018-06-02T06:11:29
2018-06-02T06:11:29
125,799,199
0
0
null
null
null
null
UTF-8
C++
false
false
853
cpp
/* * File: main.cpp * Author: Lucy Badescu * Created on March 3, 2018, 8:14 PM * Purpose: Diamond Pattern */ //System Libraries #include <iostream> //I/O Library -> cout,endl using namespace std; //namespace I/O stream library created //User Libraries //Global Constants //Math, Physics, Science, Conversions, 2-D Array Columns //Function Prototypes //Execution Begins Here! int main() { //Declare Variables float d1, d2, d3, d4, d5, d6, d7; //Initial Variables //Map/Process Inputs to Outputs //Display Outputs cout << " * = " << d1 << endl; cout << " *** = " << d2 << endl; cout << " ***** = " << d3 << endl; cout << "******* = " << d4 << endl; cout << " ***** = " << d5 << endl; cout << " *** = " << d6 << endl; cout << " * = " << d7 << endl; //Exit program! return 0; }
[ "badescu93@g.ucla.edu" ]
badescu93@g.ucla.edu
80b693eccd4f76fb9efa3c60f4b95dc511bda734
1ecb45de29ec256a367b1d441c69158e63f1f280
/Session 1/binarySearchIterative.cpp
cc590e226c00091fa3bb1fb367fe862c753cf295
[]
no_license
safwankdb/WnCC-Competitive-Coding
2c2e1591d7693524a8c4d34c99e562f65ff20487
de04e5d99b7e61ee983797cb5a92fe0522d0cf21
refs/heads/master
2021-06-30T17:48:58.851327
2019-02-11T11:32:40
2019-02-11T11:32:40
165,313,442
5
2
null
2020-10-01T18:47:26
2019-01-11T21:35:55
C++
UTF-8
C++
false
false
651
cpp
#include<bits/stdc++.h> using namespace std; //This function return index of x in arr[] or returns -1 if it doesnt exist int binarySearch(int arr[], int left, int right, int x) { while(right>=left) { int mid = left + (right-left)/2; if(arr[mid] == x) return mid; if(arr[mid] < x) left = mid + 1; else right = mid - 1; } return -1; } int main() { int arr[] = {2, 4, 6, 9, 10, 11, 12, 13, 14, 65, 73, 88}; int x = 3; int n = sizeof(arr)/sizeof(arr[0]); int result = binarySearch(arr, 0, n-1, x); if(result == -1) cout << "Element not found"<<endl; else cout << "Element found at index " << result << endl; return 0; }
[ "noreply@github.com" ]
safwankdb.noreply@github.com
5c2ad21737375567e91881f9f45d180c0941605f
63ba7fc29d0fe05d6c513438afa9194f003bdf7d
/src/level.h
e83e5696cc32ce31757aa1975e5cdb57b8451c15
[]
no_license
Qwertazertl0/uiuc-sp19-cs126-final-project
48a54289dae28df24d6449e8eaad90593e628ed1
f8bce6a53562faf53836daf49372c164c9eb7fbb
refs/heads/master
2020-07-08T12:06:04.602885
2019-05-01T00:36:32
2019-05-01T00:36:32
203,667,610
0
0
null
null
null
null
UTF-8
C++
false
false
197
h
#pragma once #include "staticRect.h" #include "staticPolygon.h" class Level { public: std::vector<StaticRect> platforms; std::vector<StaticPolygon> hills; void draw(short absCP); };
[ "mjong3@illinois.edu" ]
mjong3@illinois.edu
9c0c41a853ea1280992b0e0fd297ac09454262a5
d3ea2b9a2bec9bcd811fb22e10596b03c2e21f9d
/src/icebox/samples/linux/main.cpp
c09302f5dcd41655f60d25cebcda05021a69488c
[ "MIT" ]
permissive
bamiaux/icebox
1dc478817f3f34a9c6456a578ed362f007fc6cb6
15058c0cd58809e43c6f7d587d6fe0420dbf08c9
refs/heads/master
2021-12-01T15:10:13.002666
2020-02-10T10:36:24
2020-02-10T10:36:24
190,866,182
1
1
MIT
2019-06-08T08:53:49
2019-06-08T08:53:48
null
UTF-8
C++
false
false
8,093
cpp
#define FDP_MODULE "linux" #include <icebox/core.hpp> #include <icebox/log.hpp> #include <iomanip> #include <iostream> #include <limits> #include <sstream> #define SYSTEM_PAUSE \ if(system("pause")) \ { \ } std::string thread_pc(core::Core& core, const thread_t& thread) { const auto pc = threads::program_counter(core, {}, thread); if(!pc) return "<err>"; const auto proc = threads::process(core, thread); return symbols::string(core, *proc, *pc); } void display_thread(core::Core& core, const thread_t& thread) { const auto thread_id = threads::tid(core, {}, thread); LOG(INFO, "thread : 0x%" PRIx64 " id:%s %s %s", thread.id, thread_id <= 4194304 ? std::to_string(thread_id).append(7 - std::to_string(thread_id).length(), ' ').data() : "no", std::string("").append(39, ' ').data(), thread_pc(core, thread).data()); } std::string pad_with(const std::string& arg, int pad) { const auto need = std::max(0, pad - static_cast<int>(arg.size())); auto reply = arg; return reply.append(need, ' '); } void display_proc(core::Core& core, const proc_t& proc) { const auto proc_pid = process::pid(core, proc); auto proc_name = process::name(core, proc); const bool proc_32bits = !!process::flags(core, proc).is_x86; const auto proc_parent = process::parent(core, proc); uint64_t proc_parent_pid = 0xffffffffffffffff; if(proc_parent) proc_parent_pid = process::pid(core, *proc_parent); std::string leader_thread_pc; std::string threads; int threads_count = -1; threads::list(core, proc, [&](thread_t thread) { if(threads_count++ < 0) { leader_thread_pc = thread_pc(core, thread); return walk_e::next; } if(threads_count > 1) threads.append(", "); threads.append(std::to_string(threads::tid(core, {}, thread))); return walk_e::next; }); if(!proc_name) proc_name = "<noname>"; LOG(INFO, "process: 0x%" PRIx64 " pid:%s parent:%s %s %s %s %s pgd:0x%" PRIx64 "%s", proc.id, pad_with(proc_pid <= 4194304 ? std::to_string(proc_pid) : "no", 7).data(), pad_with(proc_parent_pid <= 4194304 ? std::to_string(proc_parent_pid) : "error", 7).data(), proc_32bits ? "x86" : "x64", pad_with(*proc_name, 16).data(), leader_thread_pc.data(), threads_count > 0 ? ("+" + std::to_string(threads_count) + " threads (" + threads + ")").data() : "", proc.udtb.val, proc.udtb.val ? "" : " (kernel)"); } void display_mod(core::Core& core, const proc_t& proc) { state::pause(core); modules::list(core, proc, [&](mod_t mod) { const auto span = modules::span(core, proc, mod); auto name = modules::name(core, {}, mod); if(!name) name = "<no-name>"; LOG(INFO, "module: 0x%" PRIx64 " %s %s %zd bytes", span->addr, name->append(32 - name->length(), ' ').data(), mod.flags.is_x86 ? "x86" : "x64", span->size); return walk_e::next; }); state::resume(core); } void display_vm_area(core::Core& core, const proc_t& proc) { state::pause(core); vm_area::list(core, proc, [&](vm_area_t vm_area) { const auto span = vm_area::span(core, proc, vm_area); const auto type = vm_area::type(core, proc, vm_area); std::string type_str = " "; if(type == vma_type_e::heap) type_str = "[heap] "; else if(type == vma_type_e::stack) type_str = "[stack] "; else if(type == vma_type_e::module) type_str = "[module]"; else if(type == vma_type_e::other) type_str = "[other] "; const auto access = vm_area::access(core, proc, vm_area); auto access_str = std::string{}; access_str += (access & VMA_ACCESS_READ) ? "r" : "-"; access_str += (access & VMA_ACCESS_WRITE) ? "w" : "-"; access_str += (access & VMA_ACCESS_EXEC) ? "x" : "-"; access_str += (access & VMA_ACCESS_SHARED) ? "s" : "p"; auto name = vm_area::name(core, proc, vm_area); if(!name) name = ""; LOG(INFO, "vm_area: 0x%" PRIx64 "-0x%" PRIx64 " %s %s %s", span ? span->addr : 0, span ? span->addr + span->size : 0, access_str.data(), type_str.data(), name->data()); return walk_e::next; }); state::resume(core); } opt<proc_t> select_process(core::Core& core) { while(true) { int pid; std::cout << "Enter a process PID or -1 to skip : "; std::cin >> pid; while(std::cin.fail()) { std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); std::cout << "Enter a process PID or -1 to skip : "; std::cin >> pid; } if(pid == -1) return {}; state::pause(core); const auto target = process::find_pid(core, pid); state::resume(core); if(target) return *target; LOG(ERROR, "unable to find a process with PID %d", pid); } } void proc_join(core::Core& core, proc_t target, mode_e mode) { state::pause(core); printf("Process found, VM running...\n"); process::join(core, target, mode); const auto thread = threads::current(core); if(thread) { std::cout << "Current thread : "; display_thread(core, *thread); } else LOG(ERROR, "no current thread"); const auto proc = process::current(core); if(proc) { std::cout << "Current process : "; display_proc(core, *proc); } else LOG(ERROR, "no current proc"); printf("\nPress a key to resume VM...\n"); SYSTEM_PAUSE state::resume(core); } int main(int argc, char** argv) { logg::init(argc, argv); // core initialization if(argc != 2) return FAIL(-1, "usage: linux <name>"); SYSTEM_PAUSE const auto name = std::string{argv[1]}; LOG(INFO, "starting on %s", name.data()); const auto core = core::attach(name); if(!core) return FAIL(-1, "unable to start core at %s", name.data()); state::resume(*core); SYSTEM_PAUSE printf("\n"); // get list of processes state::pause(*core); process::list(*core, [&](proc_t proc) { display_proc(*core, proc); return walk_e::next; }); state::resume(*core); // proc_join in kernel mode printf("\n--- Join a process in kernel mode ---\n"); auto target = select_process(*core); if(target) process::join(*core, *target, mode_e::kernel); // proc_join in user mode printf("\n--- Join a process in user mode ---\n"); target = select_process(*core); if(target) process::join(*core, *target, mode_e::user); printf("\n"); SYSTEM_PAUSE printf("\n"); // get list of drivers state::pause(*core); drivers::list(*core, [&](driver_t driver) { const auto span = drivers::span(*core, driver); auto name = drivers::name(*core, driver); if(!name) name = "<no-name>"; LOG(INFO, "driver: 0x%" PRIx64 " %s %zd bytes", span->addr, name->append(32 - name->length(), ' ').data(), span->size); return walk_e::next; }); state::resume(*core); printf("\n"); SYSTEM_PAUSE printf("\n"); // get list of vm_area printf("\n--- Display virtual memory areas and modules of a process ---\n"); target = select_process(*core); if(target) { printf("\nVirtual memory areas :\n"); display_vm_area(*core, *target); printf("\n"); SYSTEM_PAUSE printf("\nModules :\n"); display_mod(*core, *target); } printf("\n"); SYSTEM_PAUSE printf("\n"); return 0; }
[ "benoit.amiaux@gmail.com" ]
benoit.amiaux@gmail.com
ea240ed1de3da63a5a6a2ab1b0f8baa6eae98e5b
21f553e7941c9e2154ff82aaef5e960942f89387
/algorithms/kernel/kmeans/kmeans_partialresult.h
c4c1669c6c24239fab653d13482c08f5f40588ab
[ "Apache-2.0", "Intel" ]
permissive
tonythomascn/daal
7e6fe4285c7bb640cc58deb3359d4758a9f5eaf5
3e5071f662b561f448e8b20e994b5cb53af8e914
refs/heads/daal_2017_update2
2021-01-19T23:05:41.968161
2017-04-19T16:18:44
2017-04-19T16:18:44
88,920,723
1
0
null
2017-04-20T23:54:18
2017-04-20T23:54:18
null
UTF-8
C++
false
false
2,896
h
/* file: kmeans_partialresult.h */ /******************************************************************************* * Copyright 2014-2017 Intel Corporation * * 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. *******************************************************************************/ /* //++ // Implementation of kmeans classes. //-- */ #ifndef __KMEANS_PARTIALRESULT_ #define __KMEANS_PARTIALRESULT_ #include "algorithms/kmeans/kmeans_types.h" namespace daal { namespace algorithms { namespace kmeans { /** * Allocates memory to store partial results of the K-Means algorithm * \param[in] input Pointer to the structure of the input objects * \param[in] parameter Pointer to the structure of the algorithm parameters * \param[in] method Computation method of the algorithm */ template <typename algorithmFPType> DAAL_EXPORT void PartialResult::allocate(const daal::algorithms::Input *input, const daal::algorithms::Parameter *parameter, const int method) { const Parameter *kmPar = static_cast<const Parameter *>(parameter); size_t nFeatures = static_cast<const InputIface *>(input)->getNumberOfFeatures(); size_t nClusters = kmPar->nClusters; Argument::set(nObservations, data_management::SerializationIfacePtr( new data_management::HomogenNumericTable<algorithmFPType>(1, nClusters, data_management::NumericTable::doAllocate))); Argument::set(partialSums, data_management::SerializationIfacePtr( new data_management::HomogenNumericTable<algorithmFPType>(nFeatures, nClusters, data_management::NumericTable::doAllocate))); Argument::set(partialGoalFunction, data_management::SerializationIfacePtr( new data_management::HomogenNumericTable<algorithmFPType>(1, 1, data_management::NumericTable::doAllocate))); if( kmPar->assignFlag ) { Input *algInput = static_cast<Input *>(const_cast<daal::algorithms::Input *>(input)); size_t nRows = algInput->get(data)->getNumberOfRows(); Argument::set(partialAssignments, data_management::SerializationIfacePtr( new data_management::HomogenNumericTable<int>(1, nRows, data_management::NumericTable::doAllocate))); } } } // namespace kmeans } // namespace algorithms } // namespace daal #endif
[ "vasily.rubtsov@intel.com" ]
vasily.rubtsov@intel.com
9008eff132a21fbc7ff21cbe3467426b9337a811
a43a0a8b82e8e2c345ca2336bec57d76e5a38b47
/Experiment/src/Model/model.hpp
451f6d9e74321422a39cd9b1427ce4deb6195481
[]
no_license
LukeAndrewSmith/AutonomousVehicles
2448f03d7bf7d3eecb506223d303f93f3e277c90
89e512eaab72cfa9b8169201205fa0f197fedbcb
refs/heads/master
2022-12-08T14:58:09.815518
2020-08-20T10:35:27
2020-08-20T10:35:27
245,980,250
0
0
null
null
null
null
UTF-8
C++
false
false
8,783
hpp
#include <queue> // Helpers int random_num(int lower, int upper); /*----------------------------------------------------------------------------*/ /* Car */ /*----------------------------------------------------------------------------*/ class Road; // Forward declaration of road as it is needed for 'update_decision(Road* road);' method class Car { private: int id; float velocity; // [m/s] float max_velocity; float x_pos; // [m] Position of back wheels float y_pos; // lanes are integers float accel_param; float max_accel_param; float min_accel_param; float car_length; float y_target; float horizon; // distance ahead to aim for during lane change float road_angle; float turning_angle; float max_delta_turning_angle; float braking_strategy_multiplier; bool overreacting; int overreaction_brake_iterations; int overreaction_pause_iterations; int overreaction_iterations; std::vector<int> ovverreaction_count; float previous_accel_param; float starting_velocity_accel; float accel_start_proportion; // Random parameters so that all humans have a different acceleration strategy float accel_max; // Concertina int event_iterations; // The front car needs to count how many iterations to brake for // Below used for lane merging protocol int human; // Flag to indicate wether human or AV (human = 0 => AV, human = 1 => Human) bool merging; // Flag to indicate that the current car is merging bool merged; // Flag to check if this car has merged bool accelerating; // Flag to indicate that the car should accelerate float starting_lane; // The protocol is dependent on the starting lane of the vehicle float wait; // The human model waits a random time before letting someone into their lane during lane merging bool waited; // Flag to indicate that the human model has waited public: Car(int id, float init_velocity, float init_max_velocity, float init_x_pos, float init_y_pos, float init_accel_param, float init_max_accel_param, float init_min_accel_param, float init_car_length, float init_horizon, float init_max_delta_turning_angle, float init_overreaction_brake_time, float init_overreaction_pause_time, float braking_strategy_multiplier, float time_step, int human); int update_decision(Road* road, float time_step, int iteration, int n_iterations_event); void update_position(float time_step); float get_x_pos(); float get_x_pos_front_of_car(); float get_y_pos(); float get_length(); float get_accel_param(); float get_velocity(); int get_id(); std::vector<int> get_ovvereaction_count(); bool get_merged(); bool get_merging(); bool at_velocity(float speed_limit); // Checks if close enough to target velocity => speeds up convergence bool greater_than_velocity(float target_velocity); bool in_target_lane(); // Checks if close enough to target lane => speeds up convergence float accelerate(Road* road, int car_ahead_id); // Calculates the next accel_param void merge(); // Merges the car }; /*----------------------------------------------------------------------------*/ /* Road */ /*----------------------------------------------------------------------------*/ class Road { private: int road_length; int speed_limit; int speed_limit_after_merge; int n_lanes; // Lane 0 = 0, Lane 1 = 1, cars will try to go from lane 0 to lane 1 std::vector<Car> cars; float begin_event; // Indicates at what position braking/lane merging should begin float end_event; int av_only_merge_front; // Only allow the front two AV's to merge at a time float n_iterations_event; // Indicates for how long the car should brake during concertina public: Road(); Road(int init_road_length, int init_speed_limit, int init_speed_limit_after_merge, int init_n_lanes, float init_begin_event, float init_end_event, int init_av_only_merge_front, int init_n_iterations_event); float get_car_ahead_pos(float my_x_pos, float my_y_pos); float get_car_ahead_velocity(float car_ahead_x_pos, float car_ahead_y_pos); float get_car_ahead_accel_param(float car_ahead_x_pos, float car_ahead_y_pos); bool get_car_ahead_merged(float car_ahead_x_pos, float car_ahead_y_pos); float get_car_behind_pos(float my_x_pos); bool check_merging_space(int my_id, int id_ahead, int id_behind, float car_length); float get_car_ahead_pos_otherlane(float my_x_pos, float my_y_pos); float get_car_behind_pos_otherlane(float my_x_pos, float my_y_pos); float get_car_ahead_or_next_to_pos_otherlane(float my_x_pos, float my_y_pos); float get_car_behind_or_next_to_pos_otherlane(float my_x_pos, float my_y_pos); float get_car_ahead_pos_anylane(float my_x_pos); float get_car_pos_id(int id); float get_velocity_id(int id); bool get_car_merging_id(int id); bool get_car_merged_id(int id); int update_car_decisions(float time_step, int iteration); // Updates for all cars on the road void update_car_positions(float time_step); // Updates for all cars on the road void add_car(Car new_car); bool cars_at_speed_limit(); // Check if all the cars are at the speed limit (Experiment ending condition) bool cars_in_lane_1(); // Check if all the cars are in lane 1 (Experiment ending condition) bool cars_at_safety_distance(); // Check if all the cars are respecting the safety distance (Experiment ending condition) std::vector<Car> get_cars(); int get_road_length(); int get_speed_limit(); int get_speed_limit_after_merge(); int get_begin_event(); int get_end_event(); int get_av_only_merge_front(); int get_n_cars_per_lane(); }; /*----------------------------------------------------------------------------*/ /* Init Experiment */ /*----------------------------------------------------------------------------*/ // Structure that contains all the initial parameters needed for an experiment struct init_experiment { // Car float init_velocity; // All cars begin with the same velocity float init_max_velocity; float init_accel_param; float init_max_accel_param; float init_min_accel_param; float init_car_length; float init_horizon; float init_max_delta_turning_angle; float init_overreaction_brake_time; float init_overreaction_pause_time; float init_braking_strategy_multiplier; int init_human; // Road int init_road_length; // ( road_length == 0 ) => continue until experiment_finished() and take road length to be the final x_pos of the front car int init_speed_limit; int init_speed_limit_after_merge; int init_n_lanes; float init_begin_event; // ( begin_event < 0 ) => no event float init_end_event; int init_av_only_merge_front; int init_n_iterations_event; // Experiment float init_n_cars_per_lane; // All lanes begin with the same number of cars int init_car_spacing; int init_max_it; // ( max_it == 0 ) => continue until 'experiment_finished()', otherwise stop at 'experiment_finished()' or when 'max_it' reached (whichever happens first) float init_time_step; }; /*----------------------------------------------------------------------------*/ /* Experiment */ /*----------------------------------------------------------------------------*/ class Experiment { private: Road road; int n_cars_per_lane; // Same initial number of cars per lane int car_spacing; // Initial distance between the the cars int max_it; // Number of iterations float time_step; // Time passed in each iteration (should be small as we have made small angle approximations) public: Experiment(init_experiment init_vals); void main_loop(std::string experiment_num, bool multi_lane, bool event, int visualise); // event => whether braking/lane merging is happening bool experiment_finished(); };
[ "luke.smith@bluewin.ch" ]
luke.smith@bluewin.ch
b31c3a7a6f9d4ccac78a2e4cac732c925ff48adc
529d232b905aa117c83f040fdaff24eb742bfb55
/arduino/IRrecvDemo/IRrecvDemo.ino
ed404391dc2c2d82946b4d46f138b9f839ed9e88
[]
no_license
jasontsemf/FakeHangout
c2c51cb530e5f3c8f548eb0fd71a08bd2763c2e5
af8c0775491a7ca9f94d8e6879117647a4af89f0
refs/heads/master
2021-03-02T17:30:15.596376
2020-03-11T16:48:57
2020-03-11T16:48:57
245,889,032
0
0
null
null
null
null
UTF-8
C++
false
false
903
ino
/* * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv * An IR detector/demodulator must be connected to the input RECV_PIN. * Version 0.1 July, 2009 * Copyright 2009 Ken Shirriff * http://arcfn.com */ #include <IRremote.h> int RECV_PIN = 9; IRrecv irrecv(RECV_PIN); int servopin = 4; int pulse = 1500; decode_results results; void setup() { Serial.begin(9600); // In case the interrupt driver crashes on setup, give a clue // to the user what's going on. Serial.println("Enabling IRin"); irrecv.enableIRIn(); // Start the receiver Serial.println("Enabled IRin"); pinMode(servopin, OUTPUT); } void loop() { digitalWrite(servopin, HIGH); delayMicroseconds(pulse); digitalWrite(servopin, LOW); if (irrecv.decode(&results)) { Serial.println(results.value, HEX); irrecv.resume(); // Receive the next value } delay(20); // delay(100); }
[ "jason1996429@gmail.com" ]
jason1996429@gmail.com
359af8b2d0cbfcc6c29e3ae7c4c2845ec238070e
eba7ecf0673954c16c13072187674ee21be186a2
/luawrapper.cc
833276a3253d263138848ab22ea74e149101e7fd
[]
no_license
gitter-badger/lua_wrapper
3588adff680237cfc08862d3c786ea807324a4d7
c77419f2351de2412c0c819034e93c26d8831417
refs/heads/master
2021-01-12T03:51:40.449980
2016-06-23T17:04:03
2016-06-23T17:04:03
78,275,134
0
0
null
2017-01-07T11:28:45
2017-01-07T11:28:45
null
UTF-8
C++
false
false
5,148
cc
/** * * @brief Lua Wrapper * @author Toni Marquez * **/ #include "luawrapper.h" /// constructor LuaWrapper::LuaWrapper() { LUA_ = nullptr; } /// init values void LuaWrapper::init(const char* path) { LUA_ = luaL_newstate(); luaL_openlibs(LUA_); if (luaL_dofile(LUA_, path)){ printf("ERROR en Lua\n"); } } /** * @brief register a function / call the function * @param const char* lua_function, lua_CFunction cfunction / none * @return void / void **/ void LuaWrapper::registerFunction(const char* lua_function, lua_CFunction cfunction) { lua_register(LUA_, lua_function, cfunction); } void LuaWrapper::callFunction() { lua_pcall(LUA_, 0, 0, 0); } /** * @brief insert global from lua file to the stack and pop it * @param const char* global * @return const int / const float / const char* / const bool **/ const int LuaWrapper::getGlobalInteger(const char* global) { lua_getglobal(LUA_, global); int integer = lua_tointeger(LUA_, -1); lua_pop(LUA_, 1); return integer; } const float LuaWrapper::getGlobalNumber(const char* global) { lua_getglobal(LUA_, global); float number = lua_tonumber(LUA_, -1); lua_pop(LUA_, 1); return number; } const char* LuaWrapper::getGlobalString(const char* global) { lua_getglobal(LUA_, global); char* string = (char*)lua_tostring(LUA_, -1); lua_pop(LUA_, 1); return string; } const bool LuaWrapper::getGlobalBoolean(const char* global) { lua_getglobal(LUA_, global); bool boolean = lua_toboolean(LUA_, -1); lua_pop(LUA_, 1); return boolean; } /** * @brief insert table from lua file to the stack, get a specified field * and pop it * @param const char* table, const char* field * @return const int / const float / const char* / const bool **/ const int LuaWrapper::getIntegerFromTable(const char* table, const char* field) { lua_getglobal(LUA_, table); lua_getfield(LUA_, -1, field); int integer = lua_tointeger(LUA_, -1); lua_pop(LUA_, 2); return integer; } const float LuaWrapper::getNumberFromTable(const char* table, const char* field) { lua_getglobal(LUA_, table); lua_getfield(LUA_, -1, field); double number = lua_tonumber(LUA_, -1); lua_pop(LUA_, 2); return number; } const char* LuaWrapper::getStringFromTable(const char* table, const char* field) { lua_getglobal(LUA_, table); lua_getfield(LUA_, -1, field); char* string = (char*)lua_tostring(LUA_, -1); lua_pop(LUA_, 2); return string; } const bool LuaWrapper::getBooleanFromTable(const char* table, const char* field) { lua_getglobal(LUA_, table); lua_getfield(LUA_, -1, field); bool boolean = lua_toboolean(LUA_, -1); lua_pop(LUA_, 2); return boolean; } /** * @brief insert table from lua file to the stack and get a specified * position by index * @param const char* table, const short int index * @return const int / const float / const char* / const bool **/ const int LuaWrapper::getIntegerFromTableByIndex(const char* table, const short int index) { lua_checkstack(LUA_, 3); lua_getglobal(LUA_, table); lua_pushnumber(LUA_, index + 1); lua_gettable(LUA_, -2); int integer = lua_tointeger(LUA_, -1); return integer; } const float LuaWrapper::getNumberFromTableByIndex(const char* table, const short int index) { lua_checkstack(LUA_, 3); lua_getglobal(LUA_, table); lua_pushnumber(LUA_, index + 1); lua_gettable(LUA_, -2); float number = lua_tonumber(LUA_, -1); return number; } const char* LuaWrapper::getStringFromTableByIndex(const char* table, const short int index) { lua_checkstack(LUA_, 3); lua_getglobal(LUA_, table); lua_pushnumber(LUA_, index + 1); lua_gettable(LUA_, -2); char* string = (char*)lua_tostring(LUA_, -1); return string; } const bool LuaWrapper::getBooleanFromTableByIndex(const char* table, const short int index) { lua_checkstack(LUA_, 3); lua_getglobal(LUA_, table); lua_pushnumber(LUA_, index); lua_gettable(LUA_, -2); bool boolean = lua_toboolean(LUA_, -1); return boolean; } /** releasers **/ void LuaWrapper::pop(const unsigned short int num_elements) { lua_pop(LUA_, num_elements); } void LuaWrapper::remove(const short int index) { lua_remove(LUA_, index); } void LuaWrapper::free() { lua_settop(LUA_, 0); } /// reset lua void LuaWrapper::reset() { lua_close(LUA_); LUA_ = luaL_newstate(); luaL_openlibs(LUA_); } /// close lua void LuaWrapper::close() { lua_settop(LUA_, 0); lua_close(LUA_); } /// destructor LuaWrapper::~LuaWrapper() { //lua_close(LUA_); LUA_ = nullptr; }
[ "noreply@github.com" ]
gitter-badger.noreply@github.com
389378b07cb83dda633a294ade107bd417ef0cdf
c6bdab6dcf6dd9bf5f36f58eb4aaa4ba38af6042
/2d Physics Engine_StepByStepSources/2d Physics Engine99_FinalResult/KVector2.h
e148d809153cd17b80fe7a7bf30de1fef241c848
[]
no_license
lant86/UnderstandingUnity
0111442a22a46c40d39ea417b976bd1ac3deecf9
716b30c1031ea9b14ae69c74271d61b865ebb8b6
refs/heads/master
2023-06-01T22:42:43.789249
2021-06-21T09:25:55
2021-06-21T09:25:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,752
h
#pragma once #include <math.h> #include <cmath> class KVector2 { public: static float EPSILON; static float PI; static KVector2 zero; static KVector2 one; static KVector2 right; static KVector2 up; static KVector2 Lerp(const KVector2& begin, const KVector2& end, float ratio); static float Dot(const KVector2& left, const KVector2& right); static float DistSquared(const KVector2& a, const KVector2& b); static float Dist(const KVector2& a, const KVector2& b); static float Determinant(const KVector2&a, const KVector2 &b); static bool IsCCW(const KVector2&a, const KVector2 &b); static KVector2 Min(const KVector2& a, const KVector2& b); static KVector2 Max(const KVector2& a, const KVector2& b); static KVector2 Cross(const KVector2& v, float a); static KVector2 Cross(float a, const KVector2& v); static float Cross(const KVector2& a, const KVector2& b); public: union { float v[2]; float m[1][1]; struct { float x; float y; }; }; public: KVector2(float tx=0.0f, float ty=0.0f) { x = tx; y = ty; } void Set(float x_, float y_) { x = x_; y = y_; } float Length() const { return sqrtf(x*x + y*y); } float LengthSquared() const { return x * x + y * y; } void Normalize() { const float length = Length(); if (length > EPSILON) { x = x / length; y = y / length; } } void Rotate(float radians ) { float c = std::cos(radians); float s = std::sin(radians); float tx = x * c - y * s; float ty = x * s + y * c; x = tx; y = ty; } float& operator[](int i) { return v[i]; } KVector2 operator-() const { return KVector2(-x, -y); } KVector2 operator*=(float scalar) { x *= scalar; y *= scalar; return *this; } KVector2 operator+=(const KVector2 rhs) { x += rhs.x; y += rhs.y; return *this; } KVector2 operator-=(const KVector2 rhs) { x -= rhs.x; y -= rhs.y; return *this; } }; inline KVector2 operator+(const KVector2& lhs, const KVector2& rhs) { KVector2 temp(lhs.x + rhs.x, lhs.y + rhs.y); return temp; } inline KVector2 operator-(const KVector2& lhs, const KVector2& rhs) { KVector2 temp(lhs.x - rhs.x, lhs.y - rhs.y); return temp; } inline float operator*(const KVector2& left, const KVector2& right) { return left.x * right.x + left.y * right.y; } inline KVector2 operator*(float scalar, const KVector2& rhs) { KVector2 temp(scalar*rhs.x, scalar*rhs.y); return temp; } inline KVector2 operator*(const KVector2& lhs, float scalar) { KVector2 temp(lhs.x*scalar, lhs.y*scalar); return temp; } inline KVector2 operator/(const KVector2& lhs, float scalar) { KVector2 temp(lhs.x/scalar, lhs.y/scalar); return temp; }
[ "jintaeks@gmail.com" ]
jintaeks@gmail.com
67fb394d77970edca6b7e2dc4d0e6030413095f6
e085a4b09c0be034b90a950fc60acf1d55abbf96
/recommendation/news/recommender/recommendation_handler.h
a0c3bfd5402fac4e4319ba4ae81d0de5a4a3a14b
[]
no_license
macytangtang/develop
35fc7d7a636cb79bbda9457feb1a8bd7bdf4f76d
03844cbebfc2d09ebe83376ff34736a84e354a75
refs/heads/master
2021-01-23T05:18:27.694512
2017-03-27T05:21:53
2017-03-27T05:21:53
86,294,152
0
0
null
2017-03-27T05:20:36
2017-03-27T05:20:36
null
UTF-8
C++
false
false
1,775
h
// Copyright 2017 Mobvoi Inc. All Rights Reserved. // Author: xjliu@mobvoi.com (Xiaojia Liu) #ifndef RECOMMENDATION_NEWS_RECOMMENDER_RECOMMENDATION_HANDLER_H_ #define RECOMMENDATION_NEWS_RECOMMENDER_RECOMMENDATION_HANDLER_H_ #include "base/basictypes.h" #include "base/compat.h" #include "onebox/http_handler.h" #include "push/util/location_helper.h" #include "push/util/user_info_helper.h" #include "third_party/jsoncpp/json.h" #include "util/net/http_server/http_request.h" #include "util/net/http_server/http_response.h" #include "recommendation/news/recommender/news_trigger.h" #include "recommendation/news/recommender/toutiao_trigger.h" namespace recommendation { class StatusHandler : public serving::HttpRequestHandler { public: StatusHandler(); virtual ~StatusHandler(); virtual bool HandleRequest(util::HttpRequest* request, util::HttpResponse* response); private: DISALLOW_COPY_AND_ASSIGN(StatusHandler); }; class RecommendationHandler : public serving::HttpRequestHandler { public: RecommendationHandler(); virtual ~RecommendationHandler(); virtual bool HandleRequest(util::HttpRequest* request, util::HttpResponse* response); private: bool ParseQuery(const std::string& url, map<string, string>* params); string GetDefaultResponse(const string& user_id, const vector<StoryDetail>& doc_vec); string GetErrorResponse(const std::string& err_msg); ToutiaoTrigger* toutiao_trigger_; NewsTrigger* news_trigger_; DeviceInfoHelper* device_info_helper_; LocationHelper* location_helper_; DISALLOW_COPY_AND_ASSIGN(RecommendationHandler); }; } // namespace recommendation #endif // RECOMMENDATION_NEWS_RECOMMENDER_RECOMMENDATION_HANDLER_H_
[ "xjliu@mobvoi.com" ]
xjliu@mobvoi.com
cce198404bf675caa76a8f6f9a81d1507a7dc41e
438cd59a4138cd87d79dcd62d699d563ed976eb9
/mame/src/mame/includes/dkong.h
a02e128a5eeae138c194c10a0da163381b7445fd
[]
no_license
clobber/UME
031c677d49634b40b5db27fbc6e15d51c97de1c5
9d4231358d519eae294007133ab3eb45ae7e4f41
refs/heads/master
2021-01-20T05:31:28.376152
2013-05-01T18:42:59
2013-05-01T18:42:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,643
h
#include "sound/discrete.h" /* * From the schematics: * * XTAL is 61,44 MHZ. There is some oscillator logic around it. The oscillating circuit * transfers the signal with a transformator. Onwards, it is fed through a M(B/C)10136. This * is a programmable counter which is used as a divisor by 5. * Cascaded 74LS161 further divide the signal. The following signals are generated: * 1/2H: 61,44MHZ/5/2 - pixel clock * 1H : 61,44MHZ/5/4 - cpu-clock * 2H : 61,44MHZ/5/8 * .... * 128H: 61,44MHZ/5/512 * The horizontal circuit counts till 384=256+128, thus 256H only being high for 128H/2 * * Signal 16H,32H,64H and 256H are combined using a LS00, LS04 and a D-Flipflop to produce * a signal with Freq 16H/12. This is only possible because a 220pf capacitor with the * impedance of the LS-Family of 10K delays the 16H signal by about half a cycle. * This signal is divided by two by another D-Flipflop(74LS74) to give: * 1VF: 61,44MHZ/5/64/12/2 = 8KHZ * 2VF: 1VF/2 - Noise frequency: 4Khz * ... * The vertical circuit counts from 248 till 512 giving 264 lines. * 256VF is not being used, so counting is from 248...255, 0...255, .... */ #define MASTER_CLOCK XTAL_61_44MHz #define CLOCK_1H (MASTER_CLOCK / 5 / 4) #define CLOCK_16H (CLOCK_1H / 16) #define CLOCK_1VF ((CLOCK_16H) / 12 / 2) #define CLOCK_2VF ((CLOCK_1VF) / 2) #define PIXEL_CLOCK (MASTER_CLOCK/10) #define HTOTAL (384) #define HBSTART (256) #define HBEND (0) #define VTOTAL (264) #define VBSTART (240) #define VBEND (16) #define I8035_CLOCK (XTAL_6MHz) /**************************************************************************** * CONSTANTS ****************************************************************************/ #define HARDWARE_TYPE_TAG "HARDWARE_TYPE" enum { HARDWARE_TKG04 = 0, HARDWARE_TRS01, HARDWARE_TRS02, HARDWARE_TKG02 }; enum { DKONG_RADARSCP_CONVERSION = 0, DKONG_BOARD = 1 }; enum { DK2650_HERBIEDK = 0, DK2650_HUNCHBKD, DK2650_EIGHTACT, DK2650_SHOOTGAL, DK2650_SPCLFORC }; #define DK2B_PALETTE_LENGTH (256+256+8+1) /* (256) */ #define DK4B_PALETTE_LENGTH (256+256+8+1) /* (256) */ #define DK3_PALETTE_LENGTH (256+256+8+1) /* (256) */ #define RS_PALETTE_LENGTH (256+256+8+1) class dkong_state : public driver_device { public: dkong_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_video_ram(*this,"video_ram"), m_sprite_ram(*this,"sprite_ram"), m_vidhw(DKONG_BOARD), m_discrete(*this, "discrete") { } /* memory pointers */ required_shared_ptr<UINT8> m_video_ram; required_shared_ptr<UINT8> m_sprite_ram; /* devices */ device_t *m_dev_n2a03a; device_t *m_dev_n2a03b; device_t *m_dev_vp2; /* virtual port 2 */ device_t *m_dev_6h; /* machine states */ UINT8 m_hardware_type; UINT8 m_nmi_mask; /* sound state */ const UINT8 *m_snd_rom; /* video state */ tilemap_t *m_bg_tilemap; bitmap_ind16 m_bg_bits; const UINT8 * m_color_codes; emu_timer * m_scanline_timer; INT8 m_vidhw; /* Selected video hardware RS Conversion / TKG04 */ optional_device<discrete_device> m_discrete; /* radar scope */ UINT8 * m_gfx4; UINT8 * m_gfx3; int m_gfx3_len; UINT8 m_sig30Hz; UINT8 m_lfsr_5I; UINT8 m_grid_sig; UINT8 m_rflip_sig; UINT8 m_star_ff; UINT8 m_blue_level; double m_cd4049_a; double m_cd4049_b; /* Specific states */ INT8 m_decrypt_counter; /* 2650 protection */ UINT8 m_protect_type; UINT8 m_hunchloopback; UINT8 m_prot_cnt; UINT8 m_main_fo; /* Save state relevant */ UINT8 m_gfx_bank; UINT8 m_palette_bank; UINT8 m_grid_on; UINT16 m_grid_col; UINT8 m_sprite_bank; UINT8 m_dma_latch; UINT8 m_flip; /* radarscp_step */ double m_cv1; double m_cv2; double m_vg1; double m_vg2; double m_vg3; double m_cv3; double m_cv4; double m_vc17; int m_pixelcnt; /* radarscp_scanline */ int m_counter; /* reverse address lookup map - hunchbkd */ INT16 m_rev_map[0x200]; DECLARE_READ8_MEMBER(hb_dma_read_byte); DECLARE_WRITE8_MEMBER(hb_dma_write_byte); DECLARE_WRITE8_MEMBER(dkong3_coin_counter_w); DECLARE_READ8_MEMBER(dkong_in2_r); DECLARE_READ8_MEMBER(dkongjr_in2_r); DECLARE_READ8_MEMBER(s2650_mirror_r); DECLARE_WRITE8_MEMBER(s2650_mirror_w); DECLARE_READ8_MEMBER(epos_decrypt_rom); DECLARE_WRITE8_MEMBER(s2650_data_w); DECLARE_WRITE8_MEMBER(s2650_fo_w); DECLARE_READ8_MEMBER(s2650_port0_r); DECLARE_READ8_MEMBER(s2650_port1_r); DECLARE_WRITE8_MEMBER(dkong3_2a03_reset_w); DECLARE_READ8_MEMBER(strtheat_inputport_0_r); DECLARE_READ8_MEMBER(strtheat_inputport_1_r); DECLARE_WRITE8_MEMBER(nmi_mask_w); DECLARE_WRITE8_MEMBER(braze_a15_w); DECLARE_WRITE8_MEMBER(dkong_videoram_w); DECLARE_WRITE8_MEMBER(dkongjr_gfxbank_w); DECLARE_WRITE8_MEMBER(dkong3_gfxbank_w); DECLARE_WRITE8_MEMBER(dkong_palettebank_w); DECLARE_WRITE8_MEMBER(radarscp_grid_enable_w); DECLARE_WRITE8_MEMBER(radarscp_grid_color_w); DECLARE_WRITE8_MEMBER(dkong_flipscreen_w); DECLARE_WRITE8_MEMBER(dkong_spritebank_w); DECLARE_WRITE8_MEMBER(dkong_voice_w); DECLARE_WRITE8_MEMBER(dkong_audio_irq_w); DECLARE_READ8_MEMBER(p8257_ctl_r); DECLARE_WRITE8_MEMBER(p8257_ctl_w); DECLARE_WRITE8_MEMBER(p8257_drq_w); DECLARE_WRITE8_MEMBER(dkong_z80dma_rdy_w); DECLARE_READ8_MEMBER(braze_eeprom_r); DECLARE_WRITE8_MEMBER(braze_eeprom_w); DECLARE_DRIVER_INIT(strtheat); DECLARE_DRIVER_INIT(herodk); DECLARE_DRIVER_INIT(dkingjr); DECLARE_DRIVER_INIT(drakton); DECLARE_DRIVER_INIT(dkongx); TILE_GET_INFO_MEMBER(dkong_bg_tile_info); TILE_GET_INFO_MEMBER(radarscp1_bg_tile_info); DECLARE_MACHINE_START(dkong2b); DECLARE_MACHINE_RESET(dkong); DECLARE_VIDEO_START(dkong); DECLARE_VIDEO_START(dkong_base); DECLARE_PALETTE_INIT(dkong2b); DECLARE_MACHINE_START(dkong3); DECLARE_PALETTE_INIT(dkong3); DECLARE_MACHINE_START(radarscp); DECLARE_PALETTE_INIT(radarscp); DECLARE_MACHINE_START(radarscp1); DECLARE_PALETTE_INIT(radarscp1); DECLARE_MACHINE_START(s2650); DECLARE_MACHINE_RESET(strtheat); DECLARE_MACHINE_RESET(drakton); UINT32 screen_update_dkong(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); UINT32 screen_update_pestplce(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); UINT32 screen_update_spclforc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(s2650_interrupt); INTERRUPT_GEN_MEMBER(vblank_irq); TIMER_CALLBACK_MEMBER(scanline_callback); DECLARE_WRITE8_MEMBER(M58817_command_w); DECLARE_READ8_MEMBER(dkong_voice_status_r); DECLARE_READ8_MEMBER(dkong_tune_r); DECLARE_WRITE8_MEMBER(dkong_p1_w); }; /*----------- defined in audio/dkong.c -----------*/ MACHINE_CONFIG_EXTERN( radarscp_audio ); MACHINE_CONFIG_EXTERN( dkong2b_audio ); MACHINE_CONFIG_EXTERN( dkongjr_audio ); MACHINE_CONFIG_EXTERN( dkong3_audio ); MACHINE_CONFIG_EXTERN( radarscp1_audio );
[ "brymaster@gmail.com" ]
brymaster@gmail.com
893249bc865df1ca7268c1655ab2a868e4be5090
8edcbc5cb37cffb3d9b3c000c982a66992f41643
/autocomplete.cpp
fb5c66c0e25d0e72b2d20c1f528e5414877046c8
[]
no_license
darylnak/Bloom-Filter
fb2cbb4ce933220e5985967fcd66152dfef799ba
b5903753f8d8706e9b4840f59cc340e7cf9da895
refs/heads/master
2020-05-17T03:55:24.552082
2019-05-07T02:57:15
2019-05-07T02:57:15
183,495,481
0
0
null
null
null
null
UTF-8
C++
false
false
3,887
cpp
/** * Filename: autocomplete.cpp * * Team: Brandon Olmos (bolmos@ucsd.edu), * Daryl Nakamoto (dnakamot@ucsd.edu) * * Reference(s): cplusplus.com * * Description: Read a dictionary into ternary trie and suggest * autocompletion K results to users based on an input prefx * and K number of wanted suggested completions. */ #include <iostream> #include <fstream> #include <sstream> #include "DictionaryTrie.hpp" #include "util.hpp" using namespace std; /** find an underscore in str. Return true if found, false if not.*/ bool findUnderscoreIn(string str) { for(char& c : str) { if(c == '_') return true; } return false; } /** * IMPORTANT! You should use the following lines of code to match the correct output: * * cout << "This program needs exactly one argument!" << endl; * cout << "Reading file: " << file << endl; * cout << "Enter a prefix/pattern to search for:" << endl; * cout << "Enter a number of completions:" << endl; * cout << completion << endl; * cout << "Continue? (y/n)" << endl; * * arg 1 - Input file name (in format like freq_dict.txt) * * * Run queries for autocompletion */ int main(int argc, char** argv) { /** DEBUGGING /* string test = "hello"; string hold; while(test.length() > 0) { cout << test << endl; test.erase(0, 1); } DictionaryTrie trie; DictionaryTrie trie2; bool check1 = false; check1 = trie.insert("g", 10); check1 = trie.insert("a", 1); check1 = trie.insert("h", 1000); check1 = trie.insert("g", 10); check1 = trie.insert("a", 1); check1 = trie.insert("h", 1000); check1 = trie2.insert("get", 30000); check1 = trie2.insert("apple", 1); check1 = trie2.insert("gat", 2); check1 = trie2.insert("git", 3); check1 = trie2.insert("git", 3); check1 = trie2.insert("github", 1337); //*/ char yes = 'y'; // exit due to incorrect argument count if(argc != 2) { cout << "This program needs exactly one argument!" << endl; return -1; } DictionaryTrie dictionary; // dictionary trie vector<string> completions; // hold completions to return string file = argv[1]; // hold file name string prefix; // hold prefix string getCompletions; // hold number of completions unsigned int numCompletions; // // hold number of completions char _continue; Utils read; ifstream load; bool hasUnderscore = false; cout << "Reading file: " << file << endl; load.open(file, ifstream::in); // open file read.load_dict(dictionary, load); // populate trie load.close(); // start program do { cout << "Enter a prefix/pattern to search for:" << endl; getline(cin, prefix); cout << "Enter a number of completions:" << endl; cin >> getCompletions; // get number of completions from input. Convert string to integer istringstream convert(getCompletions); convert >> numCompletions; // check for underscore/wildcard in prefix hasUnderscore = findUnderscoreIn(prefix); // run autocompletion with wild card if(hasUnderscore) completions = dictionary.predictUnderscore(prefix, numCompletions); // run regular autocompletion else completions = dictionary.predictCompletions(prefix, numCompletions); // print autocomplete suggestions for(auto itr = completions.begin(); itr != completions.end(); ++itr) cout << *itr << endl; cout << "Continue? (y/n)" << endl; cin >> _continue; cin.ignore(); // clear new line character from input sequence } while(_continue == yes); // check if program needs to end return 0; }
[ "dnak@no-reply.github.com" ]
dnak@no-reply.github.com
01584947f7eeb21161fde4b6e3229f148d06dce5
c6f1349d1153f4cdce5dfb108f9cb18f7bc2f09d
/MPosWebAdmin/DataBase/datbasesettingsdialog.cpp
b2a057fcdffbc0d0dc92f71ca7bd618ea9b5d1f5
[]
no_license
rust3128/MposWebServer
1fcc1ebb8409781c5b0d38a97d32847a00975800
5b00f728ad3b23570b6ac39994955f711154dd79
refs/heads/master
2020-12-20T07:26:02.177418
2020-02-07T13:58:59
2020-02-07T13:58:59
236,001,733
0
1
null
null
null
null
UTF-8
C++
false
false
1,602
cpp
#include "datbasesettingsdialog.h" #include "ui_datbasesettingsdialog.h" #include "LoggingCategories/loggingcategories.h" DatbaseSettingsDialog::DatbaseSettingsDialog(QSettings *set, QWidget *parent) : QDialog(parent), ui(new Ui::DatbaseSettingsDialog), dbSettings(set) { ui->setupUi(this); createUI(); } DatbaseSettingsDialog::~DatbaseSettingsDialog() { delete ui; } void DatbaseSettingsDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; } } void DatbaseSettingsDialog::createUI() { ui->lineEditServer->setText(dbSettings->value("Server").toString()); ui->spinBoxPort->setValue(dbSettings->value("Port").toInt()); ui->lineEditDatabase->setText(dbSettings->value("Database").toString()); ui->lineEditUser->setText(dbSettings->value("User").toString()); ui->lineEditPassword->setText(dbSettings->value("Password").toString()); } void DatbaseSettingsDialog::on_buttonBox_rejected() { this->reject(); } void DatbaseSettingsDialog::on_buttonBox_accepted() { qInfo(logInfo()) << "INI file CROUP" << dbSettings->group(); dbSettings->setValue("Server",ui->lineEditServer->text().trimmed()); dbSettings->setValue("Port",ui->spinBoxPort->value()); dbSettings->setValue("Database",ui->lineEditDatabase->text().trimmed()); dbSettings->setValue("User",ui->lineEditUser->text().trimmed()); dbSettings->setValue("Password",ui->lineEditPassword->text().trimmed()); this->accept(); }
[ "rust3128@gmail.com" ]
rust3128@gmail.com
38d28ad83832a1b6b39388e57dbc7cebf2964501
5ac4199d968f301e01ef741fe7d1d162c4f82921
/Samples/Physics/MassSprings3D/CpuMassSpringVolume.h
422b3f1a17f805dfe16d09ecd79f804b6507d6b5
[ "LicenseRef-scancode-unknown-license-reference", "BSL-1.0" ]
permissive
kabukunz/GeometricTools
9eada1b0d8b1447398e8739c9684e5ed14d4cf96
bbc55cdef89a877f06310fdb6c6248205eae704b
refs/heads/master
2020-11-25T11:54:23.772441
2019-12-17T16:11:32
2019-12-17T16:11:32
228,645,271
0
0
null
null
null
null
UTF-8
C++
false
false
4,230
h
// David Eberly, Geometric Tools, Redmond WA 98052 // Copyright (c) 1998-2019 // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // Version: 4.0.2019.08.13 #pragma once #include <Applications/Environment.h> #include <Graphics/ProgramFactory.h> using namespace gte; class CpuMassSpringVolume { public: // Construction and destruction. This class represents a CxRxS array of // masses lying on in a volume and connected by an array of springs. The // masses are indexed by mass(c,r,s) for 0 <= c < C, 0 <= r < R, and // 0 <= s < S. The mass at interior position X(c,r,s) is connected by // springs to the masses at positions X(c,r-1,s), X(c,r+1,s), X(c-1,r,s), // X(c+1,r,s), X(c,r,s-1), and X(c,r,s+1). Boundary masses have springs // connecting them to their neighbors: a "face" mass has 5 neighbors, an // "edge" mass has 4 neighbors, and a "corner" mass has 3 neighbors. ~CpuMassSpringVolume() = default; CpuMassSpringVolume(std::shared_ptr<ProgramFactory> const& factory, int numColumns, int numRows, int numSlices, float step, float viscosity, Environment& environment, bool& created); // Deferred construction. The physical parameters must be set before // starting the simulation. // Basic physical parameters. The indices must satisfy 0 <= c < C, // 0 <= r < R, and 0 <= s < S. void SetMass(int c, int r, int s, float mass); void SetPosition(int c, int r, int s, Vector3<float> const& position); void SetVelocity(int c, int r, int s, Vector3<float> const& velocity); // Each interior mass at (c,r,s) has 6 adjacent springs. Face masses // have only 5 neighbors, edge masses have only 4 neighbors, and corner // masses have only 3 neighbors. Each mass provides access to 3 adjacent // springs at (c+1,r,s), (c,r+1,s), and (c,r,s+1). The face, edge, and // corner masses provide access to only an appropriate subset of these. // The indices must satisfy // ConstantC/LengthC: 0 <= c < C-1, 0 <= r < R, 0 <= s < S // ConstantR/LengthR: 0 <= c < C, 0 <= r < R-1, 0 <= s < S // ConstantS/LengthS: 0 <= c < C, 0 <= r < R, 0 <= s < S-1 void SetConstantC(int c, int r, int s, float v); // spring to (c+1,r,s) void SetLengthC(int c, int r, int s, float v); // spring to (c+1,r,s) void SetConstantR(int c, int r, int s, float v); // spring to (c,r+1,s) void SetLengthR(int c, int r, int s, float v); // spring to (c,r+1,s) void SetConstantS(int c, int r, int s, float v); // spring to (c,r,s+1) void SetLengthS(int c, int r, int s, float v); // spring to (c,r,s+1) // Member access. Vector3<float> GetPosition(int c, int r, int s) const; std::vector<Vector3<float>>& GetPosition(); // Update the particle positions and velocities based on current time and // particle state. void Update(float time); private: // Compute the acceleration x" = F/m applied to the specified particle. // The internal forces are from the mass-spring equations of motion. Vector3<float> Acceleration(int i, int c, int r, int s, float time, std::vector<Vector3<float>> const& position, std::vector<Vector3<float>> const& velocity); // Mapping from 3D array to 1D memory. int GetIndex(int c, int r, int s) const; // Constructor inputs. int mNumColumns, mNumRows, mNumSlices; int mNumSliceElements, mNumVolumeElements; float mStep, mHalfStep, mSixthStep; float mViscosity; // Physical parameters. std::vector<float> mMass, mInvMass; std::vector<Vector3<float>> mPosition, mVelocity; std::vector<float> mConstantC, mLengthC; std::vector<float> mConstantR, mLengthR; std::vector<float> mConstantS, mLengthS; // Temporary storage for the Runge-Kutta differential equation solver. struct Temporary { Vector3<float> d1, d2, d3, d4; }; std::vector<Vector3<float>> mPTmp, mVTmp; std::vector<Temporary> mPAllTmp, mVAllTmp; };
[ "kabukunz@gmail.com" ]
kabukunz@gmail.com
7c271505835230812f750bdc53a9593c14658328
b53bcf8af99835ecba1c67ac726e34cb6cddfde6
/phase3/test/simulator/CellTest.cpp
06540818ccbb1882596fed74dae3675d23c4a721
[]
no_license
zainsalmandar/Bug-World-Software-Engineering-Project-
1f22f0380c89218ca9b0d52dadeb3ca49e0d8471
e5ddb77bf9714121d673a05e48e215cb95159b71
refs/heads/master
2020-03-11T14:31:48.313513
2018-06-13T11:43:24
2018-06-13T11:43:24
130,057,299
0
0
null
null
null
null
UTF-8
C++
false
false
2,466
cpp
#include "CellTest.h" #include "../../src/simulator/Cell.h" CPPUNIT_TEST_SUITE_REGISTRATION(CellTest); void CellTest::testConstructor() { char valid_sym[] ={'#', '+', '-', '.'}; char digits[] = {'1', '2', '3', '4', '5','6','7','8', '9'}; for(int i=0;i<4;i++){ CPPUNIT_ASSERT_NO_THROW(Cell testCell(valid_sym[i])); } for(int i=0;i<9;i++){ CPPUNIT_ASSERT_NO_THROW(Cell testCell(digits[i])); } bool exceptionThrown; char invalid_sym[] = {'$', '/', '*', '='}; for(int i=0;i<4;i++){ exceptionThrown = false; try { Cell testCell(invalid_sym[i]); } catch(std::runtime_error){ exceptionThrown = true; } } if(!exceptionThrown){ CPPUNIT_FAIL("No exception thrown for invalid symbol"); } Cell obs_cell('#'),food_cell('5'), clear('.'), black_home('-'), red_home('+'); CPPUNIT_ASSERT(obs_cell.has_obstruction()==true); CPPUNIT_ASSERT(food_cell.get_food() == 5); CPPUNIT_ASSERT(clear.has_obstruction()==false); CPPUNIT_ASSERT(black_home.is_black_home_area() == true); CPPUNIT_ASSERT(black_home.is_red_home_area() == false); CPPUNIT_ASSERT(red_home.is_red_home_area() == true); CPPUNIT_ASSERT(red_home.is_black_home_area() == false); } void CellTest::testGetters() { Cell obs_cell('#'), food_cell('7'), clear('.'), black_home('-'), red_home('+'); CPPUNIT_ASSERT(obs_cell.has_obstruction()==true); CPPUNIT_ASSERT(food_cell.get_food() == 7); CPPUNIT_ASSERT(clear.has_obstruction()==false); CPPUNIT_ASSERT(black_home.is_black_home_area() == true); CPPUNIT_ASSERT(black_home.is_red_home_area() == false); CPPUNIT_ASSERT(red_home.is_red_home_area() == true); CPPUNIT_ASSERT(red_home.is_black_home_area() == false); color_t col; col.val = 0; Bug testBug(col, 1, 10); clear.set_occupant(&testBug); CPPUNIT_ASSERT(clear.get_occupant()->get_progid() == testBug.get_progid()); } void CellTest::testSetters(){ Cell clear1('.'),clear2('.'),obs('#'); color_t col; col.val = 1; Bug testBug(col, 1, 10); clear1.set_occupant(&testBug); clear2.set_food(3); CPPUNIT_ASSERT(clear1.get_occupant()->get_progid() == testBug.get_progid()); CPPUNIT_ASSERT(clear2.get_food() == 3); CPPUNIT_ASSERT_THROW(obs.set_occupant(&testBug), std::runtime_error); CPPUNIT_ASSERT_THROW(obs.set_food(5), std::runtime_error); }
[ "noreply@github.com" ]
zainsalmandar.noreply@github.com
8c5d18954179681a8ec67fcab981eb120226bd0d
9eea0f0ce2aaf4b6d1869035165d339ee7e25cf9
/include/common_behavior/master_service_requester.h
0b1d060e8d7ada7921289bde88de8f326486c2fa
[]
no_license
dseredyn/common_behavior
b286e42f68de1ddf183c281dbb365e5d0293e71b
c2f2aa5e67b8cc96faf3aa84183cda11362a0704
refs/heads/master
2020-07-04T20:58:25.652029
2017-07-08T13:14:26
2017-07-08T13:14:26
74,143,296
0
0
null
2017-05-22T09:07:47
2016-11-18T15:44:28
C++
UTF-8
C++
false
false
4,881
h
/* Copyright (c) 2016, Robot Control and Pattern Recognition Group, Warsaw University of Technology All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Warsaw University of Technology nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYright HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef COMMON_BEHAVIOR_MASTER_SERVICE_REQUESTER_H_ #define COMMON_BEHAVIOR_MASTER_SERVICE_REQUESTER_H_ #include "common_behavior/input_data.h" #include "common_behavior/buffer_info.h" #include "common_behavior/abstract_behavior.h" #include "common_behavior/abstract_predicate_list.h" #include <string> #include "rtt/RTT.hpp" namespace common_behavior { class MasterServiceRequester : public RTT::ServiceRequester { public: explicit MasterServiceRequester(RTT::TaskContext *owner) : RTT::ServiceRequester("master", owner) , initBuffersData("initBuffersData") , readBuffers("readBuffers") , getBuffers("getBuffers") , writePorts("writePorts") , getDataSample("getDataSample") , getLowerInputBuffers("getLowerInputBuffers") , getUpperInputBuffers("getUpperInputBuffers") , getLowerOutputBuffers("getLowerOutputBuffers") , getUpperOutputBuffers("getUpperOutputBuffers") , getBehaviors("getBehaviors") , getStates("getStates") , getInitialState("getInitialState") , allocatePredicateList("allocatePredicateList") , calculatePredicates("calculatePredicates") , getPredicatesStr("getPredicatesStr") , iterationEnd("iterationEnd") { this->addOperationCaller(initBuffersData); this->addOperationCaller(readBuffers); this->addOperationCaller(getBuffers); this->addOperationCaller(writePorts); this->addOperationCaller(getDataSample); this->addOperationCaller(getLowerInputBuffers); this->addOperationCaller(getUpperInputBuffers); this->addOperationCaller(getLowerOutputBuffers); this->addOperationCaller(getUpperOutputBuffers); this->addOperationCaller(getBehaviors); this->addOperationCaller(getStates); this->addOperationCaller(getInitialState); this->addOperationCaller(allocatePredicateList); this->addOperationCaller(calculatePredicates); this->addOperationCaller(getPredicatesStr); this->addOperationCaller(iterationEnd); } // OROCOS ports operations RTT::OperationCaller<void (InputDataPtr&)> initBuffersData; RTT::OperationCaller<bool()> readBuffers; RTT::OperationCaller<void(InputDataPtr&)> getBuffers; RTT::OperationCaller<void (InputDataPtr&)> writePorts; RTT::OperationCaller<InputDataPtr()> getDataSample; // subsystem buffers RTT::OperationCaller<void(std::vector<InputBufferInfo >&)> getLowerInputBuffers; RTT::OperationCaller<void(std::vector<InputBufferInfo >&)> getUpperInputBuffers; RTT::OperationCaller<void(std::vector<OutputBufferInfo >&)> getLowerOutputBuffers; RTT::OperationCaller<void(std::vector<OutputBufferInfo >&)> getUpperOutputBuffers; // FSM parameters RTT::OperationCaller<std::vector<std::string >()> getBehaviors; RTT::OperationCaller<std::vector<std::string >()> getStates; RTT::OperationCaller<std::string()> getInitialState; RTT::OperationCaller<PredicateListPtr() > allocatePredicateList; RTT::OperationCaller<void(const InputDataConstPtr&, const std::vector<const RTT::TaskContext*>&, PredicateListPtr&) > calculatePredicates; RTT::OperationCaller<std::string(const PredicateListConstPtr&) > getPredicatesStr; RTT::OperationCaller<void()> iterationEnd; }; } // namespace common_behavior #endif // COMMON_BEHAVIOR_MASTER_SERVICE_REQUESTER_H_
[ "dawid.seredynski@gmail.com" ]
dawid.seredynski@gmail.com
d0606638dd5fc7886809bba256d2affb043aeed6
7eb00fc898d5d1b1ad3de8e439b93f927ef52463
/1335A.cpp
af67536ef609a41339d4911197f2e33d6820e1c3
[]
no_license
Soumili1818/CPP-Programs-
8b3db718875ab15ccf98709b6763a846d0f3e221
8548902311452f864c9802920728e5f830581c1e
refs/heads/main
2023-08-16T07:35:00.925198
2021-10-23T08:39:55
2021-10-23T08:39:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
429
cpp
#include<bits/stdc++.h> using namespace std; int main(){ unsigned int n,temp; cin>>n; for (int i = 0; i < n; i++) { cin>>temp; if(temp<3){ cout<<0<<endl; } else{ if(temp%2==0){ cout<<(temp/2)-1<<endl; } else{ cout<<temp/2<<endl; } } } return 0; }
[ "noreply@github.com" ]
Soumili1818.noreply@github.com
db7b3c1c0e0774290151acf597a81ca38f60b8f0
54f352a242a8ad6ff5516703e91da61e08d9a9e6
/Source Codes/AtCoder/agc024/B/2542318.cpp
bde81fe6bc76b97afc440e154378344232a747fa
[]
no_license
Kawser-nerd/CLCDSA
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
aee32551795763b54acb26856ab239370cac4e75
refs/heads/master
2022-02-09T11:08:56.588303
2022-01-26T18:53:40
2022-01-26T18:53:40
211,783,197
23
9
null
null
null
null
UTF-8
C++
false
false
1,342
cpp
#include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> // c++11 #include <array> #include <tuple> #include <unordered_map> #include <unordered_set> #define mp make_pair #define mt make_tuple #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; const int INF = 1 << 29; const ll LL_INF = 1LL << 60; const double EPS = 1e-9; const ll MOD = 1000000007; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int N; vector<int> A; map<int, int> values; int res; int main() { cin >> N; A.resize(N); for (auto &val : A) { cin >> val; } for (int i = 0; i < N; i++) { int val = A[i]; values[val] = values[val - 1] + 1; res = max(res, values[val]); } cout << N - res << endl; return 0; }
[ "kwnafi@yahoo.com" ]
kwnafi@yahoo.com
fb4580620bad9b3b761b3dff22cb6fe10179450c
8d71d7c9aca031934224dec11701d0037ae12039
/src/math/Mat4.h
58df811960adc49add77a579574446f24171042b
[]
no_license
misdake/E4
1ef3a236f002ff296d21bb16af6df950a3a8d4da
95136b78905afe65f75ae7721768ec9ac4b1caa1
refs/heads/dev
2020-05-19T07:38:45.264462
2020-05-18T02:23:20
2020-05-18T02:23:20
184,899,300
0
0
null
2019-07-31T05:41:06
2019-05-04T13:36:10
C++
UTF-8
C++
false
false
1,880
h
#pragma once #include "Vec3.h" namespace E4 { class Mat4 { public: float m00, m01, m02, m03; float m10, m11, m12, m13; float m20, m21, m22, m23; float m30, m31, m32, m33; //set void set(const float* array); void set(const Mat4& matrix); void set(float n00, float n01, float n02, float n03, float n10, float n11, float n12, float n13, float n20, float n21, float n22, float n23, float n30, float n31, float n32, float n33); void setZero(); void setIdentity(); //TODO add Vec3 versions void setTranslate(float x, float y, float z); void setRotateX(float r); void setRotateY(float r); void setRotateZ(float r); void setRotate(float x, float y, float z, float r); void setScale(float s); void setScale(float x, float y, float z); void setTRS(float x, float y, float z, float rx, float ry, float rz, float sx, float sy, float sz); void setPerspective(float fovy, float aspect, float zNear, float zFar); void setOrtho(float left, float right, float top, float bottom, float zNear, float zFar); //TODO // void setLookAt(float fx, float fy, float fz, float tx, float ty, float tz, float ux, float uy, float uz); //get float* array(); const float* array() const; float* operator[](int i); //op Mat4& operator=(const Mat4& src) = default; float determinant() const; bool invert(); bool invert(Mat4& dest) const; void transpose(); void transpose(Mat4& dest) const; static void multiply(const Mat4& left, const Mat4& right, Mat4& dest); Mat4 operator*(const Mat4& right) const; Vec3 transformPoint(const Vec3& src) const; Vec3 transformNormal(const Vec3& src) const; }; }
[ "misdake@gmail.com" ]
misdake@gmail.com
02937789436b3edf3e3101657c68189b3ef2a88e
09f3e5bc007c6de75c6059cc6da8eb97de14ec0b
/src/parser.cpp
518177b1bad1645afdfe13d44162962e2970d96d
[]
no_license
Epsylon42/ejdi
7564c8988bd47edcfed4114dedc88199a11d591d
cb2e37c93633724dd70a6316678d6bd009202bbb
refs/heads/main
2021-06-24T07:14:11.659073
2019-10-27T18:31:15
2019-10-27T18:31:15
213,053,738
0
0
null
null
null
null
UTF-8
C++
false
false
12,740
cpp
#include <algorithm> #include <cassert> #include <parser.hpp> using namespace std; using namespace ejdi; using namespace ejdi::lexer; using namespace ejdi::lexer::groups; using namespace ejdi::parser; using namespace ejdi::parser::result; using namespace ejdi::ast; using ejdi::span::Span; ParseStream ParseStream::clone() const { return *this; } bool ParseStream::peek(string_view str) const { if (is_empty()) { return false; } return get_str(*begin) == str; } bool ParseStream::is_empty() const { return begin >= end; } Span ParseStream::span() const { if (is_empty()) { if (parent == nullptr) { return Span::empty(); } else { return parent->surrounding.cl.span; } } else { return get_span(*begin); } } string ParseStream::str() const { string ret; if (is_empty()) { if (parent == nullptr) { ret = ""; } else { ret = parent->surrounding.cl.str; } } else { ret = string(get_str(*begin)); } if (ret.empty()) { return "[<empty string>]"; } else { return ret; } } unique_ptr<ParserError> ParseStream::expected(string expected) const { return make_unique<ParserError>(span(), move(expected), str()); } ParserResult<Expr> parser::parse_primary_expr(ParseStream& in) { auto stream = in.clone(); auto num = DO(parse_number_literal(stream)); if (num.has_result()) { in = stream; return Expr(move(num.get())); } auto str = DO(parse_string_literal(stream)); if (str.has_result()) { in = stream; return Expr(move(str.get())); } auto boolean = DO(parse_bool_literal(stream)); if (boolean.has_result()) { in = stream; return Expr(move(boolean.get())); } auto func = DO(parse_function_literal(stream)); if (func.has_result()) { in = stream; return Expr(move(func.get())); } auto array = DO(parse_array_literal(stream)); if (array.has_result()) { in = stream; return Expr(move(array.get())); } auto block = DO(parse_block(stream)); if (block.has_result()) { in = stream; return Expr(move(block.get())); } auto if_ = DO(parse_conditional(stream)); if (if_.has_result()) { in = stream; return Expr(move(if_.get())); } auto while_ = DO(parse_while_loop(stream)); if (while_.has_result()) { in = stream; return Expr(move(while_.get())); } auto for_ = DO(parse_for_loop(stream)); if (for_.has_result()) { in = stream; return Expr(move(for_.get())); } auto word = DO(parse<Word>(stream)); if (word.has_result()) { in = stream; return Expr(make_shared<Variable>(Variable{ word.get() })); } return in.expected("primary expression"); } ParserResult<Expr> parser::parse_unary_expr(ParseStream& in) { const auto valid_ops = { "!", "+", "-" }; auto stream = in.clone(); vector<Punct> ops; while (true) { if (any_of( valid_ops.begin(), valid_ops.end(), [&](auto valid_op){ return stream.peek(valid_op); } ) ) { ops.push_back(DO(parse<Punct>(stream)).get()); } else { break; } } auto access = TRY(parse_access_expr(stream)); while (!ops.empty()) { access = make_shared<UnaryOp>(UnaryOp { move(ops.back()), move(access) }); ops.pop_back(); } in = stream; return access; } ParserResult<Expr> parser::parse_access_expr(ParseStream& in) { auto stream = in.clone(); auto primary = TRY(parse_primary_expr(stream)); while (true) { if (stream.peek(".")) { auto dot = TRY(parse_str<Punct>(".", stream)); auto field = TRY_CRITICAL(parse<Word>(stream)); auto args = DO(parse_list<Expr>(parse_expr, "()", stream)); if (args.has_result()) { primary = make_shared<MethodCall>( MethodCall { move(primary), dot, field, move(args.get()) }); } else { primary = make_shared<FieldAccess>( FieldAccess { move(primary), dot, field }); } } else { auto args = DO(parse_list<Expr>(parse_expr, "()", stream)); if (args.has_result()) { primary = make_shared<FunctionCall>( FunctionCall { move(primary), move(args.get()) }); } else { break; } } } in = stream; return primary; } ParserResult<Expr> parser::parse_expr(ParseStream& in) { const auto valid_ops = { "==", "!=", "<=", ">=", "<", ">", "+", "-", "*", "/", "%", "~", "&&", "||" }; auto expr = TRY(parse_unary_expr(in)); while (any_of( valid_ops.begin(), valid_ops.end(), [&](auto valid_op){ return in.peek(valid_op); } ) ) { auto stream = in; auto op = TRY(parse<Punct>(stream)); auto right = TRY_CRITICAL(parse_unary_expr(stream)); in = stream; expr = make_shared<BinaryOp>(BinaryOp { move(op), move(expr), move(right) }); } return expr; } ParserResult<Rc<Assignment>> parser::parse_assignment(ParseStream& in) { auto stream = in.clone(); auto let = try_parse<Word>([](auto& in){ return parse_str<Word>("let", in); }, stream); optional<Expr> base; optional<Word> field; auto dest_stream = stream.clone(); auto destination = TRY(parse_access_expr(dest_stream)); if (ast_is<Variable>(destination)) { field = ast_get<Variable>(destination)->variable; } else if (ast_is<FieldAccess>(destination)) { auto access = ast_get<FieldAccess>(destination); base = move(access->base); field = access->field; } else { return stream.expected("valid lvalue expression"); } stream = dest_stream; auto assignment = TRY(parse_str<Punct>("=", stream)); auto expr = TRY_CRITICAL(parse_expr(stream)); auto semi = TRY_CRITICAL(parse_str<Punct>(";", stream)); in = stream; return make_shared<Assignment>(Assignment { let, move(base), *field, assignment, move(expr), semi }); } ParserResult<Rc<ExprStmt>> parser::parse_expr_stmt(ParseStream& in) { auto stream = in.clone(); auto expr = TRY(parse_expr(stream)); auto semi = TRY(parse_str<Punct>(";", stream)); in = stream; return make_shared<ExprStmt>(ExprStmt{ move(expr), semi }); } ParserResult<Rc<EmptyStmt>> parser::parse_empty_stmt(ParseStream& in) { auto semi = TRY(parse_str<Punct>(";", in)); return make_shared<EmptyStmt>(EmptyStmt { semi }); } ParserResult<Stmt> parser::parse_stmt(ParseStream& in) { auto stream = in.clone(); auto assignment = DO(parse_assignment(stream)); if (assignment.has_result()) { in = stream; return Stmt(move(assignment.get())); } stream = in.clone(); auto expr_stmt = DO(parse_expr_stmt(stream)); if (expr_stmt.has_result()) { in = stream; return Stmt(move(expr_stmt.get())); } auto empty = DO(parse_empty_stmt(stream)); if (empty.has_result()) { in = stream; return Stmt(move(empty.get())); } return in.expected("statement"); } ParserResult<Rc<Block>> parser::parse_block(ParseStream& in) { auto stream = in.clone(); auto group = TRY(parse<Rc<Group>>(stream)); auto parens = group->surrounding; if (parens.str != "{}") { return in.expected("block expression"); } vector<Stmt> statements; auto group_stream = ParseStream(*group); while (true) { if (group_stream.is_empty()) { break; } auto group_stream_clone = group_stream.clone(); auto stmt = DO(parse_stmt(group_stream_clone)); if (stmt.has_result()) { statements.push_back(stmt.get()); group_stream = group_stream_clone; } else { auto expr = TRY(parse_expr(group_stream)); if (group_stream.is_empty()) { in = stream; return make_shared<Block>(Block{ move(parens), move(statements), move(expr) }); } if (ast_is<Block>(expr) || ast_is<IfThenElse>(expr) || ast_is<WhileLoop>(expr) || ast_is<ForLoop>(expr) ) { statements.push_back( make_shared<ExprStmt>(ExprStmt { move(expr), Punct(Span::empty(), string_view(";")) }) ); } else { auto err = group_stream.expected("; or }"); err->critical = true; return err; } } } in = stream; return make_shared<Block>(Block{ move(parens), move(statements), nullopt }); } ParserResult<Rc<WhileLoop>> parser::parse_while_loop(ParseStream& in) { auto stream = in.clone(); auto while_ = TRY(parse_str<Word>("while", stream)); auto cond = TRY_CRITICAL(parse_expr(stream)); auto block = TRY_CRITICAL(parse_block(stream)); in = stream; return make_shared<WhileLoop>( WhileLoop { while_, move(cond), move(block), } ); } ParserResult<Rc<ForLoop>> parser::parse_for_loop(ParseStream& in) { auto stream = in.clone(); auto for_ = TRY(parse_str<Word>("for", stream)); auto variable = TRY_CRITICAL(parse<Word>(stream)); auto in_ = TRY_CRITICAL(parse_str<Word>("in", stream)); auto iterable = TRY_CRITICAL(parse_expr(stream)); auto body = TRY_CRITICAL(parse_block(stream)); in = stream; return make_shared<ForLoop>( ForLoop { for_, variable, in_, move(iterable), move(body) } ); } ParserResult<Rc<IfThenElse>> parser::parse_conditional(ParseStream& in) { auto stream = in.clone(); auto if_ = TRY(parse_str<Word>("if", stream)); auto cond = TRY_CRITICAL(parse_expr(stream)); auto then = TRY_CRITICAL(parse_block(stream)); optional<tuple<Word, Rc<Block>>> else_; if (stream.peek("else")) { auto else_word = TRY(parse_str<Word>("else", stream)); auto else_block = TRY_CRITICAL(parse_block(stream)); else_ = make_tuple(else_word, move(else_block)); } in = stream; return make_shared<IfThenElse>( IfThenElse { if_, move(cond), move(then), move(else_) } ); } ParserResult<Rc<NumberLiteral>> parser::parse_number_literal(ParseStream& in) { auto lit = TRY(parse<lexer::NumberLit>(in)); return make_shared<NumberLiteral>(NumberLiteral { lit }); } ParserResult<Rc<StringLiteral>> parser::parse_string_literal(ParseStream& in) { auto lit = TRY(parse<lexer::StringLit>(in)); return make_shared<StringLiteral>(StringLiteral { lit }); } ParserResult<Rc<BoolLiteral>> parser::parse_bool_literal(ParseStream& in) { if (in.peek("true")) { return make_shared<BoolLiteral>(BoolLiteral { TRY(parse_str<Word>("true", in)), true }); } else if (in.peek("false")) { return make_shared<BoolLiteral>(BoolLiteral { TRY(parse_str<Word>("false", in)), false }); } else { return in.expected("boolean literal"); } } ParserResult<Rc<ArrayLiteral>> parser::parse_array_literal(ParseStream& in) { auto list = TRY(parse_list<Expr>(parse_expr, "[]", in)); return make_shared<ArrayLiteral>(ArrayLiteral { move(list) }); } ParserResult<Rc<FunctionLiteral>> parser::parse_function_literal(ParseStream& in) { auto stream = in.clone(); auto func = TRY(parse_str<Word>("func", stream)); auto argnames = TRY_CRITICAL(parse_list<Word>(parse<Word>, "()", stream)); auto body = TRY_CRITICAL(parse_expr(stream)); in = stream; return make_shared<FunctionLiteral>(FunctionLiteral { func, move(argnames), move(body) }); } ParserResult<Rc<Program>> parser::parse_program(Group& group) { auto stream = ParseStream(group.inner); vector<Stmt> statements; while (!stream.is_empty()) { statements.push_back(TRY(parse_stmt(stream))); } return make_shared<Program>(Program { move(statements) }); }
[ "eepsylon.3@gmail.com" ]
eepsylon.3@gmail.com
864f727a69bf05cf31852a3dd38d9cdbd37fc8dd
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/squid/gumtree/squid_repos_function_4876_squid-3.4.14.cpp
7bd0182172d1a2c524b49c8932e177e53150ac34
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,174
cpp
void CossSwapDir::parse(int anIndex, char *aPath) { const int i = GetInteger(); if (i <= 0) fatal("storeCossDirParse: invalid size value"); index = anIndex; path = xstrdup(aPath); max_size = static_cast<uint64_t>(i) << 20; // MBytes to Bytes parseOptions(0); if (NULL == io) changeIO(DiskIOModule::FindDefault()); /* Enforce maxobjsize being set to something */ if (max_objsize == -1) fatal("COSS requires max-size to be set to something other than -1!\n"); if (max_objsize > COSS_MEMBUF_SZ) fatalf("COSS max-size option must be less than COSS_MEMBUF_SZ (%d)\n", COSS_MEMBUF_SZ); // check that we won't overflow sfileno later. const uint64_t max_offset = (uint64_t)SwapFilenMax << blksz_bits; if (maxSize() > max_offset) { debugs(47, DBG_CRITICAL, "COSS block-size = " << (1<<blksz_bits) << " bytes"); debugs(47, DBG_CRITICAL, "COSS largest file offset = " << (max_offset >> 10) << " KB"); debugs(47, DBG_CRITICAL, "COSS cache_dir size = " << (maxSize() >> 10) << " KB"); fatal("COSS cache_dir size exceeds largest offset\n"); } }
[ "993273596@qq.com" ]
993273596@qq.com
ffa720f02f8f5c3b51efc867472a2870b6dcf577
277cd286fa69eb7ab03b806a620322d5701b04b3
/2020-Qualification/nestingDepth.cpp
16eae0ca48ab2d40f2d524b285f0f457930c78f1
[]
no_license
YeahHuang/Codejam
5cd96d45cdb8d26eadb1e3a5f1fae8c1faef4e48
5086696b9dd1ac7b09f0cab34b643dde1d916e0b
refs/heads/master
2021-05-24T17:36:36.314823
2020-07-19T15:52:52
2020-07-19T15:52:52
253,679,729
0
0
null
null
null
null
UTF-8
C++
false
false
2,319
cpp
//#include <bits/stdc++.h> #include <iostream> #include <cassert> #include <cstring> #include <cstdlib> #include <cstdio> #include <cctype> #include <cmath> #include <ctime> #include <queue> #include <set> #include <map> #include <stack> #include <string> #include <bitset> #include <vector> #include <complex> #include <algorithm> #include <unordered_map> #include <memory.h> #include <set> #include <functional> using namespace std; #define ll long long #define pii pair<int, int> #define pb push_back #define pli pair<ll, int> #define pil pair<int, ll> #define clr(a, x) memset(a, x, sizeof(a)) #define sz(a) (int)a.size() #define debug(a) cout << #a << ": " << a << endl #define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl #define fdto(i, r, l) for(int i = (r); i > (l); --i) #define fto(i, l, r) for(int i = (l); i < (r); ++i) const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const double EPS = 1e-9; double fRand(double fMin, double fMax) { double f = (double)rand() / RAND_MAX; return fMin + f * (fMax - fMin); } template <class T> T min(T a, T b, T c) { return min(a, min(b, c)); } template <class T> T max(T a, T b, T c) { return max(a, max(b, c)); } /* 23 - 57 34min S string of digits d exactly d pairs of () small: 直接连续的1两边加括号即可 large: 两个相同的可以直接当成一个整体 3 1 2 (((3))1(2)) ((22)1) 似乎可以直接推倒? left */ const int N = 1e5 + 10; // 这样更好 防止下面弄着弄着就少了个0 int q,p1,p2,T, n,cnt,delta, l,r; bool flag; string s,ans; vector<int> m[100015]; bool debugg = true; bool test = true; int main(){ ios_base::sync_with_stdio(0); cin>>T; fto(it,0,T){ cin>>s; n = s.size(); ans = ""; fto(i,0,s[0]-'0') ans += '('; ans += s[0]; fto(i,1,n){ delta = s[i] - s[i-1]; if (delta > 0){ fto(j,0,delta) ans += '('; } else if (delta < 0){ delta *= -1; fto(j,0,delta) ans += ')'; } ans += s[i]; } fto(j,0,s[n-1]-'0') ans += ')'; cout << "Case #" << it + 1 << ": "<<ans<<endl; } }
[ "noreply@github.com" ]
YeahHuang.noreply@github.com
4b291fa7d0f131bc19bba21b51d40532225005b9
8c9fe5b679cdcd29e92c1e2ab35244d7beffd544
/autoGenerate/setFrame/frame/worker/worker/workerMain.cpp
660ad5fe2adebeff9583d58ed08eaa02c5d82c5b
[]
no_license
fresh-ji/SimuFrame
456cabc43565f96cdb68513220644ece79681905
b5d85a31e4ce33909ba46829f460ae9eb88f0d83
refs/heads/master
2021-08-06T23:45:36.473057
2017-11-07T06:52:52
2017-11-07T06:52:52
107,382,049
0
0
null
null
null
null
UTF-8
C++
false
false
642
cpp
#include "workerI.h" using namespace std; using namespace Demo; using namespace Ice; int main(int argc, char* argv[]) { Ice::CommunicatorPtr ic; try { ic = Ice::initialize(argc,argv); ObjectAdapterPtr Adapter = ic->createObjectAdapterWithEndpoints("Adapter", "$MODELLOCATION$"); $MODELNAME$Ptr Ptr = new $MODELNAME$I; Adapter->add(Ptr, ic->stringToIdentity("sentinel")); Adapter->activate(); cout << "$MODELNAME$ is ready!!" << endl; ic->waitForShutdown(); } catch (const Ice::Exception& ex) { cerr << ex << endl; } catch (const char* msg) { cerr << msg << endl; } if (ic) { ic->destroy(); } return 0; }
[ "jihangchn@163.com" ]
jihangchn@163.com
ce1da9ae59680316bb7bec5f297bc5bb403ea837
07327b5e8b2831b12352bf7c6426bfda60129da7
/Include/10.0.10240.0/um/animationcoordinator.h
d6d33527aed48d1c5e62006f4a096a31da9a8f28
[]
no_license
tpn/winsdk-10
ca279df0fce03f92036e90fb04196d6282a264b7
9b69fd26ac0c7d0b83d378dba01080e93349c2ed
refs/heads/master
2021-01-10T01:56:18.586459
2018-02-19T21:26:31
2018-02-19T21:29:50
44,352,845
218
432
null
null
null
null
UTF-8
C++
false
false
6,533
h
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 8.00.0613 */ /* @@MIDL_FILE_HEADING( ) */ #pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 475 #endif /* verify that the <rpcsal.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCSAL_H_VERSION__ #define __REQUIRED_RPCSAL_H_VERSION__ 100 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif /* __RPCNDR_H_VERSION__ */ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef __animationcoordinator_h__ #define __animationcoordinator_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef __IInputPaneAnimationCoordinator_FWD_DEFINED__ #define __IInputPaneAnimationCoordinator_FWD_DEFINED__ typedef interface IInputPaneAnimationCoordinator IInputPaneAnimationCoordinator; #endif /* __IInputPaneAnimationCoordinator_FWD_DEFINED__ */ #ifndef __ShowInputPaneAnimationCoordinator_FWD_DEFINED__ #define __ShowInputPaneAnimationCoordinator_FWD_DEFINED__ #ifdef __cplusplus typedef class ShowInputPaneAnimationCoordinator ShowInputPaneAnimationCoordinator; #else typedef struct ShowInputPaneAnimationCoordinator ShowInputPaneAnimationCoordinator; #endif /* __cplusplus */ #endif /* __ShowInputPaneAnimationCoordinator_FWD_DEFINED__ */ #ifndef __HideInputPaneAnimationCoordinator_FWD_DEFINED__ #define __HideInputPaneAnimationCoordinator_FWD_DEFINED__ #ifdef __cplusplus typedef class HideInputPaneAnimationCoordinator HideInputPaneAnimationCoordinator; #else typedef struct HideInputPaneAnimationCoordinator HideInputPaneAnimationCoordinator; #endif /* __cplusplus */ #endif /* __HideInputPaneAnimationCoordinator_FWD_DEFINED__ */ /* header files for imported files */ #include "wtypes.h" #include "unknwn.h" #include "dcompanimation.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_animationcoordinator_0000_0000 */ /* [local] */ //--------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- #include <winapifamily.h> #pragma region Desktop Family #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #if (NTDDI_VERSION >= NTDDI_WINBLUE) extern RPC_IF_HANDLE __MIDL_itf_animationcoordinator_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_animationcoordinator_0000_0000_v0_0_s_ifspec; #ifndef __IInputPaneAnimationCoordinator_INTERFACE_DEFINED__ #define __IInputPaneAnimationCoordinator_INTERFACE_DEFINED__ /* interface IInputPaneAnimationCoordinator */ /* [unique][uuid][object][local] */ EXTERN_C const IID IID_IInputPaneAnimationCoordinator; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("2AF16BA9-2DE5-4B75-82D9-01372AFBFFB4") IInputPaneAnimationCoordinator : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE AddAnimation( /* [annotation][in] */ _In_ IUnknown *device, /* [annotation][in] */ _In_ IDCompositionAnimation *animation) = 0; }; #else /* C style interface */ typedef struct IInputPaneAnimationCoordinatorVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IInputPaneAnimationCoordinator * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( IInputPaneAnimationCoordinator * This); ULONG ( STDMETHODCALLTYPE *Release )( IInputPaneAnimationCoordinator * This); HRESULT ( STDMETHODCALLTYPE *AddAnimation )( IInputPaneAnimationCoordinator * This, /* [annotation][in] */ _In_ IUnknown *device, /* [annotation][in] */ _In_ IDCompositionAnimation *animation); END_INTERFACE } IInputPaneAnimationCoordinatorVtbl; interface IInputPaneAnimationCoordinator { CONST_VTBL struct IInputPaneAnimationCoordinatorVtbl *lpVtbl; }; #ifdef COBJMACROS #define IInputPaneAnimationCoordinator_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define IInputPaneAnimationCoordinator_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define IInputPaneAnimationCoordinator_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define IInputPaneAnimationCoordinator_AddAnimation(This,device,animation) \ ( (This)->lpVtbl -> AddAnimation(This,device,animation) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __IInputPaneAnimationCoordinator_INTERFACE_DEFINED__ */ #ifndef __AnimationCoordinatorLib_LIBRARY_DEFINED__ #define __AnimationCoordinatorLib_LIBRARY_DEFINED__ /* library AnimationCoordinatorLib */ /* [version][uuid] */ EXTERN_C const IID LIBID_AnimationCoordinatorLib; EXTERN_C const CLSID CLSID_ShowInputPaneAnimationCoordinator; #ifdef __cplusplus class DECLSPEC_UUID("1F046ABF-3202-4DC1-8CB5-3C67617CE1FA") ShowInputPaneAnimationCoordinator; #endif EXTERN_C const CLSID CLSID_HideInputPaneAnimationCoordinator; #ifdef __cplusplus class DECLSPEC_UUID("384742B1-2A77-4CB3-8CF8-1136F5E17E59") HideInputPaneAnimationCoordinator; #endif #endif /* __AnimationCoordinatorLib_LIBRARY_DEFINED__ */ /* interface __MIDL_itf_animationcoordinator_0000_0002 */ /* [local] */ #endif // (NTDDI_VERSION >= NTDDI_WINBLUE) #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */ #pragma endregion extern RPC_IF_HANDLE __MIDL_itf_animationcoordinator_0000_0002_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_animationcoordinator_0000_0002_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
[ "trent@trent.me" ]
trent@trent.me
7c1b2eea6aafc0ca39af14266a0a8fae634cd001
97af7e305f5868effe30092621d2213a6c994b35
/Traditional-Algorithms/LeetCode26.cpp
8b7a5dc03e4b1019c2f91d27e0894ded5f115a34
[]
no_license
hyamy/Algorithms
b631d5070e33bdc8dd5a6ddb722464535a787259
0dc48b87cb1e4de33891be0dd3366ffb032bdd65
refs/heads/master
2022-05-26T06:54:57.244511
2020-04-30T06:03:35
2020-04-30T06:03:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
490
cpp
class Solution { public: int removeDuplicates(vector<int>& nums) { int len = nums.size(); if(len == 0 || len == 1) return len; int front = nums[0]; int count = 1; for(int i = 1 ;i < nums.size();){ if(nums[i] == front){ nums.erase(nums.begin()+i); continue; }else{ front = nums[i]; i++; } } return nums.size(); } };
[ "jpzhu.gm@gmail.com" ]
jpzhu.gm@gmail.com
f1b427ad8d0f773c8565093c088f06b2f7ae31d2
3ea34c23f90326359c3c64281680a7ee237ff0f2
/Data/3458/E
0b94e9d068159792648c0dd4b5cc4f37b18d508a
[]
no_license
lcnbr/EM
c6b90c02ba08422809e94882917c87ae81b501a2
aec19cb6e07e6659786e92db0ccbe4f3d0b6c317
refs/heads/master
2023-04-28T20:25:40.955518
2020-02-16T23:14:07
2020-02-16T23:14:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
80,925
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | foam-extend: Open Source CFD | | \\ / O peration | Version: 4.0 | | \\ / A nd | Web: http://www.foam-extend.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "Data/3458"; object E; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 4096 ( (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-163574.726426682,86790.1937419301,76784.532684751) (-173043.46088259,83244.9439557011,166583.049611639) (-194893.505557211,75755.3611538772,285721.194014969) (-236178.449528003,64038.9203316855,457860.723211297) (-310623.841844261,48269.021190139,720215.543865418) (-444194.399577009,30097.7626745399,1134312.18076789) (-686047.297887872,13522.3507082542,1806837.12794753) (-1123098.43443347,3367.34786170665,2926568.21451931) (-1852340.77592025,-11.9725733535981,4778920.96301287) (-2580903.52271354,-278.293579897278,7360102.7793064) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-173098.655509857,186669.185402197,73219.663849588) (-182637.074656862,179942.405244858,159159.277217294) (-204840.252319779,165728.465382876,274026.425308071) (-247081.5809388,143125.980076964,442020.946501592) (-323566.576519592,111905.681684908,701950.862526414) (-460320.421074139,74668.7204439917,1117700.32583109) (-704817.115745764,39409.8418188767,1796629.95046623) (-1140228.20585184,17083.8014448726,2923141.70273486) (-1863786.40618479,8306.89259807144,4778609.24374828) (-2586265.23547931,4253.7639295976,7360342.42171798) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-194784.191169661,314974.845362011,66478.5312098466) (-204477.192471728,305931.586757165,144966.542169273) (-227348.736804174,286671.9155806,251371.828775729) (-271665.328045716,255460.511647476,410702.625250933) (-353015.314729348,210928.749314089,664694.872351086) (-498250.344888324,155164.328265151,1082449.60941825) (-751151.212984894,98712.6827081587,1774297.98151388) (-1182885.71605973,59917.2323781536,2914350.26664027) (-1891271.41009139,39463.216769072,4774465.35256073) (-2598723.11166243,21407.6780420163,7356034.55011075) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-235082.171199957,492671.429310406,57385.587251563) (-244927.839817188,482571.467831084,125673.545994834) (-268670.142769484,460963.141561777,220052.462783133) (-316032.394230435,425500.209832757,366045.158828279) (-405435.023479496,373510.821704513,608898.109917363) (-566950.179948805,305071.023611747,1025941.59451956) (-839916.969542023,229075.78188498,1735495.46488476) (-1265436.4335086,166976.379546123,2893872.75122537) (-1941630.30989635,118643.196468908,4756323.08142181) (-2620698.73974409,63853.3603863097,7334576.1388218) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-307241.958639277,752668.551047269,47244.8369024078) (-317057.926832018,742837.693548763,104036.538016744) (-341279.688112121,721840.815700977,184438.551989664) (-391203.038688939,687256.089792446,313885.710718915) (-488926.167118752,635985.779458939,540336.92008324) (-670598.447369075,566212.224379892,949794.166684152) (-975121.932866426,480679.572286747,1673312.30914881) (-1391146.1139116,386047.091384737,2845387.71122184) (-2014815.23606055,277506.734328361,4701339.40942305) (-2652444.32737828,147093.306739118,7270543.79044852) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-437484.360902164,1152780.56718235,37372.3447670919) (-446813.092718954,1144036.28140029,82986.8496345156) (-470255.37095956,1125360.65521036,149722.381084692) (-519687.672710698,1094206.99767612,262459.145911703) (-618439.953224332,1046457.42475728,470427.453837707) (-803555.101561431,976060.58441869,864134.195360351) (-1108999.82677349,875215.824327857,1578597.77009273) (-1506156.04676013,734137.303468946,2736663.60476867) (-2094093.94211703,537560.373940538,4570703.90727357) (-2692381.20164852,286962.022696385,7123216.39296478) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-676613.395715052,1800794.13140995,28599.8314874493) (-684857.762624231,1793236.36259926,64257.512912716) (-705886.56748715,1776995.98772469,118508.74788554) (-751040.50386365,1749157.11684947,214599.132575841) (-842756.811557056,1703890.75640333,399922.612486838) (-1016671.9480441,1629476.93600496,763178.208944675) (-1303303.55045532,1504311.26131028,1437386.32241759) (-1664439.37490756,1296063.21978383,2539899.78101025) (-2212233.22554561,969757.41498887,4319935.96550748) (-2757551.80578539,528388.367066062,6836061.42692329) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1113862.30042244,2893635.54288615,21020.8889462274) (-1120462.17676738,2886782.09709242,47937.3312204554) (-1137408.23933539,2871707.2888469,90634.2694336585) (-1174136.55245148,2844637.26597117,169290.672763429) (-1249511.73560761,2797208.75802352,325484.406750856) (-1394061.58130016,2711044.9078493,637978.01620665) (-1634080.0921642,2547339.21786143,1229030.15181965) (-1926465.64398187,2238182.36605576,2213376.64952962) (-2426758.80324545,1731577.16385595,3878315.70390797) (-2882216.01084434,981516.589737313,6307403.49208101) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1846062.34108699,4725555.87890064,14142.0050724929) (-1850588.37683336,4718732.75685308,32779.7221451769) (-1862108.01989477,4703068.04063804,63526.9902487514) (-1886792.75689922,4673092.81011366,121864.203005461) (-1936578.04573964,4616360.2205586,239290.786210028) (-2030118.10138978,4506233.08168392,474220.713765216) (-2187250.50788142,4289015.97047679,919794.46903128) (-2420781.70119397,3872141.26509071,1706617.27119033) (-2822450.83380951,3132630.76278077,3128014.5060749) (-3099628.13629857,1883559.9562486,5325599.27586219) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2578032.63780773,7296370.28880734,7218.22790101492) (-2580310.35794239,7289335.14271585,16926.1999806172) (-2586038.02756035,7272668.9109481,33363.3572309137) (-2598151.94677687,7239558.295285,65049.818836499) (-2622243.16202755,7174605.54057197,129047.660850681) (-2667292.50578268,7045695.03128484,256878.217032386) (-2745933.90847817,6789013.07936469,502815.016622625) (-2878477.23997972,6286473.22099925,966960.300693786) (-3098883.74912237,5319802.70675494,1878672.10584191) (-3120906.38138076,3441407.29311125,3441731.15036009) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (24205229.067759,77339.4858577072,67346.719082067) (24189380.2415425,73686.3348516777,144726.680930897) (24153027.7758198,65870.372644063,244425.026035209) (24085142.8875324,53209.8738681293,383383.814232144) (23964317.8961202,35385.4864838634,586546.588909216) (23749488.1955013,13998.4198655002,892355.573090821) (23355402.2565083,-5230.45603683382,1369626.47385681) (22576651.7572051,-13722.9327516432,2197089.21409536) (20819536.8218912,-11404.7328789813,4050106.3482884) (16047565.0983,-5607.25806030826,9940734.98446064) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (24188992.6502732,165057.899600403,63680.2795997037) (24173143.0980679,158141.422907177,136935.017945013) (24136468.2879843,143242.639913829,231744.209496689) (24067330.718458,118549.978373301,365481.804720225) (23943239.1001222,82453.7291204924,565097.884567357) (23722405.1100131,36763.5480222156,873097.224448821) (23322296.986043,-6864.07141624063,1361106.73716507) (22546764.1926759,-25515.3107148441,2199396.7157259) (20800923.1191917,-19126.026270451,4055898.48286629) (16039389.9470022,-8182.39855826403,9946308.44000804) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (24152349.9429233,274651.992462952,56761.7721698858) (24136464.1932853,265431.955422551,122019.853022947) (24099130.8622028,245312.166861916,206960.726193406) (24027007.401346,211064.001726506,329263.972574058) (23894339.1318257,158499.213859746,519354.040405275) (23655415.8657577,86518.4897741367,829422.88713286) (23232415.5065807,10046.7854921659,1342435.3097844) (22464274.2210837,-22538.5123528615,2205788.57340453) (20752934.5985391,-10840.6442318663,4066787.18186075) (16019467.5116509,-537.879906536052,9954442.03902121) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (24085137.9873456,420427.68799835,47494.1450444442) (24069297.8721415,410363.172490078,101827.21514377) (24031095.9561962,388300.797227736,172562.484937753) (23954255.7936559,350294.094159629,276534.203743861) (23805770.7996803,290036.515413495,447281.078155893) (23525956.4686581,201513.199990062,752869.718458511) (23032644.9089216,93991.2526140673,1309853.37199856) (22276478.3452475,41387.4828521088,2217502.59716307) (20655968.3462954,45526.8796738389,4077026.41619094) (15982210.2787266,32139.9894292537,9954929.52751012) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (23966993.5425002,622305.60479814,37376.581186242) (23951500.9156339,612956.66529774,79714.2450381183) (23913084.2628174,592748.608232526,134392.482229497) (23832234.2866653,558668.475740103,216070.774420226) (23665653.9683933,506429.339810629,358587.813636605) (23324523.1709621,433279.990268596,645189.404152467) (22673521.2139444,346854.496530236,1257173.01255098) (21928295.56636,271086.439655217,2221522.37460183) (20503996.5023155,198253.921437706,4063473.5935873) (15926821.8591991,107167.654295164,9922669.74126939) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (23756768.587313,913532.031839634,28010.6238687435) (23742323.8117952,905835.008233211,59485.3755445577) (23705717.520249,889539.517827796,100211.573866239) (23626360.4121787,862663.806651316,163658.157191227) (23457881.8460693,821991.06833531,285264.628498428) (23107011.2149404,762844.124218826,558624.177171814) (22447794.6363455,680842.689654589,1181331.52005401) (21735454.1085844,575777.676336805,2148520.12715332) (20374624.2240853,419362.543685744,3972183.33782852) (15863364.9443292,221767.079677986,9815327.76559328) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (23366768.4559711,1363327.45774884,20312.7215301132) (23354197.4894066,1357413.43168832,43169.0451696359) (23321770.0971934,1345238.81622967,73303.0812127533) (23249742.157817,1325816.63695563,122857.588353271) (23092694.4248503,1296928.65476744,225958.764639341) (22757246.7355896,1251895.78065249,476478.423697435) (22117997.9078723,1173363.71080421,1076145.94334561) (21475150.1459915,1033884.64061914,1991939.4572897) (20183039.2790242,755121.372875341,3774398.12265563) (15755063.2164751,403697.014492787,9593343.16470591) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (22587359.3183093,2161199.97490108,14395.8632415217) (22577437.7240752,2156453.71483164,30945.6783811177) (22551607.7041797,2146792.59714236,53865.9530788939) (22493430.1225596,2131715.7501903,93890.163958566) (22364042.1442586,2109890.49555649,180864.442428725) (22079551.6599449,2074742.26032569,397894.720636113) (21520162.7168295,1993947.29517268,936558.326399408) (21100792.6413348,1743700.2172393,1712974.46358792) (19796406.4588782,1335749.8116434,3422670.76182166) (15504291.1422207,764031.482968488,9189319.13940636) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (20825697.4265103,3993309.22200268,9620.98442665052) (20818994.8847867,3988757.16532175,21224.2714419931) (20801737.8927344,3978874.05448019,38786.9006004523) (20763717.8349704,3961431.89902646,72050.1590201576) (20682743.8834568,3930404.19678196,145704.527723713) (20518010.4638769,3868756.12148569,317052.100422601) (20221009.7079925,3730045.75347248,686183.425374485) (19803508.0250097,3414239.30408418,1304844.61145148) (18624923.3923923,2856040.48816097,2850669.7078576) (14741434.9252813,1862167.49037223,8424960.63799944) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (16049737.7663029,9874079.48668573,4949.3303317422) (16046405.539432,9869302.20484687,11178.3925575849) (16037937.9070628,9858346.67712306,21219.8344171313) (16019691.3947578,9837353.41087285,40944.9801616689) (15982060.5873089,9796550.57938191,83984.8473508636) (15908029.205107,9712688.92670067,178220.330371801) (15770936.5685103,9534665.37897526,370220.227006031) (15508253.4061855,9164733.85827584,746485.02577479) (14742058.1539579,8418514.56509003,1856559.04489098) (11986607.2204477,6562193.65207633,6562509.28048394) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-421065.740397303,61257.3010581173,51547.5079727303) (-438566.112599554,57560.9141476727,108442.948841511) (-478036.842949511,49428.6549944328,176588.913491007) (-549797.232847619,35486.9947483677,262552.039997186) (-672586.116033951,14343.2858385524,371622.767187397) (-877405.343525458,-13079.885823312,498106.192912043) (-1212298.72181532,-38313.7984658727,590630.97057617) (-1742264.63621873,-43539.2282910779,439596.59316559) (-2502081.18343913,-29911.5525729672,-722363.848056601) (-3067128.31802586,-13693.3130329135,-6107467.11782321) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-439650.554417326,128572.036338569,47838.4702846151) (-456824.712540882,121591.827167449,100285.368748049) (-495879.375583858,105972.228494047,162599.459691071) (-567680.275036959,78262.0375273853,241345.411281507) (-692281.265908778,33558.2902768477,344160.773748651) (-902617.388117503,-30212.263760716,472825.650691238) (-1245340.87525454,-96691.340217335,585351.054614646) (-1770186.3450151,-107925.251075893,453197.615965058) (-2516107.07644373,-67040.3409121998,-706133.399185659) (-3072099.45064852,-28057.8180911951,-6093769.49560199) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-480952.727051347,207534.450055717,40850.2571321045) (-497527.182926054,198316.714139451,84626.7472459896) (-535826.835997084,177285.160688486,134781.514125912) (-608300.319230668,138328.883593629,196532.389510775) (-739329.570180752,69942.2922607134,280327.090407834) (-971309.328457337,-42913.5782189938,406263.599955617) (-1355913.51947526,-189658.548284368,574069.834953066) (-1866948.56447205,-210228.667785648,494106.038093038) (-2558590.3046407,-107737.950579993,-667161.448184656) (-3085742.2163274,-37752.79882925,-6065746.73859382) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-554606.191791432,302195.435006521,31593.195060823) (-570286.515618813,292483.948407205,63520.3494278409) (-607477.614949455,270233.189707378,95655.8924291115) (-681435.033509926,228213.73113422,127971.872928779) (-827030.328024532,149867.84699425,167357.446774505) (-1122552.06506809,58.3039123788269,259404.099243902) (-1699472.77618988,-265092.179549308,553465.416494737) (-2183730.06106716,-306706.81260205,596661.968500236) (-2665015.20847597,-106402.916308024,-597179.510125699) (-3114975.19086783,-23226.8787586121,-6028009.95972751) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-678119.423850846,411962.560710231,21855.8415218241) (-692529.56389441,403645.302021326,41234.9683105535) (-727680.189546568,385260.234663035,53482.3765931677) (-801631.790602341,352659.923725604,49412.2621439848) (-964439.894293465,298532.044449963,17351.928249478) (-1381288.3402856,215683.287127805,-5951.54284380947) (-2743867.2296666,121114.853898205,511739.868194128) (-3255303.21159778,78232.2690755759,796909.565348762) (-2873724.50000614,68847.6536542523,-514110.001417275) (-3162858.50977226,43685.8041256469,-6004832.3144556) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-881718.432724541,523413.808292982,13545.7733293937) (-894354.891973995,517543.187812578,22836.5921819068) (-925879.983166945,505411.176032942,20793.1551024303) (-994665.193348805,485878.576317758,-4889.89108781185) (-1152940.3474241,456649.139805641,-65674.7920756011) (-1568730.20622753,412951.075408795,-100691.158314102) (-2865023.27604304,350939.030726268,468812.578120816) (-3333750.3729943,315357.257928045,787402.071721544) (-2970849.7449637,227689.805147163,-539456.109848003) (-3210646.70410755,113419.652367457,-6048668.30877838) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1214679.94073283,583658.977327375,7713.22854404683) (-1225098.04557731,580367.590148911,10694.3620661659) (-1251619.83211927,574785.969610093,1219.49867613107) (-1311586.68129643,569212.874727144,-34275.9597452965) (-1456875.02336438,568025.630890358,-109573.001740878) (-1863980.75084032,573996.140081793,-162880.579109394) (-3215883.95385791,575354.662045999,433095.652175682) (-3648854.61910495,659400.114389633,699567.561685097) (-3117626.99054961,368387.104140553,-653953.466859771) (-3289516.20780789,152892.009644526,-6162336.39897941) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1746156.57091929,399222.062297882,4462.80513258145) (-1753996.60200739,397690.156711333,5084.56552725781) (-1774239.73949348,396596.450163736,-4368.47047877267) (-1821261.25520076,401618.207564915,-35572.4246816275) (-1941491.07793838,428223.536818574,-103727.107538276) (-2314935.59860288,512884.000177319,-161617.708211646) (-3791134.18601311,694538.012447014,517005.845104484) (-3090885.37274038,446227.626321203,408366.348122674) (-3234697.26817229,164132.424109091,-869765.243920746) (-3411643.33846877,1119.46655009693,-6315548.21926221) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2508471.32527988,-783020.190735934,2921.0056984539) (-2513585.02183514,-784228.137432582,3929.20733870618) (-2526576.11874325,-785331.38653356,681.056388199127) (-2555461.07711141,-783036.064252437,-8975.75883813418) (-2621669.94160562,-770728.83058143,-19099.5655011712) (-2779983.37433248,-741656.713986999,19944.987746934) (-3126072.62675493,-720434.995187783,268510.331003603) (-3239937.68457172,-881359.757669625,126053.425450295) (-3538204.41304156,-1027084.96996637,-1033091.37416583) (-3594237.69057257,-892811.271681872,-6316978.01920548) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3072074.15981452,-6176320.06360097,1621.79985700761) (-3074565.09731379,-6177814.57646891,2688.87651362039) (-3080796.50196422,-6180317.15561258,2919.05549416202) (-3094140.01779669,-6183069.59390152,3293.99857217447) (-3122576.91864018,-6186217.38769467,9930.06250896648) (-3182206.53378511,-6196028.88754136,41047.9758298431) (-3292407.55622952,-6236930.89914207,107398.005398486) (-3415217.65835121,-6344111.99721035,-19868.6896497423) (-3595291.03648948,-6324023.75161115,-899070.716683088) (-3469625.56110135,-5424715.62820066,-5424423.57774088) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-498074.875077308,42865.252578809,34143.8821011956) (-512922.463314588,39463.6894737334,69036.5433425012) (-545571.364551641,31741.6650941109,104829.399850523) (-602437.432402833,17715.5591714054,139754.040234329) (-694270.597535736,-5318.41110096369,166756.932837078) (-835450.150180518,-38287.2938133854,163089.033305522) (-1038311.69026906,-71353.3804126524,60455.3821719187) (-1289817.38740155,-71460.9613419359,-320530.905303323) (-1490897.31921946,-43921.3831920747,-1287793.38633088) (-1295509.88292449,-18635.779347888,-3040776.04208434) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-514952.58470114,87445.0345921888,30722.2482704315) (-528957.03940635,81047.9335361691,61270.3310734664) (-559782.06794599,66142.4611005989,90772.2274291135) (-613609.248236597,37729.6885901653,116687.071209986) (-701200.949468964,-13444.7232922834,133733.066961486) (-838269.034118806,-98852.9310665019,129950.350215909) (-1039798.99070174,-207236.205379066,60291.290629526) (-1283681.24207594,-204675.336080452,-292999.437571118) (-1481017.04550102,-109496.51093269,-1262514.3407732) (-1289435.98192424,-41669.9088197672,-3022143.68002568) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-551823.436981965,134024.401084154,24291.3434386577) (-564193.952448614,125679.416725823,46326.6297715614) (-591394.50892516,105740.534811057,62296.2289891764) (-639013.524678019,65292.5801149676,65446.5429117248) (-717835.141225882,-17719.8775219003,48227.2681864693) (-849264.935836227,-194131.941966827,21461.8864656666) (-1071255.20247889,-533220.092188602,62787.4562788292) (-1284072.01718352,-526976.58632562,-197787.840764544) (-1457061.68938151,-214115.506319258,-1194697.46063717) (-1274629.80357482,-66945.5196328133,-2980534.26257672) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-615151.5102601,178664.194961192,15905.5245916379) (-625262.370251799,170248.183124745,26312.6128257083) (-647210.100135329,150090.139508152,21695.4933144917) (-684780.132823677,108035.323851148,-17702.1511079362) (-746542.216691816,12400.6698289903,-128310.809791539) (-868502.933562399,-258755.344354393,-317736.538909673) (-1309821.43387534,-1309546.08631606,68938.1129032523) (-1378611.74286918,-1378267.60457035,115110.812949992) (-1401405.25991715,-315101.514130576,-1047513.12779752) (-1244753.89594099,-71112.8192053525,-2913567.1231519) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-715188.465655582,208275.478398726,7457.75836720116) (-722655.287315716,201740.067495173,6091.59741808067) (-738043.722274849,187035.719709525,-20490.4500550015) (-760200.191668481,159597.923962636,-113484.649100349) (-775860.160454079,109965.766032684,-399629.479143435) (-699105.055318081,28166.9732271258,-1368735.08169248) (-7.19293532462802e-05,-1.89538173087301e-05,4.58793720648072e-05) (-497.001638786595,-217.796950347497,1178254.68015223) (-1178698.8447155,-28303.484054757,-803569.00521426) (-1190939.33062904,-4140.6048707515,-2842460.39869209) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-864777.206761911,190400.942225053,933.31021104867) (-869750.220864963,186717.360276713,-8648.65367952922) (-879100.81591832,179596.977273345,-47989.078491968) (-888719.247438778,168908.954309301,-163246.054748661) (-877308.734078813,152660.859018897,-481572.761080169) (-742667.735805754,117647.492356027,-1397115.75063085) (-6.68334914765165e-05,-2.62622749518526e-05,3.84069859160943e-05) (-226.306613777193,215.475823737726,1150166.06423147) (-1150375.14547144,80886.1309669714,-779498.150282512) (-1190374.56877088,34513.8232994776,-2838424.71378932) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1073701.77573677,52093.7886183044,-2671.01138929906) (-1076609.98963923,51332.8880637596,-15774.5951144265) (-1081069.56186882,52003.6315441487,-58731.5196356736) (-1081097.99765278,59361.2790392439,-179672.528009264) (-1050354.46757214,83266.0322919588,-516798.257074573) (-871187.392499576,122973.589111344,-1514917.71217063) (-0.000181336861146153,6.60494994117376e-05,4.92439605274429e-05) (-432.930023279191,1217354.9120126,1230707.65076321) (-1231247.57001308,251271.099419699,-826056.738226039) (-1238601.41088642,30705.3201988466,-2873163.0320469) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1327429.19750688,-363278.84301626,-3354.74177785877) (-1328811.68832095,-362087.973082586,-15118.7943179567) (-1330022.73447168,-355933.538941505,-51398.6288541128) (-1324553.93420028,-332833.021592469,-155911.649222888) (-1284645.8811586,-252202.233461134,-477288.580249583) (-1078954.25005068,47635.8159614577,-1637932.15565189) (-713.977814961886,1359476.62090919,1217165.23696867) (-1217918.93224927,297115.126128799,264438.582361342) (-1532613.93273691,-139454.774063464,-1046918.87959088) (-1342105.99586338,-181544.075316947,-2904206.82668049) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1522680.48813995,-1346914.56777095,-2155.11238523439) (-1523267.60881284,-1345539.8303127,-9020.6681774043) (-1523364.81474917,-1339907.98478373,-28257.5263292423) (-1519173.42029266,-1322094.99871406,-75283.2060263891) (-1499619.4397694,-1272022.02675755,-177513.914566182) (-1439395.35608306,-1144240.26924925,-326225.847604897) (-1360321.14478581,-887070.528901298,154569.820236466) (-1559029.11327312,-1056880.79288561,-172342.832047717) (-1676327.97808359,-1084374.48873357,-1089299.55233557) (-1373745.40120365,-768335.91159076,-2723000.00543071) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1313450.44249781,-3104704.2035255,-834.081562137908) (-1313668.72014192,-3103775.27095795,-3495.01808875631) (-1313657.57617081,-3100090.08133682,-10451.8473290736) (-1311988.40349762,-3089504.1351296,-25194.3252125771) (-1305820.11184412,-3064226.16229279,-49746.9964734075) (-1292606.28976475,-3014379.37557765,-69208.1341653704) (-1288211.86748766,-2944987.76873977,-15486.5830687207) (-1358310.8152593,-2929235.1797533,-200039.039292911) (-1377191.33373461,-2729003.19131233,-773510.039469004) (-1101256.34860345,-1955257.49755845,-1954957.66599919) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-543549.636600305,26140.5744043629,19334.1871186374) (-553557.670440354,23558.1431832896,36411.2510611144) (-574717.504688414,17632.8150530666,47924.5761448145) (-609065.110013761,6614.00260254666,47938.2511531956) (-659658.533956388,-12250.2432880327,25576.4308618799) (-728873.355956564,-41166.3767330102,-39833.9866290694) (-814086.77791348,-72924.5998583404,-191134.299126309) (-893737.923809558,-65396.0440509054,-521817.718667396) (-885923.831055523,-34066.6594340103,-1092724.54739733) (-630016.975475465,-12561.6848745751,-1745655.76997176) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-556348.156853657,50798.7035676981,16737.4429891829) (-565102.211947502,45999.2207095672,30441.5380040521) (-583235.033228734,34663.1677395267,36864.1506003341) (-611587.023010639,12433.7321732893,29022.1958036391) (-651010.014532741,-30017.7373883292,-3401.24503228821) (-701345.44658027,-109835.016241104,-71656.1930627284) (-761958.066496912,-238750.942667363,-183670.77445853) (-837105.99488134,-205132.390298888,-490509.67540513) (-848799.360541427,-85543.3449839555,-1071250.67481479) (-613293.422847649,-26842.7855243394,-1733112.13324161) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-583723.707963898,70796.1381936127,11902.8363560157) (-590068.989127591,64693.3406399518,19083.753104612) (-602250.894434359,50009.3271576352,14593.979195706) (-618129.104561795,19618.7841860576,-13475.4929332839) (-631651.305979208,-46376.8268229557,-83300.2387453317) (-628353.470159386,-213378.570784695,-200668.149878569) (-588634.53296824,-771884.761585285,-150155.000471289) (-646844.055100265,-621568.728410468,-370946.624442969) (-742531.654847608,-158449.635130504,-1012570.36883033) (-570690.251897017,-37049.4584561714,-1706303.24757632) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-628765.03991214,78620.0484380957,5789.61940755955) (-631978.113084203,72833.7438353124,4364.95904459635) (-636162.776867448,59236.8579708958,-15909.8950365442) (-634089.746666707,32594.7560341799,-79576.2530416391) (-605107.64832002,-16964.4136782516,-250423.234558149) (-483564.176303345,-89455.575363614,-759284.987238287) (-3.59384412629941e-05,-6.87121737206919e-06,1.82915417781728e-05) (-150.501512536445,-260.707529686321,92149.6603648272) (-484124.234094008,-92431.2647031031,-891149.735885718) (-486448.667377785,-17325.3961091075,-1669179.026796) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-695130.156066443,58583.1154358451,-21.3765868871985) (-695134.888666853,54570.7581976837,-9278.78959812823) (-691318.049289436,45889.8280497634,-42657.4326624137) (-672052.318137281,31027.6049165112,-129238.155075947) (-607506.521814575,8485.81528380109,-323042.022677493) (-426203.090637406,-15436.2601215373,-669963.302600221) (4.08376015628937e-06,-2.36649199103083e-06,-8.60711758902778e-05) (-7.93814997895652e-05,-9.46101282613538e-06,2.37575365569262e-06) (-135.350650734746,-2.25208613396608,-816051.655940461) (-368868.539377764,-3594.72871365448,-1651853.11458717) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-783619.614861729,-18536.7761398547,-4037.70032448568) (-781119.211363662,-20122.1954446447,-17975.7561834571) (-771213.342541467,-22399.0073600327,-57574.394150515) (-739861.83842636,-23503.9438909537,-151900.254355468) (-653209.117295682,-20411.6767491127,-347102.379105674) (-439612.249034469,-10862.6798745649,-654731.446123926) (-1.15966904329778e-06,-6.72757617676289e-06,-6.65791495350166e-05) (-5.91264808641618e-05,-2.00326431646534e-05,2.88881422571264e-06) (-124.799027827893,50.4180312356449,-819690.045065272) (-351644.654616408,-13679.7777433947,-1648334.91019001) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-885161.18702255,-201532.066058386,-5545.29879568797) (-881228.588089086,-200836.242136406,-20212.653654072) (-867953.200789151,-196994.756479425,-58733.2656143576) (-830155.089125899,-184176.443270821,-149003.674761368) (-730908.844440472,-151065.970944529,-337795.00369762) (-491093.023618604,-84650.9475631067,-644101.10489007) (-9.85187735850699e-06,-0.000105077197275809,-7.84000967320386e-05) (-0.000103594901074258,2.3345717442808e-06,2.04244589817939e-06) (-236.122584024336,-50021.8528195765,-833543.231012471) (-378250.370707294,-72787.1811374619,-1634786.86779753) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-965662.888180625,-558558.135705659,-4740.23967898321) (-961457.202500421,-556597.626552692,-16333.3410832392) (-948085.999601575,-549343.711090882,-45921.121341875) (-911044.515806501,-527559.008626987,-116047.974379476) (-812803.437867892,-467265.6696226,-271690.718992106) (-562617.836394567,-312801.045941137,-559877.034270199) (-0.00012557676672211,6.89264495784097e-06,7.79132193421441e-06) (-242.32327735415,-43903.3832224443,-50293.503163544) (-493225.619556477,-283145.007382435,-856558.661781113) (-495991.134292889,-213206.047468651,-1562254.65702043) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-940675.224923903,-1137828.67264,-2734.72628170563) (-937385.914741405,-1136125.90154249,-9088.14536334031) (-927286.67794545,-1130427.0497858,-24082.9434721417) (-899889.872092794,-1115160.74748094,-55764.7528180541) (-826841.634335783,-1078470.57484188,-117337.653032386) (-624659.143912756,-997633.32925836,-247241.581885463) (-481.701693187584,-815066.354680921,-44198.058437619) (-501123.483641578,-856262.737215519,-289744.334076101) (-677055.542474214,-785322.489217288,-786839.287850623) (-528568.70161603,-495894.224748639,-1349327.81015825) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-658725.722351192,-1791499.44007796,-1053.95270866106) (-656997.871964552,-1790399.76594433,-3450.93648420161) (-651927.774191652,-1786809.20848529,-8798.57976387484) (-638965.614799321,-1777924.49760186,-19057.618341255) (-607978.309939365,-1758805.99612576,-36563.9989621033) (-539829.920110655,-1722098.84995442,-64874.8479201484) (-425479.499982752,-1657006.49781348,-85667.0722925123) (-510145.551032201,-1571089.18640283,-219005.887332312) (-531939.857639921,-1351921.5214473,-497658.331197005) (-387005.57170759,-854036.971120445,-853766.361721068) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-566281.825788109,13404.050440872,9328.13874693743) (-571600.57874258,12089.4570980021,15281.5899511612) (-582107.808763633,9191.85639489381,13480.0376314868) (-597065.387271053,4173.45862665183,-2693.14373787437) (-615191.802363284,-3555.10258317555,-43604.7727478047) (-633775.077747404,-13664.1737616351,-125038.877195323) (-647493.336921447,-20870.6203647302,-270761.697822636) (-641563.769291489,-8855.00064252713,-514080.851698177) (-565970.877858327,3030.35074285076,-837064.155638198) (-355188.011955762,4155.74358673563,-1116048.86274469) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-574492.212418979,23569.8153256673,7978.29068052925) (-578546.915737507,21166.8438496626,12345.6077188756) (-585913.280713883,15766.5744652792,8449.13713364571) (-594514.292559148,6014.931398971,-10465.0660901669) (-600715.313046399,-10561.2037643756,-53753.666395307) (-599672.256217169,-36799.8958431739,-132291.134676871) (-590811.791179725,-65493.4677851913,-258814.562573594) (-587510.89410213,-14981.8280042124,-502282.835991123) (-532715.189634046,20673.9068275393,-836010.562983171) (-340679.049188815,15758.6609337917,-1120227.85398907) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-591482.580910987,25795.1537645334,5533.53450822755) (-593141.15459435,22842.5491794396,6929.99464521239) (-594447.309781164,16198.6245457783,-1305.64008847891) (-590106.984652561,3753.30507628994,-27066.1336750353) (-569444.402674319,-19791.24844286,-80042.9923014402) (-515534.947689442,-68605.5778766458,-161055.832737921) (-423399.413520732,-183412.446051486,-208371.973919134) (-428500.282347369,24992.1666795544,-466689.741355799) (-447501.273537818,99893.4927741725,-840939.708612227) (-307104.849763924,47173.5559970505,-1135940.00580857) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-617801.83291685,12234.4622659081,2597.48450333146) (-616451.89416489,9644.0347336446,269.780029816689) (-609965.32768676,4077.53998292443,-13806.5845880162) (-588113.427531085,-5353.92742665192,-50675.6712206949) (-527253.139092479,-19362.6291985792,-128958.799692514) (-373042.051387095,-32128.1973203487,-275958.30516506) (-3.09724464634337e-05,-5.7600115931217e-06,-3.22255731320473e-06) (-89.4126535273793,-255.012260934056,-391809.238424531) (-273935.158765649,391514.623327121,-893619.444305846) (-250146.846272493,100242.627609856,-1182990.33702393) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-652905.254519956,-29985.7594948186,-4.67978575254355) (-648709.063584251,-31449.5976135796,-5336.8725211278) (-635245.602487286,-34033.8750041839,-23297.9043361725) (-599170.400187492,-36773.5744426447,-64760.1752699706) (-512592.975822241,-37189.4386961228,-141846.91176476) (-327343.271340373,-28844.1616554099,-243990.766726735) (3.71324130270604e-06,-9.31743638520024e-07,-6.36523909626856e-06) (-7.05807751054317e-05,-2.37138802782817e-06,-1.272385353467e-05) (-297.934659706966,25.860285118055,-1184870.28122266) (-183939.837959071,13635.2849037627,-1283191.63993525) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-692066.877459364,-120049.359081222,-1489.13781596565) (-685977.879379115,-120129.045414494,-7951.02199960043) (-668050.508070832,-119050.303059423,-26097.4284150002) (-623704.44615121,-113734.832719557,-65293.5624132392) (-523961.346962438,-98071.9885515099,-133658.782891095) (-324435.887482002,-62313.9482227243,-215365.357876251) (-5.71266419892136e-07,-3.15017460821247e-06,-1.97913920651275e-11) (-4.92824421021182e-05,-2.93760948715207e-06,-9.27783709411234e-06) (63.474372069714,-3.89075199863917,-1171276.07268538) (-172170.205755959,-40254.5689424731,-1296860.66769959) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-721823.861626346,-281835.533596601,-1551.15088083825) (-715133.115726373,-280896.362461573,-6879.30619647246) (-696007.333791438,-277001.170761328,-20874.3054922773) (-649991.393395578,-264964.909047774,-49807.9248943789) (-547823.976305593,-232844.955247902,-98119.8263328674) (-342205.195680279,-156034.89434535,-153286.708148563) (-7.27349066131573e-06,-6.86336706071369e-06,-2.33732188805886e-11) (-8.5970972418901e-05,-4.77849751614314e-06,-1.57830639995857e-05) (157.505600151848,-542866.181891589,-1211576.62383455) (-182961.957322315,-190480.83039207,-1256638.77576995) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-713507.727510454,-533450.887298215,-539.806968555521) (-707504.669177411,-532421.106163787,-2967.59658934558) (-690715.990127809,-528462.127611205,-8876.64921323558) (-650709.550923395,-516337.024061358,-17839.4990827597) (-560681.749962912,-481194.40742466,-21611.7348109832) (-368038.052782449,-374622.45739337,2396.04462492015) (-0.000108115060552489,-1.94110874807833e-05,-5.05209483968884e-06) (-174.267322041745,-544548.240254534,-543187.409441812) (-253044.029118667,-466873.932707641,-859361.249063562) (-233758.322513863,-245776.127948238,-1066298.76328641) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-618808.289476604,-855854.104992651,536.282247141872) (-614536.550866679,-855735.342268495,1001.15447711413) (-602901.489818548,-855115.456399386,3269.29513838267) (-575901.205172376,-854312.827167085,17256.431323708) (-515889.65460102,-859673.469997522,84783.5141618046) (-378505.13473827,-912791.506649907,376798.554243852) (-903.880240427569,-1239951.04586176,-544852.560471394) (-259594.260071141,-865210.629656832,-465719.394639526) (-331087.491053544,-640137.848718835,-638423.530049001) (-237736.154381623,-354295.390127279,-820736.815104386) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-382290.563666499,-1132931.89372303,642.630045698246) (-380137.665131748,-1133547.53468639,1594.6156307897) (-374467.668279637,-1135066.57231013,4085.62562951462) (-361913.374158978,-1139142.6060998,11863.1639218746) (-336338.845096487,-1150963.89057166,31514.1196531378) (-288175.935474223,-1182322.58403681,49391.2124036024) (-214158.888293314,-1231499.87160321,-170380.573544384) (-244014.580609311,-1060877.7901965,-240844.383427605) (-240281.388815149,-819867.23580452,-352773.46516669) (-160401.301727637,-466929.100898513,-466744.024375411) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-575478.008915473,5271.71245265183,3924.4706747026) (-577649.377388849,5257.63076662252,4715.63855434733) (-581298.069662787,5483.25928369891,-1577.35983019403) (-584623.172506696,6796.73451784815,-20816.3091123949) (-584843.600859018,10965.5517464231,-62130.0623630845) (-577636.779971358,20451.332640542,-138719.692779673) (-557160.10386599,35790.0468570607,-264842.972692184) (-512955.729420462,45136.6945052871,-438587.707068496) (-414287.80576287,36244.4049903515,-626515.184154307) (-239101.165449202,18623.6681625423,-761225.698823397) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-579788.314013515,6706.93378443007,3860.88026275646) (-581101.749277642,6725.8677964478,4947.47677306682) (-582635.482965117,7365.59711073933,-212.658802746571) (-581789.043440027,10540.4170998022,-16681.5905038222) (-574527.615000318,20796.5987536352,-52700.3355571177) (-555872.550899332,47385.4586364165,-123434.166870836) (-524779.374365642,101869.981467779,-255546.518295647) (-494304.218947416,143937.844355098,-447554.343300184) (-405650.779717292,105805.777220433,-644180.125447022) (-235640.509598003,49288.739366131,-779883.736241415) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-588117.355719816,-495.877768001724,3837.58636125858) (-587813.266759793,-383.427698717806,5618.99402186109) (-585278.292630675,782.490152642803,3033.08382946704) (-575893.830924242,5797.70261345182,-6437.35541250167) (-551292.285884026,22385.5623687547,-26178.4358179181) (-499112.057305539,73824.2057711598,-69040.0733365635) (-416824.760216665,239770.954146798,-213515.699319656) (-465615.399368863,453248.001214206,-485710.739157275) (-400080.018284632,273344.107912198,-700670.325102208) (-233453.783134078,104070.820865545,-829103.473231471) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-599359.233862936,-22887.3888686154,3948.91204669886) (-597033.838693948,-22621.4040644966,6768.83294153121) (-589255.529345273,-21186.7799038615,8028.30465654723) (-568004.447188488,-16377.2818240757,10094.3087514819) (-515257.756135542,-4667.35054380998,25151.8387071185) (-384431.768929639,13562.8956538395,96802.866366984) (-1.99189147272343e-05,4.6201768188001e-06,-1.28723825364956e-05) (-539664.562288609,-323.894770851536,-665582.500816317) (-461356.370191089,665071.900024254,-869889.081502922) (-249313.475970046,166406.976072868,-933058.607012686) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-610744.477608796,-69204.2642059675,4156.09842618556) (-606584.404080499,-68731.9012614701,8141.93611941411) (-594238.656359948,-66845.64115025,12793.8512384681) (-563169.393145905,-61296.0538320395,21711.6162048482) (-490288.879660383,-48500.2684650217,43240.4379641953) (-327720.145148043,-25887.7591614248,83067.9665871308) (6.8142993221805e-06,8.86918893420433e-07,1.55274792944401e-06) (-4.89085938235763e-05,3.22595634700758e-06,-2.33080158382786e-05) (-840482.461724418,358.176955149858,-1368504.26095274) (-312011.650965208,25375.2542966083,-1099400.72617033) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-616083.982070642,-149783.70647397,4596.54687928381) (-610910.673496845,-149207.46842981,10004.9081653609) (-596264.5286295,-146932.658890245,18305.9464640244) (-561081.473232221,-140008.232711668,34395.1524246633) (-481787.887355501,-121951.107014461,65672.5313671666) (-313328.316765742,-80082.5600925499,108759.761582033) (9.94568897475289e-07,4.34829860889328e-07,1.52667234123698e-12) (-3.40165137912895e-05,4.9960643820012e-06,-1.70360348191499e-05) (-796304.116687753,87.3115528508537,-1343565.52286335) (-314477.896567628,-51057.7054258016,-1124824.87232927) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-603448.963491897,-273337.923067628,5179.31845921857) (-598337.448706061,-273083.75183578,12259.9348448714) (-584297.550420477,-271525.226044055,25142.7186277168) (-551618.731860557,-265546.624402477,52308.448783502) (-479204.331301385,-245588.475106168,107326.171871006) (-321815.895067593,-181756.518644198,188610.829809962) (-3.75605830458854e-06,-1.44620467418097e-06,-1.66996428257221e-12) (-4.7035867182662e-05,-8.7155326689895e-06,-2.52235098552122e-05) (-872906.727844837,-795966.951717429,-1394769.77623053) (-313783.515429643,-241234.054055334,-1073771.86949367) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-553755.819283116,-438566.787243989,5476.95594903068) (-549674.025732467,-439257.105966664,13819.6666349754) (-539032.273794324,-440464.663024308,31075.3872817444) (-515939.051538188,-441369.373860581,72127.6373546385) (-468798.361473086,-436214.888193554,170870.661952196) (-364150.804730838,-384776.254999381,370003.150255767) (-6.36080481631654e-05,-3.26815131814067e-05,-1.04088313465333e-05) (-642338.159107388,-803614.548256131,-796075.378487838) (-460232.116823983,-544723.168050299,-840131.074449653) (-232884.988279898,-249656.275554157,-832582.187184795) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-442952.016967119,-619221.92558163,4798.86582814882) (-440376.54463773,-621226.881052285,12608.6346848221) (-434309.941310418,-626622.066190853,30174.4893432343) (-423988.444250945,-640312.722981971,77205.0775431919) (-416845.400779177,-680093.155326791,222039.090854586) (-473114.962518945,-822349.667652006,754222.331287875) (-978081.588991864,-1452936.98713356,-803595.474322159) (-480077.556634877,-849427.836380756,-537298.889633787) (-318803.687612467,-549140.006322701,-545165.854802477) (-172695.307634891,-276833.211604945,-583029.765498413) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-253620.647307134,-750655.450055082,2763.6081140903) (-252420.936371974,-753395.30024048,7215.29854251589) (-249783.255762697,-760623.331122501,16532.150957224) (-245798.971708038,-777255.893166311,37360.9186906236) (-244069.503552552,-814580.001571623,79578.423391515) (-260264.855263914,-894017.541754313,123335.217283524) (-326325.859807217,-1017176.02583824,-200258.772497898) (-239812.456690022,-816736.968958999,-237151.763838949) (-174198.244731111,-579430.898331764,-272944.015913921) (-97424.0893666906,-306413.749508277,-306340.690371534) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-578119.369990577,986.282320593802,1655.07875451511) (-578859.776242717,1848.90735324735,1016.57025513468) (-579517.794442856,4200.20819797905,-4963.91316278106) (-578302.96478359,9695.33234966022,-20979.4532355483) (-572277.652806739,21342.0666063453,-54887.4678941715) (-556516.810402377,42250.9523257953,-118258.38978895) (-522884.178080874,68177.2545523982,-220711.570126467) (-457338.032216235,63758.0949190526,-340087.362249743) (-347597.910791559,44834.7213456146,-451611.978566674) (-190351.62308226,22040.7921224331,-522402.313056044) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-579714.048706717,-1564.05082429241,2476.06783808567) (-580236.0456674,95.209958014657,3364.06162307832) (-580461.12783112,4825.41170376695,564.502983295303) (-578713.113805135,16576.5769527882,-9392.67125472783) (-572708.091915667,44157.5186811779,-34027.6464142079) (-559521.291426549,104220.330974559,-92348.2845357508) (-533629.847770486,209812.00569407,-225132.562272582) (-469199.693362137,172545.165030244,-359024.157969037) (-356722.919687546,111280.390284616,-474397.686937788) (-194918.035809101,51415.8932707259,-544495.261874987) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-582052.370298748,-11738.0890176356,4109.05277227574) (-582158.160364061,-9561.76225970352,8110.91859426095) (-581557.978880062,-3141.79622525323,12357.8127726726) (-578829.82902357,13732.7621552077,18137.6256695857) (-573413.714160959,58444.6894988792,25971.8831288195) (-570609.481270496,188497.359028992,13192.2790393446) (-587964.451531818,656532.784905931,-262388.808857354) (-514300.092590153,379098.876892071,-420257.827497887) (-386818.491640055,211955.455787562,-534194.419645409) (-208499.729754714,88133.2343976257,-595865.814151675) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-583025.747214014,-34340.0904346783,6268.51476812332) (-582616.272038657,-32219.1147504327,14508.3006035711) (-580878.885345544,-26201.3512313151,29191.2116099051) (-576311.701265643,-11532.9031579236,62764.1310001832) (-570326.323265471,20350.4264107142,155926.961218274) (-591413.408562113,70248.3736258132,481157.586253922) (-872335.554113683,-302.641253683263,-539759.001086727) (-652213.213064736,539241.428709069,-587352.902127597) (-464669.575697148,285877.277097726,-657961.517931716) (-238908.127414093,103669.77815023,-683903.410240258) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-578805.843663754,-74566.7063736788,8287.9819939607) (-577910.962112654,-73065.8334093341,20461.2586850115) (-574881.616077425,-68898.4601209635,43801.3272921304) (-566202.510873858,-59213.8606754777,94515.4025376307) (-541181.970071135,-39936.2144106123,205695.133769718) (-450878.102741167,-11454.7856559268,410556.250644577) (-3.50314738321876e-05,1.60996104931394e-05,2.98482469632585e-05) (-861887.217430366,91.1403800967859,-840632.324669371) (-599642.494043301,44528.0801679153,-840123.095420675) (-283858.082414147,22890.9370829004,-787497.8229044) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-563295.128812765,-137094.468701678,9738.90907012111) (-562285.203084072,-136568.736026045,24616.3412740595) (-559059.150449706,-134936.466204134,53448.9691774387) (-549942.581703594,-130566.062475005,113662.279448338) (-522681.178698923,-119387.696441316,234007.052822463) (-424050.924216108,-88579.05285214,421853.927469039) (-2.60018666050926e-05,2.52735962593254e-05,2.15736864365398e-05) (-810402.284120087,87.4328129102717,-796268.272345289) (-609751.730381856,-76499.0391929999,-861793.539290259) (-292605.861987827,-50357.6566639436,-810416.980123217) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-527324.208477444,-223506.123592366,10286.8998762279) (-526633.091274794,-224271.652789742,26285.4592086543) (-524614.534817785,-226111.595650928,57777.5730527554) (-519346.863297474,-229757.481610146,124697.123624807) (-503405.220348244,-235093.610484848,264603.926715192) (-431954.854281199,-224024.653183404,510188.486260069) (-3.67895038960217e-05,3.51493474169322e-05,2.74537791683249e-05) (-892798.168113731,-642308.986886669,-872935.603183494) (-603390.588799546,-383257.558679524,-835693.222742255) (-279465.105932561,-160314.237953016,-760055.050950267) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-459258.226868764,-327530.881952923,9527.1659462021) (-459136.772341666,-329737.341637851,24455.6014035096) (-459266.229680263,-335545.208884143,54123.1705226589) (-461554.512589013,-349251.055929122,119232.205892459) (-475985.158938164,-384101.405426171,275426.798298866) (-553098.093772101,-493605.007312368,733954.441469103) (-999029.00471288,-978081.424271537,-642418.080975618) (-671895.650940463,-641179.446120613,-613990.129908596) (-441526.170795458,-403147.410066332,-612806.224550304) (-216897.736725069,-189380.21207799,-599727.501980167) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-348065.417585311,-429735.838355585,7318.35702085571) (-348316.367908879,-433127.762265124,18648.6009192756) (-349656.879602892,-441997.606478343,40447.9368059555) (-355038.411419665,-462059.491957461,84306.3400030197) (-375040.090145357,-507264.916677452,165664.54062048) (-440729.813892522,-609438.561662593,249112.946344286) (-600275.896256271,-801081.368873273,-305692.801789566) (-441875.629502038,-608993.356528752,-376080.818514276) (-294562.575417187,-404378.315107228,-399091.025668655) (-149355.04608587,-201466.021740268,-410345.477555385) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-190361.454186329,-496915.819580874,3920.78810448466) (-190601.595218659,-500858.391203307,9832.07588935139) (-191627.408333719,-510799.828790348,20478.4507723719) (-195010.975779138,-531426.605551888,39057.5684379) (-205135.527171373,-570450.578030466,63309.2534097423) (-229979.690116023,-633628.585840459,57214.1124397197) (-265714.118172293,-690699.154514863,-113779.843553624) (-214230.551609731,-576790.194766969,-171564.910395696) (-148838.228809081,-405116.453697447,-196186.787727511) (-77263.4606358706,-208906.913026216,-208906.525172389) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-578383.526817049,-616.256296830136,880.413123296748) (-578721.735026537,453.438317279474,288.933589835804) (-578648.677388355,3282.09089435554,-3862.27435901231) (-576527.390322496,9343.81963150762,-14981.6684516209) (-569080.798731029,20942.8390427878,-39121.3615701205) (-550252.978489655,39230.7377111922,-84615.9311940277) (-509677.194958754,57410.7589842938,-155233.673300441) (-433901.679226506,51865.2567670287,-230535.283057194) (-319219.458331675,35660.7617537488,-294574.497270828) (-170101.889377894,17447.1974700958,-332271.42844529) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-578405.615955643,-3854.26191170054,1929.5728637958) (-579120.058587322,-1807.03066186734,3074.05476285935) (-580083.445250266,3785.13735400157,2193.3257223607) (-580330.21671788,16577.3499038023,-3423.10163718556) (-577880.459354011,43526.8660652218,-20834.7612212785) (-567837.291540237,93133.5233908254,-66421.5467872277) (-537301.923178285,155412.221131182,-160750.933526315) (-458687.634301367,127333.860704474,-246731.596524537) (-336103.256557644,81086.4362718905,-312776.934172574) (-178288.002955664,37790.6432032219,-349750.412759144) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-577221.559740982,-12656.8244470644,3971.75197759751) (-578653.881348921,-9970.30194803069,8630.744248621) (-581716.579838254,-2380.1932342273,14954.6757950405) (-587119.39652112,16356.4862519201,23465.1069444675) (-596738.607232444,61587.1411343635,28729.7249468102) (-612263.125173582,167687.412716014,-4170.52047529147) (-620027.531992704,372102.775852286,-188797.99473551) (-523944.287790941,241112.051199503,-292931.990029763) (-376698.319323299,134048.398317656,-356014.124392285) (-196903.628688777,57682.4570245976,-387502.039279592) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-572185.018043695,-30139.2746229518,6641.72100556932) (-574576.209814707,-27531.8412831761,16163.1981167584) (-580508.340588482,-20203.4307294134,33615.8908548798) (-593593.243279654,-1382.27029470604,68636.1894155274) (-624408.020018552,49539.9166328133,134765.110670156) (-699911.934139739,210769.88991931,200181.159044499) (-852252.09225664,871962.010660833,-319761.537621096) (-660452.121983525,329537.31400482,-399947.891507616) (-449142.665041363,150901.637530579,-432328.041376333) (-227167.292674327,58714.5170669248,-445100.936158429) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-559081.355139858,-59017.1719893807,9153.40884253025) (-562373.008107197,-57367.6033702144,23451.2169241133) (-571051.618127284,-52998.2785621907,52416.066806753) (-591792.503316228,-42877.4641560034,119501.25311042) (-646709.433367414,-21348.2213245331,295916.854364046) (-820920.424344283,15420.3024925181,861308.763393946) (-1514880.41816175,27.6711105193842,-862129.552044978) (-867569.311070821,51617.1277854614,-578527.272185153) (-537283.695181285,34443.661820716,-524428.095337304) (-260034.645169499,14152.9356230873,-503689.951138126) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-532034.700357944,-101017.458971703,10739.8585275051) (-535955.794604407,-100785.273406033,27828.1200836566) (-546395.850755697,-100362.102390483,62528.6442179398) (-571348.960264086,-99880.3874409589,140937.946063388) (-635583.787086849,-100063.079431255,332555.412558033) (-825354.812699126,-96504.585946141,845784.18947972) (-1483395.18506356,-239.332313839618,-810582.270897977) (-891329.534852605,-82331.5582289525,-595706.334151023) (-556182.936738461,-70130.7200603041,-544700.745913421) (-268131.839261998,-37202.745270251,-517819.087745907) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-484050.302340028,-155263.520505639,10972.1553965243) (-488156.014200722,-156598.719145429,28308.5240618486) (-499100.187296057,-160575.05860295,63007.1327525845) (-525084.788696354,-171770.839748088,140635.5104586) (-591276.239577352,-207519.520272469,335962.970528918) (-789316.808653408,-345086.3973079,941906.7362629) (-1542328.74802306,-998953.94035405,-892772.127397096) (-862959.514280866,-421389.51220343,-583552.827255495) (-523923.997129195,-221378.880144637,-511771.258841522) (-250070.667184307,-97755.8974621413,-480612.545397878) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-408032.998990034,-216094.547857429,9605.79947305833) (-411749.221265532,-218719.045670017,24338.5749215103) (-421549.570093352,-225756.727446307,51803.5841779582) (-443783.921092736,-242511.635098659,104773.788032252) (-494055.376532079,-282927.456605232,198251.941958932) (-606757.435061817,-381076.615393609,287901.501334353) (-815524.569320618,-579218.442293565,-315338.432118388) (-613957.416770728,-411035.169453048,-383631.009038514) (-402251.799729393,-256118.032316078,-388166.227933146) (-198137.542463645,-121839.259699416,-382843.059957285) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-299283.134865077,-271882.879034828,7006.04845716823) (-302065.541753759,-275289.935649984,17326.1122820145) (-309295.184722116,-283864.983077538,35072.6730324694) (-324886.984840164,-301879.722987887,64289.3343421916) (-356428.675029989,-337194.004964317,99944.4675859054) (-412813.135891102,-398571.301391013,89522.4755818848) (-476200.614211531,-466415.947548686,-147355.301207747) (-390243.979945736,-381203.2667323,-228818.85348479) (-267042.878913298,-258552.459005865,-253904.123298884) (-134767.16306458,-129353.291790167,-260977.974229425) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-159485.452519041,-306406.032897543,3647.15219542729) (-160955.832467361,-310114.9691784,8826.42297254359) (-164708.437006844,-319064.598420067,17107.0669881985) (-172427.122377333,-336281.576293881,28925.0668923857) (-186673.52992827,-365194.406863224,38463.4715481876) (-208020.300272122,-403565.261991619,21498.0423048869) (-223400.194308285,-424927.875183032,-62303.9539247722) (-189025.133183064,-362502.224080908,-106210.415002832) (-132739.655617257,-256220.560837477,-124640.886363044) (-68033.0602479122,-131614.052278496,-131610.526262673) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-578196.508118575,-647.942605228912,460.923906754148) (-578511.471325963,63.6905925314065,186.969613656076) (-578434.591408927,1877.0027478072,-1904.119113582) (-576331.705702406,5558.66258864042,-7658.46632231297) (-568546.756868018,12155.3121378509,-20347.82032317) (-548165.912340414,21641.3494331346,-44076.2359055486) (-504045.938275617,29788.4091695728,-79495.9017582648) (-424464.656815067,27059.8553261586,-115992.779495867) (-308303.032593272,18718.9550456929,-145628.160279959) (-162541.234689588,9212.02358837504,-162400.838556645) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-577511.508842949,-2685.45954950172,1143.40983158122) (-578509.468407202,-1350.28735620409,1946.7976001985) (-580214.607566768,2194.54801758542,1760.41464692359) (-581790.14355529,9853.16782956431,-1074.16375659443) (-580661.329197385,24705.9398208547,-10843.9215962255) (-569797.034131612,48679.9596361279,-35922.7892078394) (-533822.630269131,72599.7030237395,-82213.3759711549) (-451477.555164573,61971.9399242042,-124335.539705997) (-326959.183309802,40386.9840001286,-155147.641908273) (-171703.199916094,19114.4882289107,-171634.909588374) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-574711.096655343,-7666.16145725899,2470.2388221169) (-577052.360113015,-5919.72827751127,5438.15850752195) (-582317.728097538,-1143.19416573661,9377.04895012722) (-591560.939103077,9921.71574624715,13750.0436154063) (-605310.389841319,33898.5104315148,13129.2556136258) (-618394.89057922,79934.9304240707,-11993.9497686811) (-606312.108047037,139702.825218275,-92812.4959088852) (-513347.652755108,104431.776747066,-145868.967767574) (-367280.083699411,61482.6058894846,-176382.825280826) (-190783.397032164,27342.7050852729,-190731.2737938) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-566979.698445482,-17061.6019973944,4190.12094192193) (-571081.823668014,-15370.3873791915,10146.3938969114) (-581129.868262924,-10760.6537213803,20385.3811270006) (-601445.850632151,438.814846257097,37720.8893794818) (-639171.342695192,27224.060574679,59158.6619129564) (-698253.533897592,89678.8966671147,47756.2954277619) (-745880.245273362,209178.941509371,-128091.6678466) (-617599.181716608,122283.073818512,-188795.905184959) (-428631.64955568,62676.9984056895,-210501.313186858) (-218068.343621921,25797.0329011182,-218054.590055107) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-549932.875145235,-32019.6539775648,5809.57198555056) (-555662.399636127,-30993.2867209578,14721.8628562477) (-570315.979551198,-28360.0349728245,31585.6055316115) (-601854.114169758,-22426.1553721235,64512.186603521) (-666348.334263613,-10210.4500458504,121585.598120247) (-787857.609784076,10984.4240582289,167217.256168931) (-954945.265804593,31471.2437997635,-215010.198478635) (-739734.293585464,27829.7940437278,-248391.936189183) (-491201.968814247,15521.9202570017,-247318.58440753) (-243830.6059974,6043.12422540423,-243768.714903907) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-517825.499788615,-53013.241279798,6784.38673290318) (-524555.751556555,-52969.9729022674,17361.0298663602) (-541880.411433889,-53034.8310125797,37520.3865843032) (-579372.538217798,-53573.3305309484,76691.1396968393) (-656076.277908183,-55747.6425499887,142720.823022313) (-798788.381227296,-60496.6371565025,187635.452765209) (-986351.943382913,-59237.153450981,-218699.391664693) (-767491.069642571,-53995.5374227879,-260712.525408208) (-506686.766892619,-37911.4194046414,-256775.355592412) (-249898.983782356,-19164.7933870235,-249800.293459634) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-464773.513446074,-79111.3494338309,6821.31926007558) (-471563.609662263,-80075.0392073006,17333.9810266525) (-488878.290953167,-82902.1789323192,36979.4326035028) (-525820.246892307,-90313.8702574707,74455.4305259788) (-600289.301342858,-110186.679336787,137907.529078282) (-738234.776597423,-162493.616939107,188822.476804893) (-927054.881287628,-272166.404295566,-213522.139085928) (-713419.116645772,-172428.542410594,-244629.531733219) (-468716.549685247,-99756.3622917959,-237992.036290011) (-230715.895587339,-45875.0717010576,-230636.529572948) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-385759.797972086,-107223.51254626,5838.96209448185) (-391587.693028982,-108919.299775756,14521.6944263917) (-406098.289810823,-113380.330360807,29548.5655723532) (-435620.922740091,-123437.975351767,54509.6723140049) (-490140.468519817,-145139.498644774,85547.5836097364) (-575732.238827781,-187056.521309891,79085.2917464819) (-654841.141200159,-239893.599307436,-113870.941362103) (-540909.442687057,-187363.337740137,-171984.120116215) (-368895.896885029,-120997.438512807,-184098.94673958) (-184785.999990196,-58557.8003966073,-184767.760517475) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-278679.520563413,-132006.506346501,4179.37949857249) (-282828.954425968,-134079.094464758,10102.5868597873) (-292907.57832529,-139152.844873569,19487.4949757231) (-312364.393502037,-149234.629591192,32761.5578770198) (-345125.87963522,-167261.791617465,43581.0554549427) (-388749.37459176,-193674.537462344,26135.310308055) (-414930.49652489,-213570.469831839,-61457.9368541815) (-353455.157168377,-179959.615912581,-105650.481459099) (-247777.492133003,-124265.774464089,-121647.532288114) (-126132.741419887,-62637.5386926524,-126202.215636761) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-146800.186830782,-146844.172161244,2152.4001264835) (-148915.216815274,-149048.228573403,5080.91858304233) (-153968.070350314,-154198.219473114,9385.92652605537) (-163337.154158343,-163623.70817086,14685.0368867326) (-178050.809464779,-178333.496925417,17134.0217311945) (-195231.760008403,-195456.411500017,6127.35550515132) (-201400.00667514,-201496.048492599,-27947.2534672322) (-173484.585844795,-173486.247511262,-49961.1692068214) (-123501.588997278,-123497.986151206,-59967.0241396824) (-63515.5076865231,-63563.2902548174,-63558.8251389076) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) ) ; boundaryField { fuel { type fixedValue; value uniform (0.1 0 0); } air { type fixedValue; value uniform (-0.1 0 0); } outlet { type zeroGradient; } frontAndBack { type empty; } } // ************************************************************************* //
[ "huberlulu@gmail.com" ]
huberlulu@gmail.com
cba0593de333a27edb3a8a6b1e2dd6e55041f5c2
aca894409ae1b19952663089ba24c9e65fe88767
/documentacao/code/arduino/arduino.ino
04cc152d61090bad7e5e3cedd1703a75c843ab30
[]
no_license
RamonCardosoBarbosa/IOT_SmartCane
36b5b4d505d9b624469d9eed11311484a8868314
8aea7baa191aff2e15dc8d93e4be1c67fa895eaf
refs/heads/master
2021-09-15T19:56:07.092182
2018-06-09T15:39:57
2018-06-09T15:39:57
130,922,519
1
0
null
null
null
null
UTF-8
C++
false
false
28,611
ino
/* Firmata is a generic protocol for communicating with microcontrollers from software on a host computer. It is intended to work with any host computer software package. To download a host software package, please click on the following link to open the list of Firmata client libraries in your default browser. https://github.com/firmata/arduino#firmata-client-libraries Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. Copyright (C) 2010-2011 Paul Stoffregen. All rights reserved. Copyright (C) 2009 Shigeru Kobayashi. All rights reserved. Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See file LICENSE.txt for further informations on licensing terms. Last updated October 16th, 2016 */ #include <Servo.h> #include <Wire.h> #include <Firmata.h> #include <Ultrasonic.h> #define I2C_WRITE B00000000 #define I2C_READ B00001000 #define I2C_READ_CONTINUOUSLY B00010000 #define I2C_STOP_READING B00011000 #define I2C_READ_WRITE_MODE_MASK B00011000 #define I2C_10BIT_ADDRESS_MODE_MASK B00100000 #define I2C_END_TX_MASK B01000000 #define I2C_STOP_TX 1 #define I2C_RESTART_TX 0 #define I2C_MAX_QUERIES 8 #define I2C_REGISTER_NOT_SPECIFIED -1 // the minimum interval for sampling analog input #define MINIMUM_SAMPLING_INTERVAL 1 /*============================================================================== GLOBAL VARIABLES ============================================================================*/ #ifdef FIRMATA_SERIAL_FEATURE SerialFirmata serialFeature; #endif /* analog inputs */ int analogInputsToReport = 0; // bitwise array to store pin reporting /* digital input ports */ byte reportPINs[TOTAL_PORTS]; // 1 = report this port, 0 = silence byte previousPINs[TOTAL_PORTS]; // previous 8 bits sent /* Declaração das variáveis*/ int ledPin = 11; int pinCheck = 12; int echo = 6; int trig = 7; int cm = 0; /* pins configuration */ byte portConfigInputs[TOTAL_PORTS]; // each bit: 1 = pin in INPUT, 0 = anything else /* timer variables */ unsigned long currentMillis; // store the current value from millis() unsigned long previousMillis; // for comparison with currentMillis unsigned int samplingInterval = 19; // how often to run the main loop (in ms) /* i2c data */ struct i2c_device_info { byte addr; int reg; byte bytes; byte stopTX; }; /* for i2c read continuous more */ i2c_device_info query[I2C_MAX_QUERIES]; byte i2cRxData[64]; boolean isI2CEnabled = false; signed char queryIndex = -1; // default delay time between i2c read request and Wire.requestFrom() unsigned int i2cReadDelayTime = 0; Servo servos[MAX_SERVOS]; byte servoPinMap[TOTAL_PINS]; byte detachedServos[MAX_SERVOS]; byte detachedServoCount = 0; byte servoCount = 0; boolean isResetting = false; // Forward declare a few functions to avoid compiler errors with older versions // of the Arduino IDE. void setPinModeCallback(byte, int); void reportAnalogCallback(byte analogPin, int value); void sysexCallback(byte, byte, byte*); /* utility functions */ void wireWrite(byte data) { #if ARDUINO >= 100 Wire.write((byte)data); #else Wire.send(data); #endif } byte wireRead(void) { #if ARDUINO >= 100 return Wire.read(); #else return Wire.receive(); #endif } /*============================================================================== FUNCTIONS ============================================================================*/ void attachServo(byte pin, int minPulse, int maxPulse) { if (servoCount < MAX_SERVOS) { // reuse indexes of detached servos until all have been reallocated if (detachedServoCount > 0) { servoPinMap[pin] = detachedServos[detachedServoCount - 1]; if (detachedServoCount > 0) detachedServoCount--; } else { servoPinMap[pin] = servoCount; servoCount++; } if (minPulse > 0 && maxPulse > 0) { servos[servoPinMap[pin]].attach(PIN_TO_DIGITAL(pin), minPulse, maxPulse); } else { servos[servoPinMap[pin]].attach(PIN_TO_DIGITAL(pin)); } } else { Firmata.sendString("Max servos attached"); } } void detachServo(byte pin) { servos[servoPinMap[pin]].detach(); // if we're detaching the last servo, decrement the count // otherwise store the index of the detached servo if (servoPinMap[pin] == servoCount && servoCount > 0) { servoCount--; } else if (servoCount > 0) { // keep track of detached servos because we want to reuse their indexes // before incrementing the count of attached servos detachedServoCount++; detachedServos[detachedServoCount - 1] = servoPinMap[pin]; } servoPinMap[pin] = 255; } void enableI2CPins() { byte i; // is there a faster way to do this? would probaby require importing // Arduino.h to get SCL and SDA pins for (i = 0; i < TOTAL_PINS; i++) { if (IS_PIN_I2C(i)) { // mark pins as i2c so they are ignore in non i2c data requests setPinModeCallback(i, PIN_MODE_I2C); } } isI2CEnabled = true; Wire.begin(); } /* disable the i2c pins so they can be used for other functions */ void disableI2CPins() { isI2CEnabled = false; // disable read continuous mode for all devices queryIndex = -1; } void readAndReportData(byte address, int theRegister, byte numBytes, byte stopTX) { // allow I2C requests that don't require a register read // for example, some devices using an interrupt pin to signify new data available // do not always require the register read so upon interrupt you call Wire.requestFrom() if (theRegister != I2C_REGISTER_NOT_SPECIFIED) { Wire.beginTransmission(address); wireWrite((byte)theRegister); Wire.endTransmission(stopTX); // default = true // do not set a value of 0 if (i2cReadDelayTime > 0) { // delay is necessary for some devices such as WiiNunchuck delayMicroseconds(i2cReadDelayTime); } } else { theRegister = 0; // fill the register with a dummy value } Wire.requestFrom(address, numBytes); // all bytes are returned in requestFrom // check to be sure correct number of bytes were returned by slave if (numBytes < Wire.available()) { Firmata.sendString("I2C: Too many bytes received"); } else if (numBytes > Wire.available()) { Firmata.sendString("I2C: Too few bytes received"); } i2cRxData[0] = address; i2cRxData[1] = theRegister; for (int i = 0; i < numBytes && Wire.available(); i++) { i2cRxData[2 + i] = wireRead(); } // send slave address, register and received bytes Firmata.sendSysex(SYSEX_I2C_REPLY, numBytes + 2, i2cRxData); } void outputPort(byte portNumber, byte portValue, byte forceSend) { // pins not configured as INPUT are cleared to zeros portValue = portValue & portConfigInputs[portNumber]; // only send if the value is different than previously sent if (forceSend || previousPINs[portNumber] != portValue) { Firmata.sendDigitalPort(portNumber, portValue); previousPINs[portNumber] = portValue; } } /* ----------------------------------------------------------------------------- check all the active digital inputs for change of state, then add any events to the Serial output queue using Serial.print() */ void checkDigitalInputs(void) { /* Using non-looping code allows constants to be given to readPort(). The compiler will apply substantial optimizations if the inputs to readPort() are compile-time constants. */ if (TOTAL_PORTS > 0 && reportPINs[0]) outputPort(0, readPort(0, portConfigInputs[0]), false); if (TOTAL_PORTS > 1 && reportPINs[1]) outputPort(1, readPort(1, portConfigInputs[1]), false); if (TOTAL_PORTS > 2 && reportPINs[2]) outputPort(2, readPort(2, portConfigInputs[2]), false); if (TOTAL_PORTS > 3 && reportPINs[3]) outputPort(3, readPort(3, portConfigInputs[3]), false); if (TOTAL_PORTS > 4 && reportPINs[4]) outputPort(4, readPort(4, portConfigInputs[4]), false); if (TOTAL_PORTS > 5 && reportPINs[5]) outputPort(5, readPort(5, portConfigInputs[5]), false); if (TOTAL_PORTS > 6 && reportPINs[6]) outputPort(6, readPort(6, portConfigInputs[6]), false); if (TOTAL_PORTS > 7 && reportPINs[7]) outputPort(7, readPort(7, portConfigInputs[7]), false); if (TOTAL_PORTS > 8 && reportPINs[8]) outputPort(8, readPort(8, portConfigInputs[8]), false); if (TOTAL_PORTS > 9 && reportPINs[9]) outputPort(9, readPort(9, portConfigInputs[9]), false); if (TOTAL_PORTS > 10 && reportPINs[10]) outputPort(10, readPort(10, portConfigInputs[10]), false); if (TOTAL_PORTS > 11 && reportPINs[11]) outputPort(11, readPort(11, portConfigInputs[11]), false); if (TOTAL_PORTS > 12 && reportPINs[12]) outputPort(12, readPort(12, portConfigInputs[12]), false); if (TOTAL_PORTS > 13 && reportPINs[13]) outputPort(13, readPort(13, portConfigInputs[13]), false); if (TOTAL_PORTS > 14 && reportPINs[14]) outputPort(14, readPort(14, portConfigInputs[14]), false); if (TOTAL_PORTS > 15 && reportPINs[15]) outputPort(15, readPort(15, portConfigInputs[15]), false); } // ----------------------------------------------------------------------------- /* sets the pin mode to the correct state and sets the relevant bits in the two bit-arrays that track Digital I/O and PWM status */ void setPinModeCallback(byte pin, int mode) { if (Firmata.getPinMode(pin) == PIN_MODE_IGNORE) return; if (Firmata.getPinMode(pin) == PIN_MODE_I2C && isI2CEnabled && mode != PIN_MODE_I2C) { // disable i2c so pins can be used for other functions // the following if statements should reconfigure the pins properly disableI2CPins(); } if (IS_PIN_DIGITAL(pin) && mode != PIN_MODE_SERVO) { if (servoPinMap[pin] < MAX_SERVOS && servos[servoPinMap[pin]].attached()) { detachServo(pin); } } if (IS_PIN_ANALOG(pin)) { reportAnalogCallback(PIN_TO_ANALOG(pin), mode == PIN_MODE_ANALOG ? 1 : 0); // turn on/off reporting } if (IS_PIN_DIGITAL(pin)) { if (mode == INPUT || mode == PIN_MODE_PULLUP) { portConfigInputs[pin / 8] |= (1 << (pin & 7)); } else { portConfigInputs[pin / 8] &= ~(1 << (pin & 7)); } } Firmata.setPinState(pin, 0); switch (mode) { case PIN_MODE_ANALOG: if (IS_PIN_ANALOG(pin)) { if (IS_PIN_DIGITAL(pin)) { pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver #if ARDUINO <= 100 // deprecated since Arduino 1.0.1 - TODO: drop support in Firmata 2.6 digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups #endif } Firmata.setPinMode(pin, PIN_MODE_ANALOG); } break; case INPUT: if (IS_PIN_DIGITAL(pin)) { pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver #if ARDUINO <= 100 // deprecated since Arduino 1.0.1 - TODO: drop support in Firmata 2.6 digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups #endif Firmata.setPinMode(pin, INPUT); } break; case PIN_MODE_PULLUP: if (IS_PIN_DIGITAL(pin)) { pinMode(PIN_TO_DIGITAL(pin), INPUT_PULLUP); Firmata.setPinMode(pin, PIN_MODE_PULLUP); Firmata.setPinState(pin, 1); } break; case OUTPUT: if (IS_PIN_DIGITAL(pin)) { if (Firmata.getPinMode(pin) == PIN_MODE_PWM) { // Disable PWM if pin mode was previously set to PWM. digitalWrite(PIN_TO_DIGITAL(pin), LOW); } pinMode(PIN_TO_DIGITAL(pin), OUTPUT); Firmata.setPinMode(pin, OUTPUT); } break; case PIN_MODE_PWM: if (IS_PIN_PWM(pin)) { pinMode(PIN_TO_PWM(pin), OUTPUT); analogWrite(PIN_TO_PWM(pin), 0); Firmata.setPinMode(pin, PIN_MODE_PWM); } break; case PIN_MODE_SERVO: if (IS_PIN_DIGITAL(pin)) { Firmata.setPinMode(pin, PIN_MODE_SERVO); if (servoPinMap[pin] == 255 || !servos[servoPinMap[pin]].attached()) { // pass -1 for min and max pulse values to use default values set // by Servo library attachServo(pin, -1, -1); } } break; case PIN_MODE_I2C: if (IS_PIN_I2C(pin)) { // mark the pin as i2c // the user must call I2C_CONFIG to enable I2C for a device Firmata.setPinMode(pin, PIN_MODE_I2C); } break; case PIN_MODE_SERIAL: #ifdef FIRMATA_SERIAL_FEATURE serialFeature.handlePinMode(pin, PIN_MODE_SERIAL); #endif break; default: Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM } // TODO: save status to EEPROM here, if changed } /* Sets the value of an individual pin. Useful if you want to set a pin value but are not tracking the digital port state. Can only be used on pins configured as OUTPUT. Cannot be used to enable pull-ups on Digital INPUT pins. */ void setPinValueCallback(byte pin, int value) { if (pin < TOTAL_PINS && IS_PIN_DIGITAL(pin)) { if (Firmata.getPinMode(pin) == OUTPUT) { Firmata.setPinState(pin, value); digitalWrite(PIN_TO_DIGITAL(pin), value); } } } void analogWriteCallback(byte pin, int value) { if (pin < TOTAL_PINS) { switch (Firmata.getPinMode(pin)) { case PIN_MODE_SERVO: if (IS_PIN_DIGITAL(pin)) servos[servoPinMap[pin]].write(value); Firmata.setPinState(pin, value); break; case PIN_MODE_PWM: if (IS_PIN_PWM(pin)) analogWrite(PIN_TO_PWM(pin), value); Firmata.setPinState(pin, value); break; } } } void digitalWriteCallback(byte port, int value) { byte pin, lastPin, pinValue, mask = 1, pinWriteMask = 0; if (port < TOTAL_PORTS) { // create a mask of the pins on this port that are writable. lastPin = port * 8 + 8; if (lastPin > TOTAL_PINS) lastPin = TOTAL_PINS; for (pin = port * 8; pin < lastPin; pin++) { // do not disturb non-digital pins (eg, Rx & Tx) if (IS_PIN_DIGITAL(pin)) { // do not touch pins in PWM, ANALOG, SERVO or other modes if (Firmata.getPinMode(pin) == OUTPUT || Firmata.getPinMode(pin) == INPUT) { pinValue = ((byte)value & mask) ? 1 : 0; if (Firmata.getPinMode(pin) == OUTPUT) { pinWriteMask |= mask; } else if (Firmata.getPinMode(pin) == INPUT && pinValue == 1 && Firmata.getPinState(pin) != 1) { // only handle INPUT here for backwards compatibility #if ARDUINO > 100 pinMode(pin, INPUT_PULLUP); #else // only write to the INPUT pin to enable pullups if Arduino v1.0.0 or earlier pinWriteMask |= mask; #endif } Firmata.setPinState(pin, pinValue); } } mask = mask << 1; } writePort(port, (byte)value, pinWriteMask); } } // ----------------------------------------------------------------------------- /* sets bits in a bit array (int) to toggle the reporting of the analogIns */ //void FirmataClass::setAnalogPinReporting(byte pin, byte state) { //} void reportAnalogCallback(byte analogPin, int value) { if (analogPin < TOTAL_ANALOG_PINS) { if (value == 0) { analogInputsToReport = analogInputsToReport & ~ (1 << analogPin); } else { analogInputsToReport = analogInputsToReport | (1 << analogPin); // prevent during system reset or all analog pin values will be reported // which may report noise for unconnected analog pins if (!isResetting) { // Send pin value immediately. This is helpful when connected via // ethernet, wi-fi or bluetooth so pin states can be known upon // reconnecting. Firmata.sendAnalog(analogPin, analogRead(analogPin)); } } } // TODO: save status to EEPROM here, if changed } void reportDigitalCallback(byte port, int value) { if (port < TOTAL_PORTS) { reportPINs[port] = (byte)value; // Send port value immediately. This is helpful when connected via // ethernet, wi-fi or bluetooth so pin states can be known upon // reconnecting. if (value) outputPort(port, readPort(port, portConfigInputs[port]), true); } // do not disable analog reporting on these 8 pins, to allow some // pins used for digital, others analog. Instead, allow both types // of reporting to be enabled, but check if the pin is configured // as analog when sampling the analog inputs. Likewise, while // scanning digital pins, portConfigInputs will mask off values from any // pins configured as analog } /*============================================================================== SYSEX-BASED commands ============================================================================*/ void sysexCallback(byte command, byte argc, byte *argv) { byte mode; byte stopTX; byte slaveAddress; byte data; int slaveRegister; unsigned int delayTime; switch (command) { case I2C_REQUEST: mode = argv[1] & I2C_READ_WRITE_MODE_MASK; if (argv[1] & I2C_10BIT_ADDRESS_MODE_MASK) { Firmata.sendString("10-bit addressing not supported"); return; } else { slaveAddress = argv[0]; } // need to invert the logic here since 0 will be default for client // libraries that have not updated to add support for restart tx if (argv[1] & I2C_END_TX_MASK) { stopTX = I2C_RESTART_TX; } else { stopTX = I2C_STOP_TX; // default } switch (mode) { case I2C_WRITE: Wire.beginTransmission(slaveAddress); for (byte i = 2; i < argc; i += 2) { data = argv[i] + (argv[i + 1] << 7); wireWrite(data); } Wire.endTransmission(); delayMicroseconds(70); break; case I2C_READ: if (argc == 6) { // a slave register is specified slaveRegister = argv[2] + (argv[3] << 7); data = argv[4] + (argv[5] << 7); // bytes to read } else { // a slave register is NOT specified slaveRegister = I2C_REGISTER_NOT_SPECIFIED; data = argv[2] + (argv[3] << 7); // bytes to read } readAndReportData(slaveAddress, (int)slaveRegister, data, stopTX); break; case I2C_READ_CONTINUOUSLY: if ((queryIndex + 1) >= I2C_MAX_QUERIES) { // too many queries, just ignore Firmata.sendString("too many queries"); break; } if (argc == 6) { // a slave register is specified slaveRegister = argv[2] + (argv[3] << 7); data = argv[4] + (argv[5] << 7); // bytes to read } else { // a slave register is NOT specified slaveRegister = (int)I2C_REGISTER_NOT_SPECIFIED; data = argv[2] + (argv[3] << 7); // bytes to read } queryIndex++; query[queryIndex].addr = slaveAddress; query[queryIndex].reg = slaveRegister; query[queryIndex].bytes = data; query[queryIndex].stopTX = stopTX; break; case I2C_STOP_READING: byte queryIndexToSkip; // if read continuous mode is enabled for only 1 i2c device, disable // read continuous reporting for that device if (queryIndex <= 0) { queryIndex = -1; } else { queryIndexToSkip = 0; // if read continuous mode is enabled for multiple devices, // determine which device to stop reading and remove it's data from // the array, shifiting other array data to fill the space for (byte i = 0; i < queryIndex + 1; i++) { if (query[i].addr == slaveAddress) { queryIndexToSkip = i; break; } } for (byte i = queryIndexToSkip; i < queryIndex + 1; i++) { if (i < I2C_MAX_QUERIES) { query[i].addr = query[i + 1].addr; query[i].reg = query[i + 1].reg; query[i].bytes = query[i + 1].bytes; query[i].stopTX = query[i + 1].stopTX; } } queryIndex--; } break; default: break; } break; case I2C_CONFIG: delayTime = (argv[0] + (argv[1] << 7)); if (delayTime > 0) { i2cReadDelayTime = delayTime; } if (!isI2CEnabled) { enableI2CPins(); } break; case SERVO_CONFIG: if (argc > 4) { // these vars are here for clarity, they'll optimized away by the compiler byte pin = argv[0]; int minPulse = argv[1] + (argv[2] << 7); int maxPulse = argv[3] + (argv[4] << 7); if (IS_PIN_DIGITAL(pin)) { if (servoPinMap[pin] < MAX_SERVOS && servos[servoPinMap[pin]].attached()) { detachServo(pin); } attachServo(pin, minPulse, maxPulse); setPinModeCallback(pin, PIN_MODE_SERVO); } } break; case SAMPLING_INTERVAL: if (argc > 1) { samplingInterval = argv[0] + (argv[1] << 7); if (samplingInterval < MINIMUM_SAMPLING_INTERVAL) { samplingInterval = MINIMUM_SAMPLING_INTERVAL; } } else { //Firmata.sendString("Not enough data"); } break; case EXTENDED_ANALOG: if (argc > 1) { int val = argv[1]; if (argc > 2) val |= (argv[2] << 7); if (argc > 3) val |= (argv[3] << 14); analogWriteCallback(argv[0], val); } break; case CAPABILITY_QUERY: Firmata.write(START_SYSEX); Firmata.write(CAPABILITY_RESPONSE); for (byte pin = 0; pin < TOTAL_PINS; pin++) { if (IS_PIN_DIGITAL(pin)) { Firmata.write((byte)INPUT); Firmata.write(1); Firmata.write((byte)PIN_MODE_PULLUP); Firmata.write(1); Firmata.write((byte)OUTPUT); Firmata.write(1); } if (IS_PIN_ANALOG(pin)) { Firmata.write(PIN_MODE_ANALOG); Firmata.write(10); // 10 = 10-bit resolution } if (IS_PIN_PWM(pin)) { Firmata.write(PIN_MODE_PWM); Firmata.write(DEFAULT_PWM_RESOLUTION); } if (IS_PIN_DIGITAL(pin)) { Firmata.write(PIN_MODE_SERVO); Firmata.write(14); } if (IS_PIN_I2C(pin)) { Firmata.write(PIN_MODE_I2C); Firmata.write(1); // TODO: could assign a number to map to SCL or SDA } #ifdef FIRMATA_SERIAL_FEATURE serialFeature.handleCapability(pin); #endif Firmata.write(127); } Firmata.write(END_SYSEX); break; case PIN_STATE_QUERY: if (argc > 0) { byte pin = argv[0]; Firmata.write(START_SYSEX); Firmata.write(PIN_STATE_RESPONSE); Firmata.write(pin); if (pin < TOTAL_PINS) { Firmata.write(Firmata.getPinMode(pin)); Firmata.write((byte)Firmata.getPinState(pin) & 0x7F); if (Firmata.getPinState(pin) & 0xFF80) Firmata.write((byte)(Firmata.getPinState(pin) >> 7) & 0x7F); if (Firmata.getPinState(pin) & 0xC000) Firmata.write((byte)(Firmata.getPinState(pin) >> 14) & 0x7F); } Firmata.write(END_SYSEX); } break; case ANALOG_MAPPING_QUERY: Firmata.write(START_SYSEX); Firmata.write(ANALOG_MAPPING_RESPONSE); for (byte pin = 0; pin < TOTAL_PINS; pin++) { Firmata.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127); } Firmata.write(END_SYSEX); break; case SERIAL_MESSAGE: #ifdef FIRMATA_SERIAL_FEATURE serialFeature.handleSysex(command, argc, argv); #endif break; } } /*============================================================================== SETUP() ============================================================================*/ void systemResetCallback() { isResetting = true; // initialize a defalt state // TODO: option to load config from EEPROM instead of default #ifdef FIRMATA_SERIAL_FEATURE serialFeature.reset(); #endif if (isI2CEnabled) { disableI2CPins(); } for (byte i = 0; i < TOTAL_PORTS; i++) { reportPINs[i] = false; // by default, reporting off portConfigInputs[i] = 0; // until activated previousPINs[i] = 0; } for (byte i = 0; i < TOTAL_PINS; i++) { // pins with analog capability default to analog input // otherwise, pins default to digital output if (IS_PIN_ANALOG(i)) { // turns off pullup, configures everything setPinModeCallback(i, PIN_MODE_ANALOG); } else if (IS_PIN_DIGITAL(i)) { // sets the output to 0, configures portConfigInputs setPinModeCallback(i, OUTPUT); } servoPinMap[i] = 255; } // by default, do not report any analog inputs analogInputsToReport = 0; detachedServoCount = 0; servoCount = 0; /* send digital inputs to set the initial state on the host computer, since once in the loop(), this firmware will only send on change */ /* TODO: this can never execute, since no pins default to digital input but it will be needed when/if we support EEPROM stored config for (byte i=0; i < TOTAL_PORTS; i++) { outputPort(i, readPort(i, portConfigInputs[i]), true); } */ isResetting = false; } void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(pinCheck, OUTPUT); Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION); Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); Firmata.attach(REPORT_ANALOG, reportAnalogCallback); Firmata.attach(REPORT_DIGITAL, reportDigitalCallback); Firmata.attach(SET_PIN_MODE, setPinModeCallback); Firmata.attach(SET_DIGITAL_PIN_VALUE, setPinValueCallback); Firmata.attach(START_SYSEX, sysexCallback); Firmata.attach(SYSTEM_RESET, systemResetCallback); // to use a port other than Serial, such as Serial1 on an Arduino Leonardo or Mega, // Call begin(baud) on the alternate serial port and pass it to Firmata to begin like this: // Serial1.begin(57600); // Firmata.begin(Serial1); // However do not do this if you are using SERIAL_MESSAGE Firmata.begin(57600); while (!Serial) { ; // wait for serial port to connect. Needed for ATmega32u4-based boards and Arduino 101 } systemResetCallback(); // reset to default config } /*============================================================================== LOOP() ============================================================================*/ void loop() { byte pin, analogPin; Ultrasonic ultrasonic(trig, echo); cm = ultrasonic.distanceRead(); Serial.print("Distancia: "); Serial.print(cm); Serial.print("cm"); Serial.println(); if (cm <= 4) { digitalWrite(ledPin, HIGH); Serial.println("TRUE"); digitalWrite(pinCheck, HIGH); } else { digitalWrite(ledPin, LOW); digitalWrite(pinCheck, LOW); Serial.println("FALSE"); } /* DIGITALREAD - as fast as possible, check for changes and output them to the FTDI buffer using Serial.print() */ checkDigitalInputs(); /* STREAMREAD - processing incoming messagse as soon as possible, while still checking digital inputs. */ while (Firmata.available()) Firmata.processInput(); // TODO - ensure that Stream buffer doesn't go over 60 bytes currentMillis = millis(); if (currentMillis - previousMillis > samplingInterval) { previousMillis += samplingInterval; /* ANALOGREAD - do all analogReads() at the configured sampling interval */ for (pin = 0; pin < TOTAL_PINS; pin++) { if (IS_PIN_ANALOG(pin) && Firmata.getPinMode(pin) == PIN_MODE_ANALOG) { analogPin = PIN_TO_ANALOG(pin); if (analogInputsToReport & (1 << analogPin)) { Firmata.sendAnalog(analogPin, analogRead(analogPin)); } } } // report i2c data for all device with read continuous mode enabled if (queryIndex > -1) { for (byte i = 0; i < queryIndex + 1; i++) { readAndReportData(query[i].addr, query[i].reg, query[i].bytes, query[i].stopTX); } } } #ifdef FIRMATA_SERIAL_FEATURE serialFeature.update(); #endif delay(300); }
[ "cardosoramonbarbosa@hotmail.com" ]
cardosoramonbarbosa@hotmail.com
9fd2c7358021a0a0ad7457ac33ddb331377924f5
8adec48dfaee1cdfd6c7f4d2fb3038aa1c17bda6
/WProf/src/net/spdy/spdy_stream.h
dddc0e71d08b9d26c3055032bdbcf6f01608908c
[ "BSD-3-Clause" ]
permissive
kusoof/wprof
ef507cfa92b3fd0f664d0eefef7fc7d6cd69481e
8511e9d4339d3d6fad5e14ad7fff73dfbd96beb8
refs/heads/master
2021-01-11T00:52:51.152225
2016-12-10T23:51:14
2016-12-10T23:51:14
70,486,057
0
1
null
null
null
null
UTF-8
C++
false
false
13,486
h
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_SPDY_SPDY_STREAM_H_ #define NET_SPDY_SPDY_STREAM_H_ #pragma once #include <string> #include <vector> #include "base/basictypes.h" #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" #include "googleurl/src/gurl.h" #include "net/base/bandwidth_metrics.h" #include "net/base/io_buffer.h" #include "net/base/net_export.h" #include "net/base/net_log.h" #include "net/base/request_priority.h" #include "net/base/server_bound_cert_service.h" #include "net/base/ssl_client_cert_type.h" #include "net/base/upload_data.h" #include "net/socket/ssl_client_socket.h" #include "net/spdy/spdy_framer.h" #include "net/spdy/spdy_protocol.h" namespace net { class AddressList; class IPEndPoint; class SpdySession; class SSLCertRequestInfo; class SSLInfo; // The SpdyStream is used by the SpdySession to represent each stream known // on the SpdySession. This class provides interfaces for SpdySession to use. // Streams can be created either by the client or by the server. When they // are initiated by the client, both the SpdySession and client object (such as // a SpdyNetworkTransaction) will maintain a reference to the stream. When // initiated by the server, only the SpdySession will maintain any reference, // until such a time as a client object requests a stream for the path. class NET_EXPORT_PRIVATE SpdyStream : public base::RefCounted<SpdyStream>, public ChunkCallback { public: // Delegate handles protocol specific behavior of spdy stream. class NET_EXPORT_PRIVATE Delegate { public: Delegate() {} // Called when SYN frame has been sent. // Returns true if no more data to be sent after SYN frame. virtual bool OnSendHeadersComplete(int status) = 0; // Called when stream is ready to send data. // Returns network error code. OK when it successfully sent data. virtual int OnSendBody() = 0; // Called when data has been sent. |status| indicates network error // or number of bytes that has been sent. On return, |eof| is set to true // if no more data is available to send in the request body. // Returns network error code. OK when it successfully sent data. virtual int OnSendBodyComplete(int status, bool* eof) = 0; // Called when the SYN_STREAM, SYN_REPLY, or HEADERS frames are received. // Normal streams will receive a SYN_REPLY and optional HEADERS frames. // Pushed streams will receive a SYN_STREAM and optional HEADERS frames. // Because a stream may have a SYN_* frame and multiple HEADERS frames, // this callback may be called multiple times. // |status| indicates network error. Returns network error code. virtual int OnResponseReceived(const SpdyHeaderBlock& response, base::Time response_time, int status) = 0; // Called when data is received. virtual void OnDataReceived(const char* data, int length) = 0; // Called when data is sent. virtual void OnDataSent(int length) = 0; // Called when SpdyStream is closed. virtual void OnClose(int status) = 0; // Sets the callback to be invoked when a new chunk is available to upload. virtual void set_chunk_callback(ChunkCallback* callback) = 0; protected: friend class base::RefCounted<Delegate>; virtual ~Delegate() {} private: DISALLOW_COPY_AND_ASSIGN(Delegate); }; // SpdyStream constructor SpdyStream(SpdySession* session, SpdyStreamId stream_id, bool pushed, const BoundNetLog& net_log); // Set new |delegate|. |delegate| must not be NULL. // If it already received SYN_REPLY or data, OnResponseReceived() or // OnDataReceived() will be called. void SetDelegate(Delegate* delegate); Delegate* GetDelegate() { return delegate_; } // Detach delegate from the stream. It will cancel the stream if it was not // cancelled yet. It is safe to call multiple times. void DetachDelegate(); // Is this stream a pushed stream from the server. bool pushed() const { return pushed_; } SpdyStreamId stream_id() const { return stream_id_; } void set_stream_id(SpdyStreamId stream_id) { stream_id_ = stream_id; } bool response_received() const { return response_received_; } void set_response_received() { response_received_ = true; } // For pushed streams, we track a path to identify them. const std::string& path() const { return path_; } void set_path(const std::string& path) { path_ = path; } RequestPriority priority() const { return priority_; } void set_priority(RequestPriority priority) { priority_ = priority; } int32 send_window_size() const { return send_window_size_; } void set_send_window_size(int32 window_size) { send_window_size_ = window_size; } int32 recv_window_size() const { return recv_window_size_; } void set_recv_window_size(int32 window_size) { recv_window_size_ = window_size; } // Set session_'s initial_recv_window_size. Used by unittests. void set_initial_recv_window_size(int32 window_size); bool stalled_by_flow_control() { return stalled_by_flow_control_; } void set_stalled_by_flow_control(bool stalled) { stalled_by_flow_control_ = stalled; } // Adjusts the |send_window_size_| by |delta_window_size|. |delta_window_size| // is the difference between the SETTINGS_INITIAL_WINDOW_SIZE in SETTINGS // frame and the previous initial_send_window_size. void AdjustSendWindowSize(int32 delta_window_size); // Increases |send_window_size_| with delta extracted from a WINDOW_UPDATE // frame; sends a RST_STREAM if delta overflows |send_window_size_| and // removes the stream from the session. void IncreaseSendWindowSize(int32 delta_window_size); // Decreases |send_window_size_| by the given number of bytes. void DecreaseSendWindowSize(int32 delta_window_size); int GetPeerAddress(IPEndPoint* address) const; int GetLocalAddress(IPEndPoint* address) const; // Returns true if the underlying transport socket ever had any reads or // writes. bool WasEverUsed() const; // Increases |recv_window_size_| by the given number of bytes, also sends // a WINDOW_UPDATE frame. void IncreaseRecvWindowSize(int32 delta_window_size); // Decreases |recv_window_size_| by the given number of bytes, called // whenever data is read. May also send a RST_STREAM and remove the // stream from the session if the resultant |recv_window_size_| is // negative, since that would be a flow control violation. void DecreaseRecvWindowSize(int32 delta_window_size); const BoundNetLog& net_log() const { return net_log_; } const linked_ptr<SpdyHeaderBlock>& spdy_headers() const; void set_spdy_headers(const linked_ptr<SpdyHeaderBlock>& headers); base::Time GetRequestTime() const; void SetRequestTime(base::Time t); // Called by the SpdySession when a response (e.g. a SYN_STREAM or SYN_REPLY) // has been received for this stream. Returns a status code. int OnResponseReceived(const SpdyHeaderBlock& response); // Called by the SpdySession when late-bound headers are received for a // stream. Returns a status code. int OnHeaders(const SpdyHeaderBlock& headers); // Called by the SpdySession when response data has been received for this // stream. This callback may be called multiple times as data arrives // from the network, and will never be called prior to OnResponseReceived. // |buffer| contains the data received. The stream must copy any data // from this buffer before returning from this callback. // |length| is the number of bytes received or an error. // A zero-length count does not indicate end-of-stream. void OnDataReceived(const char* buffer, int bytes); // Called by the SpdySession when a write has completed. This callback // will be called multiple times for each write which completes. Writes // include the SYN_STREAM write and also DATA frame writes. // |result| is the number of bytes written or a net error code. void OnWriteComplete(int bytes); // Called by the SpdySession when the request is finished. This callback // will always be called at the end of the request and signals to the // stream that the stream has no more network events. No further callbacks // to the stream will be made after this call. // |status| is an error code or OK. void OnClose(int status); // Called by the SpdySession to log stream related errors. void LogStreamError(int status, const std::string& description); void Cancel(); void Close(); bool cancelled() const { return cancelled_; } bool closed() const { return io_state_ == STATE_DONE; } // TODO(satorux): This is only for testing. We should be able to remove // this once crbug.com/113107 is addressed. bool body_sent() const { return io_state_ > STATE_SEND_BODY_COMPLETE; } // Interface for Spdy[Http|WebSocket]Stream to use. // Sends the request. // For non push stream, it will send SYN_STREAM frame. int SendRequest(bool has_upload_data); // Sends DATA frame. int WriteStreamData(IOBuffer* data, int length, SpdyDataFlags flags); // Fills SSL info in |ssl_info| and returns true when SSL is in use. bool GetSSLInfo(SSLInfo* ssl_info, bool* was_npn_negotiated, NextProto* protocol_negotiated); // Fills SSL Certificate Request info |cert_request_info| and returns // true when SSL is in use. bool GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); bool is_idle() const { return io_state_ == STATE_OPEN || io_state_ == STATE_DONE; } int response_status() const { return response_status_; } // Returns true if the URL for this stream is known. bool HasUrl() const; // Get the URL associated with this stream. Only valid when has_url() is // true. GURL GetUrl() const; // ChunkCallback methods. virtual void OnChunkAvailable() OVERRIDE; int GetProtocolVersion() const; private: enum State { STATE_NONE, STATE_GET_DOMAIN_BOUND_CERT, STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, STATE_SEND_DOMAIN_BOUND_CERT, STATE_SEND_DOMAIN_BOUND_CERT_COMPLETE, STATE_SEND_HEADERS, STATE_SEND_HEADERS_COMPLETE, STATE_SEND_BODY, STATE_SEND_BODY_COMPLETE, STATE_WAITING_FOR_RESPONSE, STATE_OPEN, STATE_DONE }; friend class base::RefCounted<SpdyStream>; virtual ~SpdyStream(); // If the stream is stalled and if |send_window_size_| is positive, then set // |stalled_by_flow_control_| to false and unstall the stream. void PossiblyResumeIfStalled(); void OnGetDomainBoundCertComplete(int result); // Try to make progress sending/receiving the request/response. int DoLoop(int result); // The implementations of each state of the state machine. int DoGetDomainBoundCert(); int DoGetDomainBoundCertComplete(int result); int DoSendDomainBoundCert(); int DoSendDomainBoundCertComplete(int result); int DoSendHeaders(); int DoSendHeadersComplete(int result); int DoSendBody(); int DoSendBodyComplete(int result); int DoReadHeaders(); int DoReadHeadersComplete(int result); int DoOpen(int result); // Update the histograms. Can safely be called repeatedly, but should only // be called after the stream has completed. void UpdateHistograms(); // When a server pushed stream is first created, this function is posted on // the MessageLoop to replay all the data that the server has already sent. void PushedStreamReplayData(); // There is a small period of time between when a server pushed stream is // first created, and the pushed data is replayed. Any data received during // this time should continue to be buffered. bool continue_buffering_data_; SpdyStreamId stream_id_; std::string path_; RequestPriority priority_; size_t slot_; // Flow control variables. bool stalled_by_flow_control_; int32 send_window_size_; int32 recv_window_size_; int32 unacked_recv_window_bytes_; const bool pushed_; ScopedBandwidthMetrics metrics_; bool response_received_; scoped_refptr<SpdySession> session_; // The transaction should own the delegate. SpdyStream::Delegate* delegate_; // The request to send. linked_ptr<SpdyHeaderBlock> request_; // The time at which the request was made that resulted in this response. // For cached responses, this time could be "far" in the past. base::Time request_time_; linked_ptr<SpdyHeaderBlock> response_; base::Time response_time_; State io_state_; // Since we buffer the response, we also buffer the response status. // Not valid until the stream is closed. int response_status_; bool cancelled_; bool has_upload_data_; BoundNetLog net_log_; base::TimeTicks send_time_; base::TimeTicks recv_first_byte_time_; base::TimeTicks recv_last_byte_time_; int send_bytes_; int recv_bytes_; // Data received before delegate is attached. std::vector<scoped_refptr<IOBufferWithSize> > pending_buffers_; SSLClientCertType domain_bound_cert_type_; std::string domain_bound_private_key_; std::string domain_bound_cert_; ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; DISALLOW_COPY_AND_ASSIGN(SpdyStream); }; } // namespace net #endif // NET_SPDY_SPDY_STREAM_H_
[ "kusoof@kookaburra.(none)" ]
kusoof@kookaburra.(none)