blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
642dc059194c03822ffcc2ba9db94751428d77e4
0108763202f4a75ab70b6cabfee551f22b65b9ab
/GSM/Card.h
05f9d8ae68fe75ab48a0914e95a85398ecb2fa31
[]
no_license
gra3/SDPTest
1ab808b51596d94e0b9b0b127cd0684d647ef068
75321fcef07d2c248df74d1cc2a873498ffb2f77
refs/heads/master
2021-05-31T12:11:35.974883
2016-04-21T20:23:01
2016-04-21T20:23:01
50,212,253
0
0
null
2016-01-23T00:22:13
2016-01-22T22:46:38
C++
UTF-8
C++
false
false
1,401
h
#pragma once #include <stdio.h> #include <iostream> #include <string> using namespace std; class Card { public: int suit, rank; Card(void) { suit = -1; rank = -1; } Card(int rankIn, int suitIn) { rank = rankIn; suit = suitIn; } ~Card(void) { } void set(int rankIn, int suitIn) { rank = rankIn; suit = suitIn; } void printCard() { if(rank!=-1&&suit!=-1) { if(rank==14) cout << "Ace of "; if(rank==13) cout << "Kind of "; if(rank==12) cout << "Queen of "; if(rank==11) cout << "Jack of "; if(rank==10) cout << "10 of "; if(rank==9) cout << "9 of "; if(rank==8) cout << "8 of "; if(rank==7) cout << "7 of "; if(rank==6) cout << "6 of "; if(rank==5) cout << "5 of "; if(rank==4) cout << "4 of "; if(rank==3) cout << "3 of "; if(rank==2) cout << "2 of "; if(suit==0) cout << "Hearts\n"; if(suit==1) cout << "Spades\n"; if(suit==2) cout << "Clubs\n"; if(suit==3) cout << "Diamonds\n"; } } bool operator==(const Card &other) { if(suit==other.suit&&rank==other.rank) return true; else return false; } bool operator!=(const Card &other) { if(suit!=other.suit||rank!=other.rank) return true; else return false; } void operator=(const Card &other) { rank = other.rank; suit = other.suit; } bool operator<(const Card &other) { if(rank<other.rank) return true; else return false; } };
[ "gra3@zips.uakron.edu" ]
gra3@zips.uakron.edu
9d8faffb728479c8bad014a7edef0e17c3bc9baf
d063ee27407f2fb7dfd653b38db79a99c7945adc
/hardcoded_views/vertical_slider_view.h
f723f8fcbd51d0c0ca68a25b91c4bbcfc1ebf4db
[]
no_license
jjzhang166/SWAG
fe1f0ad8a6318cee067336f93d0bc604cd8b1b03
aeb29c108ae2eb7f6db427373416fe16bd71c189
refs/heads/master
2021-01-02T08:13:37.975440
2013-06-11T16:55:41
2013-06-11T16:55:41
98,967,481
0
0
null
null
null
null
UTF-8
C++
false
false
216
h
#include <widget_view.h> struct ALLEGRO_FONT; class Vertical_slider_view: public Widget_view { public: virtual Vector2 Request_size(const Widget& widget) const; virtual void Render(const Widget& widget) const; };
[ "trezker@gmail.com" ]
trezker@gmail.com
b7c681189ef7ac00481f102814a908d1a53b26ca
249630ace4f18594e43ac8179db3b8d30021370a
/aws-cpp-sdk-ec2/source/model/ReportInstanceReasonCodes.cpp
2c92b50838eb22e94587540452829c8bae979095
[ "JSON", "MIT", "Apache-2.0" ]
permissive
FlyingSquid/aws-sdk-cpp
5e5f2040867b1e1998fa8b06b837b3b19f550469
3fe46f05d1c58fc946045d3b860a79c88d76ceb1
refs/heads/master
2021-01-10T17:19:36.927018
2016-02-27T01:30:38
2016-02-27T01:30:38
52,852,300
0
0
null
null
null
null
UTF-8
C++
false
false
5,018
cpp
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 <aws/ec2/model/ReportInstanceReasonCodes.h> #include <aws/core/utils/HashingUtils.h> #include <aws/core/Globals.h> using namespace Aws::Utils; static const int instance_stuck_in_state_HASH = HashingUtils::HashString("instance-stuck-in-state"); static const int unresponsive_HASH = HashingUtils::HashString("unresponsive"); static const int not_accepting_credentials_HASH = HashingUtils::HashString("not-accepting-credentials"); static const int password_not_available_HASH = HashingUtils::HashString("password-not-available"); static const int performance_network_HASH = HashingUtils::HashString("performance-network"); static const int performance_instance_store_HASH = HashingUtils::HashString("performance-instance-store"); static const int performance_ebs_volume_HASH = HashingUtils::HashString("performance-ebs-volume"); static const int performance_other_HASH = HashingUtils::HashString("performance-other"); static const int other_HASH = HashingUtils::HashString("other"); namespace Aws { namespace EC2 { namespace Model { namespace ReportInstanceReasonCodesMapper { ReportInstanceReasonCodes GetReportInstanceReasonCodesForName(const Aws::String& name) { int hashCode = HashingUtils::HashString(name.c_str()); if (hashCode == instance_stuck_in_state_HASH) { return ReportInstanceReasonCodes::instance_stuck_in_state; } else if (hashCode == unresponsive_HASH) { return ReportInstanceReasonCodes::unresponsive; } else if (hashCode == not_accepting_credentials_HASH) { return ReportInstanceReasonCodes::not_accepting_credentials; } else if (hashCode == password_not_available_HASH) { return ReportInstanceReasonCodes::password_not_available; } else if (hashCode == performance_network_HASH) { return ReportInstanceReasonCodes::performance_network; } else if (hashCode == performance_instance_store_HASH) { return ReportInstanceReasonCodes::performance_instance_store; } else if (hashCode == performance_ebs_volume_HASH) { return ReportInstanceReasonCodes::performance_ebs_volume; } else if (hashCode == performance_other_HASH) { return ReportInstanceReasonCodes::performance_other; } else if (hashCode == other_HASH) { return ReportInstanceReasonCodes::other; } EnumParseOverflowContainer* overflowContainer = g_enumOverflow.load(); if(overflowContainer) { overflowContainer->StoreOverflow(hashCode, name); return static_cast<ReportInstanceReasonCodes>(hashCode); } return ReportInstanceReasonCodes::NOT_SET; } Aws::String GetNameForReportInstanceReasonCodes(ReportInstanceReasonCodes enumValue) { switch(enumValue) { case ReportInstanceReasonCodes::instance_stuck_in_state: return "instance-stuck-in-state"; case ReportInstanceReasonCodes::unresponsive: return "unresponsive"; case ReportInstanceReasonCodes::not_accepting_credentials: return "not-accepting-credentials"; case ReportInstanceReasonCodes::password_not_available: return "password-not-available"; case ReportInstanceReasonCodes::performance_network: return "performance-network"; case ReportInstanceReasonCodes::performance_instance_store: return "performance-instance-store"; case ReportInstanceReasonCodes::performance_ebs_volume: return "performance-ebs-volume"; case ReportInstanceReasonCodes::performance_other: return "performance-other"; case ReportInstanceReasonCodes::other: return "other"; default: EnumParseOverflowContainer* overflowContainer = g_enumOverflow.load(); if(overflowContainer) { return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); } return ""; } } } // namespace ReportInstanceReasonCodesMapper } // namespace Model } // namespace EC2 } // namespace Aws
[ "henso@amazon.com" ]
henso@amazon.com
9a69d939f43cf5eb17ad318a21e0c73cef763b43
dd2f2ed45672e8ab361d44015a8affa682182914
/example2.cpp
415c9edc68dc86f0d0bc3f295bbe5ca8ff3b8e9a
[]
no_license
aadebuger/tapp
1112bd54ff031f79ab09ba4583c8897c74a62743
5027bc36e8d5a7ffbc7c75bfe7f57a85191d79ef
refs/heads/master
2021-01-22T20:35:37.795953
2017-03-20T14:16:58
2017-03-20T14:16:58
85,335,218
0
0
null
2017-03-17T16:57:13
2017-03-17T16:57:13
null
UTF-8
C++
false
false
1,891
cpp
/* * TA++ Copyright (c) 2008-2009, Wei Dong wdong.pku@gmail.com * All rights reserved. * * FOR PERSONAL AND NON-COMMERCIAL USE ONLY. REDISTRIBUTION IS NOT PERMITTED. * * 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 REGENTS 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. */ /** * \file example.cpp * * \brief Example program. */ #include "ta++.h" #include "ta++-plot.h" // All TA++ symbols are under the namespace tapp. using namespace tapp; int main () { // Initialize the TA-Lib. This function is from TA-lib. TA_Initialize(); // Load stock data from the file "C". // Records before the date 2008-05-01 are not loaded. Candles candles("C", str2time("2008-05-01")); // GnuplotChart generate gnuplot scripts. The output will be stored in "C.gp". // The constructor automatically generate two panes: pane0 for the candles and // pane1 for volume. // // c.gp is the output Gnuplot script name // c.png is the image file that should be generated by running the Gnuplot script. GnuplotChart chart("C", "c.gp", "c.png"); chart.addPane("")->drawCandles(candles); // Generate the output. chart.render(); TA_Shutdown(); return 0; }
[ "wdong@wdong.org" ]
wdong@wdong.org
460ca3bfe97bdcb05417efdffab435d0993f3e07
e2c3ad5709359f13f9d93378fadbc0f0116d595f
/GTT/InputMovement.h
0c739675307663d8419c3d1ade8717ded781fe02
[]
no_license
dagil02/TaxiRevengeDLC
b2bb7ea69bf146ec5f4251ed80ab02acd43e2e9a
b785dd652c435b7495e9aaed2b4a3d1bc4900af7
refs/heads/master
2020-06-02T01:01:49.305137
2019-07-01T17:06:11
2019-07-01T17:06:11
190,985,412
0
0
null
null
null
null
UTF-8
C++
false
false
701
h
#pragma once #include "Vehicle.h" class InputMovement : public ControlType { public: InputMovement(KeysScheme k, Vehicle* v); virtual ~InputMovement(); virtual void handleInput(GameObject* o, Uint32 deltaTime, const SDL_Event& event); virtual void update(GameObject* o, Uint32 deltaTime); private: KeysScheme k_; Vehicle* v_; //Input booleans bool forwardPressed_ = false; bool backwardPressed_ = false; bool rightTurnPressed_ = false; bool leftTurnPressed_ = false; bool handBrakePressed_ = false; float targetLateralVelocity = 0; float targetDamping = 1; float targetMaxSpeed; void steeringWheel(); bool isMoving(); Vector2D getLateralVelocity(); void updateFriction(); };
[ "dagil02@ucm.es" ]
dagil02@ucm.es
a696a294023dcd7740d44388f2b98f02c4c9c50f
241b935d22ef26b5c30e0d0457918528d8914ece
/src/governance-object.h
6e3a44c886f25ee0d2d00a7dfccaa5f6e929e3e3
[ "MIT" ]
permissive
minblock/compute
6cc96778fd69d5fdb08020cb995b56b4b0536b2d
daaff2edac93fb8754d6c015788162bcbe73aea5
refs/heads/master
2022-08-28T11:21:37.489509
2022-08-19T00:21:10
2022-08-19T00:21:10
163,465,881
1
0
MIT
2019-02-27T01:44:18
2018-12-29T02:00:57
C++
UTF-8
C++
false
false
10,050
h
// Copyright (c) 2018-2019 The ComputeCore developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef GOVERNANCE_OBJECT_H #define GOVERNANCE_OBJECT_H #include "cachemultimap.h" #include "governance-exceptions.h" #include "governance-vote.h" #include "governance-votedb.h" #include "key.h" #include "net.h" #include "sync.h" #include "util.h" #include "utilstrencodings.h" #include "bls/bls.h" #include <univalue.h> class CGovernanceManager; class CGovernanceTriggerManager; class CGovernanceObject; class CGovernanceVote; static const int MIN_GOVERNANCE_PEER_PROTO_VERSION = 70213; static const int GOVERNANCE_FILTER_PROTO_VERSION = 70206; static const int GOVERNANCE_POSE_BANNED_VOTES_VERSION = 70215; static const double GOVERNANCE_FILTER_FP_RATE = 0.001; static const int GOVERNANCE_OBJECT_UNKNOWN = 0; static const int GOVERNANCE_OBJECT_PROPOSAL = 1; static const int GOVERNANCE_OBJECT_TRIGGER = 2; static const CAmount GOVERNANCE_PROPOSAL_FEE_TX = (5.0 * COIN); static const int64_t GOVERNANCE_FEE_CONFIRMATIONS = 6; static const int64_t GOVERNANCE_MIN_RELAY_FEE_CONFIRMATIONS = 1; static const int64_t GOVERNANCE_UPDATE_MIN = 60 * 60; static const int64_t GOVERNANCE_DELETION_DELAY = 10 * 60; static const int64_t GOVERNANCE_ORPHAN_EXPIRATION_TIME = 10 * 60; // FOR SEEN MAP ARRAYS - GOVERNANCE OBJECTS AND VOTES static const int SEEN_OBJECT_IS_VALID = 0; static const int SEEN_OBJECT_ERROR_INVALID = 1; static const int SEEN_OBJECT_ERROR_IMMATURE = 2; static const int SEEN_OBJECT_EXECUTED = 3; //used for triggers static const int SEEN_OBJECT_UNKNOWN = 4; // the default typedef std::pair<CGovernanceVote, int64_t> vote_time_pair_t; inline bool operator<(const vote_time_pair_t& p1, const vote_time_pair_t& p2) { return (p1.first < p2.first); } struct vote_instance_t { vote_outcome_enum_t eOutcome; int64_t nTime; int64_t nCreationTime; vote_instance_t(vote_outcome_enum_t eOutcomeIn = VOTE_OUTCOME_NONE, int64_t nTimeIn = 0, int64_t nCreationTimeIn = 0) : eOutcome(eOutcomeIn), nTime(nTimeIn), nCreationTime(nCreationTimeIn) { } ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { int nOutcome = int(eOutcome); READWRITE(nOutcome); READWRITE(nTime); READWRITE(nCreationTime); if (ser_action.ForRead()) { eOutcome = vote_outcome_enum_t(nOutcome); } } }; typedef std::map<int, vote_instance_t> vote_instance_m_t; typedef vote_instance_m_t::iterator vote_instance_m_it; typedef vote_instance_m_t::const_iterator vote_instance_m_cit; struct vote_rec_t { vote_instance_m_t mapInstances; ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(mapInstances); } }; /** * Governance Object * */ class CGovernanceObject { friend class CGovernanceManager; friend class CGovernanceTriggerManager; friend class CSuperblock; public: // Types typedef std::map<COutPoint, vote_rec_t> vote_m_t; typedef vote_m_t::iterator vote_m_it; typedef vote_m_t::const_iterator vote_m_cit; typedef CacheMultiMap<COutPoint, vote_time_pair_t> vote_cmm_t; private: /// critical section to protect the inner data structures mutable CCriticalSection cs; /// Object typecode int nObjectType; /// parent object, 0 is root uint256 nHashParent; /// object revision in the system int nRevision; /// time this object was created int64_t nTime; /// time this object was marked for deletion int64_t nDeletionTime; /// fee-tx uint256 nCollateralHash; /// Data field - can be used for anything std::vector<unsigned char> vchData; /// Masternode info for signed objects COutPoint masternodeOutpoint; std::vector<unsigned char> vchSig; /// is valid by blockchain bool fCachedLocalValidity; std::string strLocalValidityError; // VARIOUS FLAGS FOR OBJECT / SET VIA MASTERNODE VOTING /// true == minimum network support has been reached for this object to be funded (doesn't mean it will for sure though) bool fCachedFunding; /// true == minimum network has been reached flagging this object as a valid and understood governance object (e.g, the serialized data is correct format, etc) bool fCachedValid; /// true == minimum network support has been reached saying this object should be deleted from the system entirely bool fCachedDelete; /** true == minimum network support has been reached flagging this object as endorsed by an elected representative body * (e.g. business review board / technecial review board /etc) */ bool fCachedEndorsed; /// object was updated and cached values should be updated soon bool fDirtyCache; /// Object is no longer of interest bool fExpired; /// Failed to parse object data bool fUnparsable; vote_m_t mapCurrentMNVotes; /// Limited map of votes orphaned by MN vote_cmm_t cmmapOrphanVotes; CGovernanceObjectVoteFile fileVotes; public: CGovernanceObject(); CGovernanceObject(const uint256& nHashParentIn, int nRevisionIn, int64_t nTime, const uint256& nCollateralHashIn, const std::string& strDataHexIn); CGovernanceObject(const CGovernanceObject& other); // Public Getter methods int64_t GetCreationTime() const { return nTime; } int64_t GetDeletionTime() const { return nDeletionTime; } int GetObjectType() const { return nObjectType; } const uint256& GetCollateralHash() const { return nCollateralHash; } const COutPoint& GetMasternodeOutpoint() const { return masternodeOutpoint; } bool IsSetCachedFunding() const { return fCachedFunding; } bool IsSetCachedValid() const { return fCachedValid; } bool IsSetCachedDelete() const { return fCachedDelete; } bool IsSetCachedEndorsed() const { return fCachedEndorsed; } bool IsSetDirtyCache() const { return fDirtyCache; } bool IsSetExpired() const { return fExpired; } const CGovernanceObjectVoteFile& GetVoteFile() const { return fileVotes; } // Signature related functions void SetMasternodeOutpoint(const COutPoint& outpoint); bool Sign(const CBLSSecretKey& key); bool CheckSignature(const CBLSPublicKey& pubKey) const; std::string GetSignatureMessage() const; uint256 GetSignatureHash() const; // CORE OBJECT FUNCTIONS bool IsValidLocally(std::string& strError, bool fCheckCollateral) const; bool IsValidLocally(std::string& strError, bool& fMissingMasternode, bool& fMissingConfirmations, bool fCheckCollateral) const; /// Check the collateral transaction for the budget proposal/finalized budget bool IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const; void UpdateLocalValidity(); void UpdateSentinelVariables(); CAmount GetMinCollateralFee() const; UniValue GetJSONObject(); void Relay(CConnman& connman); uint256 GetHash() const; // GET VOTE COUNT FOR SIGNAL int CountMatchingVotes(vote_signal_enum_t eVoteSignalIn, vote_outcome_enum_t eVoteOutcomeIn) const; int GetAbsoluteYesCount(vote_signal_enum_t eVoteSignalIn) const; int GetAbsoluteNoCount(vote_signal_enum_t eVoteSignalIn) const; int GetYesCount(vote_signal_enum_t eVoteSignalIn) const; int GetNoCount(vote_signal_enum_t eVoteSignalIn) const; int GetAbstainCount(vote_signal_enum_t eVoteSignalIn) const; bool GetCurrentMNVotes(const COutPoint& mnCollateralOutpoint, vote_rec_t& voteRecord) const; // FUNCTIONS FOR DEALING WITH DATA STRING std::string GetDataAsHexString() const; std::string GetDataAsPlainString() const; // SERIALIZER ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { // SERIALIZE DATA FOR SAVING/LOADING OR NETWORK FUNCTIONS READWRITE(nHashParent); READWRITE(nRevision); READWRITE(nTime); READWRITE(nCollateralHash); READWRITE(vchData); READWRITE(nObjectType); READWRITE(masternodeOutpoint); if (!(s.GetType() & SER_GETHASH)) { READWRITE(vchSig); } if (s.GetType() & SER_DISK) { // Only include these for the disk file format LogPrint("gobject", "CGovernanceObject::SerializationOp Reading/writing votes from/to disk\n"); READWRITE(nDeletionTime); READWRITE(fExpired); READWRITE(mapCurrentMNVotes); READWRITE(fileVotes); LogPrint("gobject", "CGovernanceObject::SerializationOp hash = %s, vote count = %d\n", GetHash().ToString(), fileVotes.GetVoteCount()); } // AFTER DESERIALIZATION OCCURS, CACHED VARIABLES MUST BE CALCULATED MANUALLY } private: // FUNCTIONS FOR DEALING WITH DATA STRING void LoadData(); void GetData(UniValue& objResult); bool ProcessVote(CNode* pfrom, const CGovernanceVote& vote, CGovernanceException& exception, CConnman& connman); /// Called when MN's which have voted on this object have been removed void ClearMasternodeVotes(); // Revalidate all votes from this MN and delete them if validation fails. // This is the case for DIP3 MNs that changed voting or operator keys and // also for MNs that were removed from the list completely. // Returns deleted vote hashes. std::set<uint256> RemoveInvalidVotes(const COutPoint& mnOutpoint); void CheckOrphanVotes(CConnman& connman); }; #endif
[ "38344452+minblock@users.noreply.github.com" ]
38344452+minblock@users.noreply.github.com
8936fa1931b20a6c8945c4b41225c2f74d287b89
58fd3255d72e61dbc18db2ef7e756b5b0e00bde8
/APP_MPI/optimal_fence_mpi.cpp
954f79928c265988001f7e5231210e51faa070da
[]
no_license
meusburgger/Optimal-Fence
6ea3c0fe6d2af51c9d3d791e49c16f3aa0a7bfe7
ec70b6700ac884a18135f817badc1e38cdf46748
refs/heads/master
2020-03-19T08:38:05.230120
2018-06-05T19:09:08
2018-06-05T19:09:08
136,222,531
0
0
null
null
null
null
UTF-8
C++
false
false
16,055
cpp
#include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> #include "convexhull.h" #include "mpi.h" #include <assert.h> #include <string.h> #include <sys/time.h> #define MASTER_TO_SLAVE_TAG 1 //tag for messages sent from master to slaves #define SLAVE_TO_MASTER_TAG 4 //tag for messages sent from slaves to master #define DMaxArboles 27 #define DMaximoCoste 999999 ////////////////////////// // Estructuras de datos // ////////////////////////// // Definicin estructura arbol entrada (Conjunto �boles). struct Arbol { int IdArbol; Point Coord; // Posicin �bol int Valor; // Valor / Coste �bol. int Longitud; // Cantidad madera �bol }; typedef struct Arbol TArbol, *PtrArbol; // Definicin estructura Bosque entrada (Conjunto �boles). struct Bosque { int NumArboles; TArbol Arboles[DMaxArboles]; }; typedef struct Bosque TBosque, *PtrBosque; // Combinacin . struct ListaArboles { int NumArboles; float Coste; float CosteArbolesCortados; float CosteArbolesRestantes; float LongitudCerca; float MaderaSobrante; int Arboles[DMaxArboles]; }; typedef struct ListaArboles TListaArboles, *PtrListaArboles; // Vector est�ico Coordenadas. typedef Point TVectorCoordenadas[DMaxArboles], *PtrVectorCoordenadas; //typedef enum {false, true} bool; //////////////////////// // Variables Globales // //////////////////////// TBosque ArbolesEntrada; int low_bound; int upper_bound; MPI_Status status; // store status of a MPI_Recv ////////////////////////// // Prototipos funciones // ////////////////////////// bool LeerFicheroEntrada(char *PathFicIn); bool GenerarFicheroSalida(TListaArboles optimo, char *PathFicOut); bool CalcularCercaOptima(PtrListaArboles Optimo,int rank,int size); void OrdenarArboles(); int EvaluarCombinacionListaArboles(int Combinacion); int ConvertirCombinacionToArboles(int Combinacion, PtrListaArboles CombinacionArboles); int ConvertirCombinacionToArbolesTalados(int Combinacion, PtrListaArboles CombinacionArbolesTalados); void ObtenerListaCoordenadasArboles(TListaArboles CombinacionArboles, TVectorCoordenadas Coordenadas); float CalcularLongitudCerca(TVectorCoordenadas CoordenadasCerca, int SizeCerca); float CalcularDistancia(int x1, int y1, int x2, int y2); int CalcularMaderaArbolesTalados(TListaArboles CombinacionArboles); int CalcularCosteCombinacion(TListaArboles CombinacionArboles); void MostrarArboles(TListaArboles CombinacionArboles); int main(int argc, char *argv[]) { TListaArboles Optimo; int count; int rank; //process rank int size; //number of processes double tpivot1=0,tpivot2=0,tpivot3=0; //time counting double start_time, end_time; /* for time measurement */ unsigned long len; char dest[255],outfile[255]; char *posicion; int namesrclen; struct timeval tim; MPI_Init( &argc, &argv ); //initialize MPI operations MPI_Comm_rank(MPI_COMM_WORLD, &rank); //get the rank MPI_Comm_size(MPI_COMM_WORLD, &size); //get number of processes start_time = MPI_Wtime(); gettimeofday(&tim, NULL); tpivot1 = tim.tv_sec+(tim.tv_usec/1000000.0); if (!LeerFicheroEntrada(argv[1])) { printf("Error lectura fichero entrada.\n"); exit(1); } if (!CalcularCercaOptima(&Optimo,rank,size)) { printf("Error CalcularCercaOptima.\n"); exit(1); } if(rank == 0) { end_time = MPI_Wtime(); if (argc==2) { if (!GenerarFicheroSalida(Optimo, "./Cerca.res")) { printf("Error GenerarFicheroSalida.\n"); exit(1); } } else { if (!GenerarFicheroSalida(Optimo, argv[2])) { printf("Error GenerarFicheroSalida.\n"); exit(1); } } } if(rank==0) { gettimeofday(&tim, NULL); tpivot3 = (tim.tv_sec+(tim.tv_usec/1000000.0)); printf(":%.6lf:%.6lf\n", end_time-start_time,tpivot3-tpivot1); } MPI_Finalize(); return 0; } bool LeerFicheroEntrada(char *PathFicIn) { FILE *FicIn; int a; FicIn=fopen(PathFicIn,"r"); if (FicIn==NULL) { perror("Lectura Fichero entrada."); return false; } //printf("Datos Entrada:\n"); // Leemos el nmero de arboles del bosque de entrada. if (fscanf(FicIn, "%d", &(ArbolesEntrada.NumArboles))<1) { perror("Lectura arboles entrada"); return false; } //printf("\tÁrboles: %d.\n",ArbolesEntrada.NumArboles); // Leer atributos arboles. for(a=0;a<ArbolesEntrada.NumArboles;a++) { ArbolesEntrada.Arboles[a].IdArbol=a+1; // Leer x, y, Coste, Longitud. if (fscanf(FicIn, "%d %d %d %d",&(ArbolesEntrada.Arboles[a].Coord.x), &(ArbolesEntrada.Arboles[a].Coord.y), &(ArbolesEntrada.Arboles[a].Valor), &(ArbolesEntrada.Arboles[a].Longitud))<4) { perror("Lectura datos arbol."); return false; } //printf("\tÁrbol %d-> (%d,%d) Coste:%d, Long:%d.\n",a+1,ArbolesEntrada.Arboles[a].Coord.x, ArbolesEntrada.Arboles[a].Coord.y, ArbolesEntrada.Arboles[a].Valor, ArbolesEntrada.Arboles[a].Longitud); } return true; } bool GenerarFicheroSalida(TListaArboles Optimo, char *PathFicOut) { FILE *FicOut; int a; FicOut=fopen(PathFicOut,"w+"); if (FicOut==NULL) { perror("Escritura fichero salida."); return false; } // Escribir arboles a talartalado. // Escribimos nmero de arboles a talar. if (fprintf(FicOut, "Cortar %d árbol/es: ", Optimo.NumArboles)<1) { perror("Escribir nmero de arboles a talar"); return false; } for(a=0;a<Optimo.NumArboles;a++) { // Escribir nmero arbol. if (fprintf(FicOut, "%d ",ArbolesEntrada.Arboles[Optimo.Arboles[a]].IdArbol)<1) { perror("Escritura nmero �bol."); return false; } } // Escribimos coste arboles a talar. if (fprintf(FicOut, "\nMadera Sobrante: \t%4.2f (%4.2f)", Optimo.MaderaSobrante, Optimo.LongitudCerca)<1) { perror("Escribir coste arboles a talar."); return false; } // Escribimos coste arboles a talar. if (fprintf(FicOut, "\nValor árboles cortados: \t%4.2f.", Optimo.CosteArbolesCortados)<1) { perror("Escribir coste arboles a talar."); return false; } // Escribimos coste arboles a talar. if (fprintf(FicOut, "\nValor árboles restantes: \t%4.2f\n", Optimo.CosteArbolesRestantes)<1) { perror("Escribir coste arboles a talar."); return false; } return true; } bool CalcularCercaOptima(PtrListaArboles Optimo,int rank, int size) { int MaxCombinaciones; int portion, i; int Combinacion, MejorCombinacion=0, CosteMejorCombinacion; int Coste; TListaArboles CombinacionArboles; TVectorCoordenadas CoordArboles, CercaArboles; int NumArboles, PuntosCerca; float MaderaArbolesTalados; if(rank==0) { /* Total Combinations */ MaxCombinaciones = (int) pow(2.0,ArbolesEntrada.NumArboles); for (i = 1; i < size; i++) { portion = (MaxCombinaciones / (size - 1)); // calculate portion without master low_bound = (i - 1) * portion +1; if (((i + 1) == size) && ((MaxCombinaciones % (size - 1)) != 0)) {//if rows of [A] cannot be equally divided among slaves upper_bound = MaxCombinaciones; //last slave gets all the remaining rows } else { upper_bound = low_bound + portion; //rows of [A] are equally divisable among slaves } //send the low bound first without blocking, to the intended slave MPI_Send(&low_bound, 1, MPI_INT, i, MASTER_TO_SLAVE_TAG, MPI_COMM_WORLD); //next send the upper bound without blocking, to the intended slave MPI_Send(&upper_bound, 1, MPI_INT, i, MASTER_TO_SLAVE_TAG + 1, MPI_COMM_WORLD); } } // Ordenar Arboles por segun coordenadas crecientes de x,y OrdenarArboles(); Optimo->NumArboles = 0; Optimo->Coste = DMaximoCoste; if (rank > 0) { //receive low bound from the master MPI_Recv(&low_bound, 1, MPI_INT, 0, MASTER_TO_SLAVE_TAG, MPI_COMM_WORLD, &status); //next receive upper bound from the master MPI_Recv(&upper_bound, 1, MPI_INT, 0, MASTER_TO_SLAVE_TAG + 1, MPI_COMM_WORLD, &status); //printf("Evaluacin Combinaciones posibles: \n"); CosteMejorCombinacion = Optimo->Coste; //#pragma omp parallel for private(Coste) //{ for (Combinacion=low_bound; Combinacion<upper_bound; Combinacion++) { //printf("\tC%d -> \t",Combinacion); Coste = EvaluarCombinacionListaArboles(Combinacion); //#pragma omp critical //{ if ( Coste < CosteMejorCombinacion ) { CosteMejorCombinacion = Coste; MejorCombinacion = Combinacion; //printf("***"); } //} //printf("\n"); } //} //printf("\Rank : %d\n",rank); } int *sub_Coste = NULL; int *sub_Combinacion = NULL; if (rank == 0) { sub_Coste = (int *)malloc(sizeof(int) * size); sub_Combinacion= (int *)malloc(sizeof(int) * size); assert(sub_Coste != NULL); assert(sub_Combinacion != NULL); } // Get the total best combination cost MPI_Gather(&CosteMejorCombinacion, 1, MPI_INT, sub_Coste, 1, MPI_FLOAT, 0, MPI_COMM_WORLD); //Get the Bets Combination cicle MPI_Gather(&MejorCombinacion, 1, MPI_INT, sub_Combinacion, 1, MPI_FLOAT, 0, MPI_COMM_WORLD); // Now that we have all of the partial results on the root, compute the bets cost of all if(rank == 0) { CosteMejorCombinacion = Optimo->Coste; Combinacion = 0; for (i = 1; i < size - 1; i++) { if ( sub_Coste[i] < CosteMejorCombinacion ) { CosteMejorCombinacion = sub_Coste[i]; MejorCombinacion = sub_Combinacion[i]; } } if (CosteMejorCombinacion == Optimo->Coste) return false; // No se ha encontrado una combinacin mejor. // Asignar combinacin encontrada. ConvertirCombinacionToArbolesTalados(MejorCombinacion, Optimo); Optimo->Coste = CosteMejorCombinacion; // Calcular estadisticas óptimo. NumArboles = ConvertirCombinacionToArboles(MejorCombinacion, &CombinacionArboles); ObtenerListaCoordenadasArboles(CombinacionArboles, CoordArboles); PuntosCerca = chainHull_2D( CoordArboles, NumArboles, CercaArboles ); Optimo->LongitudCerca = CalcularLongitudCerca(CercaArboles, PuntosCerca); MaderaArbolesTalados = CalcularMaderaArbolesTalados(*Optimo); Optimo->MaderaSobrante = MaderaArbolesTalados - Optimo->LongitudCerca; Optimo->CosteArbolesCortados = CosteMejorCombinacion; Optimo->CosteArbolesRestantes = CalcularCosteCombinacion(CombinacionArboles); printf("%ld:%ld", ArbolesEntrada.NumArboles, CosteMejorCombinacion); } return true; } void OrdenarArboles() { int a,b; for(a=0; a<(ArbolesEntrada.NumArboles-1); a++) { for(b=a; b<ArbolesEntrada.NumArboles; b++) { if ( ArbolesEntrada.Arboles[b].Coord.x < ArbolesEntrada.Arboles[a].Coord.x || (ArbolesEntrada.Arboles[b].Coord.x == ArbolesEntrada.Arboles[a].Coord.x && ArbolesEntrada.Arboles[b].Coord.y < ArbolesEntrada.Arboles[a].Coord.y) ) { TArbol aux; // aux=a aux.Coord.x = ArbolesEntrada.Arboles[a].Coord.x; aux.Coord.y = ArbolesEntrada.Arboles[a].Coord.y; aux.IdArbol = ArbolesEntrada.Arboles[a].IdArbol; aux.Valor = ArbolesEntrada.Arboles[a].Valor; aux.Longitud = ArbolesEntrada.Arboles[a].Longitud; // a=b ArbolesEntrada.Arboles[a].Coord.x = ArbolesEntrada.Arboles[b].Coord.x; ArbolesEntrada.Arboles[a].Coord.y = ArbolesEntrada.Arboles[b].Coord.y; ArbolesEntrada.Arboles[a].IdArbol = ArbolesEntrada.Arboles[b].IdArbol; ArbolesEntrada.Arboles[a].Valor = ArbolesEntrada.Arboles[b].Valor; ArbolesEntrada.Arboles[a].Longitud = ArbolesEntrada.Arboles[b].Longitud; // b=aux ArbolesEntrada.Arboles[b].Coord.x = aux.Coord.x; ArbolesEntrada.Arboles[b].Coord.y = aux.Coord.y; ArbolesEntrada.Arboles[b].IdArbol = aux.IdArbol; ArbolesEntrada.Arboles[b].Valor = aux.Valor; ArbolesEntrada.Arboles[b].Longitud = aux.Longitud; } } } } // Calcula la combinacin ptima entre el rango de combinaciones PrimeraCombinacion-UltimaCombinacion. int EvaluarCombinacionListaArboles(int Combinacion) { TVectorCoordenadas CoordArboles, CercaArboles; TListaArboles CombinacionArboles, CombinacionArbolesTalados; int NumArboles, NumArbolesTalados, PuntosCerca, CosteCombinacion; float LongitudCerca, MaderaArbolesTalados; // Convertimos la combinacin al vector de arboles no talados. NumArboles = ConvertirCombinacionToArboles(Combinacion, &CombinacionArboles); // Obtener el vector de coordenadas de arboles no talados. ObtenerListaCoordenadasArboles(CombinacionArboles, CoordArboles); // Calcular la cerca PuntosCerca = chainHull_2D( CoordArboles, NumArboles, CercaArboles ); /* Evaluar si obtenemos suficientes �boles para construir la cerca */ LongitudCerca = CalcularLongitudCerca(CercaArboles, PuntosCerca); // Evaluar la madera obtenida mediante los arboles talados. // Convertimos la combinacin al vector de arboles no talados. NumArbolesTalados = ConvertirCombinacionToArbolesTalados(Combinacion, &CombinacionArbolesTalados); //printf(" %d arboles cortados: ",NumArbolesTalados); //MostrarArboles(CombinacionArbolesTalados); MaderaArbolesTalados = CalcularMaderaArbolesTalados(CombinacionArbolesTalados); //printf(" Madera:%4.2f \tCerca:%4.2f ",MaderaArbolesTalados, LongitudCerca); if (LongitudCerca > MaderaArbolesTalados) { // Los arboles cortados no tienen suficiente madera para construir la cerca. //printf("\tCoste:%d",DMaximoCoste); return DMaximoCoste; } // Evaluar el coste de los arboles talados. CosteCombinacion = CalcularCosteCombinacion(CombinacionArbolesTalados); //printf("\tCoste:%d",CosteCombinacion); return CosteCombinacion; } int ConvertirCombinacionToArboles(int Combinacion, PtrListaArboles CombinacionArboles) { int arbol=0; CombinacionArboles->NumArboles=0; CombinacionArboles->Coste=0; while (arbol<ArbolesEntrada.NumArboles) { if ((Combinacion%2)==0) { CombinacionArboles->Arboles[CombinacionArboles->NumArboles]=arbol; CombinacionArboles->NumArboles++; CombinacionArboles->Coste+= ArbolesEntrada.Arboles[arbol].Valor; } arbol++; Combinacion = Combinacion>>1; } return CombinacionArboles->NumArboles; } int ConvertirCombinacionToArbolesTalados(int Combinacion, PtrListaArboles CombinacionArbolesTalados) { int arbol=0; CombinacionArbolesTalados->NumArboles=0; CombinacionArbolesTalados->Coste=0; while (arbol<ArbolesEntrada.NumArboles) { if ((Combinacion%2)==1) { CombinacionArbolesTalados->Arboles[CombinacionArbolesTalados->NumArboles]=arbol; CombinacionArbolesTalados->NumArboles++; CombinacionArbolesTalados->Coste+= ArbolesEntrada.Arboles[arbol].Valor; } arbol++; Combinacion = Combinacion>>1; } return CombinacionArbolesTalados->NumArboles; } void ObtenerListaCoordenadasArboles(TListaArboles CombinacionArboles, TVectorCoordenadas Coordenadas) { int c, arbol; for (c=0;c<CombinacionArboles.NumArboles;c++) { arbol=CombinacionArboles.Arboles[c]; Coordenadas[c].x = ArbolesEntrada.Arboles[arbol].Coord.x; Coordenadas[c].y = ArbolesEntrada.Arboles[arbol].Coord.y; } } float CalcularLongitudCerca(TVectorCoordenadas CoordenadasCerca, int SizeCerca) { int x; float coste = 0; for (x=0;x<(SizeCerca-1);x++) { coste+= CalcularDistancia(CoordenadasCerca[x].x, CoordenadasCerca[x].y, CoordenadasCerca[x+1].x, CoordenadasCerca[x+1].y); } return coste; } float CalcularDistancia(int x1, int y1, int x2, int y2) { return(sqrt(pow((double)abs(x2-x1),2.0)+pow((double)abs(y2-y1),2.0))); } int CalcularMaderaArbolesTalados(TListaArboles CombinacionArboles) { int a; int LongitudTotal=0; for (a=0;a<CombinacionArboles.NumArboles;a++) { LongitudTotal += ArbolesEntrada.Arboles[CombinacionArboles.Arboles[a]].Longitud; } return(LongitudTotal); } int CalcularCosteCombinacion(TListaArboles CombinacionArboles) { int a; int CosteTotal=0; for (a=0;a<CombinacionArboles.NumArboles;a++) { CosteTotal += ArbolesEntrada.Arboles[CombinacionArboles.Arboles[a]].Valor; } return(CosteTotal); } void MostrarArboles(TListaArboles CombinacionArboles) { int a; for (a=0;a<CombinacionArboles.NumArboles;a++) printf("%d ",ArbolesEntrada.Arboles[CombinacionArboles.Arboles[a]].IdArbol); for (;a<ArbolesEntrada.NumArboles;a++) printf(" "); }
[ "maicolmeusburger@gmail.com" ]
maicolmeusburger@gmail.com
def5b2266c77f0fc16b04f1a269d3ada93482fe1
568dacff28f38f4ce8dd3d11ab256ee2409b4a2e
/common/socketdata.h
8d9ad4cbf1645e37f49e04964bd06a18c2bf6a87
[ "LicenseRef-scancode-openssl", "MIT", "BSD-3-Clause" ]
permissive
tripzero/hdcp
f1092467d6f86a404b636b1c01aee8c1da19cbeb
1f77c2019bfc499bc5f9cfd387eafddd148f2e6c
refs/heads/master
2020-04-04T05:19:40.994509
2018-11-01T16:14:49
2018-11-01T16:19:48
155,741,861
0
0
NOASSERTION
2018-11-01T16:13:32
2018-11-01T16:13:32
null
UTF-8
C++
false
false
2,873
h
/* * Copyright (c) 2009-2018, Intel Corporation * * 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. */ //! //! \file socketdata.h //! \brief //! #ifndef __HDCP_SOCKETDATA_H__ #define __HDCP_SOCKETDATA_H__ #include "hdcpdef.h" #include "hdcpapi.h" #define ONE_PORT 1 #define MAX_LISTENER_SOCKET_PATH 64 // socket file used by SDK and daemon #define HDCP_DIR_BASE "/var/run/hdcp/" #define HDCP_DIR_BASE_PERMISSIONS (S_IRWXU | S_IRWXG | S_IRWXO) #define HDCP_SDK_SOCKET_PATH HDCP_DIR_BASE ".sdk_socket" typedef enum _HDCP_API_TYPE { HDCP_API_INVALID, HDCP_API_CREATE, HDCP_API_DESTROY, HDCP_API_ENUMERATE_HDCP_DISPLAY, HDCP_API_SENDSRMDATA, HDCP_API_GETSRMVERSION, HDCP_API_ENABLE, HDCP_API_DISABLE, HDCP_API_GETSTATUS, HDCP_API_GETKSVLIST, HDCP_API_REPORTSTATUS, HDCP_API_TERM_MSG_LOOP, HDCP_API_CREATE_CALLBACK, HDCP_API_SET_PROTECTION_LEVEL, HDCP_API_CONFIG, HDCP_API_ILLEGAL } HDCP_API_TYPE; struct SocketData { public: SocketData(void); ~SocketData(void); union { uint8_t Bytes; struct { uint32_t Size; HDCP_API_TYPE Command; HDCP_STATUS Status; uint8_t KsvCount; // Number of KSV in topology uint8_t Depth; // Depth of topology bool isType1Capable; // Port whether support HDCP2.2 union { Port Ports[NUM_PHYSICAL_PORTS_MAX]; Port SinglePort; }; uint32_t PortCount; uint32_t SrmOrKsvListDataSz; uint16_t SrmVersion; HDCP_CONFIG Config; uint8_t Level; }; }; }; #endif // __HDCP_SOCKETDATA_H__
[ "shqiang.yu@intel.com" ]
shqiang.yu@intel.com
ca0921764ab69c617801f09ad87a1584fa9d58d8
01370e1d6d628834d00d74d6c27556ff39320410
/VirtualBox-5.0.12-Thinputer/src/VBox/Runtime/common/string/strcache.cpp
c3317c4b4316e2c0e101f4a146fb7b35fe5b15ca
[]
no_license
stonezk/Thinputer3D_ReadBack
13ca19c0cfc05af88082321dfc524240961dca7f
09418b420e82bb7eb6ce76e066145fcf240aaec9
refs/heads/master
2021-07-14T05:31:01.057984
2017-10-13T01:26:15
2017-10-13T01:26:15
104,833,018
2
0
null
null
null
null
UTF-8
C++
false
false
42,826
cpp
/* $Id: strcache.cpp $ */ /** @file * IPRT - String Cache. */ /* * Copyright (C) 2009-2015 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * The contents of this file may alternatively be used under the terms * of the Common Development and Distribution License Version 1.0 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the * VirtualBox OSE distribution, in which case the provisions of the * CDDL are applicable instead of those of the GPL. * * You may elect to license modified versions of this file under the * terms and conditions of either the GPL or the CDDL or both. */ /********************************************************************************************************************************* * Header Files * *********************************************************************************************************************************/ #include <iprt/strcache.h> #include "internal/iprt.h" #include <iprt/alloca.h> #include <iprt/asm.h> #include <iprt/assert.h> #include <iprt/critsect.h> #include <iprt/err.h> #include <iprt/list.h> #include <iprt/mem.h> #include <iprt/once.h> #include <iprt/param.h> #include <iprt/string.h> #include "internal/strhash.h" #include "internal/magics.h" /********************************************************************************************************************************* * Defined Constants And Macros * *********************************************************************************************************************************/ /** Special NIL pointer for the hash table. It differs from NULL in that it is * a valid hash table entry when doing a lookup. */ #define PRTSTRCACHEENTRY_NIL ((PRTSTRCACHEENTRY)~(uintptr_t)1) /** Calcuates the increment when handling a collision. * The current formula makes sure it's always odd so we cannot possibly end * up a cyclic loop with an even sized table. It also takes more bits from * the length part. */ #define RTSTRCACHE_COLLISION_INCR(uHashLen) ( ((uHashLen >> 8) | 1) ) /** The initial hash table size. Must be power of two. */ #define RTSTRCACHE_INITIAL_HASH_SIZE 512 /** The hash table growth factor. */ #define RTSTRCACHE_HASH_GROW_FACTOR 4 /** * The RTSTRCACHEENTRY size threshold at which we stop using our own allocator * and switch to the application heap, expressed as a power of two. * * Using a 1KB as a reasonable limit here. */ #ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR # define RTSTRCACHE_HEAP_THRESHOLD_BIT 10 #else # define RTSTRCACHE_HEAP_THRESHOLD_BIT 9 #endif /** The RTSTRCACHE_HEAP_THRESHOLD_BIT as a byte limit. */ #define RTSTRCACHE_HEAP_THRESHOLD RT_BIT_32(RTSTRCACHE_HEAP_THRESHOLD_BIT) /** Big (heap) entry size alignment. */ #define RTSTRCACHE_HEAP_ENTRY_SIZE_ALIGN 16 #ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR /** * The RTSTRCACHEENTRY size threshold at which we start using the merge free * list for allocations, expressed as a power of two. */ # define RTSTRCACHE_MERGED_THRESHOLD_BIT 6 /** The number of bytes (power of two) that the merged allocation lists should * be grown by. Must be much greater than RTSTRCACHE_MERGED_THRESHOLD. */ # define RTSTRCACHE_MERGED_GROW_SIZE _32K #endif /** The number of bytes (power of two) that the fixed allocation lists should * be grown by. */ #define RTSTRCACHE_FIXED_GROW_SIZE _32K /** The number of fixed sized lists. */ #define RTSTRCACHE_NUM_OF_FIXED_SIZES 12 /** Validates a string cache handle, translating RTSTRCACHE_DEFAULT when found, * and returns rc if not valid. */ #define RTSTRCACHE_VALID_RETURN_RC(pStrCache, rc) \ do { \ if ((pStrCache) == RTSTRCACHE_DEFAULT) \ { \ int rcOnce = RTOnce(&g_rtStrCacheOnce, rtStrCacheInitDefault, NULL); \ if (RT_FAILURE(rcOnce)) \ return (rc); \ (pStrCache) = g_hrtStrCacheDefault; \ } \ else \ { \ AssertPtrReturn((pStrCache), (rc)); \ AssertReturn((pStrCache)->u32Magic == RTSTRCACHE_MAGIC, (rc)); \ } \ } while (0) /********************************************************************************************************************************* * Structures and Typedefs * *********************************************************************************************************************************/ /** * String cache entry. */ typedef struct RTSTRCACHEENTRY { /** The number of references. */ uint32_t volatile cRefs; /** The lower 16-bit hash value. */ uint16_t uHash; /** The string length (excluding the terminator). * If this is set to RTSTRCACHEENTRY_BIG_LEN, this is a BIG entry * (RTSTRCACHEBIGENTRY). */ uint16_t cchString; /** The string. */ char szString[8]; } RTSTRCACHEENTRY; AssertCompileSize(RTSTRCACHEENTRY, 16); /** Pointer to a string cache entry. */ typedef RTSTRCACHEENTRY *PRTSTRCACHEENTRY; /** Pointer to a const string cache entry. */ typedef RTSTRCACHEENTRY *PCRTSTRCACHEENTRY; /** RTSTCACHEENTRY::cchString value for big cache entries. */ #define RTSTRCACHEENTRY_BIG_LEN UINT16_MAX /** * Big string cache entry. * * These are allocated individually from the application heap. */ typedef struct RTSTRCACHEBIGENTRY { /** List entry. */ RTLISTNODE ListEntry; /** The string length. */ uint32_t cchString; /** The full hash value / padding. */ uint32_t uHash; /** The core entry. */ RTSTRCACHEENTRY Core; } RTSTRCACHEBIGENTRY; AssertCompileSize(RTSTRCACHEENTRY, 16); /** Pointer to a big string cache entry. */ typedef RTSTRCACHEBIGENTRY *PRTSTRCACHEBIGENTRY; /** Pointer to a const big string cache entry. */ typedef RTSTRCACHEBIGENTRY *PCRTSTRCACHEBIGENTRY; /** * A free string cache entry. */ typedef struct RTSTRCACHEFREE { /** Zero value indicating that it's a free entry (no refs, no hash). */ uint32_t uZero; /** Number of free bytes. Only used for > 32 byte allocations. */ uint32_t cbFree; /** Pointer to the next free item. */ struct RTSTRCACHEFREE *pNext; } RTSTRCACHEFREE; AssertCompileSize(RTSTRCACHEENTRY, 16); AssertCompileMembersAtSameOffset(RTSTRCACHEENTRY, cRefs, RTSTRCACHEFREE, uZero); AssertCompileMembersAtSameOffset(RTSTRCACHEENTRY, szString, RTSTRCACHEFREE, pNext); /** Pointer to a free string cache entry. */ typedef RTSTRCACHEFREE *PRTSTRCACHEFREE; #ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR /** * A free string cache entry with merging. * * This differs from RTSTRCACHEFREE only in having a back pointer for more * efficient list management (doubly vs. singly linked lists). */ typedef struct RTSTRCACHEFREEMERGE { /** Marker that indicates what kind of entry this is, either . */ uint32_t uMarker; /** Number of free bytes. Only used for > 32 byte allocations. */ uint32_t cbFree; /** Pointer to the main node. NULL for main nodes. */ struct RTSTRCACHEFREEMERGE *pMain; /** The free list entry. */ RTLISTNODE ListEntry; /** Pads the size up to the minimum allocation unit for the merge list. * This both defines the minimum allocation unit and simplifies pointer * manipulation during merging and splitting. */ uint8_t abPadding[ARCH_BITS == 32 ? 44 : 32]; } RTSTRCACHEFREEMERGE; AssertCompileSize(RTSTRCACHEFREEMERGE, RT_BIT_32(RTSTRCACHE_MERGED_THRESHOLD_BIT)); /** Pointer to a free cache string in the merge list. */ typedef RTSTRCACHEFREEMERGE *PRTSTRCACHEFREEMERGE; /** RTSTRCACHEFREEMERGE::uMarker value indicating that it's the real free chunk * header. Must be something that's invalid UTF-8 for both little and big * endian system. */ # define RTSTRCACHEFREEMERGE_MAIN UINT32_C(0xfffffff1) /** RTSTRCACHEFREEMERGE::uMarker value indicating that it's part of a larger * chunk of free memory. Must be something that's invalid UTF-8 for both little * and big endian system. */ # define RTSTRCACHEFREEMERGE_PART UINT32_C(0xfffffff2) #endif /* RTSTRCACHE_WITH_MERGED_ALLOCATOR */ /** * Tracking structure chunk of memory used by the 16 byte or 32 byte * allocations. * * This occupies the first entry in the chunk. */ typedef struct RTSTRCACHECHUNK { /** The size of the chunk. */ size_t cb; /** Pointer to the next chunk. */ struct RTSTRCACHECHUNK *pNext; } RTSTRCACHECHUNK; AssertCompile(sizeof(RTSTRCACHECHUNK) <= sizeof(RTSTRCACHEENTRY)); /** Pointer to the chunk tracking structure. */ typedef RTSTRCACHECHUNK *PRTSTRCACHECHUNK; /** * Cache instance data. */ typedef struct RTSTRCACHEINT { /** The string cache magic (RTSTRCACHE_MAGIC). */ uint32_t u32Magic; /** Ref counter for the cache handle. */ uint32_t volatile cRefs; /** The number of strings currently entered in the cache. */ uint32_t cStrings; /** The size of the hash table. */ uint32_t cHashTab; /** Pointer to the hash table. */ PRTSTRCACHEENTRY *papHashTab; /** Free list for allocations of the sizes defined by g_acbFixedLists. */ PRTSTRCACHEFREE apFreeLists[RTSTRCACHE_NUM_OF_FIXED_SIZES]; #ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR /** Free lists based on */ RTLISTANCHOR aMergedFreeLists[RTSTRCACHE_HEAP_THRESHOLD_BIT - RTSTRCACHE_MERGED_THRESHOLD_BIT + 1]; #endif /** List of allocated memory chunks. */ PRTSTRCACHECHUNK pChunkList; /** List of big cache entries. */ RTLISTANCHOR BigEntryList; /** @name Statistics * @{ */ /** The total size of all chunks. */ size_t cbChunks; /** The total length of all the strings, terminators included. */ size_t cbStrings; /** The total size of all the big entries. */ size_t cbBigEntries; /** Hash collisions. */ uint32_t cHashCollisions; /** Secondary hash collisions. */ uint32_t cHashCollisions2; /** The number of inserts to compare cHashCollisions to. */ uint32_t cHashInserts; /** The number of rehashes. */ uint32_t cRehashes; /** @} */ /** Critical section protecting the cache structures. */ RTCRITSECT CritSect; } RTSTRCACHEINT; /** Pointer to a cache instance. */ typedef RTSTRCACHEINT *PRTSTRCACHEINT; /********************************************************************************************************************************* * Global Variables * *********************************************************************************************************************************/ /** The entry sizes of the fixed lists (RTSTRCACHEINT::apFreeLists). */ static const uint32_t g_acbFixedLists[RTSTRCACHE_NUM_OF_FIXED_SIZES] = { 16, 32, 48, 64, 96, 128, 192, 256, 320, 384, 448, 512 }; /** Init once for the default string cache. */ static RTONCE g_rtStrCacheOnce = RTONCE_INITIALIZER; /** The default string cache. */ static RTSTRCACHE g_hrtStrCacheDefault = NIL_RTSTRCACHE; /** @callback_method_impl{FNRTONCE, Initializes g_hrtStrCacheDefault} */ static DECLCALLBACK(int) rtStrCacheInitDefault(void *pvUser) { NOREF(pvUser); return RTStrCacheCreate(&g_hrtStrCacheDefault, "Default"); } RTDECL(int) RTStrCacheCreate(PRTSTRCACHE phStrCache, const char *pszName) { int rc = VERR_NO_MEMORY; PRTSTRCACHEINT pThis = (PRTSTRCACHEINT)RTMemAllocZ(sizeof(*pThis)); if (pThis) { pThis->cHashTab = RTSTRCACHE_INITIAL_HASH_SIZE; pThis->papHashTab = (PRTSTRCACHEENTRY*)RTMemAllocZ(sizeof(pThis->papHashTab[0]) * pThis->cHashTab); if (pThis->papHashTab) { rc = RTCritSectInit(&pThis->CritSect); if (RT_SUCCESS(rc)) { RTListInit(&pThis->BigEntryList); #ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aMergedFreeLists); i++) RTListInit(&pThis->aMergedFreeLists[i]); #endif pThis->cRefs = 1; pThis->u32Magic = RTSTRCACHE_MAGIC; *phStrCache = pThis; return VINF_SUCCESS; } RTMemFree(pThis->papHashTab); } RTMemFree(pThis); } return rc; } RT_EXPORT_SYMBOL(RTStrCacheCreate); RTDECL(int) RTStrCacheDestroy(RTSTRCACHE hStrCache) { if ( hStrCache == NIL_RTSTRCACHE || hStrCache == RTSTRCACHE_DEFAULT) return VINF_SUCCESS; PRTSTRCACHEINT pThis = hStrCache; RTSTRCACHE_VALID_RETURN_RC(pThis, VERR_INVALID_HANDLE); /* * Invalidate it. Enter the crit sect just to be on the safe side. */ AssertReturn(ASMAtomicCmpXchgU32(&pThis->u32Magic, RTSTRCACHE_MAGIC_DEAD, RTSTRCACHE_MAGIC), VERR_INVALID_HANDLE); RTCritSectEnter(&pThis->CritSect); Assert(pThis->cRefs == 1); PRTSTRCACHECHUNK pChunk; while ((pChunk = pThis->pChunkList) != NULL) { pThis->pChunkList = pChunk->pNext; RTMemPageFree(pChunk, pChunk->cb); } RTMemFree(pThis->papHashTab); pThis->papHashTab = NULL; pThis->cHashTab = 0; PRTSTRCACHEBIGENTRY pCur, pNext; RTListForEachSafe(&pThis->BigEntryList, pCur, pNext, RTSTRCACHEBIGENTRY, ListEntry) { RTMemFree(pCur); } RTCritSectLeave(&pThis->CritSect); RTCritSectDelete(&pThis->CritSect); RTMemFree(pThis); return VINF_SUCCESS; } RT_EXPORT_SYMBOL(RTStrCacheDestroy); /** * Selects the fixed free list index for a given minimum entry size. * * @returns Free list index. * @param cbMin Minimum entry size. */ DECLINLINE(uint32_t) rtStrCacheSelectFixedList(uint32_t cbMin) { Assert(cbMin <= g_acbFixedLists[RT_ELEMENTS(g_acbFixedLists) - 1]); unsigned i = 0; while (cbMin > g_acbFixedLists[i]) i++; return i; } #ifdef RT_STRICT # define RTSTRCACHE_CHECK(a_pThis) do { rtStrCacheCheck(pThis); } while (0) /** * Internal cache check. */ static void rtStrCacheCheck(PRTSTRCACHEINT pThis) { # ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aMergedFreeLists); i++) { PRTSTRCACHEFREEMERGE pFree; RTListForEach(&pThis->aMergedFreeLists[i], pFree, RTSTRCACHEFREEMERGE, ListEntry) { Assert(pFree->uMarker == RTSTRCACHEFREEMERGE_MAIN); Assert(pFree->cbFree > 0); Assert(RT_ALIGN_32(pFree->cbFree, sizeof(*pFree)) == pFree->cbFree); } } # endif } #else # define RTSTRCACHE_CHECK(a_pThis) do { } while (0) #endif /** * Finds the first empty hash table entry given a hash+length value. * * ASSUMES that the hash table isn't full. * * @returns Hash table index. * @param pThis The string cache instance. * @param uHashLen The hash + length (not RTSTRCACHEENTRY_BIG_LEN). */ static uint32_t rtStrCacheFindEmptyHashTabEntry(PRTSTRCACHEINT pThis, uint32_t uHashLen) { uint32_t iHash = uHashLen % pThis->cHashTab; for (;;) { PRTSTRCACHEENTRY pEntry = pThis->papHashTab[iHash]; if (pEntry == NULL || pEntry == PRTSTRCACHEENTRY_NIL) return iHash; /* Advance. */ iHash += RTSTRCACHE_COLLISION_INCR(uHashLen); iHash %= pThis->cHashTab; } } /** * Grows the hash table. * * @returns vINF_SUCCESS or VERR_NO_MEMORY. * @param pThis The string cache instance. */ static int rtStrCacheGrowHashTab(PRTSTRCACHEINT pThis) { /* * Allocate a new hash table two times the size of the old one. */ uint32_t cNew = pThis->cHashTab * RTSTRCACHE_HASH_GROW_FACTOR; PRTSTRCACHEENTRY *papNew = (PRTSTRCACHEENTRY *)RTMemAllocZ(sizeof(papNew[0]) * cNew); if (papNew == NULL) return VERR_NO_MEMORY; /* * Install the new table and move the items from the old table and into the new one. */ PRTSTRCACHEENTRY *papOld = pThis->papHashTab; uint32_t iOld = pThis->cHashTab; pThis->papHashTab = papNew; pThis->cHashTab = cNew; pThis->cRehashes++; while (iOld-- > 0) { PRTSTRCACHEENTRY pEntry = papOld[iOld]; if (pEntry != NULL && pEntry != PRTSTRCACHEENTRY_NIL) { uint32_t cchString = pEntry->cchString; if (cchString == RTSTRCACHEENTRY_BIG_LEN) cchString = RT_FROM_MEMBER(pEntry, RTSTRCACHEBIGENTRY, Core)->cchString; uint32_t iHash = rtStrCacheFindEmptyHashTabEntry(pThis, RT_MAKE_U32(pEntry->uHash, cchString)); pThis->papHashTab[iHash] = pEntry; } } /* * Free the old hash table. */ RTMemFree(papOld); return VINF_SUCCESS; } #ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR /** * Link/Relink into the free right list. * * @param pThis The string cache instance. * @param pFree The free string entry. */ static void rtStrCacheRelinkMerged(PRTSTRCACHEINT pThis, PRTSTRCACHEFREEMERGE pFree) { Assert(pFree->uMarker == RTSTRCACHEFREEMERGE_MAIN); Assert(pFree->cbFree > 0); Assert(RT_ALIGN_32(pFree->cbFree, sizeof(*pFree)) == pFree->cbFree); if (!RTListIsEmpty(&pFree->ListEntry)) RTListNodeRemove(&pFree->ListEntry); uint32_t iList = (ASMBitLastSetU32(pFree->cbFree) - 1) - RTSTRCACHE_MERGED_THRESHOLD_BIT; if (iList >= RT_ELEMENTS(pThis->aMergedFreeLists)) iList = RT_ELEMENTS(pThis->aMergedFreeLists) - 1; RTListPrepend(&pThis->aMergedFreeLists[iList], &pFree->ListEntry); } /** * Allocate a cache entry from the merged free lists. * * @returns Pointer to the cache entry on success, NULL on allocation error. * @param pThis The string cache instance. * @param uHash The full hash of the string. * @param pchString The string. * @param cchString The string length. * @param cbEntry The required entry size. */ static PRTSTRCACHEENTRY rtStrCacheAllocMergedEntry(PRTSTRCACHEINT pThis, uint32_t uHash, const char *pchString, uint32_t cchString, uint32_t cbEntry) { cbEntry = RT_ALIGN_32(cbEntry, sizeof(RTSTRCACHEFREEMERGE)); Assert(cbEntry > cchString); /* * Search the list heads first. */ PRTSTRCACHEFREEMERGE pFree = NULL; uint32_t iList = ASMBitLastSetU32(cbEntry) - 1; if (!RT_IS_POWER_OF_TWO(cbEntry)) iList++; iList -= RTSTRCACHE_MERGED_THRESHOLD_BIT; while (iList < RT_ELEMENTS(pThis->aMergedFreeLists)) { pFree = RTListGetFirst(&pThis->aMergedFreeLists[iList], RTSTRCACHEFREEMERGE, ListEntry); if (pFree) { /* * Found something. Should we we split it? We split from the end * to avoid having to update all the sub entries. */ Assert(pFree->uMarker == RTSTRCACHEFREEMERGE_MAIN); Assert(pFree->cbFree >= cbEntry); Assert(RT_ALIGN_32(pFree->cbFree, sizeof(*pFree)) == pFree->cbFree); if (pFree->cbFree == cbEntry) RTListNodeRemove(&pFree->ListEntry); else { uint32_t cRemainder = (pFree->cbFree - cbEntry) / sizeof(*pFree); PRTSTRCACHEFREEMERGE pRemainder = pFree; pFree += cRemainder; Assert((pRemainder->cbFree - cbEntry) == cRemainder * sizeof(*pFree)); pRemainder->cbFree = cRemainder * sizeof(*pFree); rtStrCacheRelinkMerged(pThis, pRemainder); } break; } iList++; } if (!pFree) { /* * Allocate a new block. (We could search the list below in some * cases, but it's too much effort to write and execute). */ size_t const cbChunk = RTSTRCACHE_MERGED_GROW_SIZE; AssertReturn(cbChunk > cbEntry * 2, NULL); PRTSTRCACHECHUNK pChunk = (PRTSTRCACHECHUNK)RTMemPageAlloc(cbChunk); if (!pChunk) return NULL; pChunk->cb = cbChunk; pChunk->pNext = pThis->pChunkList; pThis->pChunkList = pChunk; pThis->cbChunks += cbChunk; AssertCompile(sizeof(*pChunk) <= sizeof(*pFree)); /* * Get one node for the allocation at hand. */ pFree = (PRTSTRCACHEFREEMERGE)((uintptr_t)pChunk + sizeof(*pFree)); /* * Create a free block out of the remainder (always a reminder). */ PRTSTRCACHEFREEMERGE pNewFree = (PRTSTRCACHEFREEMERGE)((uintptr_t)pFree + cbEntry); pNewFree->uMarker = RTSTRCACHEFREEMERGE_MAIN; pNewFree->cbFree = cbChunk - sizeof(*pNewFree) - cbEntry; Assert(pNewFree->cbFree < cbChunk && pNewFree->cbFree > 0); pNewFree->pMain = NULL; RTListInit(&pNewFree->ListEntry); uint32_t iInternalBlock = pNewFree->cbFree / sizeof(*pNewFree); while (iInternalBlock-- > 1) { pNewFree[iInternalBlock].uMarker = RTSTRCACHEFREEMERGE_PART; pNewFree[iInternalBlock].cbFree = 0; pNewFree[iInternalBlock].pMain = pNewFree; } rtStrCacheRelinkMerged(pThis, pNewFree); } /* * Initialize the entry. We zero all bytes we don't use so they cannot * accidentally be mistaken for a free entry. */ ASMCompilerBarrier(); PRTSTRCACHEENTRY pEntry = (PRTSTRCACHEENTRY)pFree; pEntry->cRefs = 1; pEntry->uHash = (uint16_t)uHash; pEntry->cchString = (uint16_t)cchString; memcpy(pEntry->szString, pchString, cchString); RT_BZERO(&pEntry->szString[cchString], cbEntry - RT_UOFFSETOF(RTSTRCACHEENTRY, szString) - cchString); RTSTRCACHE_CHECK(pThis); return pEntry; } #endif /* RTSTRCACHE_WITH_MERGED_ALLOCATOR */ /** * Allocate a cache entry from the heap. * * @returns Pointer to the cache entry on success, NULL on allocation error. * @param pThis The string cache instance. * @param uHash The full hash of the string. * @param pchString The string. * @param cchString The string length. */ static PRTSTRCACHEENTRY rtStrCacheAllocHeapEntry(PRTSTRCACHEINT pThis, uint32_t uHash, const char *pchString, uint32_t cchString) { /* * Allocate a heap block for storing the string. We do some size aligning * here to encourage the heap to give us optimal alignment. */ size_t cbEntry = RT_UOFFSETOF(RTSTRCACHEBIGENTRY, Core.szString[cchString + 1]); PRTSTRCACHEBIGENTRY pBigEntry = (PRTSTRCACHEBIGENTRY)RTMemAlloc(RT_ALIGN_Z(cbEntry, RTSTRCACHE_HEAP_ENTRY_SIZE_ALIGN)); if (!pBigEntry) return NULL; /* * Initialize the block. */ RTListAppend(&pThis->BigEntryList, &pBigEntry->ListEntry); pThis->cbBigEntries += cbEntry; pBigEntry->cchString = cchString; pBigEntry->uHash = uHash; pBigEntry->Core.cRefs = 1; pBigEntry->Core.uHash = (uint16_t)uHash; pBigEntry->Core.cchString = RTSTRCACHEENTRY_BIG_LEN; memcpy(pBigEntry->Core.szString, pchString, cchString); pBigEntry->Core.szString[cchString] = '\0'; return &pBigEntry->Core; } /** * Allocate a cache entry from a fixed size free list. * * @returns Pointer to the cache entry on success, NULL on allocation error. * @param pThis The string cache instance. * @param uHash The full hash of the string. * @param pchString The string. * @param cchString The string length. * @param iFreeList Which free list. */ static PRTSTRCACHEENTRY rtStrCacheAllocFixedEntry(PRTSTRCACHEINT pThis, uint32_t uHash, const char *pchString, uint32_t cchString, uint32_t iFreeList) { /* * Get an entry from the free list. If empty, allocate another chunk of * memory and split it up into free entries of the desired size. */ PRTSTRCACHEFREE pFree = pThis->apFreeLists[iFreeList]; if (!pFree) { PRTSTRCACHECHUNK pChunk = (PRTSTRCACHECHUNK)RTMemPageAlloc(RTSTRCACHE_FIXED_GROW_SIZE); if (!pChunk) return NULL; pChunk->cb = RTSTRCACHE_FIXED_GROW_SIZE; pChunk->pNext = pThis->pChunkList; pThis->pChunkList = pChunk; pThis->cbChunks += RTSTRCACHE_FIXED_GROW_SIZE; PRTSTRCACHEFREE pPrev = NULL; uint32_t const cbEntry = g_acbFixedLists[iFreeList]; uint32_t cLeft = RTSTRCACHE_FIXED_GROW_SIZE / cbEntry - 1; pFree = (PRTSTRCACHEFREE)((uintptr_t)pChunk + cbEntry); Assert(sizeof(*pChunk) <= cbEntry); Assert(sizeof(*pFree) <= cbEntry); Assert(cbEntry < RTSTRCACHE_FIXED_GROW_SIZE / 16); while (cLeft-- > 0) { pFree->uZero = 0; pFree->cbFree = cbEntry; pFree->pNext = pPrev; pPrev = pFree; pFree = (PRTSTRCACHEFREE)((uintptr_t)pFree + cbEntry); } Assert(pPrev); pThis->apFreeLists[iFreeList] = pFree = pPrev; } /* * Unlink it. */ pThis->apFreeLists[iFreeList] = pFree->pNext; ASMCompilerBarrier(); /* * Initialize the entry. */ PRTSTRCACHEENTRY pEntry = (PRTSTRCACHEENTRY)pFree; pEntry->cRefs = 1; pEntry->uHash = (uint16_t)uHash; pEntry->cchString = (uint16_t)cchString; memcpy(pEntry->szString, pchString, cchString); pEntry->szString[cchString] = '\0'; return pEntry; } /** * Looks up a string in the hash table. * * @returns Pointer to the string cache entry, NULL + piFreeHashTabEntry if not * found. * @param pThis The string cache instance. * @param uHashLen The hash + length (not RTSTRCACHEENTRY_BIG_LEN). * @param cchString The real length. * @param pchString The string. * @param piFreeHashTabEntry Where to store the index insertion index if NULL * is returned (same as what * rtStrCacheFindEmptyHashTabEntry would return). * @param pcCollisions Where to return a collision counter. */ static PRTSTRCACHEENTRY rtStrCacheLookUp(PRTSTRCACHEINT pThis, uint32_t uHashLen, uint32_t cchString, const char *pchString, uint32_t *piFreeHashTabEntry, uint32_t *pcCollisions) { *piFreeHashTabEntry = UINT32_MAX; *pcCollisions = 0; uint16_t cchStringFirst = RT_UOFFSETOF(RTSTRCACHEENTRY, szString[cchString + 1]) < RTSTRCACHE_HEAP_THRESHOLD ? (uint16_t)cchString : RTSTRCACHEENTRY_BIG_LEN; uint32_t iHash = uHashLen % pThis->cHashTab; for (;;) { PRTSTRCACHEENTRY pEntry = pThis->papHashTab[iHash]; /* Give up if NULL, but record the index for insertion. */ if (pEntry == NULL) { if (*piFreeHashTabEntry == UINT32_MAX) *piFreeHashTabEntry = iHash; return NULL; } if (pEntry != PRTSTRCACHEENTRY_NIL) { /* Compare. */ if ( pEntry->uHash == (uint16_t)uHashLen && pEntry->cchString == cchStringFirst) { if (pEntry->cchString != RTSTRCACHEENTRY_BIG_LEN) { if ( !memcmp(pEntry->szString, pchString, cchString) && pEntry->szString[cchString] == '\0') return pEntry; } else { PRTSTRCACHEBIGENTRY pBigEntry = RT_FROM_MEMBER(pEntry, RTSTRCACHEBIGENTRY, Core); if ( pBigEntry->cchString == cchString && !memcmp(pBigEntry->Core.szString, pchString, cchString)) return &pBigEntry->Core; } } if (*piFreeHashTabEntry == UINT32_MAX) *pcCollisions += 1; } /* Record the first NIL index for insertion in case we don't get a hit. */ else if (*piFreeHashTabEntry == UINT32_MAX) *piFreeHashTabEntry = iHash; /* Advance. */ iHash += RTSTRCACHE_COLLISION_INCR(uHashLen); iHash %= pThis->cHashTab; } } RTDECL(const char *) RTStrCacheEnterN(RTSTRCACHE hStrCache, const char *pchString, size_t cchString) { PRTSTRCACHEINT pThis = hStrCache; RTSTRCACHE_VALID_RETURN_RC(pThis, NULL); /* * Calculate the hash and figure the exact string length, then look for an existing entry. */ uint32_t const uHash = sdbmN(pchString, cchString, &cchString); uint32_t const uHashLen = RT_MAKE_U32(uHash, cchString); AssertReturn(cchString < _1G, NULL); uint32_t const cchString32 = (uint32_t)cchString; RTCritSectEnter(&pThis->CritSect); RTSTRCACHE_CHECK(pThis); uint32_t cCollisions; uint32_t iFreeHashTabEntry; PRTSTRCACHEENTRY pEntry = rtStrCacheLookUp(pThis, uHashLen, cchString32, pchString, &iFreeHashTabEntry, &cCollisions); if (pEntry) { uint32_t cRefs = ASMAtomicIncU32(&pEntry->cRefs); Assert(cRefs < UINT32_MAX / 2); } else { /* * Allocate a new entry. */ uint32_t cbEntry = cchString32 + 1U + RT_UOFFSETOF(RTSTRCACHEENTRY, szString); if (cbEntry >= RTSTRCACHE_HEAP_THRESHOLD) pEntry = rtStrCacheAllocHeapEntry(pThis, uHash, pchString, cchString32); #ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR else if (cbEntry >= RTSTRCACHE_MERGED_THRESHOLD_BIT) pEntry = rtStrCacheAllocMergedEntry(pThis, uHash, pchString, cchString32, cbEntry); #endif else pEntry = rtStrCacheAllocFixedEntry(pThis, uHash, pchString, cchString32, rtStrCacheSelectFixedList(cbEntry)); if (!pEntry) { RTSTRCACHE_CHECK(pThis); RTCritSectLeave(&pThis->CritSect); return NULL; } /* * Insert it into the hash table. */ if (pThis->cHashTab - pThis->cStrings < pThis->cHashTab / 2) { int rc = rtStrCacheGrowHashTab(pThis); if (RT_SUCCESS(rc)) iFreeHashTabEntry = rtStrCacheFindEmptyHashTabEntry(pThis, uHashLen); else if (pThis->cHashTab - pThis->cStrings <= pThis->cHashTab / 8) /* 12.5% full => error */ { pThis->papHashTab[iFreeHashTabEntry] = pEntry; pThis->cStrings++; pThis->cHashInserts++; pThis->cHashCollisions += cCollisions > 0; pThis->cHashCollisions2 += cCollisions > 1; pThis->cbStrings += cchString32 + 1; RTStrCacheRelease(hStrCache, pEntry->szString); RTSTRCACHE_CHECK(pThis); RTCritSectLeave(&pThis->CritSect); return NULL; } } pThis->papHashTab[iFreeHashTabEntry] = pEntry; pThis->cStrings++; pThis->cHashInserts++; pThis->cHashCollisions += cCollisions > 0; pThis->cHashCollisions2 += cCollisions > 1; pThis->cbStrings += cchString32 + 1; Assert(pThis->cStrings < pThis->cHashTab && pThis->cStrings > 0); } RTSTRCACHE_CHECK(pThis); RTCritSectLeave(&pThis->CritSect); return pEntry->szString; } RT_EXPORT_SYMBOL(RTStrCacheEnterN); RTDECL(const char *) RTStrCacheEnter(RTSTRCACHE hStrCache, const char *psz) { return RTStrCacheEnterN(hStrCache, psz, strlen(psz)); } RT_EXPORT_SYMBOL(RTStrCacheEnter); static const char *rtStrCacheEnterLowerWorker(PRTSTRCACHEINT pThis, const char *pchString, size_t cchString) { /* * Try use a dynamic heap buffer first. */ if (cchString < 512) { char *pszStackBuf = (char *)alloca(cchString + 1); if (pszStackBuf) { memcpy(pszStackBuf, pchString, cchString); pszStackBuf[cchString] = '\0'; RTStrToLower(pszStackBuf); return RTStrCacheEnterN(pThis, pszStackBuf, cchString); } } /* * Fall back on heap. */ char *pszHeapBuf = (char *)RTMemTmpAlloc(cchString + 1); if (!pszHeapBuf) return NULL; memcpy(pszHeapBuf, pchString, cchString); pszHeapBuf[cchString] = '\0'; RTStrToLower(pszHeapBuf); const char *pszRet = RTStrCacheEnterN(pThis, pszHeapBuf, cchString); RTMemTmpFree(pszHeapBuf); return pszRet; } RTDECL(const char *) RTStrCacheEnterLowerN(RTSTRCACHE hStrCache, const char *pchString, size_t cchString) { PRTSTRCACHEINT pThis = hStrCache; RTSTRCACHE_VALID_RETURN_RC(pThis, NULL); return rtStrCacheEnterLowerWorker(pThis, pchString, RTStrNLen(pchString, cchString)); } RT_EXPORT_SYMBOL(RTStrCacheEnterLowerN); RTDECL(const char *) RTStrCacheEnterLower(RTSTRCACHE hStrCache, const char *psz) { PRTSTRCACHEINT pThis = hStrCache; RTSTRCACHE_VALID_RETURN_RC(pThis, NULL); return rtStrCacheEnterLowerWorker(pThis, psz, strlen(psz)); } RT_EXPORT_SYMBOL(RTStrCacheEnterLower); RTDECL(uint32_t) RTStrCacheRetain(const char *psz) { AssertPtr(psz); PRTSTRCACHEENTRY pStr = RT_FROM_MEMBER(psz, RTSTRCACHEENTRY, szString); Assert(!((uintptr_t)pStr & 15) || pStr->cchString == RTSTRCACHEENTRY_BIG_LEN); uint32_t cRefs = ASMAtomicIncU32(&pStr->cRefs); Assert(cRefs > 1); Assert(cRefs < UINT32_MAX / 2); return cRefs; } RT_EXPORT_SYMBOL(RTStrCacheRetain); static uint32_t rtStrCacheFreeEntry(PRTSTRCACHEINT pThis, PRTSTRCACHEENTRY pStr) { RTCritSectEnter(&pThis->CritSect); RTSTRCACHE_CHECK(pThis); /* Remove it from the hash table. */ uint32_t cchString = pStr->cchString == RTSTRCACHEENTRY_BIG_LEN ? RT_FROM_MEMBER(pStr, RTSTRCACHEBIGENTRY, Core)->cchString : pStr->cchString; uint32_t uHashLen = RT_MAKE_U32(pStr->uHash, cchString); uint32_t iHash = uHashLen % pThis->cHashTab; if (pThis->papHashTab[iHash] == pStr) pThis->papHashTab[iHash] = PRTSTRCACHEENTRY_NIL; else { do { AssertBreak(pThis->papHashTab[iHash] != NULL); iHash += RTSTRCACHE_COLLISION_INCR(uHashLen); iHash %= pThis->cHashTab; } while (pThis->papHashTab[iHash] != pStr); if (RT_LIKELY(pThis->papHashTab[iHash] == pStr)) pThis->papHashTab[iHash] = PRTSTRCACHEENTRY_NIL; else { AssertFailed(); iHash = pThis->cHashTab; while (iHash-- > 0) if (pThis->papHashTab[iHash] == pStr) break; AssertMsgFailed(("iHash=%u cHashTab=%u\n", iHash, pThis->cHashTab)); } } pThis->cStrings--; pThis->cbStrings -= cchString; Assert(pThis->cStrings < pThis->cHashTab); /* Free it. */ if (pStr->cchString != RTSTRCACHEENTRY_BIG_LEN) { uint32_t const cbMin = pStr->cchString + 1U + RT_UOFFSETOF(RTSTRCACHEENTRY, szString); #ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR if (cbMin <= RTSTRCACHE_MAX_FIXED) #endif { /* * No merging, just add it to the list. */ uint32_t const iFreeList = rtStrCacheSelectFixedList(cbMin); ASMCompilerBarrier(); PRTSTRCACHEFREE pFreeStr = (PRTSTRCACHEFREE)pStr; pFreeStr->cbFree = cbMin; pFreeStr->uZero = 0; pFreeStr->pNext = pThis->apFreeLists[iFreeList]; pThis->apFreeLists[iFreeList] = pFreeStr; } #ifdef RTSTRCACHE_WITH_MERGED_ALLOCATOR else { /* * Complicated mode, we merge with adjecent nodes. */ ASMCompilerBarrier(); PRTSTRCACHEFREEMERGE pFreeStr = (PRTSTRCACHEFREEMERGE)pStr; pFreeStr->cbFree = RT_ALIGN_32(cbMin, sizeof(*pFreeStr)); pFreeStr->uMarker = RTSTRCACHEFREEMERGE_MAIN; pFreeStr->pMain = NULL; RTListInit(&pFreeStr->ListEntry); /* * Merge with previous? * (Reading one block back is safe because there is always the * RTSTRCACHECHUNK structure at the head of each memory chunk.) */ uint32_t cInternalBlocks = pFreeStr->cbFree / sizeof(*pFreeStr); PRTSTRCACHEFREEMERGE pMain = pFreeStr - 1; if ( pMain->uMarker == RTSTRCACHEFREEMERGE_MAIN || pMain->uMarker == RTSTRCACHEFREEMERGE_PART) { while (pMain->uMarker != RTSTRCACHEFREEMERGE_MAIN) pMain--; pMain->cbFree += pFreeStr->cbFree; } else { pMain = pFreeStr; pFreeStr++; cInternalBlocks--; } /* * Mark internal blocks in the string we're freeing. */ while (cInternalBlocks-- > 0) { pFreeStr->uMarker = RTSTRCACHEFREEMERGE_PART; pFreeStr->cbFree = 0; pFreeStr->pMain = pMain; RTListInit(&pFreeStr->ListEntry); pFreeStr++; } /* * Merge with next? Limitation: We won't try cross page boundraries. * (pFreeStr points to the next first free enter after the string now.) */ if ( PAGE_ADDRESS(pFreeStr) == PAGE_ADDRESS(&pFreeStr[-1]) && pFreeStr->uMarker == RTSTRCACHEFREEMERGE_MAIN) { pMain->cbFree += pFreeStr->cbFree; cInternalBlocks = pFreeStr->cbFree / sizeof(*pFreeStr); Assert(cInternalBlocks > 0); /* Update the main block we merge with. */ pFreeStr->cbFree = 0; pFreeStr->uMarker = RTSTRCACHEFREEMERGE_PART; RTListNodeRemove(&pFreeStr->ListEntry); RTListInit(&pFreeStr->ListEntry); /* Change the internal blocks we merged in. */ cInternalBlocks--; while (cInternalBlocks-- > 0) { pFreeStr++; pFreeStr->pMain = pMain; Assert(pFreeStr->uMarker == RTSTRCACHEFREEMERGE_PART); Assert(!pFreeStr->cbFree); } } /* * Add/relink into the appropriate free list. */ rtStrCacheRelinkMerged(pThis, pMain); } #endif /* RTSTRCACHE_WITH_MERGED_ALLOCATOR */ RTSTRCACHE_CHECK(pThis); RTCritSectLeave(&pThis->CritSect); } else { /* Big string. */ PRTSTRCACHEBIGENTRY pBigStr = RT_FROM_MEMBER(pStr, RTSTRCACHEBIGENTRY, Core); RTListNodeRemove(&pBigStr->ListEntry); pThis->cbBigEntries -= RT_ALIGN_32(RT_UOFFSETOF(RTSTRCACHEBIGENTRY, Core.szString[cchString + 1]), RTSTRCACHE_HEAP_ENTRY_SIZE_ALIGN); RTSTRCACHE_CHECK(pThis); RTCritSectLeave(&pThis->CritSect); RTMemFree(pBigStr); } return 0; } RTDECL(uint32_t) RTStrCacheRelease(RTSTRCACHE hStrCache, const char *psz) { if (!psz) return 0; PRTSTRCACHEINT pThis = hStrCache; RTSTRCACHE_VALID_RETURN_RC(pThis, UINT32_MAX); AssertPtr(psz); PRTSTRCACHEENTRY pStr = RT_FROM_MEMBER(psz, RTSTRCACHEENTRY, szString); Assert(!((uintptr_t)pStr & 15) || pStr->cchString == RTSTRCACHEENTRY_BIG_LEN); /* * Drop a reference and maybe free the entry. */ uint32_t cRefs = ASMAtomicDecU32(&pStr->cRefs); Assert(cRefs < UINT32_MAX / 2); if (!cRefs) return rtStrCacheFreeEntry(pThis, pStr); return cRefs; } RT_EXPORT_SYMBOL(RTStrCacheRelease); RTDECL(size_t) RTStrCacheLength(const char *psz) { if (!psz) return 0; AssertPtr(psz); PRTSTRCACHEENTRY pStr = RT_FROM_MEMBER(psz, RTSTRCACHEENTRY, szString); if (pStr->cchString == RTSTRCACHEENTRY_BIG_LEN) { PRTSTRCACHEBIGENTRY pBigStr = RT_FROM_MEMBER(psz, RTSTRCACHEBIGENTRY, Core.szString); return pBigStr->cchString; } Assert(!((uintptr_t)pStr & 15)); return pStr->cchString; } RT_EXPORT_SYMBOL(RTStrCacheLength); RTDECL(bool) RTStrCacheIsRealImpl(void) { return true; } RT_EXPORT_SYMBOL(RTStrCacheIsRealImpl); RTDECL(uint32_t) RTStrCacheGetStats(RTSTRCACHE hStrCache, size_t *pcbStrings, size_t *pcbChunks, size_t *pcbBigEntries, uint32_t *pcHashCollisions, uint32_t *pcHashCollisions2, uint32_t *pcHashInserts, uint32_t *pcRehashes) { PRTSTRCACHEINT pThis = hStrCache; RTSTRCACHE_VALID_RETURN_RC(pThis, UINT32_MAX); RTCritSectEnter(&pThis->CritSect); if (pcbStrings) *pcbStrings = pThis->cbStrings; if (pcbChunks) *pcbChunks = pThis->cbChunks; if (pcbBigEntries) *pcbBigEntries = pThis->cbBigEntries; if (pcHashCollisions) *pcHashCollisions = pThis->cHashCollisions; if (pcHashCollisions2) *pcHashCollisions2 = pThis->cHashCollisions2; if (pcHashInserts) *pcHashInserts = pThis->cHashInserts; if (pcRehashes) *pcRehashes = pThis->cRehashes; uint32_t cStrings = pThis->cStrings; RTCritSectLeave(&pThis->CritSect); return cStrings; } RT_EXPORT_SYMBOL(RTStrCacheRelease);
[ "zhengke_stone@foxmail.com" ]
zhengke_stone@foxmail.com
0daf66cf82e01f6bcedba92160556ef925405bab
9e1fb975b05b97e7baab21c7224e8c7dd5a33d33
/src/utilities/ringbuffer.cpp
d67197b4781ebfff22383dba1574910b5acf0c48
[]
no_license
cowo78/canviausb
142c8ba4e0b212b1011743642369d30e86f1e7b9
0cc0556e323150258ff690e39698306ae2b6675e
refs/heads/master
2021-01-24T20:58:20.029493
2016-04-08T07:31:21
2016-04-08T07:31:21
55,758,345
0
0
null
2016-04-08T07:11:44
2016-04-08T07:11:43
C++
UTF-8
C++
false
false
2,419
cpp
/* * Copyright 2015 Laurent Schall (schall_l@yahoo.fr) * * This file is part of CANviaUSB. * * CANviaUSB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * CANviaUSB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with CANviaUSB. If not, see <http://www.gnu.org/licenses/>. */ #include "ringbuffer.h" #include <string.h> RingBuffer::RingBuffer() { head = 0; tail = 0; } RingBuffer::~RingBuffer() { } unsigned int RingBuffer::getSpaceAvailable(void) const { QMutexLocker locker(&mutex); return (RX_BUFFER_SIZE + head - tail) % RX_BUFFER_SIZE; } unsigned int RingBuffer::getDataAvailable(void) const { QMutexLocker locker(&mutex); unsigned int ret = 0; if (tail < head) ret = head - tail; else if (head < tail) ret = RX_BUFFER_SIZE + head - tail; return ret; } void RingBuffer::nonSecureAddData(char c) { int i = (head + 1) % RX_BUFFER_SIZE; if (i != tail) { buffer[head] = c; head = i; } } void RingBuffer::addData(char* buffer, unsigned int amount) { for (unsigned int i = 0; i<amount; i++) nonSecureAddData(buffer[i]); } char RingBuffer::nonSecureRemoveData(void) { // if the head isn't ahead of the tail, we don't have any characters if (head == tail) { return 0; } else { char c = buffer[tail]; tail = (tail + 1) % RX_BUFFER_SIZE; return c; } } void RingBuffer::trashOneData(void) { QMutexLocker locker(&mutex); nonSecureRemoveData(); } void RingBuffer::removeData(char* buffer, unsigned int amount) { QMutexLocker locker(&mutex); for (unsigned int i = 0; i<amount; i++) buffer[i] = nonSecureRemoveData(); } char RingBuffer::consultFirstData(void) { QMutexLocker locker(&mutex); // if the head isn't ahead of the tail, we don't have any characters if (head == tail) { return 0; } else { char c = buffer[tail]; return c; } }
[ "laurentschall@Mac-mini.fritz.box" ]
laurentschall@Mac-mini.fritz.box
06dce9affd230234a2f4ab0760680a7bbef4a937
a24eb87a3f8b5a6313f8cda021df123f499318b6
/AI_Engine_Development/Design_Tutorials/08-n-body-simulator/x1_design/aie/src/nbody.cc
a934d141755ebe39ac579dc40a2b436f6f4f266a
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
tcxxxx/Vitis-Tutorials
f9889d9ac9b6ff5f345dfe81583ebe82510fe86f
db37ebd331bda518f57cd79f7444ea3fedd6b8e3
refs/heads/2022.2
2023-01-19T07:31:48.838416
2022-12-19T03:46:10
2022-12-19T03:46:10
315,134,936
0
0
NOASSERTION
2020-11-22T21:27:05
2020-11-22T21:23:47
null
UTF-8
C++
false
false
9,547
cc
/* (c) Copyright 2021 Xilinx, Inc. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "include.h" #include "globals.h" #define POS_TIMESTEP 0 #define POS_SF2 1 #define POS_I_X 2 #define POS_I_Y 3 #define POS_I_Z 4 void nbody( input_window_float * w_input_i, // x, y, z, vx, vy, vz, m input_window_float * w_input_j, // x, y, z, m output_window_float * w_output_i // x, y, z, vx, vy, vz, m ) { v8float acc = undef_v8float(); v8float ts_sf2_i = undef_v8float(); ts_sf2_i = upd_elem(ts_sf2_i, POS_TIMESTEP, timestep); const v8float sf2 = ext_w(fpshuffle16(::xset_w(0, shft_elem(undef_v8float(), softening_factor_2)), 0, 0x00000000, 0x00000000), 0); // Step 1 of 4 - Save i from input window - once per iter { v8float * ptr_i = (v8float *)particles_i; for (int n=0; n<(7*NUM_I_VECTORS); n++) { *ptr_i = window_readincr_v8(w_input_i); ptr_i++; } } // Step 2 of 4 - Compute new i for all particles (independent of acc-i // calculate new position using vi and timestep - out of the way { const v8float * restrict xi_v8 = (v8float *)(particles_i) + (0*NUM_I_VECTORS); const v8float * restrict yi_v8 = (v8float *)(particles_i) + (1*NUM_I_VECTORS); const v8float * restrict zi_v8 = (v8float *)(particles_i) + (2*NUM_I_VECTORS); const v8float * restrict vxi_v8 = (v8float *)(particles_i) + (3*NUM_I_VECTORS); const v8float * restrict vyi_v8 = (v8float *)(particles_i) + (4*NUM_I_VECTORS); const v8float * restrict vzi_v8 = (v8float *)(particles_i) + (5*NUM_I_VECTORS); v8float * restrict xi_v8_new = (v8float *)(particles_i_new) + (0*NUM_I_VECTORS); v8float * restrict yi_v8_new = (v8float *)(particles_i_new) + (1*NUM_I_VECTORS); v8float * restrict zi_v8_new = (v8float *)(particles_i_new) + (2*NUM_I_VECTORS); for (int i=0; i<NUM_I_VECTORS; i++) { #ifdef KERNEL_BYPASS *xi_v8_new = *xi_v8; xi_v8_new++; xi_v8++; *yi_v8_new = *yi_v8; yi_v8_new++; yi_v8++; *zi_v8_new = *zi_v8; zi_v8_new++; zi_v8++; #else *xi_v8_new = fpmac(*xi_v8, ::xset_w(0, ts_sf2_i), POS_TIMESTEP, 0x00000000, *vxi_v8, 0, 0x76543210); xi_v8_new++; xi_v8++; vxi_v8++; *yi_v8_new = fpmac(*yi_v8, ::xset_w(0, ts_sf2_i), POS_TIMESTEP, 0x00000000, *vyi_v8, 0, 0x76543210); yi_v8_new++; yi_v8++; vyi_v8++; *zi_v8_new = fpmac(*zi_v8, ::xset_w(0, ts_sf2_i), POS_TIMESTEP, 0x00000000, *vzi_v8, 0, 0x76543210); zi_v8_new++; zi_v8++; vzi_v8++; #endif } } // Step 3 of 4 - Compute acc-i for all i for a given set-j for ( int j=0; j<LOOP_COUNT_J ; j++) { window_acquire(w_input_j); // Step 3.1 - read all j's - window has all this data { v8float * ptr_j = (v8float *)particles_j; for (int k=0; k<(4*NUM_J_VECTORS);k++) { *ptr_j = window_readincr_v8(w_input_j); ptr_j++; } } window_release(w_input_j); // Step 3.2 for (int i=0; i<NUM_I; i++) { float *xi = (particles_i + (0*NUM_I) + i); float *yi = (particles_i + (1*NUM_I) + i); float *zi = (particles_i + (2*NUM_I) + i); float temp_x[NUM_J]; float temp_y[NUM_J]; float temp_z[NUM_J]; float temp_d[NUM_J]; ts_sf2_i = upd_elem(ts_sf2_i, POS_I_X, *xi); ts_sf2_i = upd_elem(ts_sf2_i, POS_I_Y, *yi); ts_sf2_i = upd_elem(ts_sf2_i, POS_I_Z, *zi); // Step 3.2.1 - calculate dx, dy, dz { v8float * restrict dx = (v8float *)temp_x; v8float * restrict dy = (v8float *)temp_y; v8float * restrict dz = (v8float *)temp_z; const v8float * restrict xj_v8 = (v8float *)(particles_j) + (0*NUM_J_VECTORS); const v8float * restrict yj_v8 = (v8float *)(particles_j) + (1*NUM_J_VECTORS); const v8float * restrict zj_v8 = (v8float *)(particles_j) + (2*NUM_J_VECTORS); //for (int jj=0; jj<NUM_J_VECTORS; jj++) { for (int jj=0; jj<NUM_J_VECTORS; jj++) chess_loop_range(4,) chess_prepare_for_pipelining { const v8float rx = fpsub(*xj_v8, ::xset_w(0, ts_sf2_i) , POS_I_X , 0x00000000); xj_v8++; const v8float ry = fpsub(*yj_v8, ::xset_w(0, ts_sf2_i) , POS_I_Y , 0x00000000); yj_v8++; const v8float rz = fpsub(*zj_v8, ::xset_w(0, ts_sf2_i) , POS_I_Z , 0x00000000); zj_v8++; *dx = rx; dx++; *dy = ry; dy++; *dz = rz; dz++; } } // Step 3.2.2 - calculate l2 dist, dist^(3/2) { const v8float *restrict dx = (v8float *)temp_x; const v8float *restrict dy = (v8float *)temp_y; const v8float *restrict dz = (v8float *)temp_z; v8float *restrict dd = (v8float *)temp_d; //for (int jj=0; jj<NUM_J_VECTORS; jj++) { for (int jj=0; jj<NUM_J_VECTORS; jj++) chess_flatten_loop //chess_loop_range(4,) chess_prepare_for_pipelining { v8float l2dist = fpmac(sf2, ::xset_w(0, *dx), 0, 0x76543210, *dx, 0, 0x76543210); dx++; l2dist = fpmac(l2dist, ::xset_w(0, *dy), 0, 0x76543210, *dy, 0, 0x76543210); dy++; l2dist = fpmac(l2dist, ::xset_w(0, *dz), 0, 0x76543210, *dz, 0, 0x76543210); dz++; // dist = invsqrt( l2dist**3 ) const v8float acc2 = fpmul(::xset_w(0, l2dist), 0, 0x76543210, l2dist, 0, 0x76543210); acc = fpmul(::xset_w(0, l2dist), 0, 0x76543210, acc2, 0, 0x76543210); v8float ret = undef_v8float(); for (unsigned h = 0; h < 8; ++h) { const float e = ::ext_elem(acc, 7 - h); const float r = invsqrt(e); ret = ::shft_elem(ret, r); } *dd = ret; dd++; } } // Step 3.2.3 - { v8float accx = null_v8float(); v8float accy = null_v8float(); v8float accz = null_v8float(); const v8float * restrict dx = (v8float *)temp_x; const v8float * restrict dy = (v8float *)temp_y; const v8float * restrict dz = (v8float *)temp_z; const v8float * restrict dd = (v8float *)temp_d; const v8float * restrict mj_v8 = (v8float *)(particles_j) + (3*NUM_J_VECTORS); //for (int jj=0; jj<NUM_J_VECTORS; jj++) { for (int jj=0; jj<NUM_J_VECTORS; jj++) chess_flatten_loop //chess_loop_range(4,) chess_prepare_for_pipelining { // s = mass * dist acc = fpmul(::xset_w(0, *dd), 0, 0x76543210, *mj_v8, 0, 0x76543210); mj_v8++; dd++; // accx += dx*s; accy += dy*s; accz += dz*s accx = fpmac(accx, ::xset_w(0, acc), 0, 0x76543210, *dx, 0, 0x76543210); dx++; accy = fpmac(accy, ::xset_w(0, acc), 0, 0x76543210, *dy, 0, 0x76543210); dy++; accz = fpmac(accz, ::xset_w(0, acc), 0, 0x76543210, *dz, 0, 0x76543210); dz++; } // dx, dy, dz now have acceleration // Accumulate acceleration of i w.r.t all 8 j's - reduction tree v8float acceleration = undef_v8float(); const v8float a_xy = fpadd(concat(ext_v(accx, 0), ext_v(accy, 0)), concat(accx, accy), 0, 0xfedc7654); const v8float a_z = fpadd(accz, ::xset_w(0, accz), 0, 0x7654); acceleration = fpshuffle( ::concat(a_xy, a_z), 0, 0x951840); acceleration = fpadd(acceleration, ::concat(a_xy, a_z), 0, 0xB73A62); acceleration = fpadd(acceleration, ::xset_w(0, acceleration), 0, 0x543); /*accx = fpadd(accx, ::xset_w(0, accx), 0, 0x7654); accy = fpadd(accy, ::xset_w(0, accy), 0, 0x7654); accz = fpadd(accz, ::xset_w(0, accz), 0, 0x7654); accx = fpadd(accx, ::xset_w(0, accx), 0, 0x32); accy = fpadd(accy, ::xset_w(0, accy), 0, 0x32); accz = fpadd(accz, ::xset_w(0, accz), 0, 0x32); accx = fpadd(accx, ::xset_w(0, accx), 0, 0x1); accy = fpadd(accy, ::xset_w(0, accy), 0, 0x1); accz = fpadd(accz, ::xset_w(0, accz), 0, 0x1); acceleration = upd_elem(acceleration, 0, ext_elem(accx, 0)); acceleration = upd_elem(acceleration, 1, ext_elem(accy, 0)); acceleration = upd_elem(acceleration, 2, ext_elem(accz, 0)); */ float *vxi = (particles_i + (3*NUM_I) + i); float *vyi = (particles_i + (4*NUM_I) + i); float *vzi = (particles_i + (5*NUM_I) + i); v8float velocity = undef_v8float(); velocity = upd_elem(velocity, 0, *vxi); velocity = upd_elem(velocity, 1, *vyi); velocity = upd_elem(velocity, 2, *vzi); acc = fpmac(velocity, ::xset_w(0, ts_sf2_i), POS_TIMESTEP, 0x00000000, acceleration, 0, 0x76543210 ); #ifndef KERNEL_BYPASS *vxi = ext_elem(acc, 0); *vyi = ext_elem(acc, 1); *vzi = ext_elem(acc, 2); #endif } } } // Step 4 of 4 - Transmit new i // send x, y, z { v8float *newi = (v8float *)(particles_i_new); for ( int k=0; k<(3*NUM_I_VECTORS) ; k++) { window_writeincr(w_output_i, *newi ); newi++; } } // send vx, vy, vz { v8float *newi = (v8float *)(particles_i) + (3*NUM_I_VECTORS); for ( int k=0; k<(3*NUM_I_VECTORS) ; k++) { window_writeincr(w_output_i, *newi ); newi++; } } // send m { v8float *m = (v8float *)(particles_i) + (6*NUM_I_VECTORS); for ( int k=0; k<NUM_I_VECTORS ; k++) { window_writeincr(w_output_i, *m ); m++; } } }
[ "do-not-reply@gitenterprise.xilinx.com" ]
do-not-reply@gitenterprise.xilinx.com
cfba7f10518efa3bbadbb52ec76861d8d40783f7
6dc4a4bf3868f9dc4fdfffa274706f639d2020f5
/644.cpp
32c3a37fea76128a2640225c0850b5415f2a8f61
[ "MIT" ]
permissive
00mjk/UVa-Online-Judge
0481d2a86480177330eb672979c35c6f9ce057d7
c267f069f9690daad2b438bc32e72c148b9e100e
refs/heads/master
2022-12-31T12:48:16.082901
2020-10-28T01:58:43
2020-10-28T01:58:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,219
cpp
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; #define FOI(i, A, B) for (i = A; i <= B; i++) #define FOD(i, A, B) for (i = A; i >= B; i--) int main(){ //freopen("testI.txt", "r", stdin); //freopen("testO.txt", "w", stdout); int t = 1; int i, j; vector< string > Vec; string str; bool stat = true; while (cin >> str) { if (str == "9") { int N = Vec.size() - 1; FOI(i, 0, N) { FOI(j, 0, N) { if (i == j) continue; if (int(Vec[j].find(Vec[i])) == 0) { stat = false; break; } } if (!stat) break; } if (stat) cout << "Set " << t++ << " is immediately decodable" << endl; else cout << "Set " << t++ << " is not immediately decodable" << endl; Vec.clear(); stat = true; } else Vec.push_back(str); } return 0; }
[ "siteshshrivastava@gmail.com" ]
siteshshrivastava@gmail.com
e075447f9062b7d98f478d058c3d6eb5f5736f84
6e665dcd74541d40647ebb64e30aa60bc71e610c
/800/VPBX_Support/include/util/Data.hxx
e37dcb87437a53c7f02605500202e8f19fc8f275
[]
no_license
jacklee032016/pbx
b27871251a6d49285eaade2d0a9ec02032c3ec62
554149c134e50db8ea27de6a092934a51e156eb6
refs/heads/master
2020-03-24T21:52:18.653518
2018-08-04T20:01:15
2018-08-04T20:01:15
143,054,776
0
0
null
null
null
null
UTF-8
C++
false
false
153
hxx
#ifndef DATA_HXX_ #define DATA_HXX_ /* * $Id: Data.hxx,v 1.1.1.1 2006/11/30 16:27:09 lizhijie Exp $ */ #include "global.h" #include "Data2.hxx" #endif
[ "jacklee032016@gmail.com" ]
jacklee032016@gmail.com
e944a276ef367027771d934ffd027bc66312db00
2ae0b8d95d439ccfd55ea7933ad4a2994ad0f6c5
/src/core/include/openvino/op/nv12_to_rgb.hpp
de4d06a5bf1a397bdc004d6f2293336184fcde86
[ "Apache-2.0" ]
permissive
openvinotoolkit/openvino
38ea745a247887a4e14580dbc9fc68005e2149f9
e4bed7a31c9f00d8afbfcabee3f64f55496ae56a
refs/heads/master
2023-08-18T03:47:44.572979
2023-08-17T21:24:59
2023-08-17T21:24:59
153,097,643
3,953
1,492
Apache-2.0
2023-09-14T21:42:24
2018-10-15T10:54:40
C++
UTF-8
C++
false
false
3,127
hpp
// Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #pragma once #include "openvino/op/util/convert_color_nv12_base.hpp" namespace ov { namespace op { namespace v8 { /// \brief Color conversion operation from NV12 to RGB format. /// Input: /// - Input NV12 image can be represented in two ways: /// a) Single plane (as it is in the file): NV12 height dimension is 1.5x bigger than image height. 'C' /// dimension shall be 1. /// b) Two separate planes (used this way in many physical video sources): Y and UV. In /// this case /// b1) Y plane has height same as image height. 'C' dimension equals to 1 /// b2) UV plane has dimensions: 'H' = image_h / 2; 'W' = image_w / 2; 'C' = 2. /// - Supported element types: u8 or any supported floating-point type. /// Output: /// - Output node will have NHWC layout and shape HxW same as image spatial dimensions. /// - Number of output channels 'C' will be 3, as per interleaved RGB format, first channel is R, last is B /// /// \details Conversion of each pixel from NV12 (YUV) to RGB space is represented by following formulas: /// R = 1.164 * (Y - 16) + 1.596 * (V - 128) /// G = 1.164 * (Y - 16) - 0.813 * (V - 128) - 0.391 * (U - 128) /// B = 1.164 * (Y - 16) + 2.018 * (U - 128) /// Then R, G, B values are clipped to range (0, 255) /// /// \ingroup ov_ops_cpp_api class OPENVINO_API NV12toRGB : public util::ConvertColorNV12Base { public: OPENVINO_OP("NV12toRGB", "opset8", util::ConvertColorNV12Base); NV12toRGB() = default; /// \brief Constructs a conversion operation from input image in NV12 format /// As per NV12 format definition, node height dimension shall be 1.5 times bigger than image height /// so that image (w=640, h=480) is represented by NHWC shape {N,720,640,1} (height*1.5 x width) /// /// \param arg Node that produces the input tensor. Input tensor represents image in NV12 format (YUV). explicit NV12toRGB(const Output<Node>& arg); /// \brief Constructs a conversion operation from 2-plane input image in NV12 format /// In general case Y channel of image can be separated from UV channel which means that operation needs two nodes /// for Y and UV planes respectively. Y plane has one channel, and UV has 2 channels, both expect 'NHWC' layout /// /// \param arg_y Node that produces the input tensor for Y plane (NHWC layout). Shall have WxH dimensions /// equal to image dimensions. 'C' dimension equals to 1. /// /// \param arg_uv Node that produces the input tensor for UV plane (NHWC layout). 'H' is half of image height, /// 'W' is half of image width, 'C' dimension equals to 2. Channel 0 represents 'U', channel 1 represents 'V' /// channel /// NV12toRGB(const Output<Node>& arg_y, const Output<Node>& arg_uv); std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override; }; } // namespace v8 } // namespace op } // namespace ov
[ "noreply@github.com" ]
noreply@github.com
e483f21189fc6ce315bf839c27b9a35478c1d546
dfd2d48903c41574d2fab2adf6437665f657d0f8
/algorithms/Graph/stronglyConnectedCompo.cpp
fdf06baac07aae7992bf7aff4f91d21f93fe504e
[]
no_license
arnabs542/cpp-algorithms
d5d8ed85312da5db71f75f3a6832837ef8ead727
602dc20bf147d709952545ff9de77a186dae6733
refs/heads/master
2023-05-24T07:09:03.040165
2021-06-10T09:14:06
2021-06-10T09:14:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,052
cpp
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define sz(v) (int)v.size() #define all(v) v.begin(), v.end() void dbg_out() { cerr << "\b\b]\n"; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);} #define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__) /****************************** CODE IS HERE ***********************************/ //Strongly Connected by Kosaraju. vector <vector<int>> graph, revGraph; vector <bool> used; stack <int> nodes; //to maintain order / direction void dfs1(int u) { used[u] = true; for (int v: graph[u]) { if (!used[v]) dfs1(v); } nodes.push(u); } void dfs2(int u) { used[u] = true; for (int v: revGraph[u]) { if (!used[v]) dfs2(v); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; graph.assign(n+1, {}); revGraph.assign(n+1, {}); used.assign(n+1, false); nodes = stack<int>(); for (int i = 0, u, v; i < m; ++i) { cin >> u >> v; graph[u].push_back(v); revGraph[v].push_back(u); } for (int i = 1; i <= n; ++i) { if (!used[i]) dfs1(i); } fill(all(used), false); int components = 0; while (!nodes.empty()) { int u = nodes.top(); nodes.pop(); if (!used[u]) { dfs2(u); components++; } } cout << components; //number of components return 0; } //https://www.hackerearth.com/practice/algorithms/graphs/strongly-connected-components/practice-problems/algorithm/magical-islands/description/ //https://pastebin.com/EA3SeZUy /* https://www.hackerearth.com/practice/algorithms/graphs/strongly-connected-components/practice-problems/algorithm/a-walk-to-remember-qualifier2/description/ https://pastebin.com/249ArebS https://www.hackerrank.com/contests/all-india-contest-by-mission-helix-a-10-october/challenges/2-directions https://pastebin.com/KnethsHB */
[ "naithanipkpiyush@gmail.com" ]
naithanipkpiyush@gmail.com
347bd7e3f59085ad1f4d41e32355cb60844cdc00
6db8ebd5b071a349de6a15c1e6fc1e27a0987cd1
/Drivers/libuavcan/uavcan/navigation/GlobalNavigationSolution.hpp
2835967b598d550743550fbf254fa4ef94bf1fe0
[]
no_license
RuslanUrya/nucleo_power_uavcan
163ea518aaf25d68adb310ac51c51668c2ffa985
ee34900a4b8f83bf3a0855fa0c58a47de9df17af
refs/heads/master
2022-12-24T18:52:38.874759
2020-10-06T08:56:11
2020-10-06T08:56:11
283,022,531
0
0
null
null
null
null
UTF-8
C++
false
false
23,250
hpp
/* * UAVCAN data structure definition for libuavcan. * * Autogenerated, do not edit. * * Source file: /home/acyc/src/libuavcan/dsdl/uavcan/navigation/2000.GlobalNavigationSolution.uavcan */ #ifndef UAVCAN_NAVIGATION_GLOBALNAVIGATIONSOLUTION_HPP_INCLUDED #define UAVCAN_NAVIGATION_GLOBALNAVIGATIONSOLUTION_HPP_INCLUDED #include <uavcan/build_config.hpp> #include <uavcan/node/global_data_type_registry.hpp> #include <uavcan/marshal/types.hpp> #include <uavcan/Timestamp.hpp> /******************************* Source text ********************************** # # Inertial data and orientation in body frame with fused location. # # Fields marked as optional should be set to NaN if the corresponding value is unknown. # # # Global network synchronized timestamp, if known. # Set to zero if the timestamp is not known. # uavcan.Timestamp timestamp # # Geo location [angular degree]. # float64 longitude # required float64 latitude # required # # Height estimates [meter]. # float32 height_ellipsoid # Above ellipsoid (required) float32 height_msl # Above the mean sea level (required) float32 height_agl # Above ground level (provided by radar altimeter or LIDAR) (optional) float32 height_baro # Barometric height (optional) # # Atmospheric pressure adjusted to sea level [hectopascal]. # float16 qnh_hpa # optional # # Rotation quaternion between the NED frame and the body frame. # Zero rotation corresponds to the following orientation: # X facing north # Y facing east # Z facing down # float32[4] orientation_xyzw # # Column order: # longitude [meter^2] # latitude [meter^2] # height (MSL or ellipsoid, whichever worse) [meter^2] # roll angle [radian^2] # pitch angle [radian^2] # yaw angle [radian^2] # float16[<=36] pose_covariance # # Linear velocity in the body frame, X-Y-Z [meter/second]. # float32[3] linear_velocity_body # # Angular velocity in the body frame, roll-pitch-yaw [radian/second]. # float32[3] angular_velocity_body # # Low resolution estimate of the linear acceleration in the body frame [(meter/second)^2]. # This estimate should be properly downsampled in order to avoid aliasing effects. # float16[3] linear_acceleration_body # # Column order: # X velocity [(meter/second)^2] # Y velocity [(meter/second)^2] # Z velocity [(meter/second)^2] # roll velocity [(radian/second)^2] # pitch velocity [(radian/second)^2] # yaw velocity [(radian/second)^2] # float16[<=36] velocity_covariance ******************************************************************************/ /********************* DSDL signature source definition *********************** uavcan.navigation.GlobalNavigationSolution uavcan.Timestamp timestamp saturated float64 longitude saturated float64 latitude saturated float32 height_ellipsoid saturated float32 height_msl saturated float32 height_agl saturated float32 height_baro saturated float16 qnh_hpa saturated float32[4] orientation_xyzw saturated float16[<=36] pose_covariance saturated float32[3] linear_velocity_body saturated float32[3] angular_velocity_body saturated float16[3] linear_acceleration_body saturated float16[<=36] velocity_covariance ******************************************************************************/ #undef timestamp #undef longitude #undef latitude #undef height_ellipsoid #undef height_msl #undef height_agl #undef height_baro #undef qnh_hpa #undef orientation_xyzw #undef pose_covariance #undef linear_velocity_body #undef angular_velocity_body #undef linear_acceleration_body #undef velocity_covariance namespace uavcan { namespace navigation { template <int _tmpl> struct UAVCAN_EXPORT GlobalNavigationSolution_ { typedef const GlobalNavigationSolution_<_tmpl>& ParameterType; typedef GlobalNavigationSolution_<_tmpl>& ReferenceType; struct ConstantTypes { }; struct FieldTypes { typedef ::uavcan::Timestamp timestamp; typedef ::uavcan::FloatSpec< 64, ::uavcan::CastModeSaturate > longitude; typedef ::uavcan::FloatSpec< 64, ::uavcan::CastModeSaturate > latitude; typedef ::uavcan::FloatSpec< 32, ::uavcan::CastModeSaturate > height_ellipsoid; typedef ::uavcan::FloatSpec< 32, ::uavcan::CastModeSaturate > height_msl; typedef ::uavcan::FloatSpec< 32, ::uavcan::CastModeSaturate > height_agl; typedef ::uavcan::FloatSpec< 32, ::uavcan::CastModeSaturate > height_baro; typedef ::uavcan::FloatSpec< 16, ::uavcan::CastModeSaturate > qnh_hpa; typedef ::uavcan::Array< ::uavcan::FloatSpec< 32, ::uavcan::CastModeSaturate >, ::uavcan::ArrayModeStatic, 4 > orientation_xyzw; typedef ::uavcan::Array< ::uavcan::FloatSpec< 16, ::uavcan::CastModeSaturate >, ::uavcan::ArrayModeDynamic, 36 > pose_covariance; typedef ::uavcan::Array< ::uavcan::FloatSpec< 32, ::uavcan::CastModeSaturate >, ::uavcan::ArrayModeStatic, 3 > linear_velocity_body; typedef ::uavcan::Array< ::uavcan::FloatSpec< 32, ::uavcan::CastModeSaturate >, ::uavcan::ArrayModeStatic, 3 > angular_velocity_body; typedef ::uavcan::Array< ::uavcan::FloatSpec< 16, ::uavcan::CastModeSaturate >, ::uavcan::ArrayModeStatic, 3 > linear_acceleration_body; typedef ::uavcan::Array< ::uavcan::FloatSpec< 16, ::uavcan::CastModeSaturate >, ::uavcan::ArrayModeDynamic, 36 > velocity_covariance; }; enum { MinBitLen = FieldTypes::timestamp::MinBitLen + FieldTypes::longitude::MinBitLen + FieldTypes::latitude::MinBitLen + FieldTypes::height_ellipsoid::MinBitLen + FieldTypes::height_msl::MinBitLen + FieldTypes::height_agl::MinBitLen + FieldTypes::height_baro::MinBitLen + FieldTypes::qnh_hpa::MinBitLen + FieldTypes::orientation_xyzw::MinBitLen + FieldTypes::pose_covariance::MinBitLen + FieldTypes::linear_velocity_body::MinBitLen + FieldTypes::angular_velocity_body::MinBitLen + FieldTypes::linear_acceleration_body::MinBitLen + FieldTypes::velocity_covariance::MinBitLen }; enum { MaxBitLen = FieldTypes::timestamp::MaxBitLen + FieldTypes::longitude::MaxBitLen + FieldTypes::latitude::MaxBitLen + FieldTypes::height_ellipsoid::MaxBitLen + FieldTypes::height_msl::MaxBitLen + FieldTypes::height_agl::MaxBitLen + FieldTypes::height_baro::MaxBitLen + FieldTypes::qnh_hpa::MaxBitLen + FieldTypes::orientation_xyzw::MaxBitLen + FieldTypes::pose_covariance::MaxBitLen + FieldTypes::linear_velocity_body::MaxBitLen + FieldTypes::angular_velocity_body::MaxBitLen + FieldTypes::linear_acceleration_body::MaxBitLen + FieldTypes::velocity_covariance::MaxBitLen }; // Constants // Fields typename ::uavcan::StorageType< typename FieldTypes::timestamp >::Type timestamp; typename ::uavcan::StorageType< typename FieldTypes::longitude >::Type longitude; typename ::uavcan::StorageType< typename FieldTypes::latitude >::Type latitude; typename ::uavcan::StorageType< typename FieldTypes::height_ellipsoid >::Type height_ellipsoid; typename ::uavcan::StorageType< typename FieldTypes::height_msl >::Type height_msl; typename ::uavcan::StorageType< typename FieldTypes::height_agl >::Type height_agl; typename ::uavcan::StorageType< typename FieldTypes::height_baro >::Type height_baro; typename ::uavcan::StorageType< typename FieldTypes::qnh_hpa >::Type qnh_hpa; typename ::uavcan::StorageType< typename FieldTypes::orientation_xyzw >::Type orientation_xyzw; typename ::uavcan::StorageType< typename FieldTypes::pose_covariance >::Type pose_covariance; typename ::uavcan::StorageType< typename FieldTypes::linear_velocity_body >::Type linear_velocity_body; typename ::uavcan::StorageType< typename FieldTypes::angular_velocity_body >::Type angular_velocity_body; typename ::uavcan::StorageType< typename FieldTypes::linear_acceleration_body >::Type linear_acceleration_body; typename ::uavcan::StorageType< typename FieldTypes::velocity_covariance >::Type velocity_covariance; GlobalNavigationSolution_() : timestamp() , longitude() , latitude() , height_ellipsoid() , height_msl() , height_agl() , height_baro() , qnh_hpa() , orientation_xyzw() , pose_covariance() , linear_velocity_body() , angular_velocity_body() , linear_acceleration_body() , velocity_covariance() { ::uavcan::StaticAssert<_tmpl == 0>::check(); // Usage check #if UAVCAN_DEBUG /* * Cross-checking MaxBitLen provided by the DSDL compiler. * This check shall never be performed in user code because MaxBitLen value * actually depends on the nested types, thus it is not invariant. */ ::uavcan::StaticAssert<1860 == MaxBitLen>::check(); #endif } bool operator==(ParameterType rhs) const; bool operator!=(ParameterType rhs) const { return !operator==(rhs); } /** * This comparison is based on @ref uavcan::areClose(), which ensures proper comparison of * floating point fields at any depth. */ bool isClose(ParameterType rhs) const; static int encode(ParameterType self, ::uavcan::ScalarCodec& codec, ::uavcan::TailArrayOptimizationMode tao_mode = ::uavcan::TailArrayOptEnabled); static int decode(ReferenceType self, ::uavcan::ScalarCodec& codec, ::uavcan::TailArrayOptimizationMode tao_mode = ::uavcan::TailArrayOptEnabled); /* * Static type info */ enum { DataTypeKind = ::uavcan::DataTypeKindMessage }; enum { DefaultDataTypeID = 2000 }; static const char* getDataTypeFullName() { return "uavcan.navigation.GlobalNavigationSolution"; } static void extendDataTypeSignature(::uavcan::DataTypeSignature& signature) { signature.extend(getDataTypeSignature()); } static ::uavcan::DataTypeSignature getDataTypeSignature(); }; /* * Out of line struct method definitions */ template <int _tmpl> bool GlobalNavigationSolution_<_tmpl>::operator==(ParameterType rhs) const { return timestamp == rhs.timestamp && longitude == rhs.longitude && latitude == rhs.latitude && height_ellipsoid == rhs.height_ellipsoid && height_msl == rhs.height_msl && height_agl == rhs.height_agl && height_baro == rhs.height_baro && qnh_hpa == rhs.qnh_hpa && orientation_xyzw == rhs.orientation_xyzw && pose_covariance == rhs.pose_covariance && linear_velocity_body == rhs.linear_velocity_body && angular_velocity_body == rhs.angular_velocity_body && linear_acceleration_body == rhs.linear_acceleration_body && velocity_covariance == rhs.velocity_covariance; } template <int _tmpl> bool GlobalNavigationSolution_<_tmpl>::isClose(ParameterType rhs) const { return ::uavcan::areClose(timestamp, rhs.timestamp) && ::uavcan::areClose(longitude, rhs.longitude) && ::uavcan::areClose(latitude, rhs.latitude) && ::uavcan::areClose(height_ellipsoid, rhs.height_ellipsoid) && ::uavcan::areClose(height_msl, rhs.height_msl) && ::uavcan::areClose(height_agl, rhs.height_agl) && ::uavcan::areClose(height_baro, rhs.height_baro) && ::uavcan::areClose(qnh_hpa, rhs.qnh_hpa) && ::uavcan::areClose(orientation_xyzw, rhs.orientation_xyzw) && ::uavcan::areClose(pose_covariance, rhs.pose_covariance) && ::uavcan::areClose(linear_velocity_body, rhs.linear_velocity_body) && ::uavcan::areClose(angular_velocity_body, rhs.angular_velocity_body) && ::uavcan::areClose(linear_acceleration_body, rhs.linear_acceleration_body) && ::uavcan::areClose(velocity_covariance, rhs.velocity_covariance); } template <int _tmpl> int GlobalNavigationSolution_<_tmpl>::encode(ParameterType self, ::uavcan::ScalarCodec& codec, ::uavcan::TailArrayOptimizationMode tao_mode) { (void)self; (void)codec; (void)tao_mode; int res = 1; res = FieldTypes::timestamp::encode(self.timestamp, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::longitude::encode(self.longitude, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::latitude::encode(self.latitude, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::height_ellipsoid::encode(self.height_ellipsoid, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::height_msl::encode(self.height_msl, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::height_agl::encode(self.height_agl, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::height_baro::encode(self.height_baro, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::qnh_hpa::encode(self.qnh_hpa, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::orientation_xyzw::encode(self.orientation_xyzw, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::pose_covariance::encode(self.pose_covariance, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::linear_velocity_body::encode(self.linear_velocity_body, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::angular_velocity_body::encode(self.angular_velocity_body, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::linear_acceleration_body::encode(self.linear_acceleration_body, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::velocity_covariance::encode(self.velocity_covariance, codec, tao_mode); return res; } template <int _tmpl> int GlobalNavigationSolution_<_tmpl>::decode(ReferenceType self, ::uavcan::ScalarCodec& codec, ::uavcan::TailArrayOptimizationMode tao_mode) { (void)self; (void)codec; (void)tao_mode; int res = 1; res = FieldTypes::timestamp::decode(self.timestamp, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::longitude::decode(self.longitude, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::latitude::decode(self.latitude, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::height_ellipsoid::decode(self.height_ellipsoid, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::height_msl::decode(self.height_msl, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::height_agl::decode(self.height_agl, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::height_baro::decode(self.height_baro, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::qnh_hpa::decode(self.qnh_hpa, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::orientation_xyzw::decode(self.orientation_xyzw, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::pose_covariance::decode(self.pose_covariance, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::linear_velocity_body::decode(self.linear_velocity_body, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::angular_velocity_body::decode(self.angular_velocity_body, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::linear_acceleration_body::decode(self.linear_acceleration_body, codec, ::uavcan::TailArrayOptDisabled); if (res <= 0) { return res; } res = FieldTypes::velocity_covariance::decode(self.velocity_covariance, codec, tao_mode); return res; } /* * Out of line type method definitions */ template <int _tmpl> ::uavcan::DataTypeSignature GlobalNavigationSolution_<_tmpl>::getDataTypeSignature() { ::uavcan::DataTypeSignature signature(0x3867B6394A0C0FFCULL); FieldTypes::timestamp::extendDataTypeSignature(signature); FieldTypes::longitude::extendDataTypeSignature(signature); FieldTypes::latitude::extendDataTypeSignature(signature); FieldTypes::height_ellipsoid::extendDataTypeSignature(signature); FieldTypes::height_msl::extendDataTypeSignature(signature); FieldTypes::height_agl::extendDataTypeSignature(signature); FieldTypes::height_baro::extendDataTypeSignature(signature); FieldTypes::qnh_hpa::extendDataTypeSignature(signature); FieldTypes::orientation_xyzw::extendDataTypeSignature(signature); FieldTypes::pose_covariance::extendDataTypeSignature(signature); FieldTypes::linear_velocity_body::extendDataTypeSignature(signature); FieldTypes::angular_velocity_body::extendDataTypeSignature(signature); FieldTypes::linear_acceleration_body::extendDataTypeSignature(signature); FieldTypes::velocity_covariance::extendDataTypeSignature(signature); return signature; } /* * Out of line constant definitions */ /* * Final typedef */ typedef GlobalNavigationSolution_<0> GlobalNavigationSolution; namespace { const ::uavcan::DefaultDataTypeRegistrator< ::uavcan::navigation::GlobalNavigationSolution > _uavcan_gdtr_registrator_GlobalNavigationSolution; } } // Namespace navigation } // Namespace uavcan /* * YAML streamer specialization */ namespace uavcan { template <> class UAVCAN_EXPORT YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution > { public: template <typename Stream> static void stream(Stream& s, ::uavcan::navigation::GlobalNavigationSolution::ParameterType obj, const int level); }; template <typename Stream> void YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution >::stream(Stream& s, ::uavcan::navigation::GlobalNavigationSolution::ParameterType obj, const int level) { (void)s; (void)obj; (void)level; if (level > 0) { s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } } s << "timestamp: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::timestamp >::stream(s, obj.timestamp, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "longitude: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::longitude >::stream(s, obj.longitude, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "latitude: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::latitude >::stream(s, obj.latitude, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "height_ellipsoid: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::height_ellipsoid >::stream(s, obj.height_ellipsoid, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "height_msl: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::height_msl >::stream(s, obj.height_msl, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "height_agl: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::height_agl >::stream(s, obj.height_agl, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "height_baro: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::height_baro >::stream(s, obj.height_baro, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "qnh_hpa: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::qnh_hpa >::stream(s, obj.qnh_hpa, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "orientation_xyzw: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::orientation_xyzw >::stream(s, obj.orientation_xyzw, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "pose_covariance: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::pose_covariance >::stream(s, obj.pose_covariance, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "linear_velocity_body: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::linear_velocity_body >::stream(s, obj.linear_velocity_body, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "angular_velocity_body: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::angular_velocity_body >::stream(s, obj.angular_velocity_body, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "linear_acceleration_body: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::linear_acceleration_body >::stream(s, obj.linear_acceleration_body, level + 1); s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } s << "velocity_covariance: "; YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution::FieldTypes::velocity_covariance >::stream(s, obj.velocity_covariance, level + 1); } } namespace uavcan { namespace navigation { template <typename Stream> inline Stream& operator<<(Stream& s, ::uavcan::navigation::GlobalNavigationSolution::ParameterType obj) { ::uavcan::YamlStreamer< ::uavcan::navigation::GlobalNavigationSolution >::stream(s, obj, 0); return s; } } // Namespace navigation } // Namespace uavcan #endif // UAVCAN_NAVIGATION_GLOBALNAVIGATIONSOLUTION_HPP_INCLUDED
[ "ruslikc@gmail.om" ]
ruslikc@gmail.om
a776cc18656a0d2be11d39746215d586b5962cd6
68faae88799da37e96c29b3c981736be51e1564a
/2.Firmware/MiniRover/Camera.h
547bdeb59858d66b299e69177ba3ba01cf371b79
[]
no_license
PP-ZhangYi/MiniRover-Hardware
1d3d83ac6cc2db70558a0fc13f3f9ec2645d45a7
bd1dba69a321c70f980c0038c96d0a0ed4c6459c
refs/heads/master
2022-12-09T05:51:38.187097
2020-09-04T09:53:31
2020-09-04T09:53:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,044
h
#ifndef CAMERA_H #define CAMERA_H #include <Arduino.h> #include "Pins.h" #include "esp_camera.h" #include "esp_http_server.h" #include "esp_timer.h" #include "img_converters.h" #include "index_page.h" #include "fb_gfx.h" #include "dl_lib_matrix3d.h" class Camera { public: Camera(); ~Camera(); void initialize(); void startCameraServer(); private: }; // Web APP stuffs typedef struct { size_t size; //number of values used for filtering size_t index; //current value index size_t count; //value count int sum; int* values; //array to be filled with values } ra_filter_t; typedef struct { httpd_req_t* req; size_t len; } jpg_chunking_t; static ra_filter_t* ra_filter_init(ra_filter_t* filter, size_t sample_size); static int ra_filter_run(ra_filter_t* filter, int value); static esp_err_t stream_handler(httpd_req_t* req); static esp_err_t cmd_handler(httpd_req_t* req); static esp_err_t status_handler(httpd_req_t* req); static esp_err_t index_handler(httpd_req_t* req); static void startCameraServer_impl(); #endif
[ "593245898@qq.com" ]
593245898@qq.com
ace309f944cf046d234d0f5ea883ef0b96dd6935
1d763c65b5ab8b567d816be9cdba4098b749fd19
/plugins/MsInfoPlugin/MsInfoCategoryModel.cpp
06348e1cfd48030efda1411e77b85efda33d6801
[]
no_license
sckomoroh/InfoView
af01a35632616a0e3a5a166c7e3d906fa191a9d1
b1370b660821c1569c3c19c1d39eb18f5d3667bb
refs/heads/develop
2020-05-17T07:56:42.781228
2015-09-07T15:48:17
2015-09-07T15:48:17
40,727,340
2
0
null
2015-09-07T15:48:18
2015-08-14T17:23:28
C++
UTF-8
C++
false
false
2,736
cpp
#include "MsInfoCategoryModel.h" MsInfoCategoryModel::MsInfoCategoryModel(QObject *parent) : QAbstractItemModel(parent) , rootCategory(NULL) { } MsInfoCategoryModel::~MsInfoCategoryModel() { } void MsInfoCategoryModel::setRootCategory(const MsInfoCategory* rootCategory) { beginResetModel(); this->rootCategory = rootCategory; endResetModel(); } void MsInfoCategoryModel::reset() { beginResetModel(); rootCategory = NULL; endResetModel(); } QModelIndex MsInfoCategoryModel::index(int row, int column, const QModelIndex& parent/* = QModelIndex()*/) const { if (!hasIndex(row, column, parent)) { return QModelIndex(); } const MsInfoCategory* parentItem = NULL; if (!parent.isValid()) { parentItem = rootCategory; } else { parentItem = static_cast<MsInfoCategory*>(parent.internalPointer()); } MsInfoCategory *childItem = parentItem->categories().at(row); if (childItem) { return createIndex(row, column, childItem); } else { return QModelIndex(); } } int MsInfoCategoryModel::columnCount(const QModelIndex& parent/* = QModelIndex()*/) const { return 1; } QVariant MsInfoCategoryModel::data(const QModelIndex& index, int role/* = Qt::DisplayRole*/) const { if (role != Qt::DisplayRole) { return QVariant(); } MsInfoCategory* item = rawData(index); if (item == NULL) { return QVariant(); } return item->categoryName(); } QModelIndex MsInfoCategoryModel::parent(const QModelIndex& index) const { if (!index.isValid()) { return QModelIndex(); } MsInfoCategory* childItem = static_cast<MsInfoCategory*>(index.internalPointer()); const MsInfoCategory* parentItem = childItem->parent(); if (parentItem == rootCategory) { return QModelIndex(); } return createIndex(parentItem->row(), 0, (void*)parentItem); } int MsInfoCategoryModel::rowCount(const QModelIndex& parent/* = QModelIndex()*/) const { const MsInfoCategory *parentItem; if (parent.column() > 0) { return 0; } if (!parent.isValid()) { parentItem = rootCategory; } else { parentItem = static_cast<MsInfoCategory*>(parent.internalPointer()); } if (parentItem == NULL) { return 0; } return parentItem->categories().count(); } QVariant MsInfoCategoryModel::headerData(int section, Qt::Orientation orientation, int role/* = Qt::DisplayRole*/) const { if (orientation == Qt::Horizontal) { return QString("Categories"); } return QVariant(); } MsInfoCategory* MsInfoCategoryModel::rawData(const QModelIndex& index) const { if (!index.isValid()) { return NULL; } return static_cast<MsInfoCategory*>(index.internalPointer()); }
[ "egor.zvigunov@softheme.com" ]
egor.zvigunov@softheme.com
b4d3568ad87d8b9bd0b851aae4b2b60fc0c29378
a40b1aa26e7828979ed54292e891c172a7a48df3
/src/libnpepipe/request/call.cpp
7eb37f0a86cd9cbb5e2f04064d926f8ca9dc5c0e
[ "BSD-2-Clause" ]
permissive
nnoell/npe
57a1a773c50abc7bff1fd1880de8c96a258cef3e
a228dfe5f6de51cc849f2a7aaad88e8d9d5bf2eb
refs/heads/master
2020-03-31T13:19:15.430952
2018-10-09T12:59:10
2018-10-09T12:59:10
152,250,706
1
0
null
null
null
null
UTF-8
C++
false
false
1,580
cpp
// NPE PIPE public #include <npe/pipe/request/call.hpp> #include <npe/pipe/hash.hpp> namespace npe { namespace pipe { namespace request { buffer::Ptr CreateCall(Id object_id, const std::string& method_name, const void *args, std::size_t args_size, bool sync) { const DWORD total_size = 2 + sizeof(Id) + sizeof(Id) + args_size; buffer::Data buffer_data(new BYTE[total_size], std::default_delete<BYTE[]>()); BYTE *tmp = buffer_data.get(); tmp[0] = T_Call; tmp[1] = sync; // Object Id tmp += 2; std::memcpy(tmp, &object_id, sizeof(Id)); // Method name tmp += sizeof(Id); const Id method_hash = GetHash(method_name); std::memcpy(tmp, &method_hash, sizeof(Id)); // Args if (args && args_size > 0) { tmp += sizeof(Id); std::memcpy(tmp, args, args_size); } return std::make_shared<Buffer>(std::move(buffer_data), total_size); } bool ParseCall(BYTE *request, DWORD request_size, Id& object_id, Id& method_id, void *&args, std::size_t& args_size) { if (!request) return false; if (request_size < (2 + sizeof(Id) + sizeof(Id))) return false; // Object Id std::memcpy(&object_id, request + 2, sizeof(Id)); // Method Id std::memcpy(&method_id, request + 2 + sizeof(Id), sizeof(Id)); // Args args_size = request_size - (2 + sizeof(Id) + sizeof(Id)); if (args_size > 0) { args = request + 2 + sizeof(Id) + sizeof(Id); } else { args = nullptr; args_size = 0; } return true; } } // namespace request } // namespace pipe } // namespace npe
[ "nnoell3@gmail.com" ]
nnoell3@gmail.com
9a7bf6ea3932456c3fce341d980694759f98fd9f
0132ed42cdcf15cbb9c9ac45011e8fff1915642f
/refrigitz 12/syzygy/tbcore.cpp
37842229ee7792b91323aa5cd3bc8f96aa6966ca
[]
no_license
tetrashop/Refrigitz
50e79f17148f3ffcf853685f20d92ec2606489d8
92c228bd686c3f6015b539584c6f1cf82b29825b
refs/heads/Othermaster
2022-11-11T00:48:36.129583
2022-11-06T08:18:31
2022-11-06T08:18:31
200,526,050
15
1
null
2022-06-24T06:55:18
2019-08-04T18:09:11
C#
UTF-8
C++
false
false
35,823
cpp
/* Copyright (c) 2011-2013 Ronald de Man This file may be redistributed and/or modified without restrictions. tbcore.c contains engine-independent routines of the tablebase probing code. This file should not need too much adaptation to add tablebase probing to a particular engine, provided the engine is written in C or C++. */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <fcntl.h> #ifndef _WIN32 #include <unistd.h> #include <sys/mman.h> #endif #include "tbcore.h" #include "tbprobe.h" #define TBMAX_PIECE 254 #define TBMAX_PAWN 256 #define HSHMAX 5 #define Swap(a,b) {int tmp=a;a=b;b=tmp;} #define TB_PAWN 1 #define TB_KNIGHT 2 #define TB_BISHOP 3 #define TB_ROOK 4 #define TB_QUEEN 5 #define TB_KING 6 #define TB_WPAWN TB_PAWN #define TB_BPAWN (TB_PAWN | 8) static LOCK_T TB_mutex; static bool initialized = false; static int num_paths = 0; static char *path_string = NULL; static char **paths = NULL; static int TBnum_piece, TBnum_pawn; static struct TBEntry_piece TB_piece[TBMAX_PIECE]; static struct TBEntry_pawn TB_pawn[TBMAX_PAWN]; static struct TBHashEntry TB_hash[1 << TBHASHBITS][HSHMAX]; #define DTZ_ENTRIES 64 static struct DTZTableEntry DTZ_table[DTZ_ENTRIES]; static void init_indices(void); extern uint64 calc_key_from_pcs(int *pcs, int mirror); static void free_wdl_entry(struct TBEntry *entry); static void free_dtz_entry(struct TBEntry *entry); static FD open_tb(const char *str, const char *suffix) { int i; FD fd; char file[256]; for (i = 0; i < num_paths; i++) { strcpy(file, paths[i]); strcat(file, "/"); strcat(file, str); strcat(file, suffix); #ifndef _WIN32 fd = open(file, O_RDONLY); #else fd = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); #endif if (fd != FD_ERR) return fd; } return FD_ERR; } static void close_tb(FD fd) { #ifndef _WIN32 close(fd); #else CloseHandle(fd); #endif } static char *map_file(const char *name, const char *suffix, uint64 *mapping) { FD fd = open_tb(name, suffix); if (fd == FD_ERR) return NULL; #ifndef _WIN32 struct stat statbuf; fstat(fd, &statbuf); *mapping = statbuf.st_size; char *data = (char *)mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0); if (data == (char *)(-1)) { printf("Could not mmap() %s.\n", name); exit(1); } #else DWORD size_low, size_high; size_low = GetFileSize(fd, &size_high); // *size = ((uint64)size_high) << 32 | ((uint64)size_low); HANDLE map = CreateFileMapping(fd, NULL, PAGE_READONLY, size_high, size_low, NULL); if (map == NULL) { printf("CreateFileMapping() failed.\n"); exit(1); } *mapping = (uint64)map; char *data = (char *)MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0); if (data == NULL) { printf("MapViewOfFile() failed, name = %s%s, error = %lu.\n", name, suffix, GetLastError()); exit(1); } #endif close_tb(fd); return data; } #ifndef _WIN32 static void unmap_file(char *data, uint64 size) { if (!data) return; munmap(data, size); } #else static void unmap_file(char *data, uint64 mapping) { if (!data) return; UnmapViewOfFile(data); CloseHandle((HANDLE)mapping); } #endif static void add_to_hash(struct TBEntry *ptr, uint64 key) { int i, hshidx; hshidx = key >> (64 - TBHASHBITS); i = 0; while (i < HSHMAX && TB_hash[hshidx][i].ptr) i++; if (i == HSHMAX) { printf("HSHMAX too low!\n"); exit(1); } else { TB_hash[hshidx][i].key = key; TB_hash[hshidx][i].ptr = ptr; } } static char pchr[] = {'K', 'Q', 'R', 'B', 'N', 'P'}; static void init_tb(char *str) { FD fd; struct TBEntry *entry; int i, j, pcs[16]; uint64 key, key2; int color; char *s; fd = open_tb(str, WDLSUFFIX); if (fd == FD_ERR) return; close_tb(fd); for (i = 0; i < 16; i++) pcs[i] = 0; color = 0; for (s = str; *s; s++) switch (*s) { case 'P': pcs[TB_PAWN | color]++; break; case 'N': pcs[TB_KNIGHT | color]++; break; case 'B': pcs[TB_BISHOP | color]++; break; case 'R': pcs[TB_ROOK | color]++; break; case 'Q': pcs[TB_QUEEN | color]++; break; case 'K': pcs[TB_KING | color]++; break; case 'v': color = 0x08; break; } for (i = 0; i < 8; i++) if (pcs[i] != pcs[i+8]) break; key = calc_key_from_pcs(pcs, 0); key2 = calc_key_from_pcs(pcs, 1); if (pcs[TB_WPAWN] + pcs[TB_BPAWN] == 0) { if (TBnum_piece == TBMAX_PIECE) { printf("TBMAX_PIECE limit too low!\n"); exit(1); } entry = (struct TBEntry *)&TB_piece[TBnum_piece++]; } else { if (TBnum_pawn == TBMAX_PAWN) { printf("TBMAX_PAWN limit too low!\n"); exit(1); } entry = (struct TBEntry *)&TB_pawn[TBnum_pawn++]; } entry->key = key; entry->ready = 0; entry->num = 0; for (i = 0; i < 16; i++) entry->num += (ubyte)pcs[i]; entry->symmetric = (key == key2); entry->has_pawns = (pcs[TB_WPAWN] + pcs[TB_BPAWN] > 0); if (entry->num > Tablebases::MaxCardinality) Tablebases::MaxCardinality = entry->num; if (entry->has_pawns) { struct TBEntry_pawn *ptr = (struct TBEntry_pawn *)entry; ptr->pawns[0] = (ubyte)pcs[TB_WPAWN]; ptr->pawns[1] = (ubyte)pcs[TB_BPAWN]; if (pcs[TB_BPAWN] > 0 && (pcs[TB_WPAWN] == 0 || pcs[TB_BPAWN] < pcs[TB_WPAWN])) { ptr->pawns[0] = (ubyte)pcs[TB_BPAWN]; ptr->pawns[1] = (ubyte)pcs[TB_WPAWN]; } } else { struct TBEntry_piece *ptr = (struct TBEntry_piece *)entry; for (i = 0, j = 0; i < 16; i++) if (pcs[i] == 1) j++; if (j >= 3) ptr->enc_type = 0; else if (j == 2) ptr->enc_type = 2; else { /* only for suicide */ j = 16; for (i = 0; i < 16; i++) { if (pcs[i] < j && pcs[i] > 1) j = pcs[i]; ptr->enc_type = ubyte(1 + j); } } } add_to_hash(entry, key); if (key2 != key) add_to_hash(entry, key2); } inline void Tablebases::init(const std::string& path) { char str[16]; int i, j, k, l; if (initialized) { free(path_string); free(paths); struct TBEntry *entry; for (i = 0; i < TBnum_piece; i++) { entry = (struct TBEntry *)&TB_piece[i]; free_wdl_entry(entry); } for (i = 0; i < TBnum_pawn; i++) { entry = (struct TBEntry *)&TB_pawn[i]; free_wdl_entry(entry); } for (i = 0; i < DTZ_ENTRIES; i++) if (DTZ_table[i].entry) free_dtz_entry(DTZ_table[i].entry); } else { init_indices(); initialized = true; } const char *p = path.c_str(); if (strlen(p) == 0 || !strcmp(p, "<empty>")) return; path_string = (char *)malloc(strlen(p) + 1); strcpy(path_string, p); num_paths = 0; for (i = 0;; i++) { if (path_string[i] != SEP_CHAR) num_paths++; while (path_string[i] && path_string[i] != SEP_CHAR) i++; if (!path_string[i]) break; path_string[i] = 0; } paths = (char **)malloc(num_paths * sizeof(char *)); for (i = j = 0; i < num_paths; i++) { while (!path_string[j]) j++; paths[i] = &path_string[j]; while (path_string[j]) j++; } LOCK_INIT(TB_mutex); TBnum_piece = TBnum_pawn = 0; MaxCardinality = 0; for (i = 0; i < (1 << TBHASHBITS); i++) for (j = 0; j < HSHMAX; j++) { TB_hash[i][j].key = 0ULL; TB_hash[i][j].ptr = NULL; } for (i = 0; i < DTZ_ENTRIES; i++) DTZ_table[i].entry = NULL; for (i = 1; i < 6; i++) { sprintf(str, "K%cvK", pchr[i]); init_tb(str); } for (i = 1; i < 6; i++) for (j = i; j < 6; j++) { sprintf(str, "K%cvK%c", pchr[i], pchr[j]); init_tb(str); } for (i = 1; i < 6; i++) for (j = i; j < 6; j++) { sprintf(str, "K%c%cvK", pchr[i], pchr[j]); init_tb(str); } for (i = 1; i < 6; i++) for (j = i; j < 6; j++) for (k = 1; k < 6; k++) { sprintf(str, "K%c%cvK%c", pchr[i], pchr[j], pchr[k]); init_tb(str); } for (i = 1; i < 6; i++) for (j = i; j < 6; j++) for (k = j; k < 6; k++) { sprintf(str, "K%c%c%cvK", pchr[i], pchr[j], pchr[k]); init_tb(str); } for (i = 1; i < 6; i++) for (j = i; j < 6; j++) for (k = i; k < 6; k++) for (l = (i == k) ? j : k; l < 6; l++) { sprintf(str, "K%c%cvK%c%c", pchr[i], pchr[j], pchr[k], pchr[l]); init_tb(str); } for (i = 1; i < 6; i++) for (j = i; j < 6; j++) for (k = j; k < 6; k++) for (l = 1; l < 6; l++) { sprintf(str, "K%c%c%cvK%c", pchr[i], pchr[j], pchr[k], pchr[l]); init_tb(str); } for (i = 1; i < 6; i++) for (j = i; j < 6; j++) for (k = j; k < 6; k++) for (l = k; l < 6; l++) { sprintf(str, "K%c%c%c%cvK", pchr[i], pchr[j], pchr[k], pchr[l]); init_tb(str); } printf("info string Found %d tablebases.\n", TBnum_piece + TBnum_pawn); } static const signed char offdiag[] = { 0,-1,-1,-1,-1,-1,-1,-1, 1, 0,-1,-1,-1,-1,-1,-1, 1, 1, 0,-1,-1,-1,-1,-1, 1, 1, 1, 0,-1,-1,-1,-1, 1, 1, 1, 1, 0,-1,-1,-1, 1, 1, 1, 1, 1, 0,-1,-1, 1, 1, 1, 1, 1, 1, 0,-1, 1, 1, 1, 1, 1, 1, 1, 0 }; static const ubyte triangle[] = { 6, 0, 1, 2, 2, 1, 0, 6, 0, 7, 3, 4, 4, 3, 7, 0, 1, 3, 8, 5, 5, 8, 3, 1, 2, 4, 5, 9, 9, 5, 4, 2, 2, 4, 5, 9, 9, 5, 4, 2, 1, 3, 8, 5, 5, 8, 3, 1, 0, 7, 3, 4, 4, 3, 7, 0, 6, 0, 1, 2, 2, 1, 0, 6 }; static const ubyte invtriangle[] = { 1, 2, 3, 10, 11, 19, 0, 9, 18, 27 }; static const ubyte invdiag[] = { 0, 9, 18, 27, 36, 45, 54, 63, 7, 14, 21, 28, 35, 42, 49, 56 }; static const ubyte flipdiag[] = { 0, 8, 16, 24, 32, 40, 48, 56, 1, 9, 17, 25, 33, 41, 49, 57, 2, 10, 18, 26, 34, 42, 50, 58, 3, 11, 19, 27, 35, 43, 51, 59, 4, 12, 20, 28, 36, 44, 52, 60, 5, 13, 21, 29, 37, 45, 53, 61, 6, 14, 22, 30, 38, 46, 54, 62, 7, 15, 23, 31, 39, 47, 55, 63 }; static const ubyte lower[] = { 28, 0, 1, 2, 3, 4, 5, 6, 0, 29, 7, 8, 9, 10, 11, 12, 1, 7, 30, 13, 14, 15, 16, 17, 2, 8, 13, 31, 18, 19, 20, 21, 3, 9, 14, 18, 32, 22, 23, 24, 4, 10, 15, 19, 22, 33, 25, 26, 5, 11, 16, 20, 23, 25, 34, 27, 6, 12, 17, 21, 24, 26, 27, 35 }; static const ubyte diag[] = { 0, 0, 0, 0, 0, 0, 0, 8, 0, 1, 0, 0, 0, 0, 9, 0, 0, 0, 2, 0, 0, 10, 0, 0, 0, 0, 0, 3, 11, 0, 0, 0, 0, 0, 0, 12, 4, 0, 0, 0, 0, 0, 13, 0, 0, 5, 0, 0, 0, 14, 0, 0, 0, 0, 6, 0, 15, 0, 0, 0, 0, 0, 0, 7 }; static const ubyte flap[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 12, 18, 18, 12, 6, 0, 1, 7, 13, 19, 19, 13, 7, 1, 2, 8, 14, 20, 20, 14, 8, 2, 3, 9, 15, 21, 21, 15, 9, 3, 4, 10, 16, 22, 22, 16, 10, 4, 5, 11, 17, 23, 23, 17, 11, 5, 0, 0, 0, 0, 0, 0, 0, 0 }; static const ubyte ptwist[] = { 0, 0, 0, 0, 0, 0, 0, 0, 47, 35, 23, 11, 10, 22, 34, 46, 45, 33, 21, 9, 8, 20, 32, 44, 43, 31, 19, 7, 6, 18, 30, 42, 41, 29, 17, 5, 4, 16, 28, 40, 39, 27, 15, 3, 2, 14, 26, 38, 37, 25, 13, 1, 0, 12, 24, 36, 0, 0, 0, 0, 0, 0, 0, 0 }; static const ubyte invflap[] = { 8, 16, 24, 32, 40, 48, 9, 17, 25, 33, 41, 49, 10, 18, 26, 34, 42, 50, 11, 19, 27, 35, 43, 51 }; static const ubyte invptwist[] = { 52, 51, 44, 43, 36, 35, 28, 27, 20, 19, 12, 11, 53, 50, 45, 42, 37, 34, 29, 26, 21, 18, 13, 10, 54, 49, 46, 41, 38, 33, 30, 25, 22, 17, 14, 9, 55, 48, 47, 40, 39, 32, 31, 24, 23, 16, 15, 8 }; static const ubyte file_to_file[] = { 0, 1, 2, 3, 3, 2, 1, 0 }; static const short KK_idx[10][64] = { { -1, -1, -1, 0, 1, 2, 3, 4, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 }, { 58, -1, -1, -1, 59, 60, 61, 62, 63, -1, -1, -1, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,101,102,103,104,105,106,107, 108,109,110,111,112,113,114,115}, {116,117, -1, -1, -1,118,119,120, 121,122, -1, -1, -1,123,124,125, 126,127,128,129,130,131,132,133, 134,135,136,137,138,139,140,141, 142,143,144,145,146,147,148,149, 150,151,152,153,154,155,156,157, 158,159,160,161,162,163,164,165, 166,167,168,169,170,171,172,173 }, {174, -1, -1, -1,175,176,177,178, 179, -1, -1, -1,180,181,182,183, 184, -1, -1, -1,185,186,187,188, 189,190,191,192,193,194,195,196, 197,198,199,200,201,202,203,204, 205,206,207,208,209,210,211,212, 213,214,215,216,217,218,219,220, 221,222,223,224,225,226,227,228 }, {229,230, -1, -1, -1,231,232,233, 234,235, -1, -1, -1,236,237,238, 239,240, -1, -1, -1,241,242,243, 244,245,246,247,248,249,250,251, 252,253,254,255,256,257,258,259, 260,261,262,263,264,265,266,267, 268,269,270,271,272,273,274,275, 276,277,278,279,280,281,282,283 }, {284,285,286,287,288,289,290,291, 292,293, -1, -1, -1,294,295,296, 297,298, -1, -1, -1,299,300,301, 302,303, -1, -1, -1,304,305,306, 307,308,309,310,311,312,313,314, 315,316,317,318,319,320,321,322, 323,324,325,326,327,328,329,330, 331,332,333,334,335,336,337,338 }, { -1, -1,339,340,341,342,343,344, -1, -1,345,346,347,348,349,350, -1, -1,441,351,352,353,354,355, -1, -1, -1,442,356,357,358,359, -1, -1, -1, -1,443,360,361,362, -1, -1, -1, -1, -1,444,363,364, -1, -1, -1, -1, -1, -1,445,365, -1, -1, -1, -1, -1, -1, -1,446 }, { -1, -1, -1,366,367,368,369,370, -1, -1, -1,371,372,373,374,375, -1, -1, -1,376,377,378,379,380, -1, -1, -1,447,381,382,383,384, -1, -1, -1, -1,448,385,386,387, -1, -1, -1, -1, -1,449,388,389, -1, -1, -1, -1, -1, -1,450,390, -1, -1, -1, -1, -1, -1, -1,451 }, {452,391,392,393,394,395,396,397, -1, -1, -1, -1,398,399,400,401, -1, -1, -1, -1,402,403,404,405, -1, -1, -1, -1,406,407,408,409, -1, -1, -1, -1,453,410,411,412, -1, -1, -1, -1, -1,454,413,414, -1, -1, -1, -1, -1, -1,455,415, -1, -1, -1, -1, -1, -1, -1,456 }, {457,416,417,418,419,420,421,422, -1,458,423,424,425,426,427,428, -1, -1, -1, -1, -1,429,430,431, -1, -1, -1, -1, -1,432,433,434, -1, -1, -1, -1, -1,435,436,437, -1, -1, -1, -1, -1,459,438,439, -1, -1, -1, -1, -1, -1,460,440, -1, -1, -1, -1, -1, -1, -1,461 } }; static int binomial[5][64]; static int pawnidx[5][24]; static int pfactor[5][4]; static void init_indices(void) { int i, j, k; // binomial[k-1][n] = Bin(n, k) for (i = 0; i < 5; i++) for (j = 0; j < 64; j++) { int f = j; int l = 1; for (k = 1; k <= i; k++) { f *= (j - k); l *= (k + 1); } binomial[i][j] = f / l; } for (i = 0; i < 5; i++) { int s = 0; for (j = 0; j < 6; j++) { pawnidx[i][j] = s; s += (i == 0) ? 1 : binomial[i - 1][ptwist[invflap[j]]]; } pfactor[i][0] = s; s = 0; for (; j < 12; j++) { pawnidx[i][j] = s; s += (i == 0) ? 1 : binomial[i - 1][ptwist[invflap[j]]]; } pfactor[i][1] = s; s = 0; for (; j < 18; j++) { pawnidx[i][j] = s; s += (i == 0) ? 1 : binomial[i - 1][ptwist[invflap[j]]]; } pfactor[i][2] = s; s = 0; for (; j < 24; j++) { pawnidx[i][j] = s; s += (i == 0) ? 1 : binomial[i - 1][ptwist[invflap[j]]]; } pfactor[i][3] = s; } } static uint64 encode_piece(struct TBEntry_piece *ptr, ubyte *norm, int *pos, int *factor) { uint64 idx; int i, j, k, m, l, p; int n = ptr->num; if (pos[0] & 0x04) { for (i = 0; i < n; i++) pos[i] ^= 0x07; } if (pos[0] & 0x20) { for (i = 0; i < n; i++) pos[i] ^= 0x38; } for (i = 0; i < n; i++) if (offdiag[pos[i]]) break; if (i < (ptr->enc_type == 0 ? 3 : 2) && offdiag[pos[i]] > 0) for (i = 0; i < n; i++) pos[i] = flipdiag[pos[i]]; switch (ptr->enc_type) { case 0: /* 111 */ i = (pos[1] > pos[0]); j = (pos[2] > pos[0]) + (pos[2] > pos[1]); if (offdiag[pos[0]]) idx = triangle[pos[0]] * 63*62 + (pos[1] - i) * 62 + (pos[2] - j); else if (offdiag[pos[1]]) idx = 6*63*62 + diag[pos[0]] * 28*62 + lower[pos[1]] * 62 + pos[2] - j; else if (offdiag[pos[2]]) idx = 6*63*62 + 4*28*62 + (diag[pos[0]]) * 7*28 + (diag[pos[1]] - i) * 28 + lower[pos[2]]; else idx = 6*63*62 + 4*28*62 + 4*7*28 + (diag[pos[0]] * 7*6) + (diag[pos[1]] - i) * 6 + (diag[pos[2]] - j); i = 3; break; case 1: /* K3 */ j = (pos[2] > pos[0]) + (pos[2] > pos[1]); idx = KK_idx[triangle[pos[0]]][pos[1]]; if (idx < 441) idx = idx + 441 * (pos[2] - j); else { idx = 441*62 + (idx - 441) + 21 * lower[pos[2]]; if (!offdiag[pos[2]]) idx -= j * 21; } i = 3; break; default: /* K2 */ idx = KK_idx[triangle[pos[0]]][pos[1]]; i = 2; break; } idx *= factor[0]; for (; i < n;) { int t = norm[i]; for (j = i; j < i + t; j++) for (k = j + 1; k < i + t; k++) if (pos[j] > pos[k]) Swap(pos[j], pos[k]); int s = 0; for (m = i; m < i + t; m++) { p = pos[m]; for (l = 0, j = 0; l < i; l++) j += (p > pos[l]); s += binomial[m - i][p - j]; } idx += ((uint64)s) * ((uint64)factor[i]); i += t; } return idx; } // determine file of leftmost pawn and sort pawns static int pawn_file(struct TBEntry_pawn *ptr, int *pos) { int i; for (i = 1; i < ptr->pawns[0]; i++) if (flap[pos[0]] > flap[pos[i]]) Swap(pos[0], pos[i]); return file_to_file[pos[0] & 0x07]; } static uint64 encode_pawn(struct TBEntry_pawn *ptr, ubyte *norm, int *pos, int *factor) { uint64 idx; int i, j, k, m, s, t; int n = ptr->num; if (pos[0] & 0x04) for (i = 0; i < n; i++) pos[i] ^= 0x07; for (i = 1; i < ptr->pawns[0]; i++) for (j = i + 1; j < ptr->pawns[0]; j++) if (ptwist[pos[i]] < ptwist[pos[j]]) Swap(pos[i], pos[j]); t = ptr->pawns[0] - 1; idx = pawnidx[t][flap[pos[0]]]; for (i = t; i > 0; i--) idx += binomial[t - i][ptwist[pos[i]]]; idx *= factor[0]; // remaining pawns i = ptr->pawns[0]; t = i + ptr->pawns[1]; if (t > i) { for (j = i; j < t; j++) for (k = j + 1; k < t; k++) if (pos[j] > pos[k]) Swap(pos[j], pos[k]); s = 0; for (m = i; m < t; m++) { int p = pos[m]; for (k = 0, j = 0; k < i; k++) j += (p > pos[k]); s += binomial[m - i][p - j - 8]; } idx += ((uint64)s) * ((uint64)factor[i]); i = t; } for (; i < n;) { t = norm[i]; for (j = i; j < i + t; j++) for (k = j + 1; k < i + t; k++) if (pos[j] > pos[k]) Swap(pos[j], pos[k]); s = 0; for (m = i; m < i + t; m++) { int p = pos[m]; for (k = 0, j = 0; k < i; k++) j += (p > pos[k]); s += binomial[m - i][p - j]; } idx += ((uint64)s) * ((uint64)factor[i]); i += t; } return idx; } // place k like pieces on n squares static int subfactor(int k, int n) { int i, f, l; f = n; l = 1; for (i = 1; i < k; i++) { f *= n - i; l *= i + 1; } return f / l; } static uint64 calc_factors_piece(int *factor, int num, int order, ubyte *norm, ubyte enc_type) { int i, k, n; uint64 f; static int pivfac[] = { 31332, 28056, 462 }; n = 64 - norm[0]; f = 1; for (i = norm[0], k = 0; i < num || k == order; k++) { if (k == order) { factor[0] = static_cast<int>(f); f *= pivfac[enc_type]; } else { factor[i] = static_cast<int>(f); f *= subfactor(norm[i], n); n -= norm[i]; i += norm[i]; } } return f; } static uint64 calc_factors_pawn(int *factor, int num, int order, int order2, ubyte *norm, int file) { int i, k, n; uint64 f; i = norm[0]; if (order2 < 0x0f) i += norm[i]; n = 64 - i; f = 1; for (k = 0; i < num || k == order || k == order2; k++) { if (k == order) { factor[0] = static_cast<int>(f); f *= pfactor[norm[0] - 1][file]; } else if (k == order2) { factor[norm[0]] = static_cast<int>(f); f *= subfactor(norm[norm[0]], 48 - norm[0]); } else { factor[i] = static_cast<int>(f); f *= subfactor(norm[i], n); n -= norm[i]; i += norm[i]; } } return f; } static void set_norm_piece(struct TBEntry_piece *ptr, ubyte *norm, ubyte *pieces) { int i, j; for (i = 0; i < ptr->num; i++) norm[i] = 0; switch (ptr->enc_type) { case 0: norm[0] = 3; break; case 2: norm[0] = 2; break; default: norm[0] = ubyte(ptr->enc_type - 1); break; } for (i = norm[0]; i < ptr->num; i += norm[i]) for (j = i; j < ptr->num && pieces[j] == pieces[i]; j++) norm[i]++; } static void set_norm_pawn(struct TBEntry_pawn *ptr, ubyte *norm, ubyte *pieces) { int i, j; for (i = 0; i < ptr->num; i++) norm[i] = 0; norm[0] = ptr->pawns[0]; if (ptr->pawns[1]) norm[ptr->pawns[0]] = ptr->pawns[1]; for (i = ptr->pawns[0] + ptr->pawns[1]; i < ptr->num; i += norm[i]) for (j = i; j < ptr->num && pieces[j] == pieces[i]; j++) norm[i]++; } static void setup_pieces_piece(struct TBEntry_piece *ptr, unsigned char *data, uint64 *tb_size) { int i; int order; for (i = 0; i < ptr->num; i++) ptr->pieces[0][i] = ubyte(data[i + 1] & 0x0f); order = data[0] & 0x0f; set_norm_piece(ptr, ptr->norm[0], ptr->pieces[0]); tb_size[0] = calc_factors_piece(ptr->factor[0], ptr->num, order, ptr->norm[0], ptr->enc_type); for (i = 0; i < ptr->num; i++) ptr->pieces[1][i] = ubyte(data[i + 1] >> 4); order = data[0] >> 4; set_norm_piece(ptr, ptr->norm[1], ptr->pieces[1]); tb_size[1] = calc_factors_piece(ptr->factor[1], ptr->num, order, ptr->norm[1], ptr->enc_type); } static void setup_pieces_piece_dtz(struct DTZEntry_piece *ptr, unsigned char *data, uint64 *tb_size) { int i; int order; for (i = 0; i < ptr->num; i++) ptr->pieces[i] = ubyte(data[i + 1] & 0x0f); order = data[0] & 0x0f; set_norm_piece((struct TBEntry_piece *)ptr, ptr->norm, ptr->pieces); tb_size[0] = calc_factors_piece(ptr->factor, ptr->num, order, ptr->norm, ptr->enc_type); } static void setup_pieces_pawn(struct TBEntry_pawn *ptr, unsigned char *data, uint64 *tb_size, int f) { int i, j; int order, order2; j = 1 + (ptr->pawns[1] > 0); order = data[0] & 0x0f; order2 = ptr->pawns[1] ? (data[1] & 0x0f) : 0x0f; for (i = 0; i < ptr->num; i++) ptr->file[f].pieces[0][i] = ubyte(data[i + j] & 0x0f); set_norm_pawn(ptr, ptr->file[f].norm[0], ptr->file[f].pieces[0]); tb_size[0] = calc_factors_pawn(ptr->file[f].factor[0], ptr->num, order, order2, ptr->file[f].norm[0], f); order = data[0] >> 4; order2 = ptr->pawns[1] ? (data[1] >> 4) : 0x0f; for (i = 0; i < ptr->num; i++) ptr->file[f].pieces[1][i] = ubyte(data[i + j] >> 4); set_norm_pawn(ptr, ptr->file[f].norm[1], ptr->file[f].pieces[1]); tb_size[1] = calc_factors_pawn(ptr->file[f].factor[1], ptr->num, order, order2, ptr->file[f].norm[1], f); } static void setup_pieces_pawn_dtz(struct DTZEntry_pawn *ptr, unsigned char *data, uint64 *tb_size, int f) { int i, j; int order, order2; j = 1 + (ptr->pawns[1] > 0); order = data[0] & 0x0f; order2 = ptr->pawns[1] ? (data[1] & 0x0f) : 0x0f; for (i = 0; i < ptr->num; i++) ptr->file[f].pieces[i] = ubyte(data[i + j] & 0x0f); set_norm_pawn((struct TBEntry_pawn *)ptr, ptr->file[f].norm, ptr->file[f].pieces); tb_size[0] = calc_factors_pawn(ptr->file[f].factor, ptr->num, order, order2, ptr->file[f].norm, f); } static void calc_symlen(struct PairsData *d, int s, char *tmp) { int s1, s2; ubyte* w = d->sympat + 3 * s; s2 = (w[2] << 4) | (w[1] >> 4); if (s2 == 0x0fff) d->symlen[s] = 0; else { s1 = ((w[1] & 0xf) << 8) | w[0]; if (!tmp[s1]) calc_symlen(d, s1, tmp); if (!tmp[s2]) calc_symlen(d, s2, tmp); d->symlen[s] = ubyte(d->symlen[s1] + d->symlen[s2] + 1); } tmp[s] = 1; } static ushort ReadUshort(ubyte* d) { return ushort(d[0] | (d[1] << 8)); } static uint32 ReadUint32(ubyte* d) { return d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24); } static struct PairsData *setup_pairs(unsigned char *data, uint64 tb_size, uint64 *size, unsigned char **next, ubyte *flags, int wdl) { struct PairsData *d; int i; *flags = data[0]; if (data[0] & 0x80) { d = (struct PairsData *)malloc(sizeof(struct PairsData)); d->idxbits = 0; if (wdl) d->min_len = data[1]; else d->min_len = 0; *next = data + 2; size[0] = size[1] = size[2] = 0; return d; } int blocksize = data[1]; int idxbits = data[2]; int real_num_blocks = ReadUint32(&data[4]); int num_blocks = real_num_blocks + *(ubyte *)(&data[3]); int max_len = data[8]; int min_len = data[9]; int h = max_len - min_len + 1; int num_syms = ReadUshort(&data[10 + 2 * h]); d = (struct PairsData *)malloc(sizeof(struct PairsData) + (h - 1) * sizeof(base_t) + num_syms); d->blocksize = blocksize; d->idxbits = idxbits; d->offset = (ushort*)(&data[10]); d->symlen = ((ubyte *)d) + sizeof(struct PairsData) + (h - 1) * sizeof(base_t); d->sympat = &data[12 + 2 * h]; d->min_len = min_len; *next = &data[12 + 2 * h + 3 * num_syms + (num_syms & 1)]; uint64 num_indices = (tb_size + (1ULL << idxbits) - 1) >> idxbits; size[0] = 6ULL * num_indices; size[1] = 2ULL * num_blocks; size[2] = (1ULL << blocksize) * real_num_blocks; // char tmp[num_syms]; char tmp[4096]; for (i = 0; i < num_syms; i++) tmp[i] = 0; for (i = 0; i < num_syms; i++) if (!tmp[i]) calc_symlen(d, i, tmp); d->base[h - 1] = 0; for (i = h - 2; i >= 0; i--) d->base[i] = (d->base[i + 1] + ReadUshort((ubyte*)(d->offset + i)) - ReadUshort((ubyte*)(d->offset + i + 1))) / 2; for (i = 0; i < h; i++) d->base[i] <<= 64 - (min_len + i); d->offset -= d->min_len; return d; } static int init_table_wdl(struct TBEntry *entry, char *str) { ubyte *next; int f, s; uint64 tb_size[8]; uint64 size[8 * 3]; ubyte flags; // first mmap the table into memory entry->data = map_file(str, WDLSUFFIX, &entry->mapping); if (!entry->data) { printf("Could not find %s" WDLSUFFIX, str); return 0; } ubyte *data = (ubyte *)entry->data; if (data[0] != WDL_MAGIC[0] || data[1] != WDL_MAGIC[1] || data[2] != WDL_MAGIC[2] || data[3] != WDL_MAGIC[3]) { printf("Corrupted table.\n"); unmap_file(entry->data, entry->mapping); entry->data = 0; return 0; } int split = data[4] & 0x01; int files = data[4] & 0x02 ? 4 : 1; data += 5; if (!entry->has_pawns) { struct TBEntry_piece *ptr = (struct TBEntry_piece *)entry; setup_pieces_piece(ptr, data, &tb_size[0]); data += ptr->num + 1; data += ((uintptr_t)data) & 0x01; ptr->precomp[0] = setup_pairs(data, tb_size[0], &size[0], &next, &flags, 1); data = next; if (split) { ptr->precomp[1] = setup_pairs(data, tb_size[1], &size[3], &next, &flags, 1); data = next; } else ptr->precomp[1] = NULL; ptr->precomp[0]->indextable = (char *)data; data += size[0]; if (split) { ptr->precomp[1]->indextable = (char *)data; data += size[3]; } ptr->precomp[0]->sizetable = (ushort *)data; data += size[1]; if (split) { ptr->precomp[1]->sizetable = (ushort *)data; data += size[4]; } data = (ubyte *)((((uintptr_t)data) + 0x3f) & ~0x3f); ptr->precomp[0]->data = data; data += size[2]; if (split) { data = (ubyte *)((((uintptr_t)data) + 0x3f) & ~0x3f); ptr->precomp[1]->data = data; } } else { struct TBEntry_pawn *ptr = (struct TBEntry_pawn *)entry; s = 1 + (ptr->pawns[1] > 0); for (f = 0; f < 4; f++) { setup_pieces_pawn((struct TBEntry_pawn *)ptr, data, &tb_size[2 * f], f); data += ptr->num + s; } data += ((uintptr_t)data) & 0x01; for (f = 0; f < files; f++) { ptr->file[f].precomp[0] = setup_pairs(data, tb_size[2 * f], &size[6 * f], &next, &flags, 1); data = next; if (split) { ptr->file[f].precomp[1] = setup_pairs(data, tb_size[2 * f + 1], &size[6 * f + 3], &next, &flags, 1); data = next; } else ptr->file[f].precomp[1] = NULL; } for (f = 0; f < files; f++) { ptr->file[f].precomp[0]->indextable = (char *)data; data += size[6 * f]; if (split) { ptr->file[f].precomp[1]->indextable = (char *)data; data += size[6 * f + 3]; } } for (f = 0; f < files; f++) { ptr->file[f].precomp[0]->sizetable = (ushort *)data; data += size[6 * f + 1]; if (split) { ptr->file[f].precomp[1]->sizetable = (ushort *)data; data += size[6 * f + 4]; } } for (f = 0; f < files; f++) { data = (ubyte *)((((uintptr_t)data) + 0x3f) & ~0x3f); ptr->file[f].precomp[0]->data = data; data += size[6 * f + 2]; if (split) { data = (ubyte *)((((uintptr_t)data) + 0x3f) & ~0x3f); ptr->file[f].precomp[1]->data = data; data += size[6 * f + 5]; } } } return 1; } static int init_table_dtz(struct TBEntry *entry) { ubyte *data = (ubyte *)entry->data; ubyte *next; int f, s; uint64 tb_size[4]; uint64 size[4 * 3]; if (!data) return 0; if (data[0] != DTZ_MAGIC[0] || data[1] != DTZ_MAGIC[1] || data[2] != DTZ_MAGIC[2] || data[3] != DTZ_MAGIC[3]) { printf("Corrupted table.\n"); return 0; } int files = data[4] & 0x02 ? 4 : 1; data += 5; if (!entry->has_pawns) { struct DTZEntry_piece *ptr = (struct DTZEntry_piece *)entry; setup_pieces_piece_dtz(ptr, data, &tb_size[0]); data += ptr->num + 1; data += ((uintptr_t)data) & 0x01; ptr->precomp = setup_pairs(data, tb_size[0], &size[0], &next, &(ptr->flags), 0); data = next; ptr->map = data; if (ptr->flags & 2) { int i; for (i = 0; i < 4; i++) { ptr->map_idx[i] = static_cast<ushort>(data + 1 - ptr->map); data += 1 + data[0]; } data += ((uintptr_t)data) & 0x01; } ptr->precomp->indextable = (char *)data; data += size[0]; ptr->precomp->sizetable = (ushort *)data; data += size[1]; data = (ubyte *)((((uintptr_t)data) + 0x3f) & ~0x3f); ptr->precomp->data = data; data += size[2]; } else { struct DTZEntry_pawn *ptr = (struct DTZEntry_pawn *)entry; s = 1 + (ptr->pawns[1] > 0); for (f = 0; f < 4; f++) { setup_pieces_pawn_dtz(ptr, data, &tb_size[f], f); data += ptr->num + s; } data += ((uintptr_t)data) & 0x01; for (f = 0; f < files; f++) { ptr->file[f].precomp = setup_pairs(data, tb_size[f], &size[3 * f], &next, &(ptr->flags[f]), 0); data = next; } ptr->map = data; for (f = 0; f < files; f++) { if (ptr->flags[f] & 2) { int i; for (i = 0; i < 4; i++) { ptr->map_idx[f][i] = static_cast<ushort>(data + 1 - ptr->map); data += 1 + data[0]; } } } data += ((uintptr_t)data) & 0x01; for (f = 0; f < files; f++) { ptr->file[f].precomp->indextable = (char *)data; data += size[3 * f]; } for (f = 0; f < files; f++) { ptr->file[f].precomp->sizetable = (ushort *)data; data += size[3 * f + 1]; } for (f = 0; f < files; f++) { data = (ubyte *)((((uintptr_t)data) + 0x3f) & ~0x3f); ptr->file[f].precomp->data = data; data += size[3 * f + 2]; } } return 1; } template<bool LittleEndian> static ubyte decompress_pairs(struct PairsData *d, uint64 idx) { if (!d->idxbits) return ubyte(d->min_len); uint32 mainidx = static_cast<uint32>(idx >> d->idxbits); int litidx = (idx & ((1ULL << d->idxbits) - 1)) - (1ULL << (d->idxbits - 1)); uint32 block = *(uint32 *)(d->indextable + 6 * mainidx); if (!LittleEndian) block = BSWAP32(block); ushort idxOffset = *(ushort *)(d->indextable + 6 * mainidx + 4); if (!LittleEndian) idxOffset = ushort((idxOffset << 8) | (idxOffset >> 8)); litidx += idxOffset; if (litidx < 0) { do { litidx += d->sizetable[--block] + 1; } while (litidx < 0); } else { while (litidx > d->sizetable[block]) litidx -= d->sizetable[block++] + 1; } uint32 *ptr = (uint32 *)(d->data + (block << d->blocksize)); int m = d->min_len; ushort *offset = d->offset; base_t *base = d->base - m; ubyte *symlen = d->symlen; int sym, bitcnt; uint64 code = *((uint64 *)ptr); if (LittleEndian) code = BSWAP64(code); ptr += 2; bitcnt = 0; // number of "empty bits" in code for (;;) { int l = m; while (code < base[l]) l++; sym = offset[l]; if (!LittleEndian) sym = ((sym & 0xff) << 8) | (sym >> 8); sym += static_cast<int>((code - base[l]) >> (64 - l)); if (litidx < (int)symlen[sym] + 1) break; litidx -= (int)symlen[sym] + 1; code <<= l; bitcnt += l; if (bitcnt >= 32) { bitcnt -= 32; uint32 tmp = *ptr++; if (LittleEndian) tmp = BSWAP32(tmp); code |= ((uint64)tmp) << bitcnt; } } ubyte *sympat = d->sympat; while (symlen[sym] != 0) { ubyte* w = sympat + (3 * sym); int s1 = ((w[1] & 0xf) << 8) | w[0]; if (litidx < (int)symlen[s1] + 1) sym = s1; else { litidx -= (int)symlen[s1] + 1; sym = (w[2] << 4) | (w[1] >> 4); } } return sympat[3 * sym]; } static void load_dtz_table(char *str, uint64 key1, uint64 key2) { int i; struct TBEntry *ptr, *ptr3; struct TBHashEntry *ptr2; DTZ_table[0].key1 = key1; DTZ_table[0].key2 = key2; DTZ_table[0].entry = NULL; // find corresponding WDL entry ptr2 = TB_hash[key1 >> (64 - TBHASHBITS)]; for (i = 0; i < HSHMAX; i++) if (ptr2[i].key == key1) break; if (i == HSHMAX) return; ptr = ptr2[i].ptr; ptr3 = (struct TBEntry *)malloc(ptr->has_pawns ? sizeof(struct DTZEntry_pawn) : sizeof(struct DTZEntry_piece)); ptr3->data = map_file(str, DTZSUFFIX, &ptr3->mapping); ptr3->key = ptr->key; ptr3->num = ptr->num; ptr3->symmetric = ptr->symmetric; ptr3->has_pawns = ptr->has_pawns; if (ptr3->has_pawns) { struct DTZEntry_pawn *entry = (struct DTZEntry_pawn *)ptr3; entry->pawns[0] = ((struct TBEntry_pawn *)ptr)->pawns[0]; entry->pawns[1] = ((struct TBEntry_pawn *)ptr)->pawns[1]; } else { struct DTZEntry_piece *entry = (struct DTZEntry_piece *)ptr3; entry->enc_type = ((struct TBEntry_piece *)ptr)->enc_type; } if (!init_table_dtz(ptr3)) free(ptr3); else DTZ_table[0].entry = ptr3; } static void free_wdl_entry(struct TBEntry *entry) { unmap_file(entry->data, entry->mapping); if (!entry->has_pawns) { struct TBEntry_piece *ptr = (struct TBEntry_piece *)entry; free(ptr->precomp[0]); if (ptr->precomp[1]) free(ptr->precomp[1]); } else { struct TBEntry_pawn *ptr = (struct TBEntry_pawn *)entry; int f; for (f = 0; f < 4; f++) { free(ptr->file[f].precomp[0]); if (ptr->file[f].precomp[1]) free(ptr->file[f].precomp[1]); } } } static void free_dtz_entry(struct TBEntry *entry) { unmap_file(entry->data, entry->mapping); if (!entry->has_pawns) { struct DTZEntry_piece *ptr = (struct DTZEntry_piece *)entry; free(ptr->precomp); } else { struct DTZEntry_pawn *ptr = (struct DTZEntry_pawn *)entry; int f; for (f = 0; f < 4; f++) free(ptr->file[f].precomp); } free(entry); } static int wdl_to_map[5] = { 1, 3, 0, 2, 0 }; static ubyte pa_flags[5] = { 8, 0, 0, 0, 4 };
[ "ScienceLover@SCIENCELOVER-PC" ]
ScienceLover@SCIENCELOVER-PC
ba0664b65c55d86ecce17bdb2e31451cb3435613
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
/app/src/main/cpp/dir521/dir522/dir572/dir841/dir842/file845.cpp
82bdd6b29268cb059aa4c3f56d60d45cc3092b90
[]
no_license
tgeng/HugeProject
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
4488d3b765e8827636ce5e878baacdf388710ef2
refs/heads/master
2022-08-21T16:58:54.161627
2020-05-28T01:54:03
2020-05-28T01:54:03
267,468,475
0
0
null
null
null
null
UTF-8
C++
false
false
107
cpp
#ifndef file845 #error "macro file845 must be defined" #endif static const char* file845String = "file845";
[ "tgeng@google.com" ]
tgeng@google.com
80bdf4e6c2348cf20f66bb2e909230aeb498f14d
987fa85ca5b7db9806e698f6947714de6be9f7a6
/CPP/SDL/lazyfoo/03/eventDriven.cpp
ec8bfc03c5d7aad1b146bad19af0d4fd3bda617e
[]
no_license
mynameisjohn/code
89a711c554766a354f7268d714ddbda183e9dd6c
14f0fd704e13939e71d2bdd17862573eff32ef9d
refs/heads/master
2021-01-15T12:19:10.912281
2014-09-02T23:10:55
2014-09-02T23:10:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,525
cpp
#include <SDL2/SDL.h> #include <iostream> #define IMG "hello_world.bmp" #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 SDL_Window * gWindow=NULL; SDL_Surface* gScreenSurface=NULL; SDL_Surface* gHelloWorld=NULL; using namespace std; bool init(){ bool success=true; if (SDL_Init(SDL_INIT_VIDEO)<0){ cout << SDL_GetError() << endl; success=false; return success; } gWindow=SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); if( gWindow == NULL ){cout << SDL_GetError() << endl; success=false; return success; } gScreenSurface=SDL_GetWindowSurface(gWindow); return success; } bool loadMedia(){ gHelloWorld=SDL_LoadBMP(IMG); if (gHelloWorld==NULL){ cout << SDL_GetError() << endl; return false; } return true; } void close(){ SDL_FreeSurface(gHelloWorld); gHelloWorld=NULL; SDL_DestroyWindow(gWindow); gWindow=NULL; SDL_Quit(); } int main(int argc, char ** argv){ bool quit=false; SDL_Event e; if (!init()){ cout << "Failed to initialize" << endl; return -1; } if (!loadMedia()){ cout << "Failed to load media" << endl; return -1; } while (!quit){ while (SDL_PollEvent(&e)!=0) if (e.type==SDL_QUIT) quit=true; SDL_BlitSurface( gHelloWorld, NULL, gScreenSurface, NULL ); SDL_UpdateWindowSurface(gWindow); } close(); return 1; }
[ "mynameisjohnj@gmail.com" ]
mynameisjohnj@gmail.com
5d7847fe72698e5a9b2a8ae3a2007a2cbb9ab968
50487ee1d630ff1834564c0bdd56cad5b82a9c21
/src/hardware/atmega32/cpu/cpu.h
3c5c475008b370204c259e7b381d88bbfa225a90
[]
no_license
labdiy/imaxb6_nuvoton
7a3bfaddc06f54273c0d3c43f14a8c898e15af7e
12ded992e38c084713b6e56d3da4fb6a0def49ea
refs/heads/main
2023-03-15T15:20:04.632578
2021-01-07T08:36:28
2021-01-07T08:36:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
965
h
/* cheali-charger - open source firmware for a variety of LiPo chargers Copyright (C) 2014 Paweł Stawicki. All right reserved. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef CPU_H_ #define CPU_H_ #include <avr/interrupt.h> namespace cpu { inline void init() { sei(); } } #endif /* CPU_H_ */
[ "pampyras@gmail.com" ]
pampyras@gmail.com
15c63904f7108e78ca2cb47e87017a4edd1892a0
2eae3ba5d282ca65c0bbaf6a3f9edc9434a4fcef
/Session 1/Vectors/Module.h
84146269b215028175979ebb79c726ded10a082b
[]
no_license
GHendrikx/CPP_Hendrikx_Geoffrey_3028316
03d1c755b68acea148a06c48a1611d51c3314f49
0ca46802fab1af43d9334a415a0db955ea753f75
refs/heads/master
2020-07-30T17:19:55.652535
2019-10-13T09:10:14
2019-10-13T09:10:14
210,301,479
0
0
null
null
null
null
UTF-8
C++
false
false
371
h
#include <iostream> #include "Student.h" #include "Docent.h" #include <vector> #pragma once class Module { public: Module(std::string moduleName,Docent docent, int ECS); void changeECS(); void joinModule(Student student); void printModuleInfo(); void removeStudent(); int ECS; private: std::vector<Student> students; Docent docent; std::string moduleName; };
[ "geoffreyhendrikx@hotmail.com" ]
geoffreyhendrikx@hotmail.com
c6897395ba85281435321ea4f36a7db92e3a60f2
7f72c463d8747c05cf964e0ea4f896890b4a8b6c
/out/Release/obj/gen/deps/v8/src/builtins/proxy-get-property-tq-csa.cc
0b8a6dd5807a1ba3b3240c0d0b6a10502704674c
[ "CC0-1.0", "LicenseRef-scancode-openssl", "NTP", "BSD-3-Clause", "Artistic-2.0", "Zlib", "ICU", "NAIST-2003", "LicenseRef-scancode-unicode", "ISC", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "MIT", "LicenseRef-sca...
permissive
sdizdarevic/node-v14.15.4
5dc95efdd2dc83aa577930c0792755d2e25da238
ab3716c46ad34da8680ca48c2498e71d77838dfd
refs/heads/master
2023-03-09T00:46:54.316036
2021-02-21T10:19:33
2021-02-21T10:19:33
340,862,598
0
0
null
null
null
null
UTF-8
C++
false
false
18,795
cc
#include "src/builtins/builtins-array-gen.h" #include "src/builtins/builtins-bigint-gen.h" #include "src/builtins/builtins-collections-gen.h" #include "src/builtins/builtins-constructor-gen.h" #include "src/builtins/builtins-data-view-gen.h" #include "src/builtins/builtins-iterator-gen.h" #include "src/builtins/builtins-promise-gen.h" #include "src/builtins/builtins-promise.h" #include "src/builtins/builtins-proxy-gen.h" #include "src/builtins/builtins-regexp-gen.h" #include "src/builtins/builtins-string-gen.h" #include "src/builtins/builtins-typed-array-gen.h" #include "src/builtins/builtins-utils-gen.h" #include "src/builtins/builtins-wasm-gen.h" #include "src/builtins/builtins.h" #include "src/codegen/code-factory.h" #include "src/heap/factory-inl.h" #include "src/objects/arguments.h" #include "src/objects/bigint.h" #include "src/objects/elements-kind.h" #include "src/objects/free-space.h" #include "src/objects/js-aggregate-error.h" #include "src/objects/js-break-iterator.h" #include "src/objects/js-collator.h" #include "src/objects/js-date-time-format.h" #include "src/objects/js-display-names.h" #include "src/objects/js-generator.h" #include "src/objects/js-list-format.h" #include "src/objects/js-locale.h" #include "src/objects/js-number-format.h" #include "src/objects/js-objects.h" #include "src/objects/js-plural-rules.h" #include "src/objects/js-promise.h" #include "src/objects/js-regexp-string-iterator.h" #include "src/objects/js-relative-time-format.h" #include "src/objects/js-segment-iterator.h" #include "src/objects/js-segmenter.h" #include "src/objects/js-weak-refs.h" #include "src/objects/objects.h" #include "src/objects/ordered-hash-table.h" #include "src/objects/property-array.h" #include "src/objects/property-descriptor-object.h" #include "src/objects/source-text-module.h" #include "src/objects/stack-frame-info.h" #include "src/objects/synthetic-module.h" #include "src/objects/template-objects.h" #include "src/torque/runtime-support.h" #include "torque-generated/../../deps/v8/src/builtins/array-copywithin-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-every-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-filter-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-find-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-findindex-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-foreach-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-from-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-isarray-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-join-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-lastindexof-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-map-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-of-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-reduce-right-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-reduce-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-reverse-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-shift-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-slice-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-some-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-splice-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-unshift-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/array-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/base-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/bigint-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/boolean-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/builtins-string-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/collections-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/cast-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/convert-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/console-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/data-view-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/finalization-registry-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/frames-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/frame-arguments-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/growable-fixed-array-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/ic-callable-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/ic-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/internal-coverage-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/iterator-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/math-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/number-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/object-fromentries-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/object-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-abstract-operations-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-all-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-all-element-closure-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-any-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-constructor-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-finally-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-misc-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-race-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-reaction-job-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-resolve-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-then-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/promise-jobs-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-constructor-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-delete-property-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-get-property-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-get-prototype-of-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-has-property-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-is-extensible-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-prevent-extensions-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-revocable-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-revoke-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-set-property-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-set-prototype-of-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/proxy-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/reflect-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/regexp-exec-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/regexp-match-all-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/regexp-match-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/regexp-replace-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/regexp-search-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/regexp-source-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/regexp-split-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/regexp-test-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/regexp-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-endswith-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-html-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-iterator-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-pad-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-repeat-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-replaceall-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-slice-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-startswith-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-substring-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/string-substr-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/symbol-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/torque-internal-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-createtypedarray-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-every-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-filter-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-find-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-findindex-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-foreach-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-from-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-of-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-reduce-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-reduceright-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-set-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-slice-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-some-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-sort-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-subarray-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/typed-array-tq-csa.h" #include "torque-generated/../../deps/v8/src/builtins/wasm-tq-csa.h" #include "torque-generated/../../deps/v8/src/ic/handler-configuration-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/allocation-site-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/api-callbacks-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/arguments-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/cell-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/code-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/contexts-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/data-handler-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/debug-objects-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/descriptor-array-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/embedder-data-array-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/feedback-cell-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/feedback-vector-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/fixed-array-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/foreign-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/free-space-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/heap-number-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/heap-object-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-aggregate-error-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-array-buffer-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-array-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-collection-iterator-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-collection-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-generator-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-objects-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-promise-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-proxy-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-regexp-string-iterator-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-regexp-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/js-weak-refs-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/literal-objects-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/map-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/microtask-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/module-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/name-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/oddball-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/ordered-hash-table-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/primitive-heap-object-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/promise-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/property-array-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/property-cell-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/property-descriptor-object-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/prototype-info-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/regexp-match-info-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/scope-info-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/script-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/shared-function-info-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/source-text-module-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/stack-frame-info-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/string-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/struct-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/synthetic-module-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/template-objects-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/template-tq-csa.h" #include "torque-generated/../../deps/v8/src/wasm/wasm-objects-tq-csa.h" #include "torque-generated/../../deps/v8/test/torque/test-torque-tq-csa.h" #include "torque-generated/../../deps/v8/third_party/v8/builtins/array-sort-tq-csa.h" #include "torque-generated/../../deps/v8/src/objects/intl-objects-tq-csa.h" namespace v8 { namespace internal { TF_BUILTIN(ProxyGetProperty, CodeStubAssembler) { compiler::CodeAssemblerState* state_ = state(); compiler::CodeAssembler ca_(state()); TNode<Context> parameter0 = UncheckedCast<Context>(Parameter(Descriptor::kContext)); USE(parameter0); TNode<JSProxy> parameter1 = UncheckedCast<JSProxy>(Parameter(Descriptor::ParameterIndex<0>())); USE(parameter1); TNode<Name> parameter2 = UncheckedCast<Name>(Parameter(Descriptor::ParameterIndex<1>())); USE(parameter2); TNode<Object> parameter3 = UncheckedCast<Object>(Parameter(Descriptor::ParameterIndex<2>())); USE(parameter3); TNode<Smi> parameter4 = UncheckedCast<Smi>(Parameter(Descriptor::ParameterIndex<3>())); USE(parameter4); compiler::CodeAssemblerParameterizedLabel<> block0(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<> block16(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<> block15(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<> block20(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<> block19(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<> block24(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); compiler::CodeAssemblerParameterizedLabel<> block23(&ca_, compiler::CodeAssemblerLabel::kNonDeferred); ca_.Goto(&block0); TNode<IntPtrT> tmp0; TNode<HeapObject> tmp1; TNode<Oddball> tmp2; if (block0.is_used()) { ca_.Bind(&block0); CodeStubAssembler(state_).PerformStackCheck(TNode<Context>{parameter0}); tmp0 = FromConstexpr_intptr_constexpr_int31_0(state_, 12); tmp1 = CodeStubAssembler(state_).LoadReference<HeapObject>(CodeStubAssembler::Reference{parameter1, tmp0}); compiler::CodeAssemblerLabel label3(&ca_); tmp2 = Cast_Null_0(state_, TNode<HeapObject>{tmp1}, &label3); ca_.Goto(&block15); if (label3.is_used()) { ca_.Bind(&label3); ca_.Goto(&block16); } } TNode<IntPtrT> tmp4; TNode<HeapObject> tmp5; TNode<JSReceiver> tmp6; if (block16.is_used()) { ca_.Bind(&block16); tmp4 = FromConstexpr_intptr_constexpr_int31_0(state_, 8); tmp5 = CodeStubAssembler(state_).LoadReference<HeapObject>(CodeStubAssembler::Reference{parameter1, tmp4}); compiler::CodeAssemblerLabel label7(&ca_); tmp6 = Cast_JSReceiver_0(state_, TNode<HeapObject>{tmp5}, &label7); ca_.Goto(&block19); if (label7.is_used()) { ca_.Bind(&label7); ca_.Goto(&block20); } } if (block15.is_used()) { ca_.Bind(&block15); CodeStubAssembler(state_).ThrowTypeError(TNode<Context>{parameter0}, MessageTemplate::kProxyRevoked, "get"); } if (block20.is_used()) { ca_.Bind(&block20); CodeStubAssembler(state_).Unreachable(); } TNode<JSReceiver> tmp8; if (block19.is_used()) { ca_.Bind(&block19); compiler::CodeAssemblerLabel label9(&ca_); tmp8 = GetMethod_2(state_, TNode<Context>{parameter0}, TNode<Object>{ca_.UncheckedCast<JSReceiver>(tmp1)}, "get", &label9); ca_.Goto(&block23); if (label9.is_used()) { ca_.Bind(&label9); ca_.Goto(&block24); } } TNode<Object> tmp10; if (block24.is_used()) { ca_.Bind(&block24); tmp10 = CodeStubAssembler(state_).CallBuiltin(Builtins::kGetPropertyWithReceiver, parameter0, tmp6, parameter2, parameter3, parameter4); CodeStubAssembler(state_).Return(tmp10); } TNode<Object> tmp11; if (block23.is_used()) { ca_.Bind(&block23); tmp11 = CodeStubAssembler(state_).Call(TNode<Context>{parameter0}, TNode<Object>{tmp8}, TNode<Object>{ca_.UncheckedCast<JSReceiver>(tmp1)}, TNode<Object>{tmp6}, TNode<Object>{parameter2}, TNode<Object>{parameter3}); ProxiesCodeStubAssembler(state_).CheckGetSetTrapResult(TNode<Context>{parameter0}, TNode<JSReceiver>{tmp6}, TNode<JSProxy>{parameter1}, TNode<Name>{parameter2}, TNode<Object>{tmp11}, JSProxy::AccessKind::kGet); CodeStubAssembler(state_).Return(tmp11); } } } // namespace internal } // namespace v8
[ "saudin.dizdarevic@gmail.com" ]
saudin.dizdarevic@gmail.com
a9d2aa09261920de5090fc2cc16dd7f07511ffdc
db3b085d00c89ed16bd9e78e132c4558848e6866
/CodeForce/E114/B.cpp
340938e581f2b6d9e5db748b63d2aa09d5f45ad2
[]
no_license
zkxshg/Test_of_LeetCode
23e4bcd814499c26940659614607f0782c764b09
8a3c2d43ed0b5815c5fb2d2bb4d59e586aae9dba
refs/heads/master
2023-08-22T16:08:04.801856
2023-08-09T22:43:56
2023-08-09T22:43:56
230,379,638
1
0
null
null
null
null
UTF-8
C++
false
false
695
cpp
#include <iostream> #include <cstdlib> #include <ctime> #include <algorithm> #include <fstream> #include <sstream> #include <vector> #include <string> #include <cmath> #include <climits> #include <map> #include<unordered_map> #include <utility> using namespace std; #define MaxValue 9999999 #define ll long long int t, a, b, c, m; int main() { cin >> t; while (t) { t--; cin >> a >> b >> c >> m; int UB = (a - 1) + (b - 1) + (c - 1); int maxF = max(a, b); maxF = max(maxF, c); int LB = (maxF - 1) - (a + b + c - maxF); LB = max(0, LB); if (m <= UB && m >= LB) cout << "YES\n"; else cout << "NO\n"; } return 0; }
[ "zkxshg@126.com" ]
zkxshg@126.com
800c75af9150ab7d14d3e41c675c61568afd40c1
af097999eb5d5d0f7838d783049b8a5715f84e06
/twoStringsPermutation.cpp
3a09d0693b03bcf1a449a1ba9b4458bf722c1b4e
[]
no_license
tuancaraballo/Summer2016CodingFun
8dfd4aa4f8fa3e2817799c6055712ac40d57f20e
1812f077d23305da3cafc5624cf384bdd6efaf41
refs/heads/master
2021-01-22T17:33:47.943143
2017-07-11T05:53:22
2017-07-11T05:53:22
63,389,868
0
0
null
2017-07-11T05:53:22
2016-07-15T03:49:00
C++
UTF-8
C++
false
false
2,102
cpp
/* package whatever; // don't place package name! */ import java.io.*; import java.util.*; import java.lang.Boolean; /* QUESTION 1.3: Given two strings, write a method to decide if one is a permutation of the other Approach: I used two maps to store their characters and their counts and then compared the maps Another approach could be using an array where you store the counts. */ class myCode { public static Boolean checkIfPermutation(String one, String two){ Map<Character,Integer> m1 = new HashMap<Character,Integer>(); Map<Character,Integer> m2 = new HashMap<Character,Integer>(); int len1 = one.length(); int len2 = two.length(); if(len1 != len2) return false; for(int i = 0; i<len1; i++){ // ---> check if the character in one is contained in the map if(m1.containsKey(one.charAt(i))){ m1.put(one.charAt(i),m1.get(one.charAt(i) +1)); } else{ //---> it wasn't found, so just added to the map m1.put(one.charAt(i),1); } // --> check second map if(m2.containsKey(two.charAt(i))){ m2.put(two.charAt(i),m2.get(two.charAt(i) +1)); } else{ m2.put(two.charAt(i),1); } } if(m1.equals(m2)) return true; return false; } public static void main (String[] args) throws java.lang.Exception{ String one = "DKKBACEL"; String two = "LABECDKK"; long startTime = System.currentTimeMillis(); if(checkIfPermutation(one,two)){ System.out.println("They are permutations of each other"); } else{ System.out.println("They are NOT permutations of each other"); } double stopTime = System.currentTimeMillis(); double elapsedTime = stopTime - startTime; System.out.println("Time Taken: " + elapsedTime); } }
[ "tranc2606@gmail.com" ]
tranc2606@gmail.com
1b954ffc09d48987751eb3367e963eba9f7ace39
bdef965899820bd54cee41a707314f515ae00118
/c/s7.h
522b059ff0b35853e4725bac9988e0ba0f1843b3
[]
no_license
summerfang/study
59cecc4b2cc4d567c4856499134085d0ab0c8d88
7dd476abb7bb256e95e64011837a540c6f76503a
refs/heads/master
2023-08-10T00:57:41.748513
2023-07-27T00:01:41
2023-07-27T00:01:41
204,843,219
0
1
null
2023-07-26T02:13:39
2019-08-28T03:48:20
Jupyter Notebook
UTF-8
C++
false
false
6,044
h
#include "WebSocketProtocol.h" #include <iostream> #include <sstream> #include <string.h> #include <arpa/inet.h> #include "sha1.h" #include "base64.h" const char * MAGIC_KEY = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; CWebSocketProtocol::CGrabo CWebSocketProtocol::m_grabo; CWebSocketProtocol * CWebSocketProtocol::m_inst = 0; CWebSocketProtocol::CWebSocketProtocol() { } CWebSocketProtocol::~CWebSocketProtocol() { } CWebSocketProtocol * CWebSocketProtocol::getInstance() { if (m_inst != 0) { m_inst = new CWebSocketProtocol; } return m_inst; } int CWebSocketProtocol::getResponseHttp(string &request, string &response) { // 解析http请求头信息 int ret = WS_STATUS_UNCONNECT; std::istringstream stream(request.c_str()); std::string reqType; std::getline(stream, reqType); if (reqType.substr(0, 4) != "GET ") { return ret; } std::string header; std::string::size_type pos = 0; std::string websocketKey; while (std::getline(stream, header) && header != "\r") { header.erase(header.end() - 1); pos = header.find(": ", 0); if (pos != std::string::npos) { std::string key = header.substr(0, pos); std::string value = header.substr(pos + 2); if (key == "Sec-WebSocket-Key") { ret = WS_STATUS_CONNECT; websocketKey = value; break; } } } if (ret != WS_STATUS_CONNECT) { return ret; } // 填充http响应头信息 response = "HTTP/1.1 101 Switching Protocols\r\n"; response += "Connection: upgrade\r\n"; response += "Sec-WebSocket-Accept: "; std::string serverKey = websocketKey + MAGIC_KEY; SHA1 sha; unsigned int message_digest[5]; sha.Reset(); sha << serverKey.c_str(); sha.Result(message_digest); for (int i = 0; i < 5; i++) { message_digest[i] = htonl(message_digest[i]); } serverKey = base64_encode(reinterpret_cast<const unsigned char*>(message_digest), 20); response += serverKey; response += "\r\n"; response += "Upgrade: websocket\r\n\r\n"; return ret; } int CWebSocketProtocol::wsDecodeFrame(string inFrame, string &outMessage) { int ret = WS_OPENING_FRAME; const char *frameData = inFrame.c_str(); const int frameLength = inFrame.size(); if (frameLength < 2) { ret = WS_ERROR_FRAME; } // 检查扩展位并忽略 if ((frameData[0] & 0x70) != 0x0) { ret = WS_ERROR_FRAME; } // fin位: 为1表示已接收完整报文, 为0表示继续监听后续报文 ret = (frameData[0] & 0x80); if ((frameData[0] & 0x80) != 0x80) { ret = WS_ERROR_FRAME; } // mask位, 为1表示数据被加密 if ((frameData[1] & 0x80) != 0x80) { ret = WS_ERROR_FRAME; } // 操作码 uint16_t payloadLength = 0; uint8_t payloadFieldExtraBytes = 0; uint8_t opcode = static_cast<uint8_t>(frameData[0] & 0x0f); if (opcode == WS_TEXT_FRAME) { // 处理utf-8编码的文本帧 payloadLength = static_cast<uint16_t>(frameData[1] & 0x7f); if (payloadLength == 0x7e) { uint16_t payloadLength16b = 0; payloadFieldExtraBytes = 2; memcpy(&payloadLength16b, &frameData[2], payloadFieldExtraBytes); payloadLength = ntohs(payloadLength16b); } else if (payloadLength == 0x7f) { // 数据过长,暂不支持 ret = WS_ERROR_FRAME; } } else if (opcode == WS_BINARY_FRAME || opcode == WS_PING_FRAME || opcode == WS_PONG_FRAME) { // 二进制/ping/pong帧暂不处理 } else if (opcode == WS_CLOSING_FRAME) { ret = WS_CLOSING_FRAME; } else { ret = WS_ERROR_FRAME; } // 数据解码 if ((ret != WS_ERROR_FRAME) && (payloadLength > 0)) { // header: 2字节, masking key: 4字节 const char *maskingKey = &frameData[2 + payloadFieldExtraBytes]; char *payloadData = new char[payloadLength + 1]; memset(payloadData, 0, payloadLength + 1); memcpy(payloadData, &frameData[2 + payloadFieldExtraBytes + 4], payloadLength); for (int i = 0; i < payloadLength; i++) { payloadData[i] = payloadData[i] ^ maskingKey[i % 4]; } outMessage = payloadData; delete[] payloadData; } return ret; } int CWebSocketProtocol::wsEncodeFrame(string inMessage, string &outFrame, enum WS_FrameType frameType) { int ret = WS_EMPTY_FRAME; const uint32_t messageLength = inMessage.size(); if (messageLength > 32767) { // 暂不支持这么长的数据 std::cout << "暂不支持这么长的数据" << std::endl; return WS_ERROR_FRAME; } uint8_t payloadFieldExtraBytes = (messageLength <= 0x7d) ? 0 : 2; // header: 2字节, mask位设置为0(不加密), 则后面的masking key无须填写, 省略4字节 uint8_t frameHeaderSize = 2 + payloadFieldExtraBytes; uint8_t *frameHeader = new uint8_t[frameHeaderSize]; memset(frameHeader, 0, frameHeaderSize); // fin位为1, 扩展位为0, 操作位为frameType frameHeader[0] = static_cast<uint8_t>(0x80 | frameType); // 填充数据长度 if (messageLength <= 0x7d) { frameHeader[1] = static_cast<uint8_t>(messageLength); } else { frameHeader[1] = 0x7e; uint16_t len = htons(messageLength); memcpy(&frameHeader[2], &len, payloadFieldExtraBytes); } // 填充数据 uint32_t frameSize = frameHeaderSize + messageLength; char *frame = new char[frameSize + 1]; memcpy(frame, frameHeader, frameHeaderSize); memcpy(frame + frameHeaderSize, inMessage.c_str(), messageLength); frame[frameSize] = ‘\0‘; outFrame = frame; delete[] frame; delete[] frameHeader; return ret; }
[ "summerfang@gmail.com" ]
summerfang@gmail.com
02438150a127ff23b1b4ddd658cbc973016a7230
f359d190dd0fa43dc21772a0faccec89013e0e99
/export/windows/obj/src/flixel/input/gamepad/id/OUYAID.cpp
2124f391baca1b3de9ce5163ae1ea0f8998a569f
[]
no_license
pedrohpe/terminal
0da838959f09c50550e629fa8c592dc364b1fa1f
49fdf9fd10a075ae083e9b31850788fbb814fea5
refs/heads/master
2020-03-25T09:18:50.578453
2018-08-05T21:42:33
2018-08-05T21:42:33
143,659,093
0
0
null
null
null
null
UTF-8
C++
false
true
15,871
cpp
// Generated by Haxe 3.4.4 #include <hxcpp.h> #ifndef INCLUDED_flixel_input_gamepad_FlxGamepadAnalogStick #include <flixel/input/gamepad/FlxGamepadAnalogStick.h> #endif #ifndef INCLUDED_flixel_input_gamepad_id_OUYAID #include <flixel/input/gamepad/id/OUYAID.h> #endif HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_10_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",10,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_11_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",11,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_12_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",12,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_13_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",13,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_14_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",14,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_15_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",15,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_16_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",16,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_17_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",17,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_18_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",18,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_19_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",19,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_20_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",20,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_23_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",23,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_24_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",24,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_25_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",25,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_26_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",26,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_29_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",29,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_30_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",30,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_32_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",32,0x79a5bd07) HX_LOCAL_STACK_FRAME(_hx_pos_350a610213d94b8b_33_boot,"flixel.input.gamepad.id.OUYAID","boot",0x51416c47,"flixel.input.gamepad.id.OUYAID.boot","flixel/input/gamepad/id/OUYAID.hx",33,0x79a5bd07) namespace flixel{ namespace input{ namespace gamepad{ namespace id{ void OUYAID_obj::__construct() { } Dynamic OUYAID_obj::__CreateEmpty() { return new OUYAID_obj; } void *OUYAID_obj::_hx_vtable = 0; Dynamic OUYAID_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< OUYAID_obj > _hx_result = new OUYAID_obj(); _hx_result->__construct(); return _hx_result; } bool OUYAID_obj::_hx_isInstanceOf(int inClassId) { return inClassId==(int)0x00000001 || inClassId==(int)0x240ae257; } int OUYAID_obj::O; int OUYAID_obj::U; int OUYAID_obj::Y; int OUYAID_obj::A; int OUYAID_obj::LB; int OUYAID_obj::RB; int OUYAID_obj::LEFT_STICK_CLICK; int OUYAID_obj::RIGHT_STICK_CLICK; int OUYAID_obj::HOME; int OUYAID_obj::LEFT_TRIGGER; int OUYAID_obj::RIGHT_TRIGGER; int OUYAID_obj::DPAD_LEFT; int OUYAID_obj::DPAD_RIGHT; int OUYAID_obj::DPAD_DOWN; int OUYAID_obj::DPAD_UP; ::flixel::input::gamepad::FlxGamepadAnalogStick OUYAID_obj::LEFT_ANALOG_STICK; ::flixel::input::gamepad::FlxGamepadAnalogStick OUYAID_obj::RIGHT_ANALOG_STICK; int OUYAID_obj::LEFT_TRIGGER_ANALOG; int OUYAID_obj::RIGHT_TRIGGER_ANALOG; OUYAID_obj::OUYAID_obj() { } bool OUYAID_obj::__GetStatic(const ::String &inName, Dynamic &outValue, hx::PropertyAccess inCallProp) { switch(inName.length) { case 17: if (HX_FIELD_EQ(inName,"LEFT_ANALOG_STICK") ) { outValue = ( LEFT_ANALOG_STICK ); return true; } break; case 18: if (HX_FIELD_EQ(inName,"RIGHT_ANALOG_STICK") ) { outValue = ( RIGHT_ANALOG_STICK ); return true; } } return false; } bool OUYAID_obj::__SetStatic(const ::String &inName,Dynamic &ioValue,hx::PropertyAccess inCallProp) { switch(inName.length) { case 17: if (HX_FIELD_EQ(inName,"LEFT_ANALOG_STICK") ) { LEFT_ANALOG_STICK=ioValue.Cast< ::flixel::input::gamepad::FlxGamepadAnalogStick >(); return true; } break; case 18: if (HX_FIELD_EQ(inName,"RIGHT_ANALOG_STICK") ) { RIGHT_ANALOG_STICK=ioValue.Cast< ::flixel::input::gamepad::FlxGamepadAnalogStick >(); return true; } } return false; } #if HXCPP_SCRIPTABLE static hx::StorageInfo *OUYAID_obj_sMemberStorageInfo = 0; static hx::StaticInfo OUYAID_obj_sStaticStorageInfo[] = { {hx::fsInt,(void *) &OUYAID_obj::O,HX_HCSTRING("O","\x4f","\x00","\x00","\x00")}, {hx::fsInt,(void *) &OUYAID_obj::U,HX_HCSTRING("U","\x55","\x00","\x00","\x00")}, {hx::fsInt,(void *) &OUYAID_obj::Y,HX_HCSTRING("Y","\x59","\x00","\x00","\x00")}, {hx::fsInt,(void *) &OUYAID_obj::A,HX_HCSTRING("A","\x41","\x00","\x00","\x00")}, {hx::fsInt,(void *) &OUYAID_obj::LB,HX_HCSTRING("LB","\x76","\x42","\x00","\x00")}, {hx::fsInt,(void *) &OUYAID_obj::RB,HX_HCSTRING("RB","\xb0","\x47","\x00","\x00")}, {hx::fsInt,(void *) &OUYAID_obj::LEFT_STICK_CLICK,HX_HCSTRING("LEFT_STICK_CLICK","\x21","\x9d","\x4a","\xbf")}, {hx::fsInt,(void *) &OUYAID_obj::RIGHT_STICK_CLICK,HX_HCSTRING("RIGHT_STICK_CLICK","\x56","\x4c","\x25","\x0b")}, {hx::fsInt,(void *) &OUYAID_obj::HOME,HX_HCSTRING("HOME","\x1f","\x92","\xd3","\x2f")}, {hx::fsInt,(void *) &OUYAID_obj::LEFT_TRIGGER,HX_HCSTRING("LEFT_TRIGGER","\xa0","\x31","\xc6","\xeb")}, {hx::fsInt,(void *) &OUYAID_obj::RIGHT_TRIGGER,HX_HCSTRING("RIGHT_TRIGGER","\x55","\xe2","\x81","\x00")}, {hx::fsInt,(void *) &OUYAID_obj::DPAD_LEFT,HX_HCSTRING("DPAD_LEFT","\x17","\x2a","\x9d","\x8c")}, {hx::fsInt,(void *) &OUYAID_obj::DPAD_RIGHT,HX_HCSTRING("DPAD_RIGHT","\xac","\xb7","\xf4","\xf3")}, {hx::fsInt,(void *) &OUYAID_obj::DPAD_DOWN,HX_HCSTRING("DPAD_DOWN","\x72","\x1a","\x5b","\x87")}, {hx::fsInt,(void *) &OUYAID_obj::DPAD_UP,HX_HCSTRING("DPAD_UP","\x6b","\x00","\x87","\xa2")}, {hx::fsObject /*::flixel::input::gamepad::FlxGamepadAnalogStick*/ ,(void *) &OUYAID_obj::LEFT_ANALOG_STICK,HX_HCSTRING("LEFT_ANALOG_STICK","\x19","\x49","\x58","\xa5")}, {hx::fsObject /*::flixel::input::gamepad::FlxGamepadAnalogStick*/ ,(void *) &OUYAID_obj::RIGHT_ANALOG_STICK,HX_HCSTRING("RIGHT_ANALOG_STICK","\x44","\xe8","\xd6","\xb8")}, {hx::fsInt,(void *) &OUYAID_obj::LEFT_TRIGGER_ANALOG,HX_HCSTRING("LEFT_TRIGGER_ANALOG","\x2f","\xd6","\x74","\xa0")}, {hx::fsInt,(void *) &OUYAID_obj::RIGHT_TRIGGER_ANALOG,HX_HCSTRING("RIGHT_TRIGGER_ANALOG","\x1a","\xd6","\x39","\x88")}, { hx::fsUnknown, 0, null()} }; #endif static void OUYAID_obj_sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(OUYAID_obj::__mClass,"__mClass"); HX_MARK_MEMBER_NAME(OUYAID_obj::O,"O"); HX_MARK_MEMBER_NAME(OUYAID_obj::U,"U"); HX_MARK_MEMBER_NAME(OUYAID_obj::Y,"Y"); HX_MARK_MEMBER_NAME(OUYAID_obj::A,"A"); HX_MARK_MEMBER_NAME(OUYAID_obj::LB,"LB"); HX_MARK_MEMBER_NAME(OUYAID_obj::RB,"RB"); HX_MARK_MEMBER_NAME(OUYAID_obj::LEFT_STICK_CLICK,"LEFT_STICK_CLICK"); HX_MARK_MEMBER_NAME(OUYAID_obj::RIGHT_STICK_CLICK,"RIGHT_STICK_CLICK"); HX_MARK_MEMBER_NAME(OUYAID_obj::HOME,"HOME"); HX_MARK_MEMBER_NAME(OUYAID_obj::LEFT_TRIGGER,"LEFT_TRIGGER"); HX_MARK_MEMBER_NAME(OUYAID_obj::RIGHT_TRIGGER,"RIGHT_TRIGGER"); HX_MARK_MEMBER_NAME(OUYAID_obj::DPAD_LEFT,"DPAD_LEFT"); HX_MARK_MEMBER_NAME(OUYAID_obj::DPAD_RIGHT,"DPAD_RIGHT"); HX_MARK_MEMBER_NAME(OUYAID_obj::DPAD_DOWN,"DPAD_DOWN"); HX_MARK_MEMBER_NAME(OUYAID_obj::DPAD_UP,"DPAD_UP"); HX_MARK_MEMBER_NAME(OUYAID_obj::LEFT_ANALOG_STICK,"LEFT_ANALOG_STICK"); HX_MARK_MEMBER_NAME(OUYAID_obj::RIGHT_ANALOG_STICK,"RIGHT_ANALOG_STICK"); HX_MARK_MEMBER_NAME(OUYAID_obj::LEFT_TRIGGER_ANALOG,"LEFT_TRIGGER_ANALOG"); HX_MARK_MEMBER_NAME(OUYAID_obj::RIGHT_TRIGGER_ANALOG,"RIGHT_TRIGGER_ANALOG"); }; #ifdef HXCPP_VISIT_ALLOCS static void OUYAID_obj_sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(OUYAID_obj::__mClass,"__mClass"); HX_VISIT_MEMBER_NAME(OUYAID_obj::O,"O"); HX_VISIT_MEMBER_NAME(OUYAID_obj::U,"U"); HX_VISIT_MEMBER_NAME(OUYAID_obj::Y,"Y"); HX_VISIT_MEMBER_NAME(OUYAID_obj::A,"A"); HX_VISIT_MEMBER_NAME(OUYAID_obj::LB,"LB"); HX_VISIT_MEMBER_NAME(OUYAID_obj::RB,"RB"); HX_VISIT_MEMBER_NAME(OUYAID_obj::LEFT_STICK_CLICK,"LEFT_STICK_CLICK"); HX_VISIT_MEMBER_NAME(OUYAID_obj::RIGHT_STICK_CLICK,"RIGHT_STICK_CLICK"); HX_VISIT_MEMBER_NAME(OUYAID_obj::HOME,"HOME"); HX_VISIT_MEMBER_NAME(OUYAID_obj::LEFT_TRIGGER,"LEFT_TRIGGER"); HX_VISIT_MEMBER_NAME(OUYAID_obj::RIGHT_TRIGGER,"RIGHT_TRIGGER"); HX_VISIT_MEMBER_NAME(OUYAID_obj::DPAD_LEFT,"DPAD_LEFT"); HX_VISIT_MEMBER_NAME(OUYAID_obj::DPAD_RIGHT,"DPAD_RIGHT"); HX_VISIT_MEMBER_NAME(OUYAID_obj::DPAD_DOWN,"DPAD_DOWN"); HX_VISIT_MEMBER_NAME(OUYAID_obj::DPAD_UP,"DPAD_UP"); HX_VISIT_MEMBER_NAME(OUYAID_obj::LEFT_ANALOG_STICK,"LEFT_ANALOG_STICK"); HX_VISIT_MEMBER_NAME(OUYAID_obj::RIGHT_ANALOG_STICK,"RIGHT_ANALOG_STICK"); HX_VISIT_MEMBER_NAME(OUYAID_obj::LEFT_TRIGGER_ANALOG,"LEFT_TRIGGER_ANALOG"); HX_VISIT_MEMBER_NAME(OUYAID_obj::RIGHT_TRIGGER_ANALOG,"RIGHT_TRIGGER_ANALOG"); }; #endif hx::Class OUYAID_obj::__mClass; static ::String OUYAID_obj_sStaticFields[] = { HX_HCSTRING("O","\x4f","\x00","\x00","\x00"), HX_HCSTRING("U","\x55","\x00","\x00","\x00"), HX_HCSTRING("Y","\x59","\x00","\x00","\x00"), HX_HCSTRING("A","\x41","\x00","\x00","\x00"), HX_HCSTRING("LB","\x76","\x42","\x00","\x00"), HX_HCSTRING("RB","\xb0","\x47","\x00","\x00"), HX_HCSTRING("LEFT_STICK_CLICK","\x21","\x9d","\x4a","\xbf"), HX_HCSTRING("RIGHT_STICK_CLICK","\x56","\x4c","\x25","\x0b"), HX_HCSTRING("HOME","\x1f","\x92","\xd3","\x2f"), HX_HCSTRING("LEFT_TRIGGER","\xa0","\x31","\xc6","\xeb"), HX_HCSTRING("RIGHT_TRIGGER","\x55","\xe2","\x81","\x00"), HX_HCSTRING("DPAD_LEFT","\x17","\x2a","\x9d","\x8c"), HX_HCSTRING("DPAD_RIGHT","\xac","\xb7","\xf4","\xf3"), HX_HCSTRING("DPAD_DOWN","\x72","\x1a","\x5b","\x87"), HX_HCSTRING("DPAD_UP","\x6b","\x00","\x87","\xa2"), HX_HCSTRING("LEFT_ANALOG_STICK","\x19","\x49","\x58","\xa5"), HX_HCSTRING("RIGHT_ANALOG_STICK","\x44","\xe8","\xd6","\xb8"), HX_HCSTRING("LEFT_TRIGGER_ANALOG","\x2f","\xd6","\x74","\xa0"), HX_HCSTRING("RIGHT_TRIGGER_ANALOG","\x1a","\xd6","\x39","\x88"), ::String(null()) }; void OUYAID_obj::__register() { hx::Object *dummy = new OUYAID_obj; OUYAID_obj::_hx_vtable = *(void **)dummy; hx::Static(__mClass) = new hx::Class_obj(); __mClass->mName = HX_HCSTRING("flixel.input.gamepad.id.OUYAID","\x79","\x70","\x41","\xfa"); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &OUYAID_obj::__GetStatic; __mClass->mSetStaticField = &OUYAID_obj::__SetStatic; __mClass->mMarkFunc = OUYAID_obj_sMarkStatics; __mClass->mStatics = hx::Class_obj::dupFunctions(OUYAID_obj_sStaticFields); __mClass->mMembers = hx::Class_obj::dupFunctions(0 /* sMemberFields */); __mClass->mCanCast = hx::TCanCast< OUYAID_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = OUYAID_obj_sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = OUYAID_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = OUYAID_obj_sStaticStorageInfo; #endif hx::_hx_RegisterClass(__mClass->mName, __mClass); } void OUYAID_obj::__boot() { { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_10_boot) HXDLIN( 10) O = (int)0; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_11_boot) HXDLIN( 11) U = (int)3; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_12_boot) HXDLIN( 12) Y = (int)4; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_13_boot) HXDLIN( 13) A = (int)1; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_14_boot) HXDLIN( 14) LB = (int)6; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_15_boot) HXDLIN( 15) RB = (int)7; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_16_boot) HXDLIN( 16) LEFT_STICK_CLICK = (int)10; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_17_boot) HXDLIN( 17) RIGHT_STICK_CLICK = (int)11; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_18_boot) HXDLIN( 18) HOME = (int)2; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_19_boot) HXDLIN( 19) LEFT_TRIGGER = (int)8; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_20_boot) HXDLIN( 20) RIGHT_TRIGGER = (int)9; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_23_boot) HXDLIN( 23) DPAD_LEFT = (int)13; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_24_boot) HXDLIN( 24) DPAD_RIGHT = (int)14; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_25_boot) HXDLIN( 25) DPAD_DOWN = (int)15; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_26_boot) HXDLIN( 26) DPAD_UP = (int)16; } { HX_GC_STACKFRAME(&_hx_pos_350a610213d94b8b_29_boot) HXDLIN( 29) LEFT_ANALOG_STICK = ::flixel::input::gamepad::FlxGamepadAnalogStick_obj::__alloc( HX_CTX ,(int)0,(int)1, ::Dynamic(hx::Anon_obj::Create(4) ->setFixed(0,HX_("right",dc,0b,64,e9),(int)26) ->setFixed(1,HX_("up",5b,66,00,00),(int)23) ->setFixed(2,HX_("down",62,f8,6d,42),(int)24) ->setFixed(3,HX_("left",07,08,b0,47),(int)25))); } { HX_GC_STACKFRAME(&_hx_pos_350a610213d94b8b_30_boot) HXDLIN( 30) RIGHT_ANALOG_STICK = ::flixel::input::gamepad::FlxGamepadAnalogStick_obj::__alloc( HX_CTX ,(int)11,(int)14, ::Dynamic(hx::Anon_obj::Create(4) ->setFixed(0,HX_("right",dc,0b,64,e9),(int)30) ->setFixed(1,HX_("up",5b,66,00,00),(int)27) ->setFixed(2,HX_("down",62,f8,6d,42),(int)28) ->setFixed(3,HX_("left",07,08,b0,47),(int)29))); } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_32_boot) HXDLIN( 32) LEFT_TRIGGER_ANALOG = (int)17; } { HX_STACKFRAME(&_hx_pos_350a610213d94b8b_33_boot) HXDLIN( 33) RIGHT_TRIGGER_ANALOG = (int)18; } } } // end namespace flixel } // end namespace input } // end namespace gamepad } // end namespace id
[ "pedroh.egler@hotmail.com" ]
pedroh.egler@hotmail.com
3f2c4212cfd56656a09b38260a76af96117b4af3
397a2481df8dbf40595089b9297ef6e772c00f94
/Server_Cooling_System/Server_cooling_system/Server_cooling_system.ino
c625ab7eba328af93a17930c596bb02c98af0f70
[]
no_license
alekseykonoiko/Arduino_Projects
9f95231cf94f38b824ebc15c96d557c2f60cb7ec
ce6a1f090ef47c82daad19fd02764e73b2d6be77
refs/heads/master
2020-03-20T18:14:57.074627
2018-08-23T14:48:04
2018-08-23T14:48:04
137,578,649
3
0
null
null
null
null
UTF-8
C++
false
false
1,215
ino
#include <OneWire.h> #include <DallasTemperature.h> float serverTemp = 0; const int pwm = 3; int fanSpeed = 0; // Data wire is plugged into pin 2 on the Arduino #define ONE_WIRE_BUS 2 // Setup a oneWire instance to communicate with any OneWire devices // (not just Maxim/Dallas temperature ICs) OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. DallasTemperature sensors(&oneWire); void setup() { // start serial port Serial.begin(9600); Serial.println("Dallas Temperature IC Control Library Demo"); // Start up the library sensors.begin(); pinMode(pwm,OUTPUT) ; } void loop() { // call sensors.requestTemperatures() to issue a global temperature // request to all devices on the bus Serial.print(" Requesting temperatures..."); sensors.requestTemperatures(); // Send the command to get temperatures Serial.println("DONE"); Serial.print("Temperature is: "); serverTemp = sensors.getTempCByIndex(0); Serial.println(serverTemp); serverTemp = constrain(serverTemp, 40, 60); fanSpeed = map(serverTemp, 40, 60, 0, 255); Serial.print("Fan speed is: "); Serial.println(fanSpeed); analogWrite(pwm,fanSpeed); delay(50) ; }
[ "lesha.konoiko@gmail.com" ]
lesha.konoiko@gmail.com
f50055d4d94fe471eeac04eb66f5e9ce46861cdb
acd6a59112b9bde19528bd70cb7ec5483e3aa262
/Ejemplostipos.cpp
ea0cb89b3877f2aa25a952c4eb91809065841bc8
[]
no_license
tonydaft/Ejemplostipos.cpp
4d048e165e8f9bf268351b56c7e50e543d32846e
f6c7035110a5cf09040b30489ee2e4a70fcd88c5
refs/heads/main
2023-06-20T11:34:51.502247
2021-07-24T16:08:10
2021-07-24T16:08:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
764
cpp
#include <iostream> #include <cassert> using namespace std; int main() { //Dato de Double assert(14.0 + 6.0 == 20.0); assert(1.0 / 3.0 != 5.0); assert(10.0 - 6.0 == 4.0); //Dato de String assert("calculadora" == "calculadora"); assert("cheesecake" == "cheesecake"); assert("facebook" == "facebook"); assert("instagram" == "instagram"); //Dato de Bool assert(true == true and true); assert(4 >= 4 == true); assert(8 <= 8 == true); assert(2 >= 5 == false); //Dato de Char assert('a' == 'a'); assert('a' != 'b'); assert ('a' < 'g'); //Dato de Unsigned assert(2 * 2 == 4); assert(4 + 18 == 22); assert(12 - 5 == 7); assert(2 / 2 == 1); //Dato de Int assert(290 + 13000 == 13290); return 0; }
[ "noreply@github.com" ]
noreply@github.com
ccd02daab07019b00728ae707706847193cce742
29cbde8a0b1b3c4e360afbdd0db8c4732e06dc6f
/Day 5/Intersection point of 2 linked list/solution.cpp
08db81e2e2c7d257f3bb337ccfaa8c6b5bb4cd98
[]
no_license
Sachindebug/100DaysOfCode
0267a8be04a753111a866f9b26bb1a9380e43bc1
e22b82d0fab14a147f69d89085b317198f3329f1
refs/heads/main
2023-06-27T14:57:33.267415
2021-06-30T05:20:48
2021-06-30T05:20:48
373,736,609
1
0
null
null
null
null
UTF-8
C++
false
false
831
cpp
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { ListNode *p1 = headA; ListNode *p2 = headB; if (p1 == NULL || p2 == NULL) return NULL; while (p1 != NULL && p2 != NULL && p1 != p2) { p1 = p1->next; p2 = p2->next; // // Any time they collide or reach end together without colliding // then return any one of the pointers. // if (p1 == p2) return p1; // // If one of them reaches the end earlier then reuse it // by moving it to the beginning of other list. // Once both of them go through reassigning, // they will be equidistant from the collision point. // if (p1 == NULL) p1 = headB; if (p2 == NULL) p2 = headA; } return p1; }
[ "noreply@github.com" ]
noreply@github.com
a96476c345420e047f79df33e851336a9b45d1cc
3ff1fe3888e34cd3576d91319bf0f08ca955940f
/tcss/src/v20201101/model/ReverseShellWhiteListBaseInfo.cpp
9f1e2be84e9a158bfeefb273cac0cefbb7485575
[ "Apache-2.0" ]
permissive
TencentCloud/tencentcloud-sdk-cpp
9f5df8220eaaf72f7eaee07b2ede94f89313651f
42a76b812b81d1b52ec6a217fafc8faa135e06ca
refs/heads/master
2023-08-30T03:22:45.269556
2023-08-30T00:45:39
2023-08-30T00:45:39
188,991,963
55
37
Apache-2.0
2023-08-17T03:13:20
2019-05-28T08:56:08
C++
UTF-8
C++
false
false
10,731
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/tcss/v20201101/model/ReverseShellWhiteListBaseInfo.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Tcss::V20201101::Model; using namespace std; ReverseShellWhiteListBaseInfo::ReverseShellWhiteListBaseInfo() : m_idHasBeenSet(false), m_imageCountHasBeenSet(false), m_processNameHasBeenSet(false), m_dstIpHasBeenSet(false), m_createTimeHasBeenSet(false), m_updateTimeHasBeenSet(false), m_dstPortHasBeenSet(false), m_isGlobalHasBeenSet(false), m_imageIdsHasBeenSet(false) { } CoreInternalOutcome ReverseShellWhiteListBaseInfo::Deserialize(const rapidjson::Value &value) { string requestId = ""; if (value.HasMember("Id") && !value["Id"].IsNull()) { if (!value["Id"].IsString()) { return CoreInternalOutcome(Core::Error("response `ReverseShellWhiteListBaseInfo.Id` IsString=false incorrectly").SetRequestId(requestId)); } m_id = string(value["Id"].GetString()); m_idHasBeenSet = true; } if (value.HasMember("ImageCount") && !value["ImageCount"].IsNull()) { if (!value["ImageCount"].IsUint64()) { return CoreInternalOutcome(Core::Error("response `ReverseShellWhiteListBaseInfo.ImageCount` IsUint64=false incorrectly").SetRequestId(requestId)); } m_imageCount = value["ImageCount"].GetUint64(); m_imageCountHasBeenSet = true; } if (value.HasMember("ProcessName") && !value["ProcessName"].IsNull()) { if (!value["ProcessName"].IsString()) { return CoreInternalOutcome(Core::Error("response `ReverseShellWhiteListBaseInfo.ProcessName` IsString=false incorrectly").SetRequestId(requestId)); } m_processName = string(value["ProcessName"].GetString()); m_processNameHasBeenSet = true; } if (value.HasMember("DstIp") && !value["DstIp"].IsNull()) { if (!value["DstIp"].IsString()) { return CoreInternalOutcome(Core::Error("response `ReverseShellWhiteListBaseInfo.DstIp` IsString=false incorrectly").SetRequestId(requestId)); } m_dstIp = string(value["DstIp"].GetString()); m_dstIpHasBeenSet = true; } if (value.HasMember("CreateTime") && !value["CreateTime"].IsNull()) { if (!value["CreateTime"].IsString()) { return CoreInternalOutcome(Core::Error("response `ReverseShellWhiteListBaseInfo.CreateTime` IsString=false incorrectly").SetRequestId(requestId)); } m_createTime = string(value["CreateTime"].GetString()); m_createTimeHasBeenSet = true; } if (value.HasMember("UpdateTime") && !value["UpdateTime"].IsNull()) { if (!value["UpdateTime"].IsString()) { return CoreInternalOutcome(Core::Error("response `ReverseShellWhiteListBaseInfo.UpdateTime` IsString=false incorrectly").SetRequestId(requestId)); } m_updateTime = string(value["UpdateTime"].GetString()); m_updateTimeHasBeenSet = true; } if (value.HasMember("DstPort") && !value["DstPort"].IsNull()) { if (!value["DstPort"].IsString()) { return CoreInternalOutcome(Core::Error("response `ReverseShellWhiteListBaseInfo.DstPort` IsString=false incorrectly").SetRequestId(requestId)); } m_dstPort = string(value["DstPort"].GetString()); m_dstPortHasBeenSet = true; } if (value.HasMember("IsGlobal") && !value["IsGlobal"].IsNull()) { if (!value["IsGlobal"].IsBool()) { return CoreInternalOutcome(Core::Error("response `ReverseShellWhiteListBaseInfo.IsGlobal` IsBool=false incorrectly").SetRequestId(requestId)); } m_isGlobal = value["IsGlobal"].GetBool(); m_isGlobalHasBeenSet = true; } if (value.HasMember("ImageIds") && !value["ImageIds"].IsNull()) { if (!value["ImageIds"].IsArray()) return CoreInternalOutcome(Core::Error("response `ReverseShellWhiteListBaseInfo.ImageIds` is not array type")); const rapidjson::Value &tmpValue = value["ImageIds"]; for (rapidjson::Value::ConstValueIterator itr = tmpValue.Begin(); itr != tmpValue.End(); ++itr) { m_imageIds.push_back((*itr).GetString()); } m_imageIdsHasBeenSet = true; } return CoreInternalOutcome(true); } void ReverseShellWhiteListBaseInfo::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const { if (m_idHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Id"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_id.c_str(), allocator).Move(), allocator); } if (m_imageCountHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "ImageCount"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, m_imageCount, allocator); } if (m_processNameHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "ProcessName"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_processName.c_str(), allocator).Move(), allocator); } if (m_dstIpHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "DstIp"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_dstIp.c_str(), allocator).Move(), allocator); } if (m_createTimeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "CreateTime"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_createTime.c_str(), allocator).Move(), allocator); } if (m_updateTimeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "UpdateTime"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_updateTime.c_str(), allocator).Move(), allocator); } if (m_dstPortHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "DstPort"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_dstPort.c_str(), allocator).Move(), allocator); } if (m_isGlobalHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "IsGlobal"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, m_isGlobal, allocator); } if (m_imageIdsHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "ImageIds"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator); for (auto itr = m_imageIds.begin(); itr != m_imageIds.end(); ++itr) { value[key.c_str()].PushBack(rapidjson::Value().SetString((*itr).c_str(), allocator), allocator); } } } string ReverseShellWhiteListBaseInfo::GetId() const { return m_id; } void ReverseShellWhiteListBaseInfo::SetId(const string& _id) { m_id = _id; m_idHasBeenSet = true; } bool ReverseShellWhiteListBaseInfo::IdHasBeenSet() const { return m_idHasBeenSet; } uint64_t ReverseShellWhiteListBaseInfo::GetImageCount() const { return m_imageCount; } void ReverseShellWhiteListBaseInfo::SetImageCount(const uint64_t& _imageCount) { m_imageCount = _imageCount; m_imageCountHasBeenSet = true; } bool ReverseShellWhiteListBaseInfo::ImageCountHasBeenSet() const { return m_imageCountHasBeenSet; } string ReverseShellWhiteListBaseInfo::GetProcessName() const { return m_processName; } void ReverseShellWhiteListBaseInfo::SetProcessName(const string& _processName) { m_processName = _processName; m_processNameHasBeenSet = true; } bool ReverseShellWhiteListBaseInfo::ProcessNameHasBeenSet() const { return m_processNameHasBeenSet; } string ReverseShellWhiteListBaseInfo::GetDstIp() const { return m_dstIp; } void ReverseShellWhiteListBaseInfo::SetDstIp(const string& _dstIp) { m_dstIp = _dstIp; m_dstIpHasBeenSet = true; } bool ReverseShellWhiteListBaseInfo::DstIpHasBeenSet() const { return m_dstIpHasBeenSet; } string ReverseShellWhiteListBaseInfo::GetCreateTime() const { return m_createTime; } void ReverseShellWhiteListBaseInfo::SetCreateTime(const string& _createTime) { m_createTime = _createTime; m_createTimeHasBeenSet = true; } bool ReverseShellWhiteListBaseInfo::CreateTimeHasBeenSet() const { return m_createTimeHasBeenSet; } string ReverseShellWhiteListBaseInfo::GetUpdateTime() const { return m_updateTime; } void ReverseShellWhiteListBaseInfo::SetUpdateTime(const string& _updateTime) { m_updateTime = _updateTime; m_updateTimeHasBeenSet = true; } bool ReverseShellWhiteListBaseInfo::UpdateTimeHasBeenSet() const { return m_updateTimeHasBeenSet; } string ReverseShellWhiteListBaseInfo::GetDstPort() const { return m_dstPort; } void ReverseShellWhiteListBaseInfo::SetDstPort(const string& _dstPort) { m_dstPort = _dstPort; m_dstPortHasBeenSet = true; } bool ReverseShellWhiteListBaseInfo::DstPortHasBeenSet() const { return m_dstPortHasBeenSet; } bool ReverseShellWhiteListBaseInfo::GetIsGlobal() const { return m_isGlobal; } void ReverseShellWhiteListBaseInfo::SetIsGlobal(const bool& _isGlobal) { m_isGlobal = _isGlobal; m_isGlobalHasBeenSet = true; } bool ReverseShellWhiteListBaseInfo::IsGlobalHasBeenSet() const { return m_isGlobalHasBeenSet; } vector<string> ReverseShellWhiteListBaseInfo::GetImageIds() const { return m_imageIds; } void ReverseShellWhiteListBaseInfo::SetImageIds(const vector<string>& _imageIds) { m_imageIds = _imageIds; m_imageIdsHasBeenSet = true; } bool ReverseShellWhiteListBaseInfo::ImageIdsHasBeenSet() const { return m_imageIdsHasBeenSet; }
[ "tencentcloudapi@tencent.com" ]
tencentcloudapi@tencent.com
d540f9e2bd15501d6a37a05ddd94b94789f39481
24bc4990e9d0bef6a42a6f86dc783785b10dbd42
/chrome/browser/thumbnail/cc/thumbnail_cache_unittest.cc
be73747681cc35a43fa504338f2427e3fc3e7e1f
[ "BSD-3-Clause" ]
permissive
nwjs/chromium.src
7736ce86a9a0b810449a3b80a4af15de9ef9115d
454f26d09b2f6204c096b47f778705eab1e3ba46
refs/heads/nw75
2023-08-31T08:01:39.796085
2023-04-19T17:25:53
2023-04-19T17:25:53
50,512,158
161
201
BSD-3-Clause
2023-05-08T03:19:09
2016-01-27T14:17:03
null
UTF-8
C++
false
false
6,122
cc
// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/thumbnail/cc/thumbnail_cache.h" #include "base/memory/weak_ptr.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "cc/resources/ui_resource_client.h" #include "chrome/browser/thumbnail/cc/features.h" #include "content/public/test/browser_task_environment.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/android/ui_android_export.h" namespace thumbnail { namespace { constexpr int kKiB = 1024; constexpr int kN32PixelSize = 4; constexpr int kDefaultCacheSize = 3; constexpr int kApproximationCacheSize = 5; constexpr int kCompressionQueueMaxSize = 2; constexpr int kWriteQueueMaxSize = 2; constexpr bool kUseApproximationThumbnail = true; constexpr bool kSaveJpegThumbnails = true; constexpr double kJpegAspectRatio = 0.85; class MockUIResourceProvider : public ui::UIResourceProvider { public: MOCK_METHOD(cc::UIResourceId, CreateUIResource, (cc::UIResourceClient*), (override)); MOCK_METHOD(void, DeleteUIResource, (cc::UIResourceId), (override)); MOCK_METHOD(bool, SupportsETC1NonPowerOfTwo, (), (const, override)); base::WeakPtr<UIResourceProvider> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } private: base::WeakPtrFactory<MockUIResourceProvider> weak_factory_{this}; }; } // namespace class ThumbnailCacheTest : public ::testing::Test { protected: void SetUp() override { thumbnail_cache_ = std::make_unique<ThumbnailCache>( kDefaultCacheSize, kApproximationCacheSize, kCompressionQueueMaxSize, kWriteQueueMaxSize, kUseApproximationThumbnail, kSaveJpegThumbnails, kJpegAspectRatio); thumbnail_cache_->SetUIResourceProvider(ui_resource_provider_.GetWeakPtr()); EXPECT_CALL(ui_resource_provider_, CreateUIResource(::testing::_)) .WillRepeatedly(::testing::Return(1)); } void TearDown() override {} ThumbnailCache& thumbnail_cache() { return *thumbnail_cache_; } void RecordCacheMetrics() { thumbnail_cache_->RecordCacheMetrics(); } content::BrowserTaskEnvironment task_environment_; private: MockUIResourceProvider ui_resource_provider_; std::unique_ptr<ThumbnailCache> thumbnail_cache_; }; // TODO(crbug.com/1402843): Tests are being added in the process of refactoring // and optimizing the ThumbnailCache for modern usage add more tests here. TEST_F(ThumbnailCacheTest, PruneCache) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures({kThumbnailCacheRefactor}, {}); constexpr int kTabId1 = 1; constexpr int kTabId2 = 2; constexpr int kDimension = 16; SkBitmap bitmap; ASSERT_TRUE(bitmap.tryAllocN32Pixels(kDimension * kKiB, kDimension)); bitmap.setImmutable(); EXPECT_TRUE(thumbnail_cache().CheckAndUpdateThumbnailMetaData( kTabId1, GURL("https://www.foo.com/"))); thumbnail_cache().Put(kTabId1, bitmap, /*thumbnail_scale=*/1.0f, kJpegAspectRatio); EXPECT_TRUE(thumbnail_cache().CheckAndUpdateThumbnailMetaData( kTabId2, GURL("https://www.bar.com/"))); thumbnail_cache().Put(kTabId2, bitmap, /*thumbnail_scale=*/1.0f, kJpegAspectRatio); EXPECT_TRUE(thumbnail_cache().Get(kTabId1, false, false)); EXPECT_TRUE(thumbnail_cache().Get(kTabId2, false, false)); thumbnail_cache().UpdateVisibleIds({kTabId1, kTabId2}, kTabId1); EXPECT_TRUE(thumbnail_cache().Get(kTabId1, false, false)); EXPECT_TRUE(thumbnail_cache().Get(kTabId2, false, false)); thumbnail_cache().UpdateVisibleIds({kTabId1, kTabId2}, -1); EXPECT_TRUE(thumbnail_cache().Get(kTabId1, false, false)); EXPECT_TRUE(thumbnail_cache().Get(kTabId2, false, false)); thumbnail_cache().UpdateVisibleIds({kTabId2}, kTabId1); EXPECT_FALSE(thumbnail_cache().Get(kTabId1, false, false)); EXPECT_TRUE(thumbnail_cache().Get(kTabId2, false, false)); thumbnail_cache().UpdateVisibleIds({kTabId1}, kTabId1); // The thumbnail will not be paged in yet although will be scheduled. EXPECT_FALSE(thumbnail_cache().Get(kTabId1, false, false)); EXPECT_FALSE(thumbnail_cache().Get(kTabId2, false, false)); } TEST_F(ThumbnailCacheTest, MetricsEmission) { base::HistogramTester histograms; histograms.ExpectTotalCount("Android.ThumbnailCache.InMemoryCacheEntries", 0); histograms.ExpectTotalCount("Android.ThumbnailCache.InMemoryCacheSize", 0); histograms.ExpectTotalCount( "Android.ThumbnailCache.InMemoryApproximationCacheEntries", 0); histograms.ExpectTotalCount( "Android.ThumbnailCache.InMemoryApproximationCacheSize", 0); SkBitmap bitmap; constexpr int kTabId = 4; constexpr int kDimension = 4; ASSERT_TRUE(bitmap.tryAllocN32Pixels(kDimension * kKiB, kDimension)); bitmap.setImmutable(); EXPECT_TRUE(thumbnail_cache().CheckAndUpdateThumbnailMetaData( kTabId, GURL("https://www.foo.com/"))); thumbnail_cache().Put(kTabId, bitmap, /*thumbnail_scale=*/1.0f, kJpegAspectRatio); RecordCacheMetrics(); histograms.ExpectTotalCount("Android.ThumbnailCache.InMemoryCacheEntries", 1); histograms.ExpectTotalCount("Android.ThumbnailCache.InMemoryCacheSize", 1); histograms.ExpectUniqueSample("Android.ThumbnailCache.InMemoryCacheEntries", 1, 1); histograms.ExpectUniqueSample("Android.ThumbnailCache.InMemoryCacheSize", kDimension * kDimension * kN32PixelSize, 1); histograms.ExpectTotalCount( "Android.ThumbnailCache.InMemoryApproximationCacheEntries", 1); histograms.ExpectTotalCount( "Android.ThumbnailCache.InMemoryApproximationCacheSize", 1); histograms.ExpectUniqueSample( "Android.ThumbnailCache.InMemoryApproximationCacheEntries", 1, 1); histograms.ExpectUniqueSample( "Android.ThumbnailCache.InMemoryApproximationCacheSize", kN32PixelSize, 1); } } // namespace thumbnail
[ "roger@nwjs.io" ]
roger@nwjs.io
2ed2ecd733f7f45e3f67e7215003dc60675609bf
621e8282a397f5c10fcd0195d414bc6082990677
/socket服务端/SocketAPP.cpp
5aaae3258819f0048f5f1b09e81d18c9ba234e99
[]
no_license
shaozhanyu/C_WeChat-public-number
ac6b94865c30e75db8d6cb7415704421c9c4160f
110570e62d99b926128a7e8ccac8fe8b21121e58
refs/heads/master
2021-06-23T20:23:03.484132
2020-10-28T05:48:37
2020-10-28T05:48:37
131,083,294
0
1
null
null
null
null
GB18030
C++
false
false
17,898
cpp
#pragma once #include "stdafx.h" #include "SocketAPP.h" #include "mcom.h" ////////////////////////////////////////////////////// #define FLAG_THRED_EXIT 0xFFFFFFFF CTestTask *pTaskAPP=new CTestTask(1);//创建任务 /////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////// unsigned __stdcall RecvThread( void* pArguments ) { CSocketAPP* pParent = reinterpret_cast<CSocketAPP*>(pArguments); if (NULL == pParent) { //log return -1; } return pParent->IOCP_Recv(); } /////////////////Winsocket初始化///////////////////////////////// class windowsSocketInit { public: windowsSocketInit(): m_init(false) { WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD(2, 2); //加载dll err = WSAStartup(wVersionRequested, &wsaData); if (err != 0) { return; } else { printf("加载WSAdll成功!\r\n"); } if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { //printf("Could not find a usable version of Winsock.dll\n"); WSACleanup(); return ; } else { m_init = true; //printf("The Winsock 2.2 dll was found okay\n"); } } ~windowsSocketInit() { //卸载dll if (m_init) { WSACleanup(); } } private: bool m_init; }; CSocketAPP::CSocketAPP() { //static windowsSocketInit loadDLLOnce; m_sockfd = -1; m_newClinetSockfd = -1; m_CompletionPort = INVALID_HANDLE_VALUE; memset(&m_overlap,0,sizeof(WSAOVERLAPPED)); } CSocketAPP::~CSocketAPP() { //等待子线程关闭,否则会崩溃 Close(); } int CSocketAPP::Create(char* cIP,int iPort,bool bRebind) { if (NULL == cIP || 0 > iPort) { return -1; } char opt=1; if((m_sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))<0) { #ifdef _PrintError_ perror("socket"); #endif return -2; } else { printf("APP服务端创建socket套接字\r\n"); } // 创建IOCP的内核对象 /**** * 需要用到的函数的原型: * HANDLE WINAPI CreateIoCompletionPort( * __in HANDLE FileHandle, // 已经打开的文件句柄或者空句柄,一般是客户端的句柄 * __in HANDLE ExistingCompletionPort, // 已经存在的IOCP句柄 * __in ULONG_PTR CompletionKey, // 完成键,包含了指定I/O完成包的指定文件 * __in DWORD NumberOfConcurrentThreads // 真正并发同时执行最大线程数,一般推介是CPU核心数*2 * ); ****/ // Create completion port,创建内核队列IOCP m_CompletionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);////创建完成端口句柄 if (NULL == m_CompletionPort){ // 创建IO内核对象失败 printf("CreateIoCompletionPort failed. Error: %d" , GetLastError()); system("pause"); return -1; } // 绑定SOCKET到本机 struct sockaddr_in clientAddr; clientAddr.sin_family=AF_INET; clientAddr.sin_port=htons(iPort); if(bRebind) { setsockopt(m_sockfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));//SO_REUSEADDR是让端口释放后立即就可以被再次使用 } if(0 == strlen(cIP)) { clientAddr.sin_addr.s_addr=htonl(INADDR_ANY); //监听所有IP地址段 } else { clientAddr.sin_addr.s_addr=inet_addr(cIP); //监听指定的IP } int ret = bind(m_sockfd, (struct sockaddr *)&clientAddr, sizeof(clientAddr));//绑定套接字 if ( -1 == ret) { #ifdef _PrintError printf("bind failed %s \n", strerror(errno)); #endif return -3; } else { printf("APP服务端绑定套接字成功!\r\n"); } //某些具体程序要求待未发送完的数据发送出去后再关闭socket,可通过设置让程序满足要求: struct linger { u_short l_onoff; u_short l_linger; }; linger m_sLinger; m_sLinger.l_onoff = 1; //在调用closesocket()时还有数据未发送完,允许等待 // 若m_sLinger.l_onoff=0;则调用closesocket()后强制关闭 m_sLinger.l_linger = 2; //设置等待时间为2秒 setsockopt(m_sockfd, SOL_SOCKET, SO_LINGER, ( const char* )&m_sLinger, sizeof( linger ) ); #define SIO_RCVALL _WSAIOW(IOC_VENDOR,1) #define SIO_RCVALL_MCAST _WSAIOW(IOC_VENDOR,2) #define SIO_RCVALL_IGMPMCAST _WSAIOW(IOC_VENDOR,3) #define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4) #define SIO_ABSORB_RTRALERT _WSAIOW(IOC_VENDOR,5) #define SIO_UCAST_IF _WSAIOW(IOC_VENDOR,6) #define SIO_LIMIT_BROADCASTS _WSAIOW(IOC_VENDOR,7) #define SIO_INDEX_BIND _WSAIOW(IOC_VENDOR,8) #define SIO_INDEX_MCASTIF _WSAIOW(IOC_VENDOR,9) #define SIO_INDEX_ADD_MCAST _WSAIOW(IOC_VENDOR,10) #define SIO_INDEX_DEL_MCAST _WSAIOW(IOC_VENDOR,11) struct tcp_keepalive { u_long onoff; u_long keepalivetime; //第一次开始发送的时间(单位毫秒) u_long keepaliveinterval;//每次检测的间隔 (单位毫秒) }; // 开启KeepAlive BOOL bKeepAlive = TRUE; int nRet = setsockopt(m_sockfd, SOL_SOCKET, SO_KEEPALIVE, (char*)&bKeepAlive, sizeof(bKeepAlive)); if (nRet == SOCKET_ERROR) { printf("open-keepalive-error\r\n"); return -11; } // 设置KeepAlive参数 tcp_keepalive alive_in = { 0 }; tcp_keepalive alive_out = { 0 }; alive_in.keepalivetime = 20000; // 开始首次KeepAlive探测前的TCP空闭时间 alive_in.keepaliveinterval = 1000; // 两次KeepAlive探测间的时间间隔 alive_in.onoff = TRUE; unsigned long ulBytesReturn = 0; nRet = WSAIoctl(m_sockfd, SIO_KEEPALIVE_VALS, &alive_in, sizeof(alive_in), &alive_out, sizeof(alive_out), &ulBytesReturn, NULL, NULL); if (nRet == SOCKET_ERROR) { printf("set-keepalive-error\r\n"); return -12; } //在send(),recv()过程中有时由于网络状况等原因,发收不能预期进行,而设置收发时限: //int nNetTimeout=1000;//1秒 //发送时限 //setsockopt(m_sockfd , SOL_SOCKET , SO_SNDTIMEO ,(char *)&nNetTimeout,sizeof(int)); //接收时限 //setsockopt(m_sockfd , SOL_SOCKET , SO_RCVTIMEO ,(char *)&nNetTimeout,sizeof(int)); return 0; } int CSocketAPP::Listen(int lNum ) { if(0 > lNum) { return -1; } if(-1 == m_sockfd) { return -2; } if(listen(m_sockfd,lNum)<0) { #ifdef _PrintError_ perror("listen"); #endif return -3; } else { printf("APP服务端启动监听成功!\r\n"); } // 创建IOCP线程--线程里面创建线程池 // 确定处理器的核心数量比如4核心8核心 SYSTEM_INFO systeminfo; GetSystemInfo(&systeminfo); int workThredNum = systeminfo.dwNumberOfProcessors*2; if (0 > workThredNum) { return -4; } printf("CPU核心数:%d\r\n" , workThredNum/2); // 基于处理器的核心数量创建线程 for (int i = 0; i < workThredNum; i++) { unsigned threadID; /*********_beginthreadex()函数在创建新线程时会分配并初始化一个_tiddata块。 这个_tiddata块自然是用来存放一些需要线程独享的数据。 事实上新线程运行时会首先将_tiddata块与自己进一步关联起来。 然后新线程调用标准C运行库函数如strtok()时就会先取得_tiddata块的地址再将需要保护的数据存入_tiddata块中。 这样每个线程就只会访问和修改自己的数据而不会去篡改其它线程的数据了。 因此,如果在代码中有使用标准C运行库中的函数时,尽量使用_beginthreadex()来代替CreateThread()。 *********/ HANDLE hWorkThread = (HANDLE)_beginthreadex( NULL, 0, &RecvThread, this, 0, &threadID );//创建线程,this指针 m_IOCPThread.insert(hWorkThread);//把新建的线程句柄加入句柄集合中 } // 开始处理IO数据 printf( "APP软件socket服务器已就绪,正在等待客户端接入....\r\n"); return 0; } void CSocketAPP::closeAllClient() { //会唤醒所有线程,并通知退出线程; //close all thread int iThreadNum = m_IOCPThread.size(); if (0 < iThreadNum) { //notice all thread exit for (int i = 0; i < iThreadNum;++i) { DWORD dwNumberOfBytesTrlansferred = FLAG_THRED_EXIT; DWORD dwCompletlonKey = 0; PostQueuedCompletionStatus(m_CompletionPort,dwNumberOfBytesTrlansferred,DWORD(dwCompletlonKey), &m_overlap); } //wait for thread close; for (set<HANDLE>::iterator itor = m_IOCPThread.begin();itor != m_IOCPThread.end();++itor) { HANDLE threadHandle = (*itor); WaitForSingleObject(threadHandle,INFINITE); CloseHandle(threadHandle); } m_IOCPThread.clear(); } //clear resource if (INVALID_HANDLE_VALUE != m_CompletionPort ) { CloseHandle(m_CompletionPort); m_CompletionPort = INVALID_HANDLE_VALUE; } for (set<IOCPContextKeyAPP*>::iterator itor = m_setIOCPKEY.begin();itor != m_setIOCPKEY.end();++itor) { IOCPContextKeyAPP* pIOCPKey = (*itor); if (NULL == pIOCPKey) { continue; } //close all client shutdown(pIOCPKey->clientSocket,SD_BOTH); closesocket(pIOCPKey->clientSocket); delete pIOCPKey; pIOCPKey = NULL; } m_setIOCPKEY.clear(); } /***** IOCP端口完成运行主线程 ********/ int CSocketAPP::IOCP_Recv() { DWORD dwBytesTransfered = 0; void* pVoidContextKey = NULL; //OVERLAPPED* pOverlapped = NULL; int* pnThreadNo = NULL; IOCPContextKeyAPP *pIOCPContext = NULL ; //类指针必须new,因为没有实例化,而对象是直接实例化到内存的 SOCKET nSocket = -1; DWORD sendBytes = 0; DWORD recvBytes = 0; DWORD Flags = 0; BOOL nRetCode = false; while (true) { /***GetQueuedCompletionStatus功能:获取队列完成状态。 返回值:调用成功,则返回非零数值,相关数据存于lpNumberOfBytes、lpCompletionKey、lpoverlapped变量中。 失败则返回零值。****/ nRetCode = GetQueuedCompletionStatus(m_CompletionPort,&dwBytesTransfered,(PULONG_PTR)&pVoidContextKey, (LPOVERLAPPED *)&m_overlap,INFINITE); pIOCPContext = (IOCPContextKeyAPP *)pVoidContextKey;//获取当前连接,类指针指向一个实例指针 if (TRUE == nRetCode && FLAG_THRED_EXIT == dwBytesTransfered && 0 == pVoidContextKey) { //service exit thread break; } if (FALSE == nRetCode && 0 == dwBytesTransfered && NULL == pVoidContextKey) { //CloseHandle(m_CompletionPort); //完成端口关闭 //break; //client close tcp if (0 == m_setIOCPKEY.size()) { break; } { CLockMutex::Lock lock(m_mutex);//创建结构体类lock,初始化锁变量给构造函数,出函数,自动解析释放解锁 m_setIOCPKEY.erase(pIOCPContext);//删除当前连接 } shutdown(pIOCPContext->clientSocket, SD_BOTH); closesocket(pIOCPContext->clientSocket); delete pIOCPContext;//释放类指针 pIOCPContext = NULL; continue; } if (TRUE == nRetCode && 0 == dwBytesTransfered && NULL != pVoidContextKey) { //client close tcp if (0 == m_setIOCPKEY.size()) { break; } { CLockMutex::Lock lock(m_mutex);//创建结构体类lock,初始化锁变量给构造函数,出函数,自动解析释放解锁 m_setIOCPKEY.erase(pIOCPContext);//删除当前连接 } shutdown(pIOCPContext->clientSocket,SD_BOTH); closesocket(pIOCPContext->clientSocket); delete pIOCPContext;//释放类指针 pIOCPContext = NULL; continue; } if (NULL == pVoidContextKey) { //不许key为NULL continue; } nSocket = pIOCPContext->clientSocket; //获取当前的socket连接 //业务逻辑处理 switch(pIOCPContext->opType) { case APP_RECV_POSTED: //1) 收到客户端数据流 { if( (dwBytesTransfered > 0) && dwBytesTransfered < REC_SIZE) { EnterCriticalSection(&mAPP_RECLock);//加锁 memcpy( mAPP_RevUnit.RecData , pIOCPContext->Buffer.buf ,dwBytesTransfered); mAPP_RevUnit.DataLen = dwBytesTransfered; mAPP_RevUnit.SocketNum =nSocket; //totalcnt++; //cout<<"收到数据"<<totalcnt<<endl; //这里的任务队列其实就是存了需要执行的任务次数,触发一次,就入队一次。实际数据没有存储,是全局变量 APPthreadpool.addTask(pTaskAPP,NORMAL);//任务放入线程池中并执行任务,会唤醒挂起的线程,从而执行任务类的具体代码 LeaveCriticalSection(&mAPP_RECLock);//解锁 } /*****/ //投递下个RECV命令 memset(pIOCPContext->szMessage,0,pIOCPContext->Buffer.len);//当前缓存清0 pIOCPContext-> Buffer.len = DATA_LEN;//设置缓存大小 ZeroMemory( &m_overlap,sizeof(OVERLAPPED) ); pIOCPContext->NumberOfBytesRecv = 0; pIOCPContext->NumberOfBytesSend = 0; pIOCPContext->opType = APP_RECV_POSTED; int iRecv = WSARecv(nSocket,&pIOCPContext->Buffer,1,&recvBytes,&Flags,&m_overlap,NULL);//接收socket数据 if (SOCKET_ERROR == iRecv && WSA_IO_PENDING != WSAGetLastError()) { //接收错误,清除此socket if (0 == m_setIOCPKEY.size()) { break; } { CLockMutex::Lock lock(m_mutex);//创建结构体类lock,初始化锁变量给构造函数,出函数,自动解析释放解锁 m_setIOCPKEY.erase(pIOCPContext); } shutdown(pIOCPContext->clientSocket,SD_BOTH); closesocket(pIOCPContext->clientSocket); delete pIOCPContext; pIOCPContext = NULL; continue; } else { //ok } /**********/ #if 0 //pIOCPContext->NumberOfBytesRecv = dwBytesTransfered; pIOCPContext->opType = APP_SEND_POSTED; memcpy(pIOCPContext->Buffer.buf,"RECOK!",6); //设置发送数据长度(这个长度不可能超出收到缓存的长度) pIOCPContext->Buffer.len = 6; //do your logic by default send origin data //发送数据 WSASend函数,可以支持一次发送多个BUFFER的请求,减少了send的调用次数,实际检验证明,使用WSASend可以提高50%的性能甚至更多 int iRetSend = WSASend(nSocket,&pIOCPContext->Buffer,1,&sendBytes,0,&m_overlap,NULL); if (SOCKET_ERROR == iRetSend && WSA_IO_PENDING != WSAGetLastError()) { //发送错误,清除此socket if (0 == m_setIOCPKEY.size()) { break; } { CLockMutex::Lock lock(m_mutex);//创建结构体类lock,初始化锁变量给构造函数,出函数,自动解析释放解锁 m_setIOCPKEY.erase(pIOCPContext); } shutdown(pIOCPContext->clientSocket,SD_BOTH); closesocket(pIOCPContext->clientSocket); delete pIOCPContext; pIOCPContext = NULL; continue; } else { //ok } #endif }break; #if 0 case APP_SEND_POSTED : //业务逻辑处理 //2> 处理发送请求处理(必须处理的是继续投递信息) { /************** pIOCPContext->NumberOfBytesSend += dwBytesTransfered; //查看数据有没有发送完成(以目前接到到数据全部返回的默认例子,应该发送数据长度为原始接收到的数据长度) if ( pIOCPContext->NumberOfBytesSend < pIOCPContext->NumberOfBytesRecv ) { //没有发送完成,继续发送,否则就继续接收数据 pIOCPContext->Buffer.buf = pIOCPContext->Buffer.buf + pIOCPContext->NumberOfBytesSend; pIOCPContext->Buffer.len = (pIOCPContext->NumberOfBytesRecv - pIOCPContext->NumberOfBytesSend); int iRetSend = WSASend(nSocket,&pIOCPContext->Buffer,1,&sendBytes,0, &m_overlap,NULL); //继续发送剩余的 if (SOCKET_ERROR == iRetSend && WSA_IO_PENDING != WSAGetLastError()) { //发送错误,清除此socket if (0 == m_setIOCPKEY.size()) { break; } { CLockMutex::Lock lock(m_mutex);//创建结构体类lock,初始化锁变量给构造函数,出函数,自动解析释放解锁 m_setIOCPKEY.erase(pIOCPContext); } shutdown(pIOCPContext->clientSocket,SD_BOTH); closesocket(pIOCPContext->clientSocket); delete pIOCPContext; pIOCPContext = NULL; continue; } else { //ok } } else //发送完毕 *************/ /*******/ { //投递下个RECV命令 memset(pIOCPContext->Buffer.buf,0,pIOCPContext->Buffer.len);//接收缓存清0 pIOCPContext-> Buffer.len = DATA_LEN;//设置缓存大小 pIOCPContext->NumberOfBytesRecv = 0; pIOCPContext->NumberOfBytesSend = 0; pIOCPContext->opType = APP_RECV_POSTED; int iRecv = WSARecv(nSocket,&pIOCPContext->Buffer,1,&recvBytes,&Flags,&m_overlap,NULL);//接收socket数据 if (SOCKET_ERROR == iRecv && WSA_IO_PENDING != WSAGetLastError()) { //接收错误,清除此socket if (0 == m_setIOCPKEY.size()) { break; } { CLockMutex::Lock lock(m_mutex);//创建结构体类lock,初始化锁变量给构造函数,出函数,自动解析释放解锁 m_setIOCPKEY.erase(pIOCPContext); } shutdown(pIOCPContext->clientSocket,SD_BOTH); closesocket(pIOCPContext->clientSocket); delete pIOCPContext; pIOCPContext = NULL; continue; } else { //ok } } /*********/ }break; #endif default: break; }//end switch }//end while return 0; } void CSocketAPP::Close() { //关闭客户端 closeAllClient(); //关闭服务端socket if (-1 != m_sockfd) { //closesocket(m_sockfd); m_sockfd = -1; } } int CSocketAPP::GetLastError() { return WSAGetLastError(); } char* CSocketAPP::GetSocketIP() { sockaddr_in sin; int len = sizeof(sin); if(getsockname(m_sockfd, (struct sockaddr *)&sin, &len) != 0) { //printf("getsockname() error:%s\n", strerror(errno)); return NULL; } return inet_ntoa(sin.sin_addr); } int CSocketAPP::GetSocketPort() { sockaddr_in sin; int len = sizeof(sin); if(getsockname(m_sockfd, (struct sockaddr *)&sin, &len) != 0) { //printf("getsockname() error:%s\n", strerror(errno)); return 0; } return ntohs(sin.sin_port); }
[ "411656434@qq.com" ]
411656434@qq.com
79491ba2cb300d2b34860b4a49f93b3c1e65a194
26a3af56db7f16fc1a4ab85dd54e62d4a8c9e98b
/lab5pro2part2.ino
ebe209791b0091ce8fd4b133e30f20db9edb7e8c
[]
no_license
spencewalde/Temp-Humidity_Sensor_Arduino
dc81e6663286262637dfb481d7dc361b3f7a104d
184b10766f55305569b1fb5bf6db934922c902ab
refs/heads/master
2023-04-08T10:07:51.549784
2021-03-30T02:42:37
2021-03-30T02:42:37
261,230,244
0
0
null
null
null
null
UTF-8
C++
false
false
1,410
ino
#include <SparkFun_Si7021_Breakout_Library.h> #include <LiquidCrystal.h> #include <Wire.h> const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); float temp = 0; float humidity = 0; float mintemp = 0; float maxtemp = 0; float minhum = 0; float maxhum = 0; int count = 0; Weather sensor; void setup() { // put your setup code here, to run once: lcd.begin(16, 2); sensor.begin(); } void loop() { // put your main code here, to run repeatedly: temp = sensor.getTempF(); humidity = sensor.getRH(); if (count == 0) { mintemp = temp; maxtemp = temp; minhum = humidity; maxhum = humidity; } if (mintemp > temp) { mintemp = temp; } if (maxtemp < temp) { maxtemp = temp; } if (minhum > humidity) { minhum = humidity; } if (maxhum < humidity) { maxhum = humidity; } printTemp(mintemp, maxtemp, minhum, maxhum); delay(1000); lcd.clear(); count++; } void printTemp(float minF, float maxF, float minH, float maxH ) { lcd.print("T: "); lcd.print(minF); lcd.print("F,"); lcd.print(maxF); lcd.print("F"); lcd.setCursor(0, 1); lcd.print("H: "); lcd.print(minH); lcd.print("%,"); lcd.print(maxH); lcd.print("%"); } void printHumid() { lcd.print("humidity: "); lcd.print(humidity); lcd.print("%"); }
[ "noreply@github.com" ]
noreply@github.com
1eaa66c949fcd6d8d2c304a4ba753109702fd228
03f037d0f6371856ede958f0c9d02771d5402baf
/graphics/VTK-7.0.0/Infovis/Layout/vtkSplineGraphEdges.h
2ce33eee84f74a89ad1e0244ac7c93d02e65cc3b
[ "BSD-3-Clause" ]
permissive
hlzz/dotfiles
b22dc2dc5a9086353ed6dfeee884f7f0a9ddb1eb
0591f71230c919c827ba569099eb3b75897e163e
refs/heads/master
2021-01-10T10:06:31.018179
2016-09-27T08:13:18
2016-09-27T08:13:18
55,040,954
4
0
null
null
null
null
UTF-8
C++
false
false
3,037
h
/*========================================================================= Program: Visualization Toolkit Module: vtkSplineGraphEdges.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /*------------------------------------------------------------------------- Copyright 2008 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. -------------------------------------------------------------------------*/ // .NAME vtkSplineGraphEdges - subsample graph edges to make smooth curves // // .SECTION Description // vtkSplineGraphEdges uses a vtkSpline to make edges into nicely sampled // splines. By default, the filter will use an optimized b-spline. // Otherwise, it will use a custom vtkSpline instance set by the user. #ifndef vtkSplineGraphEdges_h #define vtkSplineGraphEdges_h #include "vtkInfovisLayoutModule.h" // For export macro #include "vtkGraphAlgorithm.h" #include "vtkSmartPointer.h" // For ivars class vtkSpline; class VTKINFOVISLAYOUT_EXPORT vtkSplineGraphEdges : public vtkGraphAlgorithm { public: static vtkSplineGraphEdges *New(); vtkTypeMacro(vtkSplineGraphEdges,vtkGraphAlgorithm); void PrintSelf(ostream& os, vtkIndent indent); // Description: // If SplineType is CUSTOM, uses this spline. virtual void SetSpline(vtkSpline* s); vtkGetObjectMacro(Spline, vtkSpline); //BTX enum { BSPLINE = 0, CUSTOM }; //ETX // Description: // Spline type used by the filter. // BSPLINE (0) - Use optimized b-spline (default). // CUSTOM (1) - Use spline set with SetSpline. vtkSetMacro(SplineType, int); vtkGetMacro(SplineType, int); // Description: // The number of subdivisions in the spline. vtkSetMacro(NumberOfSubdivisions, vtkIdType); vtkGetMacro(NumberOfSubdivisions, vtkIdType); protected: vtkSplineGraphEdges(); ~vtkSplineGraphEdges(); virtual int RequestData( vtkInformation *, vtkInformationVector **, vtkInformationVector *); virtual unsigned long GetMTime(); void GeneratePoints(vtkGraph* g, vtkIdType e); void GenerateBSpline(vtkGraph* g, vtkIdType e); vtkSpline* Spline; int SplineType; //BTX vtkSmartPointer<vtkSpline> XSpline; vtkSmartPointer<vtkSpline> YSpline; vtkSmartPointer<vtkSpline> ZSpline; //ETX vtkIdType NumberOfSubdivisions; private: vtkSplineGraphEdges(const vtkSplineGraphEdges&); // Not implemented. void operator=(const vtkSplineGraphEdges&); // Not implemented. }; #endif
[ "shentianweipku@gmail.com" ]
shentianweipku@gmail.com
6993a63e387d28e7e65749c62ec529dfff9bcc8f
e0b605809492e83430a539e6c05c7daec541cf37
/lec-06/testshapes.cpp
819d8719778e593537712f78c4735bf8fa3f372c
[]
no_license
ucsb-cs16-f19/ucsb-cs16-f19-lectures
470b822aecf1c494ed8c33eaa6f06e5672f079ec
17c453815fc0d859207a58f06ff832c9db4edeb1
refs/heads/master
2020-08-08T05:53:36.910767
2020-02-11T17:57:45
2020-02-11T17:57:45
213,743,094
0
0
null
null
null
null
UTF-8
C++
false
false
844
cpp
//testshapes.cpp #include <string> #include <iostream> using namespace std; string drawTriangle(int); void assertEqual(string actual, string expected, string message=""){ if(expected==actual){ cout<<"PASSED: "<<message<<endl; } else{ cout<<"FAILED: "<<message<<" Expected: [\n"<<expected <<"\n]"<<"Actual: [\n"<<actual<<"\n]"<<endl; } } // test suite for drawTriangle void test_drawTriangle(){ // Test cases: List of specific inputs and expected outputs // Case 1: int input; string act_output; input = 1; string exp_output; exp_output= "*\n"; act_output = drawTriangle(input); assertEqual(act_output, exp_output, "width = 1"); input = 3; exp_output = "-*-\n" "***\n"; act_output = drawTriangle(input); assertEqual(act_output, exp_output, "width = 3"); } int main(){ test_drawTriangle(); return 0; }
[ "dimirza@cs.ucsb.edu" ]
dimirza@cs.ucsb.edu
1b57b7c9131558943acf8431eb3c2d73035ec9f8
4cae422afc5224db8846d9c454a12ef627fd4909
/MyRenderer/IRenderTarget.h
804f4486a8d21fed859d87e15e6e255a58de2d41
[]
no_license
EternalWind/MyRenderer
90adcbd79e68634c225532018e6507f756ac22fa
973e9090470d4992a97ab7c1caf708ec314638fd
refs/heads/master
2016-09-10T01:03:30.824093
2014-06-07T06:06:13
2014-06-07T06:06:13
20,586,847
0
0
null
null
null
null
UTF-8
C++
false
false
335
h
#pragma once #include "ColorRGBA.h" class IRenderTarget { public: virtual void SetPixel(unsigned row, unsigned column, const ColorRGBA& color) = 0; virtual ColorRGBA PixelAt(unsigned row, unsigned column) const = 0; virtual unsigned Width() const = 0; virtual unsigned Height() const = 0; virtual ~IRenderTarget() = 0 {} };
[ "eternalwind@live.cn" ]
eternalwind@live.cn
e034173c8f8b5f6cedf58bbe723129b7d06121ba
9f520bcbde8a70e14d5870fd9a88c0989a8fcd61
/pitzDaily/811/pa
a071f69f318d375a7dd21e4bd8a3e89921ef5953
[]
no_license
asAmrita/adjoinShapOptimization
6d47c89fb14d090941da706bd7c39004f515cfea
079cbec87529be37f81cca3ea8b28c50b9ceb8c5
refs/heads/master
2020-08-06T21:32:45.429939
2019-10-06T09:58:20
2019-10-06T09:58:20
213,144,901
1
0
null
null
null
null
UTF-8
C++
false
false
104,852
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1806 | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "811"; object pa; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 6400 ( -0.122471713077 -0.122472308197 -0.122473982689 -0.1224772787 -0.12248226376 -0.1224890014 -0.122497577118 -0.122508360972 -0.122521795804 -0.122538472324 -0.122559924328 -0.122587211415 -0.122620211348 -0.122659359405 -0.122705665251 -0.122760442583 -0.122824900463 -0.122899770208 -0.122985200491 -0.123080378355 -0.123184423184 -0.123298596455 -0.123426124929 -0.123570556685 -0.123734612707 -0.123919323226 -0.124124488258 -0.124350154131 -0.12459721779 -0.124867057488 -0.125160997813 -0.125479272337 -0.125820099317 -0.12618145844 -0.126562759448 -0.126963369352 -0.127384209448 -0.127828935588 -0.128297173897 -0.128784238318 -0.129290870883 -0.129824677437 -0.130389777684 -0.130981330403 -0.131591937437 -0.13221591689 -0.132848653453 -0.133486235703 -0.134124844617 -0.134760912321 -0.135391154383 -0.136010240883 -0.136609349965 -0.13717765729 -0.137711354481 -0.138211711544 -0.138672610912 -0.139082549554 -0.139435805728 -0.139735915618 -0.139986217213 -0.140186900678 -0.140337739642 -0.140459127977 -0.140588368121 -0.140763799647 -0.14098626281 -0.141209477519 -0.141396723603 -0.141545071859 -0.141664360906 -0.141765769918 -0.141856460169 -0.141934297716 -0.142001460445 -0.142058124679 -0.142103733327 -0.142132930621 -0.142151247292 -0.14215894195 -0.122470936722 -0.122471568186 -0.122473086349 -0.122476275124 -0.12248147465 -0.122488405243 -0.122496952673 -0.122507267849 -0.122520167984 -0.122536625063 -0.122557787108 -0.122584594673 -0.122617329385 -0.122656297756 -0.122702188107 -0.122756139142 -0.122819943476 -0.122894488693 -0.122979715027 -0.123074491919 -0.123177448761 -0.123290513918 -0.123417394298 -0.123561287624 -0.123724872332 -0.123909179365 -0.124113788774 -0.124338972624 -0.124585681094 -0.124855082326 -0.125148341336 -0.125466108758 -0.125806699048 -0.126167458334 -0.126548288299 -0.126948614355 -0.12736907407 -0.127813825638 -0.128282573985 -0.128770111462 -0.129276442412 -0.129810448954 -0.130377287494 -0.130970281249 -0.13158173795 -0.13220674459 -0.132840670796 -0.13347972489 -0.134119819676 -0.134756483887 -0.135386323888 -0.136006367407 -0.136609211028 -0.137179790615 -0.137715334905 -0.138218289518 -0.138678429499 -0.13908641102 -0.139440006028 -0.139740098425 -0.139988483446 -0.140189421887 -0.140343080996 -0.140468700271 -0.140601705453 -0.140778487324 -0.141003949511 -0.14122694972 -0.141412763581 -0.141560481975 -0.141679346338 -0.141780826871 -0.141872165022 -0.141950863068 -0.142016609169 -0.142070668508 -0.142112302264 -0.142140050027 -0.142157572944 -0.142163356591 -0.122468733033 -0.122469704754 -0.122471050274 -0.122473914205 -0.122478822569 -0.122486313347 -0.122495236593 -0.12250493824 -0.122516935019 -0.122532674973 -0.122553194337 -0.122579302608 -0.122611382051 -0.122649690666 -0.122694661989 -0.122746748956 -0.122808673601 -0.122883067698 -0.122967888374 -0.123061313878 -0.123162283424 -0.123272866991 -0.123398301978 -0.123541685875 -0.123704225743 -0.123887056746 -0.124090584661 -0.124314892555 -0.12456063581 -0.124828964943 -0.125120995775 -0.125437677846 -0.12577774159 -0.126136996438 -0.1265159889 -0.126916190441 -0.127336097045 -0.127779878904 -0.128248907018 -0.12873806269 -0.129247656828 -0.129784118023 -0.130350949613 -0.130943943781 -0.131556437286 -0.132183072162 -0.132819280614 -0.133460939145 -0.134103901884 -0.134744016666 -0.135377468052 -0.135999521296 -0.136602112627 -0.137176254162 -0.137718510776 -0.138224073171 -0.138683661969 -0.139091319964 -0.139445074942 -0.13974537072 -0.139994614876 -0.140195352561 -0.140352668825 -0.140487887274 -0.140634501443 -0.140820520095 -0.141039383121 -0.141255766602 -0.141442617933 -0.141592700356 -0.141713727888 -0.141815977153 -0.141903846742 -0.141977658783 -0.142040395461 -0.142091264232 -0.142128604111 -0.142153606546 -0.142169031166 -0.142174463963 -0.122465554836 -0.122466518028 -0.122467621405 -0.122470153022 -0.122474300469 -0.12248141743 -0.122491969409 -0.122501387077 -0.122512165368 -0.122526775242 -0.122546299921 -0.122571473046 -0.122602624772 -0.12263967364 -0.122683002826 -0.12273419576 -0.122795144859 -0.122867134138 -0.122948421832 -0.12303754012 -0.123135972018 -0.123246025275 -0.123370444188 -0.123512116693 -0.123672953591 -0.123854069484 -0.12405596118 -0.124278756923 -0.124522997056 -0.124789672653 -0.125080133552 -0.125395210357 -0.125733703001 -0.126092225295 -0.126468413489 -0.126865857415 -0.127286436567 -0.127729864175 -0.128197670773 -0.128688688967 -0.129202554673 -0.129742586859 -0.130311023015 -0.130905110842 -0.131519412872 -0.132148642397 -0.132788101158 -0.133433476908 -0.13408055733 -0.134725134712 -0.135362895603 -0.135988512709 -0.136594800997 -0.137174391129 -0.137721709366 -0.138229897517 -0.138690774813 -0.139099153902 -0.139453361648 -0.139754092209 -0.140004038886 -0.140207998301 -0.140376974378 -0.140530490648 -0.14068923528 -0.140873222305 -0.141090059407 -0.141306613791 -0.141495200186 -0.141647150275 -0.141766832567 -0.141863038181 -0.141943874343 -0.142016171852 -0.142078355899 -0.142124501675 -0.142155441646 -0.142178199626 -0.142193724603 -0.142200042714 -0.122460624264 -0.122460800153 -0.122462032899 -0.122464437208 -0.122468688757 -0.122474680653 -0.122483828387 -0.122493761839 -0.122504611462 -0.122518541804 -0.12253688365 -0.122560905168 -0.122590807702 -0.122626973743 -0.122669634813 -0.122718757264 -0.12277616353 -0.122843157038 -0.122919804942 -0.123006035708 -0.123102512593 -0.123210706001 -0.123333216576 -0.123472784724 -0.12363128519 -0.123810021345 -0.124009542214 -0.124230175726 -0.124472380557 -0.124736966557 -0.125025095893 -0.125338388149 -0.125675786044 -0.126030776812 -0.12640417328 -0.1267992262 -0.12721765157 -0.127661244501 -0.12813021063 -0.12862367474 -0.129141494592 -0.129685406612 -0.130256562785 -0.130852923322 -0.13147001917 -0.132102834943 -0.132746591641 -0.133396826052 -0.134049232304 -0.134699481771 -0.135342925647 -0.135974015422 -0.136586049548 -0.137172002897 -0.137724919635 -0.138236851988 -0.138700156047 -0.139110246723 -0.139465854859 -0.139768373703 -0.14002201543 -0.140234852484 -0.14042089225 -0.140593435721 -0.140762073019 -0.140948672728 -0.141163321409 -0.141378984073 -0.141568822691 -0.141720485962 -0.141834738295 -0.141923751989 -0.142003888955 -0.142078136788 -0.142135901951 -0.142175069891 -0.14220214602 -0.142225838044 -0.142239542614 -0.142243720249 -0.122451882243 -0.122451790218 -0.12245362759 -0.122455860621 -0.122460024261 -0.122465576661 -0.122473791871 -0.122483222421 -0.122494128215 -0.12250751799 -0.122524366625 -0.122546862856 -0.12257604001 -0.122611322434 -0.122651464628 -0.1226972776 -0.12275054942 -0.122813097769 -0.122885598893 -0.122968222484 -0.123061368522 -0.123166713686 -0.123286640575 -0.123423551744 -0.123579176597 -0.123754641547 -0.123951080113 -0.124168866422 -0.124408462793 -0.124670509542 -0.124956018016 -0.125266265454 -0.125599928728 -0.125953516856 -0.126322955269 -0.126714068184 -0.127131226934 -0.1275753645 -0.128045966892 -0.128542235912 -0.129064023775 -0.129612173876 -0.130187064971 -0.130786927413 -0.131407950784 -0.132045432023 -0.13269458979 -0.133350851274 -0.134009816784 -0.13466703984 -0.135317678291 -0.13595608841 -0.136575679146 -0.137169160468 -0.137728593229 -0.138245539732 -0.138712816921 -0.1391264274 -0.139485758471 -0.139793380409 -0.140055397559 -0.14028214094 -0.140488039558 -0.140675920718 -0.140855014538 -0.141050543553 -0.141269163455 -0.141482912648 -0.141669492662 -0.141815085409 -0.141921808167 -0.1420100486 -0.142094874997 -0.142165739691 -0.142215486688 -0.142247874007 -0.142273583323 -0.142293813273 -0.142303141549 -0.14230660486 -0.122438933024 -0.122439667344 -0.122442454783 -0.122445432724 -0.122448216331 -0.12245334576 -0.122461306998 -0.122470194744 -0.122480660079 -0.122493288721 -0.122509500932 -0.122529992731 -0.122557468423 -0.122589993766 -0.122626846785 -0.122668956327 -0.122718459779 -0.12277715051 -0.122845521293 -0.122923472432 -0.123012421835 -0.12311429868 -0.123230829898 -0.123364168515 -0.123516139854 -0.123688175501 -0.123880089125 -0.124094153143 -0.124330722373 -0.124590296578 -0.124872180278 -0.125177955908 -0.125507660051 -0.125855876693 -0.12622236076 -0.126611145462 -0.127027376054 -0.127472074516 -0.127944455756 -0.128443692316 -0.128969567109 -0.129522375777 -0.130101939689 -0.130706524142 -0.1313327068 -0.131976047639 -0.132631806412 -0.133295347918 -0.133962198332 -0.13462782422 -0.135287267367 -0.13593478428 -0.136563636107 -0.137166072787 -0.137733513013 -0.138257411665 -0.138731127011 -0.139151386749 -0.13951844653 -0.139835957035 -0.140111398432 -0.140355925832 -0.140579119765 -0.140783375203 -0.140980980672 -0.141188678547 -0.141410945624 -0.141619151954 -0.141796088206 -0.141933387409 -0.1420392368 -0.142134281634 -0.142219228531 -0.142280875448 -0.1423210183 -0.142347022744 -0.142368891729 -0.142380613267 -0.142382384592 -0.142383567738 -0.122423990505 -0.122425491991 -0.122428400533 -0.122432206094 -0.122434451874 -0.122439497993 -0.122446353905 -0.122454578008 -0.122464504148 -0.122475103667 -0.122490661562 -0.12250999011 -0.12253445186 -0.122563409857 -0.122596664778 -0.122634745298 -0.122680579834 -0.122735312952 -0.122798749442 -0.122871579613 -0.122955733592 -0.123053222688 -0.123165519182 -0.123294883183 -0.123442670818 -0.123609801362 -0.12379762625 -0.124005250563 -0.124238582464 -0.124495542507 -0.124773343213 -0.125071914939 -0.12539594209 -0.125739464666 -0.126102188121 -0.126489839419 -0.126905696619 -0.127350852137 -0.127824940142 -0.128327240125 -0.128857410009 -0.129415364175 -0.13000051654 -0.13061104021 -0.131243693148 -0.131894212145 -0.132557909531 -0.133230120063 -0.133906315529 -0.134581898321 -0.135251830543 -0.135910252113 -0.136550182345 -0.137163461845 -0.137741203622 -0.138275067344 -0.138759038842 -0.139190459765 -0.139569992743 -0.139901610513 -0.140192972834 -0.140454833331 -0.140696586798 -0.140925173387 -0.141143463423 -0.141365220966 -0.14158642377 -0.141787668131 -0.141955817975 -0.142090009762 -0.142201616044 -0.14230148034 -0.142378188574 -0.142427161168 -0.142455831104 -0.142473458638 -0.142482536864 -0.142481196375 -0.142471668312 -0.142466457546 -0.122408043766 -0.122409829346 -0.122412332377 -0.122414633576 -0.122417269918 -0.122422905555 -0.122428688398 -0.122435867042 -0.122445400067 -0.122454901078 -0.122466975839 -0.122484775032 -0.122506677367 -0.122531681703 -0.12256124709 -0.122596041972 -0.122637216537 -0.122686857139 -0.122745001062 -0.122812599409 -0.12289145834 -0.12298350661 -0.123090150956 -0.123214179806 -0.123358290464 -0.123519062232 -0.123701526759 -0.123905311036 -0.124131705437 -0.124383034289 -0.124656465466 -0.124951511769 -0.125265573955 -0.125602565489 -0.125963027298 -0.126349745174 -0.126765243021 -0.127210790909 -0.12768650989 -0.128191942363 -0.128726676596 -0.129290329786 -0.129881995099 -0.130499696248 -0.131140221697 -0.131799388373 -0.13247254486 -0.133155003632 -0.133842179338 -0.134529413201 -0.135211616269 -0.135882850608 -0.136535984009 -0.137162699199 -0.137754173616 -0.138302436738 -0.138801786204 -0.139249311173 -0.139645203138 -0.139993563183 -0.140301882336 -0.140581904486 -0.140845462008 -0.141098766782 -0.141341774417 -0.141580322611 -0.141807976145 -0.141999061636 -0.142160714098 -0.142297177075 -0.142416486141 -0.142513676016 -0.142576277888 -0.142608618724 -0.142622707115 -0.142624273183 -0.142611656258 -0.14259005145 -0.142565757014 -0.142551075179 -0.122390993863 -0.122392830754 -0.122395295064 -0.122396516421 -0.122398909018 -0.122403540459 -0.122408200402 -0.122413820684 -0.122421222085 -0.122431152968 -0.122440495155 -0.122455072013 -0.122473903389 -0.122495332438 -0.122520514941 -0.122551635272 -0.122588470249 -0.122632282648 -0.122684253231 -0.122746044944 -0.122819354054 -0.122905629698 -0.123005883771 -0.123122164356 -0.123260878145 -0.123417482241 -0.123589902109 -0.123788406386 -0.124008173664 -0.124254176985 -0.124521682756 -0.124809711238 -0.125117548268 -0.125447592903 -0.125804548075 -0.126189916474 -0.126604932565 -0.127050807782 -0.127528092028 -0.128036702169 -0.128576290371 -0.1291462581 -0.129745409074 -0.130371579428 -0.131021498616 -0.131690980065 -0.132375360251 -0.133069899714 -0.133769920044 -0.134470679376 -0.135167075383 -0.135853233564 -0.136522172133 -0.137165877571 -0.13777601092 -0.138344735903 -0.138865320074 -0.139332672067 -0.139746964087 -0.140115681784 -0.140444502649 -0.14074435746 -0.14103020918 -0.141306653311 -0.141574303715 -0.141830252941 -0.142062417927 -0.142264087741 -0.14242283613 -0.142564769672 -0.142689546061 -0.142777413954 -0.142820702227 -0.142829478569 -0.142824717935 -0.142800993944 -0.142758200431 -0.142707120329 -0.142662251536 -0.142635448737 -0.122372407193 -0.122373861713 -0.122375944112 -0.122376873889 -0.122379590971 -0.122382084253 -0.122385171857 -0.122389081223 -0.122392813401 -0.122401210176 -0.12240896314 -0.122420370645 -0.122435747936 -0.122454096937 -0.122475225386 -0.122501162505 -0.12253294358 -0.122570956109 -0.122616422505 -0.122671396301 -0.122738207641 -0.122818593567 -0.122913566871 -0.123021287066 -0.123149225952 -0.123301513128 -0.123467390065 -0.123656438379 -0.123868711863 -0.124103050299 -0.124365304304 -0.124647221396 -0.124948556546 -0.125273116583 -0.125626245202 -0.126009474604 -0.126423586001 -0.12686964723 -0.127348442364 -0.127860257338 -0.128404971857 -0.12898190188 -0.129589577525 -0.130225605228 -0.130886599171 -0.131568315593 -0.132266016827 -0.132974824783 -0.133689869023 -0.134406268689 -0.135118954512 -0.135822392455 -0.136510286957 -0.137175716156 -0.137811342125 -0.138408413533 -0.138955784149 -0.139443405365 -0.13987750291 -0.140278448854 -0.140637507657 -0.140954900351 -0.141259089571 -0.14155430714 -0.141840591613 -0.14211065235 -0.142354917874 -0.142574386294 -0.142743848257 -0.142903920059 -0.143035817744 -0.143110143832 -0.143124459468 -0.143091359421 -0.143065618696 -0.143011269617 -0.142927685669 -0.142832488828 -0.142754975481 -0.142709307374 -0.122351929655 -0.122352643236 -0.122353236546 -0.122354463254 -0.122357172391 -0.122357998243 -0.122359499038 -0.122361846387 -0.122362642934 -0.122367060007 -0.122372499718 -0.12238061271 -0.122392042883 -0.122407048985 -0.122425217426 -0.122445534768 -0.122471078927 -0.122502709865 -0.122541370839 -0.122588768902 -0.122647352797 -0.122719896214 -0.122810105757 -0.122912697487 -0.123027949491 -0.123169663435 -0.123329735655 -0.123506707931 -0.123712526753 -0.123939026151 -0.124188873512 -0.124461627852 -0.124756657973 -0.125077314147 -0.125426724407 -0.125807144492 -0.126219808598 -0.126665822452 -0.127146097624 -0.127661163259 -0.128211227915 -0.128795750807 -0.129413059331 -0.130060462604 -0.130734421249 -0.131430622134 -0.132144189154 -0.132869951573 -0.133602659581 -0.134337140809 -0.135068417015 -0.135791632605 -0.136502074308 -0.137195145387 -0.137865505301 -0.138501228236 -0.13908035751 -0.139583868924 -0.140038260283 -0.140505326632 -0.140913957154 -0.141231218287 -0.141542857372 -0.141850375234 -0.142154488941 -0.142440844063 -0.142697760427 -0.142917419975 -0.143120405852 -0.143306403916 -0.143471471467 -0.143529981856 -0.143500086289 -0.143384598454 -0.143357737867 -0.143271742041 -0.14312943378 -0.142958374359 -0.142826690682 -0.142747110153 -0.122329932233 -0.122329894179 -0.122328723737 -0.122329545269 -0.122330612207 -0.122330543979 -0.12233066531 -0.122330940623 -0.122329821062 -0.122330473195 -0.122332061475 -0.122336148442 -0.122343056335 -0.122353312224 -0.122367627321 -0.122382919828 -0.122402415842 -0.122427310103 -0.122458746392 -0.122498203491 -0.122547588276 -0.122609843875 -0.122691230814 -0.122790190804 -0.122896635139 -0.1230233098 -0.123175622934 -0.123342102095 -0.123533200486 -0.123751217434 -0.123992019947 -0.124256069716 -0.124543301798 -0.124858673926 -0.125204019522 -0.125581241356 -0.125991952368 -0.126437523569 -0.126919198292 -0.127437691281 -0.127993385789 -0.128586055963 -0.129214087988 -0.129874522873 -0.13056360496 -0.131276963296 -0.132009541253 -0.132755662562 -0.133509348879 -0.134264867397 -0.135017191361 -0.135762607112 -0.136499006919 -0.13722598645 -0.13794292933 -0.138633318678 -0.139255735962 -0.139760762225 -0.140220308945 -0.14085985103 -0.141436000033 -0.141650926647 -0.141957767124 -0.142282536695 -0.142619261734 -0.14292706915 -0.143194172036 -0.143336580171 -0.143520452631 -0.143912420962 -0.144238663211 -0.144276498526 -0.144143500446 -0.143662280589 -0.143687273201 -0.143588027315 -0.143364051269 -0.143061180478 -0.142851226125 -0.142708490952 -0.122306913413 -0.122306566985 -0.12230527503 -0.12230377292 -0.122302247319 -0.122300779614 -0.122299194244 -0.122296654607 -0.122294000313 -0.122290801258 -0.122287939988 -0.122287429695 -0.122289361113 -0.122294079445 -0.122301870641 -0.122311970136 -0.122325944855 -0.122344153462 -0.122367967099 -0.122399032876 -0.122438990736 -0.122490100706 -0.122559054331 -0.122650411441 -0.122751828556 -0.122863376014 -0.123003237619 -0.123161948754 -0.123337092848 -0.123540847842 -0.123770526317 -0.124025263042 -0.12430628852 -0.124615938409 -0.124956384058 -0.125329769844 -0.125738093637 -0.126182864831 -0.126665596058 -0.127187560218 -0.12774933013 -0.128350810477 -0.128990616505 -0.129665772062 -0.130372395313 -0.131106109554 -0.131861660787 -0.13263256841 -0.133411601669 -0.134191878898 -0.134967984042 -0.135737466052 -0.136501524594 -0.137265325234 -0.138041832581 -0.138824347981 -0.139542459557 -0.13999989626 -0.140291831628 -0.141360977068 -0.141308067647 -0.141244922692 -0.141306112596 -0.141390114682 -0.14150783223 -0.141639932486 -0.141801318325 -0.142017179675 -0.142245245803 -0.142466730733 -0.142705947952 -0.142789746591 -0.14279259951 -0.14328891308 -0.144297930631 -0.144305878394 -0.143876703204 -0.143120229032 -0.142787972765 -0.142514507824 -0.122283052156 -0.12228248851 -0.122281175791 -0.12227702132 -0.122273095696 -0.122269676381 -0.122265970935 -0.122260735279 -0.122256208768 -0.122248253201 -0.122240475587 -0.122234975269 -0.122231614422 -0.122230704408 -0.122231380092 -0.12223474075 -0.122242147945 -0.122253128203 -0.122268759873 -0.122290734 -0.122320832247 -0.122360853913 -0.122415591734 -0.122494533386 -0.122590032485 -0.122689194769 -0.12281125541 -0.122961345151 -0.123127085088 -0.123312732447 -0.123527863825 -0.123771431174 -0.124044086013 -0.124346961586 -0.124681720075 -0.125050585516 -0.125455825293 -0.125899434668 -0.126383044139 -0.126908286751 -0.127476375204 -0.128087435786 -0.128740184116 -0.129431769528 -0.130158502957 -0.130916322251 -0.131699859407 -0.132501467494 -0.133311836303 -0.134122000683 -0.134925177257 -0.135720012529 -0.136508856303 -0.137297313553 -0.138140061455 -0.139101756629 -0.140102125724 -0.140040976936 -0.140018167129 -0.140277839979 -0.140626492718 -0.14064189274 -0.140519248546 -0.140313007952 -0.140073109043 -0.139809434786 -0.13956901016 -0.139422550754 -0.13940489323 -0.139514628343 -0.13974024845 -0.139982859884 -0.140264325981 -0.140792953959 -0.141603796592 -0.142138299329 -0.14229863096 -0.142669152756 -0.142746422475 -0.14209465054 -0.12225827405 -0.122257194734 -0.122254530118 -0.122248986216 -0.122243071792 -0.122237563986 -0.122231184396 -0.122222825095 -0.122215103126 -0.122202418494 -0.122189822311 -0.122179140415 -0.122170321143 -0.122163602031 -0.122156927262 -0.122152414572 -0.122151978752 -0.122154718356 -0.122161298032 -0.122173322178 -0.122192592662 -0.122221031536 -0.122261894466 -0.122324884947 -0.122409271333 -0.122500937637 -0.122602657139 -0.122733528508 -0.122889843975 -0.123063967448 -0.123263670228 -0.123493804637 -0.123755792324 -0.124050168896 -0.124378060472 -0.124741374432 -0.125142732127 -0.125584459653 -0.126068636835 -0.126597068997 -0.127171513242 -0.127792743586 -0.128459698036 -0.129169509773 -0.129918900388 -0.1307049157 -0.131522754574 -0.132363175231 -0.133213327885 -0.134060902128 -0.134896310073 -0.135719184552 -0.136524653664 -0.137280804032 -0.138080312787 -0.139380523957 -0.139511017577 -0.139618637736 -0.1396502806 -0.139690109444 -0.139841376322 -0.139730701232 -0.139392947372 -0.138873581946 -0.138245467453 -0.137553073427 -0.136862471184 -0.136247364935 -0.135779121366 -0.135510583657 -0.135439438848 -0.135480144971 -0.135643909694 -0.136167695629 -0.137288279297 -0.138679192324 -0.139889743892 -0.1405468012 -0.140681102068 -0.140577776319 -0.122233502082 -0.122231851721 -0.122227883964 -0.122220636727 -0.122213000103 -0.122205065661 -0.122195496414 -0.12218322621 -0.122170707696 -0.122153836787 -0.122136258425 -0.122120125845 -0.122105637334 -0.122092989421 -0.122078098857 -0.122065075858 -0.122055862816 -0.122049376167 -0.122045851675 -0.122046916343 -0.122054228067 -0.122069861743 -0.122096550037 -0.122141967874 -0.122210160388 -0.122293565523 -0.12237926506 -0.122487836913 -0.122624502845 -0.12278591839 -0.122972085289 -0.123189095174 -0.123438934201 -0.123723104353 -0.124042858087 -0.124399678024 -0.124796080195 -0.125235094485 -0.125719172409 -0.126250515519 -0.126831301551 -0.12746298038 -0.128145158315 -0.128875032874 -0.12964963154 -0.130468207248 -0.13132791442 -0.13221760563 -0.133119457969 -0.134016892858 -0.13489267429 -0.135756232181 -0.13658545301 -0.137117253335 -0.138053967047 -0.138385813395 -0.13867294503 -0.139042429125 -0.139129041879 -0.139028714933 -0.138782012832 -0.138280858867 -0.137580592015 -0.13670897712 -0.135729024027 -0.13469313406 -0.133663407518 -0.132696332175 -0.131849550981 -0.131183077432 -0.130734032943 -0.130459795006 -0.130368252171 -0.130645567256 -0.131581632601 -0.13323741752 -0.135174248135 -0.136648610589 -0.138020591375 -0.140661939107 -0.12220952325 -0.122207222467 -0.12220148075 -0.122192737291 -0.122183607197 -0.122173008865 -0.12215998111 -0.122143856237 -0.122126306871 -0.122103840964 -0.122080470508 -0.122058216866 -0.122037363245 -0.122017933588 -0.121994154279 -0.121972234357 -0.121953511284 -0.121937050827 -0.121922415528 -0.121911482646 -0.121905658912 -0.12190712442 -0.121918510665 -0.121945321705 -0.121993402067 -0.122062291532 -0.122138906831 -0.122227802902 -0.122341884523 -0.122483285704 -0.122652516291 -0.122854418953 -0.123090220881 -0.12336248542 -0.123672766046 -0.124021874183 -0.124412523114 -0.124847912018 -0.12533118443 -0.125864841674 -0.126451553828 -0.127093807157 -0.12779206243 -0.128543805616 -0.129345318978 -0.130198436843 -0.131107152811 -0.13206141385 -0.133033734963 -0.13400156815 -0.134927180621 -0.13588845719 -0.1369019946 -0.137006677899 -0.13713776786 -0.137509756099 -0.138056905654 -0.138361339721 -0.13822432933 -0.13780353146 -0.137105392906 -0.136136905454 -0.134979998132 -0.133674648529 -0.132274520163 -0.130828327268 -0.129392404059 -0.128018887396 -0.126760290608 -0.125675917241 -0.124826859686 -0.124226495172 -0.123875777535 -0.123928919682 -0.12468915263 -0.126379290483 -0.128618594876 -0.130443415239 -0.133344543822 -0.144185702794 -0.122187403024 -0.122184369064 -0.122176793713 -0.122166720363 -0.122155748984 -0.122142187622 -0.122125366911 -0.122105439153 -0.122082316258 -0.12205334098 -0.122023232003 -0.121993930929 -0.121965639143 -0.121937238183 -0.121904645188 -0.121873453235 -0.12184446632 -0.121816921734 -0.121790442922 -0.121766668235 -0.121746618054 -0.121732440389 -0.121727211661 -0.121734240553 -0.121759476595 -0.121807381962 -0.121871238037 -0.12194333376 -0.122035743185 -0.122155900845 -0.122304556146 -0.122487602414 -0.12270742141 -0.122965290271 -0.123264106122 -0.123604127005 -0.123987704745 -0.124418541921 -0.124900232282 -0.125435810184 -0.126028034117 -0.126680205654 -0.127394101217 -0.128168324029 -0.128999917399 -0.129892958567 -0.130856111834 -0.131882050436 -0.13294649178 -0.134027609708 -0.134956966534 -0.136000061117 -0.136306287549 -0.136534332607 -0.136729358944 -0.137126814349 -0.137476586282 -0.13737112621 -0.136796028133 -0.135892434979 -0.134681353711 -0.133210153001 -0.131552838676 -0.129755727982 -0.127866316121 -0.125927098392 -0.123984327969 -0.122079782655 -0.120250279359 -0.118535108507 -0.116994948728 -0.115699608082 -0.114639724016 -0.113927403584 -0.113841277467 -0.114734818265 -0.116431116201 -0.117461334144 -0.117387550242 -0.12192371885 -0.122167888825 -0.122164175213 -0.122155214379 -0.122143644656 -0.122130204001 -0.122113261402 -0.122092178348 -0.122068053253 -0.122038913202 -0.122002920967 -0.121965353808 -0.121928199908 -0.121891511998 -0.121852943241 -0.121810840283 -0.121769388799 -0.12172911078 -0.121689056484 -0.121649615288 -0.121612011808 -0.121576700203 -0.121545453902 -0.121522096061 -0.12150813362 -0.121508928561 -0.121530883303 -0.121572446888 -0.121627547268 -0.121699824817 -0.121797973105 -0.121925205478 -0.122085266472 -0.122285035863 -0.122526129332 -0.122812015774 -0.123142007979 -0.123517265984 -0.123942180087 -0.124421038719 -0.124957620325 -0.125555007766 -0.126216648809 -0.126946112095 -0.127743739993 -0.128607600328 -0.129540756056 -0.130556448086 -0.131664201628 -0.132852823867 -0.134146492952 -0.134902910941 -0.135305940974 -0.135678402656 -0.136189257458 -0.136491568284 -0.136675799584 -0.136534854691 -0.135856059053 -0.134716582814 -0.133227577677 -0.131431767368 -0.129388536808 -0.12715320659 -0.124763054262 -0.122251596005 -0.119648007899 -0.116983194664 -0.114285684171 -0.111579592049 -0.108890362146 -0.106268874716 -0.103787720774 -0.101403209704 -0.0990397383372 -0.0968500429265 -0.0952924189593 -0.0942843053171 -0.0900403928925 -0.0745390831493 -0.0558419030846 -0.122151762788 -0.122147340316 -0.122137134749 -0.122123812153 -0.122107477921 -0.122086763458 -0.122061323468 -0.122032416561 -0.121996610443 -0.121953333657 -0.121907753406 -0.121862079212 -0.121816376449 -0.121767481409 -0.121714224435 -0.121661255014 -0.121608525954 -0.121554600646 -0.121500362487 -0.12144743359 -0.121395445365 -0.121345581992 -0.121302115065 -0.121265852905 -0.121241103581 -0.121234604742 -0.121249643934 -0.121284138925 -0.121338847589 -0.121410946979 -0.121512299455 -0.1216477592 -0.12182393641 -0.12204210698 -0.122309804348 -0.122628755882 -0.12299528876 -0.12341364784 -0.123888320901 -0.124424238845 -0.125025844422 -0.125696948771 -0.126441946304 -0.127261472551 -0.128152050743 -0.129118828365 -0.130183805592 -0.131389345099 -0.132784499708 -0.135040309043 -0.134472137218 -0.134728110623 -0.135337140808 -0.13590526589 -0.135967714859 -0.135725863703 -0.134969442584 -0.133644567362 -0.131861113201 -0.129715968136 -0.127263426784 -0.124559880721 -0.121645248791 -0.118546786951 -0.115287821263 -0.111890463704 -0.108378786372 -0.104774963789 -0.101093313381 -0.0973360573617 -0.0934992203672 -0.0895688041601 -0.0854504404156 -0.080812883976 -0.0755581389474 -0.070071372812 -0.0637665486326 -0.0497865369497 -0.0122237258303 0.042760360878 -0.122139450774 -0.122134335149 -0.122122981919 -0.122107586946 -0.122088011743 -0.122063250487 -0.122033527866 -0.121998885186 -0.121956039654 -0.121905579856 -0.121851355358 -0.121796397494 -0.121740876687 -0.121680980797 -0.121615538264 -0.121549834172 -0.121483537506 -0.121414091854 -0.121343262248 -0.121273167977 -0.121202414777 -0.121132082524 -0.121066057882 -0.121005962153 -0.120954435181 -0.120917559909 -0.120902412907 -0.120909443071 -0.120942339639 -0.120991269276 -0.121063748739 -0.12116826162 -0.121317388805 -0.121513563614 -0.121757449603 -0.122058215175 -0.122413961652 -0.122824884907 -0.123295407534 -0.123829828148 -0.124433870391 -0.12511378976 -0.125873341538 -0.126710699102 -0.127619202618 -0.128605620913 -0.129691958058 -0.130906028681 -0.131998152298 -0.132907994466 -0.133555220498 -0.133802019268 -0.135056134536 -0.135306780581 -0.134960300009 -0.134121231675 -0.132666305356 -0.130638883492 -0.128155430793 -0.125307351654 -0.122154612224 -0.118751070112 -0.115134626236 -0.11133588138 -0.107382145474 -0.103297915612 -0.0991017183574 -0.0947983383703 -0.0903690364395 -0.0857594238068 -0.0808661931918 -0.0755297706306 -0.0695328887292 -0.0624694713132 -0.0540619333864 -0.044443279445 -0.0318630749922 -0.00675096586876 0.0478817209842 0.117472625103 -0.122131859251 -0.122125984153 -0.122113389737 -0.12209554304 -0.122072244146 -0.122043252254 -0.122009021318 -0.121967770051 -0.121917953657 -0.121860421521 -0.121796950202 -0.12173190853 -0.121665703696 -0.121593886636 -0.121515277914 -0.121435611855 -0.121354384739 -0.121267377526 -0.121178473626 -0.12108940475 -0.120997059763 -0.120904486071 -0.120813736803 -0.12072737415 -0.120647671834 -0.120579029529 -0.120530296546 -0.120504117561 -0.12050564813 -0.120530404789 -0.120576081417 -0.120647884961 -0.120760778167 -0.120927611214 -0.121149146212 -0.1214279354 -0.121767916868 -0.122168400842 -0.122632954428 -0.123165989557 -0.123772591315 -0.124459281928 -0.125229532689 -0.126078789464 -0.127002244005 -0.128016967907 -0.129158997375 -0.130479380923 -0.130837668827 -0.130551283829 -0.131058061625 -0.132955995167 -0.134366161558 -0.134194358822 -0.133339025143 -0.131791555618 -0.129586222662 -0.126819410206 -0.123614235246 -0.120063000779 -0.116233941145 -0.112185966375 -0.107964317355 -0.103606238312 -0.0991388756332 -0.0945748298535 -0.0899043837798 -0.0850878692737 -0.0800507483198 -0.0746751953602 -0.0687727758906 -0.0620455417739 -0.0541176723507 -0.0447106655429 -0.0335750494313 -0.0204173306919 -0.00236934634267 0.0310251723292 0.0920943986279 0.156411254345 -0.122129814808 -0.122123179001 -0.122109279619 -0.122088574782 -0.122061311686 -0.122027907951 -0.121988572017 -0.121940370078 -0.121884259473 -0.12181932784 -0.121745604343 -0.1216695724 -0.121591744175 -0.121506995949 -0.121414132836 -0.121319264469 -0.121220436517 -0.121114171196 -0.121006377933 -0.120896485943 -0.120779896418 -0.120663427087 -0.120548154244 -0.120431539984 -0.120321364791 -0.120218813658 -0.120133607423 -0.120070598381 -0.120034176269 -0.12002561047 -0.120042196497 -0.120085738076 -0.120159899429 -0.120285410495 -0.120474148034 -0.120728262592 -0.121049597186 -0.121437696377 -0.121893641503 -0.122423807786 -0.123032113698 -0.123722596635 -0.124497374727 -0.125352061496 -0.126290834935 -0.127359252433 -0.128628275378 -0.130944573792 -0.129413046608 -0.128871024695 -0.130129670031 -0.132445576611 -0.133242722415 -0.132532420626 -0.131027025414 -0.128710753214 -0.125738514361 -0.122234849921 -0.118335383043 -0.114138341934 -0.1097217781 -0.105149274722 -0.100466988847 -0.0957041396405 -0.0908676639944 -0.0859370366948 -0.0808585719229 -0.0755433567041 -0.0698702133781 -0.0636827272295 -0.0567528243267 -0.0487133162732 -0.0390811347952 -0.0275254469075 -0.0140199168975 0.00203253717459 0.0244273886422 0.0629687998812 0.124607169524 0.18076765849 -0.122134773509 -0.122127179512 -0.122111666927 -0.122088225942 -0.122057167769 -0.122019011268 -0.1219742252 -0.121919260343 -0.121855914631 -0.121782212743 -0.121698109414 -0.121610455055 -0.121520153593 -0.121421499946 -0.121313301848 -0.121201760308 -0.121083646618 -0.120957617911 -0.120829547467 -0.120696428899 -0.120554216249 -0.120413957301 -0.120272748646 -0.120127171154 -0.119981761362 -0.119840548594 -0.119714920071 -0.119610736067 -0.119530958218 -0.119480373709 -0.119458792938 -0.119469253679 -0.119507580899 -0.119590071656 -0.119733826938 -0.119950670737 -0.120246754883 -0.120620465786 -0.121067776796 -0.121593672564 -0.122200787438 -0.122892522661 -0.123665969224 -0.124514236748 -0.125432881597 -0.12640874183 -0.127348290669 -0.127836188433 -0.127776958788 -0.127560780395 -0.130103669075 -0.1318159203 -0.131736054625 -0.130312998709 -0.128021312806 -0.124909516212 -0.121186556939 -0.116992812246 -0.112474737804 -0.107735550241 -0.102857321695 -0.0978987844449 -0.0928932923629 -0.0878471694157 -0.0827363984065 -0.0775052607448 -0.0720654460239 -0.0662978426451 -0.0600571128221 -0.0531673822608 -0.0453801198061 -0.0362969613407 -0.0253829562281 -0.0122368021825 0.00317396626858 0.0214963607889 0.0467837958059 0.0877803866612 0.147494733744 0.19706906511 -0.122147390601 -0.122138877024 -0.122121645934 -0.1220957858 -0.122061023453 -0.12201787833 -0.121967302815 -0.121905432203 -0.121833611671 -0.121750521499 -0.121655773461 -0.12155592174 -0.121452338413 -0.121338898383 -0.121214579743 -0.121085455661 -0.120947828276 -0.120801119928 -0.120650970491 -0.12049321076 -0.120327289233 -0.120161777308 -0.119990783907 -0.11981561469 -0.119635009887 -0.119455293275 -0.119282083783 -0.11912899267 -0.119000010459 -0.118900433502 -0.118829238785 -0.118792718698 -0.118792932902 -0.118831407434 -0.118928147937 -0.119096561311 -0.119353460563 -0.119703930888 -0.12014160208 -0.1206620723 -0.121268051982 -0.121963210742 -0.122742038644 -0.123604016966 -0.124533801583 -0.125334239057 -0.125375944098 -0.125070716246 -0.124780815438 -0.126831342465 -0.1298078087 -0.130650245132 -0.129720945162 -0.127481489099 -0.124351631443 -0.120460146151 -0.116038786563 -0.111239157613 -0.106210983743 -0.101055408286 -0.0958475041283 -0.0906296851934 -0.0854123526721 -0.0801737437792 -0.0748610210354 -0.0693926216189 -0.0636596357494 -0.0575270957618 -0.0508355236297 -0.0433931988103 -0.0349347796904 -0.025052392421 -0.0132141806992 0.000992309266398 0.017687319243 0.0376426019997 0.0646839557694 0.106272491825 0.162919359336 0.207143428715 -0.122168757247 -0.122159207883 -0.122140075884 -0.122111822499 -0.122073703334 -0.122025464846 -0.121968836085 -0.121899834175 -0.121819475603 -0.12172670013 -0.121620401197 -0.121507597722 -0.121389870407 -0.121260711369 -0.121119503815 -0.120971801447 -0.120814141736 -0.120646092667 -0.120472677561 -0.120289925602 -0.120099210389 -0.119903750094 -0.119700411947 -0.11949069555 -0.119275144767 -0.119054393984 -0.118833616502 -0.118626444452 -0.11844403374 -0.118289364409 -0.118160599426 -0.118063467701 -0.118008298838 -0.117995601918 -0.118040271037 -0.118156922282 -0.118364762965 -0.118679377317 -0.119100578153 -0.119614806874 -0.120222644268 -0.12092852088 -0.121735067042 -0.122642015276 -0.123691364851 -0.12537260278 -0.124063438676 -0.123445272988 -0.12381309074 -0.126780978249 -0.129021835384 -0.128904537801 -0.127103889121 -0.124013638958 -0.120069793411 -0.115459617452 -0.110427831228 -0.105132586076 -0.0997177512493 -0.0942730867767 -0.0888560392927 -0.0834850757901 -0.0781442598844 -0.0727858660323 -0.0673348330336 -0.0616924108623 -0.0557372697192 -0.0493250329609 -0.0422876302796 -0.0344251810354 -0.0254704459298 -0.0150331750484 -0.00262461601128 0.0121274130289 0.0293482442876 0.0497850651945 0.0769698654096 0.117230064068 0.170006185193 0.210099301602 -0.122199879105 -0.122189106394 -0.122168358931 -0.122137211708 -0.122095574205 -0.122042567632 -0.121979881219 -0.121903851472 -0.121814987508 -0.121712254764 -0.121593780577 -0.121467212038 -0.121334387463 -0.12118857687 -0.121029673739 -0.120862183137 -0.120683624193 -0.120493343881 -0.120294839836 -0.120084894487 -0.119865524813 -0.11963660999 -0.119397046476 -0.119150579801 -0.11889433762 -0.11863133922 -0.11836439018 -0.118100977842 -0.117863034896 -0.117647409647 -0.117456409947 -0.117294071616 -0.117169534128 -0.117087842954 -0.117063697025 -0.117117615575 -0.117266799751 -0.11753464052 -0.117929507447 -0.118434953239 -0.119045970439 -0.119759795082 -0.120588635002 -0.121507635258 -0.122347632001 -0.122157146205 -0.122702883187 -0.121782899884 -0.12403583744 -0.126755106921 -0.127823661605 -0.1266497058 -0.123899965445 -0.119958649738 -0.115260919061 -0.110023529287 -0.104492692015 -0.0988236445046 -0.0931448446043 -0.0875261034004 -0.0820001232669 -0.0765586228689 -0.0711606176989 -0.0657372367308 -0.0601976600239 -0.0544324990516 -0.0483140860025 -0.0416949905438 -0.0344067155076 -0.0262528393004 -0.0169798969786 -0.00623132027494 0.00643206110211 0.0213462189476 0.0386103437 0.0587957758679 0.0848491768711 0.12225101637 0.170668041979 0.207726256012 -0.122243007821 -0.122230850098 -0.122207966677 -0.122173812064 -0.122128125444 -0.122070272408 -0.122001576819 -0.121918545992 -0.121821044323 -0.121708525462 -0.121577641898 -0.121436387982 -0.121287667867 -0.121124711857 -0.120947199677 -0.120758480506 -0.120558598245 -0.120344951987 -0.120118792239 -0.119879108993 -0.119626828288 -0.119362192591 -0.119085615589 -0.118801036637 -0.118503947864 -0.118198684566 -0.117879379354 -0.11756266782 -0.117261277853 -0.116977754156 -0.116716703857 -0.116483897008 -0.116282421059 -0.116120754765 -0.116010141054 -0.115978696722 -0.116048751368 -0.11625352003 -0.116610777424 -0.117103773604 -0.117723424123 -0.118464746491 -0.11931875668 -0.120277443693 -0.122246416375 -0.120478363551 -0.12028955412 -0.121064252651 -0.124345081132 -0.126210261486 -0.126121339796 -0.123862996196 -0.120151465853 -0.115400569277 -0.110032381762 -0.104275904066 -0.0983655429883 -0.0924422022534 -0.0866101594042 -0.0809131328335 -0.0753561105441 -0.0699051391861 -0.0644980863409 -0.0590504748203 -0.053461423697 -0.0476160690387 -0.0413849778407 -0.0346218769042 -0.0271617674 -0.0188152636875 -0.00934545791922 0.00157116883902 0.0143340490529 0.0292637481679 0.046448252979 0.0662590381785 0.0910035593683 0.125413473645 0.169661341757 0.204157098941 -0.122298932325 -0.122285918047 -0.122260556095 -0.122223253902 -0.122173158733 -0.122110089195 -0.122035236198 -0.121945128535 -0.121838771185 -0.121716808627 -0.121573709425 -0.121416822083 -0.121251781968 -0.12107176213 -0.120874786965 -0.120663580633 -0.120441399226 -0.120202684123 -0.119946331707 -0.119674767648 -0.119388423558 -0.119087280838 -0.118774769998 -0.118450768763 -0.118113593576 -0.11775934851 -0.117385655073 -0.117011424683 -0.116641569203 -0.116287308961 -0.115945501282 -0.115629642558 -0.115343610712 -0.115096693782 -0.114888010814 -0.114745330757 -0.11470606677 -0.114817836009 -0.115119738295 -0.115589925424 -0.116220966748 -0.117039310637 -0.117926022058 -0.118613988454 -0.118061188861 -0.118827069982 -0.117984228157 -0.12118855806 -0.124231426269 -0.125057201039 -0.123833519168 -0.12051418436 -0.11590260692 -0.110426057019 -0.104493259998 -0.0983343313599 -0.092161348541 -0.0860916186117 -0.0801991512281 -0.0744986832261 -0.0689679817279 -0.063550840766 -0.058168825922 -0.0527270375429 -0.0471191936839 -0.0412289530997 -0.0349286442539 -0.0280765063394 -0.0205145074377 -0.0120641699248 -0.00250932708967 0.00843697940159 0.0211325455188 0.0358816949858 0.0527655701809 0.0719916073016 0.0953425881742 0.126974762558 0.167601483281 0.200007090308 -0.122368663509 -0.12235463644 -0.12232708496 -0.122286656092 -0.122232143058 -0.122163548457 -0.122082407312 -0.121985124541 -0.121869433358 -0.12173835871 -0.121583863472 -0.121410632635 -0.12122837538 -0.12103189495 -0.120815428735 -0.120580218679 -0.120333691158 -0.120067628608 -0.119779951809 -0.119475611318 -0.119154471472 -0.118816339041 -0.118466148713 -0.118097310916 -0.117712309349 -0.117309321768 -0.116884349234 -0.116449048334 -0.116016699945 -0.115586824289 -0.115162103671 -0.114751306714 -0.114366534711 -0.114012934651 -0.113699919871 -0.113430203556 -0.113245970831 -0.113209577152 -0.1134267859 -0.113851539051 -0.114484678758 -0.115402774429 -0.116559001291 -0.118058652909 -0.116708445885 -0.11659157201 -0.117272910287 -0.121621403045 -0.123603973384 -0.123351480126 -0.120961789697 -0.116636723188 -0.111218427665 -0.105123913356 -0.0987449984197 -0.0923003832765 -0.0859720016784 -0.0798474583904 -0.0739678226983 -0.068319068056 -0.0628545772722 -0.057500323321 -0.052166343045 -0.0467517246897 -0.0411485061053 -0.0352420596972 -0.0289094234237 -0.0220163725691 -0.0144151966257 -0.0059419233373 0.0035959798775 0.0144478936898 0.0269293501628 0.0413238736139 0.057703152829 0.076146017626 0.0980290601285 0.12708863452 0.164577768617 0.195310630595 -0.122452519623 -0.122437648849 -0.122408368335 -0.122364779621 -0.122306112942 -0.122232031941 -0.122144633322 -0.122040522491 -0.121915053284 -0.121774290316 -0.121609561873 -0.121420112427 -0.121219578314 -0.121006718571 -0.120770855104 -0.120510626652 -0.120237742918 -0.119942228097 -0.119622215681 -0.119284339403 -0.118926010188 -0.118548754852 -0.118155254532 -0.117737884625 -0.117304073559 -0.116852588512 -0.116376705956 -0.115883853798 -0.115390983669 -0.114886095389 -0.114380682453 -0.113874387938 -0.113379544519 -0.112901078434 -0.112456692169 -0.112047754919 -0.111692729519 -0.111435521503 -0.111472465662 -0.111838481305 -0.112534887721 -0.113562483485 -0.114737966468 -0.1198574057 -0.115554094099 -0.11381190829 -0.11739857595 -0.121695834696 -0.122451761647 -0.121106532885 -0.117546178848 -0.112302662075 -0.106181843927 -0.0995853440042 -0.0928786181587 -0.0862566971556 -0.079865584671 -0.0737598131502 -0.0679477437252 -0.062389078117 -0.0570169511906 -0.0517441940045 -0.0464737189477 -0.0411024274422 -0.0355239347817 -0.0296282624456 -0.0232999816079 -0.0164152702761 -0.00883966923165 -0.000426258425752 0.00899302386117 0.0196320606119 0.0317672855274 0.0456613762768 0.0613786218197 0.0789014862476 0.0992887788212 0.125955322452 0.160669555253 0.190032387283 -0.122551799519 -0.122535891796 -0.122504867405 -0.122458118581 -0.122395702202 -0.122316599988 -0.122222985741 -0.122113048459 -0.121979192762 -0.12182680311 -0.121651534563 -0.121447557269 -0.121228915409 -0.120997750475 -0.120741087904 -0.120456546463 -0.120155978396 -0.11982948529 -0.119475756408 -0.119104382282 -0.118707951759 -0.118286657282 -0.1178437273 -0.117376232335 -0.116891080142 -0.116385235294 -0.115858296816 -0.115310893162 -0.114752388112 -0.114183726301 -0.113599168555 -0.113004990933 -0.112395139214 -0.111793841987 -0.111201109217 -0.110629138383 -0.110080051516 -0.109575018391 -0.109193249317 -0.109383796374 -0.110126761001 -0.111386984114 -0.112211721977 -0.110791979646 -0.111428015737 -0.110721405516 -0.117711398424 -0.121058281163 -0.120747910706 -0.118296927197 -0.113635704122 -0.107587798947 -0.100877239945 -0.0938958017601 -0.0869712773902 -0.0802666454597 -0.0738885392839 -0.0678575900179 -0.0621517844308 -0.056708388176 -0.0514449351593 -0.0462656388707 -0.0410702669433 -0.0357569180448 -0.030223714772 -0.0243679949696 -0.0180843568905 -0.0112617250846 -0.00378101666066 0.00448615018018 0.0136835801368 0.0239924445527 0.0356540517415 0.0489128242337 0.0638324006075 0.0803308310203 0.0992201465027 0.123661924161 0.155910665819 0.184159003458 -0.122666709551 -0.12264998139 -0.122616469771 -0.12256684286 -0.12250131387 -0.12241790892 -0.122318381555 -0.122202608456 -0.1220623038 -0.121898485453 -0.121712779807 -0.121495426223 -0.121258487266 -0.121007203871 -0.120728599963 -0.12042012429 -0.120090655486 -0.119732857848 -0.119345310011 -0.11893617161 -0.11849720432 -0.118028549514 -0.117533901936 -0.117015399497 -0.116472515152 -0.115905459721 -0.115320097279 -0.114712779216 -0.114087088997 -0.113453094643 -0.112798222503 -0.112116231716 -0.111411761466 -0.110693246528 -0.10995985498 -0.109223928332 -0.108482781036 -0.107738327007 -0.10695663587 -0.106467487629 -0.106846855689 -0.108918516659 -0.111618656091 -0.108135205655 -0.106815315055 -0.109288302247 -0.117864609576 -0.119743005184 -0.118509551604 -0.114933995 -0.109293792027 -0.102564438556 -0.095381866375 -0.0881280674272 -0.0810835368849 -0.0743750546808 -0.0680689196769 -0.0621533498496 -0.0565796909377 -0.0512672518178 -0.0461226143345 -0.0410455313743 -0.0359361491206 -0.0306967269366 -0.0252324655578 -0.019450332058 -0.0132570453791 -0.00655614189038 0.00075452939954 0.00878392406559 0.0176521934627 0.0275105880173 0.0385695390481 0.051059638252 0.0650528561748 0.080431605222 0.0978212122083 0.120193186696 0.150277088326 0.177680523034 -0.122798470427 -0.12278074368 -0.122744735056 -0.122692824532 -0.12262431704 -0.12253708908 -0.122432141713 -0.12231004692 -0.122163913338 -0.12199033883 -0.12179492324 -0.121565364032 -0.121309657967 -0.121037522849 -0.12073724758 -0.120403773333 -0.120044332664 -0.119655985425 -0.119233356083 -0.118781041833 -0.118296210828 -0.11777814654 -0.117230163619 -0.116654992273 -0.116045538607 -0.115414149477 -0.114758228089 -0.114076512226 -0.113377256855 -0.112664933656 -0.111940065363 -0.111187203608 -0.110409927927 -0.109592051794 -0.108755925569 -0.107897921786 -0.107013770176 -0.106081005621 -0.105078452647 -0.103956791853 -0.102186785365 -0.105457734611 -0.112862956537 -0.106264543066 -0.103266610976 -0.109540441517 -0.117707472888 -0.117975703069 -0.115799992294 -0.111085914822 -0.104599573068 -0.0973043660039 -0.0897645100808 -0.0823405083948 -0.0752594109396 -0.0686102273187 -0.0624200116658 -0.056647759158 -0.0512226700559 -0.0460507252467 -0.0410319028308 -0.0360651698909 -0.0310540815294 -0.0259075634087 -0.0205400228607 -0.0148698884218 -0.00881753556937 -0.00230231050325 0.00476025448577 0.0124596877443 0.0208937458806 0.0301865060227 0.0405211154293 0.0521181889887 0.0650647214156 0.0792262387068 0.0950868885889 0.115501522115 0.143713754964 0.17058170867 -0.122947647368 -0.122929351272 -0.122893670773 -0.122838794485 -0.122766648631 -0.122675677861 -0.122565777524 -0.12243774322 -0.12228569892 -0.122103007441 -0.121897845824 -0.121658982513 -0.121384327293 -0.121090497045 -0.120770620518 -0.120412146505 -0.12001977314 -0.119601122265 -0.119142561016 -0.118643842668 -0.118111921158 -0.117540439475 -0.116935737752 -0.11629732432 -0.115617746397 -0.114911110662 -0.11417004113 -0.11340281285 -0.112612706242 -0.111804542222 -0.110991294268 -0.110173883083 -0.109322339764 -0.108444355177 -0.10753615258 -0.106598782052 -0.105631044471 -0.104615493219 -0.103551848008 -0.102018950687 -0.101845052264 -0.101745052499 -0.103039516666 -0.101883942199 -0.0996695526534 -0.110346780288 -0.11696195267 -0.115846756021 -0.11265062328 -0.106836590922 -0.0996315839039 -0.0918755800195 -0.0840839804196 -0.0765776176765 -0.069528295085 -0.062986964993 -0.0569440822157 -0.051333553084 -0.0460671571842 -0.0410419871013 -0.0361553059418 -0.0313084447294 -0.0264108929951 -0.0213802755047 -0.0161418816418 -0.0106269986927 -0.00477082382108 0.00149050134611 0.0082229365564 0.015496072083 0.0233853619699 0.0319883478024 0.0414618256519 0.0520193377266 0.0637722302349 0.0765875928037 0.0908435949242 0.109366563266 0.136037323035 0.16279465342 -0.123114700986 -0.123095617519 -0.123060471399 -0.123003635275 -0.122927969599 -0.122833895299 -0.12272004498 -0.122587033849 -0.122430249556 -0.122240167177 -0.122023728811 -0.121776935495 -0.121486293335 -0.121169329387 -0.120829812568 -0.120448717184 -0.120023786046 -0.119570529463 -0.119073400017 -0.118528375364 -0.117949304744 -0.117323316295 -0.116651963348 -0.115940949614 -0.115188384354 -0.114395068004 -0.113562427456 -0.112697381761 -0.111799963338 -0.110876559581 -0.1099380308 -0.109001290411 -0.108052676698 -0.10709027975 -0.106086338221 -0.105047267511 -0.103985351411 -0.102952996954 -0.10204797973 -0.101288717935 -0.101394810884 -0.101231605328 -0.0995885228048 -0.0976835020571 -0.0980011103752 -0.111207288523 -0.11554864461 -0.113339382762 -0.10905966079 -0.102254074445 -0.0944526695401 -0.0863353839674 -0.0783863518198 -0.0708706553616 -0.0639072323252 -0.0575096960991 -0.0516357484043 -0.0461986842206 -0.0410974391485 -0.0362242329436 -0.0314769384636 -0.0267618360213 -0.0219963517465 -0.0171083756705 -0.0120353555464 -0.00672252037063 -0.00112083492772 0.00481592901308 0.0111345848224 0.0178847630162 0.0251208971387 0.0329165780161 0.0414050143192 0.0507972096454 0.0612420936892 0.0726249560231 0.0852081220908 0.10180524577 0.12716813402 0.154376200856 -0.123298358523 -0.123278550836 -0.12324096208 -0.123183755685 -0.12310688357 -0.123011033925 -0.122894648154 -0.122757529912 -0.122597427074 -0.122402910816 -0.122175638115 -0.12192168827 -0.121620059012 -0.12128061905 -0.120917618115 -0.120513706962 -0.120059207332 -0.119567743667 -0.119032016984 -0.118442411344 -0.117808564852 -0.117122279855 -0.116382004237 -0.115595291761 -0.114760933369 -0.113873623587 -0.112943807256 -0.111965569804 -0.110947320287 -0.109891439072 -0.108804137848 -0.107690116982 -0.10655875455 -0.105404334749 -0.104207127651 -0.102964178205 -0.101691063504 -0.100442009952 -0.0993441375865 -0.0986815470246 -0.099335558663 -0.102217393203 -0.0964563925004 -0.0921255191276 -0.097906156575 -0.111692211908 -0.11361941763 -0.110462897852 -0.105052202497 -0.0973970888313 -0.0891111507245 -0.0807281064591 -0.0727040928815 -0.0652387679812 -0.0584031475736 -0.0521752646486 -0.0464847529877 -0.0412287414999 -0.0362975499898 -0.0315820148865 -0.0269833800062 -0.0224149493269 -0.0178036526837 -0.0130888592056 -0.00822117591109 -0.00316063222829 0.00212531578501 0.00766468366965 0.01348467892 0.0196147318653 0.0260884566508 0.0329551601613 0.0403195246954 0.0483778603739 0.0573098627117 0.0670315983555 0.077672582969 0.091988882028 0.116071091524 0.145128448404 -0.123499510738 -0.123479359866 -0.123440045514 -0.123382168192 -0.123305139656 -0.123207856844 -0.123089544049 -0.122949236234 -0.122786209905 -0.122589976265 -0.122354264863 -0.122091111958 -0.121785921973 -0.121426430965 -0.121037176762 -0.120612084172 -0.120129974127 -0.119596978889 -0.119022958522 -0.1183889075 -0.117694945881 -0.116945950452 -0.116132689558 -0.115266322756 -0.114343147221 -0.113359623789 -0.112319114793 -0.111217249606 -0.110070385587 -0.108868720579 -0.107617130563 -0.106314460589 -0.104968764171 -0.1035706443 -0.102114836399 -0.10058472203 -0.0989730309913 -0.0972863303482 -0.0956416133825 -0.0944513007328 -0.0951912216519 -0.103671806827 -0.0928237364324 -0.0873213492126 -0.0987756494808 -0.111475942732 -0.111274205568 -0.107213641834 -0.100677920833 -0.0923196417726 -0.0836469400741 -0.0750869692401 -0.0670578312296 -0.0596910636907 -0.0530151939026 -0.0469753408853 -0.0414781084941 -0.0364086317424 -0.0316523821285 -0.0271017332754 -0.0226634994955 -0.0182595732201 -0.0138275000906 -0.00931893957431 -0.00469830309666 5.90254717012e-05 0.00496861371243 0.0100397979505 0.0152795489737 0.0206961883537 0.0263019516594 0.0321227756987 0.0382355239963 0.0448172350898 0.0520805087838 0.060038391054 0.0688314404682 0.0811358982832 0.10419267761 0.136379827977 -0.123717451396 -0.123698065282 -0.123660456124 -0.123603204147 -0.123524256348 -0.123425140171 -0.123305021089 -0.123162489892 -0.122997697903 -0.122801852252 -0.122563383852 -0.122288608489 -0.12198034788 -0.12161048614 -0.121193745752 -0.120745491524 -0.120239525728 -0.119667967669 -0.119049438634 -0.118368128074 -0.117614360255 -0.116801080301 -0.11591614172 -0.114961017162 -0.11394149725 -0.112855048609 -0.111695073857 -0.110471579003 -0.10918381169 -0.10782984344 -0.1064147261 -0.104932266897 -0.103386804895 -0.101766038487 -0.100057594674 -0.098240815208 -0.0962680088888 -0.0940808978964 -0.0916779332328 -0.089102619716 -0.0870971884987 -0.0880051922307 -0.0864713194523 -0.0824975217199 -0.0999517660002 -0.110450814591 -0.108561427627 -0.103575528867 -0.0959879587522 -0.0870647078495 -0.0780921638336 -0.0694354132531 -0.0614587442559 -0.0542290254922 -0.047737070535 -0.0418984708707 -0.0366017236027 -0.0317237238302 -0.0271483492143 -0.0227718819293 -0.0185084123292 -0.0142895762982 -0.0100643431561 -0.00579729322086 -0.00146724316477 0.00293443526952 0.007405718103 0.0119368087854 0.0165142302988 0.0211252370948 0.0257615578818 0.0304291366552 0.0351810158684 0.0401613054659 0.0455540635946 0.0514011475666 0.0579581068405 0.0678251344296 0.0872003740631 0.112960410235 -0.123951153835 -0.123932182809 -0.123896463619 -0.123842890726 -0.123761944337 -0.123661121981 -0.123540108317 -0.123396667038 -0.123231268371 -0.12303744362 -0.122801150597 -0.122518731064 -0.122202143288 -0.12183315198 -0.121395217036 -0.120916623751 -0.120388740484 -0.119785572831 -0.119116238799 -0.118388184234 -0.117578651339 -0.116691855494 -0.115729884191 -0.114682221278 -0.11356510749 -0.112372675722 -0.111092502731 -0.109735570145 -0.108302688319 -0.106800438785 -0.105220850231 -0.103564003255 -0.101834800597 -0.100018785708 -0.0981092367553 -0.0960773217788 -0.0938670395835 -0.0913458635516 -0.0884841236147 -0.0836478586655 -0.0853868766274 -0.0854211214039 -0.083134720389 -0.0809911079383 -0.101513607552 -0.108755018322 -0.105529913752 -0.0995507360991 -0.0910301260864 -0.0816630513037 -0.0724703026439 -0.063787608802 -0.0559104500773 -0.0488485942146 -0.0425590157295 -0.0369317215069 -0.0318416055882 -0.027160610922 -0.0227737549049 -0.0185831001634 -0.0145112909126 -0.0105005139475 -0.00651169779341 -0.00252274885198 0.00147275731475 0.00546718855357 0.00944087168088 0.0133651424072 0.017206346483 0.0209295312628 0.0245007991128 0.0278942985752 0.0311157169515 0.0342182466047 0.0372141446101 0.0399569622395 0.0428236728777 0.0487581535318 0.0609251787856 0.0644641369446 -0.124198683572 -0.124179451502 -0.124142205459 -0.124088799204 -0.124012525775 -0.123912729104 -0.123792540965 -0.123650196292 -0.123485496315 -0.123295073869 -0.123065676733 -0.122785041589 -0.122457233828 -0.122086759593 -0.121644544945 -0.121135643933 -0.120580687203 -0.119952590622 -0.11923501095 -0.118452610086 -0.11758765915 -0.116624715374 -0.115582165541 -0.114449813791 -0.113225905546 -0.111915796574 -0.110512061966 -0.109017548085 -0.107439939907 -0.105777158931 -0.10403185362 -0.10220835678 -0.100303241963 -0.0983135526526 -0.0962440722648 -0.0940838404995 -0.091809101316 -0.0893506313835 -0.0866842990291 -0.0823915215724 -0.0855875711482 -0.0840656980086 -0.0763922278348 -0.0811018578323 -0.10270494559 -0.106529696472 -0.102219889871 -0.0951646132119 -0.0858476502193 -0.07613591827 -0.0667966720247 -0.0581495381453 -0.0504106909599 -0.0435418904896 -0.037469400307 -0.0320619265464 -0.0271847128524 -0.0227075956768 -0.0185189810689 -0.0145281615472 -0.0106672783036 -0.00688964616107 -0.0031685906743 0.000504178608001 0.00411965062885 0.007652891645 0.0110648663391 0.0143050165128 0.0173138172849 0.0200231967883 0.02235384488 0.0242167092369 0.025526809093 0.0261883126314 0.0259600328001 0.024402023696 0.0217564893712 0.0201277160432 0.0179505619465 -0.00105888042962 -0.124459812498 -0.12444048963 -0.124402904859 -0.12434449803 -0.124274284078 -0.124177679612 -0.124059963512 -0.123920645079 -0.123758282604 -0.123572789972 -0.123353198863 -0.123083416477 -0.12275531464 -0.12237568319 -0.121938246379 -0.121413269445 -0.120818744276 -0.120166646595 -0.119415313251 -0.118567204293 -0.117646530689 -0.116618713444 -0.115486226759 -0.114259079758 -0.112924823642 -0.111494257166 -0.109961709502 -0.108326096492 -0.106589453096 -0.104762954153 -0.102853482497 -0.100848401183 -0.098754073969 -0.0965869361007 -0.0943640942168 -0.092089116903 -0.0897820006623 -0.0875075947734 -0.0854570614456 -0.0839237970433 -0.0879538416864 -0.0805878591167 -0.0707246800132 -0.082112789192 -0.102758913054 -0.103752206698 -0.0985618638571 -0.090425327878 -0.0804660998936 -0.0704943857233 -0.0610788179868 -0.0525206004352 -0.0449530757424 -0.0382987832706 -0.0324560390968 -0.0272766385423 -0.0226195714794 -0.0183550380354 -0.0143766769471 -0.0106021592203 -0.00697388652855 -0.00345686967889 -3.74926903591e-05 0.00327772654278 0.00646277549886 0.00947310204082 0.0122470538922 0.014707917487 0.016765453299 0.0183144786364 0.0192304213265 0.0193724088768 0.0186025449682 0.016769776022 0.013572594594 0.00856343471065 0.00205569610938 -0.00416097630222 -0.0117708303034 -0.0299857777374 -0.124729865183 -0.124711794006 -0.124678322581 -0.124616834941 -0.124546593298 -0.124454456132 -0.124340587259 -0.124206318137 -0.124048902837 -0.123869617301 -0.123660604265 -0.123407474903 -0.123091517314 -0.122708744755 -0.122269501213 -0.12175150479 -0.121127941934 -0.120434545455 -0.119652626829 -0.118751843931 -0.117762165699 -0.116665374159 -0.115445070781 -0.114116130326 -0.112673114334 -0.11111456106 -0.109444360805 -0.107656892167 -0.105755506638 -0.103763651096 -0.101661667759 -0.0994463549701 -0.0971436690574 -0.0947770307527 -0.0923626513124 -0.0899204425603 -0.0874898449809 -0.0851285980902 -0.0829231449163 -0.080449838877 -0.0842490434995 -0.0780733926308 -0.0655831146755 -0.082361415234 -0.101584793859 -0.100448768072 -0.0944678558142 -0.0853313914345 -0.0748915689103 -0.0647398743504 -0.0553173962423 -0.0468955529158 -0.0395288872953 -0.0331083930356 -0.0275073278599 -0.0225648934633 -0.018136750301 -0.0140956416486 -0.0103419887423 -0.00680283683633 -0.00343161476784 -0.000205814152735 0.00287399114855 0.00578477750936 0.00848123817578 0.0108965924807 0.0129443566339 0.0145213584003 0.0155112419221 0.0157862636574 0.0152078803383 0.0136389731574 0.0109787308463 0.0071659937417 0.00206354122039 -0.00452289429825 -0.012050676771 -0.0187242590771 -0.0251015949702 -0.0355866177541 -0.12500478457 -0.124987883123 -0.124957337097 -0.12489927674 -0.124824365071 -0.124739490598 -0.124632521279 -0.124506015704 -0.124357354878 -0.124185644273 -0.123987724727 -0.123751573254 -0.123458855166 -0.123089167062 -0.122643193376 -0.122130416286 -0.121508829313 -0.120772871088 -0.119950481865 -0.119011660719 -0.117946936773 -0.116770673887 -0.115466471337 -0.114030823759 -0.112468966926 -0.110780424013 -0.108964043192 -0.107016887853 -0.104949580685 -0.102757679474 -0.100432072272 -0.0979872986261 -0.0954398498373 -0.0928176594695 -0.0901438915549 -0.0874625034109 -0.0848400478661 -0.0823027675445 -0.0797846615836 -0.0755951752952 -0.081323129266 -0.0766298532553 -0.0581078950229 -0.0821049838903 -0.0995442191653 -0.096661274274 -0.0899033870647 -0.0798972113618 -0.0691251490029 -0.0588708342645 -0.0495095557344 -0.0412672244464 -0.0341290336621 -0.0279605423084 -0.0226132427293 -0.0179178451861 -0.0137292515206 -0.00992472400873 -0.00641284770106 -0.00313104021537 -4.47040357026e-05 0.00285500820646 0.00555162774854 0.00800336425704 0.0101432192298 0.0118807002582 0.013105696098 0.0136951209315 0.013522175037 0.0124660685519 0.010421292603 0.00731778499012 0.00316567702499 -0.00192264742099 -0.00782766048373 -0.0144499094005 -0.0211488785429 -0.0264111335494 -0.0305155905762 -0.0359479268126 -0.125285118698 -0.125270445456 -0.125241754786 -0.125194744438 -0.125120657131 -0.125036840702 -0.124935804664 -0.124818701443 -0.124682077287 -0.124521260546 -0.124337806478 -0.124118549233 -0.123852077237 -0.123511636735 -0.123078869131 -0.122558238904 -0.121943240382 -0.121191203186 -0.120316258417 -0.119332207353 -0.118213337625 -0.116946106164 -0.115548147752 -0.114008676973 -0.112321847129 -0.110496826245 -0.108528585038 -0.106416443795 -0.10415188837 -0.101730530321 -0.0991542366476 -0.0964265545725 -0.0935680376853 -0.0906079734613 -0.087575560358 -0.0845544892659 -0.0816476935326 -0.0790795290347 -0.0774336732889 -0.0770300955036 -0.08360493657 -0.056633021784 -0.0447798451226 -0.0807092527901 -0.0963873509057 -0.0923338314038 -0.0848678252518 -0.0741502978023 -0.0631727261131 -0.0528893314121 -0.0436532930355 -0.0356295858655 -0.0287460188586 -0.0228470841184 -0.0177661779448 -0.0133292679282 -0.0093928156221 -0.00584044809242 -0.00259024675504 0.000408864326364 0.00317825655453 0.00571147615737 0.00797399543661 0.00990291168703 0.0114080811963 0.0123766568753 0.012681626478 0.0121948678445 0.0108047427574 0.00843542539462 0.00506312833576 0.00073458656528 -0.00439581821416 -0.0100356419468 -0.0158256195281 -0.0214642230472 -0.0265134031393 -0.0301434198095 -0.0327765852261 -0.0357702707102 -0.125574422154 -0.12556382336 -0.12554059868 -0.125505986385 -0.125441492732 -0.125353666815 -0.12525317817 -0.125144608093 -0.125021444327 -0.124876354453 -0.124708047011 -0.124512141407 -0.124269707976 -0.123968089724 -0.123571027174 -0.123059413045 -0.122437375569 -0.121684693018 -0.120772927972 -0.11972220201 -0.118541370685 -0.117205524201 -0.115701201824 -0.114047419902 -0.112239760543 -0.110269800224 -0.108136871232 -0.105830836385 -0.103339934001 -0.100660560344 -0.0977890313384 -0.0947381512077 -0.0915105270435 -0.0881154203769 -0.0845994677103 -0.0810444481427 -0.0775608347529 -0.0746669978091 -0.0732547715706 -0.0739856312042 -0.0851994808011 -0.0451328115568 -0.0361598965406 -0.0793525681054 -0.0922439496796 -0.0875048220516 -0.0793855051894 -0.0681222344661 -0.0570464114942 -0.0468032854171 -0.0377502644937 -0.0299800491365 -0.0233754873273 -0.0177629209668 -0.0129615478859 -0.00879589469152 -0.00512612198138 -0.00184399223271 0.00112153535304 0.00380867388812 0.00622397303145 0.00834367804705 0.0101129681053 0.0114462598289 0.0122312003653 0.0123386691291 0.0116387049186 0.0100215834073 0.00742331044922 0.00385183214698 -0.000596101277503 -0.00573298656136 -0.0112770839867 -0.0168344907285 -0.0219262770421 -0.0261817063962 -0.0296485573322 -0.0324614352292 -0.0343363530039 -0.0345677504156 -0.125867940987 -0.125863434557 -0.125849806012 -0.125822490915 -0.125772426183 -0.125691060295 -0.125590830291 -0.125486291521 -0.125374092395 -0.12524669075 -0.125096288454 -0.124924557751 -0.124710732928 -0.124444592263 -0.124097394797 -0.123630155827 -0.123006843046 -0.122243166291 -0.121317826539 -0.120210988076 -0.118942241575 -0.117523522257 -0.115931516208 -0.114155731806 -0.112214470186 -0.110090176106 -0.107770423624 -0.105251380717 -0.102521007363 -0.0995671281424 -0.0963956691972 -0.09298131883 -0.0893070054185 -0.0853843170501 -0.0812612660451 -0.0769384333995 -0.0725835583954 -0.0687647543432 -0.0663049722622 -0.0659368852538 -0.0790429611686 -0.0372904493704 -0.0306593079657 -0.0784860697102 -0.0878179634003 -0.08244285366 -0.0735542702292 -0.0618650914745 -0.0507689100505 -0.0406274526998 -0.0318070714768 -0.024320571625 -0.0180170217797 -0.0127065306989 -0.00819806024003 -0.00431753484222 -0.000930828463761 0.00206042999856 0.00471492234037 0.00705641978511 0.0090748194442 0.010727035325 0.0119363579583 0.0125949403598 0.0125731253944 0.0117377283098 0.00997721632024 0.0072298077229 0.00351180074236 -0.00105720837615 -0.00624645265432 -0.011745054851 -0.0172190531832 -0.0223258655864 -0.0266622392099 -0.0298316559207 -0.0320586166477 -0.0347355642922 -0.0340596299773 -0.0341023377616 -0.126157313576 -0.126158533727 -0.126152620788 -0.126131592065 -0.126095528784 -0.126035049324 -0.125946173538 -0.125840611082 -0.125735869372 -0.125623982616 -0.125497048437 -0.125349579457 -0.125178670139 -0.124949422249 -0.124650841159 -0.124236713534 -0.123662736917 -0.122883074767 -0.121929005521 -0.12078765565 -0.11944100194 -0.117912954531 -0.116215999157 -0.114331774581 -0.112239768176 -0.109943056434 -0.107435614817 -0.104709546446 -0.10173853811 -0.0985120543753 -0.0949932627678 -0.0911536083538 -0.0869947662739 -0.0825112067986 -0.0776736892705 -0.0724362701016 -0.0669068586287 -0.0614178041777 -0.0561675670218 -0.0501274511899 -0.0463370680877 -0.0318207900069 -0.0249624091149 -0.0768261868742 -0.0829988767508 -0.0771677889458 -0.0674340099939 -0.0554309297346 -0.0443698484039 -0.0343826315856 -0.0258353959892 -0.0186577759321 -0.0126742174431 -0.00767996612003 -0.00347762525668 0.000103065349711 0.00318858899192 0.00586574178931 0.00817926295599 0.0101367602591 0.0117096331371 0.0128338617274 0.013410692426 0.0133135188226 0.0124052157517 0.0105667489072 0.00773149780307 0.00391575384487 -0.0007607529446 -0.00606333013502 -0.0116497603719 -0.0171340979124 -0.0222068054004 -0.0266698979247 -0.0303034640634 -0.0328460117649 -0.0339873960786 -0.0336818704659 -0.0336890661071 -0.0336423484325 -0.126437755692 -0.126442049783 -0.126440374094 -0.126427406027 -0.126401771333 -0.126360865283 -0.126292940458 -0.126194204234 -0.126096168193 -0.125999159601 -0.125896954562 -0.125781238388 -0.125650844934 -0.125485921577 -0.125240952666 -0.124899620372 -0.124374870066 -0.123628717891 -0.122630690762 -0.121432431024 -0.120019130115 -0.118394070861 -0.116565830453 -0.114545457142 -0.112312313946 -0.109842084941 -0.107152384503 -0.104217094762 -0.100994302892 -0.097449214442 -0.0935584274146 -0.0893290737718 -0.0847019019813 -0.0796249389048 -0.0740175213065 -0.0677936640191 -0.0610156319403 -0.0539442234312 -0.0464225019994 -0.0340416744527 -0.0415046501137 -0.0411860655184 -0.0219091956036 -0.0752315325145 -0.0779027681303 -0.0715967842095 -0.0610280176701 -0.0488482110358 -0.0378753268674 -0.0280918762284 -0.0198506665564 -0.0130021973813 -0.00735414958547 -0.00268839944904 0.00119506425471 0.00446060409804 0.00722519440942 0.00956237893368 0.0115013277061 0.0130317969072 0.0141051776385 0.0146359466443 0.0145054995771 0.013576122062 0.0117185144472 0.00885075326334 0.0049786627638 0.000221075953257 -0.00519109998189 -0.010929335247 -0.0165802960026 -0.0217069686206 -0.0260378548575 -0.0296113577489 -0.0324847263239 -0.0345651734342 -0.0355885745058 -0.0339285300582 -0.0334296232127 -0.0332306942569 -0.126711546092 -0.126713021328 -0.126713686869 -0.126706013317 -0.126689844408 -0.12666341062 -0.126620160598 -0.126539392997 -0.126446414485 -0.126362303326 -0.126282163519 -0.126202850807 -0.126115715301 -0.12601468465 -0.125855443928 -0.125603662729 -0.125160955364 -0.124423936568 -0.123431496001 -0.122168120006 -0.120651400238 -0.118923733626 -0.116984018907 -0.114805313111 -0.11241519426 -0.10978942381 -0.106912589903 -0.103751756214 -0.100251730941 -0.0963993953941 -0.0922165345397 -0.0876057882186 -0.0824751762549 -0.0767577083394 -0.0703457233472 -0.0631187116052 -0.0553436126078 -0.0474327383393 -0.0415669578242 -0.0392206372006 -0.0404344138488 -0.0204924932413 -0.00830530013577 -0.0717753238321 -0.0719824403544 -0.06558704052 -0.0543404546884 -0.0421405525195 -0.0313115894346 -0.021779968291 -0.01387097528 -0.00736719849077 -0.0020664537795 0.0022606738385 0.00581322933279 0.00874784531389 0.0111701880254 0.0131389412007 0.0146661439115 0.0157222708831 0.0162379108776 0.0161070620663 0.0151964683077 0.0133694961375 0.0105247237566 0.00664211642305 0.00182363162866 -0.00369297192994 -0.00956622305411 -0.0154047203246 -0.0207813457298 -0.0252459315055 -0.0285726646524 -0.0312612377538 -0.033956619009 -0.0357483007413 -0.0342862001146 -0.0333357267697 -0.0328633904176 -0.0326629726683 -0.126974166115 -0.126970616074 -0.126971511601 -0.12696574408 -0.126954748276 -0.126938992033 -0.126911524012 -0.126866216544 -0.126784199803 -0.126705428364 -0.126640970042 -0.126591354514 -0.126559202043 -0.126522923896 -0.126490266931 -0.126323228447 -0.12593800468 -0.125259269904 -0.124239320164 -0.122946642716 -0.12136403253 -0.119482002966 -0.117400603931 -0.11508951975 -0.112546031017 -0.109762369491 -0.106699266114 -0.103301916182 -0.0995566135534 -0.0954872310847 -0.0909952536476 -0.085958701268 -0.0803204452052 -0.0739584059229 -0.0667306054498 -0.0584878811502 -0.049618965208 -0.0403570209666 -0.0373823131727 -0.0376842371784 -0.0387515021091 -0.000260227381577 0.00294197849016 -0.0676595900212 -0.0649505736771 -0.0590876834135 -0.0474024027636 -0.0353452870314 -0.0247141241476 -0.0154760878179 -0.00791711220219 -0.00176805953969 0.00317772964493 0.00715842182666 0.0103688643953 0.0129563617839 0.015013584211 0.0165828875881 0.0176578349831 0.0181887256381 0.018085719655 0.017225609686 0.0154694090239 0.0126987798468 0.0088650851517 0.00403631962118 -0.00157081972899 -0.00759241676455 -0.013588453483 -0.0191647466309 -0.0240039683588 -0.0277682627728 -0.0302284050619 -0.0320590376095 -0.035028593349 -0.0338930421201 -0.0330803242119 -0.0324502182481 -0.0320896063281 -0.0319244557086 -0.127218356781 -0.127215877166 -0.127215194838 -0.127208815659 -0.127197251654 -0.127186602717 -0.127173535746 -0.127149829501 -0.12710099222 -0.127021423287 -0.126960151527 -0.126927925161 -0.126940845919 -0.12697381667 -0.127023745625 -0.127066720652 -0.12662814967 -0.126100656876 -0.125072240655 -0.123720649169 -0.122038001039 -0.120051392179 -0.117808260301 -0.115357436187 -0.112685204097 -0.109751646966 -0.106499012374 -0.102911897282 -0.0989952847519 -0.0946823825515 -0.0898535404613 -0.0844434801155 -0.0783403348564 -0.0713871484178 -0.0633805177918 -0.0541106106686 -0.0436362490136 -0.0313784102323 -0.028490115434 -0.0339289501917 -0.0369201391991 0.0157279203736 0.00783533687196 -0.0644896240411 -0.0577846132339 -0.0525291669999 -0.0403816757182 -0.0285473831212 -0.0181363133537 -0.00921552614385 -0.0020121404509 0.0037791782836 0.00836699569705 0.0119958223376 0.0148537504487 0.0170774656285 0.0187451626337 0.0198816596731 0.0204611139674 0.0204135871198 0.0196307834845 0.0179783972955 0.0153247892533 0.0115917729406 0.006811577296 0.00116343916354 -0.00501982122553 -0.0112728337697 -0.0170962265104 -0.0221575286119 -0.026340719218 -0.0295254416482 -0.0317051834546 -0.0328487623118 -0.0324467884108 -0.0322789958248 -0.0318040677861 -0.0314000046363 -0.0311379355631 -0.0310090195537 -0.127444280771 -0.127449712681 -0.127448403266 -0.127436424968 -0.127418322773 -0.127404710006 -0.127403363001 -0.12740283234 -0.127364860468 -0.127306294012 -0.127229826952 -0.127190906949 -0.127228943501 -0.127287159211 -0.127339797169 -0.127302524265 -0.127209269436 -0.126638717463 -0.125863601285 -0.124438295853 -0.122678054639 -0.120530850714 -0.118159355439 -0.115594577341 -0.112809571806 -0.109747562215 -0.106346640001 -0.102610038052 -0.0985075307885 -0.0939433795223 -0.0888484946535 -0.083128135179 -0.0766682882755 -0.0692766935499 -0.060708565672 -0.05058617475 -0.0381423814019 -0.0223490692283 -0.0189397458365 -0.029210182984 -0.0315071531388 0.0328740395072 0.00893105591665 -0.0617399609758 -0.0510240131907 -0.0462706945227 -0.0334746165764 -0.0218590398262 -0.0116420435453 -0.00303581821384 0.00382134195273 0.00925982754519 0.0134913036001 0.0167649515784 0.0192604906287 0.0211030667728 0.0223552086691 0.0230233369888 0.02306185293 0.022381594043 0.0208597902603 0.0183606444463 0.0147775604379 0.010097829812 0.00446253918222 -0.00181985898624 -0.00831503187565 -0.0145024892855 -0.0198331659961 -0.024014143875 -0.0273153203467 -0.0301308967467 -0.0325255964478 -0.0337907711467 -0.0318145111078 -0.0310770146516 -0.0305721319471 -0.0302340827704 -0.0300229313206 -0.0299133610147 -0.127656187829 -0.127670904837 -0.127674360394 -0.127648105899 -0.127614686018 -0.127588336294 -0.127583756678 -0.127613645002 -0.127574951932 -0.127529062942 -0.127458509298 -0.127369693054 -0.12742886639 -0.127407176759 -0.127356435837 -0.12731564424 -0.127297612611 -0.127094216005 -0.126277605898 -0.125056764165 -0.123077568712 -0.120872355157 -0.118420021841 -0.115779183003 -0.11290669583 -0.109734029873 -0.106225156286 -0.102353890785 -0.0980711672062 -0.0933253249858 -0.0880384626225 -0.0821252659959 -0.0754655515045 -0.0678910771849 -0.0591428740786 -0.0487320291512 -0.0354396737028 -0.0249247800359 -0.018415340231 -0.0263721172928 -0.0145731509353 0.0530339915362 0.00741079993824 -0.0583482391288 -0.0445829963603 -0.0403169567717 -0.0267553444431 -0.0153492286404 -0.00527651767884 0.00303538603058 0.0095670903573 0.0146638265297 0.0185440100319 0.0214604056123 0.0235836258143 0.0250267052327 0.0258356803062 0.0259982253508 0.025449504114 0.0240836204567 0.0217698157556 0.0183844694652 0.0138684703701 0.0083018372056 0.00195977943552 -0.00470193211254 -0.011158708164 -0.0169138952685 -0.0214476568234 -0.024499310096 -0.0271225320455 -0.0306939938257 -0.0332842064103 -0.0314579518857 -0.0303036192098 -0.0296258182108 -0.0291902942789 -0.0289085977577 -0.0287342871361 -0.0286433780899 -0.127855290019 -0.127878360802 -0.127896821762 -0.127844680018 -0.127782711688 -0.127731136261 -0.127705790527 -0.127715039456 -0.127737358169 -0.12768533499 -0.127631969593 -0.127403130298 -0.127381670755 -0.127352996946 -0.12731233725 -0.127306399344 -0.12728844903 -0.127184593482 -0.126714176679 -0.125103275447 -0.123228604407 -0.121014880072 -0.118571774782 -0.115888738511 -0.112946675831 -0.109710413694 -0.10611509048 -0.10213141504 -0.097730978122 -0.0928653448682 -0.0874666519395 -0.0814639432504 -0.0748015928165 -0.0673361672511 -0.0588134067468 -0.0487763303198 -0.0355704608092 -0.0298815101872 -0.0253561643315 -0.0312326812391 0.0206000278999 0.0706982194192 0.00446302009371 -0.0536218510044 -0.0384243656755 -0.0345587218244 -0.0202134789075 -0.0090273094387 0.000950063218921 0.00899048963466 0.015221021902 0.0199889827989 0.0235237741277 0.0260805225695 0.0278204935657 0.0288441942881 0.0291806421189 0.0287989010919 0.0276162866444 0.025514112326 0.0223626732269 0.018068679199 0.0126491322034 0.00630812757675 -0.00052470405971 -0.00724035251335 -0.0132452293425 -0.0182200148804 -0.021998761264 -0.0243374474735 -0.0264813232341 -0.0313054462173 -0.0300478586262 -0.0292001813337 -0.0284679628807 -0.0279682451053 -0.0276333307271 -0.0274124445111 -0.0272720300024 -0.0272044467286 -0.12802901303 -0.128081556123 -0.128122941043 -0.12802045532 -0.127919332691 -0.127834005436 -0.12777332884 -0.127748652792 -0.127749568053 -0.127728984613 -0.127703579039 -0.127654778589 -0.127405620505 -0.127295835337 -0.127284402752 -0.127324943178 -0.127354353285 -0.127230655851 -0.126321530485 -0.124936884862 -0.123123727988 -0.121012470687 -0.118598747343 -0.115911483755 -0.1129479523 -0.109665967444 -0.106020062108 -0.101974383077 -0.0974983821281 -0.0925684827105 -0.0871346812297 -0.0811704955278 -0.0746564485949 -0.0675280910999 -0.0597114952484 -0.0512715404898 -0.0420158456694 -0.0347687696438 -0.0322069379558 -0.0381013585815 0.027618915368 0.0715804250432 -0.000520571463655 -0.0484786870323 -0.0329245991943 -0.0289844344112 -0.0138506438831 -0.00287605687455 0.00705361924663 0.0148416187301 0.020792702796 0.0252423165679 0.0284355233971 0.0306280980195 0.0319718675169 0.0325543880098 0.0323874469744 0.0314223420106 0.0295613362981 0.0266794166955 0.0226613387435 0.0174686876882 0.0112291522274 0.00430047899331 -0.00273948074779 -0.00918551660561 -0.0144307272304 -0.0184087880757 -0.0217931451107 -0.0249865284932 -0.0271390183053 -0.0265801616977 -0.0271716991572 -0.0268579661199 -0.026458222949 -0.0261241596516 -0.0258816957118 -0.0257195189429 -0.0256055760136 -0.0255560361657 -0.128128227299 -0.128153295615 -0.128145608339 -0.128127190248 -0.128015173806 -0.127905939368 -0.127821451297 -0.12776734579 -0.127764788882 -0.127801082329 -0.127735954917 -0.127599913176 -0.127462518075 -0.127361562158 -0.127358558665 -0.127429892362 -0.127420882735 -0.126896480048 -0.125986638023 -0.124633155233 -0.122934754199 -0.12090131927 -0.118554652648 -0.115884763999 -0.112922832183 -0.109638228427 -0.105965917516 -0.101885153116 -0.0973816913934 -0.0924379405255 -0.0870240483266 -0.081143039522 -0.074842559442 -0.0681162410829 -0.0611332432136 -0.0541728944225 -0.0473648928598 -0.0419301275355 -0.0391884750719 -0.0444035760664 0.0241390676004 0.0655586558028 -0.00621465027224 -0.044144204979 -0.0284149099772 -0.0236287571106 -0.00768581924881 0.00313431494602 0.0130656966333 0.0206155761976 0.0263031116106 0.030439087343 0.0332900332929 0.0351102185574 0.0360419253856 0.036159176985 0.0354565288225 0.0338689164737 0.0312874194664 0.0275888305801 0.0226882844716 0.0166285209082 0.00967863407725 0.00236834644609 -0.00459754546778 -0.0105022191631 -0.0148046256443 -0.0176333253591 -0.0207573645047 -0.0256876662408 -0.0288048636423 -0.0259200604046 -0.0252257462503 -0.0247355964657 -0.0243808397697 -0.0241122016466 -0.0239127149154 -0.0237807462913 -0.023687921864 -0.023636030139 -0.128150340123 -0.128148854375 -0.128145013263 -0.128151109489 -0.128060664404 -0.127945945111 -0.127851630498 -0.127784161956 -0.127750914474 -0.127734668996 -0.127683391647 -0.12756803278 -0.127441272535 -0.127406755227 -0.127497390479 -0.127557299142 -0.1272221643 -0.126595763548 -0.125650940148 -0.124326405607 -0.122703781623 -0.120759623948 -0.118462047975 -0.115835829489 -0.112904468163 -0.109627418689 -0.105962071248 -0.101882017294 -0.0973766140363 -0.0924473030184 -0.0870732848422 -0.0812829158478 -0.0751276655245 -0.0687601642969 -0.0624691548004 -0.0565944257519 -0.0514536333053 -0.0475337348689 -0.0451684715541 -0.0495717028855 0.0220235169165 0.0615574536381 -0.0103060797379 -0.0402933949502 -0.0245020391847 -0.0183526069963 -0.00166427817339 0.00907115710909 0.019036911053 0.0263520491048 0.0317820115078 0.0356006926255 0.0381025072704 0.0395374217549 0.0400379121458 0.0396636949436 0.0383924093735 0.0361449559645 0.0328069868349 0.0282687979896 0.022498744683 0.015656927206 0.00819185240915 0.000824569481126 -0.00562987669248 -0.0105382153977 -0.0137020536427 -0.0156666520781 -0.0187409012235 -0.0264905773958 -0.0244941523153 -0.0234367428951 -0.0228413273149 -0.0224365215656 -0.0221418394433 -0.0219153368229 -0.0217387414014 -0.0216102093066 -0.0215321607587 -0.0214734960351 -0.128141131585 -0.12814084201 -0.128149945193 -0.128166239056 -0.128070045524 -0.127960090602 -0.127861967595 -0.127781673643 -0.127725929347 -0.127664986676 -0.12759624507 -0.127521783526 -0.12745752515 -0.127462094912 -0.127540058012 -0.127575041648 -0.12705615716 -0.126346715219 -0.125342829649 -0.124050804248 -0.122491412503 -0.120599326755 -0.118370622153 -0.115802129282 -0.112914521607 -0.109676327226 -0.106029502497 -0.101966017726 -0.0974872634556 -0.092580268958 -0.0872131662102 -0.0814290252423 -0.0753728353808 -0.0692394408908 -0.063357982567 -0.0581942762753 -0.0541560234948 -0.0518268007923 -0.0499097462955 -0.0535568211938 0.0214327485933 0.0599423221886 -0.0125301384262 -0.0362815230819 -0.0205097102766 -0.0128747027786 0.00437587422123 0.0150535420865 0.0250411224023 0.0321027326995 0.0372652733532 0.0407520312262 0.042890510632 0.0439222516788 0.0439691845445 0.0430755881317 0.0412027150252 0.0382604849799 0.034136233877 0.0287475614375 0.0221421314406 0.0146327990628 0.00686505324057 -0.00028975254269 -0.00602398912607 -0.00993616986028 -0.0124966988044 -0.0156431323174 -0.019594831929 -0.019271042647 -0.0206429202106 -0.0205031908644 -0.0202361423985 -0.0199734352935 -0.0197521829039 -0.0195697017865 -0.0194217165157 -0.0193049180353 -0.0192343689078 -0.0191914292792 -0.128186540287 -0.128149388933 -0.128157925488 -0.128180508026 -0.128069828537 -0.127962862465 -0.127865137395 -0.127782963333 -0.127720686267 -0.127611063939 -0.127514128137 -0.127475360396 -0.127534471224 -0.127658980359 -0.127527727181 -0.127352159973 -0.126862895615 -0.126125555516 -0.125125919456 -0.123863929651 -0.122316757414 -0.120472105575 -0.118319363522 -0.11582034406 -0.112987412691 -0.109786929129 -0.106181482364 -0.102154052416 -0.097701142732 -0.0927815568141 -0.0873508716415 -0.081530332042 -0.0754865138722 -0.0694012991429 -0.0636551382974 -0.0587475327709 -0.0551617200546 -0.0535718938904 -0.0530495974592 -0.057840416264 0.0192388439949 0.0584380533703 -0.0136354568031 -0.0318843017605 -0.0160110090672 -0.00695653348268 0.0106305438833 0.0212203620659 0.0311625147429 0.0379238761626 0.0427896309516 0.0459177324748 0.0476713149324 0.048277542566 0.0478463217827 0.0464050069477 0.0438994551295 0.0402330247989 0.0353044022887 0.0290767025011 0.0217105114089 0.0137111650027 0.00592723919059 -0.000683182384956 -0.00547348656867 -0.00849958281646 -0.0106316705035 -0.0140952619909 -0.0220848995869 -0.0185216528512 -0.0181754903236 -0.0178521485102 -0.017614817437 -0.01741566461 -0.0172491689706 -0.0171103881303 -0.0169970511925 -0.0169057849521 -0.0168476967928 -0.0168225543476 -0.12819257255 -0.128156133783 -0.128160024989 -0.128177556701 -0.128063176503 -0.127960309357 -0.127865348303 -0.127785591475 -0.127737208676 -0.12756706763 -0.127436489224 -0.127431832318 -0.127547440179 -0.127663710729 -0.127657068623 -0.127353274459 -0.126791124688 -0.125983486057 -0.12497872511 -0.123733035426 -0.122226112944 -0.120429590783 -0.118334559589 -0.115909382516 -0.113137087848 -0.109990217975 -0.106425842585 -0.102440556553 -0.0979865763563 -0.0929760793878 -0.0874757009027 -0.0815896485826 -0.0754051940153 -0.0691560239841 -0.0632265878334 -0.0580686090274 -0.0542925800773 -0.0530344679805 -0.0541110778855 -0.0723478138496 0.0117551571718 0.0550365744007 -0.0139576721646 -0.0269094018396 -0.0107712146677 -0.000433567202244 0.0172673911289 0.0276876221495 0.0374720472634 0.0438622986444 0.0483842962811 0.0511169797021 0.0524586299448 0.0526143683755 0.0516798141273 0.0496634773216 0.0464970818777 0.0420826298027 0.0363407153178 0.0292983769903 0.0212622738074 0.0129589609808 0.00540387882212 -0.000482190757777 -0.00432281708374 -0.00686493428555 -0.0104865340961 -0.0148946999904 -0.0143199757719 -0.0151654899334 -0.0151618270829 -0.0150328159823 -0.0148874908034 -0.014756953874 -0.0146450930989 -0.0145515166326 -0.0144750730525 -0.0144105068758 -0.0143726562493 -0.0143604134442 -0.128197357205 -0.128166264776 -0.128160317033 -0.128141423449 -0.128054270824 -0.127957505198 -0.127863205321 -0.127781746503 -0.127737538357 -0.127527796887 -0.127374163952 -0.127396780386 -0.127552637122 -0.1276621866 -0.127636183584 -0.127580650528 -0.126749854325 -0.125910203111 -0.124892218781 -0.123663143383 -0.122198514583 -0.120465363316 -0.11843966605 -0.116085429172 -0.113380977384 -0.11028417037 -0.106770575058 -0.102801487843 -0.0982870181713 -0.0932187463618 -0.0876402240981 -0.0815751110082 -0.0750911318737 -0.0683767160397 -0.0617977673262 -0.0557382417567 -0.0507288491819 -0.047732463765 -0.0490598013366 -0.0567066478888 -0.000566495829847 0.0512479658954 -0.0114288490536 -0.020569337654 -0.00444624977801 0.00688478377211 0.0244215960556 0.0345281916737 0.0440090215008 0.049941633385 0.054062093972 0.0563580179798 0.0572592748085 0.0569401580095 0.055479236001 0.0528641770934 0.0490146593911 0.0438387031089 0.0372933923136 0.0294944231468 0.0209389993992 0.0126174970334 0.00568709469023 0.000877877765428 -0.00196930735216 -0.00401140995888 -0.00801504259485 -0.017492944483 -0.0131258699785 -0.0125791711833 -0.0123205349883 -0.0121925862294 -0.0120985969205 -0.0120255396323 -0.0119655807049 -0.0119166041496 -0.0118784305489 -0.0118444504763 -0.0118274818729 -0.0118248132692 -0.128211015476 -0.128187873334 -0.128226985943 -0.128164636033 -0.12806156753 -0.127956176265 -0.127857561021 -0.127772558178 -0.127726812519 -0.127490057978 -0.127325554969 -0.127379877007 -0.127559616057 -0.127650015299 -0.127646846909 -0.127266491619 -0.126639097607 -0.125852941137 -0.124853225395 -0.123660562667 -0.122254482933 -0.12059434162 -0.118638722079 -0.116357312363 -0.113717279158 -0.110675176241 -0.10720113147 -0.103228842976 -0.0986913123725 -0.0935688054958 -0.0878608856266 -0.0815015567155 -0.0745310093274 -0.0672289284258 -0.0597783085047 -0.0522454591405 -0.0449500696204 -0.0384242439959 -0.0383114138475 -0.0402683246325 -0.0297276124795 0.0520539389896 -0.00372320389486 -0.0122729661214 0.0033873658026 0.0152058237372 0.0321757515678 0.041758692245 0.0507691288264 0.0561527889413 0.0598130621806 0.0616340738304 0.0620707610625 0.0612574040706 0.0592526552594 0.0560214751714 0.0514741579485 0.0455331958729 0.0382080713716 0.0297261676695 0.0208104848014 0.0127317640202 0.00671971851335 0.0031546057432 0.000892107146904 -0.0032269863862 -0.00878845595858 -0.00816329729856 -0.00917038900587 -0.00927474008855 -0.00928446812172 -0.00927628646325 -0.00926738712439 -0.00926247745388 -0.00925932215696 -0.00925680609852 -0.00925506863033 -0.00925644493439 -0.00926328377139 -0.00927081459839 -0.128224875776 -0.128204840963 -0.12822544856 -0.128216590285 -0.12807322161 -0.127953223331 -0.127845645259 -0.1277544171 -0.127704618034 -0.127454563077 -0.127285993855 -0.127359227575 -0.127546115965 -0.127652424074 -0.127511078828 -0.127176706901 -0.126612253515 -0.125830710951 -0.124889053712 -0.12376219325 -0.122402986574 -0.120804447941 -0.118933198554 -0.116732047802 -0.114149857977 -0.111166987727 -0.107743133823 -0.103784894986 -0.099231389513 -0.0940624224189 -0.0881901386335 -0.0814666990784 -0.0740793898684 -0.0662484611311 -0.0578061029636 -0.0484329752086 -0.0377292866353 -0.0219628576647 -0.0252327509887 -0.0271693304514 -0.0119519496024 0.0861304236109 0.0125722029 -0.00104989326801 0.0132392496059 0.0246092705356 0.0404909246886 0.0493135064238 0.0576918671939 0.062447643972 0.0656012121101 0.0669215759985 0.0668803846729 0.0655633270209 0.0630067022247 0.0591515943831 0.0539028236473 0.0472087547381 0.0391554999568 0.0301209602567 0.021104736423 0.0136932424685 0.00914425673459 0.00712357925603 0.00552673669222 0.00057592236493 -0.0119978497811 -0.00690532312662 -0.00641164802734 -0.00626977281141 -0.00630476686357 -0.00637894150592 -0.00645474754372 -0.00652623266893 -0.00658929289179 -0.00664201792182 -0.00668338084306 -0.00671910340875 -0.00674384422355 -0.00675430071489 -0.12823249867 -0.128211947063 -0.128223620564 -0.128220257039 -0.128072553135 -0.12794402575 -0.127828719344 -0.127730722775 -0.127679485207 -0.127430661104 -0.127264078475 -0.127352844358 -0.127551724598 -0.127694504417 -0.127489411414 -0.127142113802 -0.126619399849 -0.125897150043 -0.125001879519 -0.123921027927 -0.122640926442 -0.121142119158 -0.119336011626 -0.117192591884 -0.114697609998 -0.111797094322 -0.108407100404 -0.104484218316 -0.0999636830602 -0.0947415910372 -0.0886698418676 -0.0817159500247 -0.074110390711 -0.0659061102179 -0.0568142863299 -0.0462814040853 -0.0333418194638 -0.0121145931924 -0.0132875691973 -0.0165329186182 0.044719844333 0.140104054796 0.0316362248944 0.0132205190348 0.0250218398801 0.0347792914512 0.0491302439368 0.0570173150739 0.0646505324974 0.068736863133 0.0713649028509 0.0721810929075 0.0716662963525 0.0698510395678 0.0667480043949 0.0622744639372 0.0563350058626 0.0489161681935 0.0402074209133 0.0307807549627 0.0219245972768 0.0154286248764 0.012584012746 0.0119929774486 0.0076370263214 -0.000391542441155 -4.7869297724e-05 -0.00215711738683 -0.00270334509973 -0.00302630383759 -0.00327612921555 -0.00349541858684 -0.00368563108404 -0.00385039928514 -0.00399102578966 -0.00410751355485 -0.00420030558425 -0.00426854103755 -0.00430766041734 -0.00431528870868 -0.128235428611 -0.128214163205 -0.128223509991 -0.128220607247 -0.128068754665 -0.127932908685 -0.127811779868 -0.127712203884 -0.127679461957 -0.127446576792 -0.12727595365 -0.127360662507 -0.127564180867 -0.12771561784 -0.127479415817 -0.127130464686 -0.126641169366 -0.126003163021 -0.125180177131 -0.124174171156 -0.12298472556 -0.121558207354 -0.11982752473 -0.117787115261 -0.115389100566 -0.112542916773 -0.10922873764 -0.1053856987 -0.100888922513 -0.0956337477149 -0.0894664160017 -0.0824264576427 -0.0747743412455 -0.0664927063784 -0.0573469644104 -0.0469903546543 -0.03509242883 -0.0196741790234 -0.0175520628038 -0.0221695596073 0.13617508983 0.183108158181 0.0458413946558 0.0285416591989 0.0370857492301 0.0448117999741 0.0576269669281 0.0645797855947 0.0714572437642 0.0748968156408 0.0770224811795 0.0773614144228 0.0764003022121 0.074111382426 0.0704840459718 0.065413124464 0.0588096458298 0.0507119574776 0.0414443370279 0.0318510634644 0.0235940738776 0.0184129933021 0.0171587661501 0.0184993907026 0.0136560723649 -0.00499143945899 0.00117581385555 0.00100214882299 0.000609436033444 0.000135780417463 -0.0002891206 -0.000658391002118 -0.000979262715172 -0.00124917273639 -0.00147423483742 -0.00165726911073 -0.00180090082138 -0.00190253760828 -0.00196517705856 -0.00198593102634 -0.128234674067 -0.128211076107 -0.128223065258 -0.128217812665 -0.12806592398 -0.12792102457 -0.1277887287 -0.127675713572 -0.127652504511 -0.127527231742 -0.127327485181 -0.127377764919 -0.127578891621 -0.127733014288 -0.127491993404 -0.127143070759 -0.126681832524 -0.126111691162 -0.125401070715 -0.12450541721 -0.123404573542 -0.122065953326 -0.120448470012 -0.118519356161 -0.11620130756 -0.11343204022 -0.110218119063 -0.106474244809 -0.102053230048 -0.096830158011 -0.0906353706265 -0.0836281463247 -0.0760883207269 -0.0679557385707 -0.0590871826759 -0.049304181602 -0.0385465603717 -0.0254426873557 -0.0236343698614 -0.0278787090843 0.147184923368 0.183536383228 0.0495688015701 0.0407099412407 0.0467971724647 0.0535621732962 0.0654003028893 0.0716498511414 0.0778961561038 0.0807892884221 0.0824840816367 0.0824066874305 0.0810524287703 0.0783362995426 0.0742268905466 0.0685998980179 0.0613827752746 0.0526841054886 0.042993905427 0.0334847151549 0.0262278212301 0.0225356679321 0.0212681599087 0.0196008394349 0.0151515064511 0.012759243256 0.00728600887446 0.00533873475756 0.00417043564304 0.00333602471641 0.00266797098678 0.00211913450833 0.0016556305192 0.0012721036741 0.000957540500266 0.000704626147091 0.00050839281746 0.000372760504095 0.00028200912595 0.000238947963577 -0.128237847595 -0.128207462626 -0.128233496816 -0.128226685345 -0.128070170688 -0.127921704754 -0.127803996584 -0.127725613936 -0.127702539938 -0.127538109196 -0.127363734589 -0.127392601777 -0.127589106687 -0.127746766148 -0.127513324668 -0.127186814429 -0.126765050618 -0.126250971583 -0.125625252584 -0.124857494467 -0.123894643199 -0.122676186253 -0.12117495247 -0.119351295658 -0.117131975696 -0.1144811397 -0.111397947426 -0.107771614976 -0.103440335087 -0.0983026617442 -0.092209836589 -0.0853381891745 -0.0780043568174 -0.0701586032925 -0.0617339888941 -0.0526852822422 -0.0431358916149 -0.0322864195397 -0.0309094604444 -0.0352508565373 0.134227289612 0.16956075165 0.0478024527022 0.0480219456586 0.0529741026701 0.0604654646218 0.0720427225107 0.0779479385453 0.0837869856578 0.0862932004469 0.0876682622117 0.0872655442275 0.0855958038134 0.0825213378176 0.0779935017895 0.071872276512 0.0641096755738 0.0548964431131 0.0448990211819 0.0356217177606 0.0294731937154 0.0271381984557 0.0253068508989 0.0184629389017 0.0113780335908 0.0116096874191 0.0102213415853 0.00873865140946 0.00748220503662 0.00643610231528 0.00555810776752 0.00482159792929 0.00421087660754 0.00370958861127 0.00330328729153 0.00297996247879 0.00273241362306 0.00255665421329 0.0024369672106 0.00237350476762 -0.128252654955 -0.128235639556 -0.128255956134 -0.128255588986 -0.128070020154 -0.127911815355 -0.127790495283 -0.12772557234 -0.12771564497 -0.127622724371 -0.127432303506 -0.127411390038 -0.127592795179 -0.127745228196 -0.127558547614 -0.127252891449 -0.126873893344 -0.126433583767 -0.125905954083 -0.125243370958 -0.124398640749 -0.123323551291 -0.121972023022 -0.120279383583 -0.118185224129 -0.115671728969 -0.112727284534 -0.109253514977 -0.105088602129 -0.100102960958 -0.0941527453531 -0.0874861232513 -0.0804328532417 -0.0729355258206 -0.0649847082517 -0.0566151218638 -0.0480363645874 -0.0386852876955 -0.0377922045311 -0.0421994323994 0.126039741631 0.161074510743 0.0470004786945 0.0526720072426 0.0568122130516 0.0658905028522 0.077535618772 0.0833860730452 0.0890429710529 0.0913321906856 0.0925161128734 0.0918978521007 0.0900102345307 0.0866677475658 0.0818088387192 0.0752815188459 0.0670741131395 0.0574817540437 0.0473840162128 0.0387201273256 0.0342925198368 0.0336268287945 0.032052247775 0.0241414899183 0.00680333775772 0.0133539882096 0.0131902857877 0.0121063799763 0.0107475545971 0.00947621599316 0.00837794876136 0.00744514433706 0.00667551444473 0.00605043506215 0.00555052614086 0.00515764293604 0.00486136292018 0.0046430883928 0.0044972358247 0.0044174394971 -0.128275692669 -0.128294279989 -0.128283171802 -0.128277093871 -0.128072292804 -0.127920483539 -0.127810292991 -0.127733329028 -0.127715795442 -0.12765808531 -0.127474703062 -0.127424990081 -0.127597091644 -0.127768910669 -0.127596516704 -0.127329633363 -0.127004211474 -0.126642367148 -0.126227942584 -0.125699666579 -0.124974345957 -0.124016383216 -0.122788945578 -0.121237784104 -0.119306042496 -0.116978670063 -0.114222339402 -0.110927720916 -0.106947669503 -0.102163597599 -0.0964409433159 -0.0900466748874 -0.0833005885918 -0.0761583913151 -0.0686342498128 -0.0607966617965 -0.052886994916 -0.0444342507523 -0.0440529957389 -0.0480981997881 0.123401219009 0.158078447501 0.0479840979463 0.0566800906564 0.0599042353224 0.0705149598167 0.0821201002964 0.0880497337404 0.0936710162772 0.0958814951101 0.0969956488872 0.0962776882384 0.0942823633963 0.0907817994336 0.0857045326618 0.0788907997304 0.070374729016 0.0605802347134 0.0506100356327 0.0428509641025 0.0408202052489 0.0423678209849 0.036169272357 0.0227501367986 0.022261575724 0.019437255825 0.0177089319769 0.0159401124616 0.0141347070714 0.0125101059369 0.0111223935205 0.00996804337694 0.00902268724805 0.00826331082146 0.00766572612699 0.00720328361322 0.00685673710466 0.00660258365522 0.00643595902206 0.00634803386097 -0.128300575132 -0.128299930013 -0.128291208142 -0.128287602768 -0.128092960212 -0.127944068701 -0.127832904067 -0.12775091846 -0.127724372266 -0.127678179746 -0.127503914866 -0.127442972484 -0.127624293554 -0.127846656068 -0.127691186096 -0.127429056563 -0.127140260089 -0.126849902699 -0.126552665668 -0.126183451887 -0.125602998257 -0.124774628236 -0.123667905898 -0.122248723169 -0.12047938029 -0.118347689591 -0.115793837691 -0.112716097428 -0.108981080228 -0.104473692285 -0.0990688284474 -0.0929849441393 -0.0865583440108 -0.0797545409121 -0.0725768815784 -0.0650879762036 -0.0575290428457 -0.049444397385 -0.0494855353824 -0.0530603153722 0.12220398322 0.156293344353 0.0491192064256 0.0603571368784 0.0627888807723 0.0746353576723 0.0860031337131 0.0920534578912 0.0977122618498 0.0999364634304 0.101087261935 0.100382097893 0.0984000882399 0.0948699891994 0.089716251949 0.0827733991829 0.074132854106 0.0643978819193 0.0550590738426 0.0490446683092 0.050258526471 0.0560212962614 0.048219451795 0.0158885101382 0.0249635275292 0.0238509566833 0.021989964057 0.0197875420342 0.0175306826463 0.0154713024682 0.0137542475976 0.0123483265979 0.0112121152121 0.0103088685512 0.00960958166413 0.00907605589699 0.00867785115546 0.0083915719474 0.00820482708777 0.00811276395626 -0.128329900943 -0.128298789164 -0.128298292075 -0.128299096651 -0.128152686117 -0.127997109478 -0.127873527327 -0.127772336422 -0.12772901689 -0.127684838413 -0.127523387554 -0.127460923193 -0.12764333932 -0.127808124763 -0.127804792341 -0.127531838334 -0.127265689575 -0.127040834617 -0.126876139973 -0.126702010264 -0.126243141863 -0.125535416314 -0.124564710537 -0.123307262192 -0.121720979994 -0.119779301007 -0.117429994884 -0.114567640616 -0.111108789207 -0.106962667603 -0.101990639913 -0.0962782710155 -0.0901892393949 -0.083715224199 -0.0768096610405 -0.0694859628307 -0.0619459821581 -0.0536873608838 -0.0540633527438 -0.057208395728 0.121058653552 0.154332391549 0.0496304267378 0.0633840780054 0.0652041190709 0.0781459722167 0.089198990724 0.095445461697 0.101179123954 0.103497906742 0.10477250899 0.104191407146 0.102344328694 0.0989304160124 0.0938692376682 0.0870084318464 0.0785063437367 0.0691631139325 0.0609908544011 0.0575348634585 0.0601531295924 0.0613304354066 0.0529008308585 0.0451446415563 0.0349666776624 0.030244577478 0.0267600563302 0.0237265901397 0.0209122505459 0.0183394101675 0.016227628361 0.014542953154 0.013204985067 0.0121511807987 0.0113402030735 0.0107312486261 0.0102854942861 0.0099729135871 0.0097667795443 0.00967203669738 -0.128348405158 -0.128315801903 -0.128339736515 -0.128380929352 -0.12827491737 -0.128094921635 -0.127948912874 -0.12783420613 -0.127745539638 -0.127682095618 -0.127538846315 -0.127459524219 -0.127612715901 -0.127774001137 -0.127829436381 -0.127606145368 -0.127342645096 -0.127158833917 -0.127090573631 -0.127132698092 -0.126811363654 -0.126267287707 -0.125450278931 -0.124365709841 -0.122987917555 -0.121256362379 -0.119115364721 -0.116480381565 -0.113299891006 -0.109545217359 -0.10510799573 -0.0998948475356 -0.0942068426537 -0.0880979429766 -0.0814374234606 -0.074131539204 -0.0662526863518 -0.0569932805821 -0.0576439980848 -0.0604427387759 0.119769707799 0.152527844773 0.0497215665564 0.0657160558915 0.0670327473486 0.0809162186997 0.0917181199329 0.0981839800693 0.104048754769 0.106504143786 0.107999881212 0.107641954082 0.106074240726 0.102940596974 0.098182005132 0.0916460339019 0.0835817441325 0.0748891003825 0.0679053610443 0.0671365638343 0.0713707283032 0.0626444791814 0.0449027103048 0.0425174731861 0.0387679388426 0.0347147669751 0.0309265141755 0.0273973226493 0.0241114379102 0.0210690068512 0.0185138294927 0.0165184714823 0.0149667474589 0.0137638597215 0.0128431757416 0.0121564706278 0.0116610127463 0.0113266212778 0.0111047277642 0.0110031107453 -0.128393838586 -0.128380053103 -0.128371631889 -0.128393356843 -0.128393557686 -0.128196818521 -0.128040075436 -0.127912990734 -0.127825682202 -0.127696429153 -0.127566233117 -0.127460365013 -0.127580214741 -0.127762878145 -0.127870221241 -0.127684437618 -0.127367561667 -0.127193701769 -0.127173694876 -0.127159177653 -0.127197389935 -0.126880340817 -0.126285609165 -0.125408098309 -0.124255611368 -0.122736501411 -0.120802622014 -0.118382465766 -0.115464677906 -0.112144102734 -0.108345651829 -0.103814446729 -0.0986565021707 -0.0930268051299 -0.086691102854 -0.0793858588276 -0.0709064931723 -0.0594436025848 -0.0601196262584 -0.0630123101753 0.11779810156 0.150556264895 0.0491158379385 0.0672009324219 0.0679681438614 0.0828936716155 0.0934201311772 0.100271357135 0.106261067744 0.108967789071 0.110732903242 0.110713416889 0.109526561985 0.106842113159 0.102588668115 0.0966778602861 0.0894745781212 0.082131472538 0.0770959794084 0.0797129541472 0.0887396713624 0.0768999794864 0.0341496636609 0.0456283029291 0.0429596962354 0.0390516551195 0.0348524480104 0.0308265507548 0.0270778267927 0.0236076544949 0.0206001103166 0.0182589227952 0.0164761780676 0.0151194325909 0.0140978345384 0.0133449147634 0.0128028988392 0.0124412466559 0.0122089579962 0.0120901265425 -0.128429998754 -0.128406542024 -0.128387559474 -0.128394851242 -0.128422358319 -0.128272158791 -0.12814415635 -0.128019853158 -0.127893427868 -0.12773843934 -0.127597156383 -0.127477293003 -0.127577948203 -0.127775543521 -0.127887562495 -0.12783764926 -0.127291398297 -0.127099244267 -0.127017044688 -0.127027653358 -0.127187921121 -0.127296488094 -0.127061955115 -0.126406619755 -0.125509688772 -0.124183689922 -0.12244612512 -0.120214104405 -0.117470927309 -0.11457331239 -0.111495014604 -0.107897299981 -0.1036361061 -0.0986622545544 -0.0929107824323 -0.0858930305242 -0.0769738017471 -0.0617304746516 -0.0615622905786 -0.0666987189762 0.111981347539 0.147856222652 0.0478335878102 0.0681642060685 0.0689704014058 0.0842066237183 0.0947391069973 0.101530953391 0.107820396062 0.110610535214 0.112823606718 0.11315822017 0.112581562005 0.110523033772 0.107127976295 0.102190902724 0.0963569203069 0.0910324542733 0.0892022169584 0.0933724441563 0.096576994217 0.0842111222119 0.0710446546757 0.0573409785034 0.049810367233 0.0438684122456 0.0386766634499 0.0339989322035 0.0297541135043 0.025882384682 0.0224584406671 0.0197566684952 0.0177341855339 0.0162200160316 0.0150928933488 0.0142763264218 0.0137000745833 0.0133145229364 0.0130717414028 0.0129390055608 -0.128483931357 -0.128461298483 -0.128411116538 -0.128407240006 -0.128438465241 -0.128345000926 -0.128256889498 -0.128157598418 -0.128034010079 -0.127871118478 -0.127624335751 -0.127486422812 -0.12756187419 -0.127752894409 -0.128053435282 -0.127535582197 -0.126845805414 -0.126829834838 -0.126720941103 -0.12682995955 -0.127247160804 -0.127526005601 -0.127894167132 -0.12716954601 -0.126582720758 -0.125451242166 -0.123917582383 -0.121892731075 -0.119115914153 -0.116570540185 -0.114286665631 -0.111753657847 -0.108859691195 -0.10518812186 -0.10045082694 -0.0947138679536 -0.0874644350151 -0.078220710388 -0.0618608773974 -0.103785525156 0.103710122714 0.141235681339 0.043322747231 0.0682176330904 0.0679102197435 0.0849510588654 0.0946089383334 0.102341462497 0.10849536532 0.111899880682 0.114322370287 0.11525366892 0.115129910585 0.113858456838 0.111345522896 0.107823670681 0.103903801209 0.101641004253 0.104862255417 0.114782851733 0.104352752097 0.0753150488239 0.0701812587276 0.0617707995301 0.0543003682935 0.0477660167471 0.0419432765304 0.0367287882432 0.0320453429809 0.0278226300283 0.0240418661002 0.021000564817 0.0187472570788 0.0170837384283 0.0158561916646 0.0149690999715 0.0143544650166 0.0139524538318 0.0137092142114 0.0135960724657 -0.128495079299 -0.128497114245 -0.128448412446 -0.128440687173 -0.12843838751 -0.128429251812 -0.128400046112 -0.128352252835 -0.128264679729 -0.128096533759 -0.127713180525 -0.127546633801 -0.127404839447 -0.127262312153 -0.127259484777 -0.127618194507 -0.127221858041 -0.12698870589 -0.126704696866 -0.126767354978 -0.126901934287 -0.126980824045 -0.127026573945 -0.127537459505 -0.128052725393 -0.126958191414 -0.125527967013 -0.123856970379 -0.120322214806 -0.117970824594 -0.116544555907 -0.114969207909 -0.113591173711 -0.111750918921 -0.109191629829 -0.105096469235 -0.100335725559 -0.0962249993363 -0.0947235368575 -0.117466271502 0.101578620928 0.132749594602 0.040208958103 0.0725637044926 0.0698078749501 0.0868826995724 0.0949867978047 0.102358103297 0.108189727762 0.111697094935 0.114467259464 0.116022171335 0.116765130155 0.116694790939 0.115763756361 0.114271133091 0.113041445405 0.113770634012 0.122969643576 0.146188781257 0.130999356151 0.0607257105849 0.070712342114 0.0650765372951 0.0579145783444 0.0509448827776 0.0445976081335 0.0389255169933 0.0338709165251 0.0293586600887 0.0252967159516 0.0219737603698 0.0195213939921 0.0177217673574 0.0164111832191 0.0154687532831 0.0148165708401 0.01439702593 0.0141551835846 0.0140638180813 -0.128502925992 -0.128500430762 -0.128487299459 -0.128481780555 -0.128459187754 -0.128549698665 -0.1286047326 -0.12865796591 -0.128700162946 -0.128696694967 -0.128530639464 -0.128023120466 -0.127406831797 -0.126486145333 -0.125427703984 -0.125107283451 -0.125981496089 -0.126391349959 -0.125995479028 -0.124933455409 -0.125356323013 -0.124973101725 -0.124378429835 -0.123688518127 -0.123472308486 -0.123181676826 -0.122262898327 -0.121775291322 -0.119244538411 -0.117026241444 -0.11662765737 -0.116173800211 -0.116344905517 -0.116674580101 -0.11704569684 -0.115849650205 -0.112036343273 -0.109730692546 -0.119412828875 -0.123364583315 0.144213361083 0.10774019408 0.0289048984241 0.0855553967156 0.0527926396637 0.0967534154626 0.0839776822364 0.108251209717 0.103346478602 0.115730386523 0.113099251024 0.119391582791 0.117194091039 0.120212567513 0.117963373327 0.120357057707 0.120646763797 0.131483636346 0.143238520766 0.184642608688 0.166783854985 0.123789781398 0.0791060064728 0.0712856835431 0.0616205876739 0.0535811128102 0.0465978017858 0.0405076805221 0.0351538159643 0.0304147811281 0.0261627206323 0.0226567877879 0.020057842779 0.0181515794584 0.0167731211544 0.015790071345 0.0151101542226 0.0146715577248 0.014418069209 0.0143203663962 -0.12849945203 -0.128495576911 -0.128613156677 -0.1286284959 -0.128658455168 -0.128725821729 -0.128790126511 -0.128852322827 -0.128910357626 -0.128957718758 -0.128976234691 -0.12893533746 -0.128815715198 -0.12880106808 -0.128459349754 -0.127768508684 -0.127722834381 -0.128687192925 -0.13060282418 -0.131027670257 -0.12853060028 -0.128211035155 -0.128321941439 -0.127935513397 -0.127298964323 -0.12703791003 -0.127277785869 -0.125616195787 -0.127047017666 -0.127537244759 -0.127693980389 -0.12775353848 -0.127850090284 -0.128286136166 -0.128891961916 -0.128340234645 -0.124427030593 -0.119727420102 -0.129990846567 -0.17229973379 0.176073969576 0.0562451512048 0.0593970633948 0.130932213846 0.0581185473245 0.126614063274 0.0779965396159 0.119303049488 0.0948986631547 0.117603907143 0.10661312935 0.120478729595 0.116098871294 0.126672447845 0.125924797872 0.137324293018 0.138105630728 0.156339017502 0.148141019038 0.193837958573 0.117942651521 0.0736972189239 0.076525912431 0.0765109555758 0.0639492947784 0.0551421466482 0.0477129924175 0.0413579445648 0.0358275843791 0.0309589441915 0.0265957260656 0.0230006688522 0.0203335213798 0.018369039292 0.0169484865333 0.0159416870737 0.015248836425 0.0147985624477 0.0145276296893 0.0144195229523 ) ; boundaryField { frontAndBack { type empty; } upperWall { type zeroGradient; } lowerWall { type zeroGradient; } inlet { type zeroGradient; } outlet { type adjointOutletPressurePower; value nonuniform List<scalar> 20 ( 0.0228879943341 0.105910425773 0.145255146469 0.17100389562 0.188735777057 0.199805286956 0.203769428426 0.202427182302 0.199522377769 0.195905674884 0.191662268844 0.186785018711 0.181262208717 0.175076294158 0.168195238815 0.16050108545 0.151948404478 0.14248551401 0.133955707432 0.106332344212 ) ; } } // ************************************************************************* //
[ "as998@snu.edu.in" ]
as998@snu.edu.in
c13e820d9e6c6118f5ac70d85eec42323c66fbda
07a399c8d3a6ff714584869a03ace090e30161e7
/MinimizingCoins.cpp
86174d318dcd694b56b2dadbef922fe008f8a681
[]
no_license
abxinth/CSES-PROBLEMSET
dee9245b8fb7ed8bba9c12ecea68f58a72be076e
a688d5535b1770b21b9d582c40bc3edfa0205789
refs/heads/main
2023-04-19T07:20:26.985781
2021-04-22T05:16:22
2021-04-22T05:16:22
309,242,184
1
0
null
null
null
null
UTF-8
C++
false
false
821
cpp
#include<iostream> #include<vector> using namespace std; #define INF 9999999 vector<long> coins; long val[1000001]; bool is_val[1000001]; bool f = false; long solve(long x){ long result = INF; if(x == 0){ f = true; return 0; } if(x<0){ return INF; } if(is_val[x])return val[x]; for(unsigned long i=0;i<coins.size();i++){ long temp = solve(x-coins[i]) + 1; if(temp<result){ result = temp; } } is_val[x] = true; val[x] = result; return result; } int main(){ long n,x,i,c; cin>>n>>x; for(i=0;i<n;i++){ cin>>c; coins.push_back(c); } long ans = solve(x); if(f){ cout<<ans; return 0; } cout<<-1; return 0; }
[ "noreply@github.com" ]
noreply@github.com
6ecab7bf9128abc4d11a8f13d1a1a53d35955c0a
26a3639a3c6a7d1b2dcae332d2436e708bc8bbfe
/source/scene/scene_rayColoring.cpp
693fa7f9916d1233fa32e7a4131943e072594322
[]
no_license
necipfazil/raytracer
fc0769b6daca0b2a58605cef6c308c4c57a9eaa8
c76ebc86c0d173157c27837cf559cd074bb6bc2a
refs/heads/master
2020-03-30T10:00:56.239386
2019-11-24T05:33:49
2019-11-24T05:33:49
151,102,066
5
0
null
null
null
null
UTF-8
C++
false
false
10,098
cpp
#include "../config.h" #include "../scene.hpp" #include "../geometry/headers/geometry.hpp" #include "../image/color.hpp" #include "../image/image.hpp" #include "../utility/concurrent_bag.hpp" #include "../utility/pixel_mission_generator.hpp" #include "../utility/random_number_generator.hpp" #include <forward_list> #include <cmath> Color Scene::getDiffuseColor(const Material & material, const HitInfo & hitInfo, const IncidentLight& incidentLight) const { if(incidentLight.inShadow) return Color::Black(); float normalDotLight = (hitInfo.normal ^ incidentLight.hitToLightDirection); if(normalDotLight < 0.f) normalDotLight = 0.f; Color diffuseColor = Color(material.getDiffuse().intensify(incidentLight.intensity) * normalDotLight); return diffuseColor; } Color Scene::getSpecular(const Ray & ray, const Material & material, const HitInfo & hitInfo, const IncidentLight& incidentLight) const { if(incidentLight.inShadow) return Color::Black(); Vector3 h = (( -ray.getDirection()) + incidentLight.hitToLightDirection ).normalize(); float max = hitInfo.normal ^ h; max = max < 0.0f ? 0.0f : max; max = pow(max, material.getPhongExponent()); Vector3 colorVector = material.getSpecular().intensify(incidentLight.intensity) * max; return Color(colorVector); } Color Scene::getAmbientColor(const Material & material, const Vector3 & ambientLight) const { return Color(ambientLight.intensify(material.getAmbient())); } Color Scene::getReflectionColor(const Ray & ray, const HitInfo & hitInfo, int recursionDepth) const { if(recursionDepth == 0) { return Color::Black(); } Ray reflectionRay = ray.createReflectionRay(hitInfo); // set time reflectionRay.setTimeCreated(ray.getTimeCreated()); return getRayColor(reflectionRay, recursionDepth - 1, true); } bool isRefracted(float refractionIndexRatio, float cosTheta) { float delta = 1 - pow(refractionIndexRatio, 2) * (1 - pow(cosTheta, 2)); return delta > 0.f; } Color Scene::getRefractionColor(const Ray & hittingRay, const HitInfo & hitInfo, int recursionDepth) const { if(recursionDepth == 0) { return Color::Black(); } Color color = Color::Black(); bool isEntering; float refractionIndexRatio; Vector3 normal; HitInfo reflectionRayHitInfo = hitInfo; // its normal will be manipulated // check if the ray is entering to or was already inside the refractive object // .. compute refractionIndexRatio and normal according to entering/exitting case float cosTheta = (-hittingRay.getDirection()) ^ hitInfo.normal; if(cosTheta >= 0.f) // entering { isEntering = true; refractionIndexRatio = AIR_REFRACTION_INDEX / hitInfo.material.getRefractionIndex(); normal = hitInfo.normal; } else // was already inside the refractive object { isEntering = false; refractionIndexRatio = hitInfo.material.getRefractionIndex() / AIR_REFRACTION_INDEX; normal = -hitInfo.normal; reflectionRayHitInfo.normal = - reflectionRayHitInfo.normal; } float theta = acos(cosTheta); float sinTheta = sin(theta); float sinPhi = refractionIndexRatio * sinTheta; float phi = asin(sinPhi); float cosPhi = cos(phi); // take abs of cosPhi and cosTheta since we are looking for the acute angle cosPhi = cosPhi < 0.f ? -cosPhi : cosPhi; cosTheta = cosTheta < 0.f ? -cosTheta : cosTheta; // compute R_0 float R_0 = pow( (hitInfo.material.getRefractionIndex() - AIR_REFRACTION_INDEX) / (hitInfo.material.getRefractionIndex() + AIR_REFRACTION_INDEX) , 2); // compute R_theta float R_theta = R_0 + (1 - R_0) * pow(1 - cosTheta, 5); if(!std::isnan(cosPhi) && cosPhi < cosTheta) { R_theta = R_0 + (1 - R_0) * pow(1 - cosPhi, 5); } // init refraction and reflection color as black Color refractionColor = Color::Black(); Color reflectionColor = Color::Black(); // create reflection ray Ray reflectionRay = hittingRay.createReflectionRay(reflectionRayHitInfo); // set time reflectionRay.setTimeCreated(hittingRay.getTimeCreated()); // get reflected ray's color reflectionColor = getRayColor(reflectionRay, recursionDepth - 1, false); if(isRefracted(refractionIndexRatio, cosTheta)) { // compute t, which is the direction of the refracted ray Vector3 t = ((hittingRay.getDirection() + (normal * cosTheta)) * refractionIndexRatio) - (normal * cosPhi); // create the refracted ray, origined at hit position(+epsilon) and directed as t Ray refractedRay = Ray(hitInfo.hitPosition, t).translateRayOrigin(shadowRayEpsilon); // set time refractedRay.setTimeCreated(hittingRay.getTimeCreated()); // set refracted ray's color refractionColor = getRayColor(refractedRay, recursionDepth - 1, false) .intensify(Vector3(1 - R_theta)); // intensify reflection color reflectionColor.intensify(Vector3(R_theta)); } if(!isEntering) { // if the ray was inside, attenuation should be applied to the color Vector3 attenuation = hitInfo.material.getTransparency().power(hitInfo.t); refractionColor.intensify(attenuation); reflectionColor.intensify(attenuation); } color += refractionColor; color += reflectionColor; return color; } Color Scene::getRayColor(const Ray & ray, int recursionDepth, bool backfaceCulling, bool onlyOpaque) const { if(recursionDepth == 0) return Color::Black(); HitInfo hitInfo; if( BVH && BVH->hit(ray, hitInfo, backfaceCulling, onlyOpaque) ) { if(hitInfo.isLight) return hitInfo.lightColor; Material & material = hitInfo.material; bool shapeIsFacing = (hitInfo.normal ^ ray.getDirection()) < 0; Color color(0.0f, 0.0f, 0.0f); // ambient, diffuse, specular and reflection - if shape is facing if(!backfaceCulling || shapeIsFacing) { if(hitInfo.textureInfo.hasTexture && hitInfo.textureInfo.decalMode == DecalMode::REPLACE_ALL) { return hitInfo.textureInfo.textureColor; } // ambient color += getAmbientColor(material, this->ambientLight); // direct lighting - diffuse and specular if(shapeIsFacing) { // traverse lights for(int i = 0; i < this->lights.size(); i++) { // get incident light IncidentLight incidentLight = lights[i]->getIncidentLight(*this, hitInfo, ray.getTimeCreated()); color += hitInfo.material.getBRDF().computeReflectedLight(ray, hitInfo, incidentLight); } } // indirect lighting - path tracing if(this->integrator != Integrator::DEFAULT && shapeIsFacing) { // decide the random factor RandomFactor randomFactor; switch(this->integrator) { case Integrator::UNIFORM_PATHTRACING: randomFactor = RandomFactor::UNIFORM; break; case Integrator::IMPORTANCE_PATHTRACING: randomFactor = RandomFactor::IMPORTANCE; break; } // generate random around normal Vector3 w_i = hitInfo.normal.generateRandomVectorWithinHemisphere(randomFactor); // create ray Ray sampleRay = Ray(hitInfo.hitPosition, w_i).translateRayOrigin(getShadowRayEpsilon()); // get color of sampled ray Color sampleColor = getRayColor(sampleRay, recursionDepth - 1, backfaceCulling, true); if(!sampleColor.isBlack()) { // create incident light IncidentLight incidentLight; incidentLight.intensity = sampleColor.getVector3(); incidentLight.inShadow = false; incidentLight.hitToLightDirection = w_i; // compute and add the color Color pathTracedColor = hitInfo.material.getBRDF().computeReflectedLight(sampleRay, hitInfo, incidentLight); // 1 / p(w) float _1_pw = 1.f; // divide by prop switch(this->integrator) { case Integrator::UNIFORM_PATHTRACING: _1_pw = 1 / SPHERE_UNIFORM_SAMPLING_PROP; break; case Integrator::IMPORTANCE_PATHTRACING: _1_pw = 1 / SPHERE_UNIFORM_SAMPLING_PROP; // TODO break; } color += pathTracedColor.intensify(_1_pw); } } // reflection // check if it has mirrorish material if(!material.getMirror().isZeroVector()) { if(recursionDepth) color += getReflectionColor(ray, hitInfo, recursionDepth).intensify(material.getMirror()); } } // refraction // check if the material has refractive character if(!material.getTransparency().isZeroVector()) { if(recursionDepth) { Color refractionColor = this->getRefractionColor(ray, hitInfo, recursionDepth); color += refractionColor; } } return color; } else { if(sphericalEnvLight) { return sphericalEnvLight->getColor(ray.getDirection()); } else return this->backgroundColor; } }
[ "fazilyildiran@gmail.com" ]
fazilyildiran@gmail.com
32e2fb5fd7bb88234c92880cfc295dad724818b2
b656dc19dcd1cbd76ef4d88c879e7f6fa2e885e4
/include/lirequest.h
8a4a994c8f087b655c808a25e9764a2d6f789c31
[]
no_license
setrunk/LiCore
53b19b6c82b1129d10679c9b33c87fb276e00b51
b372688732901bbb6fd45dc0b21b99f8be5e935f
refs/heads/master
2020-05-20T01:16:20.121067
2019-11-19T14:02:46
2019-11-19T14:02:46
185,304,772
1
2
null
null
null
null
UTF-8
C++
false
false
1,972
h
#ifndef LIREQUEST_H #define LIREQUEST_H #include "licore_global.h" #include "asyncfuture.h" #include "boundingvolume.h" #include <QNetworkRequest> class LiRequestPrivate; class RequestScheduler; typedef std::function<double(void)> PriorityFunction; class LICORE_EXPORT LiRequest { public: enum RequestState { UNISSUED = 0, ISSUED, ACTIVE, RECEIVED, CANCELLED, FAILED }; enum RequestType { TERRAIN = 0, IMAGERY, TILES3D, OTHER }; LiRequest(); LiRequest(const QNetworkRequest &request, PriorityFunction priorityFunc, RequestType type, bool throttleByServer = true, bool throttle = true, const QString &serverKey = QString()); LiRequest(const LiRequest &o); ~LiRequest(); LiRequest &operator =(const LiRequest &o); bool operator ==(const LiRequest &other) const; QNetworkRequest request() const; bool isNull() const; bool isValid() const; bool isUnissued() const; bool isActive() const; bool isCanceled() const; void cancel(); RequestState state() const; void setState(RequestState state); QUrl url() const; void setUrl(const QUrl &url); QString serverKey() const; void setServerKey(const QString &key); RequestType type() const; void setType(RequestType type); QVariantMap headers() const; void setHeader(const QVariantMap &headers); bool throttleByServer() const; bool throttle() const; double priority() const; void updatePriority(); QFuture<QByteArray> loadArrayBuffer(); QFuture<QImage> loadImage(bool mirrored = false); QFuture<QByteArray> promise() const; private: void create(); void received(const QByteArray &data); void failed(); QSharedPointer<LiRequestPrivate> d_ptr; friend class RequestScheduler; }; #endif // LIREQUEST_H
[ "setrunk@163.com" ]
setrunk@163.com
bc64b01061c027c10b264faa41ecb65bf2365fad
c5227c7cfcc6b6b57f2b68edeb80f9761cb60195
/tests/cpp_exception_handling.cpp
88c8f25c719ff9e89a50bfd43edc5f19f561e7db
[]
no_license
msyksphinz-self/myriscvx-tests
306fdaed844f2238c3499805e0eb7ead8bea4a5c
81aec87e3d6c7a6c9cbabc7b388ce15110b70aa0
refs/heads/master
2020-06-16T06:15:41.942801
2019-10-07T13:51:05
2019-10-07T13:51:05
195,499,118
0
0
null
null
null
null
UTF-8
C++
false
false
209
cpp
class Ex1 {}; void throw_exception(int a, int b) { Ex1 ex1; if (a > b) { throw ex1; } } int test_try_catch() { try { throw_exception(2, 1); } catch(...) { return 1; } return 0; }
[ "msyksphinz_dev@gmail.com" ]
msyksphinz_dev@gmail.com
963d8998a0883505ecc575653ca264847c8ef912
1148c88529bcc3809f033f74496b177b2ff1b675
/Algorithms/Insertion Sort/Insertion Sort.cpp
cf4257218c773634ba322dd856d10e2a99ce906f
[]
no_license
gmryu6617/Algorithms
5dc01478bce492de6fdc8c573e4c9c2599cddf43
ef0ed67f78f7e0039b23c6b2ef070acfca5ccf5f
refs/heads/master
2021-01-25T07:01:12.193216
2017-06-19T13:01:49
2017-06-19T13:01:49
93,639,007
0
0
null
null
null
null
UTF-8
C++
false
false
1,157
cpp
#include <iostream> #include <chrono> #include <memory> using namespace std; using namespace chrono; // 3. Insertion Sort // Time Complexity: theta(n ^ 2) // If the input array is sorted, 'Time Complexity' is theta(n). template <typename T> void InsertionSort(T* A, int n) { T newItem; int loc; for (int i = 0; i <= n - 1; ++i) { newItem = A[i]; loc = i - 1; while (loc >= 0 && newItem < A[loc]) { A[loc + 1] = A[loc]; loc--; } A[loc + 1] = newItem; } } const size_t ARRAY_SIZE = 100'000; int main() { shared_ptr<int> sp_intArray(new int[ARRAY_SIZE], [](int* ptr) { delete[] ptr; }); for (int i = 0; i <= ARRAY_SIZE - 1; ++i) sp_intArray.get()[i] = rand() % RAND_MAX; cout << "3. Insertion Sort" << endl; cout << "Start!" << endl; auto start = high_resolution_clock::now(); InsertionSort(sp_intArray.get(), ARRAY_SIZE); cout << "Finish!" << endl; auto finish = high_resolution_clock::now(); auto duration = finish - start; cout << "Elapsed Time: " << duration_cast<milliseconds>(duration).count() << "(ms)" << endl; for (int i = 0; i <= ARRAY_SIZE - 1; ++i) cout << sp_intArray.get()[i] << ", "; return 0; }
[ "gmryu6617@outlook.com" ]
gmryu6617@outlook.com
3d34ca1090eaa5578a6868099aab0e7fa1b98595
19e3a102f54f5ffdaad4ce6b7760473cb3dac782
/firewalker_mike.ino
61548a50a0ffa71752fc492fbade47efbab5f910
[]
no_license
mphun/custom_firewalkers
fb7fd49704d60c6728a559987286f762fbe437e5
b4f0e0eeed23246d0c3ff454fd2e222639aa44f2
refs/heads/master
2021-01-10T06:12:27.198677
2016-01-25T04:42:33
2016-01-25T04:42:33
50,326,501
0
0
null
null
null
null
UTF-8
C++
false
false
4,732
ino
#include <Adafruit_NeoPixel.h> const int analogInPin = A9; // Analog input pin that the potentiometer is attached to int lednum = 40; Adafruit_NeoPixel strip = Adafruit_NeoPixel(lednum, 6, NEO_GRB + NEO_KHZ800); int sensorValue = 0; // value read from the pot int choice = 0; int sensitivity = 100; void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); pinMode(9, INPUT_PULLUP); strip.begin(); strip.show(); // Initialize all pixels to 'off' } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // print the results to the serial monitor: Serial.print("sensor = " ); Serial.println(sensorValue); if (sensorValue < sensitivity){ Serial.println("leds triggered"); int red = random(255); int green = random(255); int blue = random(255); switch (choice % 6){ case 0: //colorWipe(strip.Color(255, 0, 0), 25); colorWipe(strip.Color(red, green, blue), 25); colorWipe(strip.Color(0, 0, 0), 25); break; case 1: colorOddEven(strip.Color(red, green, blue), 100, 15); clearLed(); break; case 2: colorDim(25); clearLed(); break; case 3: colorWipeBothWay(strip.Color(red, green, blue), 25); break; case 4: rainbow(5); clearLed(); break; case 5: rainbowCycle(1); clearLed(); break; } choice++; while (sensorValue < sensitivity) { sensorValue = analogRead(analogInPin); Serial.print("sensor = " ); Serial.println(sensorValue); delay(50); } } } void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, c); strip.show(); delay(wait); } } void colorWipeBothWay(uint32_t c, uint8_t wait) { for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, c); strip.show(); delay(wait); } for(int i=strip.numPixels(); i >= 0; i--) { strip.setPixelColor(i, strip.Color(0, 0, 0)); strip.show(); delay(wait); } } void colorOddEven(uint32_t c, uint8_t wait, uint8_t cycle){ uint32_t blank = strip.Color(0, 0, 0); for(uint16_t i=0; i<cycle; i++) { for(uint16_t j=0; j<strip.numPixels(); j++) { if ((j % 2) == (i % 2)){ strip.setPixelColor(j, c); } else{ strip.setPixelColor(j, blank); } } strip.show(); delay(wait); } } void colorDim(uint8_t wait) { float red = random(32); float green = random(32); float blue = random(32); float orig_red = red; float orig_green = green; float orig_blue = blue; while (true){ red = red + (red * 0.1); green = green + (green * 0.1); blue = blue + (blue * 0.1); if ( red > 255 || green > 255 || blue > 255 ){ break; } for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, strip.Color(red, green, blue)); } strip.show(); delay(wait); } while (true){ red = red - (red * 0.1); green = green - (green * 0.1); blue = blue - (blue * 0.1); if ( red < orig_red || green < orig_green || blue < orig_blue ){ break; } for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, strip.Color(red, green, blue)); } strip.show(); delay(wait); } } void clearLed(){ for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, strip.Color(0, 0, 0)); } strip.show(); delay(25); } void rainbow(uint8_t wait) { uint16_t i, j; for(j=0; j<256; j++) { for(i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, Wheel((i+j) & 255)); } strip.show(); delay(wait); } } // Slightly different, this makes the rainbow equally distributed throughout void rainbowCycle(uint8_t wait) { uint16_t i, j; //for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel for(j=0; j<256*2; j++) { // 5 cycles of all colors on wheel for(i=0; i< strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); } strip.show(); delay(wait); } } // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { if(WheelPos < 85) { return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } else if(WheelPos < 170) { WheelPos -= 85; return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } else { WheelPos -= 170; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } }
[ "mik3phun@gmail.com" ]
mik3phun@gmail.com
ff58b812dab829981902a0d8af9f97514475bf5f
4d77398fc24009f483f2b2abc028a135e09fc9eb
/Assignment4/Solid_convection/1.5/gradTx
0ce59b2d859db312e620c9dc64acc403827b04de
[]
permissive
Naveen-Surya/CFD-Lab-1
12c635b72c611d83080ed6dd316b1b0016f2f86f
c38b0bfe43c7135f4a10e744ea1ac6cf6e9d4a1a
refs/heads/master
2020-04-05T16:43:39.651232
2018-08-23T12:10:06
2018-08-23T12:10:06
157,026,052
0
1
MIT
2018-11-10T22:11:51
2018-11-10T22:11:51
null
UTF-8
C++
false
false
63,021
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 5.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "1.5"; object gradTx; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 -1 0 1 0 0 0]; internalField nonuniform List<scalar> 6300 ( -29.3533 -29.4211 -29.5559 -29.7566 -30.0209 -30.3459 -30.7276 -31.1608 -31.6393 -32.1555 -32.7006 -33.2649 -33.8379 -34.4093 -34.9691 -29.2856 -29.354 -29.4902 -29.693 -29.9602 -30.2892 -30.676 -31.1156 -31.6017 -32.1266 -32.6815 -33.2561 -33.8396 -34.421 -34.9894 -29.1494 -29.2191 -29.3579 -29.5648 -29.8379 -30.1748 -30.5717 -31.0239 -31.5252 -32.0679 -32.6425 -33.2385 -33.8436 -34.4455 -35.032 -28.9437 -29.0151 -29.1576 -29.3704 -29.652 -30.0003 -30.4121 -30.8831 -31.4074 -31.9771 -32.5825 -33.2116 -33.8509 -34.4855 -35.1006 -28.6665 -28.7401 -28.8871 -29.1072 -29.3994 -29.7622 -30.1934 -30.6892 -31.2441 -31.8507 -32.4986 -33.1747 -33.8629 -34.545 -35.2021 -28.3156 -28.3916 -28.5437 -28.7719 -29.0761 -29.4559 -29.9101 -30.436 -31.0294 -31.6831 -32.3866 -33.1256 -33.881 -34.6297 -35.3461 -27.8889 -27.9671 -28.1241 -28.3605 -28.6773 -29.0753 -29.555 -30.1155 -30.7542 -31.4655 -32.2394 -33.0602 -33.9057 -34.7465 -35.5473 -27.3839 -27.464 -27.6251 -27.8688 -28.1972 -28.6131 -29.119 -29.7168 -30.4066 -31.1854 -32.0451 -32.9701 -33.9352 -34.9035 -35.8258 -26.7988 -26.8799 -27.0436 -27.2922 -27.6298 -28.0609 -28.5912 -29.2261 -29.9701 -30.8245 -31.7855 -32.84 -33.9617 -35.1065 -36.2079 -26.1325 -26.2134 -26.377 -26.6269 -26.9687 -27.4096 -27.9588 -28.6264 -29.423 -30.3572 -31.4324 -32.6425 -33.965 -35.353 -36.7239 -25.3853 -25.4642 -25.6241 -25.8698 -26.2085 -26.6501 -27.2079 -27.8978 -28.7384 -29.7487 -30.9446 -32.3328 -33.9027 -35.6168 -37.3936 -24.5594 -24.6339 -24.7855 -25.0198 -25.3452 -25.7745 -26.3248 -27.0186 -27.8842 -28.9547 -30.2644 -31.8412 -33.6962 -35.8175 -38.1778 -23.6589 -23.7265 -23.8644 -24.0785 -24.3782 -24.778 -25.2982 -25.9675 -26.825 -27.9214 -29.3169 -31.0714 -33.2232 -35.7793 -38.8259 -22.6909 -22.7487 -22.8671 -23.0515 -23.3113 -23.661 -24.1225 -24.7283 -25.527 -26.5889 -28.0104 -29.9041 -32.346 -35.2507 -38.4723 -21.665 -21.7105 -21.8037 -21.9491 -22.1545 -22.4323 -22.8024 -23.2963 -23.9658 -24.8967 -26.2312 -28.1885 -31.0063 -34.4069 -34.9654 -35.4655 -35.8966 -36.3062 -36.6926 -37.0552 -37.3937 -37.7089 -38.0011 -38.2709 -38.518 -38.7422 -38.9427 -39.1186 -39.2692 -39.3948 -39.4961 -39.575 -39.6343 -39.6776 -39.7089 -39.7321 -39.7508 -39.7677 -39.7843 -39.8011 -39.8173 -39.8316 -39.8421 -39.8468 -39.8444 -39.8342 -39.8165 -39.7926 -39.7647 -39.7354 -39.7072 -39.6826 -39.6632 -39.6495 -39.6412 -39.6369 -39.6345 -39.6315 -39.6257 -39.6151 -39.5986 -39.5764 -39.5494 -39.5194 -39.4887 -39.4598 -39.4347 -39.4149 -39.4008 -39.3918 -39.3863 -39.3821 -39.3767 -39.3675 -39.3527 -39.3311 -39.3025 -39.268 -39.2293 -39.1886 -39.1485 -39.1109 -39.0774 -39.0485 -39.0238 -39.002 -38.9812 -38.9594 -38.9347 -38.906 -38.8734 -38.8379 -38.8022 -38.7699 -38.7452 -38.7327 -38.7369 -38.7611 -38.8075 -38.8766 -38.9667 -39.0747 -39.1952 -39.3219 -39.4475 -35.4922 -35.9274 -36.3396 -36.7271 -37.0896 -37.4276 -37.7419 -38.0336 -38.3034 -38.5512 -38.7765 -38.9781 -39.1548 -39.3055 -39.4298 -39.5284 -39.6032 -39.6574 -39.6949 -39.7205 -39.7387 -39.7536 -39.7681 -39.7841 -39.8018 -39.8202 -39.8372 -39.8504 -39.8572 -39.8557 -39.845 -39.8254 -39.7985 -39.7669 -39.7337 -39.7022 -39.6752 -39.6549 -39.6418 -39.6355 -39.6342 -39.6354 -39.6358 -39.6326 -39.6234 -39.607 -39.5834 -39.5537 -39.5204 -39.4862 -39.4543 -39.4272 -39.4068 -39.3935 -39.3867 -39.3844 -39.384 -39.3821 -39.3757 -39.3625 -39.341 -39.3111 -39.2741 -39.232 -39.1879 -39.1447 -39.1051 -39.0708 -39.0425 -39.0196 -39.0005 -38.9826 -38.9634 -38.9403 -38.9117 -38.8773 -38.8383 -38.7974 -38.7588 -38.7274 -38.7088 -38.7079 -38.7291 -38.7749 -38.846 -38.9411 -39.0564 -39.1862 -39.3233 -39.4596 -35.548 -35.9915 -36.4085 -36.7978 -37.1596 -37.4954 -37.8075 -38.0978 -38.3675 -38.6169 -38.8449 -39.0496 -39.2286 -39.3798 -39.5019 -39.595 -39.6613 -39.7044 -39.7296 -39.7428 -39.7502 -39.7568 -39.7666 -39.7816 -39.8017 -39.8251 -39.8485 -39.8679 -39.8795 -39.8803 -39.8687 -39.845 -39.8114 -39.7714 -39.7296 -39.6906 -39.6585 -39.6362 -39.6245 -39.6227 -39.6282 -39.6372 -39.6453 -39.6481 -39.6423 -39.626 -39.5991 -39.5635 -39.5226 -39.4805 -39.4418 -39.4102 -39.3883 -39.3769 -39.3751 -39.38 -39.3878 -39.3939 -39.3939 -39.3842 -39.363 -39.3301 -39.2873 -39.2378 -39.1858 -39.1358 -39.0915 -39.0555 -39.0286 -39.0099 -38.997 -38.9861 -38.973 -38.9538 -38.9257 -38.8879 -38.8412 -38.7892 -38.7371 -38.6913 -38.6591 -38.6472 -38.6615 -38.7056 -38.781 -38.8862 -39.0171 -39.1667 -39.326 -39.4847 -35.6376 -36.0938 -36.5175 -36.908 -37.2668 -37.5976 -37.9046 -38.1915 -38.461 -38.7133 -38.9469 -39.1581 -39.3426 -39.4961 -39.6156 -39.7005 -39.7527 -39.7774 -39.7816 -39.7738 -39.7626 -39.7555 -39.7577 -39.7717 -39.7969 -39.83 -39.8655 -39.8968 -39.9176 -39.9228 -39.9099 -39.879 -39.8334 -39.7786 -39.7214 -39.6692 -39.628 -39.6021 -39.593 -39.5994 -39.6172 -39.6406 -39.6625 -39.6762 -39.6764 -39.6601 -39.6274 -39.581 -39.5264 -39.4701 -39.4191 -39.3793 -39.3547 -39.3467 -39.3537 -39.3715 -39.3942 -39.4146 -39.4258 -39.4226 -39.4018 -39.3633 -39.31 -39.247 -39.181 -39.1187 -39.066 -39.0269 -39.0028 -38.992 -38.9906 -38.9926 -38.9912 -38.9799 -38.9539 -38.9109 -38.8519 -38.7812 -38.706 -38.6356 -38.58 -38.5489 -38.5507 -38.5912 -38.6728 -38.7944 -38.9508 -39.1331 -39.3293 -39.5255 -35.7692 -36.243 -36.6745 -37.0637 -37.4146 -37.7342 -38.0305 -38.3106 -38.5791 -38.8369 -39.081 -39.3052 -39.5013 -39.6614 -39.7794 -39.8528 -39.884 -39.8798 -39.8508 -39.8097 -39.7694 -39.7409 -39.7319 -39.7458 -39.781 -39.8316 -39.8885 -39.9409 -39.978 -39.9916 -39.977 -39.9344 -39.8688 -39.7891 -39.7063 -39.6319 -39.5755 -39.5439 -39.5393 -39.5596 -39.5984 -39.6461 -39.6915 -39.7237 -39.7342 -39.718 -39.6753 -39.6106 -39.5326 -39.4521 -39.3803 -39.3266 -39.2973 -39.2948 -39.3166 -39.3562 -39.4038 -39.4483 -39.4787 -39.4862 -39.466 -39.418 -39.3467 -39.2607 -39.1707 -39.0876 -39.0209 -38.9769 -38.9576 -38.9606 -38.9793 -39.004 -39.0236 -39.0272 -39.0064 -38.9569 -38.8792 -38.7795 -38.6681 -38.5585 -38.4654 -38.4032 -38.3842 -38.4173 -38.5069 -38.6523 -38.8471 -39.0793 -39.3323 -39.5864 -35.9559 -36.4532 -36.8924 -37.2746 -37.6076 -37.9043 -38.1796 -38.4464 -38.7128 -38.9804 -39.244 -39.4926 -39.7119 -39.8873 -40.0073 -40.0662 -40.0664 -40.018 -39.9375 -39.8446 -39.7592 -39.6982 -39.6734 -39.6892 -39.7428 -39.8242 -39.9182 -40.0069 -40.0726 -40.1011 -40.0845 -40.023 -39.9247 -39.8041 -39.6793 -39.5686 -39.4876 -39.4467 -39.4499 -39.4933 -39.5668 -39.655 -39.7395 -39.8028 -39.8304 -39.8144 -39.7547 -39.6594 -39.5425 -39.4218 -39.3154 -39.2386 -39.2016 -39.2079 -39.254 -39.3292 -39.4181 -39.5025 -39.5645 -39.5898 -39.5704 -39.506 -39.4046 -39.2802 -39.1503 -39.0329 -38.9432 -38.8911 -38.8802 -38.9064 -38.9592 -39.0229 -39.079 -39.1096 -39.1003 -39.0432 -38.9384 -38.7946 -38.6276 -38.4574 -38.3062 -38.1952 -38.1426 -38.162 -38.2607 -38.4391 -38.6894 -38.9956 -39.3336 -39.6747 -36.2179 -36.7471 -37.1926 -37.5563 -37.8527 -38.1055 -38.3412 -38.5828 -38.8447 -39.1297 -39.4286 -39.7223 -39.9859 -40.1932 -40.3231 -40.3642 -40.3188 -40.2027 -40.0421 -39.8687 -39.7137 -39.6037 -39.5564 -39.5784 -39.6646 -39.7986 -39.9557 -40.1062 -40.2208 -40.2755 -40.2567 -40.1645 -40.0127 -39.8253 -39.6321 -39.4626 -39.3418 -39.2864 -39.3024 -39.3839 -39.5143 -39.669 -39.8184 -39.9332 -39.9894 -39.9736 -39.8857 -39.7392 -39.5579 -39.3711 -39.2079 -39.0933 -39.0434 -39.064 -39.1493 -39.2825 -39.4388 -39.5888 -39.7032 -39.7579 -39.7393 -39.6475 -39.4956 -39.3074 -39.112 -38.9384 -38.8111 -38.7462 -38.7493 -38.814 -38.9235 -39.0524 -39.171 -39.2494 -39.2631 -39.1979 -39.0535 -38.8432 -38.5913 -38.329 -38.0891 -37.9031 -37.7974 -37.7922 -37.8995 -38.1221 -38.4513 -38.8657 -39.3306 -39.802 -36.5864 -37.1616 -37.6104 -37.9348 -38.1609 -38.3314 -38.4941 -38.6899 -38.9435 -39.2591 -39.6206 -39.9955 -40.3408 -40.6108 -40.7668 -40.7868 -40.673 -40.4513 -40.1654 -39.8663 -39.6036 -39.4189 -39.3394 -39.3754 -39.5177 -39.74 -40.0025 -40.2573 -40.4554 -40.5558 -40.5347 -40.3921 -40.1519 -39.8552 -39.5508 -39.2864 -39.1019 -39.0235 -39.0606 -39.2039 -39.4271 -39.6907 -39.9471 -40.1479 -40.2523 -40.2367 -40.1011 -39.8691 -39.5814 -39.2862 -39.0308 -38.8546 -38.7837 -38.8271 -38.9755 -39.2026 -39.4688 -39.7266 -39.9277 -40.0314 -40.0139 -39.8753 -39.6389 -39.3452 -39.0422 -38.7772 -38.589 -38.5035 -38.5294 -38.657 -38.8596 -39.0969 -39.3209 -39.4823 -39.5392 -39.4668 -39.2635 -38.9514 -38.5702 -38.1681 -37.7945 -37.495 -37.3073 -37.2602 -37.3724 -37.6514 -38.0906 -38.6628 -39.318 -39.9871 -37.109 -37.7583 -38.2075 -38.4551 -38.549 -38.5684 -38.5995 -38.7139 -38.9531 -39.3225 -39.7935 -40.3114 -40.8041 -41.1927 -41.4064 -41.4024 -41.1823 -40.7927 -40.3079 -39.8114 -39.3815 -39.0824 -38.9565 -39.0192 -39.2556 -39.6236 -40.0606 -40.49 -40.8308 -41.0113 -40.9878 -40.7602 -40.3725 -39.8962 -39.4118 -38.9954 -38.7092 -38.5944 -38.666 -38.9089 -39.2819 -39.7228 -40.156 -40.5014 -40.6881 -40.6728 -40.4554 -40.0794 -39.6156 -39.1439 -38.7397 -38.4645 -38.3595 -38.4391 -38.6885 -39.0663 -39.5107 -39.9461 -40.2926 -40.4794 -40.4631 -40.2438 -39.8646 -39.3961 -38.918 -38.5052 -38.2191 -38.1003 -38.1631 -38.3922 -38.7455 -39.1606 -39.5609 -39.8654 -40.0017 -39.9241 -39.6299 -39.1592 -38.579 -37.9658 -37.3933 -36.9258 -36.6148 -36.4988 -36.6047 -36.9502 -37.5381 -38.3403 -39.2854 -40.2615 -37.8577 -38.6433 -39.0948 -39.197 -39.0445 -38.7885 -38.5851 -38.5579 -38.7754 -39.2396 -39.8988 -40.6637 -41.4176 -42.0263 -42.3596 -42.329 -41.936 -41.2712 -40.4672 -39.6605 -38.9713 -38.4965 -38.3021 -38.4131 -38.8038 -39.4081 -40.1297 -40.8504 -41.4369 -41.7607 -41.7347 -41.359 -40.721 -39.9488 -39.1752 -38.5172 -38.0695 -37.8971 -38.0246 -38.4268 -39.0389 -39.766 -40.4914 -41.0835 -41.415 -41.3999 -41.0381 -40.4162 -39.6613 -38.9047 -38.2627 -37.8295 -37.6693 -37.8066 -38.2166 -38.8344 -39.5655 -40.2936 -40.8873 -41.2198 -41.2048 -40.8424 -40.2189 -39.461 -38.6996 -38.0508 -37.6081 -37.4356 -37.5575 -37.9482 -38.5425 -39.2453 -39.939 -40.4908 -40.7719 -40.6931 -40.2505 -39.5247 -38.6352 -37.7049 -36.8409 -36.131 -35.6414 -35.418 -35.4917 -35.8998 -36.6772 -37.8118 -39.2079 -40.678 -38.9356 -40.0094 -40.4854 -40.306 -39.689 -38.933 -38.3172 -38.0495 -38.2426 -38.8756 -39.8522 -41.0318 -42.24 -43.2567 -43.8367 -43.7778 -43.081 -41.9502 -40.6305 -39.3405 -38.2524 -37.5069 -37.2081 -37.4042 -38.0447 -39.0236 -40.2003 -41.4041 -42.4215 -43.014 -42.9853 -42.3357 -41.2625 -40.0037 -38.772 -37.736 -37.0337 -36.7681 -36.9875 -37.6428 -38.6303 -39.8117 -41.0189 -42.0407 -42.6413 -42.6262 -41.9955 -40.9446 -39.7093 -38.5005 -37.4853 -36.8013 -36.5506 -36.7816 -37.4455 -38.4391 -39.6247 -40.8347 -41.8584 -42.4604 -42.4466 -41.8172 -40.7668 -39.5307 -38.3193 -37.2994 -36.608 -36.3471 -36.5645 -37.2111 -38.1834 -39.3429 -40.5211 -41.506 -42.0601 -41.9861 -41.2789 -40.1255 -38.7503 -37.3482 -36.0666 -35.0187 -34.2847 -33.9091 -33.8971 -34.3176 -35.3016 -36.9067 -39.0235 -41.3308 -40.4621 -42.2363 -42.8198 -42.0453 -40.5342 -38.8761 -37.5482 -36.8774 -37.0766 -38.0169 -39.5131 -41.359 -43.3382 -45.1162 -46.2337 -46.1451 -44.8513 -42.9012 -40.7513 -38.7297 -37.0404 -35.8742 -35.4012 -35.7556 -36.7981 -38.3545 -40.2318 -42.2266 -44.0178 -45.162 -45.13 -43.9226 -42.0714 -40.0198 -38.0872 -36.4742 -35.3692 -34.9409 -35.323 -36.3803 -37.9425 -39.8204 -41.8135 -43.6045 -44.7545 -44.7388 -43.5581 -41.7386 -39.7194 -37.8173 -36.2313 -35.1489 -34.7385 -35.1334 -36.1995 -37.7674 -39.6489 -41.6442 -43.4365 -44.588 -44.5749 -43.398 -41.582 -39.5651 -37.6631 -36.075 -34.9878 -34.5696 -34.9535 -36.005 -37.5546 -39.4136 -41.3817 -43.1413 -44.253 -44.1906 -42.9497 -41.0459 -38.9037 -36.8181 -34.9558 -33.4542 -32.4117 -31.8765 -31.6797 -31.924 -33.0314 -35.2648 -38.5649 -42.3965 -42.429 -46.1775 -47.1096 -44.8454 -41.5915 -38.3445 -35.8333 -34.4528 -34.8432 -36.3576 -38.6706 -41.4943 -44.7262 -47.9267 -50.3678 -50.2478 -47.5667 -44.1398 -40.6875 -37.6403 -35.0751 -33.2435 -32.4031 -33.1161 -34.8118 -37.2232 -40.0943 -43.3423 -46.5457 -49.004 -48.9672 -46.4367 -43.1691 -39.8644 -36.9423 -34.481 -32.7301 -31.9467 -32.6864 -34.3908 -36.8001 -39.6631 -42.8994 -46.0916 -48.5463 -48.529 -46.0408 -42.8203 -39.5611 -36.6788 -34.252 -32.529 -31.7667 -32.5189 -34.2308 -36.6442 -39.5092 -42.7459 -45.9376 -48.3924 -48.3793 -45.8992 -42.6866 -39.4337 -36.5551 -34.1293 -32.4044 -31.6372 -32.3811 -34.0814 -36.4801 -39.3272 -42.5425 -45.7094 -48.1362 -48.0922 -45.5751 -42.3093 -38.9755 -35.9662 -33.3255 -31.2286 -29.8083 -29.3562 -28.8273 -28.2874 -29.1396 -32.0869 -37.3406 -44.2324 -43.8585 -54.1741 -56.0002 -49.0698 -42.6395 -36.7541 -32.4905 -29.4784 -30.9913 -33.5485 -37.0926 -41.0421 -46.1592 -51.8309 -58.1901 -58.0388 -51.3559 -45.4153 -40.0404 -35.8571 -32.0532 -29.1855 -27.1682 -29.0614 -31.7951 -35.4298 -39.4142 -44.5224 -50.1467 -56.4389 -56.3955 -50.0125 -44.3202 -39.1585 -35.1336 -31.4651 -28.6981 -26.7592 -28.6605 -31.3866 -35.0043 -38.9685 -44.0487 -49.6408 -55.8978 -55.8774 -49.5781 -43.9577 -38.8602 -34.8846 -31.2594 -28.5257 -26.6138 -28.5227 -31.2519 -34.8706 -38.8344 -43.9124 -49.4999 -55.7507 -55.7359 -49.4551 -43.8493 -38.7634 -34.7949 -31.1742 -28.4418 -26.5286 -28.4315 -31.1522 -34.7598 -38.7105 -43.7728 -49.3434 -55.5773 -55.5549 -49.2785 -43.6704 -38.5799 -34.5836 -30.912 -28.0286 -25.8104 -26.9466 -25.9906 -22.6459 -22.2307 -25.5878 -33.7571 -47.6091 -38.0949 -74.397 -77.4923 -52.567 -42.9022 -32.8293 -27.3457 -17.9884 -25.6357 -29.318 -34.931 -38.9084 -46.794 -54.745 -75.3875 -75.2353 -54.0762 -45.8763 -37.6777 -33.5273 -27.6835 -23.9032 -16.302 -23.7965 -27.481 -33.1331 -37.1158 -44.9594 -52.7863 -72.9969 -72.9531 -52.5939 -44.7072 -36.8155 -32.812 -27.1509 -23.4739 -16.0417 -23.4472 -27.0985 -32.7097 -36.6669 -44.461 -52.2326 -72.289 -72.2676 -52.1378 -44.3423 -36.5438 -32.5857 -26.9832 -23.339 -15.9591 -23.3455 -26.992 -32.6 -36.5553 -44.3453 -52.1072 -72.1313 -72.1159 -52.0389 -44.2635 -36.4839 -32.5339 -26.94 -23.2994 -15.9249 -23.3044 -26.9457 -32.5452 -36.4932 -44.2709 -52.0221 -72.0271 -72.0235 -52.0193 -44.2862 -36.6085 -32.7334 -27.3632 -23.8707 -16.9823 -27.5497 -26.5936 -12.7861 -9.88977 -12.1591 -21.9906 -54.1934 -39.5751 -39.6929 -39.7789 -39.8273 -39.8363 -39.808 -39.7477 -39.6627 -39.5619 -39.4546 -39.3497 -39.2554 -39.1785 -39.1242 -39.0961 -39.5977 -39.7247 -39.8164 -39.8665 -39.8735 -39.8401 -39.7722 -39.6784 -39.5684 -39.4521 -39.3391 -39.238 -39.1557 -39.0978 -39.0679 -39.6453 -39.7918 -39.8953 -39.9488 -39.9511 -39.9064 -39.8226 -39.7102 -39.5809 -39.4461 -39.3166 -39.2015 -39.1085 -39.0433 -39.0098 -39.7235 -39.9019 -40.0241 -40.082 -40.0756 -40.0116 -39.9014 -39.759 -39.5988 -39.4348 -39.2794 -39.1428 -39.0334 -38.9571 -38.918 -39.8417 -40.068 -40.2171 -40.2796 -40.2577 -40.1629 -40.0124 -39.8253 -39.6204 -39.4149 -39.2232 -39.057 -38.9249 -38.8336 -38.7869 -40.0152 -40.3113 -40.4968 -40.5613 -40.5124 -40.3699 -40.1599 -39.9091 -39.6426 -39.3811 -39.1416 -38.9367 -38.7758 -38.6653 -38.6091 -40.2691 -40.6651 -40.8972 -40.9563 -40.8606 -40.6445 -40.3479 -40.0088 -39.6595 -39.3253 -39.0251 -38.7723 -38.5762 -38.4425 -38.3749 -40.6439 -41.1826 -41.4706 -41.506 -41.329 -40.9994 -40.5783 -40.1186 -39.6611 -39.2353 -38.861 -38.5513 -38.3139 -38.1536 -38.073 -41.2083 -41.9505 -42.2966 -42.2681 -41.95 -41.4456 -40.8472 -40.226 -39.631 -39.0936 -38.6324 -38.2577 -37.9745 -37.785 -37.6902 -42.0829 -43.1146 -43.4972 -43.3194 -42.7573 -41.9856 -41.1389 -40.307 -39.5432 -38.8756 -38.3173 -37.8725 -37.5411 -37.3217 -37.2126 -43.4927 -44.9276 -45.258 -44.755 -43.7742 -42.6004 -41.4158 -40.32 -39.3589 -38.5483 -37.8885 -37.3736 -36.9958 -36.7481 -36.6256 -45.8917 -47.845 -47.8522 -46.6682 -44.9839 -43.2258 -41.6037 -40.198 -39.0241 -38.07 -37.3148 -36.7375 -36.3201 -36.0493 -35.916 -50.2932 -52.7084 -51.6374 -49.0817 -46.2671 -43.715 -41.5752 -39.8441 -38.4695 -37.3927 -36.5632 -35.9413 -35.4978 -35.2127 -35.0731 -59.2649 -61.058 -56.9071 -51.754 -47.2877 -43.7919 -41.1379 -39.1336 -37.6168 -36.468 -35.6038 -34.9665 -34.5172 -34.2303 -34.0905 -80.3924 -75.3512 -63.1788 -53.7394 -47.3376 -43.0268 -40.0509 -37.9356 -36.3958 -35.2588 -34.4174 -33.8036 -33.3739 -33.1008 -32.9681 -20.6828 -20.7152 -20.7811 -20.8837 -21.0277 -21.2215 -21.4787 -21.8226 -22.2949 -22.9755 -24.0293 -25.827 -29.2457 -36.2437 -48.8867 -19.7675 -19.7869 -19.8262 -19.8862 -19.9688 -20.0768 -20.2153 -20.3938 -20.6313 -20.9693 -21.5109 -22.5551 -25.1627 -33.9832 -73.3822 -18.8387 -18.8449 -18.8568 -18.8732 -18.8922 -18.9108 -18.924 -18.9239 -18.8977 -18.8216 -18.6431 -18.1982 -16.7704 -10.4714 24.3076 -17.9056 -17.8989 -17.8842 -17.8583 -17.816 -17.7486 -17.6419 -17.4723 -17.1986 -16.7448 -15.9601 -14.5245 -11.7648 -6.74028 -3.40043 -16.9772 -16.9586 -16.9193 -16.8549 -16.7573 -16.6138 -16.4036 -16.0929 -15.6244 -14.8975 -13.7285 -11.77 -8.33275 -1.84208 13.3671 -16.0616 -16.0326 -15.972 -15.8744 -15.7304 -15.5252 -15.2351 -14.8232 -14.2297 -13.3569 -12.045 -10.0419 -7.02099 -2.99853 -1.45804 -15.1662 -15.1285 -15.0504 -14.9262 -14.7462 -14.4954 -14.1513 -13.6796 -13.0289 -12.1213 -10.8413 -9.02057 -6.40468 -2.43142 5.53699 -14.2969 -14.2524 -14.1608 -14.0166 -13.811 -13.5305 -13.1561 -12.6605 -12.0064 -11.1442 -10.013 -8.55132 -6.73096 -4.63876 -2.68528 -13.4586 -13.4091 -13.3077 -13.1498 -12.9278 -12.6309 -12.2449 -11.7514 -11.1285 -10.354 -9.41421 -8.33111 -7.246 -6.74979 -9.55098 -12.6547 -12.6017 -12.4939 -12.3275 -12.0965 -11.7933 -11.4085 -10.9321 -10.3559 -9.6785 -8.91495 -8.11227 -7.35207 -6.57095 -3.90543 -11.8875 -11.8324 -11.7209 -11.5499 -11.3154 -11.0123 -10.6356 -10.1821 -9.65366 -9.06283 -8.44286 -7.86394 -7.47268 -7.70083 -10.8654 -11.1585 -11.1024 -10.9891 -10.8165 -10.5819 -10.2823 -9.91601 -9.48422 -8.9947 -8.4674 -7.94226 -7.48527 -7.16312 -6.79166 -4.09284 -10.4685 -10.4121 -10.2985 -10.1262 -9.89341 -9.59868 -9.24191 -8.82638 -8.36198 -7.87046 -7.39432 -7.01294 -6.88781 -7.4988 -11.3763 -9.81759 -9.76145 -9.64855 -9.47782 -9.24798 -8.95812 -8.60859 -8.20248 -7.74806 -7.26283 -6.78055 -6.36267 -6.10128 -5.93767 -3.69659 -9.20568 -9.15022 -9.03879 -8.87049 -8.64421 -8.35899 -8.01455 -7.61211 -7.15552 -6.65314 -6.12205 -5.60371 -5.24683 -5.81939 -12.1165 -8.63227 -8.57784 -8.46851 -8.30342 -8.08136 -7.80096 -7.46077 -7.05933 -6.59476 -6.06338 -5.45468 -4.73259 -3.74692 -1.72587 5.99997 -8.09664 -8.04355 -7.93694 -7.77587 -7.559 -7.28442 -6.94951 -6.55036 -6.08038 -5.52727 -4.86602 -4.04451 -2.96601 -1.59427 -1.42795 -7.59784 -7.54643 -7.44315 -7.28707 -7.07668 -6.80975 -6.48284 -6.09054 -5.62371 -5.06624 -4.38863 -3.53485 -2.38869 -0.625823 3.32147 -7.13473 -7.0853 -6.986 -6.83594 -6.63362 -6.3767 -6.06157 -5.68245 -5.22995 -4.68862 -4.03356 -3.22821 -2.23961 -1.17465 -1.24988 -6.70592 -6.65876 -6.56408 -6.42108 -6.22844 -5.98406 -5.6847 -5.32528 -4.89784 -4.38996 -3.78281 -3.04878 -2.14352 -0.931991 1.46986 -6.30982 -6.26521 -6.17569 -6.04067 -5.85915 -5.62956 -5.3495 -5.01533 -4.62157 -4.16021 -3.62013 -2.98823 -2.26008 -1.51629 -1.48592 -5.94468 -5.9028 -5.81886 -5.69252 -5.52322 -5.31008 -5.05185 -4.74673 -4.39222 -3.98507 -3.52118 -2.99448 -2.38744 -1.60552 -0.0500945 -5.6086 -5.56956 -5.49144 -5.37418 -5.21769 -5.02189 -4.78674 -4.51238 -4.19938 -3.84931 -3.46581 -3.0565 -2.63619 -2.23228 -1.90479 -5.2996 -5.26343 -5.19117 -5.08305 -4.93943 -4.76098 -4.54882 -4.30482 -4.03225 -3.73674 -3.42832 -3.12612 -2.87351 -2.80635 -3.53217 -5.01568 -4.98231 -4.91578 -4.81652 -4.68532 -4.52346 -4.33296 -4.11708 -3.88102 -3.63308 -3.38647 -3.16127 -2.98198 -2.83013 -2.24706 -4.7549 -4.7242 -4.66307 -4.57214 -4.45247 -4.30578 -4.13469 -3.94331 -3.73799 -3.52848 -3.32971 -3.1645 -3.07136 -3.15378 -3.97375 -4.51541 -4.48717 -4.43101 -4.34767 -4.23836 -4.10499 -3.95047 -3.7792 -3.59783 -3.41637 -3.24959 -3.11766 -3.03878 -2.96564 -2.32657 -4.29549 -4.26948 -4.2178 -4.1412 -4.04092 -3.91885 -3.77784 -3.62205 -3.45768 -3.29402 -3.14523 -3.03393 -3.00216 -3.17096 -4.17912 -4.0936 -4.06957 -4.02184 -3.95112 -3.85855 -3.74584 -3.61543 -3.47082 -3.31701 -3.1613 -3.01479 -2.89494 -2.82619 -2.79382 -2.24303 -3.90835 -3.88607 -3.84181 -3.77618 -3.69014 -3.58506 -3.46283 -3.32593 -3.1776 -3.02215 -2.86579 -2.72042 -2.62492 -2.77716 -4.41344 -3.73853 -3.7178 -3.67658 -3.61536 -3.53489 -3.43615 -3.32038 -3.18892 -3.04309 -2.8836 -2.7091 -2.51122 -2.25153 -1.73041 0.258727 -3.58305 -3.5637 -3.52519 -3.46787 -3.39228 -3.29903 -3.18876 -3.06185 -2.91802 -2.75541 -2.56861 -2.3449 -2.05963 -1.70364 -1.66688 -3.44097 -3.42287 -3.3868 -3.33302 -3.26188 -3.17369 -3.06865 -2.94648 -2.80595 -2.64395 -2.4537 -2.22127 -1.91679 -1.45571 -0.429843 -3.31142 -3.29446 -3.26066 -3.21019 -3.14325 -3.06001 -2.96038 -2.8438 -2.70875 -2.55207 -2.36802 -2.14764 -1.88261 -1.60056 -1.61776 -3.19358 -3.17771 -3.14605 -3.09873 -3.03591 -2.95766 -2.86384 -2.75389 -2.6265 -2.47914 -2.30752 -2.10495 -1.86018 -1.53816 -0.909859 -3.08672 -3.07187 -3.04226 -2.99799 -2.93922 -2.86606 -2.77844 -2.67605 -2.55807 -2.42299 -2.26846 -2.0915 -1.89134 -1.68904 -1.67367 -2.99012 -2.97624 -2.94858 -2.90726 -2.85249 -2.78444 -2.70326 -2.60898 -2.50145 -2.3803 -2.2449 -2.09411 -1.92391 -1.71069 -1.30297 -2.90309 -2.89014 -2.86433 -2.82583 -2.77491 -2.71188 -2.63711 -2.55105 -2.45423 -2.34744 -2.23197 -2.11016 -1.98626 -1.86802 -1.77325 -2.82501 -2.81291 -2.78883 -2.75298 -2.70569 -2.64741 -2.57876 -2.50053 -2.41389 -2.32056 -2.22339 -2.12759 -2.04462 -2.00966 -2.17787 -2.75526 -2.74395 -2.72145 -2.68801 -2.64404 -2.5901 -2.52699 -2.4558 -2.37812 -2.29628 -2.21381 -2.13604 -2.06956 -2.01083 -1.84933 -2.69332 -2.6827 -2.6616 -2.6303 -2.58925 -2.5391 -2.48077 -2.41553 -2.34518 -2.27236 -2.20091 -2.13659 -2.08906 -2.08399 -2.25891 -2.6387 -2.62868 -2.60878 -2.5793 -2.54072 -2.49373 -2.43929 -2.37873 -2.31391 -2.24744 -2.183 -2.12542 -2.07898 -2.0328 -1.85563 -2.59098 -2.58145 -2.56255 -2.53456 -2.49798 -2.45348 -2.402 -2.34483 -2.28371 -2.22105 -2.16027 -2.10644 -2.06865 -2.07322 -2.26394 -2.54982 -2.54069 -2.52256 -2.49573 -2.46067 -2.418 -2.36861 -2.31362 -2.25452 -2.1933 -2.13263 -2.07628 -2.02882 -1.98501 -1.82439 -2.51494 -2.5061 -2.48855 -2.46257 -2.42857 -2.38714 -2.33903 -2.28519 -2.22675 -2.1651 -2.10194 -2.03989 -1.98637 -1.97857 -2.25392 -2.48615 -2.4775 -2.46034 -2.43491 -2.40158 -2.36086 -2.31339 -2.25988 -2.20115 -2.13788 -2.0704 -1.99752 -1.91208 -1.77617 -1.36521 -2.46329 -2.45476 -2.43781 -2.41267 -2.37966 -2.33921 -2.29186 -2.23815 -2.17862 -2.11353 -2.04255 -1.96381 -1.87276 -1.76546 -1.70088 -2.4463 -2.4378 -2.42091 -2.39582 -2.36283 -2.3223 -2.27468 -2.22041 -2.15988 -2.09322 -2.02001 -1.9386 -1.84464 -1.72576 -1.5278 -2.43515 -2.42662 -2.40964 -2.38441 -2.35117 -2.31026 -2.26205 -2.20695 -2.14532 -2.07738 -2.00309 -1.92202 -1.83375 -1.74169 -1.68147 -2.42986 -2.42123 -2.40405 -2.37849 -2.34477 -2.30321 -2.25415 -2.19797 -2.13508 -2.06589 -1.99081 -1.91039 -1.8254 -1.73619 -1.63343 -2.4305 -2.42171 -2.40422 -2.37816 -2.34376 -2.3013 -2.25111 -2.19358 -2.12915 -2.05841 -1.98219 -1.90185 -1.8199 -1.74082 -1.67424 -2.43717 -2.42818 -2.41026 -2.38357 -2.34829 -2.3047 -2.25312 -2.19391 -2.12754 -2.05468 -1.97634 -1.89438 -1.81231 -1.73748 -1.68912 -2.45003 -2.44078 -2.42234 -2.39486 -2.35853 -2.31359 -2.26035 -2.19914 -2.13038 -2.05467 -1.97295 -1.88691 -1.7996 -1.71647 -1.65044 -2.46926 -2.45969 -2.44064 -2.41224 -2.37467 -2.32819 -2.27305 -2.20955 -2.13799 -2.05876 -1.97248 -1.88025 -1.7839 -1.68431 -1.56607 -2.49506 -2.48513 -2.46537 -2.43591 -2.39695 -2.34873 -2.2915 -2.22549 -2.15085 -2.06768 -1.97607 -1.8764 -1.77037 -1.66581 -1.60857 -2.52768 -2.51735 -2.49677 -2.46611 -2.42558 -2.37546 -2.31598 -2.24735 -2.16957 -2.08239 -1.98519 -1.87688 -1.75574 -1.61516 -1.40267 -2.56742 -2.55661 -2.53511 -2.50309 -2.46082 -2.40861 -2.34677 -2.27549 -2.19474 -2.104 -2.00195 -1.88621 -1.75452 -1.61517 -1.56184 -2.61459 -2.60325 -2.58069 -2.54713 -2.5029 -2.4484 -2.38403 -2.31014 -2.22679 -2.1334 -2.02814 -1.90655 -1.75854 -1.55614 -1.17167 -2.66957 -2.65761 -2.63384 -2.59851 -2.55205 -2.49496 -2.42785 -2.3513 -2.26573 -2.17098 -2.06559 -1.94517 -1.80023 -1.62429 -1.5459 -2.7328 -2.72012 -2.69494 -2.65757 -2.60851 -2.54843 -2.47816 -2.39867 -2.31097 -2.21588 -2.11342 -2.00077 -1.86336 -1.62539 -0.83462 -2.80476 -2.79126 -2.76444 -2.72468 -2.67256 -2.6089 -2.5348 -2.45167 -2.36127 -2.26583 -2.16826 -2.07348 -1.99624 -2.0111 -2.58924 -2.88604 -2.87158 -2.84287 -2.8003 -2.74455 -2.67656 -2.59765 -2.50964 -2.41501 -2.31719 -2.2211 -2.13395 -2.06506 -2.00633 -1.73063 -2.97729 -2.96174 -2.93084 -2.88503 -2.82498 -2.75174 -2.66677 -2.57216 -2.4709 -2.36729 -2.26766 -2.18167 -2.12676 -2.15294 -2.52845 -3.07928 -3.0625 -3.02912 -2.97957 -2.91452 -2.835 -2.74251 -2.63922 -2.52835 -2.41457 -2.30467 -2.20774 -2.13206 -2.05765 -1.73946 -3.19287 -3.17471 -3.13857 -3.08481 -3.01405 -2.92721 -2.82568 -2.7115 -2.58775 -2.4591 -2.3326 -2.219 -2.13639 -2.13234 -2.45977 -3.31901 -3.29935 -3.26018 -3.20179 -3.12467 -3.02956 -2.91756 -2.79035 -2.6505 -2.50207 -2.3515 -2.20867 -2.08608 -1.9775 -1.67752 -3.45874 -3.43749 -3.39508 -3.33172 -3.24773 -3.14358 -3.01996 -2.87791 -2.71913 -2.54646 -2.36495 -2.18424 -2.02597 -1.95624 -2.26377 -3.61317 -3.59025 -3.54447 -3.47592 -3.38473 -3.27106 -3.13509 -2.97704 -2.79735 -2.59693 -2.37779 -2.14415 -1.90428 -1.67365 -1.48708 -3.78345 -3.75883 -3.70961 -3.63578 -3.53729 -3.41398 -3.26548 -3.09113 -2.88991 -2.66034 -2.40064 -2.10832 -1.77611 -1.36112 -0.580982 -3.97077 -3.94445 -3.89178 -3.8127 -3.70702 -3.57432 -3.41376 -3.22384 -3.00208 -2.74462 -2.44607 -2.10015 -1.70535 -1.30282 -1.25312 -4.17631 -4.14829 -4.09224 -4.00804 -3.89547 -3.75395 -3.58236 -3.3786 -3.13897 -2.85738 -2.52433 -2.12585 -1.63987 -1.00013 0.228958 -4.40125 -4.37156 -4.31217 -4.22303 -4.10395 -3.9544 -3.77326 -3.55821 -3.30495 -3.00582 -2.64796 -2.21226 -1.68108 -1.10737 -1.10484 -4.64675 -4.61539 -4.55271 -4.45876 -4.33353 -4.17675 -3.98763 -3.7643 -3.50274 -3.19497 -2.82559 -2.36491 -1.75176 -0.818581 1.23226 -4.91398 -4.88092 -4.81491 -4.71617 -4.58496 -4.42149 -4.22572 -3.99687 -3.73255 -3.42686 -3.06657 -2.62338 -2.04461 -1.30656 -1.1738 -5.2041 -5.16927 -5.09979 -4.99607 -4.85873 -4.68861 -4.48672 -4.25403 -3.99104 -3.69661 -3.36505 -2.97596 -2.44801 -1.3748 2.67943 -5.51837 -5.48162 -5.40839 -5.29926 -5.15521 -4.97774 -4.76905 -4.53218 -4.2713 -3.9921 -3.70343 -3.42491 -3.22999 -3.51378 -6.7761 -5.8581 -5.81925 -5.74187 -5.62665 -5.47485 -5.28851 -5.0709 -4.82697 -4.56423 -4.29411 -4.03471 -3.81575 -3.67946 -3.58486 -2.3732 -6.22475 -6.18359 -6.10158 -5.9794 -5.81841 -5.62095 -5.39097 -5.13476 -4.86222 -4.58864 -4.33786 -4.14915 -4.09993 -4.4322 -6.47821 -6.61994 -6.57626 -6.48912 -6.35905 -6.18723 -5.97593 -5.72919 -5.45385 -5.1609 -4.86727 -4.59786 -4.38565 -4.25543 -4.08993 -2.65499 -7.0454 -6.99906 -6.90642 -6.76765 -6.58344 -6.35547 -6.08723 -5.78513 -5.46001 -5.12905 -4.81808 -4.56518 -4.43539 -4.6297 -6.35388 -7.50299 -7.45398 -7.35569 -7.20775 -7.00997 -6.76293 -6.46874 -6.13235 -5.76313 -5.37691 -4.99793 -4.65917 -4.39024 -4.10754 -2.73178 -7.99457 -7.94306 -7.83939 -7.6824 -7.47068 -7.20307 -6.87951 -6.50231 -6.078 -5.61969 -5.14983 -4.70462 -4.35461 -4.34491 -6.00015 -8.52187 -8.46831 -8.36008 -8.19502 -7.97015 -7.68202 -7.32748 -6.90496 -6.41645 -5.87045 -5.28457 -4.68394 -4.0826 -3.42654 -2.57239 -9.08631 -9.03148 -8.92018 -8.74913 -8.51349 -8.20704 -7.82263 -7.35337 -6.79479 -6.14886 -5.42953 -4.6637 -3.84857 -2.64616 1.44841 -9.68877 -9.63381 -9.52171 -9.34805 -9.10598 -8.78614 -8.37666 -7.86377 -7.23374 -6.47819 -5.60673 -4.67767 -3.88343 -3.87469 -7.4594 -10.3294 -10.2758 -10.166 -9.99441 -9.75241 -9.42744 -9.00246 -8.45546 -7.75982 -6.88799 -5.8239 -4.59798 -3.37277 -2.60825 -3.08477 -11.0071 -10.9567 -10.853 -10.6897 -10.4564 -10.1381 -9.71296 -9.15033 -8.40821 -7.43124 -6.15343 -4.51775 -2.54214 -0.48045 0.958833 -11.7198 -11.6747 -11.5814 -11.4334 -11.2195 -10.923 -10.5189 -9.96979 -9.21966 -8.18337 -6.73143 -4.67355 -1.77124 2.0791 6.00181 -12.4637 -12.4261 -12.3479 -12.2227 -12.0398 -11.7826 -11.4254 -10.9288 -10.2298 -9.22411 -7.73018 -5.41571 -1.65863 4.5879 13.7688 -13.2337 -13.2056 -13.1469 -13.0521 -12.9118 -12.7115 -12.4288 -12.0283 -11.4529 -10.6038 -9.2987 -7.15966 -3.27476 5.05848 27.9111 -158.066 -94.9904 -66.4222 -52.7749 -45.4664 -41.1016 -38.2654 -36.3096 -34.9073 -33.8792 -33.1211 -32.5688 -32.1823 -31.9367 -31.8173 -196.592 -88.8817 -59.009 -47.496 -41.721 -38.2897 -36.0308 -34.4471 -33.294 -32.4377 -31.7995 -31.3309 -31.0011 -30.7907 -30.6882 50.6892 -28.7203 -38.846 -38.2322 -36.3479 -34.6637 -33.3271 -32.2855 -31.4745 -30.8445 -30.3601 -29.9966 -29.737 -29.5697 -29.4877 -7.49008 -16.6737 -26.1407 -29.8508 -30.8357 -30.7961 -30.4185 -29.9637 -29.5293 -29.1501 -28.8366 -28.5901 -28.4086 -28.2893 -28.2303 27.805 -4.43111 -17.4334 -23.3616 -26.0349 -27.1632 -27.5635 -27.6277 -27.5456 -27.4099 -27.2666 -27.1385 -27.0368 -26.9671 -26.9317 -1.61086 -5.54625 -13.6384 -19.1328 -22.3069 -24.0359 -24.9416 -25.3932 -25.599 -25.675 -25.6859 -25.6684 -25.6429 -25.6209 -25.6086 12.1184 -3.77556 -11.6474 -16.5153 -19.5824 -21.4801 -22.635 -23.3295 -23.7425 -23.9851 -24.125 -24.2037 -24.2463 -24.2679 -24.2768 -3.52734 -7.57663 -11.7425 -15.1483 -17.6699 -19.4402 -20.6482 -21.461 -22.0043 -22.3663 -22.6065 -22.764 -22.8644 -22.9236 -22.9511 -16.3612 -11.2976 -12.3653 -14.3953 -16.279 -17.7906 -18.9358 -19.7795 -20.392 -20.8322 -21.1453 -21.3639 -21.5109 -21.6013 -21.6443 -5.63345 -10.7614 -12.3199 -13.7439 -15.1464 -16.3953 -17.4326 -18.2586 -18.8991 -19.3862 -19.7496 -20.0136 -20.1966 -20.3118 -20.3674 -18.423 -12.7048 -12.3677 -13.1072 -14.1204 -15.147 -16.076 -16.8664 -17.5128 -18.0261 -18.4229 -18.7193 -18.9294 -19.0636 -19.129 -5.84461 -10.9121 -11.668 -12.2805 -13.0851 -13.9664 -14.8157 -15.5741 -16.2187 -16.747 -17.1657 -17.485 -17.7148 -17.8632 -17.936 -19.0862 -12.1144 -11.0678 -11.3202 -11.9965 -12.808 -13.6184 -14.3607 -15.0054 -15.5438 -15.9775 -16.3127 -16.5565 -16.7152 -16.7934 -5.02042 -9.20274 -9.56561 -10.0653 -10.8141 -11.6502 -12.4684 -13.215 -13.8658 -14.4132 -14.8577 -15.2039 -15.4573 -15.6231 -15.705 -20.1994 -8.94427 -7.96834 -8.63731 -9.57097 -10.5047 -11.3681 -12.1357 -12.7981 -13.3539 -13.8061 -14.1594 -14.4189 -14.5892 -14.6735 12.408 -1.54825 -5.22874 -7.02547 -8.32772 -9.40798 -10.3343 -11.1294 -11.8043 -12.3666 -12.8231 -13.1799 -13.4424 -13.6149 -13.7003 -0.895493 -1.28894 -3.79726 -5.75696 -7.23857 -8.4181 -9.39148 -10.2065 -10.8885 -11.4527 -11.9093 -12.2659 -12.5283 -12.7009 -12.7865 7.50998 0.43824 -2.74673 -4.82037 -6.35914 -7.57131 -8.55859 -9.37589 -10.0545 -10.6134 -11.0648 -11.4172 -11.6766 -11.8473 -11.932 -0.609525 -0.534512 -2.46789 -4.25517 -5.70644 -6.88061 -7.84368 -8.64154 -9.30358 -9.8486 -10.2889 -10.633 -10.8865 -11.0534 -11.1363 4.15563 -0.113332 -2.29048 -3.92324 -5.24609 -6.33644 -7.24344 -8.00143 -8.63386 -9.15648 -9.57993 -9.91154 -10.1563 -10.3178 -10.398 -1.05162 -1.14558 -2.49109 -3.80645 -4.94713 -5.91953 -6.74659 -7.44846 -8.04034 -8.53315 -8.93464 -9.25032 -9.48405 -9.63848 -9.7153 1.43353 -1.30948 -2.71257 -3.8109 -4.76495 -5.60349 -6.3366 -6.97179 -7.51553 -7.97316 -8.34888 -8.64594 -8.86675 -9.01303 -9.08591 -1.8038 -2.40467 -3.14566 -3.91546 -4.66293 -5.36059 -5.99454 -6.55857 -7.05047 -7.46997 -7.81767 -8.09444 -8.30113 -8.43849 -8.50705 -4.62398 -3.40332 -3.55871 -4.03547 -4.59543 -5.16185 -5.70098 -6.19537 -6.6356 -7.01658 -7.33566 -7.59152 -7.7836 -7.91167 -7.97572 -2.4107 -3.44718 -3.74852 -4.09764 -4.52335 -4.98201 -5.4384 -5.8697 -6.2618 -6.60611 -6.89748 -7.13284 -7.31043 -7.42925 -7.48878 -5.35898 -4.00234 -3.9051 -4.10657 -4.42832 -4.80367 -5.19318 -5.57119 -5.92113 -6.23234 -6.49811 -6.71421 -6.87802 -6.98795 -7.04312 -2.55626 -3.68371 -3.85419 -4.03189 -4.29601 -4.61544 -4.95585 -5.29212 -5.60726 -5.89006 -6.13318 -6.33183 -6.48294 -6.5846 -6.63569 -5.66389 -4.03041 -3.79823 -3.89712 -4.12521 -4.41257 -4.72134 -5.02765 -5.31579 -5.57527 -5.79905 -5.98238 -6.12214 -6.21631 -6.26368 -2.42506 -3.40475 -3.5123 -3.67257 -3.91318 -4.19475 -4.48847 -4.77573 -5.04416 -5.28521 -5.49293 -5.66313 -5.79294 -5.88045 -5.92448 -5.98691 -3.38552 -3.18973 -3.39215 -3.67263 -3.96843 -4.26 -4.53683 -4.79147 -5.01824 -5.21279 -5.37186 -5.49305 -5.57471 -5.6158 1.57735 -1.69648 -2.59058 -3.05745 -3.42137 -3.74499 -4.0417 -4.31326 -4.55806 -4.77357 -4.95724 -5.10683 -5.22055 -5.29709 -5.33557 -1.51772 -1.6608 -2.28808 -2.79416 -3.19804 -3.54015 -3.8408 -4.10822 -4.34493 -4.55095 -4.72527 -4.86663 -4.97381 -5.04582 -5.08201 0.366348 -1.28961 -2.06971 -2.60179 -3.01755 -3.36403 -3.66291 -3.92443 -4.15305 -4.35027 -4.51614 -4.6501 -4.75141 -4.81938 -4.8535 -1.47959 -1.5274 -2.02353 -2.49012 -2.8851 -3.22091 -3.51089 -3.76342 -3.98291 -4.17129 -4.3291 -4.45619 -4.55211 -4.61637 -4.64862 -0.469787 -1.45458 -1.99782 -2.42811 -2.79367 -3.10954 -3.38481 -3.62529 -3.83431 -4.01347 -4.16334 -4.28385 -4.37472 -4.43555 -4.46606 -1.59883 -1.68914 -2.05049 -2.411 -2.73668 -3.0263 -3.28282 -3.50894 -3.70637 -3.87594 -4.01789 -4.13205 -4.21811 -4.27572 -4.30461 -1.12256 -1.73621 -2.1037 -2.41801 -2.70466 -2.96597 -3.20189 -3.41245 -3.5977 -3.75754 -3.89167 -3.9997 -4.0812 -4.13578 -4.16316 -1.76294 -1.95494 -2.1938 -2.44416 -2.69019 -2.9232 -3.13849 -3.33348 -3.50663 -3.65691 -3.7835 -3.88571 -3.96292 -4.01468 -4.04065 -2.27007 -2.14184 -2.27587 -2.47325 -2.68468 -2.89268 -3.08914 -3.2696 -3.43137 -3.57268 -3.69222 -3.789 -3.86227 -3.91143 -3.93611 -1.87885 -2.14735 -2.31389 -2.49254 -2.68147 -2.87012 -3.05082 -3.21863 -3.37027 -3.5035 -3.61667 -3.70857 -3.77828 -3.82512 -3.84865 -2.28874 -2.22436 -2.34347 -2.50461 -2.67839 -2.85301 -3.02141 -3.17882 -3.32189 -3.44817 -3.55584 -3.6435 -3.71011 -3.75493 -3.77746 -1.89701 -2.17467 -2.34381 -2.50784 -2.67467 -2.84016 -2.99955 -3.14891 -3.28511 -3.40572 -3.50884 -3.59298 -3.65702 -3.70016 -3.72186 -2.15895 -2.20101 -2.34764 -2.50908 -2.67182 -2.83148 -2.98461 -3.12807 -3.2591 -3.37536 -3.47496 -3.55636 -3.6184 -3.66022 -3.68127 -1.89151 -2.15542 -2.34115 -2.50934 -2.67105 -2.82727 -2.97632 -3.1158 -3.24327 -3.35652 -3.45365 -3.53313 -3.59375 -3.63465 -3.65524 -1.94115 -2.16477 -2.3468 -2.51404 -2.67404 -2.82798 -2.97462 -3.11182 -3.23727 -3.34881 -3.44454 -3.52293 -3.58275 -3.62312 -3.64345 -2.1009 -2.20365 -2.36267 -2.52372 -2.68117 -2.8337 -2.97941 -3.11594 -3.24088 -3.35201 -3.44743 -3.52556 -3.5852 -3.62545 -3.64572 -1.92406 -2.20408 -2.37711 -2.53583 -2.69167 -2.84409 -2.99051 -3.12805 -3.25402 -3.36607 -3.46226 -3.54099 -3.60107 -3.6416 -3.66201 -2.30819 -2.2794 -2.40145 -2.54988 -2.70448 -2.8586 -3.00773 -3.14814 -3.27677 -3.3911 -3.48915 -3.56933 -3.63045 -3.67167 -3.69242 -1.95705 -2.25057 -2.40742 -2.55961 -2.71758 -2.87652 -3.03094 -3.17637 -3.30939 -3.42739 -3.52838 -3.61084 -3.67362 -3.7159 -3.73718 -2.43253 -2.31724 -2.4166 -2.56528 -2.72994 -2.89754 -3.06034 -3.21315 -3.35239 -3.47545 -3.58044 -3.66596 -3.73095 -3.77468 -3.79667 -1.95778 -2.2354 -2.39149 -2.55979 -2.7402 -2.92183 -3.09661 -3.25932 -3.40656 -3.536 -3.64598 -3.73529 -3.80301 -3.84851 -3.87137 -2.40592 -2.23853 -2.35787 -2.54584 -2.74958 -2.95083 -3.14121 -3.31619 -3.47305 -3.61002 -3.72583 -3.81955 -3.89045 -3.93801 -3.96189 -1.85477 -2.04306 -2.27657 -2.5209 -2.76062 -2.98732 -3.19646 -3.38559 -3.55331 -3.69867 -3.82097 -3.9196 -3.99405 -4.04393 -4.06894 -1.17293 -1.81674 -2.18771 -2.4991 -2.78066 -3.03597 -3.26556 -3.46982 -3.64903 -3.8033 -3.9325 -4.0364 -4.11468 -4.16706 -4.19331 -1.70696 -1.78043 -2.14019 -2.49796 -2.81887 -3.10242 -3.35221 -3.57139 -3.76204 -3.92528 -4.06156 -4.17094 -4.25326 -4.30829 -4.33587 -0.527132 -1.54582 -2.09402 -2.52237 -2.88299 -3.19226 -3.46006 -3.69274 -3.89404 -4.06594 -4.20926 -4.32423 -4.41073 -4.46856 -4.49753 -1.61525 -1.63844 -2.13105 -2.59377 -2.98271 -3.31086 -3.59225 -3.83582 -4.04642 -4.2264 -4.37662 -4.49724 -4.58807 -4.64883 -4.67928 0.287996 -1.40555 -2.1888 -2.71637 -3.12459 -3.46189 -3.75067 -4.00175 -4.22004 -4.40747 -4.56449 -4.6909 -4.78625 -4.8501 -4.88212 -1.69405 -1.80529 -2.42407 -2.92179 -3.31568 -3.64656 -3.93524 -4.19041 -4.41505 -4.60962 -4.77359 -4.90608 -5.00627 -5.07345 -5.10716 1.46242 -1.85302 -2.74336 -3.19928 -3.5505 -3.8605 -4.14305 -4.40023 -4.63089 -4.83299 -5.0045 -5.14367 -5.24917 -5.32 -5.35558 -6.25606 -3.58527 -3.36431 -3.54945 -3.81389 -4.09348 -4.36842 -4.62844 -4.86653 -5.07757 -5.25783 -5.40462 -5.51609 -5.59102 -5.62866 -2.65202 -3.6166 -3.70323 -3.84449 -4.06675 -4.32964 -4.60412 -4.87184 -5.12092 -5.3435 -5.53436 -5.69006 -5.80837 -5.88789 -5.92784 -5.92145 -4.25796 -4.0042 -4.08327 -4.29134 -4.55772 -4.84449 -5.12815 -5.39367 -5.63142 -5.83529 -6.00144 -6.12754 -6.21222 -6.25473 -2.80286 -3.92067 -4.07401 -4.23245 -4.4754 -4.77162 -5.08699 -5.39703 -5.68568 -5.94285 -6.16237 -6.3406 -6.47546 -6.56582 -6.61111 -5.62486 -4.25343 -4.14025 -4.32291 -4.62245 -4.97219 -5.33318 -5.68073 -5.99952 -6.28039 -6.5181 -6.70986 -6.85425 -6.95067 -6.99892 -2.6825 -3.71268 -4.00105 -4.33217 -4.73462 -5.16492 -5.58866 -5.98437 -6.33966 -6.64787 -6.90573 -7.11197 -7.26632 -7.36897 -7.4202 -4.91409 -3.68733 -3.83214 -4.29189 -4.82741 -5.36219 -5.86358 -6.31606 -6.71249 -7.05028 -7.32919 -7.5501 -7.71428 -7.82295 -7.87704 -2.10833 -2.70975 -3.4445 -4.19896 -4.92071 -5.58261 -6.17246 -6.68663 -7.12602 -7.49357 -7.7929 -8.0276 -8.20076 -8.31481 -8.37141 1.11506 -1.63981 -3.04315 -4.12873 -5.05554 -5.85305 -6.53387 -7.10913 -7.58942 -7.98419 -8.30149 -8.54782 -8.72826 -8.84654 -8.90508 -1.40053 -1.50867 -2.86244 -4.16873 -5.28014 -6.2045 -6.96856 -7.59756 -8.11218 -8.52861 -8.85933 -9.11377 -9.29893 -9.41974 -9.47938 3.81102 -0.5127 -2.7147 -4.34403 -5.63463 -6.66725 -7.49702 -8.16541 -8.70311 -9.13255 -9.47013 -9.72782 -9.91426 -10.0354 -10.0951 -1.01781 -0.990336 -2.96463 -4.75454 -6.16824 -7.27087 -8.13752 -8.82401 -9.36921 -9.80026 -10.1364 -10.3913 -10.5749 -10.6938 -10.7522 7.17721 -0.0779981 -3.34259 -5.42629 -6.91787 -8.03833 -8.90314 -9.58071 -10.1146 -10.5339 -10.859 -11.1044 -11.2804 -11.3941 -11.4499 -1.41953 -1.93707 -4.54058 -6.5092 -7.92521 -8.98333 -9.79876 -10.4372 -10.9394 -11.3329 -11.637 -11.8657 -12.0293 -12.1347 -12.1863 12.1732 -2.34764 -6.17947 -7.97586 -9.18106 -10.0968 -10.8173 -11.3883 -11.8399 -12.1939 -12.4672 -12.6723 -12.8185 -12.9125 -12.9585 -21.6531 -10.1813 -9.23184 -9.85306 -10.6379 -11.346 -11.9395 -12.4224 -12.808 -13.1111 -13.3448 -13.5196 -13.644 -13.7238 -13.7627 -5.94293 -10.7077 -11.1935 -11.6166 -12.148 -12.6748 -13.1386 -13.5239 -13.8335 -14.0766 -14.2631 -14.4021 -14.5005 -14.5633 -14.594 -21.3061 -14.2056 -13.1988 -13.3051 -13.6613 -14.0472 -14.3923 -14.678 -14.9052 -15.0812 -15.2146 -15.3128 -15.3816 -15.4253 -15.4465 -7.21807 -13.4715 -14.4311 -14.82 -15.1541 -15.4478 -15.6873 -15.8728 -16.0124 -16.1155 -16.1904 -16.2438 -16.2802 -16.3029 -16.3137 -22.3305 -16.4131 -16.0596 -16.3729 -16.675 -16.8862 -17.0198 -17.0995 -17.1449 -17.1693 -17.1813 -17.1866 -17.1884 -17.1886 -17.1885 -8.00933 -15.4912 -17.225 -17.9337 -18.2589 -18.3784 -18.3896 -18.3502 -18.292 -18.2316 -18.177 -18.1318 -18.0975 -18.0747 -18.0632 -24.2816 -18.5612 -19.1023 -19.7608 -19.9856 -19.9457 -19.7946 -19.6139 -19.4407 -19.2899 -19.1661 -19.0695 -18.9988 -18.9527 -18.93 -8.73644 -17.2833 -20.8981 -21.8893 -21.8961 -21.5903 -21.22 -20.8722 -20.5739 -20.3296 -20.1363 -19.9891 -19.8831 -19.8146 -19.781 12.7449 -19.4305 -24.5162 -24.7019 -24.0239 -23.2796 -22.6297 -22.0963 -21.6696 -21.3338 -21.0746 -20.8801 -20.7414 -20.6523 -20.6087 -75.937 -40.3899 -31.538 -28.115 -26.198 -24.9032 -23.9585 -23.2463 -22.702 -22.2849 -21.9679 -21.7323 -21.5653 -21.4583 -21.406 -56.7987 -42.8044 -34.791 -30.4834 -27.9405 -26.2839 -25.1258 -24.2797 -23.6461 -23.1666 -22.8047 -22.537 -22.3475 -22.2263 -22.1672 -47.3817 -41.0589 -35.4722 -31.6278 -29.0681 -27.3184 -26.0763 -25.1656 -24.4831 -23.9665 -23.5763 -23.2872 -23.0824 -22.9513 -22.8872 -42.3578 -38.7958 -34.9452 -31.8815 -29.6337 -28.0004 -26.7966 -25.8929 -25.2051 -24.6785 -24.2777 -23.9789 -23.7663 -23.6296 -23.5628 -39.8098 -36.727 -33.8734 -31.57 -29.7732 -28.3844 -27.3085 -26.4704 -25.815 -25.3034 -24.9083 -24.6106 -24.3973 -24.2596 -24.192 -39.405 -34.4929 -32.4214 -30.9078 -29.63 -28.5512 -27.6553 -26.9209 -26.325 -25.8473 -25.4712 -25.1839 -24.976 -24.8408 -24.7742 -14.102 -14.0864 -14.0534 -13.999 -13.9166 -13.7962 -13.6223 -13.3715 -13.0071 -12.4699 -11.661 -10.4116 -8.45047 -5.51564 -2.73385 -15.0648 -15.0647 -15.0636 -15.0599 -15.0509 -15.0329 -15.0012 -14.9503 -14.8754 -14.7774 -14.6785 -14.6709 -15.0703 -16.8981 -23.3282 -16.0277 -16.0438 -16.0764 -16.126 -16.1941 -16.2833 -16.3992 -16.5529 -16.7666 -17.0857 -17.6047 -18.523 -20.2618 -23.6779 -30.297 -16.9743 -17.0065 -17.0721 -17.1737 -17.316 -17.5069 -17.7594 -18.0955 -18.5524 -19.1941 -20.1314 -21.5545 -23.776 -27.2547 -32.4697 -17.8886 -17.9356 -18.0317 -18.1806 -18.3893 -18.6688 -19.036 -19.5172 -20.1532 -21.0067 -22.1724 -23.7876 -26.0329 -29.0949 -33.0322 -18.7557 -18.8158 -18.9382 -19.1276 -19.3918 -19.7429 -20.1984 -20.7841 -21.5366 -22.507 -23.7637 -25.3905 -27.473 -30.0597 -33.0814 -19.5627 -19.6336 -19.7777 -19.9997 -20.3075 -20.7124 -21.2305 -21.884 -22.7019 -23.7211 -24.9849 -26.5374 -28.4089 -30.5894 -32.9894 -20.2987 -20.3782 -20.5391 -20.786 -21.1259 -21.5685 -22.1273 -22.8194 -23.6658 -24.6904 -25.9174 -27.3652 -29.0358 -30.8995 -32.8781 -20.9553 -21.0411 -21.2145 -21.4793 -21.8413 -22.3084 -22.8907 -23.6005 -24.4514 -25.4572 -26.6289 -27.97 -29.4696 -31.0944 -32.7833 -21.5259 -21.6163 -21.7984 -22.0754 -22.4517 -22.933 -23.5266 -24.2403 -25.082 -26.058 -27.171 -28.4162 -29.7779 -31.2253 -32.7116 -22.0061 -22.0995 -22.2875 -22.5722 -22.9568 -23.4453 -24.0422 -24.752 -25.5781 -26.5219 -27.5807 -28.7459 -30.0004 -31.3173 -32.6605 -22.3928 -22.4882 -22.6797 -22.9689 -23.3579 -23.8491 -24.4449 -25.1472 -25.9565 -26.8706 -27.884 -28.9862 -30.1602 -31.383 -32.6256 -22.6841 -22.7806 -22.9742 -23.2658 -23.6566 -24.1481 -24.7411 -25.4355 -26.2298 -27.1199 -28.0986 -29.1544 -30.2713 -31.4289 -32.6029 -22.8788 -22.9759 -23.1705 -23.4632 -23.8548 -24.3456 -24.9357 -25.6238 -26.4072 -27.2806 -28.2359 -29.2614 -30.3417 -31.4581 -32.5894 -22.9763 -23.0736 -23.2687 -23.5618 -23.9535 -24.4437 -25.0321 -25.7168 -26.4945 -27.3594 -28.3029 -29.3134 -30.3758 -31.4724 -32.5831 -25.9569 -108.747 -119.216 -73.6668 -56.9738 -41.277 -33.3974 -21.3115 -29.6437 -33.5669 -39.5207 -43.7781 -52.3002 -61.0173 -83.8038 -83.57 -59.9969 -50.854 -41.7033 -37.0782 -30.5819 -26.39 -17.9827 -26.2346 -30.2923 -36.5176 -40.9121 -49.5735 -58.242 -80.6457 -80.6389 -58.2149 -49.5213 -40.7979 -36.3705 -30.1001 -26.0265 -17.7861 -25.9987 -30.0516 -36.281 -40.6815 -49.3529 -58.0227 -80.4143 -80.4345 -58.1131 -49.4634 -40.789 -36.3852 -30.1421 -26.08 -17.8428 -26.111 -30.2031 -36.5057 -40.9654 -49.7593 -58.5502 -81.2443 -81.3078 -58.8294 -50.1301 -41.4229 -37.005 -30.737 -26.6463 -18.2992 -26.92 -31.2586 -38.0311 -42.9043 -52.6 -62.3529 -87.5341 -88.11 -64.9048 -56.1948 -48.0837 -44.2459 -39.4497 -36.3995 -30.2648 -60.001 -57.9898 -22.0229 -11.222 -8.26859 -9.35258 -16.8242 -40.1656 -66.6206 -74.5472 -64.2436 -54.2817 -45.3262 -39.0008 -34.5323 -35.6508 -38.1473 -41.8185 -46.0069 -51.5176 -57.6896 -64.6474 -64.4053 -56.9248 -50.2867 -44.2861 -39.6221 -35.3887 -32.2011 -29.9588 -32.037 -35.0485 -39.0585 -43.4619 -49.1145 -55.3511 -62.3413 -62.3303 -55.3158 -49.0496 -43.3574 -38.9155 -34.8627 -31.8061 -29.6657 -31.7839 -34.8186 -38.8457 -43.2632 -48.929 -55.1769 -62.1803 -62.198 -55.2312 -49.0054 -43.3498 -38.9369 -34.9103 -31.8765 -29.7609 -31.9182 -34.998 -39.083 -43.5669 -49.3197 -55.6668 -62.7878 -62.8506 -55.8621 -49.6177 -43.9516 -39.5387 -35.5212 -32.5144 -30.4635 -32.8232 -36.1676 -40.6211 -45.561 -51.9528 -59.0766 -67.1791 -67.7201 -60.7913 -54.6726 -49.3142 -45.3341 -42.0018 -39.8066 -39.1398 -44.1145 -41.2609 -29.8283 -22.3652 -18.9918 -18.8599 -21.5658 -40.3455 -51.1748 -56.1301 -54.3282 -50.1403 -45.5879 -41.93 -39.7076 -39.6737 -41.0358 -43.3712 -46.3316 -49.7824 -53.2304 -55.8587 -55.6636 -52.6398 -48.8011 -44.9442 -41.5459 -38.6893 -36.6511 -35.7134 -36.4953 -38.3669 -41.0331 -44.2126 -47.8147 -51.3749 -54.1184 -54.107 -51.3392 -47.7513 -44.1165 -40.9002 -38.1908 -36.2663 -35.4132 -36.2492 -38.1564 -40.8482 -44.0475 -47.6668 -51.2435 -54.0057 -54.0192 -51.2826 -47.7261 -44.1213 -40.9324 -38.2491 -36.3506 -35.5262 -36.3971 -38.3456 -41.0859 -44.3411 -48.0244 -51.6689 -54.4954 -54.5474 -51.8236 -48.2726 -44.6756 -41.503 -38.8501 -37.006 -36.2765 -37.3087 -39.4795 -42.5108 -46.1269 -50.2515 -54.391 -57.7126 -58.0867 -55.5114 -52.0557 -48.5602 -45.4896 -42.9161 -41.0124 -39.8892 -39.4986 -36.884 -31.9169 -27.6188 -25.0474 -24.2817 -24.9997 -38.6289 -44.1874 -47.4433 -47.8483 -46.5234 -44.5615 -42.7919 -41.7313 -41.6862 -42.5226 -44.0239 -45.9499 -48.0513 -49.9513 -51.1356 -50.9951 -49.5281 -47.3419 -44.9415 -42.6897 -40.8113 -39.5164 -38.9915 -39.3844 -40.5409 -42.2686 -44.3548 -46.575 -48.5746 -49.8628 -49.8528 -48.5435 -46.5205 -44.2731 -42.1549 -40.3886 -39.1837 -38.7284 -39.1718 -40.3648 -42.1197 -44.2273 -46.4659 -48.4829 -49.7895 -49.8005 -48.5149 -46.5166 -44.2939 -42.2 -40.4579 -39.2781 -38.8502 -39.3246 -40.5529 -42.3475 -44.4992 -46.7849 -48.8492 -50.1985 -50.2412 -48.9764 -46.994 -44.7885 -42.719 -41.0144 -39.8927 -39.5528 -40.1548 -41.5522 -43.5584 -45.9609 -48.5289 -50.8833 -52.4903 -52.7008 -51.4991 -49.4963 -47.1948 -44.9293 -42.8661 -41.0934 -39.5825 -38.0841 -35.8937 -33.0414 -30.386 -28.5033 -27.5679 -27.4583 -37.098 -40.5153 -42.8617 -43.8593 -43.8238 -43.2579 -42.6328 -42.2924 -42.4293 -43.0518 -44.0648 -45.3155 -46.6099 -47.7027 -48.3201 -48.2366 -47.4518 -46.1909 -44.725 -43.2956 -42.0932 -41.2725 -40.9483 -41.1737 -41.8924 -42.9876 -44.304 -45.6532 -46.7987 -47.4768 -47.4694 -46.7757 -45.6129 -44.2436 -42.9029 -41.7779 -41.0219 -40.7496 -41.015 -41.7643 -42.8832 -44.2186 -45.5842 -46.7453 -47.4392 -47.4488 -46.7736 -45.6303 -44.2811 -42.9609 -41.857 -41.1232 -40.8748 -41.1665 -41.9447 -43.0951 -44.4642 -45.8643 -47.059 -47.7834 -47.818 -47.1626 -46.0366 -44.7059 -43.4096 -42.3393 -41.6537 -41.4729 -41.8554 -42.7484 -44.0353 -45.5567 -47.1141 -48.4519 -49.2793 -49.3482 -48.6407 -47.367 -45.7778 -44.078 -42.3977 -40.7974 -39.2573 -37.6656 -35.856 -33.8824 -32.0404 -30.5953 -29.6651 -29.2164 -35.9864 -38.3853 -40.2223 -41.3576 -41.8878 -42.0395 -42.0637 -42.166 -42.4731 -43.0185 -43.7634 -44.6182 -45.4586 -46.1384 -46.5139 -46.4877 -46.0611 -45.3348 -44.4557 -43.5748 -42.8251 -42.3138 -42.1137 -42.2524 -42.7016 -43.3883 -44.2061 -45.0245 -45.6959 -46.078 -46.074 -45.6836 -45.0026 -44.1728 -43.3405 -42.6358 -42.1637 -41.9963 -42.1614 -42.6316 -43.3349 -44.1666 -44.9972 -45.6803 -46.0744 -46.0833 -45.7067 -45.0406 -44.2264 -43.4106 -42.7232 -42.2694 -42.1217 -42.3079 -42.8007 -43.528 -44.3845 -45.2397 -45.9464 -46.3616 -46.3883 -46.0267 -45.3739 -44.5737 -43.775 -43.1104 -42.6878 -42.5818 -42.8212 -43.3773 -44.1746 -45.1009 -46.0154 -46.7557 -47.1607 -47.1138 -46.5974 -45.6922 -44.5202 -43.1987 -41.8144 -40.4149 -39.0062 -37.5612 -36.0544 -34.5338 -33.1232 -31.9459 -31.0689 -30.4876 -35.2153 -37.0645 -38.5931 -39.7271 -40.4965 -41.0047 -41.3817 -41.7449 -42.1733 -42.6977 -43.3035 -43.9415 -44.5386 -45.012 -45.2861 -45.3151 -45.1019 -44.6989 -44.1889 -43.6648 -43.2138 -42.9068 -42.7912 -42.884 -43.169 -43.5999 -44.1075 -44.6073 -45.0096 -45.2352 -45.2353 -45.0097 -44.6068 -44.1054 -43.5946 -43.1587 -42.8666 -42.7644 -42.8687 -43.1631 -43.6019 -44.1163 -44.6226 -45.0316 -45.2645 -45.2729 -45.0566 -44.6641 -44.1741 -43.6757 -43.2529 -42.975 -42.8878 -43.008 -43.3191 -43.775 -44.3066 -44.8293 -45.2534 -45.4992 -45.5181 -45.3099 -44.9238 -44.4394 -43.9474 -43.533 -43.2662 -43.1935 -43.3307 -43.6591 -44.1282 -44.6623 -45.1675 -45.5422 -45.6929 -45.5554 -45.1142 -44.4016 -43.4781 -42.4099 -41.2531 -40.0458 -38.8075 -37.5456 -36.2728 -35.0268 -33.87 -32.8642 -32.0468 -31.4212 -34.6838 -36.2052 -37.5319 -38.6215 -39.4813 -40.1585 -40.7197 -41.2295 -41.7354 -42.2595 -42.7973 -43.3232 -43.7968 -44.1726 -44.4113 -44.4911 -44.4161 -44.2168 -43.9422 -43.6497 -43.3949 -43.2242 -43.1684 -43.2389 -43.4261 -43.7011 -44.0202 -44.3304 -44.5778 -44.717 -44.7215 -44.5913 -44.3528 -44.0514 -43.741 -43.4745 -43.2962 -43.2353 -43.3021 -43.4867 -43.7599 -44.0779 -44.388 -44.6364 -44.7779 -44.7859 -44.6606 -44.4282 -44.1339 -43.8317 -43.5744 -43.4059 -43.3554 -43.4332 -43.6289 -43.9131 -44.2416 -44.561 -44.817 -44.9639 -44.9748 -44.8497 -44.615 -44.3164 -44.008 -43.743 -43.5652 -43.5031 -43.5652 -43.7382 -43.9884 -44.2652 -44.5076 -44.6516 -44.6402 -44.4346 -44.0218 -43.4149 -42.6445 -41.7488 -40.7645 -39.7216 -38.6427 -37.5461 -36.4526 -35.3915 -34.3996 -33.5111 -32.7486 -32.117 -34.3156 -35.6261 -36.8121 -37.8468 -38.729 -39.4794 -40.1314 -40.7196 -41.2714 -41.8011 -42.3083 -42.7803 -43.1956 -43.5305 -43.7651 -43.8898 -43.9094 -43.8431 -43.7213 -43.58 -43.455 -43.3761 -43.3636 -43.4256 -43.5566 -43.739 -43.9455 -44.1439 -44.3018 -44.3927 -44.4017 -44.3289 -44.1895 -44.0103 -43.824 -43.6636 -43.5567 -43.5221 -43.5662 -43.6827 -43.8535 -44.0509 -44.2424 -44.3954 -44.4834 -44.4912 -44.4188 -44.2814 -44.1053 -43.9233 -43.7679 -43.6668 -43.6383 -43.6887 -43.8114 -43.9877 -44.1896 -44.3841 -44.538 -44.6243 -44.6275 -44.5473 -44.3985 -44.2074 -44.0063 -43.8276 -43.6978 -43.6338 -43.64 -43.7064 -43.8101 -43.9178 -43.9896 -43.9847 -43.8671 -43.612 -43.2092 -42.6635 -41.9913 -41.2153 -40.3603 -39.4494 -38.5035 -37.5421 -36.5856 -35.6568 -34.78 -33.9768 -33.2619 -32.6405 -34.0589 -35.2262 -36.3099 -37.2915 -38.1662 -38.942 -39.6346 -40.262 -40.8392 -41.3749 -41.87 -42.3187 -42.7101 -43.0326 -43.2769 -43.4398 -43.5261 -43.5491 -43.5283 -43.4871 -43.4484 -43.4321 -43.4517 -43.513 -43.6132 -43.7419 -43.8826 -44.0158 -44.1223 -44.1864 -44.1996 -44.1623 -44.0835 -43.9794 -43.8699 -43.7754 -43.7134 -43.6955 -43.7259 -43.8008 -43.9087 -44.0325 -44.1523 -44.2482 -44.3043 -44.3119 -44.2709 -44.1901 -44.0854 -43.9765 -43.8834 -43.8234 -43.8077 -43.8402 -43.9167 -44.0253 -44.1485 -44.2656 -44.3564 -44.4045 -44.4005 -44.3438 -44.2429 -44.1128 -43.9727 -43.8416 -43.7355 -43.6638 -43.628 -43.6208 -43.6263 -43.6222 -43.5823 -43.48 -43.2922 -43.0022 -42.6025 -42.0945 -41.4875 -40.7958 -40.0366 -39.2277 -38.3868 -37.5312 -36.6788 -35.8474 -35.0546 -34.3155 -33.6408 -33.0355 -33.8795 -34.9466 -35.9547 -36.8898 -37.7459 -38.5243 -39.2317 -39.8765 -40.4666 -41.0069 -41.4987 -41.9392 -42.3239 -42.6473 -42.906 -43.1 -43.2341 -43.3179 -43.3648 -43.3902 -43.4097 -43.4364 -43.4798 -43.5442 -43.6287 -43.7273 -43.8304 -43.9263 -44.0036 -44.0533 -44.0704 -44.0555 -44.0141 -43.9561 -43.8941 -43.8405 -43.8065 -43.7993 -43.8217 -43.8712 -43.9409 -44.0202 -44.0966 -44.1582 -44.1953 -44.2027 -44.1803 -44.1334 -44.0716 -44.0068 -43.9515 -43.9161 -43.9077 -43.9286 -43.9759 -44.0421 -44.1162 -44.1852 -44.2365 -44.2598 -44.2493 -44.2043 -44.1292 -44.0328 -43.926 -43.82 -43.7237 -43.6421 -43.5751 -43.5169 -43.4564 -43.3782 -43.2649 -43.0987 -42.8643 -42.5505 -42.1517 -41.6682 -41.1056 -40.4736 -39.7845 -39.0522 -38.2912 -37.516 -36.7416 -35.9823 -35.2518 -34.5614 -33.9197 -33.3316 -33.7554 -34.7519 -35.7045 -36.6017 -37.4372 -38.209 -38.9186 -39.5696 -40.1655 -40.709 -41.2008 -41.6403 -42.0256 -42.3551 -42.6281 -42.8464 -43.0145 -43.1398 -43.232 -43.302 -43.3604 -43.4166 -43.4775 -43.5465 -43.6239 -43.7064 -43.7885 -43.8636 -43.9248 -43.967 -43.9874 -43.9867 -43.9684 -43.9389 -43.906 -43.8777 -43.861 -43.8606 -43.8783 -43.9127 -43.9594 -44.0119 -44.0623 -44.1034 -44.1292 -44.1364 -44.125 -44.0983 -44.0621 -44.0237 -43.9909 -43.9701 -43.9656 -43.9788 -44.0078 -44.0477 -44.0913 -44.1303 -44.1567 -44.164 -44.148 -44.108 -44.0463 -43.9677 -43.8783 -43.7844 -43.6907 -43.5995 -43.5097 -43.4165 -43.3118 -43.1849 -43.0236 -42.8158 -42.5509 -42.2213 -41.823 -41.3558 -40.8237 -40.2336 -39.5948 -38.9182 -38.2158 -37.4998 -36.7826 -36.0761 -35.3912 -34.7374 -34.1217 -33.549 -33.6722 -34.6204 -35.5338 -36.4025 -37.2201 -37.9829 -38.69 -39.3419 -39.9399 -40.4851 -40.9782 -41.4192 -41.8077 -42.144 -42.4289 -42.6649 -42.8564 -43.0094 -43.1313 -43.2302 -43.3141 -43.3901 -43.4633 -43.5369 -43.6115 -43.6859 -43.7569 -43.8207 -43.8733 -43.9119 -43.935 -43.9432 -43.939 -43.9266 -43.9112 -43.8982 -43.892 -43.8958 -43.911 -43.9366 -43.9698 -44.0065 -44.0417 -44.0707 -44.0898 -44.0969 -44.092 -44.077 -44.0557 -44.0328 -44.013 -44.0006 -43.9982 -44.0065 -44.0242 -44.048 -44.073 -44.0937 -44.1047 -44.1016 -44.0814 -44.0431 -43.9879 -43.9182 -43.8373 -43.7486 -43.6543 -43.555 -43.4492 -43.3328 -43.1994 -43.0412 -42.8493 -42.615 -42.3309 -41.9913 -41.5933 -41.1371 -40.6254 -40.0637 -39.4594 -38.8216 -38.1601 -37.4855 -36.8083 -36.1387 -35.486 -34.8583 -34.262 -33.7017 -33.621 -34.5389 -35.4272 -36.277 -37.0817 -37.837 -38.5407 -39.1917 -39.7902 -40.3363 -40.8306 -41.2734 -41.6651 -42.0067 -42.2999 -42.5475 -42.7537 -42.9236 -43.0635 -43.18 -43.2794 -43.3675 -43.4486 -43.5256 -43.5996 -43.6701 -43.7356 -43.7937 -43.8422 -43.8792 -43.9041 -43.9175 -43.9213 -43.9187 -43.9132 -43.9087 -43.9085 -43.9148 -43.9287 -43.9494 -43.9752 -44.0032 -44.03 -44.0524 -44.0678 -44.0748 -44.0734 -44.0648 -44.0518 -44.0373 -44.0247 -44.0168 -44.0153 -44.0208 -44.032 -44.0465 -44.0609 -44.0711 -44.0732 -44.0639 -44.0407 -44.0028 -43.9504 -43.8848 -43.8077 -43.7208 -43.625 -43.5201 -43.4041 -43.2734 -43.1228 -42.946 -42.736 -42.4862 -42.1907 -41.8453 -41.4478 -40.9983 -40.4992 -39.9551 -39.3725 -38.759 -38.1234 -37.475 -36.8232 -36.177 -35.5449 -34.9341 -34.3506 -33.7988 -33.5966 -34.4998 -35.3758 -36.2162 -37.0143 -37.7655 -38.4669 -39.1172 -39.7156 -40.2621 -40.7571 -41.201 -41.5945 -41.939 -42.2365 -42.4898 -42.703 -42.881 -43.0294 -43.1541 -43.2609 -43.3547 -43.4398 -43.5186 -43.5926 -43.6617 -43.7249 -43.7807 -43.8274 -43.8639 -43.8897 -43.9055 -43.913 -43.9147 -43.9137 -43.9132 -43.9157 -43.9231 -43.9364 -43.955 -43.9775 -44.0016 -44.0247 -44.0442 -44.0579 -44.0649 -44.065 -44.0593 -44.0499 -44.0391 -44.0297 -44.0237 -44.0227 -44.0267 -44.035 -44.0453 -44.0549 -44.0604 -44.0584 -44.0461 -44.0214 -43.9835 -43.9321 -43.868 -43.7922 -43.7058 -43.609 -43.5012 -43.3803 -43.2428 -43.0841 -42.8986 -42.6803 -42.4232 -42.1225 -41.7744 -41.3772 -40.9309 -40.4379 -39.9023 -39.33 -38.7282 -38.1052 -37.4695 -36.83 -36.1952 -35.5731 -34.9706 -34.3934 -33.8461 -26.0215 -29.859 -30.3996 -30.0003 -29.321 -28.5949 -27.9134 -27.3106 -26.7958 -26.3681 -26.0226 -25.7539 -25.5569 -25.4278 -25.3639 -25.4441 -28.1025 -29.1354 -29.291 -29.0311 -28.5981 -28.1162 -27.6476 -27.2224 -26.8539 -26.5474 -26.3039 -26.1228 -26.0029 -25.9433 -26.5479 -27.973 -28.7494 -28.9979 -28.9142 -28.6503 -28.3059 -27.9414 -27.5921 -27.2779 -27.0093 -26.7917 -26.6275 -26.5179 -26.463 -27.9032 -28.4928 -28.8916 -29.0373 -28.9776 -28.7831 -28.5155 -28.2199 -27.9269 -27.6563 -27.4202 -27.226 -27.0778 -26.9781 -26.9279 -29.1221 -29.2036 -29.2872 -29.2822 -29.1757 -28.9892 -28.7532 -28.4958 -28.2394 -28.0002 -27.7893 -27.6142 -27.4797 -27.3886 -27.3427 -30.1272 -29.9123 -29.7713 -29.6286 -29.4538 -29.2447 -29.0122 -28.7708 -28.5348 -28.3157 -28.1226 -27.9619 -27.8381 -27.7541 -27.7117 -30.9309 -30.5472 -30.2573 -30.007 -29.7662 -29.5238 -29.28 -29.0406 -28.8132 -28.6054 -28.4236 -28.2728 -28.1567 -28.078 -28.0383 -31.566 -31.0883 -30.7037 -30.3759 -30.0804 -29.8044 -29.5435 -29.2983 -29.0721 -28.8691 -28.6936 -28.5489 -28.4381 -28.363 -28.3252 -32.0645 -31.5363 -31.0935 -30.7124 -30.3751 -30.07 -29.7912 -29.537 -29.3078 -29.1055 -28.9326 -28.7913 -28.6836 -28.6109 -28.5743 -32.4527 -31.899 -31.4215 -31.0053 -30.6376 -30.3093 -30.0146 -29.7506 -29.5165 -29.3127 -29.1401 -29.0002 -28.894 -28.8227 -28.7868 -32.7507 -32.1857 -31.6883 -31.2496 -30.8608 -30.515 -30.2072 -29.9344 -29.695 -29.4885 -29.3151 -29.1753 -29.0697 -28.999 -28.9635 -32.9736 -32.4047 -31.8966 -31.4439 -31.041 -30.6827 -30.3649 -30.0849 -29.8407 -29.6313 -29.4565 -29.3162 -29.2107 -29.1401 -29.1048 -33.1322 -32.563 -32.0495 -31.5886 -31.1766 -30.8099 -30.485 -30.1995 -29.9514 -29.7396 -29.5634 -29.4224 -29.3166 -29.246 -29.2107 -33.234 -32.6658 -32.1497 -31.6843 -31.2671 -30.8952 -30.5658 -30.2767 -30.026 -29.8124 -29.6351 -29.4935 -29.3874 -29.3167 -29.2814 -33.2839 -32.7163 -32.1993 -31.732 -31.3124 -30.938 -30.6065 -30.3156 -30.0635 -29.849 -29.6711 -29.5292 -29.4229 -29.3521 -29.3168 ) ; boundaryField { hot { type calculated; value nonuniform List<scalar> 120 ( -29.3363 -29.2684 -29.132 -28.9258 -28.648 -28.2967 -27.8693 -27.3639 -26.7785 -26.1124 -25.3658 -24.5409 -23.6422 -22.6765 -21.6537 -20.6748 -19.7627 -18.8371 -17.9072 -16.9817 -16.0687 -15.1754 -14.3079 -13.4709 -12.6678 -11.9011 -11.1725 -10.4825 -9.83159 -9.21951 -8.64585 -8.10988 -7.61067 -7.14706 -6.71768 -6.32096 -5.95515 -5.61836 -5.30865 -5.02404 -4.7626 -4.52249 -4.30202 -4.09963 -3.91394 -3.74373 -3.58791 -3.44551 -3.31566 -3.19756 -3.09044 -2.99359 -2.90634 -2.82804 -2.7581 -2.69599 -2.64122 -2.59338 -2.55212 -2.51717 -2.48832 -2.46544 -2.44843 -2.43729 -2.43202 -2.4327 -2.43943 -2.45235 -2.47165 -2.49754 -2.53027 -2.57013 -2.61743 -2.67257 -2.73598 -2.80815 -2.88967 -2.9812 -3.0835 -3.19743 -3.32394 -3.46406 -3.6189 -3.78961 -3.97735 -4.18332 -4.40867 -4.6546 -4.92225 -5.21283 -5.52757 -5.86783 -6.23506 -6.63087 -7.05699 -7.51523 -8.00741 -8.53519 -9.09991 -9.70238 -10.3426 -11.0195 -11.7308 -12.4729 -13.2405 -14.1058 -15.0648 -16.0236 -16.9663 -17.8769 -18.7408 -19.5451 -20.279 -20.9339 -21.5034 -21.9828 -22.3691 -22.66 -22.8545 -22.9519 ) ; } cold { type calculated; value nonuniform List<scalar> 120 ( -39.089 -39.0604 -39.0013 -38.9081 -38.7751 -38.5949 -38.3579 -38.0527 -37.6665 -37.1854 -36.5952 -35.883 -35.0386 -34.056 -32.9353 -31.7879 -30.6629 -29.4674 -28.2156 -26.9229 -25.6054 -24.2788 -22.9577 -21.6548 -20.3811 -19.1452 -17.954 -16.8128 -15.7254 -14.6944 -13.7216 -12.8078 -11.9531 -11.1569 -10.418 -9.73446 -9.1041 -8.52417 -7.99173 -7.50369 -7.05694 -6.6485 -6.27556 -5.93553 -5.62611 -5.34523 -5.09108 -4.86205 -4.6567 -4.4737 -4.31185 -4.17002 -4.04716 -3.9423 -3.85455 -3.78312 -3.72731 -3.68656 -3.66041 -3.64856 -3.65081 -3.66714 -3.69763 -3.74252 -3.80218 -3.8771 -3.96787 -4.07521 -4.19989 -4.34278 -4.50479 -4.6869 -4.89014 -5.11561 -5.36449 -5.63809 -5.93785 -6.26538 -6.62245 -7.01098 -7.433 -7.89053 -8.38551 -8.91964 -9.4942 -10.1099 -10.7667 -11.4637 -12.1991 -12.9699 -13.7724 -14.6015 -15.4517 -16.3164 -17.1884 -18.0604 -18.9244 -19.7727 -20.5979 -21.3931 -22.1525 -22.8714 -23.5463 -24.1752 -24.7577 -25.348 -25.9284 -26.4493 -26.9154 -27.3312 -27.7011 -28.0283 -28.3157 -28.5651 -28.7778 -28.9546 -29.0959 -29.2019 -29.2726 -29.3079 ) ; } interface_left { type calculated; value nonuniform List<scalar> 90 ( -56.8009 -105.864 53.8947 -3.26072 24.289 -2.1316 11.0776 -1.82426 -12.3345 -1.66353 -13.678 -1.64483 -14.6717 -1.54072 -17.7327 12.294 -2.01451 6.17191 -1.84703 3.16263 -1.81178 1.05047 -1.77073 -4.2189 -1.74078 -4.68893 -1.73616 -5.02947 -1.70644 -5.86985 1.87991 -1.82415 0.310342 -1.7726 -0.46886 -1.75492 -1.01769 -1.73495 -2.34478 -1.71701 -2.42086 -1.7046 -2.43669 -1.68665 -2.51385 -1.0428 -1.69422 -1.39783 -1.66735 -1.57636 -1.64575 -1.67511 -1.62405 -1.49849 -1.60164 -1.2667 -1.57783 -0.907212 -1.56328 -0.203915 -3.12117 -1.48503 -2.86096 -1.46393 -2.76059 -1.43153 -2.57132 -1.41102 -0.038306 -1.39675 1.08664 -1.38495 2.70501 -1.44743 5.9755 -9.69291 -1.21459 -8.2154 -1.34257 -7.86022 -1.5245 -7.52595 -2.07355 4.76521 -10.7258 -3.74573 1.39917 7.76802 19.0438 44.973 ) ; } interface_right { type calculated; value nonuniform List<scalar> 90 ( -201.586 -282.261 120.31 -4.93633 51.1063 -2.31815 23.119 -1.71053 -21.492 -1.3675 -23.5483 -1.28674 -25.041 -1.03672 -30.2634 23.7608 -1.88308 12.6027 -1.63508 7.15344 -1.60311 3.36435 -1.55796 -5.79599 -1.52576 -6.55839 -1.53498 -7.05967 -1.49833 -8.32319 4.22909 -1.71679 1.54543 -1.67559 0.205507 -1.68156 -0.711758 -1.68493 -2.44016 -1.69162 -2.39669 -1.70757 -2.18379 -1.72725 -1.81376 -2.0759 -1.73684 -2.38738 -1.74617 -2.57893 -1.75663 -2.6058 -1.77803 -0.736125 -1.80572 0.177074 -1.83369 1.50025 -1.92018 4.15467 -8.64581 -1.7293 -7.33564 -1.78326 -6.83173 -1.79859 -6.08832 -1.8608 3.0547 -1.94561 6.84445 -2.02486 12.3946 -2.3529 23.9673 -31.957 -1.49681 -27.4507 -1.70975 -27.7549 -1.78173 -30.0874 -2.94044 40.3085 -104.892 -65.5281 -50.4321 -43.8285 -41.3291 -43.069 ) ; } interface_top { type calculated; value nonuniform List<scalar> 90 ( -25.9569 -108.747 -119.216 -73.6668 -56.9738 -41.277 -33.3974 -21.3115 -29.6437 -33.5669 -39.5207 -43.7781 -52.3002 -61.0173 -83.8038 -83.57 -59.9969 -50.854 -41.7033 -37.0782 -30.5819 -26.39 -17.9827 -26.2346 -30.2923 -36.5176 -40.9121 -49.5735 -58.242 -80.6457 -80.6389 -58.2149 -49.5213 -40.7979 -36.3705 -30.1001 -26.0265 -17.7861 -25.9987 -30.0516 -36.281 -40.6815 -49.3529 -58.0227 -80.4143 -80.4345 -58.1131 -49.4634 -40.789 -36.3852 -30.1421 -26.08 -17.8428 -26.111 -30.2031 -36.5057 -40.9654 -49.7593 -58.5502 -81.2443 -81.3078 -58.8294 -50.1301 -41.4229 -37.005 -30.737 -26.6463 -18.2992 -26.92 -31.2586 -38.0311 -42.9043 -52.6 -62.3529 -87.5341 -88.11 -64.9048 -56.1948 -48.0837 -44.2459 -39.4497 -36.3995 -30.2648 -60.001 -57.9898 -22.0229 -11.222 -8.26859 -9.35258 -16.8242 ) ; } interface_bottom { type calculated; value nonuniform List<scalar> 90 ( -38.0949 -74.397 -77.4923 -52.567 -42.9022 -32.8293 -27.3457 -17.9884 -25.6357 -29.318 -34.931 -38.9084 -46.794 -54.745 -75.3875 -75.2353 -54.0762 -45.8763 -37.6777 -33.5273 -27.6835 -23.9032 -16.302 -23.7965 -27.481 -33.1331 -37.1158 -44.9594 -52.7863 -72.9969 -72.9531 -52.5939 -44.7072 -36.8155 -32.812 -27.1509 -23.4739 -16.0417 -23.4472 -27.0985 -32.7097 -36.6669 -44.461 -52.2326 -72.289 -72.2676 -52.1378 -44.3423 -36.5438 -32.5857 -26.9832 -23.339 -15.9591 -23.3455 -26.992 -32.6 -36.5553 -44.3453 -52.1072 -72.1313 -72.1159 -52.0389 -44.2635 -36.4839 -32.5339 -26.94 -23.2994 -15.9249 -23.3044 -26.9457 -32.5452 -36.4932 -44.2709 -52.0221 -72.0271 -72.0235 -52.0193 -44.2862 -36.6085 -32.7334 -27.3632 -23.8707 -16.9823 -27.5497 -26.5936 -12.7861 -9.88977 -12.1591 -21.9906 -54.1934 ) ; } defaultFaces { type empty; } } // ************************************************************************* //
[ "sarthakgarg1993@gmail.com" ]
sarthakgarg1993@gmail.com
bfb7a6a2083e3a72f334c4096ff0de703bab5033
85bc60be25f7ae1f059818bce174052ab60df971
/лабораторнаяработа1/realise_stack.cpp
2a4412ad84c870fd13755316d7566bcf1b5b1913
[]
no_license
feechka-patrick/The-foundations-of-modern-algorithms
7c60b97fc978a0593e20d82892108e09cc9d2989
9ec0d15b5fe393789734830611715c1488eec159
refs/heads/master
2023-01-08T04:12:16.837102
2020-11-15T12:07:59
2020-11-15T12:07:59
299,346,333
0
0
null
null
null
null
UTF-8
C++
false
false
1,054
cpp
#include <iostream> #include <locale> int SIZE; using namespace std; class Stack { public: int* stack; int current; public: Stack(int size) { current = -1; stack = new int[size]; } int pop() { if (current == -1) { cout << "Stack is empty!\n"; return (-1); } current--; return stack[current + 1]; } void push(int element) { if (current == SIZE - 1) { cout << "Stack is full!\n"; return; } stack[current + 1] = element; current++; } ~Stack() { cout << "I am free!\n"; delete[] stack; } }; int main() { SIZE = 3; setlocale(LC_ALL, "Russian"); cout << "Enter size of stack: "; cin >> SIZE; Stack stack(SIZE); while (true) { int choose; cout << "For push enter 1, for pop - 2, for exit enter 3: "; cin >> choose; if (choose == 1) { cout << "Enter element: "; int element; cin >> element; stack.push(element); } if (choose == 2) { int element = stack.pop(); if (element != -1) cout << "Element: " << element << "\n"; } if (choose == 3) return (0); } }
[ "annetatimoshenko38@gmail.com" ]
annetatimoshenko38@gmail.com
ff3db7f5304f424b3b20612352f1ee6ee364d43e
99c964fea7ea0a10459c2efb535f4d141b7bc912
/bfvmm/tests/memory_manager/test_object_allocator.cpp
71d14f23f30c7e77c74fdd1760a4511eb328bd40
[ "MIT" ]
permissive
hinoue/hypervisor
9f2f54763a5d222515a22c5982ac3cca945ab899
bfc7cdb8999790c47c1c346120b015a11d2a1701
refs/heads/master
2021-01-04T14:42:06.227534
2020-02-14T20:45:02
2020-02-14T20:45:02
240,594,575
0
0
MIT
2020-02-14T20:38:27
2020-02-14T20:38:26
null
UTF-8
C++
false
false
9,654
cpp
// // Copyright (C) 2019 Assured Information Security, Inc. // // 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. // TIDY_EXCLUSION=-cppcoreguidelines-owning-memory // // Reason: // This test triggers false positives during testing when attempting to // transfer ownership, which is currently a known issue // // https://clang.llvm.org/extra/clang-tidy/checks/ // cppcoreguidelines-owning-memory.html // #include <catch/catch.hpp> #include <list> #include <queue> #include <memory> #include <test/support.h> #include <memory_manager/object_allocator.h> constexpr const auto blocks_per_page = 512; TEST_CASE("basic allocator of 0 size") { object_allocator pool{0, 0}; } TEST_CASE("basic allocator size") { object_allocator pool{sizeof(uint64_t), 0}; CHECK(pool.size(nullptr) == sizeof(uint64_t)); } TEST_CASE("construction: limited") { { object_allocator pool{sizeof(uint64_t), 1}; CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 3); CHECK(pool.num_page() == 1); CHECK(pool.num_free() == blocks_per_page); CHECK(pool.num_used() == 0); } CHECK(g_allocated_pages.empty()); } TEST_CASE("construction: limited out of memory") { g_out_of_memory = true; auto ___ = gsl::finally([] { g_out_of_memory = false; }); { object_allocator pool1{sizeof(uint64_t), 1}; object_allocator pool2{sizeof(uint64_t), 0}; CHECK_THROWS(pool2.allocate()); } } TEST_CASE("construction: unlimited") { { object_allocator pool{sizeof(uint64_t)}; CHECK(pool.page_stack_size() == 0); CHECK(pool.objt_stack_size() == 0); CHECK(pool.num_page() == 0); CHECK(pool.num_free() == 0); CHECK(pool.num_used() == 0); } CHECK(g_allocated_pages.empty()); } TEST_CASE("allocate: single allocation") { { object_allocator pool{sizeof(uint64_t)}; auto ptr = pool.allocate(); CHECK_NOTHROW(ptr); CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 3); CHECK(pool.num_page() == 1); CHECK(pool.num_free() == blocks_per_page - 1); CHECK(pool.num_used() == 1); pool.deallocate(ptr); } CHECK(g_allocated_pages.empty()); } TEST_CASE("allocate: single allocation without free") { { object_allocator pool{sizeof(uint64_t)}; CHECK_NOTHROW(pool.allocate()); CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 3); CHECK(pool.num_page() == 1); CHECK(pool.num_free() == blocks_per_page - 1); CHECK(pool.num_used() == 1); } CHECK(!g_allocated_pages.empty()); auto pages = g_allocated_pages; for (const auto &ptr : pages) { free_page(ptr); } g_allocated_pages.clear(); } TEST_CASE("allocate: multiple allocations") { { object_allocator pool{sizeof(uint64_t)}; for (auto i = 0; i < blocks_per_page * 4; i++) { pool.allocate(); } CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 9); CHECK(pool.num_page() == 4); CHECK(pool.num_free() == 0); CHECK(pool.num_used() == blocks_per_page * 4); } CHECK(!g_allocated_pages.empty()); auto pages = g_allocated_pages; for (const auto &ptr : pages) { free_page(ptr); } g_allocated_pages.clear(); } TEST_CASE("allocate: multiple allocations with odd sized T") { { struct test { uint64_t val1; uint64_t val2; uint64_t val3; }; object_allocator pool{sizeof(test)}; for (auto i = 0U; i < 0x1000U / sizeof(test); i++) { CHECK_NOTHROW(pool.allocate()); } CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 1); CHECK(pool.num_page() == 1); CHECK(pool.num_free() == 0); CHECK(pool.num_used() == 0x1000U / sizeof(test)); CHECK_NOTHROW(pool.allocate()); CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 2); CHECK(pool.num_page() == 2); CHECK(pool.num_free() == (0x1000U / sizeof(test)) - 1); CHECK(pool.num_used() == (0x1000U / sizeof(test)) + 1); } CHECK(!g_allocated_pages.empty()); auto pages = g_allocated_pages; for (const auto &ptr : pages) { free_page(ptr); } g_allocated_pages.clear(); } TEST_CASE("allocate: over limit") { { object_allocator pool{sizeof(uint64_t), 1}; for (auto i = 0; i < blocks_per_page; i++) { pool.allocate(); } CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 3); CHECK(pool.num_page() == 1); CHECK(pool.num_free() == 0); CHECK(pool.num_used() == blocks_per_page); CHECK_THROWS(pool.allocate()); } CHECK(!g_allocated_pages.empty()); auto pages = g_allocated_pages; for (const auto &ptr : pages) { free_page(ptr); } g_allocated_pages.clear(); } TEST_CASE("deallocate: deallocate without allocate") { { uint64_t nothing = 0; object_allocator pool{sizeof(uint64_t)}; CHECK_NOTHROW(pool.deallocate(&nothing)); } CHECK(g_allocated_pages.empty()); } TEST_CASE("deallocate: deallocate single allocation") { { object_allocator pool{sizeof(uint64_t)}; auto alloc = pool.allocate(); CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 3); CHECK(pool.num_page() == 1); CHECK(pool.num_free() == blocks_per_page - 1); CHECK(pool.num_used() == 1); CHECK_NOTHROW(pool.deallocate(alloc)); CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 3); CHECK(pool.num_page() == 1); CHECK(pool.num_free() == blocks_per_page); CHECK(pool.num_used() == 0); } CHECK(g_allocated_pages.empty()); } TEST_CASE("deallocate: deallocate multiple allocations") { { std::list<void *> v{}; object_allocator pool{sizeof(uint64_t)}; for (auto i = 0; i < blocks_per_page * 4; i++) { v.push_back(pool.allocate()); } CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 9); CHECK(pool.num_page() == 4); CHECK(pool.num_free() == 0); CHECK(pool.num_used() == blocks_per_page * 4); for (auto elem : v) { pool.deallocate(elem); } CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 9); CHECK(pool.num_page() == 4); CHECK(pool.num_free() == blocks_per_page * 4); CHECK(pool.num_used() == 0); } CHECK(g_allocated_pages.empty()); } TEST_CASE("max_size: can allocate max_size") { { object_allocator pool{sizeof(__oa_page)}; CHECK_NOTHROW(pool.allocate()); CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 1); CHECK(pool.num_page() == 1); CHECK(pool.num_free() == 0); CHECK(pool.num_used() == 1); } CHECK(!g_allocated_pages.empty()); auto pages = g_allocated_pages; for (const auto &ptr : pages) { free_page(ptr); } g_allocated_pages.clear(); } TEST_CASE("max_size: can allocate max_size more than once") { { object_allocator pool{sizeof(__oa_page)}; CHECK_NOTHROW(pool.allocate()); CHECK_NOTHROW(pool.allocate()); CHECK_NOTHROW(pool.allocate()); CHECK(pool.page_stack_size() == 1); CHECK(pool.objt_stack_size() == 1); CHECK(pool.num_page() == 3); CHECK(pool.num_free() == 0); CHECK(pool.num_used() == 3); } CHECK(!g_allocated_pages.empty()); auto pages = g_allocated_pages; for (const auto &ptr : pages) { free_page(ptr); } g_allocated_pages.clear(); } TEST_CASE("allocate: contains") { { uint64_t test; object_allocator pool{sizeof(uint64_t)}; auto ptr1 = pool.allocate(); auto ptr2 = pool.allocate(); auto ptr3 = pool.allocate(); auto ptr4 = pool.allocate(); CHECK(pool.contains(ptr1)); CHECK(pool.contains(ptr2)); CHECK(pool.contains(ptr3)); CHECK(pool.contains(ptr4)); CHECK(!pool.contains(&test)); pool.deallocate(ptr1); pool.deallocate(ptr2); pool.deallocate(ptr3); pool.deallocate(ptr4); } CHECK(g_allocated_pages.empty()); }
[ "rianquinn@gmail.com" ]
rianquinn@gmail.com
ec993d3f5f87bb88bf509bb9a52a31429b423b26
daddcd10bf097ab3b5b3d28bfac9270b85a411d4
/dev/floyd_speak/libs/Celero-master/experiments/DemoToString/DemoToString.cpp
f825b2e5a9e0d8167267de55e172f3b12ee8591a
[ "Apache-2.0", "MIT" ]
permissive
lemonad/floyd
0cc3eb1b7eff833c6425d33f38cc32e2f0447687
736d21f20d1bdab7082b4461d7b6330cb4b10224
refs/heads/master
2020-04-25T05:00:42.971717
2019-02-25T21:52:22
2019-02-25T21:52:22
172,528,934
0
0
MIT
2019-02-25T15:11:27
2019-02-25T15:13:07
null
UTF-8
C++
false
false
2,966
cpp
#include <celero/Celero.h> #include <cstdlib> #include <sstream> /// /// This is the main(int argc, char** argv) for the entire celero program. /// You can write your own, or use this macro to insert the standard one into the project. /// CELERO_MAIN const std::string uint8str[50] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49"}; struct itostr_helper { static unsigned out[10000]; itostr_helper() { for(int i = 0; i < 10000; i++) { unsigned v = i; char* o = (char*)(out + i); o[3] = v % 10 + '0'; o[2] = (v % 100) / 10 + '0'; o[1] = static_cast<char>((v % 1000) / 100 + '0'); o[0] = static_cast<char>((v % 10000) / 1000); if(o[0]) { o[0] |= 0x30; } else if(o[1] != '0') { o[0] |= 0x20; } else if(o[2] != '0') { o[0] |= 0x10; } else { o[0] |= 0x00; } } } }; unsigned itostr_helper::out[10000]; itostr_helper hlp_init; template <typename T> std::string hopmanFast(T o) { typedef itostr_helper hlp; unsigned blocks[3], *b = blocks + 2; blocks[0] = o < 0 ? ~o + 1 : o; blocks[2] = blocks[0] % 10000; blocks[0] /= 10000; blocks[2] = hlp::out[blocks[2]]; if(blocks[0]) { blocks[1] = blocks[0] % 10000; blocks[0] /= 10000; blocks[1] = hlp::out[blocks[1]]; blocks[2] |= 0x30303030; b--; } if(blocks[0]) { blocks[0] = hlp::out[blocks[0] % 10000]; blocks[1] |= 0x30303030; b--; } char* f = ((char*)b); f += 3 - (*f >> 4); char* str = (char*)blocks; if(o < 0) { *--f = '-'; } return std::string(f, (str + 12) - f); } BASELINE(DemoToString, Baseline, 10000, 1000) { const int x = celero::Random() % 42; celero::DoNotOptimizeAway(x); celero::DoNotOptimizeAway(std::string("42")); } BENCHMARK(DemoToString, to_string, 10000, 1000) { const int x = celero::Random() % 42; celero::DoNotOptimizeAway(x); celero::DoNotOptimizeAway(std::to_string(x)); } BENCHMARK(DemoToString, stringstream, 10000, 1000) { const int x = celero::Random() % 42; celero::DoNotOptimizeAway(x); std::stringstream ss; ss << x; celero::DoNotOptimizeAway(ss.str()); } BENCHMARK(DemoToString, table, 10000, 1000) { const int x = celero::Random() % 42; celero::DoNotOptimizeAway(x); celero::DoNotOptimizeAway(uint8str[x]); } #ifdef _itoa // Not supported for all compilers BENCHMARK(DemoToString, itoa, 10000, 1000) { const int x = rand() % 42; celero::DoNotOptimizeAway(x); char buffer[64]; _itoa(x, buffer, 10); celero::DoNotOptimizeAway(std::string(buffer)); } #endif /// http://ideone.com/GkPcy BENCHMARK(DemoToString, hopmanFast, 10000, 1000) { const int x = celero::Random() % 42; celero::DoNotOptimizeAway(x); celero::DoNotOptimizeAway(std::string(hopmanFast(x))); }
[ "marcus.zetterquist@gmail.com" ]
marcus.zetterquist@gmail.com
20826ccbfb1c0db1722db51603875e4751de1251
6d0c83e5935251fca6108c75e19666737edafe29
/runtime/linux64/include/webm/mkvmuxer.hpp
da00c8f4ccb1f000d24b7f1d8ea00e88cf4d46e8
[ "BSD-3-Clause" ]
permissive
ssincak/webmPlayer
7a64951bbf91e966d76a58134fd6138628c5738b
45d444f5c6cc2effb8558b3aa77e7ddb9d4296e9
refs/heads/master
2023-05-29T17:19:44.849366
2021-02-14T20:09:48
2021-02-14T20:09:48
338,888,425
6
1
BSD-3-Clause
2023-05-16T22:37:48
2021-02-14T19:50:43
C
UTF-8
C++
false
false
52,747
hpp
// Copyright (c) 2012 The WebM 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 in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. #ifndef MKVMUXER_HPP #define MKVMUXER_HPP #include "mkvmuxertypes.hpp" // For a description of the WebM elements see // http://www.webmproject.org/code/specs/container/. namespace mkvparser { class IMkvReader; } // end namespace namespace mkvmuxer { class MkvWriter; class Segment; const uint64 kMaxTrackNumber = 126; /////////////////////////////////////////////////////////////// // Interface used by the mkvmuxer to write out the Mkv data. class IMkvWriter { public: // Writes out |len| bytes of |buf|. Returns 0 on success. virtual int32 Write(const void* buf, uint32 len) = 0; // Returns the offset of the output position from the beginning of the // output. virtual int64 Position() const = 0; // Set the current File position. Returns 0 on success. virtual int32 Position(int64 position) = 0; // Returns true if the writer is seekable. virtual bool Seekable() const = 0; // Element start notification. Called whenever an element identifier is about // to be written to the stream. |element_id| is the element identifier, and // |position| is the location in the WebM stream where the first octet of the // element identifier will be written. // Note: the |MkvId| enumeration in webmids.hpp defines element values. virtual void ElementStartNotify(uint64 element_id, int64 position) = 0; protected: IMkvWriter(); virtual ~IMkvWriter(); private: LIBWEBM_DISALLOW_COPY_AND_ASSIGN(IMkvWriter); }; // Writes out the EBML header for a WebM file. This function must be called // before any other libwebm writing functions are called. bool WriteEbmlHeader(IMkvWriter* writer, uint64 doc_type_version); // Deprecated. Writes out EBML header with doc_type_version as // kDefaultDocTypeVersion. Exists for backward compatibility. bool WriteEbmlHeader(IMkvWriter* writer); // Copies in Chunk from source to destination between the given byte positions bool ChunkedCopy(mkvparser::IMkvReader* source, IMkvWriter* dst, int64 start, int64 size); /////////////////////////////////////////////////////////////// // Class to hold data the will be written to a block. class Frame { public: Frame(); ~Frame(); // Sets this frame's contents based on |frame|. Returns true on success. On // failure, this frame's existing contents may be lost. bool CopyFrom(const Frame& frame); // Copies |frame| data into |frame_|. Returns true on success. bool Init(const uint8* frame, uint64 length); // Copies |additional| data into |additional_|. Returns true on success. bool AddAdditionalData(const uint8* additional, uint64 length, uint64 add_id); // Returns true if the frame has valid parameters. bool IsValid() const; // Returns true if the frame can be written as a SimpleBlock based on current // parameters. bool CanBeSimpleBlock() const; uint64 add_id() const { return add_id_; } const uint8* additional() const { return additional_; } uint64 additional_length() const { return additional_length_; } void set_duration(uint64 duration) { duration_ = duration; } uint64 duration() const { return duration_; } const uint8* frame() const { return frame_; } void set_is_key(bool key) { is_key_ = key; } bool is_key() const { return is_key_; } uint64 length() const { return length_; } void set_track_number(uint64 track_number) { track_number_ = track_number; } uint64 track_number() const { return track_number_; } void set_timestamp(uint64 timestamp) { timestamp_ = timestamp; } uint64 timestamp() const { return timestamp_; } void set_discard_padding(int64 discard_padding) { discard_padding_ = discard_padding; } int64 discard_padding() const { return discard_padding_; } void set_reference_block_timestamp(int64 reference_block_timestamp); int64 reference_block_timestamp() const { return reference_block_timestamp_; } bool reference_block_timestamp_set() const { return reference_block_timestamp_set_; } private: // Id of the Additional data. uint64 add_id_; // Pointer to additional data. Owned by this class. uint8* additional_; // Length of the additional data. uint64 additional_length_; // Duration of the frame in nanoseconds. uint64 duration_; // Pointer to the data. Owned by this class. uint8* frame_; // Flag telling if the data should set the key flag of a block. bool is_key_; // Length of the data. uint64 length_; // Mkv track number the data is associated with. uint64 track_number_; // Timestamp of the data in nanoseconds. uint64 timestamp_; // Discard padding for the frame. int64 discard_padding_; // Reference block timestamp. int64 reference_block_timestamp_; // Flag indicating if |reference_block_timestamp_| has been set. bool reference_block_timestamp_set_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Frame); }; /////////////////////////////////////////////////////////////// // Class to hold one cue point in a Cues element. class CuePoint { public: CuePoint(); ~CuePoint(); // Returns the size in bytes for the entire CuePoint element. uint64 Size() const; // Output the CuePoint element to the writer. Returns true on success. bool Write(IMkvWriter* writer) const; void set_time(uint64 time) { time_ = time; } uint64 time() const { return time_; } void set_track(uint64 track) { track_ = track; } uint64 track() const { return track_; } void set_cluster_pos(uint64 cluster_pos) { cluster_pos_ = cluster_pos; } uint64 cluster_pos() const { return cluster_pos_; } void set_block_number(uint64 block_number) { block_number_ = block_number; } uint64 block_number() const { return block_number_; } void set_output_block_number(bool output_block_number) { output_block_number_ = output_block_number; } bool output_block_number() const { return output_block_number_; } private: // Returns the size in bytes for the payload of the CuePoint element. uint64 PayloadSize() const; // Absolute timecode according to the segment time base. uint64 time_; // The Track element associated with the CuePoint. uint64 track_; // The position of the Cluster containing the Block. uint64 cluster_pos_; // Number of the Block within the Cluster, starting from 1. uint64 block_number_; // If true the muxer will write out the block number for the cue if the // block number is different than the default of 1. Default is set to true. bool output_block_number_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(CuePoint); }; /////////////////////////////////////////////////////////////// // Cues element. class Cues { public: Cues(); ~Cues(); // Adds a cue point to the Cues element. Returns true on success. bool AddCue(CuePoint* cue); // Returns the cue point by index. Returns NULL if there is no cue point // match. CuePoint* GetCueByIndex(int32 index) const; // Returns the total size of the Cues element uint64 Size(); // Output the Cues element to the writer. Returns true on success. bool Write(IMkvWriter* writer) const; int32 cue_entries_size() const { return cue_entries_size_; } void set_output_block_number(bool output_block_number) { output_block_number_ = output_block_number; } bool output_block_number() const { return output_block_number_; } private: // Number of allocated elements in |cue_entries_|. int32 cue_entries_capacity_; // Number of CuePoints in |cue_entries_|. int32 cue_entries_size_; // CuePoint list. CuePoint** cue_entries_; // If true the muxer will write out the block number for the cue if the // block number is different than the default of 1. Default is set to true. bool output_block_number_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Cues); }; /////////////////////////////////////////////////////////////// // ContentEncAESSettings element class ContentEncAESSettings { public: enum { kCTR = 1 }; ContentEncAESSettings(); ~ContentEncAESSettings() {} // Returns the size in bytes for the ContentEncAESSettings element. uint64 Size() const; // Writes out the ContentEncAESSettings element to |writer|. Returns true on // success. bool Write(IMkvWriter* writer) const; uint64 cipher_mode() const { return cipher_mode_; } private: // Returns the size in bytes for the payload of the ContentEncAESSettings // element. uint64 PayloadSize() const; // Sub elements uint64 cipher_mode_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(ContentEncAESSettings); }; /////////////////////////////////////////////////////////////// // ContentEncoding element // Elements used to describe if the track data has been encrypted or // compressed with zlib or header stripping. // Currently only whole frames can be encrypted with AES. This dictates that // ContentEncodingOrder will be 0, ContentEncodingScope will be 1, // ContentEncodingType will be 1, and ContentEncAlgo will be 5. class ContentEncoding { public: ContentEncoding(); ~ContentEncoding(); // Sets the content encryption id. Copies |length| bytes from |id| to // |enc_key_id_|. Returns true on success. bool SetEncryptionID(const uint8* id, uint64 length); // Returns the size in bytes for the ContentEncoding element. uint64 Size() const; // Writes out the ContentEncoding element to |writer|. Returns true on // success. bool Write(IMkvWriter* writer) const; uint64 enc_algo() const { return enc_algo_; } uint64 encoding_order() const { return encoding_order_; } uint64 encoding_scope() const { return encoding_scope_; } uint64 encoding_type() const { return encoding_type_; } ContentEncAESSettings* enc_aes_settings() { return &enc_aes_settings_; } private: // Returns the size in bytes for the encoding elements. uint64 EncodingSize(uint64 compresion_size, uint64 encryption_size) const; // Returns the size in bytes for the encryption elements. uint64 EncryptionSize() const; // Track element names uint64 enc_algo_; uint8* enc_key_id_; uint64 encoding_order_; uint64 encoding_scope_; uint64 encoding_type_; // ContentEncAESSettings element. ContentEncAESSettings enc_aes_settings_; // Size of the ContentEncKeyID data in bytes. uint64 enc_key_id_length_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(ContentEncoding); }; /////////////////////////////////////////////////////////////// // Track element. class Track { public: // The |seed| parameter is used to synthesize a UID for the track. explicit Track(unsigned int* seed); virtual ~Track(); // Adds a ContentEncoding element to the Track. Returns true on success. virtual bool AddContentEncoding(); // Returns the ContentEncoding by index. Returns NULL if there is no // ContentEncoding match. ContentEncoding* GetContentEncodingByIndex(uint32 index) const; // Returns the size in bytes for the payload of the Track element. virtual uint64 PayloadSize() const; // Returns the size in bytes of the Track element. virtual uint64 Size() const; // Output the Track element to the writer. Returns true on success. virtual bool Write(IMkvWriter* writer) const; // Sets the CodecPrivate element of the Track element. Copies |length| // bytes from |codec_private| to |codec_private_|. Returns true on success. bool SetCodecPrivate(const uint8* codec_private, uint64 length); void set_codec_id(const char* codec_id); const char* codec_id() const { return codec_id_; } const uint8* codec_private() const { return codec_private_; } void set_language(const char* language); const char* language() const { return language_; } void set_max_block_additional_id(uint64 max_block_additional_id) { max_block_additional_id_ = max_block_additional_id; } uint64 max_block_additional_id() const { return max_block_additional_id_; } void set_name(const char* name); const char* name() const { return name_; } void set_number(uint64 number) { number_ = number; } uint64 number() const { return number_; } void set_type(uint64 type) { type_ = type; } uint64 type() const { return type_; } void set_uid(uint64 uid) { uid_ = uid; } uint64 uid() const { return uid_; } void set_codec_delay(uint64 codec_delay) { codec_delay_ = codec_delay; } uint64 codec_delay() const { return codec_delay_; } void set_seek_pre_roll(uint64 seek_pre_roll) { seek_pre_roll_ = seek_pre_roll; } uint64 seek_pre_roll() const { return seek_pre_roll_; } void set_default_duration(uint64 default_duration) { default_duration_ = default_duration; } uint64 default_duration() const { return default_duration_; } uint64 codec_private_length() const { return codec_private_length_; } uint32 content_encoding_entries_size() const { return content_encoding_entries_size_; } private: // Track element names. char* codec_id_; uint8* codec_private_; char* language_; uint64 max_block_additional_id_; char* name_; uint64 number_; uint64 type_; uint64 uid_; uint64 codec_delay_; uint64 seek_pre_roll_; uint64 default_duration_; // Size of the CodecPrivate data in bytes. uint64 codec_private_length_; // ContentEncoding element list. ContentEncoding** content_encoding_entries_; // Number of ContentEncoding elements added. uint32 content_encoding_entries_size_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Track); }; /////////////////////////////////////////////////////////////// // Track that has video specific elements. class VideoTrack : public Track { public: // Supported modes for stereo 3D. enum StereoMode { kMono = 0, kSideBySideLeftIsFirst = 1, kTopBottomRightIsFirst = 2, kTopBottomLeftIsFirst = 3, kSideBySideRightIsFirst = 11 }; enum AlphaMode { kNoAlpha = 0, kAlpha = 1 }; // The |seed| parameter is used to synthesize a UID for the track. explicit VideoTrack(unsigned int* seed); virtual ~VideoTrack(); // Returns the size in bytes for the payload of the Track element plus the // video specific elements. virtual uint64 PayloadSize() const; // Output the VideoTrack element to the writer. Returns true on success. virtual bool Write(IMkvWriter* writer) const; // Sets the video's stereo mode. Returns true on success. bool SetStereoMode(uint64 stereo_mode); // Sets the video's alpha mode. Returns true on success. bool SetAlphaMode(uint64 alpha_mode); void set_display_height(uint64 height) { display_height_ = height; } uint64 display_height() const { return display_height_; } void set_display_width(uint64 width) { display_width_ = width; } uint64 display_width() const { return display_width_; } void set_crop_left(uint64 crop_left) { crop_left_ = crop_left; } uint64 crop_left() const { return crop_left_; } void set_crop_right(uint64 crop_right) { crop_right_ = crop_right; } uint64 crop_right() const { return crop_right_; } void set_crop_top(uint64 crop_top) { crop_top_ = crop_top; } uint64 crop_top() const { return crop_top_; } void set_crop_bottom(uint64 crop_bottom) { crop_bottom_ = crop_bottom; } uint64 crop_bottom() const { return crop_bottom_; } void set_frame_rate(double frame_rate) { frame_rate_ = frame_rate; } double frame_rate() const { return frame_rate_; } void set_height(uint64 height) { height_ = height; } uint64 height() const { return height_; } uint64 stereo_mode() { return stereo_mode_; } uint64 alpha_mode() { return alpha_mode_; } void set_width(uint64 width) { width_ = width; } uint64 width() const { return width_; } private: // Returns the size in bytes of the Video element. uint64 VideoPayloadSize() const; // Video track element names. uint64 display_height_; uint64 display_width_; uint64 crop_left_; uint64 crop_right_; uint64 crop_top_; uint64 crop_bottom_; double frame_rate_; uint64 height_; uint64 stereo_mode_; uint64 alpha_mode_; uint64 width_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(VideoTrack); }; /////////////////////////////////////////////////////////////// // Track that has audio specific elements. class AudioTrack : public Track { public: // The |seed| parameter is used to synthesize a UID for the track. explicit AudioTrack(unsigned int* seed); virtual ~AudioTrack(); // Returns the size in bytes for the payload of the Track element plus the // audio specific elements. virtual uint64 PayloadSize() const; // Output the AudioTrack element to the writer. Returns true on success. virtual bool Write(IMkvWriter* writer) const; void set_bit_depth(uint64 bit_depth) { bit_depth_ = bit_depth; } uint64 bit_depth() const { return bit_depth_; } void set_channels(uint64 channels) { channels_ = channels; } uint64 channels() const { return channels_; } void set_sample_rate(double sample_rate) { sample_rate_ = sample_rate; } double sample_rate() const { return sample_rate_; } private: // Audio track element names. uint64 bit_depth_; uint64 channels_; double sample_rate_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(AudioTrack); }; /////////////////////////////////////////////////////////////// // Tracks element class Tracks { public: // Audio and video type defined by the Matroska specs. enum { kVideo = 0x1, kAudio = 0x2 }; static const char kOpusCodecId[]; static const char kVorbisCodecId[]; static const char kVp8CodecId[]; static const char kVp9CodecId[]; static const char kVp10CodecId[]; Tracks(); ~Tracks(); // Adds a Track element to the Tracks object. |track| will be owned and // deleted by the Tracks object. Returns true on success. |number| is the // number to use for the track. |number| must be >= 0. If |number| == 0 // then the muxer will decide on the track number. bool AddTrack(Track* track, int32 number); // Returns the track by index. Returns NULL if there is no track match. const Track* GetTrackByIndex(uint32 idx) const; // Search the Tracks and return the track that matches |tn|. Returns NULL // if there is no track match. Track* GetTrackByNumber(uint64 track_number) const; // Returns true if the track number is an audio track. bool TrackIsAudio(uint64 track_number) const; // Returns true if the track number is a video track. bool TrackIsVideo(uint64 track_number) const; // Output the Tracks element to the writer. Returns true on success. bool Write(IMkvWriter* writer) const; uint32 track_entries_size() const { return track_entries_size_; } private: // Track element list. Track** track_entries_; // Number of Track elements added. uint32 track_entries_size_; // Whether or not Tracks element has already been written via IMkvWriter. mutable bool wrote_tracks_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Tracks); }; /////////////////////////////////////////////////////////////// // Chapter element // class Chapter { public: // Set the identifier for this chapter. (This corresponds to the // Cue Identifier line in WebVTT.) // TODO(matthewjheaney): the actual serialization of this item in // MKV is pending. bool set_id(const char* id); // Converts the nanosecond start and stop times of this chapter to // their corresponding timecode values, and stores them that way. void set_time(const Segment& segment, uint64 start_time_ns, uint64 end_time_ns); // Sets the uid for this chapter. Primarily used to enable // deterministic output from the muxer. void set_uid(const uint64 uid) { uid_ = uid; } // Add a title string to this chapter, per the semantics described // here: // http://www.matroska.org/technical/specs/index.html // // The title ("chapter string") is a UTF-8 string. // // The language has ISO 639-2 representation, described here: // http://www.loc.gov/standards/iso639-2/englangn.html // http://www.loc.gov/standards/iso639-2/php/English_list.php // If you specify NULL as the language value, this implies // English ("eng"). // // The country value corresponds to the codes listed here: // http://www.iana.org/domains/root/db/ // // The function returns false if the string could not be allocated. bool add_string(const char* title, const char* language, const char* country); private: friend class Chapters; // For storage of chapter titles that differ by language. class Display { public: // Establish representation invariant for new Display object. void Init(); // Reclaim resources, in anticipation of destruction. void Clear(); // Copies the title to the |title_| member. Returns false on // error. bool set_title(const char* title); // Copies the language to the |language_| member. Returns false // on error. bool set_language(const char* language); // Copies the country to the |country_| member. Returns false on // error. bool set_country(const char* country); // If |writer| is non-NULL, serialize the Display sub-element of // the Atom into the stream. Returns the Display element size on // success, 0 if error. uint64 WriteDisplay(IMkvWriter* writer) const; private: char* title_; char* language_; char* country_; }; Chapter(); ~Chapter(); // Establish the representation invariant for a newly-created // Chapter object. The |seed| parameter is used to create the UID // for this chapter atom. void Init(unsigned int* seed); // Copies this Chapter object to a different one. This is used when // expanding a plain array of Chapter objects (see Chapters). void ShallowCopy(Chapter* dst) const; // Reclaim resources used by this Chapter object, pending its // destruction. void Clear(); // If there is no storage remaining on the |displays_| array for a // new display object, creates a new, longer array and copies the // existing Display objects to the new array. Returns false if the // array cannot be expanded. bool ExpandDisplaysArray(); // If |writer| is non-NULL, serialize the Atom sub-element into the // stream. Returns the total size of the element on success, 0 if // error. uint64 WriteAtom(IMkvWriter* writer) const; // The string identifier for this chapter (corresponds to WebVTT cue // identifier). char* id_; // Start timecode of the chapter. uint64 start_timecode_; // Stop timecode of the chapter. uint64 end_timecode_; // The binary identifier for this chapter. uint64 uid_; // The Atom element can contain multiple Display sub-elements, as // the same logical title can be rendered in different languages. Display* displays_; // The physical length (total size) of the |displays_| array. int displays_size_; // The logical length (number of active elements) on the |displays_| // array. int displays_count_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Chapter); }; /////////////////////////////////////////////////////////////// // Chapters element // class Chapters { public: Chapters(); ~Chapters(); Chapter* AddChapter(unsigned int* seed); // Returns the number of chapters that have been added. int Count() const; // Output the Chapters element to the writer. Returns true on success. bool Write(IMkvWriter* writer) const; private: // Expands the chapters_ array if there is not enough space to contain // another chapter object. Returns true on success. bool ExpandChaptersArray(); // If |writer| is non-NULL, serialize the Edition sub-element of the // Chapters element into the stream. Returns the Edition element // size on success, 0 if error. uint64 WriteEdition(IMkvWriter* writer) const; // Total length of the chapters_ array. int chapters_size_; // Number of active chapters on the chapters_ array. int chapters_count_; // Array for storage of chapter objects. Chapter* chapters_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Chapters); }; /////////////////////////////////////////////////////////////// // Tag element // class Tag { public: bool add_simple_tag(const char* tag_name, const char* tag_string); private: // Tags calls Clear and the destructor of Tag friend class Tags; // For storage of simple tags class SimpleTag { public: // Establish representation invariant for new SimpleTag object. void Init(); // Reclaim resources, in anticipation of destruction. void Clear(); // Copies the title to the |tag_name_| member. Returns false on // error. bool set_tag_name(const char* tag_name); // Copies the language to the |tag_string_| member. Returns false // on error. bool set_tag_string(const char* tag_string); // If |writer| is non-NULL, serialize the SimpleTag sub-element of // the Atom into the stream. Returns the SimpleTag element size on // success, 0 if error. uint64 Write(IMkvWriter* writer) const; private: char* tag_name_; char* tag_string_; }; Tag(); ~Tag(); // Copies this Tag object to a different one. This is used when // expanding a plain array of Tag objects (see Tags). void ShallowCopy(Tag* dst) const; // Reclaim resources used by this Tag object, pending its // destruction. void Clear(); // If there is no storage remaining on the |simple_tags_| array for a // new display object, creates a new, longer array and copies the // existing SimpleTag objects to the new array. Returns false if the // array cannot be expanded. bool ExpandSimpleTagsArray(); // If |writer| is non-NULL, serialize the Tag sub-element into the // stream. Returns the total size of the element on success, 0 if // error. uint64 Write(IMkvWriter* writer) const; // The Atom element can contain multiple SimpleTag sub-elements SimpleTag* simple_tags_; // The physical length (total size) of the |simple_tags_| array. int simple_tags_size_; // The logical length (number of active elements) on the |simple_tags_| // array. int simple_tags_count_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Tag); }; /////////////////////////////////////////////////////////////// // Tags element // class Tags { public: Tags(); ~Tags(); Tag* AddTag(); // Returns the number of tags that have been added. int Count() const; // Output the Tags element to the writer. Returns true on success. bool Write(IMkvWriter* writer) const; private: // Expands the tags_ array if there is not enough space to contain // another tag object. Returns true on success. bool ExpandTagsArray(); // Total length of the tags_ array. int tags_size_; // Number of active tags on the tags_ array. int tags_count_; // Array for storage of tag objects. Tag* tags_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Tags); }; /////////////////////////////////////////////////////////////// // Cluster element // // Notes: // |Init| must be called before any other method in this class. class Cluster { public: // |timecode| is the absolute timecode of the cluster. |cues_pos| is the // position for the cluster within the segment that should be written in // the cues element. |timecode_scale| is the timecode scale of the segment. Cluster(uint64 timecode, int64 cues_pos, uint64 timecode_scale); ~Cluster(); bool Init(IMkvWriter* ptr_writer); // Adds a frame to be output in the file. The frame is written out through // |writer_| if successful. Returns true on success. bool AddFrame(const Frame* frame); // Adds a frame to be output in the file. The frame is written out through // |writer_| if successful. Returns true on success. // Inputs: // data: Pointer to the data // length: Length of the data // track_number: Track to add the data to. Value returned by Add track // functions. The range of allowed values is [1, 126]. // timecode: Absolute (not relative to cluster) timestamp of the // frame, expressed in timecode units. // is_key: Flag telling whether or not this frame is a key frame. bool AddFrame(const uint8* data, uint64 length, uint64 track_number, uint64 timecode, // timecode units (absolute) bool is_key); // Adds a frame to be output in the file. The frame is written out through // |writer_| if successful. Returns true on success. // Inputs: // data: Pointer to the data // length: Length of the data // additional: Pointer to the additional data // additional_length: Length of the additional data // add_id: Value of BlockAddID element // track_number: Track to add the data to. Value returned by Add track // functions. The range of allowed values is [1, 126]. // abs_timecode: Absolute (not relative to cluster) timestamp of the // frame, expressed in timecode units. // is_key: Flag telling whether or not this frame is a key frame. bool AddFrameWithAdditional(const uint8* data, uint64 length, const uint8* additional, uint64 additional_length, uint64 add_id, uint64 track_number, uint64 abs_timecode, bool is_key); // Adds a frame to be output in the file. The frame is written out through // |writer_| if successful. Returns true on success. // Inputs: // data: Pointer to the data. // length: Length of the data. // discard_padding: DiscardPadding element value. // track_number: Track to add the data to. Value returned by Add track // functions. The range of allowed values is [1, 126]. // abs_timecode: Absolute (not relative to cluster) timestamp of the // frame, expressed in timecode units. // is_key: Flag telling whether or not this frame is a key frame. bool AddFrameWithDiscardPadding(const uint8* data, uint64 length, int64 discard_padding, uint64 track_number, uint64 abs_timecode, bool is_key); // Writes a frame of metadata to the output medium; returns true on // success. // Inputs: // data: Pointer to the data // length: Length of the data // track_number: Track to add the data to. Value returned by Add track // functions. The range of allowed values is [1, 126]. // timecode: Absolute (not relative to cluster) timestamp of the // metadata frame, expressed in timecode units. // duration: Duration of metadata frame, in timecode units. // // The metadata frame is written as a block group, with a duration // sub-element but no reference time sub-elements (indicating that // it is considered a keyframe, per Matroska semantics). bool AddMetadata(const uint8* data, uint64 length, uint64 track_number, uint64 timecode, uint64 duration); // Increments the size of the cluster's data in bytes. void AddPayloadSize(uint64 size); // Closes the cluster so no more data can be written to it. Will update the // cluster's size if |writer_| is seekable. Returns true on success. bool Finalize(); // Returns the size in bytes for the entire Cluster element. uint64 Size() const; // Given |abs_timecode|, calculates timecode relative to most recent timecode. // Returns -1 on failure, or a relative timecode. int64 GetRelativeTimecode(int64 abs_timecode) const; int64 size_position() const { return size_position_; } int32 blocks_added() const { return blocks_added_; } uint64 payload_size() const { return payload_size_; } int64 position_for_cues() const { return position_for_cues_; } uint64 timecode() const { return timecode_; } uint64 timecode_scale() const { return timecode_scale_; } private: // Utility method that confirms that blocks can still be added, and that the // cluster header has been written. Used by |DoWriteFrame*|. Returns true // when successful. bool PreWriteBlock(); // Utility method used by the |DoWriteFrame*| methods that handles the book // keeping required after each block is written. void PostWriteBlock(uint64 element_size); // Does some verification and calls WriteFrame. bool DoWriteFrame(const Frame* const frame); // Outputs the Cluster header to |writer_|. Returns true on success. bool WriteClusterHeader(); // Number of blocks added to the cluster. int32 blocks_added_; // Flag telling if the cluster has been closed. bool finalized_; // Flag telling if the cluster's header has been written. bool header_written_; // The size of the cluster elements in bytes. uint64 payload_size_; // The file position used for cue points. const int64 position_for_cues_; // The file position of the cluster's size element. int64 size_position_; // The absolute timecode of the cluster. const uint64 timecode_; // The timecode scale of the Segment containing the cluster. const uint64 timecode_scale_; // Pointer to the writer object. Not owned by this class. IMkvWriter* writer_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Cluster); }; /////////////////////////////////////////////////////////////// // SeekHead element class SeekHead { public: SeekHead(); ~SeekHead(); // TODO(fgalligan): Change this to reserve a certain size. Then check how // big the seek entry to be added is as not every seek entry will be the // maximum size it could be. // Adds a seek entry to be written out when the element is finalized. |id| // must be the coded mkv element id. |pos| is the file position of the // element. Returns true on success. bool AddSeekEntry(uint32 id, uint64 pos); // Writes out SeekHead and SeekEntry elements. Returns true on success. bool Finalize(IMkvWriter* writer) const; // Returns the id of the Seek Entry at the given index. Returns -1 if index is // out of range. uint32 GetId(int index) const; // Returns the position of the Seek Entry at the given index. Returns -1 if // index is out of range. uint64 GetPosition(int index) const; // Sets the Seek Entry id and position at given index. // Returns true on success. bool SetSeekEntry(int index, uint32 id, uint64 position); // Reserves space by writing out a Void element which will be updated with // a SeekHead element later. Returns true on success. bool Write(IMkvWriter* writer); // We are going to put a cap on the number of Seek Entries. const static int32 kSeekEntryCount = 5; private: // Returns the maximum size in bytes of one seek entry. uint64 MaxEntrySize() const; // Seek entry id element list. uint32 seek_entry_id_[kSeekEntryCount]; // Seek entry pos element list. uint64 seek_entry_pos_[kSeekEntryCount]; // The file position of SeekHead element. int64 start_pos_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(SeekHead); }; /////////////////////////////////////////////////////////////// // Segment Information element class SegmentInfo { public: SegmentInfo(); ~SegmentInfo(); // Will update the duration if |duration_| is > 0.0. Returns true on success. bool Finalize(IMkvWriter* writer) const; // Sets |muxing_app_| and |writing_app_|. bool Init(); // Output the Segment Information element to the writer. Returns true on // success. bool Write(IMkvWriter* writer); void set_duration(double duration) { duration_ = duration; } double duration() const { return duration_; } void set_muxing_app(const char* app); const char* muxing_app() const { return muxing_app_; } void set_timecode_scale(uint64 scale) { timecode_scale_ = scale; } uint64 timecode_scale() const { return timecode_scale_; } void set_writing_app(const char* app); const char* writing_app() const { return writing_app_; } void set_date_utc(int64 date_utc) { date_utc_ = date_utc; } int64 date_utc() const { return date_utc_; } private: // Segment Information element names. // Initially set to -1 to signify that a duration has not been set and should // not be written out. double duration_; // Set to libwebm-%d.%d.%d.%d, major, minor, build, revision. char* muxing_app_; uint64 timecode_scale_; // Initially set to libwebm-%d.%d.%d.%d, major, minor, build, revision. char* writing_app_; // LLONG_MIN when DateUTC is not set. int64 date_utc_; // The file position of the duration element. int64 duration_pos_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(SegmentInfo); }; /////////////////////////////////////////////////////////////// // This class represents the main segment in a WebM file. Currently only // supports one Segment element. // // Notes: // |Init| must be called before any other method in this class. class Segment { public: enum Mode { kLive = 0x1, kFile = 0x2 }; enum CuesPosition { kAfterClusters = 0x0, // Position Cues after Clusters - Default kBeforeClusters = 0x1 // Position Cues before Clusters }; const static uint32 kDefaultDocTypeVersion = 2; const static uint64 kDefaultMaxClusterDuration = 30000000000ULL; Segment(); ~Segment(); // Initializes |SegmentInfo| and returns result. Always returns false when // |ptr_writer| is NULL. bool Init(IMkvWriter* ptr_writer); // Adds a generic track to the segment. Returns the newly-allocated // track object (which is owned by the segment) on success, NULL on // error. |number| is the number to use for the track. |number| // must be >= 0. If |number| == 0 then the muxer will decide on the // track number. Track* AddTrack(int32 number); // Adds a Vorbis audio track to the segment. Returns the number of the track // on success, 0 on error. |number| is the number to use for the audio track. // |number| must be >= 0. If |number| == 0 then the muxer will decide on // the track number. uint64 AddAudioTrack(int32 sample_rate, int32 channels, int32 number); // Adds an empty chapter to the chapters of this segment. Returns // non-NULL on success. After adding the chapter, the caller should // populate its fields via the Chapter member functions. Chapter* AddChapter(); // Adds an empty tag to the tags of this segment. Returns // non-NULL on success. After adding the tag, the caller should // populate its fields via the Tag member functions. Tag* AddTag(); // Adds a cue point to the Cues element. |timestamp| is the time in // nanoseconds of the cue's time. |track| is the Track of the Cue. This // function must be called after AddFrame to calculate the correct // BlockNumber for the CuePoint. Returns true on success. bool AddCuePoint(uint64 timestamp, uint64 track); // Adds a frame to be output in the file. Returns true on success. // Inputs: // data: Pointer to the data // length: Length of the data // track_number: Track to add the data to. Value returned by Add track // functions. // timestamp: Timestamp of the frame in nanoseconds from 0. // is_key: Flag telling whether or not this frame is a key frame. bool AddFrame(const uint8* data, uint64 length, uint64 track_number, uint64 timestamp_ns, bool is_key); // Writes a frame of metadata to the output medium; returns true on // success. // Inputs: // data: Pointer to the data // length: Length of the data // track_number: Track to add the data to. Value returned by Add track // functions. // timecode: Absolute timestamp of the metadata frame, expressed // in nanosecond units. // duration: Duration of metadata frame, in nanosecond units. // // The metadata frame is written as a block group, with a duration // sub-element but no reference time sub-elements (indicating that // it is considered a keyframe, per Matroska semantics). bool AddMetadata(const uint8* data, uint64 length, uint64 track_number, uint64 timestamp_ns, uint64 duration_ns); // Writes a frame with additional data to the output medium; returns true on // success. // Inputs: // data: Pointer to the data. // length: Length of the data. // additional: Pointer to additional data. // additional_length: Length of additional data. // add_id: Additional ID which identifies the type of additional data. // track_number: Track to add the data to. Value returned by Add track // functions. // timestamp: Absolute timestamp of the frame, expressed in nanosecond // units. // is_key: Flag telling whether or not this frame is a key frame. bool AddFrameWithAdditional(const uint8* data, uint64 length, const uint8* additional, uint64 additional_length, uint64 add_id, uint64 track_number, uint64 timestamp, bool is_key); // Writes a frame with DiscardPadding to the output medium; returns true on // success. // Inputs: // data: Pointer to the data. // length: Length of the data. // discard_padding: DiscardPadding element value. // track_number: Track to add the data to. Value returned by Add track // functions. // timestamp: Absolute timestamp of the frame, expressed in nanosecond // units. // is_key: Flag telling whether or not this frame is a key frame. bool AddFrameWithDiscardPadding(const uint8* data, uint64 length, int64 discard_padding, uint64 track_number, uint64 timestamp, bool is_key); // Writes a Frame to the output medium. Chooses the correct way of writing // the frame (Block vs SimpleBlock) based on the parameters passed. // Inputs: // frame: frame object bool AddGenericFrame(const Frame* frame); // Adds a VP8 video track to the segment. Returns the number of the track on // success, 0 on error. |number| is the number to use for the video track. // |number| must be >= 0. If |number| == 0 then the muxer will decide on // the track number. uint64 AddVideoTrack(int32 width, int32 height, int32 number); // This function must be called after Finalize() if you need a copy of the // output with Cues written before the Clusters. It will return false if the // writer is not seekable of if chunking is set to true. // Input parameters: // reader - an IMkvReader object created with the same underlying file of the // current writer object. Make sure to close the existing writer // object before creating this so that all the data is properly // flushed and available for reading. // writer - an IMkvWriter object pointing to a *different* file than the one // pointed by the current writer object. This file will contain the // Cues element before the Clusters. bool CopyAndMoveCuesBeforeClusters(mkvparser::IMkvReader* reader, IMkvWriter* writer); // Sets which track to use for the Cues element. Must have added the track // before calling this function. Returns true on success. |track_number| is // returned by the Add track functions. bool CuesTrack(uint64 track_number); // This will force the muxer to create a new Cluster when the next frame is // added. void ForceNewClusterOnNextFrame(); // Writes out any frames that have not been written out. Finalizes the last // cluster. May update the size and duration of the segment. May output the // Cues element. May finalize the SeekHead element. Returns true on success. bool Finalize(); // Returns the Cues object. Cues* GetCues() { return &cues_; } // Returns the Segment Information object. const SegmentInfo* GetSegmentInfo() const { return &segment_info_; } SegmentInfo* GetSegmentInfo() { return &segment_info_; } // Search the Tracks and return the track that matches |track_number|. // Returns NULL if there is no track match. Track* GetTrackByNumber(uint64 track_number) const; // Toggles whether to output a cues element. void OutputCues(bool output_cues); // Sets if the muxer will output files in chunks or not. |chunking| is a // flag telling whether or not to turn on chunking. |filename| is the base // filename for the chunk files. The header chunk file will be named // |filename|.hdr and the data chunks will be named // |filename|_XXXXXX.chk. Chunking implies that the muxer will be writing // to files so the muxer will use the default MkvWriter class to control // what data is written to what files. Returns true on success. // TODO: Should we change the IMkvWriter Interface to add Open and Close? // That will force the interface to be dependent on files. bool SetChunking(bool chunking, const char* filename); bool chunking() const { return chunking_; } uint64 cues_track() const { return cues_track_; } void set_max_cluster_duration(uint64 max_cluster_duration) { max_cluster_duration_ = max_cluster_duration; } uint64 max_cluster_duration() const { return max_cluster_duration_; } void set_max_cluster_size(uint64 max_cluster_size) { max_cluster_size_ = max_cluster_size; } uint64 max_cluster_size() const { return max_cluster_size_; } void set_mode(Mode mode) { mode_ = mode; } Mode mode() const { return mode_; } CuesPosition cues_position() const { return cues_position_; } bool output_cues() const { return output_cues_; } const SegmentInfo* segment_info() const { return &segment_info_; } private: // Checks if header information has been output and initialized. If not it // will output the Segment element and initialize the SeekHead elment and // Cues elements. bool CheckHeaderInfo(); // Sets |doc_type_version_| based on the current element requirements. void UpdateDocTypeVersion(); // Sets |name| according to how many chunks have been written. |ext| is the // file extension. |name| must be deleted by the calling app. Returns true // on success. bool UpdateChunkName(const char* ext, char** name) const; // Returns the maximum offset within the segment's payload. When chunking // this function is needed to determine offsets of elements within the // chunked files. Returns -1 on error. int64 MaxOffset(); // Adds the frame to our frame array. bool QueueFrame(Frame* frame); // Output all frames that are queued. Returns -1 on error, otherwise // it returns the number of frames written. int WriteFramesAll(); // Output all frames that are queued that have an end time that is less // then |timestamp|. Returns true on success and if there are no frames // queued. bool WriteFramesLessThan(uint64 timestamp); // Outputs the segment header, Segment Information element, SeekHead element, // and Tracks element to |writer_|. bool WriteSegmentHeader(); // Given a frame with the specified timestamp (nanosecond units) and // keyframe status, determine whether a new cluster should be // created, before writing enqueued frames and the frame itself. The // function returns one of the following values: // -1 = error: an out-of-order frame was detected // 0 = do not create a new cluster, and write frame to the existing cluster // 1 = create a new cluster, and write frame to that new cluster // 2 = create a new cluster, and re-run test int TestFrame(uint64 track_num, uint64 timestamp_ns, bool key) const; // Create a new cluster, using the earlier of the first enqueued // frame, or the indicated time. Returns true on success. bool MakeNewCluster(uint64 timestamp_ns); // Checks whether a new cluster needs to be created, and if so // creates a new cluster. Returns false if creation of a new cluster // was necessary but creation was not successful. bool DoNewClusterProcessing(uint64 track_num, uint64 timestamp_ns, bool key); // Adjusts Cue Point values (to place Cues before Clusters) so that they // reflect the correct offsets. void MoveCuesBeforeClusters(); // This function recursively computes the correct cluster offsets (this is // done to move the Cues before Clusters). It recursively updates the change // in size (which indicates a change in cluster offset) until no sizes change. // Parameters: // diff - indicates the difference in size of the Cues element that needs to // accounted for. // index - index in the list of Cues which is currently being adjusted. // cue_size - sum of size of all the CuePoint elements. void MoveCuesBeforeClustersHelper(uint64 diff, int index, uint64* cue_size); // Seeds the random number generator used to make UIDs. unsigned int seed_; // WebM elements Cues cues_; SeekHead seek_head_; SegmentInfo segment_info_; Tracks tracks_; Chapters chapters_; Tags tags_; // Number of chunks written. int chunk_count_; // Current chunk filename. char* chunk_name_; // Default MkvWriter object created by this class used for writing clusters // out in separate files. MkvWriter* chunk_writer_cluster_; // Default MkvWriter object created by this class used for writing Cues // element out to a file. MkvWriter* chunk_writer_cues_; // Default MkvWriter object created by this class used for writing the // Matroska header out to a file. MkvWriter* chunk_writer_header_; // Flag telling whether or not the muxer is chunking output to multiple // files. bool chunking_; // Base filename for the chunked files. char* chunking_base_name_; // File position offset where the Clusters end. int64 cluster_end_offset_; // List of clusters. Cluster** cluster_list_; // Number of cluster pointers allocated in the cluster list. int32 cluster_list_capacity_; // Number of clusters in the cluster list. int32 cluster_list_size_; // Indicates whether Cues should be written before or after Clusters CuesPosition cues_position_; // Track number that is associated with the cues element for this segment. uint64 cues_track_; // Tells the muxer to force a new cluster on the next Block. bool force_new_cluster_; // List of stored audio frames. These variables are used to store frames so // the muxer can follow the guideline "Audio blocks that contain the video // key frame's timecode should be in the same cluster as the video key frame // block." Frame** frames_; // Number of frame pointers allocated in the frame list. int32 frames_capacity_; // Number of frames in the frame list. int32 frames_size_; // Flag telling if a video track has been added to the segment. bool has_video_; // Flag telling if the segment's header has been written. bool header_written_; // Duration of the last block in nanoseconds. uint64 last_block_duration_; // Last timestamp in nanoseconds added to a cluster. uint64 last_timestamp_; // Last timestamp in nanoseconds by track number added to a cluster. uint64 last_track_timestamp_[kMaxTrackNumber]; // Maximum time in nanoseconds for a cluster duration. This variable is a // guideline and some clusters may have a longer duration. Default is 30 // seconds. uint64 max_cluster_duration_; // Maximum size in bytes for a cluster. This variable is a guideline and // some clusters may have a larger size. Default is 0 which signifies that // the muxer will decide the size. uint64 max_cluster_size_; // The mode that segment is in. If set to |kLive| the writer must not // seek backwards. Mode mode_; // Flag telling the muxer that a new cue point should be added. bool new_cuepoint_; // TODO(fgalligan): Should we add support for more than one Cues element? // Flag whether or not the muxer should output a Cues element. bool output_cues_; // The size of the EBML header, used to validate the header if // WriteEbmlHeader() is called more than once. int32 ebml_header_size_; // The file position of the segment's payload. int64 payload_pos_; // The file position of the element's size. int64 size_position_; // Current DocTypeVersion (|doc_type_version_|) and that written in // WriteSegmentHeader(). // WriteEbmlHeader() will be called from Finalize() if |doc_type_version_| // differs from |doc_type_version_written_|. uint32 doc_type_version_; uint32 doc_type_version_written_; // Pointer to the writer objects. Not owned by this class. IMkvWriter* writer_cluster_; IMkvWriter* writer_cues_; IMkvWriter* writer_header_; LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Segment); }; } // end namespace mkvmuxer #endif // MKVMUXER_HPP
[ "s.sincak@gmail.com" ]
s.sincak@gmail.com
2acc329873a32dd2fdd2e035043832608a885343
ad055716de1f5283fc905422c63a47c6d4796661
/CCDSAP/manychefs.cpp
c95513026f2218b5a2e1cbd31a288da9c7a3e3a7
[]
no_license
Akash-Sharma1/Competitive
75b1d59d8e39cd104b13f5df84f4ea4a39a68caf
93e1952038df4c3f467d18f52f7da16d49de40aa
refs/heads/master
2020-04-16T08:52:18.231098
2019-03-22T17:30:32
2019-03-22T17:30:32
165,441,602
0
0
null
null
null
null
UTF-8
C++
false
false
601
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while(t--){ string str; cin >> str; int n=str.length(); for(int i=n-4;i>=0;i--){ if(!(str[i ]=='C' || str[i ]=='?')) continue; if(!(str[i+1]=='H' || str[i+1]=='?')) continue; if(!(str[i+2]=='E' || str[i+2]=='?')) continue; if(!(str[i+3]=='F' || str[i+3]=='?')) continue; str[i ] = 'C'; str[i+1] = 'H'; str[i+2] = 'E'; str[i+3] = 'F'; } for(int i=n;i>=0;i--){if(str[i]=='?')str[i]='A';} cout<<str<<endl; } }
[ "aakashsharmajc100@gmail.com" ]
aakashsharmajc100@gmail.com
538d900d3854c8017046c255199e3a0d375c19b7
f27e22b901c90cef74d27b85dcf13e740ee99327
/src/qt/mod/HyperlinkBtn.cpp
f1d9d8a83f6f1fdf87264e04fb4fc28d343b57b5
[ "MIT" ]
permissive
masternodecoin/masternodecoin
75a214096598c764a18194d528983181ba3ca30b
4fb947b782289897874174ac9f01a13657c01d5e
refs/heads/master
2021-06-25T20:35:59.676430
2018-12-06T07:11:39
2018-12-06T07:11:39
100,444,329
6
10
MIT
2019-07-07T10:44:29
2017-08-16T03:35:14
C++
UTF-8
C++
false
false
863
cpp
#include "HyperlinkBtn.h" HyperlinkBtn::HyperlinkBtn(QString iconurl, QString url, QWidget *parent) :m_websiteUrl(url), m_icon(iconurl), QAbstractButton(parent) { setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); connect(this,SIGNAL(clicked(bool)),this,SLOT(onClicked(bool))); } const QString &HyperlinkBtn::getUrl() { return m_websiteUrl; } void HyperlinkBtn::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setRenderHint(QPainter::HighQualityAntialiasing, true); if( !m_icon.isEmpty()) painter.drawPixmap(this->rect(),QPixmap(m_icon)); } //void HyperlinkBtn::resizeEvent(QResizeEvent *event) //{ // int len = qMin(this->width(),this->height()); // this->setFixedSize(len,len); //} void HyperlinkBtn::onClicked(bool b) { QDesktopServices::openUrl(QUrl(m_websiteUrl)); }
[ "31052241+masternodecoin@users.noreply.github.com" ]
31052241+masternodecoin@users.noreply.github.com
d9e97c580e8628b60666ddb6087713494e3221b1
7abbbef9590f9c4b9469adcbae5ea8907478bf03
/chromium_git/chromium/src/ui/events/blink/input_handler_proxy_unittest.cc
16e3542c9ce19b45b769fc81e71f8c91745767aa
[ "BSD-3-Clause" ]
permissive
GiorgiGagnidze/CEF
845bdc2f54833254b3454ba8f6c61449431c7884
fbfc30b5d60f1ea7157da449e34dd9ba9c50f360
refs/heads/master
2021-01-10T17:32:27.640882
2016-03-23T07:43:04
2016-03-23T07:43:04
54,463,340
0
1
null
null
null
null
UTF-8
C++
false
false
102,135
cc
// Copyright 2013 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 "ui/events/blink/input_handler_proxy.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "cc/input/main_thread_scrolling_reason.h" #include "cc/trees/swap_promise_monitor.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/platform/WebFloatPoint.h" #include "third_party/WebKit/public/platform/WebFloatSize.h" #include "third_party/WebKit/public/platform/WebGestureCurve.h" #include "third_party/WebKit/public/platform/WebPoint.h" #include "third_party/WebKit/public/web/WebInputEvent.h" #include "ui/events/blink/input_handler_proxy_client.h" #include "ui/events/latency_info.h" #include "ui/gfx/geometry/scroll_offset.h" #include "ui/gfx/geometry/size_f.h" using blink::WebActiveWheelFlingParameters; using blink::WebFloatPoint; using blink::WebFloatSize; using blink::WebGestureDevice; using blink::WebGestureEvent; using blink::WebInputEvent; using blink::WebKeyboardEvent; using blink::WebMouseWheelEvent; using blink::WebPoint; using blink::WebSize; using blink::WebTouchEvent; using blink::WebTouchPoint; using testing::Field; namespace ui { namespace test { namespace { enum InputHandlerProxyTestType { ROOT_SCROLL_NORMAL_HANDLER, ROOT_SCROLL_SYNCHRONOUS_HANDLER, CHILD_SCROLL_NORMAL_HANDLER, CHILD_SCROLL_SYNCHRONOUS_HANDLER, }; static const InputHandlerProxyTestType test_types[] = { ROOT_SCROLL_NORMAL_HANDLER, ROOT_SCROLL_SYNCHRONOUS_HANDLER, CHILD_SCROLL_NORMAL_HANDLER, CHILD_SCROLL_SYNCHRONOUS_HANDLER}; double InSecondsF(const base::TimeTicks& time) { return (time - base::TimeTicks()).InSecondsF(); } WebGestureEvent CreateFling(base::TimeTicks timestamp, WebGestureDevice source_device, WebFloatPoint velocity, WebPoint point, WebPoint global_point, int modifiers) { WebGestureEvent fling; fling.type = WebInputEvent::GestureFlingStart; fling.sourceDevice = source_device; fling.timeStampSeconds = (timestamp - base::TimeTicks()).InSecondsF(); fling.data.flingStart.velocityX = velocity.x; fling.data.flingStart.velocityY = velocity.y; fling.x = point.x; fling.y = point.y; fling.globalX = global_point.x; fling.globalY = global_point.y; fling.modifiers = modifiers; return fling; } WebGestureEvent CreateFling(WebGestureDevice source_device, WebFloatPoint velocity, WebPoint point, WebPoint global_point, int modifiers) { return CreateFling(base::TimeTicks(), source_device, velocity, point, global_point, modifiers); } class MockInputHandler : public cc::InputHandler { public: MockInputHandler() {} ~MockInputHandler() override {} MOCK_METHOD0(PinchGestureBegin, void()); MOCK_METHOD2(PinchGestureUpdate, void(float magnify_delta, const gfx::Point& anchor)); MOCK_METHOD0(PinchGestureEnd, void()); MOCK_METHOD0(SetNeedsAnimateInput, void()); MOCK_METHOD2(ScrollBegin, ScrollStatus(cc::ScrollState*, cc::InputHandler::ScrollInputType type)); MOCK_METHOD2(RootScrollBegin, ScrollStatus(cc::ScrollState*, cc::InputHandler::ScrollInputType type)); MOCK_METHOD2(ScrollAnimated, ScrollStatus(const gfx::Point& viewport_point, const gfx::Vector2dF& scroll_delta)); MOCK_METHOD1(ScrollBy, cc::InputHandlerScrollResult(cc::ScrollState*)); MOCK_METHOD2(ScrollVerticallyByPage, bool(const gfx::Point& viewport_point, cc::ScrollDirection direction)); MOCK_METHOD1(ScrollEnd, void(cc::ScrollState*)); MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus()); scoped_ptr<cc::SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( ui::LatencyInfo* latency) override { return scoped_ptr<cc::SwapPromiseMonitor>(); } cc::ScrollElasticityHelper* CreateScrollElasticityHelper() override { return NULL; } void BindToClient(cc::InputHandlerClient* client) override {} void MouseMoveAt(const gfx::Point& mouse_position) override {} MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt, bool(const gfx::Point& point, cc::InputHandler::ScrollInputType type)); MOCK_CONST_METHOD0(HaveWheelEventHandlers, bool()); MOCK_METHOD1(DoTouchEventsBlockScrollAt, bool(const gfx::Point& point)); MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void()); MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset, void(const gfx::ScrollOffset& root_offset)); bool IsCurrentlyScrollingInnerViewport() const override { return is_scrolling_root_; } void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; } private: bool is_scrolling_root_ = true; DISALLOW_COPY_AND_ASSIGN(MockInputHandler); }; class MockSynchronousInputHandler : public SynchronousInputHandler { public: MOCK_METHOD0(SetNeedsSynchronousAnimateInput, void()); MOCK_METHOD6(UpdateRootLayerState, void(const gfx::ScrollOffset& total_scroll_offset, const gfx::ScrollOffset& max_scroll_offset, const gfx::SizeF& scrollable_size, float page_scale_factor, float min_page_scale_factor, float max_page_scale_factor)); }; // A simple WebGestureCurve implementation that flings at a constant velocity // indefinitely. class FakeWebGestureCurve : public blink::WebGestureCurve { public: FakeWebGestureCurve(const blink::WebFloatSize& velocity, const blink::WebFloatSize& cumulative_scroll) : velocity_(velocity), cumulative_scroll_(cumulative_scroll) {} ~FakeWebGestureCurve() override {} // Returns false if curve has finished and can no longer be applied. bool apply(double time, blink::WebGestureCurveTarget* target) override { blink::WebFloatSize displacement(velocity_.width * time, velocity_.height * time); blink::WebFloatSize increment( displacement.width - cumulative_scroll_.width, displacement.height - cumulative_scroll_.height); cumulative_scroll_ = displacement; // scrollBy() could delete this curve if the animation is over, so don't // touch any member variables after making that call. return target->scrollBy(increment, velocity_); } private: blink::WebFloatSize velocity_; blink::WebFloatSize cumulative_scroll_; DISALLOW_COPY_AND_ASSIGN(FakeWebGestureCurve); }; class MockInputHandlerProxyClient : public InputHandlerProxyClient { public: MockInputHandlerProxyClient() {} ~MockInputHandlerProxyClient() override {} void WillShutdown() override {} MOCK_METHOD1(TransferActiveWheelFlingAnimation, void(const WebActiveWheelFlingParameters&)); blink::WebGestureCurve* CreateFlingAnimationCurve( WebGestureDevice deviceSource, const WebFloatPoint& velocity, const WebSize& cumulative_scroll) override { return new FakeWebGestureCurve( blink::WebFloatSize(velocity.x, velocity.y), blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); } MOCK_METHOD4(DidOverscroll, void(const gfx::Vector2dF& accumulated_overscroll, const gfx::Vector2dF& latest_overscroll_delta, const gfx::Vector2dF& current_fling_velocity, const gfx::PointF& causal_event_viewport_point)); void DidStopFlinging() override {} void DidAnimateForInput() override {} private: DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); }; class MockInputHandlerProxyClientWithDidAnimateForInput : public MockInputHandlerProxyClient { public: MockInputHandlerProxyClientWithDidAnimateForInput() {} ~MockInputHandlerProxyClientWithDidAnimateForInput() override {} MOCK_METHOD0(DidAnimateForInput, void()); private: DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClientWithDidAnimateForInput); }; WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state, float x, float y) { WebTouchPoint point; point.state = state; point.screenPosition = WebFloatPoint(x, y); point.position = WebFloatPoint(x, y); return point; } const cc::InputHandler::ScrollStatus kImplThreadScrollState( cc::InputHandler::SCROLL_ON_IMPL_THREAD, cc::MainThreadScrollingReason::kNotScrollingOnMain); const cc::InputHandler::ScrollStatus kMainThreadScrollState( cc::InputHandler::SCROLL_ON_MAIN_THREAD, cc::MainThreadScrollingReason::kEventHandlers); const cc::InputHandler::ScrollStatus kScrollIgnoredScrollState( cc::InputHandler::SCROLL_IGNORED, cc::MainThreadScrollingReason::kNotScrollable); } // namespace class InputHandlerProxyTest : public testing::Test, public testing::WithParamInterface<InputHandlerProxyTestType> { public: InputHandlerProxyTest() : synchronous_root_scroll_(GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER), install_synchronous_handler_( GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER || GetParam() == CHILD_SCROLL_SYNCHRONOUS_HANDLER), expected_disposition_(InputHandlerProxy::DID_HANDLE) { input_handler_.reset( new ui::InputHandlerProxy( &mock_input_handler_, &mock_client_)); scroll_result_did_scroll_.did_scroll = true; scroll_result_did_not_scroll_.did_scroll = false; if (install_synchronous_handler_) { EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler()) .Times(1); input_handler_->SetOnlySynchronouslyAnimateRootFlings( &mock_synchronous_input_handler_); } mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_); // Set a default device so tests don't always have to set this. gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; } ~InputHandlerProxyTest() { input_handler_.reset(); } // This is defined as a macro so the line numbers can be traced back to the // correct spot when it fails. #define EXPECT_SET_NEEDS_ANIMATE_INPUT(times) \ do { \ if (synchronous_root_scroll_) { \ EXPECT_CALL(mock_synchronous_input_handler_, \ SetNeedsSynchronousAnimateInput()) \ .Times(times); \ EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(0); \ } else { \ EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(times); \ EXPECT_CALL(mock_synchronous_input_handler_, \ SetNeedsSynchronousAnimateInput()) \ .Times(0); \ } \ } while (false) // This is defined as a macro because when an expectation is not satisfied the // only output you get out of gmock is the line number that set the expectation. #define VERIFY_AND_RESET_MOCKS() \ do { \ testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); \ testing::Mock::VerifyAndClearExpectations( \ &mock_synchronous_input_handler_); \ testing::Mock::VerifyAndClearExpectations(&mock_client_); \ } while (false) void Animate(base::TimeTicks time) { if (synchronous_root_scroll_) { input_handler_->SynchronouslyAnimate(time); } else { input_handler_->Animate(time); } } void StartFling(base::TimeTicks timestamp, WebGestureDevice source_device, WebFloatPoint velocity, WebPoint position) { expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = source_device; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); gesture_ = CreateFling(timestamp, source_device, velocity, position, position, 0); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } void CancelFling(base::TimeTicks timestamp) { gesture_.timeStampSeconds = InSecondsF(timestamp); gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } void SetSmoothScrollEnabled(bool value) { input_handler_->smooth_scroll_enabled_ = value; } protected: const bool synchronous_root_scroll_; const bool install_synchronous_handler_; testing::StrictMock<MockInputHandler> mock_input_handler_; testing::StrictMock<MockSynchronousInputHandler> mock_synchronous_input_handler_; scoped_ptr<ui::InputHandlerProxy> input_handler_; testing::StrictMock<MockInputHandlerProxyClient> mock_client_; WebGestureEvent gesture_; InputHandlerProxy::EventDisposition expected_disposition_; cc::InputHandlerScrollResult scroll_result_did_scroll_; cc::InputHandlerScrollResult scroll_result_did_not_scroll_; }; TEST_P(InputHandlerProxyTest, MouseWheelByPageMainThread) { expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; WebMouseWheelEvent wheel; wheel.type = WebInputEvent::MouseWheel; wheel.scrollByPage = true; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, MouseWheelWithCtrlNotScroll) { expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; WebMouseWheelEvent wheel; wheel.type = WebInputEvent::MouseWheel; wheel.modifiers = WebInputEvent::ControlKey; wheel.canScroll = false; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); VERIFY_AND_RESET_MOCKS(); } // Mac does not smooth scroll wheel events (crbug.com/574283). #if !defined(OS_MACOSX) TEST_P(InputHandlerProxyTest, MouseWheelWithPreciseScrollingDeltas) { #else TEST_P(InputHandlerProxyTest, DISABLED_MouseWheelWithPreciseScrollingDeltas) { #endif SetSmoothScrollEnabled(true); expected_disposition_ = InputHandlerProxy::DID_HANDLE; WebMouseWheelEvent wheel; wheel.type = WebInputEvent::MouseWheel; VERIFY_AND_RESET_MOCKS(); // Smooth scroll because hasPreciseScrollingDeltas is set to false. wheel.hasPreciseScrollingDeltas = false; EXPECT_CALL(mock_input_handler_, ScrollAnimated(::testing::_, ::testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); VERIFY_AND_RESET_MOCKS(); // No smooth scroll because hasPreciseScrollingDeltas is set to true. wheel.hasPreciseScrollingDeltas = true; EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBy(::testing::_)) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); VERIFY_AND_RESET_MOCKS(); } // Mac does not smooth scroll wheel events (crbug.com/574283). #if !defined(OS_MACOSX) TEST_P(InputHandlerProxyTest, MouseWheelScrollIgnored) { #else TEST_P(InputHandlerProxyTest, DISABLED_MouseWheelScrollIgnored) { #endif SetSmoothScrollEnabled(true); expected_disposition_ = InputHandlerProxy::DROP_EVENT; WebMouseWheelEvent wheel; wheel.type = WebInputEvent::MouseWheel; EXPECT_CALL(mock_input_handler_, ScrollAnimated(testing::_, testing::_)) .WillOnce(testing::Return(kScrollIgnoredScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureScrollStarted) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_)); // The event should not be marked as handled if scrolling is not possible. expected_disposition_ = InputHandlerProxy::DROP_EVENT; VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaY = -40; // -Y means scroll down - i.e. in the +Y direction. EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) .WillOnce(testing::Return(scroll_result_did_not_scroll_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // Mark the event as handled if scroll happens. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaY = -40; // -Y means scroll down - i.e. in the +Y direction. EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollEnd; gesture_.data.scrollUpdate.deltaY = 0; EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureScrollOnMainThread) { // We should send all events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) .WillOnce(testing::Return(kMainThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaY = 40; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollEnd; gesture_.data.scrollUpdate.deltaY = 0; EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)) .WillOnce(testing::Return()); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureScrollIgnored) { // We shouldn't handle the GestureScrollBegin. // Instead, we should get a DROP_EVENT result, indicating // that we could determine that there's nothing that could scroll or otherwise // react to this gesture sequence and thus we should drop the whole gesture // sequence on the floor, except for the ScrollEnd. expected_disposition_ = InputHandlerProxy::DROP_EVENT; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kScrollIgnoredScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; gesture_.type = WebInputEvent::GestureScrollEnd; EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)) .WillOnce(testing::Return()); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureScrollByPage) { // We should send all events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.data.scrollBegin.deltaHintUnits = WebGestureEvent::ScrollUnits::Page; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaY = 1; gesture_.data.scrollUpdate.deltaUnits = WebGestureEvent::ScrollUnits::Page; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollEnd; gesture_.data.scrollUpdate.deltaY = 0; EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)) .WillOnce(testing::Return()); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } // Mac does not smooth scroll wheel events (crbug.com/574283). #if !defined(OS_MACOSX) TEST_P(InputHandlerProxyTest, GestureScrollByCoarsePixels) { #else TEST_P(InputHandlerProxyTest, DISABLED_GestureScrollByCoarsePixels) { #endif SetSmoothScrollEnabled(true); expected_disposition_ = InputHandlerProxy::DID_HANDLE; gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.data.scrollBegin.deltaHintUnits = WebGestureEvent::ScrollUnits::Pixels; EXPECT_CALL(mock_input_handler_, ScrollAnimated(::testing::_, ::testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaUnits = WebGestureEvent::ScrollUnits::Pixels; EXPECT_CALL(mock_input_handler_, ScrollAnimated(::testing::_, ::testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureScrollBeginThatTargetViewport) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, RootScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.data.scrollBegin.targetViewport = true; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GesturePinch) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchBegin; EXPECT_CALL(mock_input_handler_, HaveWheelEventHandlers()) .WillOnce(testing::Return(false)); EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchUpdate; gesture_.data.pinchUpdate.scale = 1.5; gesture_.x = 7; gesture_.y = 13; EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchUpdate; gesture_.data.pinchUpdate.scale = 0.5; gesture_.data.pinchUpdate.zoomDisabled = true; gesture_.x = 9; gesture_.y = 6; EXPECT_EQ(InputHandlerProxy::DROP_EVENT, input_handler_->HandleInputEvent(gesture_)); gesture_.data.pinchUpdate.zoomDisabled = false; VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchUpdate; gesture_.data.pinchUpdate.scale = 0.5; gesture_.x = 9; gesture_.y = 6; EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6))); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchEnd; EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GesturePinchWithWheelHandler) { // We will send the synthetic wheel event to the widget. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchBegin; EXPECT_CALL(mock_input_handler_, HaveWheelEventHandlers()) .WillOnce(testing::Return(true)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchUpdate; gesture_.data.pinchUpdate.scale = 1.5; gesture_.x = 7; gesture_.y = 13; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchUpdate; gesture_.data.pinchUpdate.scale = 0.5; gesture_.x = 9; gesture_.y = 6; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchEnd; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); } TEST_P(InputHandlerProxyTest, GesturePinchAfterScrollOnMainThread) { // Scrolls will start by being sent to the main thread. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) .WillOnce(testing::Return(kMainThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaY = 40; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // However, after the pinch gesture starts, they should go to the impl // thread. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchBegin; EXPECT_CALL(mock_input_handler_, HaveWheelEventHandlers()) .WillOnce(testing::Return(false)); EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchUpdate; gesture_.data.pinchUpdate.scale = 1.5; gesture_.x = 7; gesture_.y = 13; EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaY = -40; // -Y means scroll down - i.e. in the +Y direction. EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchUpdate; gesture_.data.pinchUpdate.scale = 0.5; gesture_.x = 9; gesture_.y = 6; EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6))); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GesturePinchEnd; EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // After the pinch gesture ends, they should go to back to the main // thread. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; VERIFY_AND_RESET_MOCKS(); gesture_.type = WebInputEvent::GestureScrollEnd; gesture_.data.scrollUpdate.deltaY = 0; EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)) .WillOnce(testing::Return()); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); gesture_.type = WebInputEvent::GestureFlingStart; gesture_.data.flingStart.velocityX = 10; gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Verify that a GestureFlingCancel during an animation cancels it. gesture_.type = WebInputEvent::GestureFlingCancel; gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); } TEST_P(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) { // We should send all events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kMainThreadScrollState)); gesture_.type = WebInputEvent::GestureFlingStart; gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // Since we returned ScrollStatusOnMainThread from scrollBegin, ensure the // input handler knows it's scrolling off the impl thread ASSERT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); VERIFY_AND_RESET_MOCKS(); // Even if we didn't start a fling ourselves, we still need to send the cancel // event to the widget. gesture_.type = WebInputEvent::GestureFlingCancel; gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); } TEST_P(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) { expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kScrollIgnoredScrollState)); gesture_.type = WebInputEvent::GestureFlingStart; gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); expected_disposition_ = InputHandlerProxy::DROP_EVENT; VERIFY_AND_RESET_MOCKS(); // Since the previous fling was ignored, we should also be dropping the next // fling_cancel. gesture_.type = WebInputEvent::GestureFlingCancel; gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); } TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. gesture_.type = WebInputEvent::GestureFlingStart; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); WebPoint fling_global_point = WebPoint(17, 23); // Note that for trackpad, wheel events with the Control modifier are // special (reserved for zoom), so don't set that here. int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, fling_delta, fling_point, fling_global_point, modifiers); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // The first animate call should let us pick up an animation start time, but // we shouldn't actually move anywhere just yet. The first frame after the // fling start will typically include the last scroll from the gesture that // lead to the scroll (either wheel or gesture scroll), so there should be no // visible hitch. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .Times(0); base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The second call should start scrolling in the -X direction. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); // Let's say on the third call we hit a non-scrollable region. We should abort // the fling and not scroll. // We also should pass the current fling parameters out to the client so the // rest of the fling can be // transferred to the main thread. EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kMainThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); // Expected wheel fling animation parameters: // *) fling_delta and fling_point should match the original GestureFlingStart // event // *) startTime should be 10 to match the time parameter of the first // Animate() call after the GestureFlingStart // *) cumulativeScroll depends on the curve, but since we've animated in the // -X direction the X value should be < 0 EXPECT_CALL( mock_client_, TransferActiveWheelFlingAnimation(testing::AllOf( testing::Field(&WebActiveWheelFlingParameters::delta, testing::Eq(fling_delta)), testing::Field(&WebActiveWheelFlingParameters::point, testing::Eq(fling_point)), testing::Field(&WebActiveWheelFlingParameters::globalPoint, testing::Eq(fling_global_point)), testing::Field(&WebActiveWheelFlingParameters::modifiers, testing::Eq(modifiers)), testing::Field(&WebActiveWheelFlingParameters::startTime, testing::Eq(10)), testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, testing::Field(&WebSize::width, testing::Gt(0)))))); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); // Since we've aborted the fling, the next animation should be a no-op and // should not result in another // frame being requested. EXPECT_SET_NEEDS_ANIMATE_INPUT(0); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .Times(0); time += base::TimeDelta::FromMilliseconds(100); Animate(time); // Since we've transferred the fling to the main thread, we need to pass the // next GestureFlingCancel to the main // thread as well. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); // Start a gesture fling in the -X direction with zero Y movement. WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); WebPoint fling_global_point = WebPoint(17, 23); // Note that for trackpad, wheel events with the Control modifier are // special (reserved for zoom), so don't set that here. int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, fling_delta, fling_point, fling_global_point, modifiers); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Start the fling animation at time 10. This shouldn't actually scroll, just // establish a start time. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .Times(0); base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The second call should start scrolling in the -X direction. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); // Let's say on the third call we hit a non-scrollable region. We should abort // the fling and not scroll. // We also should pass the current fling parameters out to the client so the // rest of the fling can be // transferred to the main thread. EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kMainThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); // Expected wheel fling animation parameters: // *) fling_delta and fling_point should match the original GestureFlingStart // event // *) startTime should be 10 to match the time parameter of the first // Animate() call after the GestureFlingStart // *) cumulativeScroll depends on the curve, but since we've animated in the // -X direction the X value should be < 0 EXPECT_CALL( mock_client_, TransferActiveWheelFlingAnimation(testing::AllOf( testing::Field(&WebActiveWheelFlingParameters::delta, testing::Eq(fling_delta)), testing::Field(&WebActiveWheelFlingParameters::point, testing::Eq(fling_point)), testing::Field(&WebActiveWheelFlingParameters::globalPoint, testing::Eq(fling_global_point)), testing::Field(&WebActiveWheelFlingParameters::modifiers, testing::Eq(modifiers)), testing::Field(&WebActiveWheelFlingParameters::startTime, testing::Eq(10)), testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, testing::Field(&WebSize::width, testing::Gt(0)))))); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); // Since we've aborted the fling, the next animation should be a no-op and // should not result in another // frame being requested. EXPECT_SET_NEEDS_ANIMATE_INPUT(0); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .Times(0); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); // Since we've transferred the fling to the main thread, we need to pass the // next GestureFlingCancel to the main // thread as well. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); input_handler_->MainThreadHasStoppedFlinging(); // Start a second gesture fling, this time in the +Y direction with no X. fling_delta = WebFloatPoint(0, -1000); fling_point = WebPoint(95, 87); fling_global_point = WebPoint(32, 71); modifiers = WebInputEvent::AltKey; gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, fling_delta, fling_point, fling_global_point, modifiers); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); expected_disposition_ = InputHandlerProxy::DID_HANDLE; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Start the second fling animation at time 30. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .Times(0); time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); Animate(time); VERIFY_AND_RESET_MOCKS(); // Tick the second fling once normally. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); // Then abort the second fling. EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kMainThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); // We should get parameters from the second fling, nothing from the first // fling should "leak". EXPECT_CALL( mock_client_, TransferActiveWheelFlingAnimation(testing::AllOf( testing::Field(&WebActiveWheelFlingParameters::delta, testing::Eq(fling_delta)), testing::Field(&WebActiveWheelFlingParameters::point, testing::Eq(fling_point)), testing::Field(&WebActiveWheelFlingParameters::globalPoint, testing::Eq(fling_global_point)), testing::Field(&WebActiveWheelFlingParameters::modifiers, testing::Eq(modifiers)), testing::Field(&WebActiveWheelFlingParameters::startTime, testing::Eq(30)), testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, testing::Field(&WebSize::height, testing::Lt(0)))))); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchscreen) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); gesture_.type = WebInputEvent::GestureFlingStart; gesture_.data.flingStart.velocityX = 10; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); // Verify that a GestureFlingCancel during an animation cancels it. gesture_.type = WebInputEvent::GestureFlingCancel; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingOnMainThreadTouchscreen) { // We should send all events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kMainThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()).Times(0); gesture_.type = WebInputEvent::GestureFlingStart; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Even if we didn't start a fling ourselves, we still need to send the cancel // event to the widget. gesture_.type = WebInputEvent::GestureFlingCancel; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); } TEST_P(InputHandlerProxyTest, GestureFlingIgnoredTouchscreen) { expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); expected_disposition_ = InputHandlerProxy::DROP_EVENT; VERIFY_AND_RESET_MOCKS(); // Flings ignored by the InputHandler should be dropped, signalling the end // of the touch scroll sequence. EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kScrollIgnoredScrollState)); gesture_.type = WebInputEvent::GestureFlingStart; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Subsequent scrolls should behave normally, even without an intervening // GestureFlingCancel, as the original GestureFlingStart was dropped. expected_disposition_ = InputHandlerProxy::DID_HANDLE; EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingAnimatesTouchscreen) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. WebFloatPoint fling_delta = WebFloatPoint(100, 0); WebPoint fling_point = WebPoint(7, 13); WebPoint fling_global_point = WebPoint(17, 23); // Note that for touchscreen the control modifier is not special. int modifiers = WebInputEvent::ControlKey; gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, fling_delta, fling_point, fling_global_point, modifiers); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // The first animate call should let us pick up an animation start time, but // we shouldn't actually move anywhere just yet. The first frame after the // fling start will typically include the last scroll from the gesture that // lead to the scroll (either wheel or gesture scroll), so there should be no // visible hitch. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The second call should start scrolling in the -X direction. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingWithValidTimestamp) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(100, 0); WebPoint fling_point = WebPoint(7, 13); WebPoint fling_global_point = WebPoint(17, 23); int modifiers = WebInputEvent::ControlKey; gesture_ = CreateFling(time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point, fling_global_point, modifiers); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // With a valid time stamp, the first animate call should skip start time // initialization and immediately begin scroll update production. This reduces // the likelihood of a hitch between the scroll preceding the fling and // the first scroll generated by the fling. // Scrolling should start in the -X direction. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); time += dt; Animate(time); VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingWithInvalidTimestamp) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. base::TimeDelta start_time_offset = base::TimeDelta::FromMilliseconds(10); gesture_.type = WebInputEvent::GestureFlingStart; WebFloatPoint fling_delta = WebFloatPoint(100, 0); WebPoint fling_point = WebPoint(7, 13); WebPoint fling_global_point = WebPoint(17, 23); int modifiers = WebInputEvent::ControlKey; gesture_.timeStampSeconds = start_time_offset.InSecondsF(); gesture_.data.flingStart.velocityX = fling_delta.x; gesture_.data.flingStart.velocityY = fling_delta.y; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; gesture_.x = fling_point.x; gesture_.y = fling_point.y; gesture_.globalX = fling_global_point.x; gesture_.globalY = fling_global_point.y; gesture_.modifiers = modifiers; EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Event though a time stamp was provided for the fling event, it will be // ignored as its too far in the past relative to the first animate call's // timestamp. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); base::TimeTicks time = base::TimeTicks() + start_time_offset + base::TimeDelta::FromSeconds(1); Animate(time); VERIFY_AND_RESET_MOCKS(); // Further animation ticks should update the fling as usual. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); time += base::TimeDelta::FromMilliseconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureScrollOnImplThreadFlagClearedAfterFling) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // After sending a GestureScrollBegin, the member variable // |gesture_scroll_on_impl_thread_| should be true. EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. WebFloatPoint fling_delta = WebFloatPoint(100, 0); WebPoint fling_point = WebPoint(7, 13); WebPoint fling_global_point = WebPoint(17, 23); int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, fling_delta, fling_point, fling_global_point, modifiers); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // |gesture_scroll_on_impl_thread_| should still be true after // a GestureFlingStart is sent. EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); VERIFY_AND_RESET_MOCKS(); // The first animate call should let us pick up an animation start time, but // we shouldn't actually move anywhere just yet. The first frame after the // fling start will typically include the last scroll from the gesture that // lead to the scroll (either wheel or gesture scroll), so there should be no // visible hitch. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The second call should start scrolling in the -X direction. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // |gesture_scroll_on_impl_thread_| should be false once // the fling has finished (note no GestureScrollEnd has been sent). EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing()); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, BeginScrollWhenGestureScrollOnImplThreadFlagIsSet) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // After sending a GestureScrollBegin, the member variable // |gesture_scroll_on_impl_thread_| should be true. EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. WebFloatPoint fling_delta = WebFloatPoint(100, 0); WebPoint fling_point = WebPoint(7, 13); WebPoint fling_global_point = WebPoint(17, 23); int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen, fling_delta, fling_point, fling_global_point, modifiers); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // |gesture_scroll_on_impl_thread_| should still be true after // a GestureFlingStart is sent. EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); VERIFY_AND_RESET_MOCKS(); // gesture_scroll_on_impl_thread_ is still true when this scroll begins. As a // result, this scroll begin will cancel the previous fling. EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); // After sending a GestureScrollBegin, the member variable // |gesture_scroll_on_impl_thread_| should be true. EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. gesture_.type = WebInputEvent::GestureFlingStart; WebFloatPoint fling_delta = WebFloatPoint(100, 100); gesture_.data.flingStart.velocityX = fling_delta.x; gesture_.data.flingStart.velocityY = fling_delta.y; EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // The first animate doesn't cause any scrolling. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The second animate starts scrolling in the positive X and Y directions. EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); // The third animate overscrolls in the positive Y direction but scrolls // somewhat. cc::InputHandlerScrollResult overscroll; overscroll.did_scroll = true; overscroll.did_overscroll_root = true; overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) .WillOnce(testing::Return(overscroll)); EXPECT_CALL( mock_client_, DidOverscroll( overscroll.accumulated_root_overscroll, overscroll.unused_scroll_delta, testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), testing::_)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); // The next call to animate will no longer scroll vertically. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(100, 0); WebPoint fling_point = WebPoint(7, 13); WebPoint fling_global_point = WebPoint(17, 23); int modifiers = WebInputEvent::ControlKey; gesture_ = CreateFling(time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point, fling_global_point, modifiers); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // With an animation timestamp equivalent to the starting timestamp, the // animation will simply be rescheduled. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); Animate(time); VERIFY_AND_RESET_MOCKS(); EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); // A small time delta should not stop the fling, even if the client // reports no scrolling. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_not_scroll_)); time += base::TimeDelta::FromMicroseconds(5); Animate(time); VERIFY_AND_RESET_MOCKS(); EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); // A time delta of zero should not stop the fling, and neither should it // trigger scrolling on the client. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); Animate(time); VERIFY_AND_RESET_MOCKS(); EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); // Lack of movement on the client, with a non-trivial scroll delta, should // terminate the fling. EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(1)))) .WillOnce(testing::Return(scroll_result_did_not_scroll_)); time += base::TimeDelta::FromMilliseconds(100); Animate(time); VERIFY_AND_RESET_MOCKS(); EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); } TEST_P(InputHandlerProxyTest, GestureFlingCancelledAfterBothAxesStopScrolling) { cc::InputHandlerScrollResult overscroll; overscroll.did_scroll = true; overscroll.did_overscroll_root = true; // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. gesture_.type = WebInputEvent::GestureFlingStart; WebFloatPoint fling_delta = WebFloatPoint(100, 100); gesture_.data.flingStart.velocityX = fling_delta.x; gesture_.data.flingStart.velocityY = fling_delta.y; EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // The first animate doesn't cause any scrolling. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The second animate starts scrolling in the positive X and Y directions. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); time += base::TimeDelta::FromMilliseconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The third animate hits the bottom content edge. overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) .WillOnce(testing::Return(overscroll)); EXPECT_CALL( mock_client_, DidOverscroll( overscroll.accumulated_root_overscroll, overscroll.unused_scroll_delta, testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), testing::_)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); time += base::TimeDelta::FromMilliseconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The next call to animate will no longer scroll vertically. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); time += base::TimeDelta::FromMilliseconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The next call will hit the right edge. overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) .WillOnce(testing::Return(overscroll)); EXPECT_CALL( mock_client_, DidOverscroll( overscroll.accumulated_root_overscroll, overscroll.unused_scroll_delta, testing::Property(&gfx::Vector2dF::x, testing::Lt(0)), testing::_)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); time += base::TimeDelta::FromMilliseconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // The next call to animate will no longer scroll horizontally or vertically, // and the fling should be cancelled. EXPECT_SET_NEEDS_ANIMATE_INPUT(0); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); time += base::TimeDelta::FromMilliseconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); } TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { // None of the three touch points fall in the touch region. So the event // should be dropped. expected_disposition_ = InputHandlerProxy::DROP_EVENT; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt( testing::Property(&gfx::Point::x, testing::Gt(0)))) .WillOnce(testing::Return(false)); EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt( testing::Property(&gfx::Point::x, testing::Lt(0)))) .WillOnce(testing::Return(false)); WebTouchEvent touch; touch.type = WebInputEvent::TouchStart; touch.touchesLength = 3; touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0); touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { // One of the touch points is on a touch-region. So the event should be sent // to the main thread. expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt( testing::Property(&gfx::Point::x, testing::Eq(0)))) .WillOnce(testing::Return(false)); EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt( testing::Property(&gfx::Point::x, testing::Gt(0)))) .WillOnce(testing::Return(true)); // Since the second touch point hits a touch-region, there should be no // hit-testing for the third touch point. WebTouchEvent touch; touch.type = WebInputEvent::TouchStart; touch.touchesLength = 3; touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); VERIFY_AND_RESET_MOCKS(); // Keyboard events received during a scroll should have no effect. WebKeyboardEvent key_event; key_event.type = WebInputEvent::KeyDown; EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, input_handler_->HandleInputEvent(key_event)); EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); VERIFY_AND_RESET_MOCKS(); // On the fling start, animation should be scheduled, but no scrolling occurs. gesture_.type = WebInputEvent::GestureFlingStart; WebFloatPoint fling_delta = WebFloatPoint(100, 100); gesture_.data.flingStart.velocityX = fling_delta.x; gesture_.data.flingStart.velocityY = fling_delta.y; EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); VERIFY_AND_RESET_MOCKS(); // Keyboard events received during a fling should cancel the active fling. EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, input_handler_->HandleInputEvent(key_event)); EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); VERIFY_AND_RESET_MOCKS(); // The call to animate should have no effect, as the fling was cancelled. base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); // A fling cancel should be dropped, as there is nothing to cancel. gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(InputHandlerProxy::DROP_EVENT, input_handler_->HandleInputEvent(gesture_)); EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); } TEST_P(InputHandlerProxyTest, GestureFlingWithNegativeTimeDelta) { // We shouldn't send any events to the widget for this gesture. expected_disposition_ = InputHandlerProxy::DID_HANDLE; VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); gesture_.type = WebInputEvent::GestureScrollBegin; gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // On the fling start, we should schedule an animation but not actually start // scrolling. base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(100, 0); WebPoint fling_point = WebPoint(7, 13); WebPoint fling_global_point = WebPoint(17, 23); int modifiers = WebInputEvent::ControlKey; gesture_ = CreateFling(time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point, fling_global_point, modifiers); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // If we get a negative time delta, that is, the Animation tick time happens // before the fling's start time then we should *not* try scrolling and // instead reset the fling start time. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); time -= base::TimeDelta::FromMilliseconds(5); Animate(time); VERIFY_AND_RESET_MOCKS(); // The first call should have reset the start time so subsequent calls should // generate scroll events. EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL( mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); Animate(time + base::TimeDelta::FromMilliseconds(1)); VERIFY_AND_RESET_MOCKS(); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, FlingBoost) { base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; base::TimeTicks last_animate_time = time; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); StartFling( time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); // Now cancel the fling. The fling cancellation should be deferred to allow // fling boosting events to arrive. time += dt; CancelFling(time); // The GestureScrollBegin should be swallowed by the fling if it hits the same // scrolling layer. EXPECT_CALL(mock_input_handler_, IsCurrentlyScrollingLayerAt(testing::_, testing::_)) .WillOnce(testing::Return(true)); time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Animate calls within the deferred cancellation window should continue. time += dt; float expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x; EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Eq(expected_delta)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); Animate(time); last_animate_time = time; VERIFY_AND_RESET_MOCKS(); // GestureScrollUpdates in the same direction and at sufficient speed should // be swallowed by the fling. time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaX = fling_delta.x; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Animate calls within the deferred cancellation window should continue. time += dt; expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x; EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Eq(expected_delta)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); Animate(time); last_animate_time = time; VERIFY_AND_RESET_MOCKS(); // GestureFlingStart in the same direction and at sufficient speed should // boost the active fling. gesture_ = CreateFling(time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point, fling_point, 0); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); time += dt; // Note we get *2x* as much delta because 2 flings have combined. expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x; EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Eq(expected_delta)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); Animate(time); last_animate_time = time; VERIFY_AND_RESET_MOCKS(); // Repeated GestureFlingStarts should accumulate. CancelFling(time); gesture_ = CreateFling(time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point, fling_point, 0); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); time += dt; // Note we get *3x* as much delta because 3 flings have combined. expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x; EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Eq(expected_delta)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); Animate(time); last_animate_time = time; VERIFY_AND_RESET_MOCKS(); // GestureFlingCancel should terminate the fling if no boosting gestures are // received within the timeout window. time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureFlingCancel; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); time += base::TimeDelta::FromMilliseconds(100); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); Animate(time); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, NoFlingBoostIfScrollTargetsDifferentLayer) { base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); StartFling( time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); // Cancel the fling. The fling cancellation should be deferred to allow // fling boosting events to arrive. time += dt; CancelFling(time); // If the GestureScrollBegin targets a different layer, the fling should be // cancelled and the scroll should be handled as usual. EXPECT_CALL(mock_input_handler_, IsCurrentlyScrollingLayerAt(testing::_, testing::_)) .WillOnce(testing::Return(false)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, NoFlingBoostIfScrollDelayed) { base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); StartFling( time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); // Cancel the fling. The fling cancellation should be deferred to allow // fling boosting events to arrive. time += dt; CancelFling(time); // The GestureScrollBegin should be swallowed by the fling if it hits the same // scrolling layer. EXPECT_CALL(mock_input_handler_, IsCurrentlyScrollingLayerAt(testing::_, testing::_)) .WillOnce(testing::Return(true)); time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // If no GestureScrollUpdate or GestureFlingStart is received within the // timeout window, the fling should be cancelled and scrolling should resume. time += base::TimeDelta::FromMilliseconds(100); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); Animate(time); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, NoFlingBoostIfNotAnimated) { base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); StartFling( time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); // Animate fling once. time += dt; EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); Animate(time); // Cancel the fling after long delay of no animate. The fling cancellation // should be deferred to allow fling boosting events to arrive. time += base::TimeDelta::FromMilliseconds(100); CancelFling(time); // The GestureScrollBegin should be swallowed by the fling if it hits the same // scrolling layer. EXPECT_CALL(mock_input_handler_, IsCurrentlyScrollingLayerAt(testing::_, testing::_)) .WillOnce(testing::Return(true)); time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Should exit scroll bosting on GestureScrollUpdate due to long delay // since last animate. Cancel old fling and start new scroll. gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaY = -40; EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, NoFlingBoostIfFlingInDifferentDirection) { base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); StartFling( time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); // Cancel the fling. The fling cancellation should be deferred to allow // fling boosting events to arrive. time += dt; CancelFling(time); // If the new fling is orthogonal to the existing fling, no boosting should // take place, with the new fling replacing the old. WebFloatPoint orthogonal_fling_delta = WebFloatPoint(fling_delta.y, -fling_delta.x); gesture_ = CreateFling(time, blink::WebGestureDeviceTouchscreen, orthogonal_fling_delta, fling_point, fling_point, 0); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Note that the new fling delta uses the orthogonal, unboosted fling // velocity. time += dt; float expected_delta = dt.InSecondsF() * -orthogonal_fling_delta.y; EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(expected_delta)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); Animate(time); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, NoFlingBoostIfScrollInDifferentDirection) { base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); StartFling( time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); // Cancel the fling. The fling cancellation should be deferred to allow // fling boosting events to arrive. time += dt; CancelFling(time); // The GestureScrollBegin should be swallowed by the fling if it hits the same // scrolling layer. EXPECT_CALL(mock_input_handler_, IsCurrentlyScrollingLayerAt(testing::_, testing::_)) .WillOnce(testing::Return(true)); time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // If the GestureScrollUpdate is in a different direction than the fling, // the fling should be cancelled and scrolling should resume. time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaX = -fling_delta.x; EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Eq(fling_delta.x)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, NoFlingBoostIfFlingTooSlow) { base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); StartFling( time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); // Cancel the fling. The fling cancellation should be deferred to allow // fling boosting events to arrive. time += dt; CancelFling(time); // If the new fling is too slow, no boosting should take place, with the new // fling replacing the old. WebFloatPoint small_fling_delta = WebFloatPoint(100, 0); gesture_ = CreateFling(time, blink::WebGestureDeviceTouchscreen, small_fling_delta, fling_point, fling_point, 0); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Note that the new fling delta uses the *slow*, unboosted fling velocity. time += dt; float expected_delta = dt.InSecondsF() * -small_fling_delta.x; EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Eq(expected_delta)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); Animate(time); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, NoFlingBoostIfPreventBoostingFlagIsSet) { base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); StartFling( time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); // Cancel the fling. The fling cancellation should not be deferred because of // prevent boosting flag set. gesture_.data.flingCancel.preventBoosting = true; time += dt; CancelFling(time); // VERIFY_AND_RESET_MOCKS already called by CancelFling } TEST_P(InputHandlerProxyTest, FlingBoostTerminatedDuringScrollSequence) { base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); base::TimeTicks time = base::TimeTicks() + dt; base::TimeTicks last_animate_time = time; WebFloatPoint fling_delta = WebFloatPoint(1000, 0); WebPoint fling_point = WebPoint(7, 13); StartFling( time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); // Now cancel the fling. The fling cancellation should be deferred to allow // fling boosting events to arrive. time += dt; CancelFling(time); // The GestureScrollBegin should be swallowed by the fling. time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollBegin; EXPECT_CALL(mock_input_handler_, IsCurrentlyScrollingLayerAt(testing::_, testing::_)) .WillOnce(testing::Return(true)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // Now animate the fling to completion (in this case, the fling should // terminate because the input handler reports a failed scroll). As the fling // was cancelled during an active scroll sequence, a synthetic // GestureScrollBegin should be processed, resuming the scroll. time += dt; float expected_delta = (time - last_animate_time).InSecondsF() * -fling_delta.x; EXPECT_CALL(mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Eq(expected_delta)))) .WillOnce(testing::Return(scroll_result_did_not_scroll_)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); Animate(time); VERIFY_AND_RESET_MOCKS(); // Subsequent GestureScrollUpdates after the cancelled, boosted fling should // cause scrolling as usual. time += dt; expected_delta = 7.3f; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollUpdate; gesture_.data.scrollUpdate.deltaX = -expected_delta; EXPECT_CALL(mock_input_handler_, ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Eq(expected_delta)))) .WillOnce(testing::Return(scroll_result_did_scroll_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); // GestureScrollEnd should terminate the resumed scroll properly. time += dt; gesture_.timeStampSeconds = InSecondsF(time); gesture_.type = WebInputEvent::GestureScrollEnd; EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); } TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput> mock_client; input_handler_.reset( new ui::InputHandlerProxy( &mock_input_handler_, &mock_client)); if (install_synchronous_handler_) { EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler()) .Times(1); input_handler_->SetOnlySynchronouslyAnimateRootFlings( &mock_synchronous_input_handler_); } mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_); gesture_.type = WebInputEvent::GestureFlingStart; WebFloatPoint fling_delta = WebFloatPoint(100, 100); gesture_.data.flingStart.velocityX = fling_delta.x; gesture_.data.flingStart.velocityY = fling_delta.y; EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) .WillOnce(testing::Return(kImplThreadScrollState)); EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); EXPECT_EQ(InputHandlerProxy::DID_HANDLE, input_handler_->HandleInputEvent(gesture_)); VERIFY_AND_RESET_MOCKS(); EXPECT_SET_NEEDS_ANIMATE_INPUT(1); EXPECT_CALL(mock_client, DidAnimateForInput()); base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); Animate(time); VERIFY_AND_RESET_MOCKS(); } TEST(SynchronousInputHandlerProxyTest, StartupShutdown) { testing::StrictMock<MockInputHandler> mock_input_handler; testing::StrictMock<MockInputHandlerProxyClient> mock_client; testing::StrictMock<MockSynchronousInputHandler> mock_synchronous_input_handler; ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client); // When adding a SynchronousInputHandler, immediately request an // UpdateRootLayerStateForSynchronousInputHandler() call. EXPECT_CALL(mock_input_handler, RequestUpdateForSynchronousInputHandler()) .Times(1); proxy.SetOnlySynchronouslyAnimateRootFlings(&mock_synchronous_input_handler); testing::Mock::VerifyAndClearExpectations(&mock_input_handler); testing::Mock::VerifyAndClearExpectations(&mock_client); testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); EXPECT_CALL(mock_input_handler, RequestUpdateForSynchronousInputHandler()) .Times(0); proxy.SetOnlySynchronouslyAnimateRootFlings(nullptr); testing::Mock::VerifyAndClearExpectations(&mock_input_handler); testing::Mock::VerifyAndClearExpectations(&mock_client); testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); } TEST(SynchronousInputHandlerProxyTest, UpdateRootLayerState) { testing::NiceMock<MockInputHandler> mock_input_handler; testing::StrictMock<MockInputHandlerProxyClient> mock_client; testing::StrictMock<MockSynchronousInputHandler> mock_synchronous_input_handler; ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client); proxy.SetOnlySynchronouslyAnimateRootFlings(&mock_synchronous_input_handler); // When adding a SynchronousInputHandler, immediately request an // UpdateRootLayerStateForSynchronousInputHandler() call. EXPECT_CALL( mock_synchronous_input_handler, UpdateRootLayerState(gfx::ScrollOffset(1, 2), gfx::ScrollOffset(3, 4), gfx::SizeF(5, 6), 7, 8, 9)) .Times(1); proxy.UpdateRootLayerStateForSynchronousInputHandler( gfx::ScrollOffset(1, 2), gfx::ScrollOffset(3, 4), gfx::SizeF(5, 6), 7, 8, 9); testing::Mock::VerifyAndClearExpectations(&mock_input_handler); testing::Mock::VerifyAndClearExpectations(&mock_client); testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); } TEST(SynchronousInputHandlerProxyTest, SetOffset) { testing::NiceMock<MockInputHandler> mock_input_handler; testing::StrictMock<MockInputHandlerProxyClient> mock_client; testing::StrictMock<MockSynchronousInputHandler> mock_synchronous_input_handler; ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client); proxy.SetOnlySynchronouslyAnimateRootFlings(&mock_synchronous_input_handler); EXPECT_CALL(mock_input_handler, SetSynchronousInputHandlerRootScrollOffset( gfx::ScrollOffset(5, 6))); proxy.SynchronouslySetRootScrollOffset(gfx::ScrollOffset(5, 6)); testing::Mock::VerifyAndClearExpectations(&mock_input_handler); testing::Mock::VerifyAndClearExpectations(&mock_client); testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); } INSTANTIATE_TEST_CASE_P(AnimateInput, InputHandlerProxyTest, testing::ValuesIn(test_types)); } // namespace test } // namespace ui
[ "ggagn12@freeuni.edu.ge" ]
ggagn12@freeuni.edu.ge
2eeb1c074db3a260b6bcc09bbff8fecce1efd096
410926de476cd142bdcaa7a6221f04056dc5dd42
/Image_Median_Filtering/prompt.cpp
9615e9581b2550fd5322f646d19bdd6b4bc54388
[]
no_license
kuzb/Cpp-Course-Projects
aec4a8390e6c2f3eb143d8dfd5270320bf2e31b0
d80bb5785b30b96f727cd6700e7f1686a79e8bc4
refs/heads/master
2022-12-18T13:03:41.896769
2020-09-13T17:37:52
2020-09-13T17:37:52
130,321,401
1
0
null
null
null
null
UTF-8
C++
false
false
2,976
cpp
#include <cctype> #include <iostream> using namespace std; #include "prompt.h" long int PromptRange(const string & prompt,long int low, long int high) // precondition: low <= high // postcondition: returns a value between low and high (inclusive) { long int value; string response; do { cout << prompt << " between "; cout << low << " and " << high << ": "; cin >> response; value = atol(response.c_str()); } while (value < low || high < value); return value; } static void eatline() { string dummy; getline(cin,dummy); } long int PromptlnRange(const string & prompt,long int low, long int high) // precondition: low <= high // postcondition: returns a value between low and high (inclusive) { long int retval = PromptRange(prompt,low,high); eatline(); return retval; } int PromptRange(const string & prompt,int low, int high) // precondition: low <= high // postcondition: returns a value between low and high (inclusive) { int value; string response; do { cout << prompt << " between "; cout << low << " and " << high << ": "; cin >> response; value = atoi(response.c_str()); } while (value < low || high < value); return value; } int PromptlnRange(const string & prompt,int low, int high) // precondition: low <= high // postcondition: returns a value between low and high (inclusive) { int retval = PromptRange(prompt,low,high); eatline(); return retval; } double PromptRange(const string & prompt,double low, double high) // precondition: low <= high // postcondition: returns a value between low and high (inclusive) { double value; string response; do { cout << prompt << " between "; cout << low << " and " << high << ": "; cin >> response; value = atof(response.c_str()); } while (value < low || high < value); return value; } double PromptlnRange(const string & prompt,double low, double high) // precondition: low <= high // postcondition: returns a value between low and high (inclusive) { double retval = PromptRange(prompt,low,high); eatline(); return retval; } string PromptString(const string & prompt) // postcondition: returns string entered by user { string str; cout << prompt; cin >> str; return str; } string PromptlnString(const string & prompt) // postcondition: returns string entered by user { string str; cout << prompt; getline(cin,str); return str; } bool PromptYesNo(const string & prompt) // postcondition: returns true iff user enters yes { string str; char ch; do { cout << prompt << " "; cin >> str; ch = tolower(str[0]); } while (ch != 'y' && ch != 'n'); return ch == 'y'; } bool PromptlnYesNo(const string & prompt) // postcondition: returns true iff user enters yes { bool retval = PromptYesNo(prompt); eatline(); return retval; }
[ "burakkuz@sabanciuniv.edu" ]
burakkuz@sabanciuniv.edu
b8be037b149faf7572c483af44a4f0f08e7245f9
546bea1cb4cec407912f3bab94e4ec5500aa888b
/p55.cpp
189e2ef595d3d5b901459c65da2ec144693c0b7e
[]
no_license
Aa-kash-roy/LeetcodeDp150
84c1251ff33705cca712292cf9f1a45be32c49d3
6e3d2a3133a418bf49219769305bca4cb38db2db
refs/heads/main
2023-03-03T20:52:50.777697
2021-02-15T12:04:37
2021-02-15T12:04:37
326,923,078
0
0
null
null
null
null
UTF-8
C++
false
false
1,886
cpp
// link :: https://leetcode.com/problems/shortest-path-in-binary-matrix/ class Solution { public: int x_mov[8] = {1, 1, 1, 0, 0, -1, -1, -1}; int y_mov[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; bool is_valid(int x, int y, int n){ if(x<0 || y<0 || x>=n || y>=n) return false; return true; } int shortestPathBinaryMatrix(vector<vector<int>>& grid) { int n = grid.size(); if(grid[0][0] == 1 || grid[n-1][n-1] == 1) return -1; int dp[n][n]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++) dp[i][j] = INT_MAX; } dp[0][0] = 1; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i==0 && j==0){ dp[i][j] = 1; if(!grid[i][j]){ for(int k=0;k<8;k++){ int new_x = i + x_mov[k], new_y = j + y_mov[k]; if(is_valid(new_x, new_y, n) && !grid[new_x][new_y] && dp[i][j] != INT_MAX){ dp[new_x][new_y] = min(dp[new_x][new_y], (1 + dp[i][j])); } } } } else { if(!grid[i][j]){ for(int k=0;k<8;k++){ int new_x = i + x_mov[k], new_y = j + y_mov[k]; if(is_valid(new_x, new_y, n) && !grid[new_x][new_y] && dp[i][j] != INT_MAX){ dp[new_x][new_y] = min(dp[new_x][new_y], (1 + dp[i][j])); } } } } } } if(dp[n-1][n-1] != INT_MAX) return dp[n-1][n-1]; return -1; } };
[ "noreply@github.com" ]
noreply@github.com
1db4b03b7bc3a8167ceb52bcd5ca059eb1385486
184180d341d2928ab7c5a626d94f2a9863726c65
/issuestests/ALassoSurvIC/inst/testfiles/fun_subless/AFL_fun_subless/fun_subless_DeepState_TestHarness.cpp
86220145d5d4a1b93ea26c8d9dc105142bd47b93
[]
no_license
akhikolla/RcppDeepStateTest
f102ddf03a22b0fc05e02239d53405c8977cbc2b
97e73fe4f8cb0f8e5415f52a2474c8bc322bbbe5
refs/heads/master
2023-03-03T12:19:31.725234
2021-02-12T21:50:12
2021-02-12T21:50:12
254,214,504
2
1
null
null
null
null
UTF-8
C++
false
false
1,394
cpp
// AUTOMATICALLY GENERATED BY RCPPDEEPSTATE PLEASE DO NOT EDIT BY HAND, INSTEAD EDIT // fun_subless_DeepState_TestHarness_generation.cpp and fun_subless_DeepState_TestHarness_checks.cpp #include <fstream> #include <ctime> #include <RInside.h> #include <iostream> #include <RcppDeepState.h> #include <qs.h> #include <DeepState.hpp> LogicalMatrix fun_subless(NumericVector u, NumericVector lessthan); TEST(ALassoSurvIC_deepstate_test,fun_subless_test){ RInside R; std::time_t t = std::time(0); std::cout << "input starts" << std::endl; NumericVector u = RcppDeepState_NumericVector(); std::string u_t = "/home/akhila/fuzzer_packages/fuzzedpackages/ALassoSurvIC/inst/testfiles/fun_subless/AFL_fun_subless/afl_inputs/" + std::to_string(t) + "_u.qs"; qs::c_qsave(u,u_t, "high", "zstd", 1, 15, true, 1); std::cout << "u values: "<< u << std::endl; NumericVector lessthan = RcppDeepState_NumericVector(); std::string lessthan_t = "/home/akhila/fuzzer_packages/fuzzedpackages/ALassoSurvIC/inst/testfiles/fun_subless/AFL_fun_subless/afl_inputs/" + std::to_string(t) + "_lessthan.qs"; qs::c_qsave(lessthan,lessthan_t, "high", "zstd", 1, 15, true, 1); std::cout << "lessthan values: "<< lessthan << std::endl; std::cout << "input ends" << std::endl; try{ fun_subless(u,lessthan); } catch(Rcpp::exception& e){ std::cout<<"Exception Handled"<<std::endl; } }
[ "akhilakollasrinu424jf@gmail.com" ]
akhilakollasrinu424jf@gmail.com
91b59694bd9a6cfb5dbaa798031b531c644f986f
c3723a78471fda07ed280ce7a32da5d97ae0741a
/PAG/PAG01/PAG01/Input.cpp
aa5e0dab8de1ed30ec41ba92228e77f5ee220fc4
[]
no_license
ACPLMaverick/marjan
fa603521089f73900728bba99d79c460bb76f22f
afab932182985021560b291885ec2dd9617d0709
refs/heads/master
2021-01-10T18:45:15.809889
2017-05-09T09:29:59
2017-05-09T09:29:59
17,566,421
0
0
null
null
null
null
UTF-8
C++
false
false
773
cpp
#include "Input.h" Input::Input() { horizontalAngle = 0.0f; verticalAngle = 0.0f; horizontalActual = 0.0f; verticalActual = 0.0f; } Input::~Input() { } bool Input::Initialize(GLFWwindow* window, GLFWscrollfun fun) { m_window = window; glfwSetInputMode(m_window, GLFW_STICKY_KEYS, GL_TRUE); glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); glfwSetInputMode(m_window, GLFW_STICKY_MOUSE_BUTTONS, GL_TRUE); glfwSetScrollCallback(window, fun); return true; } void Input::Shutdown() { } bool Input::IsKeyDown(int keyCode) { if (glfwGetKey(m_window, keyCode) == GLFW_PRESS) return true; else return false; } bool Input::IsMouseButtonDown(int keyCode) { if (glfwGetMouseButton(m_window, keyCode) == GLFW_PRESS) return true; else return false; }
[ "MaverickCCCP@Gmail.com" ]
MaverickCCCP@Gmail.com
78995ab800b0d7deabc323853008daf1b525f962
4f06b67cdd92724020d7a7bfd9428f631ceb986d
/app/inc/rendering/RenderPassText.hpp
4f155342f5dc641cce0f2baadc57775373263f55
[ "MIT" ]
permissive
filipwasil/rearwing-glviewer
857e19dbd0abf7a6947628b236ad86ad201c6fa8
3d0289398367b6dc330eae18042497b8da2e77da
refs/heads/master
2020-08-30T12:36:59.968087
2020-01-24T10:06:01
2020-01-24T10:06:01
218,382,206
0
0
null
null
null
null
UTF-8
C++
false
false
531
hpp
#pragma once #include <array> namespace rwc { /*! * @class RenderPassDefault is a text specific class to be used together with renderer * Its purpose is to implement preRender and postRender callbacks * It is used as first parameter for Renderer class specialization */ struct RenderPassText final { /* * @brief called by renderer before render items starts to render */ void preRender(); /* * @brief called by renderer after render items starts to render */ void postRender(); }; } // namespace rwc
[ "filipwasil@saferendering.com" ]
filipwasil@saferendering.com
a19336e9d2aabf4fb0d74d3076ffcdb1ddc4cf61
bb32b44cdfe08a2a13ced83c9e7184dd76280cd5
/1/main.cpp
bf80cd8da3326792c93853f6c6f896cdd3b457f8
[]
no_license
Falconesto/algorithmsLabs
2333f95f3745a3911819efb4a11f588e3ee73fbd
7de39ca0ff57e9b219fbe30aceb58935346545be
refs/heads/main
2023-03-28T17:33:16.151616
2021-04-07T18:53:33
2021-04-07T18:53:33
355,651,693
0
0
null
null
null
null
UTF-8
C++
false
false
5,102
cpp
#include <iostream> #include <queue> using namespace std; struct point { int x; int y; }; struct arrayy { int distance; char value; }; string bfs(vector<vector<arrayy>> &arr, int iStart, int jStart, int x, int y) { queue<point> pointsQueue; point firstPoint; firstPoint.x = jStart; firstPoint.y = iStart; pointsQueue.push(firstPoint); while (!pointsQueue.empty()) { point first = pointsQueue.front(); pointsQueue.pop(); if (arr[first.y][first.x].value == 'T') { string route; int yLimit = first.y; int xLimit = first.x; for (int i = 0; i < arr[yLimit][xLimit].distance; i++) { if ((first.y - 1 >= 0) && (arr[first.y - 1][first.x].distance == arr[first.y][first.x].distance - 1)) { route.insert(0, "D"); first.y = first.y - 1; } else { if ((first.x - 1 >= 0) && (arr[first.y][first.x - 1].distance == arr[first.y][first.x].distance - 1)) { route.insert(0, "R"); first.x = first.x - 1; } else { if ((first.x + 1 < x) && (arr[first.y][first.x + 1].distance == arr[first.y][first.x].distance - 1)) { route.insert(0, "L"); first.x = first.x + 1; } else { if ((first.y + 1 < y) && (arr[first.y + 1][first.x].distance == arr[first.y][first.x].distance - 1)) { route.insert(0, "U"); first.y = first.y + 1; } } } } } return route; } else { if (((first.y + 1 < y) && ((arr[first.y + 1][first.x].value == '.') || (arr[first.y + 1][first.x].value == 'T'))) && (arr[first.y + 1][first.x].distance == -1)) { arr[first.y + 1][first.x].distance = arr[first.y][first.x].distance + 1; point tmp; tmp.x = first.x; tmp.y = first.y + 1; pointsQueue.push(tmp); } if (((first.x - 1 >= 0) && ((arr[first.y][first.x - 1].value == '.') || (arr[first.y][first.x - 1].value == 'T'))) && (arr[first.y][first.x - 1].distance == -1)) { arr[first.y][first.x - 1].distance = arr[first.y][first.x].distance + 1; point tmp; tmp.x = first.x - 1; tmp.y = first.y; pointsQueue.push(tmp); } if (((first.x + 1 < x) && ((arr[first.y][first.x + 1].value == '.') || (arr[first.y][first.x + 1].value == 'T'))) && (arr[first.y][first.x + 1].distance == -1)) { arr[first.y][first.x + 1].distance = arr[first.y][first.x].distance + 1; point tmp; tmp.x = first.x + 1; tmp.y = first.y; pointsQueue.push(tmp); } if (((first.y - 1 >= 0) && ((arr[first.y - 1][first.x].value == '.') || (arr[first.y - 1][first.x].value == 'T'))) && (arr[first.y - 1][first.x].distance == -1)) { arr[first.y - 1][first.x].distance = arr[first.y][first.x].distance + 1; point tmp; tmp.x = first.x; tmp.y = first.y - 1; pointsQueue.push(tmp); } } } string route = "bad"; return route; } int main() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); int x; int y; cin >> x >> y; if (x * y < 2) { cout << -1; return 0; } vector<vector<arrayy>> arr(x, vector<arrayy>(y)); int iStart = -1; int jStart = -1; bool sExists = false; bool tExists = false; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { char lol; cin >> lol; arr[i][j].value = lol; if (arr[i][j].value == 'T') { tExists = true; } if (arr[i][j].value == 'S') { arr[i][j].distance = 0; sExists = true; iStart = i; jStart = j; } else arr[i][j].distance = -1; } } if ((sExists) && (tExists)) { string route = bfs(arr, iStart, jStart, y, x); if(route=="bad"){ cout << -1; return 0; } cout << route.length() << endl; cout << route; } else { cout << -1; return 0; } return 0; } CPerson Vasya(Vasya Poopkin, 11); CPerson Vasiliy(Vasya); CPerson Sanek; sanek KvMng syka(1, 2, 3); vivedi(syka); //x^2 + 2*x + 3 KvMng blyat(x^2 + 2*x + 3); int k = znach(blyat, 1); int s = Cho-to
[ "a.g.sokolovskii@gmail.com" ]
a.g.sokolovskii@gmail.com
6216fda17a1bc0acf384964cc10244101214613d
ad273708d98b1f73b3855cc4317bca2e56456d15
/aws-cpp-sdk-networkmanager/include/aws/networkmanager/model/GlobalNetwork.h
17e88d19c4b552ef2856e2ccdb12cb7dd8664a59
[ "MIT", "Apache-2.0", "JSON" ]
permissive
novaquark/aws-sdk-cpp
b390f2e29f86f629f9efcf41c4990169b91f4f47
a0969508545bec9ae2864c9e1e2bb9aff109f90c
refs/heads/master
2022-08-28T18:28:12.742810
2020-05-27T15:46:18
2020-05-27T15:46:18
267,351,721
1
0
Apache-2.0
2020-05-27T15:08:16
2020-05-27T15:08:15
null
UTF-8
C++
false
false
9,846
h
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ #pragma once #include <aws/networkmanager/NetworkManager_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/utils/DateTime.h> #include <aws/networkmanager/model/GlobalNetworkState.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/networkmanager/model/Tag.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace NetworkManager { namespace Model { /** * <p>Describes a global network.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/networkmanager-2019-07-05/GlobalNetwork">AWS * API Reference</a></p> */ class AWS_NETWORKMANAGER_API GlobalNetwork { public: GlobalNetwork(); GlobalNetwork(Aws::Utils::Json::JsonView jsonValue); GlobalNetwork& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The ID of the global network.</p> */ inline const Aws::String& GetGlobalNetworkId() const{ return m_globalNetworkId; } /** * <p>The ID of the global network.</p> */ inline bool GlobalNetworkIdHasBeenSet() const { return m_globalNetworkIdHasBeenSet; } /** * <p>The ID of the global network.</p> */ inline void SetGlobalNetworkId(const Aws::String& value) { m_globalNetworkIdHasBeenSet = true; m_globalNetworkId = value; } /** * <p>The ID of the global network.</p> */ inline void SetGlobalNetworkId(Aws::String&& value) { m_globalNetworkIdHasBeenSet = true; m_globalNetworkId = std::move(value); } /** * <p>The ID of the global network.</p> */ inline void SetGlobalNetworkId(const char* value) { m_globalNetworkIdHasBeenSet = true; m_globalNetworkId.assign(value); } /** * <p>The ID of the global network.</p> */ inline GlobalNetwork& WithGlobalNetworkId(const Aws::String& value) { SetGlobalNetworkId(value); return *this;} /** * <p>The ID of the global network.</p> */ inline GlobalNetwork& WithGlobalNetworkId(Aws::String&& value) { SetGlobalNetworkId(std::move(value)); return *this;} /** * <p>The ID of the global network.</p> */ inline GlobalNetwork& WithGlobalNetworkId(const char* value) { SetGlobalNetworkId(value); return *this;} /** * <p>The Amazon Resource Name (ARN) of the global network.</p> */ inline const Aws::String& GetGlobalNetworkArn() const{ return m_globalNetworkArn; } /** * <p>The Amazon Resource Name (ARN) of the global network.</p> */ inline bool GlobalNetworkArnHasBeenSet() const { return m_globalNetworkArnHasBeenSet; } /** * <p>The Amazon Resource Name (ARN) of the global network.</p> */ inline void SetGlobalNetworkArn(const Aws::String& value) { m_globalNetworkArnHasBeenSet = true; m_globalNetworkArn = value; } /** * <p>The Amazon Resource Name (ARN) of the global network.</p> */ inline void SetGlobalNetworkArn(Aws::String&& value) { m_globalNetworkArnHasBeenSet = true; m_globalNetworkArn = std::move(value); } /** * <p>The Amazon Resource Name (ARN) of the global network.</p> */ inline void SetGlobalNetworkArn(const char* value) { m_globalNetworkArnHasBeenSet = true; m_globalNetworkArn.assign(value); } /** * <p>The Amazon Resource Name (ARN) of the global network.</p> */ inline GlobalNetwork& WithGlobalNetworkArn(const Aws::String& value) { SetGlobalNetworkArn(value); return *this;} /** * <p>The Amazon Resource Name (ARN) of the global network.</p> */ inline GlobalNetwork& WithGlobalNetworkArn(Aws::String&& value) { SetGlobalNetworkArn(std::move(value)); return *this;} /** * <p>The Amazon Resource Name (ARN) of the global network.</p> */ inline GlobalNetwork& WithGlobalNetworkArn(const char* value) { SetGlobalNetworkArn(value); return *this;} /** * <p>The description of the global network.</p> */ inline const Aws::String& GetDescription() const{ return m_description; } /** * <p>The description of the global network.</p> */ inline bool DescriptionHasBeenSet() const { return m_descriptionHasBeenSet; } /** * <p>The description of the global network.</p> */ inline void SetDescription(const Aws::String& value) { m_descriptionHasBeenSet = true; m_description = value; } /** * <p>The description of the global network.</p> */ inline void SetDescription(Aws::String&& value) { m_descriptionHasBeenSet = true; m_description = std::move(value); } /** * <p>The description of the global network.</p> */ inline void SetDescription(const char* value) { m_descriptionHasBeenSet = true; m_description.assign(value); } /** * <p>The description of the global network.</p> */ inline GlobalNetwork& WithDescription(const Aws::String& value) { SetDescription(value); return *this;} /** * <p>The description of the global network.</p> */ inline GlobalNetwork& WithDescription(Aws::String&& value) { SetDescription(std::move(value)); return *this;} /** * <p>The description of the global network.</p> */ inline GlobalNetwork& WithDescription(const char* value) { SetDescription(value); return *this;} /** * <p>The date and time that the global network was created.</p> */ inline const Aws::Utils::DateTime& GetCreatedAt() const{ return m_createdAt; } /** * <p>The date and time that the global network was created.</p> */ inline bool CreatedAtHasBeenSet() const { return m_createdAtHasBeenSet; } /** * <p>The date and time that the global network was created.</p> */ inline void SetCreatedAt(const Aws::Utils::DateTime& value) { m_createdAtHasBeenSet = true; m_createdAt = value; } /** * <p>The date and time that the global network was created.</p> */ inline void SetCreatedAt(Aws::Utils::DateTime&& value) { m_createdAtHasBeenSet = true; m_createdAt = std::move(value); } /** * <p>The date and time that the global network was created.</p> */ inline GlobalNetwork& WithCreatedAt(const Aws::Utils::DateTime& value) { SetCreatedAt(value); return *this;} /** * <p>The date and time that the global network was created.</p> */ inline GlobalNetwork& WithCreatedAt(Aws::Utils::DateTime&& value) { SetCreatedAt(std::move(value)); return *this;} /** * <p>The state of the global network.</p> */ inline const GlobalNetworkState& GetState() const{ return m_state; } /** * <p>The state of the global network.</p> */ inline bool StateHasBeenSet() const { return m_stateHasBeenSet; } /** * <p>The state of the global network.</p> */ inline void SetState(const GlobalNetworkState& value) { m_stateHasBeenSet = true; m_state = value; } /** * <p>The state of the global network.</p> */ inline void SetState(GlobalNetworkState&& value) { m_stateHasBeenSet = true; m_state = std::move(value); } /** * <p>The state of the global network.</p> */ inline GlobalNetwork& WithState(const GlobalNetworkState& value) { SetState(value); return *this;} /** * <p>The state of the global network.</p> */ inline GlobalNetwork& WithState(GlobalNetworkState&& value) { SetState(std::move(value)); return *this;} /** * <p>The tags for the global network.</p> */ inline const Aws::Vector<Tag>& GetTags() const{ return m_tags; } /** * <p>The tags for the global network.</p> */ inline bool TagsHasBeenSet() const { return m_tagsHasBeenSet; } /** * <p>The tags for the global network.</p> */ inline void SetTags(const Aws::Vector<Tag>& value) { m_tagsHasBeenSet = true; m_tags = value; } /** * <p>The tags for the global network.</p> */ inline void SetTags(Aws::Vector<Tag>&& value) { m_tagsHasBeenSet = true; m_tags = std::move(value); } /** * <p>The tags for the global network.</p> */ inline GlobalNetwork& WithTags(const Aws::Vector<Tag>& value) { SetTags(value); return *this;} /** * <p>The tags for the global network.</p> */ inline GlobalNetwork& WithTags(Aws::Vector<Tag>&& value) { SetTags(std::move(value)); return *this;} /** * <p>The tags for the global network.</p> */ inline GlobalNetwork& AddTags(const Tag& value) { m_tagsHasBeenSet = true; m_tags.push_back(value); return *this; } /** * <p>The tags for the global network.</p> */ inline GlobalNetwork& AddTags(Tag&& value) { m_tagsHasBeenSet = true; m_tags.push_back(std::move(value)); return *this; } private: Aws::String m_globalNetworkId; bool m_globalNetworkIdHasBeenSet; Aws::String m_globalNetworkArn; bool m_globalNetworkArnHasBeenSet; Aws::String m_description; bool m_descriptionHasBeenSet; Aws::Utils::DateTime m_createdAt; bool m_createdAtHasBeenSet; GlobalNetworkState m_state; bool m_stateHasBeenSet; Aws::Vector<Tag> m_tags; bool m_tagsHasBeenSet; }; } // namespace Model } // namespace NetworkManager } // namespace Aws
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
8e135c3a3bced860fa57fe438246d9f628ddbafe
921abfe8a10a4c0edc3035e8abc4a33d51625c1d
/BOJ/10816_숫자카드2.cpp
363db49f7d197a2fb63f1717d50d39ba88747db7
[]
no_license
gudwnsgur/Algorithm
760fcff3b1e930bf1f8cf047c26253449b52cae9
016f6db056d821c918ea620d5517b00a387eff9a
refs/heads/master
2023-05-01T03:28:17.003101
2023-04-18T14:08:05
2023-04-18T14:08:05
230,247,085
4
0
null
null
null
null
UTF-8
C++
false
false
506
cpp
#include <vector> #include <algorithm> #include <iostream> #include <map> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, num; cin >> n; map<int, int> M; for (int i = 0; i < n; i++) { cin >> num; if (M.find(num) != M.end()) M.find(num)->second++; else M.insert({ num, 1 }); } cin >> m; for (int i = 0; i < m; i++) { cin >> num; cout << (M.find(num) != M.end() ? M.find(num)->second : 0) << ' '; } cout << endl; return 0; }
[ "gudwnsgur12@naver.com" ]
gudwnsgur12@naver.com
5fc401becdf2fb288f5a019c056d0ef27a70b500
546e90101a9f2430b8292903802a38db5ad92dbe
/tinhnamamlich.cpp
20708f4f1d662443305eaf21705d9fcc8ac5aecc
[]
no_license
VoKimTri/Programming-techniques
5079bc15a37ab82e84c06e6ff9be75206262cc7d
8034349d066230ddbd68bb1e9a000ea0df9576e8
refs/heads/master
2020-09-22T22:12:49.929901
2019-12-02T09:13:51
2019-12-02T09:13:51
225,332,136
0
0
null
null
null
null
UTF-8
C++
false
false
328
cpp
#include <math.h> #include <bits/stdc++.h> #include <iostream> using namespace std; int a[100001]; int main() { int n, i, k = 0; cin>>n; for (i = 0; i < n; i++){ cin>>a[i]; if (a[i]%19==0 || a[i]%19==3 || a[i]%19==6 || a[i]%19==9 || a[i]%19==11 || a[i]%19==14 || a[i]%19==17) k++; } cout<<k; }
[ "noreply@github.com" ]
noreply@github.com
280f7fc140f61463fe4807c812b3ad096c4c83fb
6f4cd87855aaf2db66894e79463dac19b91e20ca
/file_helpers.cpp
775ef4b2690e802d870a4761687c3cac2b103e45
[]
no_license
vendethiel/worldofcore.cpp
24bddc5016402663bc2314c7fd28221dd0a54b8a
568abe60f57227d3fb56163579512abb883591f2
refs/heads/master
2021-01-17T07:15:52.871679
2016-05-06T15:05:37
2016-05-06T15:05:37
33,720,131
0
0
null
null
null
null
UTF-8
C++
false
false
462
cpp
#include <string> #include <fstream> #include "file_helpers.hpp" std::ifstream::pos_type file_helpers::get_file_size(char const* filename) { std::ifstream in(filename, std::ifstream::ate | std::ifstream::binary); return in.tellg(); } const char* file_helpers::read_file(char const* filename) { std::ifstream t(filename); std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>()); return str.c_str(); };
[ "vendethiel@hotmail.fr" ]
vendethiel@hotmail.fr
5ad75f4a4caff681a6edf64b4ecbaaa92e1b4edd
260e5dec446d12a7dd3f32e331c1fde8157e5cea
/Indi/SDK/Indi_Engineering_Skill_parameters.hpp
d7a12213dfabc75f11b5e9c3cdfb490be095c28c
[]
no_license
jfmherokiller/TheOuterWorldsSdkDump
6e140fde4fcd1cade94ce0d7ea69f8a3f769e1c0
18a8c6b1f5d87bb1ad4334be4a9f22c52897f640
refs/heads/main
2023-08-30T09:27:17.723265
2021-09-17T00:24:52
2021-09-17T00:24:52
407,437,218
0
0
null
null
null
null
UTF-8
C++
false
false
364
hpp
#pragma once // TheOuterWorlds SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "Indi_Engineering_Skill_classes.hpp" namespace SDK { //--------------------------------------------------------------------------- //Parameters //--------------------------------------------------------------------------- } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "peterpan0413@live.com" ]
peterpan0413@live.com
b8d7452455cd0845c7484d44411464d10b1849d2
c49461da0582407866ea199c29eaa4a38c0ffa84
/sparta/example/DynamicModelPipeline/src/ExampleSimulation.cpp
fba0abe3978a5ef55ebe99a3e4607f7b51c6ba83
[ "MIT" ]
permissive
eabsi5/map
092ef88bf25d1699c8623a233ebea1d2245d3d4f
970ab5c46b3785201edc85c00d40fb64312d9a9a
refs/heads/master
2021-07-06T01:09:41.912343
2021-04-09T21:49:09
2021-04-09T21:49:09
232,630,030
0
0
MIT
2020-01-08T18:22:17
2020-01-08T18:22:16
null
UTF-8
C++
false
false
52,274
cpp
// <Simulation.cpp> -*- C++ -*- #include <iostream> #include "ExampleSimulation.hpp" #include "Core.hpp" #include "sparta/simulation/Clock.hpp" #include "sparta/utils/TimeManager.hpp" #include "sparta/simulation/TreeNode.hpp" #include "sparta/simulation/TreeNodeExtensions.hpp" #include "sparta/trigger/ContextCounterTrigger.hpp" #include "sparta/utils/StringUtils.hpp" #include "sparta/report/DatabaseInterface.hpp" #include "simdb/schema/Schema.hpp" #include "simdb/async/AsyncTaskEval.hpp" #include "simdb/impl/sqlite/SQLiteConnProxy.hpp" #include "simdb/impl/hdf5/HDF5ConnProxy.hpp" #include "simdb/utils/uuids.hpp" #include "Fetch.hpp" #include "Decode.hpp" #include "Rename.hpp" #include "Dispatch.hpp" #include "Execute.hpp" #include "LSU.hpp" #include "ROB.hpp" #include "FlushManager.hpp" #include "Preloader.hpp" // UPDATE #include "BIU.hpp" #include "MSS.hpp" namespace { // Struct for writing and verifying SQLite records. // See buildSchemaA() below. struct TestSQLiteSchemaA { struct Numbers { double First; double Second; }; Numbers numbers; struct Metadata { std::string Name; double Value; }; Metadata metadata; static TestSQLiteSchemaA createRandom() { TestSQLiteSchemaA s; s.numbers.First = rand() / 1000 * 3.14; s.numbers.Second = rand() / 1000 * 3.14; s.metadata.Name = simdb::generateUUID(); s.metadata.Value = rand() / 1000 * 3.14; return s; } }; // Another struct for writing and verifying SQLite // records. See buildSchemaB() below. struct TestSQLiteSchemaB { struct Strings { std::string First; std::string Second; }; Strings strings; struct Metadata { std::string Name; std::string Value; }; Metadata metadata; static TestSQLiteSchemaB createRandom() { TestSQLiteSchemaB s; s.strings.First = simdb::generateUUID(); s.strings.Second = simdb::generateUUID(); s.metadata.Name = simdb::generateUUID(); s.metadata.Value = simdb::generateUUID(); return s; } }; // Struct for writing and verifying HDF5 records struct TestHDF5SchemaC { double x; double y; uint16_t z; static TestHDF5SchemaC createRandom() { TestHDF5SchemaC s; s.x = rand() / 1000 * 3.14; s.y = rand() / 1000 * 3.14; s.z = rand(); return s; } }; // Helper class which creates random SQLite / HDF5 // structs for SimDB writes, and stores the structs // in memory too. The data will be read back from // the database at the end of simulation, and the // values retrieved from file will be compared with // the values that were stored in memory. class DatabaseTester { public: static DatabaseTester & getTester() { static DatabaseTester tester; return tester; } ~DatabaseTester() = default; const TestSQLiteSchemaA & createAndStoreRecordForSQLiteSchemaA() { if (records_schemaA_.size() < 100) { indices_schemaA_.emplace_back(records_schemaA_.size()); records_schemaA_.emplace_back(TestSQLiteSchemaA::createRandom()); return records_schemaA_.back(); } else { indices_schemaA_.emplace_back(rand() % records_schemaA_.size()); return records_schemaA_[indices_schemaA_.back()]; } } const TestSQLiteSchemaB & createAndStoreRecordForSQLiteSchemaB() { if (records_schemaB_.size() < 100) { indices_schemaB_.emplace_back(records_schemaB_.size()); records_schemaB_.emplace_back(TestSQLiteSchemaB::createRandom()); return records_schemaB_.back(); } else { indices_schemaB_.emplace_back(rand() % records_schemaB_.size()); return records_schemaB_[indices_schemaB_.back()]; } } const TestHDF5SchemaC & createAndStoreRecordForHDF5SchemaC() { records_schemaC_.emplace_back(TestHDF5SchemaC::createRandom()); return records_schemaC_.back(); } const std::vector<TestSQLiteSchemaA> & getWrittenRecordsForSchemaA() const { return records_schemaA_; } const std::vector<TestSQLiteSchemaB> & getWrittenRecordsForSchemaB() const { return records_schemaB_; } const std::vector<TestHDF5SchemaC> & getWrittenRecordsForSchemaC() const { return records_schemaC_; } void verifyRecords(const std::string & db_file) const { simdb::ObjectManager obj_mgr("."); if (!obj_mgr.connectToExistingDatabase(db_file)) { return; } auto numeric_db = GET_DB_FROM_CURRENT_SIMULATION(NumericMeta); if (numeric_db) { auto values_query = numeric_db->createObjectQueryForTable("Numbers"); if (values_query) { double first, second; values_query->writeResultIterationsTo( "First", &first, "Second", &second); if (values_query->countMatches() != indices_schemaA_.size()) { throw sparta::SpartaException("Could not verify SimDB records"); } auto result_iter = values_query->executeQuery(); size_t record_idx = 0; while (result_iter->getNext()) { const auto & expected = records_schemaA_[indices_schemaA_[record_idx]]; if (first != expected.numbers.First) { throw sparta::SpartaException("Could not verify SimDB records"); } if (second != expected.numbers.Second) { throw sparta::SpartaException("Could not verify SimDB records"); } ++record_idx; } } auto meta_query = numeric_db->createObjectQueryForTable("Metadata"); if (meta_query) { std::string name; double value; meta_query->writeResultIterationsTo("Name", &name, "Value", &value); if (meta_query->countMatches() != indices_schemaA_.size()) { throw sparta::SpartaException("Could not verify SimDB records"); } auto result_iter = meta_query->executeQuery(); size_t record_idx = 0; while (result_iter->getNext()) { const auto & expected = records_schemaA_[indices_schemaA_[record_idx]]; if (name != expected.metadata.Name) { throw sparta::SpartaException("Could not verify SimDB records"); } if (value != expected.metadata.Value) { throw sparta::SpartaException("Could not verify SimDB records"); } ++record_idx; } } } } private: DatabaseTester() = default; std::vector<TestSQLiteSchemaA> records_schemaA_; std::vector<TestSQLiteSchemaB> records_schemaB_; std::vector<TestHDF5SchemaC> records_schemaC_; std::vector<uint16_t> indices_schemaA_; std::vector<uint16_t> indices_schemaB_; std::vector<uint16_t> indices_schemaC_; }; // Schema builder to test two simdb::ObjectManager's // bound to the same database file, separated in that // same file by their respective application name. // A third schema builder is for another ObjectManager, // though it will be used to write records to an HDF5 // database, and therefore will be in its own file. // SimDB's worker thread should be able to keep them // separated into two groups: one group for the two // SQLite database connections, and one group only // serving the one HDF5 connection. // // Note that the two schema builders below have some // overlap in their table definitions: schemaA and // schemaB have some of the same table names, but // these tables have different column configurations. // This should not be a problem for ObjectManager // since it will use its unique application name // with the table names we give it to create a // unique schema inside the shared file, separated // from other applications tied to the same file. // The specific way in which the schemas are kept // separate in the file is not our concern; the // DbConnProxy subclasses take care of those // specifics. void buildSchemaA(simdb::Schema & schema) { using dt = simdb::ColumnDataType; schema.addTable("Numbers") .addColumn("First", dt::double_t) .addColumn("Second", dt::double_t); schema.addTable("Metadata") .addColumn("Name", dt::string_t) .addColumn("Value", dt::double_t); } void buildSchemaB(simdb::Schema & schema) { using dt = simdb::ColumnDataType; schema.addTable("Strings") .addColumn("First", dt::string_t) .addColumn("Second", dt::string_t); schema.addTable("Metadata") .addColumn("Name", dt::string_t) .addColumn("Value", dt::string_t); } void buildSchemaC(simdb::Schema & schema) { using dt = simdb::ColumnDataType; schema.addTable("Numbers") .addField("x", dt::double_t, FOFFSET(TestHDF5SchemaC,x)) .addField("y", dt::double_t, FOFFSET(TestHDF5SchemaC,y)) .addField("z", dt::uint16_t, FOFFSET(TestHDF5SchemaC,z)); } simdb::DbConnProxy * createSQLiteProxy() { return new simdb::SQLiteConnProxy; } simdb::DbConnProxy * createHDF5Proxy() { return new simdb::HDF5ConnProxy; } } namespace sparta { // Example parameter set used to reproduce write-final-config // bug class IntParameterSet : public ParameterSet { public: IntParameterSet(TreeNode * parent) : ParameterSet(parent), int_param_(new Parameter<uint32_t>( "baz", 0, "Example parameter set to reproduce bug")) { addParameter_(int_param_.get()); } uint32_t read() const { return int_param_->getValue(); } private: std::unique_ptr<Parameter<uint32_t>> int_param_; }; // Dummy node class used together with IntParameterSet to // reproduce write-final-config bug class Baz : public TreeNode { public: Baz(TreeNode* parent, const std::string & desc) : TreeNode(parent, "baz_node", "BazGroup", 0, desc) { baz_.reset(new IntParameterSet(this)); if (auto dbconn = GET_DB_FOR_COMPONENT(Stats, this)) { //Run a simple query against the database just to verify //the connection is open and accepting requests (void) dbconn->findObject("ObjectManagersInDatabase", 1); } } void readParams() { std::cout << " Node '" << getLocation() << "' has parameter 'baz' with a value set to " << baz_->read() << std::endl; } private: std::unique_ptr<IntParameterSet> baz_; }; } template <typename DataT> void validateParameter(const sparta::ParameterSet & params, const std::string & param_name, const DataT & expected_value) { if (!params.hasParameter(param_name)) { return; } const DataT actual_value = params.getParameterValueAs<DataT>(param_name); if (actual_value != expected_value) { throw sparta::SpartaException("Invalid extension parameter encountered:\n") << "\tParameter name: " << param_name << "\nParameter value (actual): " << actual_value << "\nParameter value (expected): " << expected_value; } } template <typename DataT> void validateParameter(const sparta::ParameterSet & params, const std::string & param_name, const std::set<DataT> & expected_values) { bool found = false; for (const auto & expected : expected_values) { try { found = false; validateParameter<DataT>(params, param_name, expected); found = true; break; } catch (...) { } } if (!found) { throw sparta::SpartaException("Invalid extension parameter " "encountered for '") << param_name << "'"; } } class CircleExtensions : public sparta::ExtensionsParamsOnly { public: CircleExtensions() : sparta::ExtensionsParamsOnly() {} virtual ~CircleExtensions() {} void doSomethingElse() const { std::cout << "Invoking a method that is unknown to the sparta::TreeNode object, " "even though 'this' object was created by, and currently owned by, " "a specific tree node."; } private: // Note: this parameter is NOT in the yaml config file, // but subclasses can provide any parameter type supported // by sparta::Parameter<T> which may be too complicated to // clearly describe using simple yaml syntax std::unique_ptr<sparta::Parameter<double>> degrees_; // The base class will clobber together whatever parameter values it // found in the yaml file, and give us a chance to add custom parameters // to the same set virtual void postCreate() override { sparta::ParameterSet * ps = getParameters(); degrees_.reset(new sparta::Parameter<double>( "degrees_", 360.0, "Number of degrees in a circle", ps)); } }; double calculateAverageOfInternalCounters( const std::vector<const sparta::CounterBase*> & counters) { double agg = 0; for (const auto & ctr : counters) { agg += ctr->get(); } return agg / counters.size(); } void tryAccessSimDB() { if (auto dbconn = GET_DB_FROM_CURRENT_SIMULATION(Stats)) { //Run a simple query against the database just to verify //the connection is open and accepting requests (void) dbconn->findObject("ObjectManagersInDatabase", 1); } } ExampleSimulator::ExampleSimulator(sparta::Scheduler & scheduler, uint32_t num_cores, uint64_t instruction_limit, bool show_factories) : sparta::app::Simulation("sparta_core_example", &scheduler), num_cores_(num_cores), instruction_limit_(instruction_limit) { // Set up all resources to be available through ResourceTreeNode getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::Core, core_example::Core::CoreParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::Fetch, core_example::Fetch::FetchParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::Decode, core_example::Decode::DecodeParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::Rename, core_example::Rename::RenameParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::Dispatch, core_example::Dispatch::DispatchParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::Execute, core_example::Execute::ExecuteParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::LSU, core_example::LSU::LSUParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::SimpleTLB, core_example::SimpleTLB::TLBParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::BIU, core_example::BIU::BIUParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::MSS, core_example::MSS::MSSParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::ROB, core_example::ROB::ROBParameterSet>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::FlushManager, core_example::FlushManager::FlushManagerParameters>>(); getResourceSet()->addResourceFactory<sparta::ResourceFactory<core_example::Preloader, core_example::Preloader::PreloaderParameterSet>>(); // Print the registered factories if(show_factories) { std::cout << "Registered factories: \n"; for(const auto & f : *getResourceSet()) { std::cout << "\t" << f.first << std::endl; } } // Set up all node extension factories to be available during the simulation // - This is only needed for parameter sets that also want to add some methods // to their tree node extension, and/or for those that want to extend node // parameter sets with more complicated sparta::Parameter<T> data types addTreeNodeExtensionFactory_("circle", [](){return new CircleExtensions;}); // Initialize example simulation controller controller_.reset(new ExampleSimulator::ExampleController(this)); setSimulationController_(controller_); // Register a custom calculation method for 'combining' a context counter's // internal counters into one number. In this example simulator, let's just // use an averaging function called "avg" which we can then invoke from report // definition YAML files. sparta::trigger::ContextCounterTrigger::registerContextCounterCalcFunction( "avg", &calculateAverageOfInternalCounters); //SQLite namespaces: NumericMeta & StringMeta REGISTER_SIMDB_NAMESPACE(NumericMeta, SQLite); REGISTER_SIMDB_SCHEMA_BUILDER(NumericMeta, buildSchemaA); REGISTER_SIMDB_NAMESPACE(StringMeta, SQLite); REGISTER_SIMDB_SCHEMA_BUILDER(StringMeta, buildSchemaB); //HDF5 namespace: NumericVals REGISTER_SIMDB_NAMESPACE(NumericVals, HDF5); REGISTER_SIMDB_SCHEMA_BUILDER(NumericVals, buildSchemaC); //Proxy factory registration REGISTER_SIMDB_PROXY_CREATE_FUNCTION(HDF5, createHDF5Proxy); } ExampleSimulator::~ExampleSimulator() { getRoot()->enterTeardown(); // Allow deletion of nodes without error now if (on_triggered_notifier_registered_) { getRoot()->DEREGISTER_FOR_NOTIFICATION( onTriggered_, std::string, "sparta_expression_trigger_fired"); } if (simdb_perf_async_ctrl_enabled_) { std::set<std::string> simdb_files; if (auto dbconn = GET_DB_FOR_COMPONENT(NumericMeta, this)) { simdb_files.insert(dbconn->getDatabaseFile()); } for (const auto & db_file : simdb_files) { DatabaseTester::getTester().verifyRecords(db_file); } } } void ExampleSimulator::buildTree_() { // TREE_BUILDING Phase. See sparta::PhasedObject::TreePhase for (uint32_t i = 0; i < num_cores_; ++i) { std::stringstream nodeName, humanName; nodeName << "core" << i; humanName << "Core " << i; // We create resource tree nodes because each component of the // core requires parameters and a clock. TreeNode does not // provide this. sparta::ResourceTreeNode* core_tn = new sparta::ResourceTreeNode(getRoot(), nodeName.str(), "core", i, humanName.str(), getResourceSet()->getResourceFactory("core_example_core")); to_delete_.emplace_back(core_tn); // Testing reading of parameter values early on. These should be poplated from the virtual // tree based on user input configuration and could be use to make decisions about topology std::cout << "reading core 0 foo parameter = " << core_tn->getParameterSet()->getParameterValueAs<std::string>("foo") << std::endl; std::cout << "printing core0 foo parameter = " << core_tn->getParameterSet()->getParameterAs<std::string>("foo") << std::endl; sparta::ResourceTreeNode* rtn = new sparta::ResourceTreeNode(core_tn, core_example::FlushManager::name, sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "Flush Manager", getResourceSet()->getResourceFactory(core_example::FlushManager::name)); to_delete_.emplace_back(rtn); rtn = new sparta::ResourceTreeNode(core_tn, "fetch", sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "Fetch Unit", getResourceSet()->getResourceFactory("fetch")); to_delete_.emplace_back(rtn); rtn = new sparta::ResourceTreeNode(core_tn, "decode", sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "Decode Unit", getResourceSet()->getResourceFactory("decode")); to_delete_.emplace_back(rtn); rtn = new sparta::ResourceTreeNode(core_tn, "rename", sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "Rename Unit", getResourceSet()->getResourceFactory("rename")); to_delete_.emplace_back(rtn); rtn = new sparta::ResourceTreeNode(core_tn, "dispatch", sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "Dispatch Unit", getResourceSet()->getResourceFactory("dispatch")); to_delete_.emplace_back(rtn); // In the middle of the subclass' buildTree_() method, let's see if we can access // a particular named extension... for a tree node that was just created. sparta::TreeNode * dispatch = getRoot()->getChild("core0.dispatch", false); if (dispatch) { sparta::TreeNode::ExtensionsBase * extensions = dispatch->getExtension("user_data"); // If present, validate the parameter values as given in the extension / configuration file if (extensions != nullptr) { const sparta::ParameterSet * dispatch_prms = extensions->getParameters(); sparta_assert(dispatch_prms != nullptr); validateParameter<std::string>(*dispatch_prms, "when_", "buildTree_"); validateParameter<std::string>(*dispatch_prms, "why_", "checkAvailability"); } // There might be an extension given in --extension-file that is not found // at all in any --config-file given at the command prompt. Verify that if // present, the value is as expected. extensions = dispatch->getExtension("square"); if (extensions != nullptr) { const sparta::ParameterSet * dispatch_prms = extensions->getParameters(); sparta_assert(dispatch_prms != nullptr); validateParameter<std::string>(*dispatch_prms, "edges_", "4"); } } // This ALU will show up in the tree as top.core0.alu0. In // python, this can also be accessed as top.core0.alu[0] rtn = new sparta::ResourceTreeNode(core_tn, "alu0", "alu", 0, "ALU Unit 0", getResourceSet()->getResourceFactory("execute")); to_delete_.emplace_back(rtn); // This ALU will show up in the tree as top.core0.alu1. In // python, this can also be accessed as top.core0.alu[1] rtn = new sparta::ResourceTreeNode(core_tn, "alu1", "alu", 1, "ALU Unit 1", getResourceSet()->getResourceFactory("execute")); to_delete_.emplace_back(rtn); // See if there are any extensions for the alu0/alu1 nodes sparta::TreeNode * alu0 = getRoot()->getChild("core0.alu0"); sparta::TreeNode * alu1 = getRoot()->getChild("core0.alu1"); if (alu0) { sparta::TreeNode::ExtensionsBase * extensions = alu0->getExtension("difficulty"); if (extensions != nullptr) { const sparta::ParameterSet * alu0_prms = extensions->getParameters(); sparta_assert(alu0_prms != nullptr); validateParameter<std::string>(*alu0_prms, "color_", "black"); validateParameter<std::string>(*alu0_prms, "shape_", "diamond"); } } if (alu1) { sparta::TreeNode::ExtensionsBase * extensions = alu1->getExtension("difficulty"); if (extensions != nullptr) { const sparta::ParameterSet * alu1_prms = extensions->getParameters(); sparta_assert(alu1_prms != nullptr); validateParameter<std::string>(*alu1_prms, "color_", "green"); validateParameter<std::string>(*alu1_prms, "shape_", "circle"); } } rtn = new sparta::ResourceTreeNode(core_tn, "fpu", "alu", 2,"FPU Unit", getResourceSet()->getResourceFactory("execute")); to_delete_.emplace_back(rtn); // Once again, ask for a named extension for a tree node that was just created. // The difference here is that the 'circle' extension also has a factory associated // with it. sparta::TreeNode * fpu = getRoot()->getChild("core0.fpu", false); if (fpu) { sparta::TreeNode::ExtensionsBase * extensions = fpu->getExtension("circle"); // If present, validate the parameter values as given in the extension / configuration file if (extensions != nullptr) { const sparta::ParameterSet * fpu_prms = extensions->getParameters(); sparta_assert(fpu_prms != nullptr); validateParameter<std::string>(*fpu_prms, "color_", "green"); validateParameter<std::string>(*fpu_prms, "shape_", "round"); validateParameter<double> (*fpu_prms, "degrees_", 360.0); // While most of the 'circle' extensions are given in --config-file options, // there might be more parameters added in with --extension-file, so let's check validateParameter<std::string>(*fpu_prms, "edges_", "0"); // We know the subclass type, so we should be able to safely dynamic cast // to that type and call methods on it const CircleExtensions * circle_subclass = dynamic_cast<const CircleExtensions*>(extensions); circle_subclass->doSomethingElse(); } } rtn = new sparta::ResourceTreeNode(core_tn, "br", "alu", 3,"BR Unit", getResourceSet()->getResourceFactory("execute")); to_delete_.emplace_back(rtn); rtn = new sparta::ResourceTreeNode(core_tn, "lsu", sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "Load-Store Unit", getResourceSet()->getResourceFactory("lsu")); to_delete_.emplace_back(rtn); // Add TLB as a private subtree so no one can get access to it through the // tree, we will give it to MMU explicitly. rtn = new sparta::ResourceTreeNode(rtn, "tlb", "TLB Unit", getResourceSet()->getResourceFactory("tlb")); rtn->makeSubtreePrivate(); tlb_nodes_.push_back(rtn); to_delete_.insert(to_delete_.begin(), std::unique_ptr<sparta::TreeNode>(rtn)); rtn = new sparta::ResourceTreeNode(core_tn, "biu", sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "Bus Interface Unit", getResourceSet()->getResourceFactory("biu")); to_delete_.emplace_back(rtn); rtn = new sparta::ResourceTreeNode(core_tn, "mss", sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "Memory Sub-System", getResourceSet()->getResourceFactory("mss")); to_delete_.emplace_back(rtn); rtn = new sparta::ResourceTreeNode(core_tn, "rob", sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "ROB Unit", getResourceSet()->getResourceFactory("rob")); to_delete_.emplace_back(rtn); rtn = new sparta::ResourceTreeNode(core_tn, "preloader", sparta::TreeNode::GROUP_NAME_NONE, sparta::TreeNode::GROUP_IDX_NONE, "Preloader Facility", getResourceSet()->getResourceFactory("preloader")); to_delete_.emplace_back(rtn); } // Attach two tree nodes to get the following: // top // core0 // dispatch // baz_node // params // baz // fpu // baz_node // params // baz // // This is needed to reproduce a write-final-config bug where an arch file // specifies 'top.core0.*.baz_node.params.baz: 300' and the ConfigEmitterYAML // ends up throwing an exception due to the '*' which tripped up the tree node // extensions code. auto dispatch = getRoot()->getChild("core0.dispatch"); auto fpu = getRoot()->getChild("core0.fpu"); dispatch_baz_.reset(new sparta::Baz( dispatch, "Dummy node under top.core0.dispatch (to reproduce bug)")); fpu_baz_.reset(new sparta::Baz( fpu, "Dummy node under top.core0.fpu (to reproduce bug)")); } void ExampleSimulator::configureTree_() { //Context-aware SimDB access std::pair<std::string, std::string> sqlite_db_files; if (auto dbconn = GET_DB_FOR_COMPONENT(NumericMeta, this)) { const TestSQLiteSchemaA data = DatabaseTester::getTester(). createAndStoreRecordForSQLiteSchemaA(); const double first = data.numbers.First; const double second = data.numbers.Second; dbconn->getTable("Numbers")->createObjectWithArgs( "First", first, "Second", second); const std::string meta_name = data.metadata.Name; const double meta_value = data.metadata.Value; dbconn->getTable("Metadata")->createObjectWithArgs( "Name", meta_name, "Value", meta_value); sqlite_db_files.first = dbconn->getDatabaseFile(); //Verification of the two records we just made above //will occur at the end of the simulation. } if (auto dbconn = GET_DB_FOR_COMPONENT(StringMeta, this)) { const TestSQLiteSchemaB data = DatabaseTester::getTester(). createAndStoreRecordForSQLiteSchemaB(); const std::string first = data.strings.First; const std::string second = data.strings.Second; dbconn->getTable("Strings")->createObjectWithArgs( "First", first, "Second", second); const std::string meta_name = data.metadata.Name; const std::string meta_value = data.metadata.Value; dbconn->getTable("Metadata")->createObjectWithArgs( "Name", meta_name, "Value", meta_value); sqlite_db_files.second = dbconn->getDatabaseFile(); //Verification of the two records we just made above //will occur at the end of the simulation. } //Both of the ObjectManager's used above should have put the //created records into the same file. sparta_assert(sqlite_db_files.first == sqlite_db_files.second); //Context-unaware SimDB access tryAccessSimDB(); validateTreeNodeExtensions_(); // In TREE_CONFIGURING phase // Configuration from command line is already applied // Read these parameter values to avoid 'unread unbound parameter' exceptions: // top.core0.dispatch.baz_node.params.baz // top.core0.fpu.baz_node.params.baz dispatch_baz_->readParams(); fpu_baz_->readParams(); sparta::ParameterBase* max_instrs = getRoot()->getChildAs<sparta::ParameterBase>("core0.rob.params.num_insts_to_retire"); // Safely assign as string for now in case parameter type changes. // Direct integer assignment without knowing parameter type is not yet available through C++ API if(instruction_limit_ != 0){ max_instrs->setValueFromString(sparta::utils::uint64_to_str(instruction_limit_)); } testing_notification_source_.reset(new sparta::NotificationSource<uint64_t>( this->getRoot()->getSearchScope()->getChild("top.core0.rob"), "testing_notif_channel", "Notification channel for testing purposes only", "testing_notif_channel")); toggle_trigger_notification_source_.reset(new sparta::NotificationSource<uint64_t>( getRoot()->getSearchScope()->getChild("top.core0.rob"), "stats_profiler", "Notification channel for testing report toggling on/off (statistics profiling)", "stats_profiler")); legacy_warmup_report_starter_.reset(new sparta::NotificationSource<uint64_t>( getRoot(), "all_threads_warmup_instruction_count_retired_re4", "Legacy notificiation channel for testing purposes only", "all_threads_warmup_instruction_count_retired_re4")); getRoot()->REGISTER_FOR_NOTIFICATION( onTriggered_, std::string, "sparta_expression_trigger_fired"); on_triggered_notifier_registered_ = true; simdb_perf_async_ctrl_enabled_ = sparta::IsFeatureValueEnabled( getFeatureConfiguration(), "simdb-perf-async-ctrl") > 0; } void ExampleSimulator::bindTree_() { // In TREE_FINALIZED phase // Tree is finalized. Taps placed. No new nodes at this point // Bind appropriate ports for (uint32_t i = 0; i < num_cores_; ++i) { sparta::TreeNode* core_tree_node = getRoot()->getChild(std::string("core") + sparta::utils::uint32_to_str(i)); sparta_assert(core_tree_node != nullptr); (core_tree_node->getChild("lsu")->getResourceAs<core_example::LSU>())->setTLB(*tlb_nodes_.at(i)->getResourceAs<core_example::SimpleTLB>()); // Bind Fetch to Decode sparta::bind(core_tree_node->getChildAs<sparta::Port>("fetch.ports.out_fetch_queue_write"), core_tree_node->getChildAs<sparta::Port>("decode.ports.in_fetch_queue_write")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("fetch.ports.in_fetch_queue_credits"), core_tree_node->getChildAs<sparta::Port>("decode.ports.out_fetch_queue_credits")); // Bind Decode to Rename sparta::bind(core_tree_node->getChildAs<sparta::Port>("decode.ports.out_uop_queue_write"), core_tree_node->getChildAs<sparta::Port>("rename.ports.in_uop_queue_append")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("decode.ports.in_uop_queue_credits"), core_tree_node->getChildAs<sparta::Port>("rename.ports.out_uop_queue_credits")); // Bind Rename to Dispatch sparta::bind(core_tree_node->getChildAs<sparta::Port>("rename.ports.out_dispatch_queue_write"), core_tree_node->getChildAs<sparta::Port>("dispatch.ports.in_dispatch_queue_write")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("rename.ports.in_dispatch_queue_credits"), core_tree_node->getChildAs<sparta::Port>("dispatch.ports.out_dispatch_queue_credits")); // Bind Dispatch to ALU0, ALU1, FPU, BR, LSU, and ROB sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.out_fpu_write"), core_tree_node->getChildAs<sparta::Port>("fpu.ports.in_execute_write")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.in_fpu_credits"), core_tree_node->getChildAs<sparta::Port>("fpu.ports.out_scheduler_credits")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.out_alu0_write"), core_tree_node->getChildAs<sparta::Port>("alu0.ports.in_execute_write")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.in_alu0_credits"), core_tree_node->getChildAs<sparta::Port>("alu0.ports.out_scheduler_credits")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.out_alu1_write"), core_tree_node->getChildAs<sparta::Port>("alu1.ports.in_execute_write")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.in_alu1_credits"), core_tree_node->getChildAs<sparta::Port>("alu1.ports.out_scheduler_credits")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.out_br_write"), core_tree_node->getChildAs<sparta::Port>("br.ports.in_execute_write")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.in_br_credits"), core_tree_node->getChildAs<sparta::Port>("br.ports.out_scheduler_credits")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.out_lsu_write"), core_tree_node->getChildAs<sparta::Port>("lsu.ports.in_lsu_insts")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.in_lsu_credits"), core_tree_node->getChildAs<sparta::Port>("lsu.ports.out_lsu_credits")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.out_reorder_buffer_write"), core_tree_node->getChildAs<sparta::Port>("rob.ports.in_reorder_buffer_write")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("dispatch.ports.in_reorder_buffer_credits"), core_tree_node->getChildAs<sparta::Port>("rob.ports.out_reorder_buffer_credits")); // Bind LSU to BIU sparta::bind(core_tree_node->getChildAs<sparta::Port>("lsu.ports.out_biu_req"), core_tree_node->getChildAs<sparta::Port>("biu.ports.in_biu_req")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("lsu.ports.in_biu_ack"), core_tree_node->getChildAs<sparta::Port>("biu.ports.out_biu_ack")); // Bind BIU to MSS sparta::bind(core_tree_node->getChildAs<sparta::Port>("biu.ports.out_mss_req_sync"), core_tree_node->getChildAs<sparta::Port>("mss.ports.in_mss_req_sync")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("biu.ports.in_mss_ack_sync"), core_tree_node->getChildAs<sparta::Port>("mss.ports.out_mss_ack_sync")); //////////////////////////////////////////////////////////////////////////////// // Bind Flushing Ports // Connect ROB to the Manager sparta::bind(core_tree_node->getChildAs<sparta::Port>("rob.ports.out_retire_flush"), core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.in_retire_flush")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("rob.ports.out_fetch_flush_redirect"), core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.in_fetch_flush_redirect")); // Connect ROB to LSU sparta::bind(core_tree_node->getChildAs<sparta::Port>("rob.ports.out_rob_retire_ack"), core_tree_node->getChildAs<sparta::Port>("lsu.ports.in_rob_retire_ack")); // Connect the FlushManager to the rest of the pipe sparta::bind(core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.out_retire_flush"), core_tree_node->getChildAs<sparta::Port>("alu0.ports.in_reorder_flush")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.out_retire_flush"), core_tree_node->getChildAs<sparta::Port>("alu1.ports.in_reorder_flush")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.out_retire_flush"), core_tree_node->getChildAs<sparta::Port>("fpu.ports.in_reorder_flush")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.out_retire_flush"), core_tree_node->getChildAs<sparta::Port>("dispatch.ports.in_reorder_flush")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.out_retire_flush"), core_tree_node->getChildAs<sparta::Port>("decode.ports.in_reorder_flush")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.out_retire_flush"), core_tree_node->getChildAs<sparta::Port>("rename.ports.in_reorder_flush")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.out_retire_flush"), core_tree_node->getChildAs<sparta::Port>("rob.ports.in_reorder_flush")); sparta::bind(core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.out_retire_flush"), core_tree_node->getChildAs<sparta::Port>("lsu.ports.in_reorder_flush")); // Connect the Flushmanager to Fetch sparta::bind(core_tree_node->getChildAs<sparta::Port>("flushmanager.ports.out_fetch_flush_redirect"), core_tree_node->getChildAs<sparta::Port>("fetch.ports.in_fetch_flush_redirect")); core_example::Preloader* preloader = core_tree_node->getChild("preloader")->getResourceAs<core_example::Preloader>(); preloader->preload(); } sparta::SpartaHandler cb = sparta::SpartaHandler::from_member< ExampleSimulator, &ExampleSimulator::postRandomNumber_>( this, "ExampleSimulator::postRandomNumber_"); random_number_trigger_.reset(new sparta::trigger::ExpressionCounterTrigger( "RandomNumber", cb, "core0.rob.stats.total_number_retired 7500", false, this->getRoot())); toggle_notif_trigger_.reset(new sparta::trigger::ExpressionTimeTrigger( "ToggleNotif", CREATE_SPARTA_HANDLER(ExampleSimulator, postToToggleTrigger_), "1 ns", getRoot())); static const uint32_t warmup_multiplier = 1000; auto gen_expression = [](const uint32_t core_idx) { std::ostringstream oss; oss << "core" << core_idx << ".rob.stats.total_number_retired >= " << ((core_idx+1) * warmup_multiplier); return oss.str(); }; num_cores_still_warming_up_ = num_cores_; core_warmup_listeners_.reserve(num_cores_); for (uint32_t core_idx = 0; core_idx < num_cores_; ++core_idx) { core_warmup_listeners_.emplace_back( new sparta::trigger::ExpressionTrigger( "LegacyWarmupNotifications", CREATE_SPARTA_HANDLER(ExampleSimulator, onLegacyWarmupNotification_), gen_expression(core_idx), getRoot(), nullptr)); } } void ExampleSimulator::onLegacyWarmupNotification_() { sparta_assert(num_cores_still_warming_up_ > 0); --num_cores_still_warming_up_; if (num_cores_still_warming_up_ == 0) { legacy_warmup_report_starter_->postNotification(1); } } const sparta::CounterBase* ExampleSimulator::findSemanticCounter_(CounterSemantic sem) const { switch(sem){ case CSEM_INSTRUCTIONS: return getRoot()->getChildAs<const sparta::CounterBase>("core0.rob.stats.total_number_retired"); break; default: return nullptr; } } void ExampleSimulator::postRandomNumber_() { const size_t random = rand() % 25; testing_notification_source_->postNotification(random); random_number_trigger_->reschedule(); } void ExampleSimulator::postToToggleTrigger_() { typedef std::pair<uint64_t,uint64_t> ValueCount; static std::queue<ValueCount> values; if (values.empty()) { values.push({0,15}); values.push({1,25}); values.push({0,15}); values.push({1,25}); values.push({0,15}); ValueCount tmp = values.front(); values.push(tmp); } if (values.front().second == 0) { values.pop(); ValueCount tmp = values.front(); values.push(tmp); } else { --values.front().second; } const ValueCount & current_value = values.front(); const uint64_t value_to_post = current_value.first; toggle_trigger_notification_source_->postNotification(value_to_post); toggle_notif_trigger_->reschedule(); } void ExampleSimulator::onTriggered_(const std::string & msg) { std::cout << " [trigger] " << msg << std::endl; } void ExampleSimulator::validateTreeNodeExtensions_() { // From the yaml file, the 'cat' extension had parameters 'name_' and 'language_' sparta::TreeNode * core_tn = getRoot()->getChild("core0.lsu"); if (core_tn == nullptr) { return; } sparta::TreeNode::ExtensionsBase * cat_base = core_tn->getExtension("cat"); if (cat_base == nullptr) { return; } sparta::ParameterSet * cat_prms = cat_base->getParameters(); validateParameter<std::string>(*cat_prms, "name_", "Tom"); // The expected "meow" parameter value, given in a --config-file, may have // been overridden in a provided --extension-file validateParameter<std::string>(*cat_prms, "language_", {"meow", "grrr"}); // Same goes for the 'mouse' extension... sparta::TreeNode::ExtensionsBase * mouse_base = core_tn->getExtension("mouse"); if (mouse_base == nullptr) { return; } sparta::ParameterSet * mouse_prms = mouse_base->getParameters(); validateParameter<std::string>(*mouse_prms, "name_", "Jerry"); validateParameter<std::string>(*mouse_prms, "language_", "squeak"); // Another extension called 'circle' was put on a different tree node... sparta::TreeNode * fpu_tn = getRoot()->getChild("core0.fpu"); if (fpu_tn == nullptr) { return; } sparta::TreeNode::ExtensionsBase * circle_base = fpu_tn->getExtension("circle"); if (circle_base == nullptr) { return; } sparta::ParameterSet * circle_prms = circle_base->getParameters(); // The 'circle' extension had 'color_' and 'shape_' parameters given in the yaml file: validateParameter<std::string>(*circle_prms, "color_", "green"); validateParameter<std::string>(*circle_prms, "shape_", "round"); // That subclass also gave a parameter value not found in the yaml file at all: validateParameter<double>(*circle_prms, "degrees_", 360.0); // Further, the 'circle' extension gave a subclass factory for the CircleExtensions class... // so we should be able to dynamic_cast to the known type: const CircleExtensions * circle_subclass = dynamic_cast<const CircleExtensions*>(circle_base); circle_subclass->doSomethingElse(); // Lastly, verify that there are no issues with putting extensions on the 'top' node sparta::TreeNode * top_node = getRoot(); if (top_node == nullptr) { return; } sparta::TreeNode::ExtensionsBase * top_extensions = top_node->getExtension("apple"); if (top_extensions == nullptr) { return; } sparta::ParameterSet *top_prms = top_extensions->getParameters(); validateParameter<std::string>(*top_prms, "color_", "red"); // The 'core0.lsu' node has two named extensions, so asking that node for // unqualified extensions (no name specified) should throw try { core_tn->getExtension(); throw sparta::SpartaException("Expected an exception to be thrown for unqualified " "call to TreeNode::getExtension()"); } catch (...) { } // While the 'core0.fpu' node only had one extension, so we should be able to // access it without giving any particular name sparta::TreeNode::ExtensionsBase * circle_base_by_default = fpu_tn->getExtension(); circle_prms = circle_base_by_default->getParameters(); validateParameter<std::string>(*circle_prms, "color_", "green"); validateParameter<std::string>(*circle_prms, "shape_", "round"); validateParameter<double>(*circle_prms, "degrees_", 360.0); // Check to see if additional parameters were added to this tree node's extension // (--config-file and --extension-file options can be given at the same time, and // we should have access to the merged result of both ParameterTree's) if (circle_prms->getNumParameters() > 3) { validateParameter<std::string>(*circle_prms, "edges_", "0"); } // Verify that we can work with extensions on 'top.core0.dispatch.baz_node', which // was added to this example simulator to reproduce bug sparta::TreeNode * baz_node = getRoot()->getChild("core0.dispatch.baz_node", false); if (baz_node) { sparta::TreeNode::ExtensionsBase * extensions = baz_node->getExtension("baz_ext"); if (extensions) { const sparta::ParameterSet * baz_prms = extensions->getParameters(); sparta_assert(baz_prms != nullptr); validateParameter<std::string>(*baz_prms, "ticket_", "663"); } } } ExampleSimulator::ExampleController::ExampleController( const sparta::app::Simulation * sim) : sparta::app::Simulation::SimulationController(sim) { sparta::app::Simulation::SimulationController::addNamedCallback_( "eat", CREATE_SPARTA_HANDLER(ExampleController, customEatCallback_)); sparta::app::Simulation::SimulationController::addNamedCallback_( "sleep", CREATE_SPARTA_HANDLER(ExampleController, customSleepCallback_)); } void ExampleSimulator::ExampleController::pause_(const sparta::app::Simulation * sim) { std::cout << " [control] Controller PAUSE method has been called for simulation '" << sim->getSimName() << "'" << std::endl; } void ExampleSimulator::ExampleController::resume_(const sparta::app::Simulation * sim) { std::cout << " [control] Controller RESUME method has been called for simulation '" << sim->getSimName() << "'" << std::endl; } void ExampleSimulator::ExampleController::terminate_(const sparta::app::Simulation * sim) { std::cout << " [control] Controller TERMINATE method has been called for simulation '" << sim->getSimName() << "'" << std::endl; } void ExampleSimulator::ExampleController::customEatCallback_() { std::cout << " [control] Controller CUSTOM method has been called ('eat')" << std::endl; } void ExampleSimulator::ExampleController::customSleepCallback_() { std::cout << " [control] Controller CUSTOM method has been called ('sleep')" << std::endl; } // Since the FlushManager does not have a subsequent source file namespace core_example { constexpr char FlushManager::name[]; }
[ "klingaard@gmail.com" ]
klingaard@gmail.com
8b0732e2d424fb95c444e961bc30ecf5511c4741
241bf79350c02fd8adc3988162a65c850829bde4
/ITP/3-A.cpp
f5571d03aaee60b89891daaeb91d513a5cee7842
[]
no_license
kurikinton105/AOJ_study
0905b9fb111bd0b6d5b61ff0ce3dcd6a2adf3ffb
b0d5868c80c9007f978ddca0f012c4f6c45a127b
refs/heads/master
2022-10-14T03:23:20.201910
2020-06-04T12:51:05
2020-06-04T12:51:05
269,358,367
0
0
null
null
null
null
UTF-8
C++
false
false
178
cpp
#include<iostream> using namespace std; int main(){ int i; i = 0; while (i < 1000) { cout << "Hello World" << endl; i++; } return 0; }
[ "yamadakenta0101@gmail.com" ]
yamadakenta0101@gmail.com
10b6836ae632b348102c81b71bc924510df5d7fe
dac2fa7a9d3b1759bc16700579af163318de861a
/MathUnitTests/Code/Game/GameCommon.hpp
4ccd09bb763a334c9ae0aab07f5ff6ce22a985ea
[]
no_license
JSarasua/Guildhall
615bb186455c2783debb1fe68685ca9a1c18a930
d458cc1ecc78b1cac7b5864aefc47db041f2c8c2
refs/heads/master
2023-06-13T04:07:39.928047
2021-07-07T04:11:07
2021-07-07T04:11:07
235,437,258
2
0
null
null
null
null
UTF-8
C++
false
false
1,041
hpp
//----------------------------------------------------------------------------------------------- // GameCommon.hpp // ///////////////////////////////////////////////////////////////////////////////////////////////// // // DO NOT MODIFY ANY CODE BELOW HERE WITHOUT EXPRESS PERMISSION FROM YOUR PROFESSOR // (as doing so will be considered cheating and have serious academic consequences) // ///////////////////////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------------------------- // Global typedefs // typedef int (TestSetFunctionType)(); // Function signature type for all test functions //----------------------------------------------------------------------------------------------- // Functions provided by Main.cpp, but globally accessible to all test files // void RunTestSet( bool isGraded, TestSetFunctionType testSetFunction, const char* testSetName ); void VerifyTestResult( bool isCorrect, const char* testName );
[ "jsarasua@smu.edu" ]
jsarasua@smu.edu
749fe155a191baa53ea9609206403fdb283ea800
7fd33d1ba3fe7d3076f5850fe1fa01158e80be08
/SDK/PUBG_TslItemDragWidget_functions.cpp
db3f0289e19f9268663f4252ec7d19b425f4e270
[]
no_license
wzpyh/PUBG-SDK
df11b08c1242f724a523d6814238914137865355
980225fb22bd67a82b8e1563444afd6af5706abd
refs/heads/master
2021-01-23T14:22:23.966345
2017-09-06T16:56:15
2017-09-06T16:56:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,765
cpp
// PlayerUnknown's Battlegrounds (2.5.39.19) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace Classes { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function TslItemDragWidget.TslItemDragWidget_C.On_ErrorIcon_Prepass_1 // (FUNC_Public, FUNC_BlueprintCallable, FUNC_BlueprintEvent) // Parameters: // class UWidget* BoundWidget (CPF_Parm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::On_ErrorIcon_Prepass_1(class UWidget* BoundWidget) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.On_ErrorIcon_Prepass_1"); UTslItemDragWidget_C_On_ErrorIcon_Prepass_1_Params params; params.BoundWidget = BoundWidget; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function TslItemDragWidget.TslItemDragWidget_C.IsEnable // (FUNC_Public, FUNC_HasOutParms, FUNC_BlueprintCallable, FUNC_BlueprintEvent, FUNC_BlueprintPure) // Parameters: // bool IsEnable (CPF_Parm, CPF_OutParm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::IsEnable(bool* IsEnable) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.IsEnable"); UTslItemDragWidget_C_IsEnable_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (IsEnable != nullptr) *IsEnable = params.IsEnable; } // Function TslItemDragWidget.TslItemDragWidget_C.UpdateBackgroundImage // (FUNC_Public, FUNC_BlueprintCallable, FUNC_BlueprintEvent) // Parameters: // class UWidget* BoundWidget (CPF_Parm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::UpdateBackgroundImage(class UWidget* BoundWidget) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.UpdateBackgroundImage"); UTslItemDragWidget_C_UpdateBackgroundImage_Params params; params.BoundWidget = BoundWidget; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function TslItemDragWidget.TslItemDragWidget_C.GettslItemDragDropOperation // (FUNC_Public, FUNC_HasOutParms, FUNC_BlueprintCallable, FUNC_BlueprintEvent, FUNC_BlueprintPure) // Parameters: // class UTslItemDragDropOperation_C* AsTsl_Item_Drag_Drop_Operation (CPF_Parm, CPF_OutParm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::GettslItemDragDropOperation(class UTslItemDragDropOperation_C** AsTsl_Item_Drag_Drop_Operation) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.GettslItemDragDropOperation"); UTslItemDragWidget_C_GettslItemDragDropOperation_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (AsTsl_Item_Drag_Drop_Operation != nullptr) *AsTsl_Item_Drag_Drop_Operation = params.AsTsl_Item_Drag_Drop_Operation; } // Function TslItemDragWidget.TslItemDragWidget_C.GetActionName // (FUNC_Public, FUNC_HasOutParms, FUNC_BlueprintCallable, FUNC_BlueprintEvent, FUNC_BlueprintPure) // Parameters: // struct FName ActionName (CPF_Parm, CPF_OutParm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::GetActionName(struct FName* ActionName) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.GetActionName"); UTslItemDragWidget_C_GetActionName_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (ActionName != nullptr) *ActionName = params.ActionName; } // Function TslItemDragWidget.TslItemDragWidget_C.GetInventory // (FUNC_Public, FUNC_HasOutParms, FUNC_BlueprintCallable, FUNC_BlueprintEvent, FUNC_BlueprintPure) // Parameters: // class AInventory* Inventory (CPF_Parm, CPF_OutParm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::GetInventory(class AInventory** Inventory) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.GetInventory"); UTslItemDragWidget_C_GetInventory_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (Inventory != nullptr) *Inventory = params.Inventory; } // Function TslItemDragWidget.TslItemDragWidget_C.GetAdditionalMaxStackCount // (FUNC_Public, FUNC_HasOutParms, FUNC_BlueprintCallable, FUNC_BlueprintEvent, FUNC_BlueprintPure) // Parameters: // int Count (CPF_Parm, CPF_OutParm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::GetAdditionalMaxStackCount(int* Count) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.GetAdditionalMaxStackCount"); UTslItemDragWidget_C_GetAdditionalMaxStackCount_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (Count != nullptr) *Count = params.Count; } // Function TslItemDragWidget.TslItemDragWidget_C.GetShooterPlayerController // (FUNC_Public, FUNC_HasOutParms, FUNC_BlueprintCallable, FUNC_BlueprintEvent, FUNC_BlueprintPure) // Parameters: // class ATslPlayerController* ShooterPlayerController (CPF_Parm, CPF_OutParm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::GetShooterPlayerController(class ATslPlayerController** ShooterPlayerController) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.GetShooterPlayerController"); UTslItemDragWidget_C_GetShooterPlayerController_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (ShooterPlayerController != nullptr) *ShooterPlayerController = params.ShooterPlayerController; } // Function TslItemDragWidget.TslItemDragWidget_C.UpdateStackCount // (FUNC_Public, FUNC_HasDefaults, FUNC_BlueprintCallable, FUNC_BlueprintEvent) // Parameters: // class UWidget* BoundWidget (CPF_Parm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::UpdateStackCount(class UWidget* BoundWidget) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.UpdateStackCount"); UTslItemDragWidget_C_UpdateStackCount_Params params; params.BoundWidget = BoundWidget; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function TslItemDragWidget.TslItemDragWidget_C.UpdateStackCountVisibility // (FUNC_Public, FUNC_BlueprintCallable, FUNC_BlueprintEvent) // Parameters: // class UWidget* BoundWidget (CPF_Parm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::UpdateStackCountVisibility(class UWidget* BoundWidget) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.UpdateStackCountVisibility"); UTslItemDragWidget_C_UpdateStackCountVisibility_Params params; params.BoundWidget = BoundWidget; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function TslItemDragWidget.TslItemDragWidget_C.UpdateIcon // (FUNC_Public, FUNC_HasDefaults, FUNC_BlueprintCallable, FUNC_BlueprintEvent) // Parameters: // class UWidget* BoundWidget (CPF_Parm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::UpdateIcon(class UWidget* BoundWidget) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.UpdateIcon"); UTslItemDragWidget_C_UpdateIcon_Params params; params.BoundWidget = BoundWidget; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function TslItemDragWidget.TslItemDragWidget_C.Construct // (FUNC_BlueprintCosmetic, FUNC_Event, FUNC_Public, FUNC_BlueprintEvent) void UTslItemDragWidget_C::Construct() { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.Construct"); UTslItemDragWidget_C_Construct_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function TslItemDragWidget.TslItemDragWidget_C.Destruct // (FUNC_BlueprintCosmetic, FUNC_Event, FUNC_Public, FUNC_BlueprintEvent) void UTslItemDragWidget_C::Destruct() { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.Destruct"); UTslItemDragWidget_C_Destruct_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function TslItemDragWidget.TslItemDragWidget_C.ExecuteUbergraph_TslItemDragWidget // () // Parameters: // int EntryPoint (CPF_Parm, CPF_ZeroConstructor, CPF_IsPlainOldData) void UTslItemDragWidget_C::ExecuteUbergraph_TslItemDragWidget(int EntryPoint) { static auto fn = UObject::FindObject<UFunction>("Function TslItemDragWidget.TslItemDragWidget_C.ExecuteUbergraph_TslItemDragWidget"); UTslItemDragWidget_C_ExecuteUbergraph_TslItemDragWidget_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "pubgsdk@gmail.com" ]
pubgsdk@gmail.com
6a32bdfc21fa762e11c0bd50b70128239ee492bc
34dce8773d293673253a9ff5174f0e0a8481e7c4
/OOP/Nap chong toan tu/main.cpp
14a8f9de6ff1120707263ec89bdef343e31c778b
[]
no_license
DoanTran2001/C-
b4535d6bab219e8b04cccc53ebadf3f5a5550e9d
1e4f3ec3c6759ee8b9636ee041738c4f395c25c6
refs/heads/master
2023-08-03T10:02:30.382665
2021-09-14T05:09:41
2021-09-14T05:09:41
406,230,007
0
0
null
null
null
null
UTF-8
C++
false
false
1,873
cpp
#include <iostream> using namespace std; class PT_Bac_Nhat_2An{ private: int a; int b; int c; public: PT_Bac_Nhat_2An(){ } PT_Bac_Nhat_2An(int a,int b,int c) { this->a=a; this->b=b; this->c=c; } friend istream &operator>>(istream &is,PT_Bac_Nhat_2An &x); friend ostream &operator<<(ostream &os,PT_Bac_Nhat_2An x); PT_Bac_Nhat_2An operator+(PT_Bac_Nhat_2An x); PT_Bac_Nhat_2An operator-(PT_Bac_Nhat_2An x); PT_Bac_Nhat_2An operator--(PT_Bac_Nhat_2An x); }; istream &operator>>(istream &is,PT_Bac_Nhat_2An &x) { cout <<"Nhap a: "; is>>x.a; cout <<"Nhap b: "; is>>x.b; cout <<"Nhap c: "; is>>x.c; return is; } ostream &operator<<(ostream &os,PT_Bac_Nhat_2An x) { if(x.a!=0){ os<<x.a<<"x"; } if(x.b<0){ os<<x.b; } else if(x.b>0) os<<"+"<<x.b; os<<"y"; if(x.c<0){ os<<x.c; } else if(x.c>0){ os<<"+"<<x.c; } os<<" = 0"<<endl; return os; } PT_Bac_Nhat_2An PT_Bac_Nhat_2An::operator+(PT_Bac_Nhat_2An x) { PT_Bac_Nhat_2An tong; tong.a=this->a+x.a; tong.b=this->b+x.b; tong.c=this->c+x.c; return tong; } PT_Bac_Nhat_2An PT_Bac_Nhat_2An::operator-(PT_Bac_Nhat_2An x) { PT_Bac_Nhat_2An hieu; hieu.a=this->a-x.a; hieu.b=this->b-x.b; hieu.c=this->c-x.c; return hieu; } int main() { PT_Bac_Nhat_2An A; PT_Bac_Nhat_2An B(3,6,7); cin>>A; cout <<"Phuong trinh A vua nhap la: "; cout<<A; cout <<"Phuong trinh B vua nhap la: "; cout<<B; PT_Bac_Nhat_2An C=A+B; cout <<"Phuong trinh C vua nhap la: "; cout <<C; PT_Bac_Nhat_2An D=A-B; cout <<"Phuong trinh D vua nhap la: "; cout <<D; PT_Bac_Nhat_2An E=A-(A+A); cout <<"Phuong trinh E vua nhap la: "; cout <<E; return 0; }
[ "dadotran3@gmail.com" ]
dadotran3@gmail.com
6d8b0ef6f18932b736ef74e3240efc57ae754c73
948d085d52a212685b925171bef90a6a56b78e08
/src/qt/bitcoingui.cpp
8c4d2ca4a07f0e188b11192ef0635222db24fa5c
[ "MIT" ]
permissive
merecoin/ljcoin
d70ca303454ba071f0dddb085dfb2418de056cde
8979be9aec25b9cdbfa3fa66944f9967b1d02af5
refs/heads/master
2020-03-13T01:32:34.622860
2018-04-24T19:56:08
2018-04-24T19:56:08
130,905,616
1
0
null
null
null
null
UTF-8
C++
false
false
30,134
cpp
// Copyright (c) 2011-2013 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <QApplication> #include "bitcoingui.h" #include "transactiontablemodel.h" #include "optionsdialog.h" #include "aboutdialog.h" #include "clientmodel.h" #include "walletmodel.h" #include "walletframe.h" #include "optionsmodel.h" #include "transactiondescdialog.h" #include "bitcoinunits.h" #include "guiconstants.h" #include "notificator.h" #include "guiutil.h" #include "rpcconsole.h" #include "ui_interface.h" #include "wallet.h" #include "init.h" #ifdef Q_OS_MAC #include "macdockiconhandler.h" #endif #include <QMenuBar> #include <QMenu> #include <QIcon> #include <QVBoxLayout> #include <QToolBar> #include <QStatusBar> #include <QLabel> #include <QMessageBox> #include <QProgressBar> #include <QStackedWidget> #include <QDateTime> #include <QMovie> #include <QTimer> #include <QDragEnterEvent> #if QT_VERSION < 0x050000 #include <QUrl> #endif #include <QMimeData> #include <QStyle> #include <QSettings> #include <QDesktopWidget> #include <QListWidget> #include <iostream> const QString BitcoinGUI::DEFAULT_WALLET = "~Default"; BitcoinGUI::BitcoinGUI(QWidget *parent) : QMainWindow(parent), clientModel(0), encryptWalletAction(0), changePassphraseAction(0), aboutQtAction(0), trayIcon(0), notificator(0), rpcConsole(0), prevBlocks(0) { restoreWindowGeometry(); setWindowTitle(tr("Ljcoin") + " - " + tr("Wallet")); #ifndef Q_OS_MAC QApplication::setWindowIcon(QIcon(":icons/bitcoin")); setWindowIcon(QIcon(":icons/bitcoin")); #else setUnifiedTitleAndToolBarOnMac(true); QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); #endif // Create wallet frame and make it the central widget walletFrame = new WalletFrame(this); setCentralWidget(walletFrame); // Accept D&D of URIs setAcceptDrops(true); // Create actions for the toolbar, menu bar and tray/dock icon // Needs walletFrame to be initialized createActions(); // Create application menu bar createMenuBar(); // Create the toolbars createToolBars(); // Create system tray icon and notification createTrayIcon(); // Create status bar statusBar(); // Status bar notification icons QFrame *frameBlocks = new QFrame(); frameBlocks->setContentsMargins(0,0,0,0); frameBlocks->setMinimumWidth(56); frameBlocks->setMaximumWidth(56); QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks); frameBlocksLayout->setContentsMargins(3,0,3,0); frameBlocksLayout->setSpacing(3); labelEncryptionIcon = new QLabel(); labelConnectionsIcon = new QLabel(); labelBlocksIcon = new QLabel(); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelEncryptionIcon); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelConnectionsIcon); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelBlocksIcon); frameBlocksLayout->addStretch(); // Progress bar and label for blocks download progressBarLabel = new QLabel(); progressBarLabel->setVisible(false); progressBar = new QProgressBar(); progressBar->setAlignment(Qt::AlignCenter); progressBar->setVisible(false); // Override style sheet for progress bar for styles that have a segmented progress bar, // as they make the text unreadable (workaround for issue #1071) // See https://qt-project.org/doc/qt-4.8/gallery.html QString curStyle = QApplication::style()->metaObject()->className(); if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") { progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }"); } statusBar()->addWidget(progressBarLabel); statusBar()->addWidget(progressBar); statusBar()->addPermanentWidget(frameBlocks); syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this); rpcConsole = new RPCConsole(this); connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show())); // prevents an oben debug window from becoming stuck/unusable on client shutdown connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide())); // Install event filter to be able to catch status tip events (QEvent::StatusTip) this->installEventFilter(this); // Initially wallet actions should be disabled setWalletActionsEnabled(false); } BitcoinGUI::~BitcoinGUI() { saveWindowGeometry(); if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu) trayIcon->hide(); #ifdef Q_OS_MAC delete appMenuBar; MacDockIconHandler::instance()->setMainWindow(NULL); #endif } void BitcoinGUI::createActions() { QActionGroup *tabGroup = new QActionGroup(this); overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this); overviewAction->setStatusTip(tr("Show general overview of wallet")); overviewAction->setToolTip(overviewAction->statusTip()); overviewAction->setCheckable(true); overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1)); tabGroup->addAction(overviewAction); sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send"), this); sendCoinsAction->setStatusTip(tr("Send coins to a Ljcoin address")); sendCoinsAction->setToolTip(sendCoinsAction->statusTip()); sendCoinsAction->setCheckable(true); sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); tabGroup->addAction(sendCoinsAction); receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive"), this); receiveCoinsAction->setStatusTip(tr("Show the list of addresses for receiving payments")); receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip()); receiveCoinsAction->setCheckable(true); receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3)); tabGroup->addAction(receiveCoinsAction); historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this); historyAction->setStatusTip(tr("Browse transaction history")); historyAction->setToolTip(historyAction->statusTip()); historyAction->setCheckable(true); historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4)); tabGroup->addAction(historyAction); addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Addresses"), this); addressBookAction->setStatusTip(tr("Edit the list of stored addresses and labels")); addressBookAction->setToolTip(addressBookAction->statusTip()); addressBookAction->setCheckable(true); addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); tabGroup->addAction(addressBookAction); connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this); quitAction->setStatusTip(tr("Quit application")); quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); quitAction->setMenuRole(QAction::QuitRole); aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About Ljcoin"), this); aboutAction->setStatusTip(tr("Show information about Ljcoin")); aboutAction->setMenuRole(QAction::AboutRole); aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this); aboutQtAction->setStatusTip(tr("Show information about Qt")); aboutQtAction->setMenuRole(QAction::AboutQtRole); optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this); optionsAction->setStatusTip(tr("Modify configuration options for Ljcoin")); optionsAction->setMenuRole(QAction::PreferencesRole); toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this); toggleHideAction->setStatusTip(tr("Show or hide the main Window")); encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this); encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet")); encryptWalletAction->setCheckable(true); backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this); backupWalletAction->setStatusTip(tr("Backup wallet to another location")); changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this); changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption")); signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this); signMessageAction->setStatusTip(tr("Sign messages with your Ljcoin addresses to prove you own them")); verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this); verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Ljcoin addresses")); openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this); openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden())); connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool))); connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet())); connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase())); connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab())); connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab())); } void BitcoinGUI::createMenuBar() { #ifdef Q_OS_MAC // Create a decoupled menu bar on Mac which stays even if the window is closed appMenuBar = new QMenuBar(); #else // Get the main window's menu bar on other platforms appMenuBar = menuBar(); #endif // Configure the menus QMenu *file = appMenuBar->addMenu(tr("&File")); file->addAction(backupWalletAction); file->addAction(signMessageAction); file->addAction(verifyMessageAction); file->addSeparator(); file->addAction(quitAction); QMenu *settings = appMenuBar->addMenu(tr("&Settings")); settings->addAction(encryptWalletAction); settings->addAction(changePassphraseAction); settings->addSeparator(); settings->addAction(optionsAction); QMenu *help = appMenuBar->addMenu(tr("&Help")); help->addAction(openRPCConsoleAction); help->addSeparator(); help->addAction(aboutAction); help->addAction(aboutQtAction); } void BitcoinGUI::createToolBars() { QToolBar *toolbar = addToolBar(tr("Tabs toolbar")); toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolbar->addAction(overviewAction); toolbar->addAction(sendCoinsAction); toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); toolbar->addAction(addressBookAction); } void BitcoinGUI::setClientModel(ClientModel *clientModel) { this->clientModel = clientModel; if(clientModel) { // Replace some strings and icons, when using the testnet if(clientModel->isTestNet()) { setWindowTitle(windowTitle() + QString(" ") + tr("[testnet]")); #ifndef Q_OS_MAC QApplication::setWindowIcon(QIcon(":icons/bitcoin_testnet")); setWindowIcon(QIcon(":icons/bitcoin_testnet")); #else MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet")); #endif if(trayIcon) { // Just attach " [testnet]" to the existing tooltip trayIcon->setToolTip(trayIcon->toolTip() + QString(" ") + tr("[testnet]")); trayIcon->setIcon(QIcon(":/icons/toolbar_testnet")); } toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet")); aboutAction->setIcon(QIcon(":/icons/toolbar_testnet")); } // Create system tray menu (or setup the dock menu) that late to prevent users from calling actions, // while the client has not yet fully loaded createTrayIconMenu(); // Keep up to date with client setNumConnections(clientModel->getNumConnections()); connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); setNumBlocks(clientModel->getNumBlocks(), clientModel->getNumBlocksOfPeers()); connect(clientModel, SIGNAL(numBlocksChanged(int,int)), this, SLOT(setNumBlocks(int,int))); // Receive and report messages from network/worker thread connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int))); rpcConsole->setClientModel(clientModel); walletFrame->setClientModel(clientModel); } } bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel) { setWalletActionsEnabled(true); return walletFrame->addWallet(name, walletModel); } bool BitcoinGUI::setCurrentWallet(const QString& name) { return walletFrame->setCurrentWallet(name); } void BitcoinGUI::removeAllWallets() { setWalletActionsEnabled(false); walletFrame->removeAllWallets(); } void BitcoinGUI::setWalletActionsEnabled(bool enabled) { overviewAction->setEnabled(enabled); sendCoinsAction->setEnabled(enabled); receiveCoinsAction->setEnabled(enabled); historyAction->setEnabled(enabled); encryptWalletAction->setEnabled(enabled); backupWalletAction->setEnabled(enabled); changePassphraseAction->setEnabled(enabled); signMessageAction->setEnabled(enabled); verifyMessageAction->setEnabled(enabled); addressBookAction->setEnabled(enabled); } void BitcoinGUI::createTrayIcon() { #ifndef Q_OS_MAC trayIcon = new QSystemTrayIcon(this); trayIcon->setToolTip(tr("Ljcoin client")); trayIcon->setIcon(QIcon(":/icons/toolbar")); trayIcon->show(); #endif notificator = new Notificator(QApplication::applicationName(), trayIcon); } void BitcoinGUI::createTrayIconMenu() { QMenu *trayIconMenu; #ifndef Q_OS_MAC // return if trayIcon is unset (only on non-Mac OSes) if (!trayIcon) return; trayIconMenu = new QMenu(this); trayIcon->setContextMenu(trayIconMenu); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); #else // Note: On Mac, the dock icon is used to provide the tray's functionality. MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); dockIconHandler->setMainWindow((QMainWindow *)this); trayIconMenu = dockIconHandler->dockMenu(); #endif // Configuration of the tray icon (or dock icon) icon menu trayIconMenu->addAction(toggleHideAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(sendCoinsAction); trayIconMenu->addAction(receiveCoinsAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(signMessageAction); trayIconMenu->addAction(verifyMessageAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(optionsAction); trayIconMenu->addAction(openRPCConsoleAction); #ifndef Q_OS_MAC // This is built-in on Mac trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); #endif } #ifndef Q_OS_MAC void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) { if(reason == QSystemTrayIcon::Trigger) { // Click on system tray icon triggers show/hide of the main window toggleHideAction->trigger(); } } #endif void BitcoinGUI::saveWindowGeometry() { QSettings settings; settings.setValue("nWindowPos", pos()); settings.setValue("nWindowSize", size()); } void BitcoinGUI::restoreWindowGeometry() { QSettings settings; QPoint pos = settings.value("nWindowPos").toPoint(); QSize size = settings.value("nWindowSize", QSize(850, 550)).toSize(); if (!pos.x() && !pos.y()) { QRect screen = QApplication::desktop()->screenGeometry(); pos.setX((screen.width()-size.width())/2); pos.setY((screen.height()-size.height())/2); } resize(size); move(pos); } void BitcoinGUI::optionsClicked() { if(!clientModel || !clientModel->getOptionsModel()) return; OptionsDialog dlg; dlg.setModel(clientModel->getOptionsModel()); dlg.exec(); } void BitcoinGUI::aboutClicked() { AboutDialog dlg; dlg.setModel(clientModel); dlg.exec(); } void BitcoinGUI::gotoOverviewPage() { if (walletFrame) walletFrame->gotoOverviewPage(); } void BitcoinGUI::gotoHistoryPage() { if (walletFrame) walletFrame->gotoHistoryPage(); } void BitcoinGUI::gotoAddressBookPage() { if (walletFrame) walletFrame->gotoAddressBookPage(); } void BitcoinGUI::gotoReceiveCoinsPage() { if (walletFrame) walletFrame->gotoReceiveCoinsPage(); } void BitcoinGUI::gotoSendCoinsPage(QString addr) { if (walletFrame) walletFrame->gotoSendCoinsPage(addr); } void BitcoinGUI::gotoSignMessageTab(QString addr) { if (walletFrame) walletFrame->gotoSignMessageTab(addr); } void BitcoinGUI::gotoVerifyMessageTab(QString addr) { if (walletFrame) walletFrame->gotoVerifyMessageTab(addr); } void BitcoinGUI::setNumConnections(int count) { QString icon; switch(count) { case 0: icon = ":/icons/connect_0"; break; case 1: case 2: case 3: icon = ":/icons/connect_1"; break; case 4: case 5: case 6: icon = ":/icons/connect_2"; break; case 7: case 8: case 9: icon = ":/icons/connect_3"; break; default: icon = ":/icons/connect_4"; break; } labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Ljcoin network", "", count)); } void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) { // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text) statusBar()->clearMessage(); // Acquire current block source enum BlockSource blockSource = clientModel->getBlockSource(); switch (blockSource) { case BLOCK_SOURCE_NETWORK: progressBarLabel->setText(tr("Synchronizing with network...")); break; case BLOCK_SOURCE_DISK: progressBarLabel->setText(tr("Importing blocks from disk...")); break; case BLOCK_SOURCE_REINDEX: progressBarLabel->setText(tr("Reindexing blocks on disk...")); break; case BLOCK_SOURCE_NONE: // Case: not Importing, not Reindexing and no network connection progressBarLabel->setText(tr("No block source available...")); break; } QString tooltip; QDateTime lastBlockDate = clientModel->getLastBlockDate(); QDateTime currentDate = QDateTime::currentDateTime(); int secs = lastBlockDate.secsTo(currentDate); if(count < nTotalBlocks) { tooltip = tr("Processed %1 of %2 (estimated) blocks of transaction history.").arg(count).arg(nTotalBlocks); } else { tooltip = tr("Processed %1 blocks of transaction history.").arg(count); } // Set icon state: spinning if catching up, tick otherwise if(secs < 90*60 && count >= nTotalBlocks) { tooltip = tr("Up to date") + QString(".<br>") + tooltip; labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); walletFrame->showOutOfSyncWarning(false); progressBarLabel->setVisible(false); progressBar->setVisible(false); } else { // Represent time from last generated block in human readable text QString timeBehindText; if(secs < 48*60*60) { timeBehindText = tr("%n hour(s)","",secs/(60*60)); } else if(secs < 14*24*60*60) { timeBehindText = tr("%n day(s)","",secs/(24*60*60)); } else { timeBehindText = tr("%n week(s)","",secs/(7*24*60*60)); } progressBarLabel->setVisible(true); progressBar->setFormat(tr("%1 behind").arg(timeBehindText)); progressBar->setMaximum(1000000000); progressBar->setValue(clientModel->getVerificationProgress() * 1000000000.0 + 0.5); progressBar->setVisible(true); tooltip = tr("Catching up...") + QString("<br>") + tooltip; labelBlocksIcon->setMovie(syncIconMovie); if(count != prevBlocks) syncIconMovie->jumpToNextFrame(); prevBlocks = count; walletFrame->showOutOfSyncWarning(true); tooltip += QString("<br>"); tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText); tooltip += QString("<br>"); tooltip += tr("Transactions after this will not yet be visible."); } // Don't word-wrap this (fixed-width) tooltip tooltip = QString("<nobr>") + tooltip + QString("</nobr>"); labelBlocksIcon->setToolTip(tooltip); progressBarLabel->setToolTip(tooltip); progressBar->setToolTip(tooltip); } void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret) { QString strTitle = tr("Ljcoin"); // default title // Default to information icon int nMBoxIcon = QMessageBox::Information; int nNotifyIcon = Notificator::Information; QString msgType; // Prefer supplied title over style based title if (!title.isEmpty()) { msgType = title; } else { switch (style) { case CClientUIInterface::MSG_ERROR: msgType = tr("Error"); break; case CClientUIInterface::MSG_WARNING: msgType = tr("Warning"); break; case CClientUIInterface::MSG_INFORMATION: msgType = tr("Information"); break; default: break; } } // Append title to "Bitcoin - " if (!msgType.isEmpty()) strTitle += " - " + msgType; // Check for error/warning icon if (style & CClientUIInterface::ICON_ERROR) { nMBoxIcon = QMessageBox::Critical; nNotifyIcon = Notificator::Critical; } else if (style & CClientUIInterface::ICON_WARNING) { nMBoxIcon = QMessageBox::Warning; nNotifyIcon = Notificator::Warning; } // Display message if (style & CClientUIInterface::MODAL) { // Check for buttons, use OK as default, if none was supplied QMessageBox::StandardButton buttons; if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK))) buttons = QMessageBox::Ok; // Ensure we get users attention showNormalIfMinimized(); QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this); int r = mBox.exec(); if (ret != NULL) *ret = r == QMessageBox::Ok; } else notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message); } void BitcoinGUI::changeEvent(QEvent *e) { QMainWindow::changeEvent(e); #ifndef Q_OS_MAC // Ignored on Mac if(e->type() == QEvent::WindowStateChange) { if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray()) { QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e); if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) { QTimer::singleShot(0, this, SLOT(hide())); e->ignore(); } } } #endif } void BitcoinGUI::closeEvent(QCloseEvent *event) { if(clientModel) { #ifndef Q_OS_MAC // Ignored on Mac if(!clientModel->getOptionsModel()->getMinimizeToTray() && !clientModel->getOptionsModel()->getMinimizeOnClose()) { QApplication::quit(); } #endif } QMainWindow::closeEvent(event); } void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee) { QString strMessage = tr("This transaction is over the size limit. You can still send it for a fee of %1, " "which goes to the nodes that process your transaction and helps to support the network. " "Do you want to pay the fee?").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nFeeRequired)); QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm transaction fee"), strMessage, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes); *payFee = (retval == QMessageBox::Yes); } void BitcoinGUI::incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address) { // On new transaction, make an info balloon message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"), tr("Date: %1\n" "Amount: %2\n" "Type: %3\n" "Address: %4\n") .arg(date) .arg(BitcoinUnits::formatWithUnit(unit, amount, true)) .arg(type) .arg(address), CClientUIInterface::MSG_INFORMATION); } void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event) { // Accept only URIs if(event->mimeData()->hasUrls()) event->acceptProposedAction(); } void BitcoinGUI::dropEvent(QDropEvent *event) { if(event->mimeData()->hasUrls()) { int nValidUrisFound = 0; QList<QUrl> uris = event->mimeData()->urls(); foreach(const QUrl &uri, uris) { if (walletFrame->handleURI(uri.toString())) nValidUrisFound++; } // if valid URIs were found if (nValidUrisFound) walletFrame->gotoSendCoinsPage(); else message(tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid Ljcoin address or malformed URI parameters."), CClientUIInterface::ICON_WARNING); } event->acceptProposedAction(); } bool BitcoinGUI::eventFilter(QObject *object, QEvent *event) { // Catch status tip events if (event->type() == QEvent::StatusTip) { // Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff if (progressBarLabel->isVisible() || progressBar->isVisible()) return true; } return QMainWindow::eventFilter(object, event); } void BitcoinGUI::handleURI(QString strURI) { // URI has to be valid if (!walletFrame->handleURI(strURI)) message(tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid Ljcoin address or malformed URI parameters."), CClientUIInterface::ICON_WARNING); } void BitcoinGUI::setEncryptionStatus(int status) { switch(status) { case WalletModel::Unencrypted: labelEncryptionIcon->hide(); encryptWalletAction->setChecked(false); changePassphraseAction->setEnabled(false); encryptWalletAction->setEnabled(true); break; case WalletModel::Unlocked: labelEncryptionIcon->show(); labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>")); encryptWalletAction->setChecked(true); changePassphraseAction->setEnabled(true); encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported break; case WalletModel::Locked: labelEncryptionIcon->show(); labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>")); encryptWalletAction->setChecked(true); changePassphraseAction->setEnabled(true); encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported break; } } void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { // activateWindow() (sometimes) helps with keyboard focus on Windows if (isHidden()) { show(); activateWindow(); } else if (isMinimized()) { showNormal(); activateWindow(); } else if (GUIUtil::isObscured(this)) { raise(); activateWindow(); } else if(fToggleHidden) hide(); } void BitcoinGUI::toggleHidden() { showNormalIfMinimized(true); } void BitcoinGUI::detectShutdown() { if (ShutdownRequested()) QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection); }
[ "36365036+merecoin@users.noreply.github.com" ]
36365036+merecoin@users.noreply.github.com
e651a1220822bf4fa94d50f221eef79a7fed239b
90d386690d8935b0ef5b887fc8e32afdda92c186
/src/proc/gsx_process_cycle.cxx
9d8bb019fbd9e5011a5b60e831e028e972be644f
[ "MIT" ]
permissive
ShixianGuo/gserver
a8b509a39331e4477a58bc8ef9662d9229f2a111
02d5a1cd934eaa055b33eadbaa4827f161565c5a
refs/heads/master
2021-04-11T10:25:37.125158
2020-03-31T17:25:09
2020-03-31T17:25:09
231,286,942
9
1
null
null
null
null
UTF-8
C++
false
false
3,782
cxx
 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <signal.h> #include <errno.h> #include <unistd.h> #include "gsx_func.h" #include "gsx_macro.h" #include "gsx_c_conf.h" static void gsx_start_worker_processes(int threadnums); static int gsx_spawn_process(int threadnums, const char *pprocname); static void gsx_worker_process_cycle(int inum, const char *pprocname); static void gsx_worker_process_init(int inum); static u_char master_process[] = "master process"; void gsx_master_process_cycle() { sigset_t set; sigemptyset(&set); sigaddset(&set, SIGCHLD); sigaddset(&set, SIGALRM); sigaddset(&set, SIGIO); sigaddset(&set, SIGINT); sigaddset(&set, SIGHUP); sigaddset(&set, SIGUSR1); sigaddset(&set, SIGUSR2); sigaddset(&set, SIGWINCH); sigaddset(&set, SIGTERM); sigaddset(&set, SIGQUIT); if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) { gsx_log_error_core(GSX_LOG_ALERT, errno, "gsx_master_process_cycle()中sigprocmask()失败!"); } size_t size; int i; size = sizeof(master_process); size += g_argvneedmem; if (size < 1000) { char title[1000] = {0}; strcpy(title, (const char *)master_process); strcat(title, " "); for (i = 0; i < g_os_argc; i++) { strcat(title, g_os_argv[i]); } gsx_setproctitle(title); gsx_log_error_core(GSX_LOG_NOTICE, 0, "%s %P 【master进程】启动并开始运行......!", title, gsx_pid); } CConfig *p_config = CConfig::GetInstance(); int workprocess = p_config->GetIntDefault("WorkerProcesses", 1); gsx_start_worker_processes(workprocess); sigemptyset(&set); for (;;) { sigsuspend(&set); sleep(1); } return; } static void gsx_start_worker_processes(int threadnums) { int i; for (i = 0; i < threadnums; i++) { gsx_spawn_process(i, "worker process"); } return; } static int gsx_spawn_process(int inum, const char *pprocname) { pid_t pid; pid = fork(); switch (pid) { case -1: gsx_log_error_core(GSX_LOG_ALERT, errno, "gsx_spawn_process()fork()产生子进程num=%d,procname=\"%s\"失败!", inum, pprocname); return -1; case 0: gsx_parent = gsx_pid; gsx_pid = getpid(); gsx_worker_process_cycle(inum, pprocname); break; default: break; } return pid; } static void gsx_worker_process_cycle(int inum, const char *pprocname) { gsx_process = GSX_PROCESS_WORKER; gsx_worker_process_init(inum); gsx_setproctitle(pprocname); gsx_log_error_core(GSX_LOG_NOTICE, 0, "%s %P 【worker进程】启动并开始运行......!", pprocname, gsx_pid); for (;;) { gsx_process_events_and_timers(); /*if(false) { g_stopEvent = 1; break; }*/ } g_threadpool.StopAll(); g_socket.Shutdown_subproc(); return; } static void gsx_worker_process_init(int inum) { sigset_t set; sigemptyset(&set); if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) { gsx_log_error_core(GSX_LOG_ALERT, errno, "gsx_worker_process_init()中sigprocmask()失败!"); } CConfig *p_config = CConfig::GetInstance(); int tmpthreadnums = p_config->GetIntDefault("ProcMsgRecvWorkThreadCount", 5); if (g_threadpool.Create(tmpthreadnums) == false) { exit(-2); } sleep(1); if (g_socket.Initialize_subproc() == false) { exit(-2); } g_socket.gsx_epoll_init(); return; }
[ "729841861@qq.com" ]
729841861@qq.com
63914a9293fa02cfae1d583569a6f5699135a8bf
51635684d03e47ebad12b8872ff469b83f36aa52
/external/gcc-12.1.0/libstdc++-v3/testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc
e106b5c750e09e7c89b221654d0fabcd7c2d7667
[ "LGPL-2.1-only", "GPL-3.0-only", "GCC-exception-3.1", "GPL-2.0-only", "LGPL-3.0-only", "LGPL-2.0-or-later", "Zlib", "LicenseRef-scancode-public-domain" ]
permissive
zhmu/ananas
8fb48ddfe3582f85ff39184fc7a3c58725fe731a
30850c1639f03bccbfb2f2b03361792cc8fae52e
refs/heads/master
2022-06-25T10:44:46.256604
2022-06-12T17:04:40
2022-06-12T17:04:40
30,108,381
59
8
Zlib
2021-09-26T17:30:30
2015-01-31T09:44:33
C
UTF-8
C++
false
false
4,636
cc
// -*- C++ -*- // { dg-options "-ltbb" } // { dg-do run { target c++17 } } // { dg-timeout-factor 4 } // { dg-require-effective-target tbb_backend } //===-- find_end.pass.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "pstl/pstl_test_config.h" #ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" #else #include <execution> #include <algorithm> #endif // PSTL_STANDALONE_TESTS #include "pstl/test_utils.h" using namespace TestUtils; struct test_one_policy { #if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \ _PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration template <typename Iterator1, typename Iterator2, typename Predicate> void operator()(pstl::execution::unsequenced_policy, Iterator1 b, Iterator1 e, Iterator2 bsub, Iterator2 esub, Predicate pred) { } template <typename Iterator1, typename Iterator2, typename Predicate> void operator()(pstl::execution::parallel_unsequenced_policy, Iterator1 b, Iterator1 e, Iterator2 bsub, Iterator2 esub, Predicate pred) { } #endif template <typename ExecutionPolicy, typename Iterator1, typename Iterator2, typename Predicate> void operator()(ExecutionPolicy&& exec, Iterator1 b, Iterator1 e, Iterator2 bsub, Iterator2 esub, Predicate pred) { using namespace std; // For find_end { auto expected = find_end(b, e, bsub, esub, pred); auto actual = find_end(exec, b, e, bsub, esub); EXPECT_TRUE(actual == expected, "wrong return result from find_end"); actual = find_end(exec, b, e, bsub, esub, pred); EXPECT_TRUE(actual == expected, "wrong return result from find_end with a predicate"); } // For search { auto expected = search(b, e, bsub, esub, pred); auto actual = search(exec, b, e, bsub, esub); EXPECT_TRUE(actual == expected, "wrong return result from search"); actual = search(exec, b, e, bsub, esub, pred); EXPECT_TRUE(actual == expected, "wrong return result from search with a predicate"); } } }; template <typename T> void test(const std::size_t bits) { const std::size_t max_n1 = 1000; const std::size_t max_n2 = (max_n1 * 10) / 8; Sequence<T> in(max_n1, [max_n1, bits](std::size_t) { return T(2 * HashBits(max_n1, bits - 1) ^ 1); }); Sequence<T> sub(max_n2, [max_n1, bits](std::size_t) { return T(2 * HashBits(max_n1, bits - 1)); }); for (std::size_t n1 = 0; n1 <= max_n1; n1 = n1 <= 16 ? n1 + 1 : size_t(3.1415 * n1)) { std::size_t sub_n[] = {0, 1, 3, n1, (n1 * 10) / 8}; std::size_t res[] = {0, 1, n1 / 2, n1}; for (auto n2 : sub_n) { for (auto r : res) { std::size_t i = r, isub = 0; for (; i < n1 && isub < n2; ++i, ++isub) in[i] = sub[isub]; invoke_on_all_policies(test_one_policy(), in.begin(), in.begin() + n1, sub.begin(), sub.begin() + n2, std::equal_to<T>()); invoke_on_all_policies(test_one_policy(), in.cbegin(), in.cbegin() + n1, sub.cbegin(), sub.cbegin() + n2, std::equal_to<T>()); } } } } template <typename T> struct test_non_const { template <typename Policy, typename FirstIterator, typename SecondInterator> void operator()(Policy&& exec, FirstIterator first_iter, SecondInterator second_iter) { invoke_if(exec, [&]() { find_end(exec, first_iter, first_iter, second_iter, second_iter, non_const(std::equal_to<T>())); search(exec, first_iter, first_iter, second_iter, second_iter, non_const(std::equal_to<T>())); }); } }; int32_t main() { test<int32_t>(8 * sizeof(int32_t)); test<uint16_t>(8 * sizeof(uint16_t)); test<float64_t>(53); #if !_PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN test<bool>(1); #endif test_algo_basic_double<int32_t>(run_for_rnd_fw<test_non_const<int32_t>>()); std::cout << done() << std::endl; return 0; }
[ "rink@rink.nu" ]
rink@rink.nu
f48178efdb2fb32aab30645eb8bc425f344d3297
740e79f96f8e43fbf9033462af08c1f6a1f0f943
/torch/csrc/profiler/python/init.h
13b34b6727995f9e23a131b135888153d84f2cfc
[ "BSD-3-Clause", "LicenseRef-scancode-generic-cla", "BSL-1.0", "Apache-2.0", "BSD-2-Clause" ]
permissive
zhengwy888/pytorch
0785d5f5721dcfc2adfe8cad3184405be653c825
c8776dca6a503eaa92a8d7b2427ebce7a19df398
refs/heads/master
2022-10-14T20:15:58.414139
2022-09-27T18:43:39
2022-09-27T18:43:39
175,150,187
0
0
NOASSERTION
2019-03-12T06:37:19
2019-03-12T06:37:16
null
UTF-8
C++
false
false
661
h
#pragma once #include <Python.h> #include <torch/csrc/profiler/collection.h> #include <torch/csrc/profiler/python/pybind.h> namespace pybind11 { namespace detail { using torch::profiler::impl::StorageImplData; using torch::profiler::impl::TensorImplAddress; template <> struct type_caster<StorageImplData> : public strong_pointer_type_caster<StorageImplData> {}; template <> struct type_caster<TensorImplAddress> : public strong_pointer_type_caster<TensorImplAddress> {}; } // namespace detail } // namespace pybind11 namespace torch { namespace profiler { void initPythonBindings(PyObject* module); } // namespace profiler } // namespace torch
[ "pytorchmergebot@users.noreply.github.com" ]
pytorchmergebot@users.noreply.github.com
7c942c9e89da4ff01ca6ff320c8be27029ebe2b0
9e5d1e9414833472f43f3616e1c140f6ed5b6ee9
/Codeforces/2020/Global_12/E.cpp
9878c5f217b92770503196f195078d80f9df2cc2
[]
no_license
junewaves/contests
a93dc3b3c1a167005fe12bb0ee6f330ac572f1c4
387860b65bdd3c1559f93c5f2d01c69ee364506e
refs/heads/master
2023-02-27T07:45:11.339127
2021-02-08T18:05:01
2021-02-08T18:05:01
254,631,323
0
0
null
null
null
null
UTF-8
C++
false
false
2,814
cpp
#include <bits/stdc++.h> using namespace std; template<class Fun> class y_combinator_result { Fun fun_; public: template<class T> explicit y_combinator_result(T&& fun) : fun_(std::forward<T>(fun)) {} template<class... Args> decltype(auto) operator()(Args&&... args) { return fun_(std::ref(*this), std::forward<Args>(args)...); } }; template<class Fun> decltype(auto) y_combinator(Fun&& fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); } int main() { ios::sync_with_stdio(false), cin.tie(nullptr); int n, m; cin >> n >> m; if (n == 1) { cout << "YES\n0\n0\n"; return 0; } vector<vector<int>> adj(n); vector<vector<int>> dist(n, vector<int>(n, int(1e9))); vector<int> deg(n); for (int i = 0; i < n; i++) dist[i][i] = 0; for (int i = 0; i < m; i++) { int u, v, dir; cin >> u >> v >> dir; --u, --v; if (dir) { adj[u].push_back(v); deg[v]++; dist[u][v] = 1; dist[v][u] = -1; } else { adj[u].push_back(v); adj[v].push_back(u); deg[u]++; deg[v]++; dist[u][v] = 1; dist[v][u] = 1; } } int start = min_element(deg.begin(), deg.end()) - deg.begin(); vector<int> color(n, 0); auto bipartite = y_combinator([&](auto dfs, int u, int p, int c) -> bool { color[u] = c; for (int v : adj[u]) { if (v == p) continue; if (color[v] == 0) { if (!dfs(v, u, 3 - c)) return false; } else if (color[v] == c) { return false; } } return true; })(start, -1, 1); if (!bipartite) { cout << "NO\n"; return 0; } for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (dist[i][j] > dist[i][k] + dist[k][j]) { cout << "NO\n"; return 0; } int max_dist = 0; int u = -1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j) { if (dist[i][j] > max_dist) { max_dist = dist[i][j]; u = i; } max_dist = max(max_dist, dist[i][j]); } } } assert(u >= 0); cout << "YES\n"; cout << max_dist << '\n'; for (int i = 0; i < n; i++) cout << dist[u][i] << ' '; cout << endl; return 0; }
[ "a0929551932@gmail.com" ]
a0929551932@gmail.com
ecd07ad127952d60dea4218bdcfc34aabb1170fd
7b92f4574caf894e8e4c35aa721ba563b8868bac
/Obfuscated Codes/test4.cpp
acd412449c1156b87084515d054f90bb9f176a59
[]
no_license
sarvaniimranalikhan/Obfuscation-Results
6780bb8e2a327972d7df3b2908299e8c8895efbd
b500e9aa23d68ecdf5c7bd8f37361ddca3a9ab1d
refs/heads/master
2023-05-28T06:21:10.582966
2023-04-28T09:04:49
2023-04-28T09:04:49
191,743,108
0
0
null
null
null
null
UTF-8
C++
false
false
285
cpp
#include \ <iostream> using namespace std ; int lo ( ) { string i0 , I0 ; cout << "\105\156t\145\162 string \1631:\040" ; getline ( cin , i0 ) ; I0 = i0 ; cout << "s1\040\075 " << i0 << endl ; cout << "\1632\040= " << I0 ; return 0 ; }
[ "noreply@github.com" ]
noreply@github.com
7aa0223f52edaa0ddf51866976f3c3c34d8315c8
38b55a50fdc2ba67ae74a65f375f6460438140bb
/Projects/assembler/test_queue_int.cpp
31543586d6a76150db4c779d267ba5a7c59e6dc2
[]
no_license
Rollo-Pollo/CS23001-KentState
c3160228ee0e70a7f77267f6083f911702d1ecd3
493e6ecafc98570dc211c7a8eb566f39200699df
refs/heads/master
2023-03-17T08:43:26.429437
2015-09-16T00:17:00
2015-09-16T00:17:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
640
cpp
/* * ===================================================================================== * * Filename: test_stack_int.cpp * * Description: Tests stacks with ints * * Version: 1.0 * Created: Today * Revision: none * Compiler: clang++ * * Author: Christopher Jones * * ===================================================================================== */ #include "queue.hpp" int main() { { Queue<int> blank_queue; assert(blank_queue == Queue<int>()); assert(blank_queue.getLength() == 0); } std::cout << "Completed testing queue!" << std::endl; return 0; }
[ "christopherjones72521@gmail.com" ]
christopherjones72521@gmail.com
0120d92790377a47efa8a323e2c84e6a27653c21
f1fa1926c6879b01cb1789d57af88501dca429f2
/include/mbedtls_util/mbed_aes128_gcm.hpp
675163d03d547b782cdada4055ca189da5dc858b
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
suburbanembedded/mbedtls_util
cc44e0945bc8f87f69e8784f4425acf5a9a85ac6
eb708645b7eca61060f37ad97ba56f3906eacc6b
refs/heads/master
2020-08-09T13:14:57.351453
2020-05-25T20:58:43
2020-05-25T20:58:43
214,095,372
0
0
null
null
null
null
UTF-8
C++
false
false
1,588
hpp
/** * @brief mbed_aes128_gcm * @author Jacob Schloss <jacob@schloss.io> * @copyright Copyright (c) 2019 Jacob Schloss. All rights reserved. * @license Licensed under the 3-Clause BSD license. See LICENSE for details */ #pragma once #include <mbedtls/cipher.h> #include <array> class mbed_aes128_gcm { public: static constexpr size_t TAG_SIZE = 128 / CHAR_BIT; static constexpr size_t BLOCK_SIZE = 128 / CHAR_BIT; static constexpr size_t KEY_LEN_BITS = 128; static constexpr size_t KEY_SIZE = 128 / CHAR_BIT; typedef std::array<unsigned char, BLOCK_SIZE> BlockType; typedef std::array<unsigned char, KEY_SIZE> KeyType; typedef std::array<unsigned char, BLOCK_SIZE> IVType; typedef std::array<unsigned char, TAG_SIZE> TagType; void set_key(const KeyType& key) { m_key = key; } const KeyType& get_key() const { return m_key; } static bool key_from_str(const char key_str[], KeyType* const out_key); static bool iv_from_str(const char iv_str[], IVType* const out_iv); static bool tag_from_str(const char tag_str[], TagType* const out_tag); void set_iv(const IVType& iv) { m_iv = iv; } const IVType& get_iv() const { return m_iv; } void set_tag(const TagType& tag) { m_tag = tag; } const TagType& get_tag() const { return m_tag; } bool update(const BlockType& in_block, const size_t in_block_len, BlockType* const out_block, size_t* const out_len); protected: std::array<unsigned char, KEY_SIZE> m_key; std::array<unsigned char, BLOCK_SIZE> m_iv; std::array<unsigned char, TAG_SIZE> m_tag; mbedtls_cipher_context_t ctx; };
[ "jacob@schloss.io" ]
jacob@schloss.io
b44d8a3523cbc180dc75b9ef87d79119b99814ec
a6e474c6d1ecf31f93d81a553b6e1fcf69456efd
/include/solutions/231.power-of-two.hpp
605a8f63589839cc707b7389bef0baff618bd9d0
[]
no_license
georg-cantor/leetcode_cpp
bb90ce1602529395c540ee7b3742cb198b8e9d4e
a5aa5188c9f3b82e916b1ad95c61d96dcf167e89
refs/heads/master
2021-02-17T07:27:46.551018
2020-07-08T08:16:25
2020-07-08T08:16:25
243,653,395
0
0
null
null
null
null
UTF-8
C++
false
false
938
hpp
/* * @lc app=leetcode id=231 lang=cpp * * [231] Power of Two * * https://leetcode.com/problems/power-of-two/description/ * * algorithms * Easy (42.81%) * Likes: 758 * Dislikes: 182 * Total Accepted: 306.7K * Total Submissions: 708.6K * Testcase Example: '1' * * Given an integer, write a function to determine if it is a power of two. * * Example 1: * * * Input: 1 * Output: true * Explanation: 2^0 = 1 * * * Example 2: * * * Input: 16 * Output: true * Explanation: 2^4 = 16 * * Example 3: * * * Input: 218 * Output: false * */ // @lc code=start class Solution { public: bool isPowerOfTwo(int n) { //if (n == std::numeric_limits<int>::min()) return true; if (n <= 0) return false; while (n > 1) { if (n % 2 == 1) { return false; } n = n / 2; } return true; } }; // @lc code=end
[ "dongliang0908@126.com" ]
dongliang0908@126.com
6f80c621d4cdf27a140b5abd7454749bb5e74fbd
280793e8bad58faed73113842eee9d62e06054da
/src/builtins/module.re
b7a6438273d8719f066ec74815803c864c96b1b7
[ "MIT" ]
permissive
skarayan/reia
f46f03c6cae4356b10adc2a7bd0f95c738c2c78a
8385107c49c597163b08be5ddd0e2a2cb05b70b2
refs/heads/master
2021-01-23T20:21:58.454854
2010-12-09T02:00:18
2010-12-09T02:00:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
668
re
# # module.re: Methods of the Module builtin # Copyright (C)2010 Tony Arcieri # # Redistribution is permitted under the MIT license. See LICENSE for details. # module Module def class; Module; end def call(fake_self, :to_s, args, block) (:reia_module, name) = fake_self case erl.code.ensure_loaded(name) when (:module, name) name.to_string() when _ throw(NameError, "undefined module #{name}") :error end end def call(fake_self, :inspect, args, block) fake_self.to_s() end def call(fake_self, method, args, block) (:reia_module, name) = fake_self erl.apply(name, method, [args, block]) end end
[ "tony@medioh.com" ]
tony@medioh.com
abc4f2da46fd4f121b45d4577235e9256d5cdaf2
8f6dba8d9f03d552b7cdf7141d8ed416990f6c17
/chapter5/5.10.cpp
d5a28e214ad4afcf2af5fdad949fa5b5b6e6b6a3
[]
no_license
NealChalmers/CPP-Primer
3ebe321f5010d7af4b84cba8331242c607b8393d
32d583831a9f8623b7246dc3eb92026f70be5451
refs/heads/master
2021-10-23T11:37:16.751835
2019-03-17T08:38:09
2019-03-17T08:38:09
99,414,989
1
0
null
null
null
null
UTF-8
C++
false
false
478
cpp
#include <iostream> using std::cout; using std::endl; using std::cin; int main() { unsigned a = 0, e = 0, i = 0, o = 0, u = 0; //count vowel letter char ch; while (cin >> ch) { if (ch == 'a') ++a; else if (ch == 'e' || ch == 'E') ++e; else if (ch == 'i' || ch == 'I') ++i; else if (ch == 'o' || ch == 'O') ++o; else if (ch == 'u' || ch == 'U') ++u; } cout << "a:" << a << "\ne:" << e << "\ni:" << i << "\no:" << o << "\nu:" << u << endl; }
[ "Chalmers111@qq.com" ]
Chalmers111@qq.com
297cfebb6101673f0c554753396c904091336117
3122ac39f1ce0a882b48293a77195476299c2a3b
/clients/cpp-restsdk/generated/model/PipelineRunNodeSteps.cpp
3d8f60a22d2b705b00d32808a17bec33d6cd3c91
[ "MIT" ]
permissive
miao1007/swaggy-jenkins
4e6fe28470eda2428cbc584dcd365a21caa606ef
af79438c120dd47702b50d51c42548b4db7fd109
refs/heads/master
2020-08-30T16:50:27.474383
2019-04-10T13:47:17
2019-04-10T13:47:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,592
cpp
/** * Swaggy Jenkins * Jenkins API clients generated from Swagger / Open API specification * * OpenAPI spec version: 1.1.1 * Contact: blah@cliffano.com * * NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ #include "PipelineRunNodeSteps.h" namespace org { namespace openapitools { namespace client { namespace model { PipelineRunNodeSteps::PipelineRunNodeSteps() { } PipelineRunNodeSteps::~PipelineRunNodeSteps() { } void PipelineRunNodeSteps::validate() { // TODO: implement validation } web::json::value PipelineRunNodeSteps::toJson() const { web::json::value val = this->null<PipelineStepImpl>::toJson(); return val; } void PipelineRunNodeSteps::fromJson(web::json::value& val) { this->null<PipelineStepImpl>::fromJson(val); } void PipelineRunNodeSteps::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const { utility::string_t namePrefix = prefix; if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) { namePrefix += utility::conversions::to_string_t("."); } } void PipelineRunNodeSteps::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) { utility::string_t namePrefix = prefix; if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) { namePrefix += utility::conversions::to_string_t("."); } } } } } }
[ "cliffano@gmail.com" ]
cliffano@gmail.com
6d820087c60191ade27e0246f8d5e384f1b64eee
32a9356bc4e0af62eb960c89ab3adc373812675f
/XSC/SemanticGraph/Namespace.hpp
97635a81a8a903e297b21fd20541725051d576a1
[]
no_license
DOCGroup/XSC
0c2ce163a307f9d20366d707f772ff1f04c72261
b85458b18b95bf81dc9c807d8d06768111b22172
refs/heads/master
2023-08-25T18:53:51.641598
2022-05-10T14:18:58
2022-05-10T14:18:58
27,931,533
4
3
null
2023-09-11T06:12:54
2014-12-12T17:54:46
C++
UTF-8
C++
false
false
599
hpp
// file : XSC/SemanticGraph/Namespace.hpp // author : Boris Kolpackov <boris@dre.vanderbilt.edu> #ifndef XSC_SEMANTIC_GRAPH_NAMESPACE_HXX #define XSC_SEMANTIC_GRAPH_NAMESPACE_HXX #include <XSC/SemanticGraph/Elements.hpp> namespace XSC { namespace SemanticGraph { class Namespace : public virtual Scope { public: static Introspection::TypeInfo const& static_type_info (); protected: friend class Graph<Node, Edge>; Namespace () { type_info (static_type_info ()); } }; } } #endif // XSC_SEMANTIC_GRAPH_NAMESPACE_HXX
[ "arvindk@dre.vanderbilt.edu" ]
arvindk@dre.vanderbilt.edu
97841687cb8b7c077fc4e5923b28dc10f2d25e6f
872d953b46cdd91659d04efe1969a42ae8b51db3
/Lab13_UserDefinedFunction.cpp
2f867f9c0e19be0313cef8a181b8a464555b5d7a
[]
no_license
ppacris/cplusplus
95c0822de4d41cc82a9218403e8c159996b8bab8
128db77d2ad93f76197fda20f6728c401b0e4959
refs/heads/master
2023-02-13T22:33:00.248478
2021-01-09T23:41:04
2021-01-09T23:41:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
486
cpp
#include <iostream> using namespace std; void add(); int subtract(); double product(double, double); double quotient(double, double = 2); int main() { add(); cout << subtract() + 100 << endl; cout << product(5, 2.5) << endl; cout << quotient(10) << endl; return 0; } void add() { cout << 5 + 2 << endl; } int subtract() { return 5 - 2; } double product(double num1, double num2) { return num1 * num2; } double quotient(double num1, double num2) { return num1 / num2; }
[ "romarcablao@gmail.com" ]
romarcablao@gmail.com
6764d4f2a143a82d91e8f39cdecb19f53dad2e65
bf2869a0d080fa547c2557962659fa0822c4f6eb
/Bean/bean/wxgui/ButtonInterface.cpp
c7761d751a32f1cb635e40d0aa2fc09150d2c91c
[]
no_license
desktopgame/Bean
966f8a148c94bb1035373a811c910e3f50f6d238
743904b5d61d4914536e5fbb678236199abe6f0b
refs/heads/master
2021-09-26T08:43:48.247461
2017-11-11T06:22:01
2017-11-11T06:22:01
110,304,259
2
0
null
null
null
null
UTF-8
C++
false
false
147
cpp
#include "ButtonInterface.h" //public method--- ButtonInterface::ButtonInterface() { } ButtonInterface::~ButtonInterface() { } //---public method
[ "koya0306@outlook.jp" ]
koya0306@outlook.jp
356fa2e40e9de9f9c38f563e28407e5de8144ba8
74c02b03011b00411f9f6696924e178ed2a15d2a
/Ticket_booking_system/userwindow.cpp
9bf003cb62e6df334aa5335a7d23a3331c76e163
[]
no_license
ruirui0330/Windows_Qt
e5a9ba175e17f522e7b69d7f8572bf11889bf50f
bf0266c85cfae1f7e58e83c9d9851a5173506c5a
refs/heads/master
2023-04-18T01:14:16.046888
2021-05-07T13:16:13
2021-05-07T13:16:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
75,598
cpp
#include "userwindow.h" #include "ui_userwindow.h" #include "mainwindow.h" #include <QPainter> #include <QMessageBox> #include <QSqlTableModel> #include <QDebug> #include <QDate> #include <QTime> #include <QSqlQuery> QString ac_user_tel; UserWindow::UserWindow(QWidget *parent) : QWidget(parent), ui(new Ui::UserWindow) { ui->setupUi(this); initUser_info(); initUserwindow(); } UserWindow::~UserWindow() { delete ui; } //给用户界面添加可以缩放背景图片 void UserWindow::paintEvent(QPaintEvent *event) { QPainter myPainter(this); myPainter.setOpacity(0.9); //背景图片透明度 myPainter.drawPixmap(0,0,this->width(),this->height(),QPixmap(":/image/images/userbackground1.jpg")); } //初始化用户界面 void UserWindow::initUserwindow() { //order_cen_show(); //显示订单中心订单相关信息 //my_home_show(); //显示个人中心机票相关信息 ui->one_way_radioButton->setChecked(true); //初始化为单程城市航班查询 ui->flight_date_dateEdit->setCalendarPopup(true); //设置dateedit显示日历 QDate local(QDate::currentDate()); ui->flight_date_dateEdit->setDate(local); //设置日历为当前日期 ui->flight_que_tableWidget->horizontalHeader()->setStretchLastSection(true); ui->order_cen_tableWidget->horizontalHeader()->setStretchLastSection(true); ui->my_home_tableWidget->horizontalHeader()->setStretchLastSection(true); ui->flight_que_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->order_cen_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->my_home_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->flight_num_lineEdit->setReadOnly(true); //设置flight_num_edit不可编辑 ui->flight_date_dateEdit->setReadOnly(true); //设置dateedit不可编辑 if(ui->ch_des_city_comboBox->currentText() == "热门") { ui->des_city_comboBox->insertItem(0, "北京"); ui->des_city_comboBox->insertItem(1, "上海"); ui->des_city_comboBox->insertItem(2, "广州"); ui->des_city_comboBox->insertItem(3, "深圳"); ui->des_city_comboBox->insertItem(4, "成都"); ui->des_city_comboBox->insertItem(5, "杭州"); ui->des_city_comboBox->insertItem(6, "西安"); ui->des_city_comboBox->insertItem(7, "重庆"); ui->des_city_comboBox->insertItem(8, "青岛"); ui->des_city_comboBox->insertItem(9, "南京"); ui->des_city_comboBox->insertItem(10, "厦门"); ui->des_city_comboBox->insertItem(11, "昆明"); ui->des_city_comboBox->insertItem(12, "大连"); ui->des_city_comboBox->insertItem(13, "天津"); ui->des_city_comboBox->insertItem(14, "郑州"); ui->des_city_comboBox->insertItem(15, "三亚"); ui->des_city_comboBox->insertItem(16, "济南"); ui->des_city_comboBox->insertItem(17, "福州"); } if(ui->ch_lev_city_comboBox->currentText() == "热门") { ui->lev_city_comboBox->insertItem(0, "北京"); ui->lev_city_comboBox->insertItem(1, "上海"); ui->lev_city_comboBox->insertItem(2, "广州"); ui->lev_city_comboBox->insertItem(3, "深圳"); ui->lev_city_comboBox->insertItem(4, "成都"); ui->lev_city_comboBox->insertItem(5, "杭州"); ui->lev_city_comboBox->insertItem(6, "西安"); ui->lev_city_comboBox->insertItem(7, "重庆"); ui->lev_city_comboBox->insertItem(8, "青岛"); ui->lev_city_comboBox->insertItem(9, "南京"); ui->lev_city_comboBox->insertItem(10, "厦门"); ui->lev_city_comboBox->insertItem(11, "昆明"); ui->lev_city_comboBox->insertItem(12, "大连"); ui->lev_city_comboBox->insertItem(13, "天津"); ui->lev_city_comboBox->insertItem(14, "郑州"); ui->lev_city_comboBox->insertItem(15, "三亚"); ui->lev_city_comboBox->insertItem(16, "济南"); ui->lev_city_comboBox->insertItem(17, "福州"); } } //初始化用户信息 void UserWindow::initUser_info() { user_tel = ac_user_tel; QSqlTableModel user_info_model; user_info_model.setTable("user_info"); user_info_model.setFilter(tr("u_tel = '%1'").arg(user_tel)); user_info_model.select(); int rowcount = user_info_model.rowCount(); if( rowcount == 1) { user_name = user_info_model.data(user_info_model.index(0, 0)).toString(); } qDebug() << user_name; } //清理flight_que_table void UserWindow::clear_flight_que_table() { ui->flight_que_tableWidget->clearContents(); ui->flight_que_tableWidget->setRowCount(0); //ui->flight_que_tableWidget->horizontalHeader()->setStretchLastSection(true); //使行列头自适应宽度,最后一列将会填充空白部分 //ui->flight_que_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //使行列头自适应宽度,所有列平均分来填充空白部分 } //清理order_cen_table void UserWindow::clear_order_cen_table() { ui->order_cen_tableWidget->clearContents(); ui->order_cen_tableWidget->setRowCount(0); //ui->order_cen_tableWidget->horizontalHeader()->setStretchLastSection(true); //使行列头自适应宽度,最后一列将会填充空白部分 //ui->order_cen_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //使行列头自适应宽度,所有列平均分来填充空白部分 } //清理_my_home_table void UserWindow::clear_my_home_table() { ui->my_home_tableWidget->clearContents(); ui->my_home_tableWidget->setRowCount(0); //ui->order_cen_tableWidget->horizontalHeader()->setStretchLastSection(true); //使行列头自适应宽度,最后一列将会填充空白部分 //ui->order_cen_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //使行列头自适应宽度,所有列平均分来填充空白部分 } //菜单_个人中心 void UserWindow::on_menu_my_home_pushButton_clicked() { my_home_show(); ui->stackedWidget->setCurrentWidget(ui->my_home_page); } //菜单_订单中心 void UserWindow::on_menu_order_cen_pushButton_clicked() { order_cen_show(); ui->stackedWidget->setCurrentWidget(ui->order_cen_page); } //菜单_航班查询 void UserWindow::on_menu_flight_que_pushButton_clicked() { ui->stackedWidget->setCurrentWidget(ui->flight_que_page); } //退出登录功能 void UserWindow::on_logout_pushButton_clicked() { QMessageBox::StandardButton reply = QMessageBox::question(this, "提示", "确认退出系统吗?", QMessageBox::Yes | QMessageBox::No); if(reply == QMessageBox::Yes) { this->close(); MainWindow *mw = new MainWindow(); mw->setWindowTitle("航空机票预订系统"); mw->show(); } else { } } /****************************************************************************************航班查询及下单功能****************************************************************************/ //单程城市查询_radioButton void UserWindow::on_one_way_radioButton_clicked() { ui->flight_que_pushButton->setText("单程城市航班查询"); ui->flight_num_lineEdit->setReadOnly(true); ui->flight_date_dateEdit->setReadOnly(true); ui->lev_city_comboBox->setEnabled(true); ui->des_city_comboBox->setEnabled(true); ui->flight_num_lineEdit->clear(); clear_flight_que_table(); } //双程城市查询_radioButton void UserWindow::on_two_way_radioButton_clicked() { ui->flight_que_pushButton->setText("双程城市航班查询"); ui->flight_num_lineEdit->setReadOnly(true); ui->flight_date_dateEdit->setReadOnly(true); ui->lev_city_comboBox->setEnabled(true); ui->des_city_comboBox->setEnabled(true); ui->flight_num_lineEdit->clear(); clear_flight_que_table(); } //按航班号查询_radioButton void UserWindow::on_flight_num_que_radioButton_clicked() { ui->flight_que_pushButton->setText("航班号查询"); ui->flight_num_lineEdit->setReadOnly(false); ui->flight_date_dateEdit->setReadOnly(true); ui->ch_lev_city_comboBox->setEnabled(false); ui->ch_des_city_comboBox->setEnabled(false); ui->lev_city_comboBox->setEnabled(false); ui->des_city_comboBox->setEnabled(false); ui->flight_num_lineEdit->clear(); clear_flight_que_table(); } //按航班日期查询_radioButton void UserWindow::on_flight_date_que_radioButton_clicked() { ui->flight_que_pushButton->setText("航班日期查询"); ui->flight_num_lineEdit->setReadOnly(true); ui->flight_date_dateEdit->setReadOnly(false); ui->ch_lev_city_comboBox->setEnabled(false); ui->ch_des_city_comboBox->setEnabled(false); ui->lev_city_comboBox->setEnabled(false); ui->des_city_comboBox->setEnabled(false); ui->flight_num_lineEdit->clear(); clear_flight_que_table(); } // 单程_双程_航班号查询 || 航班号查询 || 航班日期查询_pushButton void UserWindow::on_flight_que_pushButton_clicked() { ui->flight_que_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置每行内容不可编辑 ui->flight_que_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); //设置选择行为,以行为单位 flight_city_que(); flight_num_que(); flight_date_que(); } //单程 || 双程_航班号查询功能 void UserWindow::flight_city_que() { clear_flight_que_table(); if(ui->flight_que_pushButton->text() == "单程城市航班查询") { QString one_way_lev_city = ui->lev_city_comboBox->currentText(); QString one_way_des_city = ui->des_city_comboBox->currentText(); if(one_way_lev_city.isEmpty() || one_way_des_city.isEmpty()) { QMessageBox::about(NULL, "提示", "请选择始发地及目的城市城市!"); } else { QSqlTableModel flight_one_way_city_model; flight_one_way_city_model.setTable("flight_info"); flight_one_way_city_model.setFilter(tr("f_take_city = '%1' and f_ar_city = '%2'").arg(one_way_lev_city).arg(one_way_des_city)); flight_one_way_city_model.select(); int rowcount = flight_one_way_city_model.rowCount(); if( rowcount >= 1) { for(int i = 0 ; i < rowcount; i++) { f_num = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 0)).toString(); f_price = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 1)).toString(); f_to_date = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 2)).toString(); f_ar_date = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 3)).toString(); f_to_time = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 4)).toString(); f_dis = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 5)).toString(); f_type = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 6)).toString(); f_cro_city = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 7)).toString(); f_take_city = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 8)).toString(); f_ar_city = flight_one_way_city_model.data(flight_one_way_city_model.index(i, 9)).toString(); int table_row = ui->flight_que_tableWidget->rowCount(); ui->flight_que_tableWidget->insertRow(table_row); QTableWidgetItem *check = new QTableWidgetItem(); check->setCheckState(Qt::Unchecked); ui->flight_que_tableWidget->setItem(table_row,0,check); //插入复选框 ui->flight_que_tableWidget->setItem(table_row, 1, new QTableWidgetItem(f_num)); ui->flight_que_tableWidget->setItem(table_row, 2, new QTableWidgetItem(f_price)); ui->flight_que_tableWidget->setItem(table_row, 3, new QTableWidgetItem(f_to_date)); ui->flight_que_tableWidget->setItem(table_row, 4, new QTableWidgetItem(f_ar_date)); ui->flight_que_tableWidget->setItem(table_row, 5, new QTableWidgetItem(f_to_time)); ui->flight_que_tableWidget->setItem(table_row, 6, new QTableWidgetItem(f_dis)); ui->flight_que_tableWidget->setItem(table_row, 7, new QTableWidgetItem(f_type)); ui->flight_que_tableWidget->setItem(table_row, 8, new QTableWidgetItem(f_take_city)); ui->flight_que_tableWidget->setItem(table_row, 9, new QTableWidgetItem(f_ar_city)); ui->flight_que_tableWidget->setItem(table_row, 10, new QTableWidgetItem(f_cro_city)); } } else { QMessageBox::about(NULL, "提示", "未查询到单程城市相关航班信息!"); clear_flight_que_table(); } } } if(ui->flight_que_pushButton->text() == "双程城市航班查询") { QString two_way_lev_city = ui->lev_city_comboBox->currentText(); QString two_way_des_city = ui->des_city_comboBox->currentText(); if(two_way_lev_city.isEmpty() || two_way_des_city.isEmpty()) { QMessageBox::about(NULL, "提示", "请选择始发地城市!"); } else { QSqlTableModel flight_two_way_go_city_model; flight_two_way_go_city_model.setTable("flight_info"); flight_two_way_go_city_model.setFilter(tr("f_take_city = '%1' and f_ar_city = '%2'").arg(two_way_lev_city).arg(two_way_des_city)); flight_two_way_go_city_model.select(); int take_rowcount = flight_two_way_go_city_model.rowCount(); if( take_rowcount >= 1) { for(int i = 0 ; i < take_rowcount; i++) { f_num = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 0)).toString(); f_price = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 1)).toString(); f_to_date = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 2)).toString(); f_ar_date = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 3)).toString(); f_to_time = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 4)).toString(); f_dis = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 5)).toString(); f_type = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 6)).toString(); f_cro_city = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 7)).toString(); f_take_city = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 8)).toString(); f_ar_city = flight_two_way_go_city_model.data(flight_two_way_go_city_model.index(i, 9)).toString(); int table_row = ui->flight_que_tableWidget->rowCount(); ui->flight_que_tableWidget->insertRow(table_row); QTableWidgetItem *check = new QTableWidgetItem(); check->setCheckState(Qt::Unchecked); ui->flight_que_tableWidget->setItem(table_row,0,check); //插入复选框 ui->flight_que_tableWidget->setItem(table_row, 1, new QTableWidgetItem(f_num)); ui->flight_que_tableWidget->setItem(table_row, 2, new QTableWidgetItem(f_price)); ui->flight_que_tableWidget->setItem(table_row, 3, new QTableWidgetItem(f_to_date)); ui->flight_que_tableWidget->setItem(table_row, 4, new QTableWidgetItem(f_ar_date)); ui->flight_que_tableWidget->setItem(table_row, 5, new QTableWidgetItem(f_to_time)); ui->flight_que_tableWidget->setItem(table_row, 6, new QTableWidgetItem(f_dis)); ui->flight_que_tableWidget->setItem(table_row, 7, new QTableWidgetItem(f_type)); ui->flight_que_tableWidget->setItem(table_row, 8, new QTableWidgetItem(f_take_city)); ui->flight_que_tableWidget->setItem(table_row, 9, new QTableWidgetItem(f_ar_city)); ui->flight_que_tableWidget->setItem(table_row, 10, new QTableWidgetItem(f_cro_city)); } } QSqlTableModel flight_two_way_bc_city_model; flight_two_way_bc_city_model.setTable("flight_info"); flight_two_way_bc_city_model.setFilter(tr("f_take_city = '%1' and f_ar_city = '%2'").arg(two_way_des_city).arg(two_way_lev_city)); flight_two_way_bc_city_model.select(); int ar_rowcount = flight_two_way_bc_city_model.rowCount(); if( ar_rowcount >= 1) { for(int i = 0 ; i < ar_rowcount; i++) { f_num = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 0)).toString(); f_price = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 1)).toString(); f_to_date = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 2)).toString(); f_ar_date = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 3)).toString(); f_to_time = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 4)).toString(); f_dis = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 5)).toString(); f_type = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 6)).toString(); f_cro_city = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 7)).toString(); f_take_city = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 8)).toString(); f_ar_city = flight_two_way_bc_city_model.data(flight_two_way_bc_city_model.index(i, 9)).toString(); int table_row = ui->flight_que_tableWidget->rowCount(); ui->flight_que_tableWidget->insertRow(table_row); QTableWidgetItem *check = new QTableWidgetItem(); check->setCheckState(Qt::Unchecked); ui->flight_que_tableWidget->setItem(table_row,0,check); //插入复选框 ui->flight_que_tableWidget->setItem(table_row, 1, new QTableWidgetItem(f_num)); ui->flight_que_tableWidget->setItem(table_row, 2, new QTableWidgetItem(f_price)); ui->flight_que_tableWidget->setItem(table_row, 3, new QTableWidgetItem(f_to_date)); ui->flight_que_tableWidget->setItem(table_row, 4, new QTableWidgetItem(f_ar_date)); ui->flight_que_tableWidget->setItem(table_row, 5, new QTableWidgetItem(f_to_time)); ui->flight_que_tableWidget->setItem(table_row, 6, new QTableWidgetItem(f_dis)); ui->flight_que_tableWidget->setItem(table_row, 7, new QTableWidgetItem(f_type)); ui->flight_que_tableWidget->setItem(table_row, 8, new QTableWidgetItem(f_take_city)); ui->flight_que_tableWidget->setItem(table_row, 9, new QTableWidgetItem(f_ar_city)); ui->flight_que_tableWidget->setItem(table_row, 10, new QTableWidgetItem(f_cro_city)); } } else { QMessageBox::about(NULL, "提示", "未查询到双程城市相关航班信息!"); clear_flight_que_table(); } } } } //航班号查询功能 void UserWindow::flight_num_que() { if(ui->flight_que_pushButton->text() == "航班号查询") { QString flight_num = ui->flight_num_lineEdit->text(); if(flight_num.isEmpty()) { QMessageBox::about(NULL, "提示", "请输入航班号!"); } else { QSqlTableModel flight_num_model; flight_num_model.setTable("flight_info"); flight_num_model.setFilter(tr("f_num = '%1'").arg(flight_num)); flight_num_model.select(); int rowcount = flight_num_model.rowCount(); if( rowcount == 1) { f_num = flight_num_model.data(flight_num_model.index(0, 0)).toString(); f_price = flight_num_model.data(flight_num_model.index(0, 1)).toString(); f_to_date = flight_num_model.data(flight_num_model.index(0, 2)).toString(); f_ar_date = flight_num_model.data(flight_num_model.index(0, 3)).toString(); f_to_time = flight_num_model.data(flight_num_model.index(0, 4)).toString(); f_dis = flight_num_model.data(flight_num_model.index(0, 5)).toString(); f_type = flight_num_model.data(flight_num_model.index(0, 6)).toString(); f_cro_city = flight_num_model.data(flight_num_model.index(0, 7)).toString(); f_take_city = flight_num_model.data(flight_num_model.index(0, 8)).toString(); f_ar_city = flight_num_model.data(flight_num_model.index(0, 9)).toString(); int table_row = ui->flight_que_tableWidget->rowCount(); ui->flight_que_tableWidget->insertRow(table_row); QTableWidgetItem *check = new QTableWidgetItem(); check->setCheckState(Qt::Unchecked); ui->flight_que_tableWidget->setItem(table_row,0,check); //插入复选框 ui->flight_que_tableWidget->setItem(table_row, 1, new QTableWidgetItem(f_num)); ui->flight_que_tableWidget->setItem(table_row, 2, new QTableWidgetItem(f_price)); ui->flight_que_tableWidget->setItem(table_row, 3, new QTableWidgetItem(f_to_date)); ui->flight_que_tableWidget->setItem(table_row, 4, new QTableWidgetItem(f_ar_date)); ui->flight_que_tableWidget->setItem(table_row, 5, new QTableWidgetItem(f_to_time)); ui->flight_que_tableWidget->setItem(table_row, 6, new QTableWidgetItem(f_dis)); ui->flight_que_tableWidget->setItem(table_row, 7, new QTableWidgetItem(f_type)); ui->flight_que_tableWidget->setItem(table_row, 8, new QTableWidgetItem(f_take_city)); ui->flight_que_tableWidget->setItem(table_row, 9, new QTableWidgetItem(f_ar_city)); ui->flight_que_tableWidget->setItem(table_row, 10, new QTableWidgetItem(f_cro_city)); } else { QMessageBox::about(NULL, "提示", "未查询到该航班相关信息!"); ui->flight_num_lineEdit->clear(); ui->flight_num_lineEdit->setFocus(); clear_flight_que_table(); } } } } //航班日期查询 void UserWindow::flight_date_que() { if(ui->flight_que_pushButton->text() == "航班日期查询") { QString flight_to_date = ui->flight_date_dateEdit->date().toString("yyyy-MM-dd"); QSqlTableModel flight_date_model; flight_date_model.setTable("flight_info"); flight_date_model.setFilter(tr("f_to_date = '%1'").arg(flight_to_date)); flight_date_model.select(); int rowcount = flight_date_model.rowCount(); if( rowcount >= 1) { for(int i = 0 ; i < rowcount; i++) { f_num = flight_date_model.data(flight_date_model.index(i, 0)).toString(); f_price = flight_date_model.data(flight_date_model.index(i, 1)).toString(); f_to_date = flight_date_model.data(flight_date_model.index(i, 2)).toString(); f_ar_date = flight_date_model.data(flight_date_model.index(i, 3)).toString(); f_to_time = flight_date_model.data(flight_date_model.index(i, 4)).toString(); f_dis = flight_date_model.data(flight_date_model.index(i, 5)).toString(); f_type = flight_date_model.data(flight_date_model.index(i, 6)).toString(); f_cro_city = flight_date_model.data(flight_date_model.index(i, 7)).toString(); f_take_city = flight_date_model.data(flight_date_model.index(i, 8)).toString(); f_ar_city = flight_date_model.data(flight_date_model.index(i, 9)).toString(); int table_row = ui->flight_que_tableWidget->rowCount(); ui->flight_que_tableWidget->insertRow(table_row); QTableWidgetItem *check = new QTableWidgetItem(); check->setCheckState(Qt::Unchecked); ui->flight_que_tableWidget->setItem(table_row,0,check); //插入复选框 ui->flight_que_tableWidget->setItem(table_row, 1, new QTableWidgetItem(f_num)); ui->flight_que_tableWidget->setItem(table_row, 2, new QTableWidgetItem(f_price)); ui->flight_que_tableWidget->setItem(table_row, 3, new QTableWidgetItem(f_to_date)); ui->flight_que_tableWidget->setItem(table_row, 4, new QTableWidgetItem(f_ar_date)); ui->flight_que_tableWidget->setItem(table_row, 5, new QTableWidgetItem(f_to_time)); ui->flight_que_tableWidget->setItem(table_row, 6, new QTableWidgetItem(f_dis)); ui->flight_que_tableWidget->setItem(table_row, 7, new QTableWidgetItem(f_type)); ui->flight_que_tableWidget->setItem(table_row, 8, new QTableWidgetItem(f_take_city)); ui->flight_que_tableWidget->setItem(table_row, 9, new QTableWidgetItem(f_ar_city)); ui->flight_que_tableWidget->setItem(table_row, 10, new QTableWidgetItem(f_cro_city)); } } else { QMessageBox::about(NULL, "提示", "未查询到该日期相关航班信息!"); clear_flight_que_table(); } } } //订票功能 void UserWindow::on_ticket_book_pushButton_clicked() { QList<int> order_list; for(int i = 0; i < ui->flight_que_tableWidget->rowCount(); i++) { if(ui->flight_que_tableWidget->item(i, 0)->checkState()) { order_list << i; } } if(order_list.isEmpty()) { QMessageBox::about(NULL, "提示", "请选择要订票的航班!"); } for(int i = 0; i < order_list.length(); i++) { QDateTime local(QDateTime::currentDateTime()); QString localtime = local.toString("hh:mm:ss"); QString ordertime = local.toString("hhmmss"); QString localdate = local.toString("yyyyMMdd"); b_order_flight_num = ui->flight_que_tableWidget->item(order_list.at(i),1)->text().toUtf8(); b_order_flight_date = ui->flight_que_tableWidget->item(order_list.at(i),3)->text().toUtf8(); b_order_flight_time = ui->flight_que_tableWidget->item(order_list.at(i),5)->text().toUtf8(); b_order_flight_price = ui->flight_que_tableWidget->item(order_list.at(i),6)->text().toUtf8(); b_order_flight_to_city = ui->flight_que_tableWidget->item(order_list.at(i),8)->text().toUtf8(); b_order_flight_ar_city = ui->flight_que_tableWidget->item(order_list.at(i),9)->text().toUtf8(); b_order_name = user_name.toUtf8(); b_order_u_tel = user_tel.toUtf8(); b_order_pay_state = QString("未支付").toUtf8(); b_order_time = localtime.toUtf8(); b_order_num = (user_tel + localdate + ordertime).toUtf8(); f_order_flight_num = b_order_flight_num.data(); f_order_flight_price = b_order_flight_price.data(); f_order_flight_date = b_order_flight_date.data(); f_order_flight_time = b_order_flight_time.data(); f_order_flight_to_city = b_order_flight_to_city.data(); f_order_flight_ar_city = b_order_flight_ar_city.data(); f_order_name = b_order_name.data(); f_order_u_tel = b_order_u_tel.data(); f_order_pay_state = b_order_pay_state.data(); f_order_time = b_order_time.data(); f_order_num = b_order_num.data(); QString str = QString("insert into order_info(order_num, order_flight_num, order_u_tel, order_u_name, order_pay_state, order_flight_date, order_flight_time, order_flight_to_city, order_flight_ar_city, order_flight_price, order_time) \ values('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9', '%10', '%11')") \ .arg(f_order_num).arg(f_order_flight_num).arg(f_order_u_tel).arg(f_order_name).arg(f_order_pay_state) .arg(f_order_flight_date).arg(f_order_flight_time).arg(f_order_flight_to_city) .arg(f_order_flight_ar_city).arg(f_order_flight_price).arg(f_order_time); QSqlQuery query; if(query.exec(str)) { QMessageBox::about(NULL, "提示", QString("订单%1下单成功,可到订单中心查看订单!").arg(user_tel + localdate + ordertime)); ui->flight_que_tableWidget->item(i, 0)->setCheckState(Qt::Unchecked); } else { QMessageBox::about(NULL, "提示", "下单失败!"); } } } //按条件ch_查询始发城市_comboBox void UserWindow::on_ch_lev_city_comboBox_activated(const QString &arg1) { ui->lev_city_comboBox->clear(); if(arg1 == "热门") { ui->lev_city_comboBox->insertItem(0, "北京"); ui->lev_city_comboBox->insertItem(1, "上海"); ui->lev_city_comboBox->insertItem(2, "广州"); ui->lev_city_comboBox->insertItem(3, "深圳"); ui->lev_city_comboBox->insertItem(4, "成都"); ui->lev_city_comboBox->insertItem(5, "杭州"); ui->lev_city_comboBox->insertItem(6, "西安"); ui->lev_city_comboBox->insertItem(7, "重庆"); ui->lev_city_comboBox->insertItem(8, "青岛"); ui->lev_city_comboBox->insertItem(9, "南京"); ui->lev_city_comboBox->insertItem(10, "厦门"); ui->lev_city_comboBox->insertItem(11, "昆明"); ui->lev_city_comboBox->insertItem(12, "大连"); ui->lev_city_comboBox->insertItem(13, "天津"); ui->lev_city_comboBox->insertItem(14, "郑州"); ui->lev_city_comboBox->insertItem(15, "三亚"); ui->lev_city_comboBox->insertItem(16, "济南"); ui->lev_city_comboBox->insertItem(17, "福州"); } else if(arg1 == "ABCDE") { ui->lev_city_comboBox->insertItem(0, "阿尔山"); ui->lev_city_comboBox->insertItem(1, "阿克苏"); ui->lev_city_comboBox->insertItem(2, "阿拉善右旗"); ui->lev_city_comboBox->insertItem(3, "阿拉善左旗"); ui->lev_city_comboBox->insertItem(4, "阿勒泰"); ui->lev_city_comboBox->insertItem(5, "阿里"); ui->lev_city_comboBox->insertItem(6, "澳门"); ui->lev_city_comboBox->insertItem(7, "安庆"); ui->lev_city_comboBox->insertItem(8, "安顺"); ui->lev_city_comboBox->insertItem(9, "鞍山"); ui->lev_city_comboBox->insertItem(10, "巴彦淖尔"); ui->lev_city_comboBox->insertItem(11, "百色"); ui->lev_city_comboBox->insertItem(12, "包头"); ui->lev_city_comboBox->insertItem(13, "保山"); ui->lev_city_comboBox->insertItem(14, "北海"); ui->lev_city_comboBox->insertItem(15, "北京"); ui->lev_city_comboBox->insertItem(16, "白城"); ui->lev_city_comboBox->insertItem(17, "白山"); ui->lev_city_comboBox->insertItem(18, "毕节"); ui->lev_city_comboBox->insertItem(19, "博乐"); ui->lev_city_comboBox->insertItem(20, "重庆"); ui->lev_city_comboBox->insertItem(21, "昌都"); ui->lev_city_comboBox->insertItem(22, "常德"); ui->lev_city_comboBox->insertItem(23, "常州"); ui->lev_city_comboBox->insertItem(24, "朝阳"); ui->lev_city_comboBox->insertItem(25, "成都"); ui->lev_city_comboBox->insertItem(26, "池州"); ui->lev_city_comboBox->insertItem(27, "赤峰"); ui->lev_city_comboBox->insertItem(28, "揭阳"); ui->lev_city_comboBox->insertItem(29, "长春"); ui->lev_city_comboBox->insertItem(30, "长沙"); ui->lev_city_comboBox->insertItem(31, "长治"); ui->lev_city_comboBox->insertItem(32, "承德"); ui->lev_city_comboBox->insertItem(33, "沧源"); ui->lev_city_comboBox->insertItem(34, "达县"); ui->lev_city_comboBox->insertItem(35, "大理"); ui->lev_city_comboBox->insertItem(36, "大连"); ui->lev_city_comboBox->insertItem(37, "大庆"); ui->lev_city_comboBox->insertItem(38, "大同"); ui->lev_city_comboBox->insertItem(39, "丹东"); ui->lev_city_comboBox->insertItem(40, "稻城"); ui->lev_city_comboBox->insertItem(41, "东营"); ui->lev_city_comboBox->insertItem(42, "敦煌"); ui->lev_city_comboBox->insertItem(43, "芒市"); ui->lev_city_comboBox->insertItem(44, "额济纳旗"); ui->lev_city_comboBox->insertItem(45, "鄂尔多斯"); ui->lev_city_comboBox->insertItem(46, "恩施"); ui->lev_city_comboBox->insertItem(47, "二连浩特"); } else if(arg1 == "FGHIJ") { ui->lev_city_comboBox->insertItem(0, "佛山"); ui->lev_city_comboBox->insertItem(1, "福州"); ui->lev_city_comboBox->insertItem(2, "抚远"); ui->lev_city_comboBox->insertItem(3, "阜阳"); ui->lev_city_comboBox->insertItem(4, "赣州"); ui->lev_city_comboBox->insertItem(5, "格尔木"); ui->lev_city_comboBox->insertItem(6, "固原"); ui->lev_city_comboBox->insertItem(7, "广元"); ui->lev_city_comboBox->insertItem(8, "广州"); ui->lev_city_comboBox->insertItem(9, "贵阳"); ui->lev_city_comboBox->insertItem(10, "桂林"); ui->lev_city_comboBox->insertItem(11, "哈尔滨"); ui->lev_city_comboBox->insertItem(12, "哈密"); ui->lev_city_comboBox->insertItem(13, "海口"); ui->lev_city_comboBox->insertItem(14, "海拉尔"); ui->lev_city_comboBox->insertItem(15, "邯郸"); ui->lev_city_comboBox->insertItem(16, "汉中"); ui->lev_city_comboBox->insertItem(17, "杭州"); ui->lev_city_comboBox->insertItem(18, "合肥"); ui->lev_city_comboBox->insertItem(19, "和田"); ui->lev_city_comboBox->insertItem(20, "黑河"); ui->lev_city_comboBox->insertItem(21, "呼和浩特"); ui->lev_city_comboBox->insertItem(22, "淮安"); ui->lev_city_comboBox->insertItem(23, "怀化"); ui->lev_city_comboBox->insertItem(24, "黄山"); ui->lev_city_comboBox->insertItem(25, "惠州"); ui->lev_city_comboBox->insertItem(26, "鸡西"); ui->lev_city_comboBox->insertItem(27, "济南"); ui->lev_city_comboBox->insertItem(28, "济宁"); ui->lev_city_comboBox->insertItem(29, "加格达奇"); ui->lev_city_comboBox->insertItem(30, "佳木斯"); ui->lev_city_comboBox->insertItem(31, "嘉峪关"); ui->lev_city_comboBox->insertItem(32, "金昌"); ui->lev_city_comboBox->insertItem(33, "金门"); ui->lev_city_comboBox->insertItem(34, "锦州"); ui->lev_city_comboBox->insertItem(35, "嘉义"); ui->lev_city_comboBox->insertItem(36, "西双版纳"); ui->lev_city_comboBox->insertItem(37, "建三江"); ui->lev_city_comboBox->insertItem(38, "晋江"); ui->lev_city_comboBox->insertItem(39, "井冈山"); ui->lev_city_comboBox->insertItem(40, "景德镇"); ui->lev_city_comboBox->insertItem(41, "九江"); ui->lev_city_comboBox->insertItem(42, "九寨沟"); } else if(arg1 == "KLMNP") { ui->lev_city_comboBox->insertItem(0, "喀什"); ui->lev_city_comboBox->insertItem(1, "凯里"); ui->lev_city_comboBox->insertItem(2, "康定"); ui->lev_city_comboBox->insertItem(3, "克拉玛依"); ui->lev_city_comboBox->insertItem(4, "库车"); ui->lev_city_comboBox->insertItem(5, "库尔勒"); ui->lev_city_comboBox->insertItem(6, "昆明"); ui->lev_city_comboBox->insertItem(7, "拉萨"); ui->lev_city_comboBox->insertItem(8, "兰州"); ui->lev_city_comboBox->insertItem(9, "黎平"); ui->lev_city_comboBox->insertItem(10, "丽江"); ui->lev_city_comboBox->insertItem(11, "荔波"); ui->lev_city_comboBox->insertItem(12, "连云港"); ui->lev_city_comboBox->insertItem(13, "六盘水"); ui->lev_city_comboBox->insertItem(14, "临汾"); ui->lev_city_comboBox->insertItem(15, "林芝"); ui->lev_city_comboBox->insertItem(16, "临沧"); ui->lev_city_comboBox->insertItem(17, "临沂"); ui->lev_city_comboBox->insertItem(18, "柳州"); ui->lev_city_comboBox->insertItem(19, "泸州"); ui->lev_city_comboBox->insertItem(20, "洛阳"); ui->lev_city_comboBox->insertItem(21, "吕梁"); ui->lev_city_comboBox->insertItem(22, "澜沧"); ui->lev_city_comboBox->insertItem(23, "龙岩"); ui->lev_city_comboBox->insertItem(24, "满洲里"); ui->lev_city_comboBox->insertItem(25, "梅州"); ui->lev_city_comboBox->insertItem(26, "绵阳"); ui->lev_city_comboBox->insertItem(27, "漠河"); ui->lev_city_comboBox->insertItem(28, "牡丹江"); ui->lev_city_comboBox->insertItem(29, "马祖"); ui->lev_city_comboBox->insertItem(30, "南昌"); ui->lev_city_comboBox->insertItem(31, "南充"); ui->lev_city_comboBox->insertItem(32, "南京"); ui->lev_city_comboBox->insertItem(33, "南宁"); ui->lev_city_comboBox->insertItem(34, "南通"); ui->lev_city_comboBox->insertItem(35, "南阳"); ui->lev_city_comboBox->insertItem(36, "宁波"); ui->lev_city_comboBox->insertItem(37, "宁蒗"); ui->lev_city_comboBox->insertItem(38, "攀枝花"); ui->lev_city_comboBox->insertItem(39, "普洱"); } else if(arg1 == "QRSTUVW") { ui->lev_city_comboBox->insertItem(0, "齐齐哈尔"); ui->lev_city_comboBox->insertItem(1, "黔江"); ui->lev_city_comboBox->insertItem(2, "且末"); ui->lev_city_comboBox->insertItem(3, "秦皇岛"); ui->lev_city_comboBox->insertItem(4, "青岛"); ui->lev_city_comboBox->insertItem(5, "庆阳"); ui->lev_city_comboBox->insertItem(6, "衢州"); ui->lev_city_comboBox->insertItem(7, "日喀则"); ui->lev_city_comboBox->insertItem(8, "日照"); ui->lev_city_comboBox->insertItem(9, "三亚"); ui->lev_city_comboBox->insertItem(10, "厦门"); ui->lev_city_comboBox->insertItem(11, "上海"); ui->lev_city_comboBox->insertItem(12, "深圳"); ui->lev_city_comboBox->insertItem(13, "神农架"); ui->lev_city_comboBox->insertItem(14, "沈阳"); ui->lev_city_comboBox->insertItem(15, "石家庄"); ui->lev_city_comboBox->insertItem(16, "塔城"); ui->lev_city_comboBox->insertItem(17, "台州"); ui->lev_city_comboBox->insertItem(18, "太原"); ui->lev_city_comboBox->insertItem(19, "扬州"); ui->lev_city_comboBox->insertItem(20, "唐山"); ui->lev_city_comboBox->insertItem(21, "腾冲"); ui->lev_city_comboBox->insertItem(22, "天津"); ui->lev_city_comboBox->insertItem(23, "天水"); ui->lev_city_comboBox->insertItem(24, "通辽"); ui->lev_city_comboBox->insertItem(25, "铜仁"); ui->lev_city_comboBox->insertItem(26, "吐鲁番"); ui->lev_city_comboBox->insertItem(27, "万州"); ui->lev_city_comboBox->insertItem(28, "威海"); ui->lev_city_comboBox->insertItem(29, "潍坊"); ui->lev_city_comboBox->insertItem(30, "温州"); ui->lev_city_comboBox->insertItem(31, "文山"); ui->lev_city_comboBox->insertItem(32, "乌海"); ui->lev_city_comboBox->insertItem(33, "乌兰浩特"); ui->lev_city_comboBox->insertItem(34, "乌鲁木齐"); ui->lev_city_comboBox->insertItem(35, "无锡"); ui->lev_city_comboBox->insertItem(36, "梧州"); ui->lev_city_comboBox->insertItem(37, "武汉"); ui->lev_city_comboBox->insertItem(38, "武夷山"); } else if(arg1 == "XYZ") { ui->lev_city_comboBox->insertItem(0, "西安"); ui->lev_city_comboBox->insertItem(1, "西昌"); ui->lev_city_comboBox->insertItem(2, "西宁"); ui->lev_city_comboBox->insertItem(3, "锡林浩特"); ui->lev_city_comboBox->insertItem(4, "香格里拉"); ui->lev_city_comboBox->insertItem(5, "襄阳"); ui->lev_city_comboBox->insertItem(6, "兴义"); ui->lev_city_comboBox->insertItem(7, "徐州"); ui->lev_city_comboBox->insertItem(8, "香港"); ui->lev_city_comboBox->insertItem(9, "烟台"); ui->lev_city_comboBox->insertItem(10, "延安"); ui->lev_city_comboBox->insertItem(11, "延吉"); ui->lev_city_comboBox->insertItem(12, "盐城"); ui->lev_city_comboBox->insertItem(13, "伊春"); ui->lev_city_comboBox->insertItem(14, "伊宁"); ui->lev_city_comboBox->insertItem(15, "宜宾"); ui->lev_city_comboBox->insertItem(16, "宜昌"); ui->lev_city_comboBox->insertItem(17, "宜春"); ui->lev_city_comboBox->insertItem(18, "义乌"); ui->lev_city_comboBox->insertItem(19, "银川"); ui->lev_city_comboBox->insertItem(20, "永州"); ui->lev_city_comboBox->insertItem(21, "榆林"); ui->lev_city_comboBox->insertItem(22, "玉树"); ui->lev_city_comboBox->insertItem(23, "运城"); ui->lev_city_comboBox->insertItem(24, "湛江"); ui->lev_city_comboBox->insertItem(25, "张家界"); ui->lev_city_comboBox->insertItem(26, "张家口"); ui->lev_city_comboBox->insertItem(27, "张掖"); ui->lev_city_comboBox->insertItem(28, "昭通"); ui->lev_city_comboBox->insertItem(29, "郑州"); ui->lev_city_comboBox->insertItem(30, "中卫"); ui->lev_city_comboBox->insertItem(31, "舟山"); ui->lev_city_comboBox->insertItem(32, "珠海"); ui->lev_city_comboBox->insertItem(33, "遵义"); } } //按条件ch_查询目的城市_comboBox void UserWindow::on_ch_des_city_comboBox_activated(const QString &arg1) { ui->des_city_comboBox->clear(); if(arg1 == "热门") { ui->des_city_comboBox->insertItem(0, "北京"); ui->des_city_comboBox->insertItem(1, "上海"); ui->des_city_comboBox->insertItem(2, "广州"); ui->des_city_comboBox->insertItem(3, "深圳"); ui->des_city_comboBox->insertItem(4, "成都"); ui->des_city_comboBox->insertItem(5, "杭州"); ui->des_city_comboBox->insertItem(6, "西安"); ui->des_city_comboBox->insertItem(7, "重庆"); ui->des_city_comboBox->insertItem(8, "青岛"); ui->des_city_comboBox->insertItem(9, "南京"); ui->des_city_comboBox->insertItem(10, "厦门"); ui->des_city_comboBox->insertItem(11, "昆明"); ui->des_city_comboBox->insertItem(12, "大连"); ui->des_city_comboBox->insertItem(13, "天津"); ui->des_city_comboBox->insertItem(14, "郑州"); ui->des_city_comboBox->insertItem(15, "三亚"); ui->des_city_comboBox->insertItem(16, "济南"); ui->des_city_comboBox->insertItem(17, "福州"); } else if(arg1 == "ABCDE") { ui->des_city_comboBox->insertItem(0, "阿尔山"); ui->des_city_comboBox->insertItem(1, "阿克苏"); ui->des_city_comboBox->insertItem(2, "阿拉善右旗"); ui->des_city_comboBox->insertItem(3, "阿拉善左旗"); ui->des_city_comboBox->insertItem(4, "阿勒泰"); ui->des_city_comboBox->insertItem(5, "阿里"); ui->des_city_comboBox->insertItem(6, "澳门"); ui->des_city_comboBox->insertItem(7, "安庆"); ui->des_city_comboBox->insertItem(8, "安顺"); ui->des_city_comboBox->insertItem(9, "鞍山"); ui->des_city_comboBox->insertItem(10, "巴彦淖尔"); ui->des_city_comboBox->insertItem(11, "百色"); ui->des_city_comboBox->insertItem(12, "包头"); ui->des_city_comboBox->insertItem(13, "保山"); ui->des_city_comboBox->insertItem(14, "北海"); ui->des_city_comboBox->insertItem(15, "北京"); ui->des_city_comboBox->insertItem(16, "白城"); ui->des_city_comboBox->insertItem(17, "白山"); ui->des_city_comboBox->insertItem(18, "毕节"); ui->des_city_comboBox->insertItem(19, "博乐"); ui->des_city_comboBox->insertItem(20, "重庆"); ui->des_city_comboBox->insertItem(21, "昌都"); ui->des_city_comboBox->insertItem(22, "常德"); ui->des_city_comboBox->insertItem(23, "常州"); ui->des_city_comboBox->insertItem(24, "朝阳"); ui->des_city_comboBox->insertItem(25, "成都"); ui->des_city_comboBox->insertItem(26, "池州"); ui->des_city_comboBox->insertItem(27, "赤峰"); ui->des_city_comboBox->insertItem(28, "揭阳"); ui->des_city_comboBox->insertItem(29, "长春"); ui->des_city_comboBox->insertItem(30, "长沙"); ui->des_city_comboBox->insertItem(31, "长治"); ui->des_city_comboBox->insertItem(32, "承德"); ui->des_city_comboBox->insertItem(33, "沧源"); ui->des_city_comboBox->insertItem(34, "达县"); ui->des_city_comboBox->insertItem(35, "大理"); ui->des_city_comboBox->insertItem(36, "大连"); ui->des_city_comboBox->insertItem(37, "大庆"); ui->des_city_comboBox->insertItem(38, "大同"); ui->des_city_comboBox->insertItem(39, "丹东"); ui->des_city_comboBox->insertItem(40, "稻城"); ui->des_city_comboBox->insertItem(41, "东营"); ui->des_city_comboBox->insertItem(42, "敦煌"); ui->des_city_comboBox->insertItem(43, "芒市"); ui->des_city_comboBox->insertItem(44, "额济纳旗"); ui->des_city_comboBox->insertItem(45, "鄂尔多斯"); ui->des_city_comboBox->insertItem(46, "恩施"); ui->des_city_comboBox->insertItem(47, "二连浩特"); } else if(arg1 == "FGHIJ") { ui->des_city_comboBox->insertItem(0, "佛山"); ui->des_city_comboBox->insertItem(1, "福州"); ui->des_city_comboBox->insertItem(2, "抚远"); ui->des_city_comboBox->insertItem(3, "阜阳"); ui->des_city_comboBox->insertItem(4, "赣州"); ui->des_city_comboBox->insertItem(5, "格尔木"); ui->des_city_comboBox->insertItem(6, "固原"); ui->des_city_comboBox->insertItem(7, "广元"); ui->des_city_comboBox->insertItem(8, "广州"); ui->des_city_comboBox->insertItem(9, "贵阳"); ui->des_city_comboBox->insertItem(10, "桂林"); ui->des_city_comboBox->insertItem(11, "哈尔滨"); ui->des_city_comboBox->insertItem(12, "哈密"); ui->des_city_comboBox->insertItem(13, "海口"); ui->des_city_comboBox->insertItem(14, "海拉尔"); ui->des_city_comboBox->insertItem(15, "邯郸"); ui->des_city_comboBox->insertItem(16, "汉中"); ui->des_city_comboBox->insertItem(17, "杭州"); ui->des_city_comboBox->insertItem(18, "合肥"); ui->des_city_comboBox->insertItem(19, "和田"); ui->des_city_comboBox->insertItem(20, "黑河"); ui->des_city_comboBox->insertItem(21, "呼和浩特"); ui->des_city_comboBox->insertItem(22, "淮安"); ui->des_city_comboBox->insertItem(23, "怀化"); ui->des_city_comboBox->insertItem(24, "黄山"); ui->des_city_comboBox->insertItem(25, "惠州"); ui->des_city_comboBox->insertItem(26, "鸡西"); ui->des_city_comboBox->insertItem(27, "济南"); ui->des_city_comboBox->insertItem(28, "济宁"); ui->des_city_comboBox->insertItem(29, "加格达奇"); ui->des_city_comboBox->insertItem(30, "佳木斯"); ui->des_city_comboBox->insertItem(31, "嘉峪关"); ui->des_city_comboBox->insertItem(32, "金昌"); ui->des_city_comboBox->insertItem(33, "金门"); ui->des_city_comboBox->insertItem(34, "锦州"); ui->des_city_comboBox->insertItem(35, "嘉义"); ui->des_city_comboBox->insertItem(36, "西双版纳"); ui->des_city_comboBox->insertItem(37, "建三江"); ui->des_city_comboBox->insertItem(38, "晋江"); ui->des_city_comboBox->insertItem(39, "井冈山"); ui->des_city_comboBox->insertItem(40, "景德镇"); ui->des_city_comboBox->insertItem(41, "九江"); ui->des_city_comboBox->insertItem(42, "九寨沟"); } else if(arg1 == "KLMNP") { ui->des_city_comboBox->insertItem(0, "喀什"); ui->des_city_comboBox->insertItem(1, "凯里"); ui->des_city_comboBox->insertItem(2, "康定"); ui->des_city_comboBox->insertItem(3, "克拉玛依"); ui->des_city_comboBox->insertItem(4, "库车"); ui->des_city_comboBox->insertItem(5, "库尔勒"); ui->des_city_comboBox->insertItem(6, "昆明"); ui->des_city_comboBox->insertItem(7, "拉萨"); ui->des_city_comboBox->insertItem(8, "兰州"); ui->des_city_comboBox->insertItem(9, "黎平"); ui->des_city_comboBox->insertItem(10, "丽江"); ui->des_city_comboBox->insertItem(11, "荔波"); ui->des_city_comboBox->insertItem(12, "连云港"); ui->des_city_comboBox->insertItem(13, "六盘水"); ui->des_city_comboBox->insertItem(14, "临汾"); ui->des_city_comboBox->insertItem(15, "林芝"); ui->des_city_comboBox->insertItem(16, "临沧"); ui->des_city_comboBox->insertItem(17, "临沂"); ui->des_city_comboBox->insertItem(18, "柳州"); ui->des_city_comboBox->insertItem(19, "泸州"); ui->des_city_comboBox->insertItem(20, "洛阳"); ui->des_city_comboBox->insertItem(21, "吕梁"); ui->des_city_comboBox->insertItem(22, "澜沧"); ui->des_city_comboBox->insertItem(23, "龙岩"); ui->des_city_comboBox->insertItem(24, "满洲里"); ui->des_city_comboBox->insertItem(25, "梅州"); ui->des_city_comboBox->insertItem(26, "绵阳"); ui->des_city_comboBox->insertItem(27, "漠河"); ui->des_city_comboBox->insertItem(28, "牡丹江"); ui->des_city_comboBox->insertItem(29, "马祖"); ui->des_city_comboBox->insertItem(30, "南昌"); ui->des_city_comboBox->insertItem(31, "南充"); ui->des_city_comboBox->insertItem(32, "南京"); ui->des_city_comboBox->insertItem(33, "南宁"); ui->des_city_comboBox->insertItem(34, "南通"); ui->des_city_comboBox->insertItem(35, "南阳"); ui->des_city_comboBox->insertItem(36, "宁波"); ui->des_city_comboBox->insertItem(37, "宁蒗"); ui->des_city_comboBox->insertItem(38, "攀枝花"); ui->des_city_comboBox->insertItem(39, "普洱"); } else if(arg1 == "QRSTUVW") { ui->des_city_comboBox->insertItem(0, "齐齐哈尔"); ui->des_city_comboBox->insertItem(1, "黔江"); ui->des_city_comboBox->insertItem(2, "且末"); ui->des_city_comboBox->insertItem(3, "秦皇岛"); ui->des_city_comboBox->insertItem(4, "青岛"); ui->des_city_comboBox->insertItem(5, "庆阳"); ui->des_city_comboBox->insertItem(6, "衢州"); ui->des_city_comboBox->insertItem(7, "日喀则"); ui->des_city_comboBox->insertItem(8, "日照"); ui->des_city_comboBox->insertItem(9, "三亚"); ui->des_city_comboBox->insertItem(10, "厦门"); ui->des_city_comboBox->insertItem(11, "上海"); ui->des_city_comboBox->insertItem(12, "深圳"); ui->des_city_comboBox->insertItem(13, "神农架"); ui->des_city_comboBox->insertItem(14, "沈阳"); ui->des_city_comboBox->insertItem(15, "石家庄"); ui->des_city_comboBox->insertItem(16, "塔城"); ui->des_city_comboBox->insertItem(17, "台州"); ui->des_city_comboBox->insertItem(18, "太原"); ui->des_city_comboBox->insertItem(19, "扬州"); ui->des_city_comboBox->insertItem(20, "唐山"); ui->des_city_comboBox->insertItem(21, "腾冲"); ui->des_city_comboBox->insertItem(22, "天津"); ui->des_city_comboBox->insertItem(23, "天水"); ui->des_city_comboBox->insertItem(24, "通辽"); ui->des_city_comboBox->insertItem(25, "铜仁"); ui->des_city_comboBox->insertItem(26, "吐鲁番"); ui->des_city_comboBox->insertItem(27, "万州"); ui->des_city_comboBox->insertItem(28, "威海"); ui->des_city_comboBox->insertItem(29, "潍坊"); ui->des_city_comboBox->insertItem(30, "温州"); ui->des_city_comboBox->insertItem(31, "文山"); ui->des_city_comboBox->insertItem(32, "乌海"); ui->des_city_comboBox->insertItem(33, "乌兰浩特"); ui->des_city_comboBox->insertItem(34, "乌鲁木齐"); ui->des_city_comboBox->insertItem(35, "无锡"); ui->des_city_comboBox->insertItem(36, "梧州"); ui->des_city_comboBox->insertItem(37, "武汉"); ui->des_city_comboBox->insertItem(38, "武夷山"); } else if(arg1 == "XYZ") { ui->des_city_comboBox->insertItem(0, "西安"); ui->des_city_comboBox->insertItem(1, "西昌"); ui->des_city_comboBox->insertItem(2, "西宁"); ui->des_city_comboBox->insertItem(3, "锡林浩特"); ui->des_city_comboBox->insertItem(4, "香格里拉"); ui->des_city_comboBox->insertItem(5, "襄阳"); ui->des_city_comboBox->insertItem(6, "兴义"); ui->des_city_comboBox->insertItem(7, "徐州"); ui->des_city_comboBox->insertItem(8, "香港"); ui->des_city_comboBox->insertItem(9, "烟台"); ui->des_city_comboBox->insertItem(10, "延安"); ui->des_city_comboBox->insertItem(11, "延吉"); ui->des_city_comboBox->insertItem(12, "盐城"); ui->des_city_comboBox->insertItem(13, "伊春"); ui->des_city_comboBox->insertItem(14, "伊宁"); ui->des_city_comboBox->insertItem(15, "宜宾"); ui->des_city_comboBox->insertItem(16, "宜昌"); ui->des_city_comboBox->insertItem(17, "宜春"); ui->des_city_comboBox->insertItem(18, "义乌"); ui->des_city_comboBox->insertItem(19, "银川"); ui->des_city_comboBox->insertItem(20, "永州"); ui->des_city_comboBox->insertItem(21, "榆林"); ui->des_city_comboBox->insertItem(22, "玉树"); ui->des_city_comboBox->insertItem(23, "运城"); ui->des_city_comboBox->insertItem(24, "湛江"); ui->des_city_comboBox->insertItem(25, "张家界"); ui->des_city_comboBox->insertItem(26, "张家口"); ui->des_city_comboBox->insertItem(27, "张掖"); ui->des_city_comboBox->insertItem(28, "昭通"); ui->des_city_comboBox->insertItem(29, "郑州"); ui->des_city_comboBox->insertItem(30, "中卫"); ui->des_city_comboBox->insertItem(31, "舟山"); ui->des_city_comboBox->insertItem(32, "珠海"); ui->lev_city_comboBox->insertItem(33, "遵义"); } } /****************************************************************************************航班查询及下单功能****************************************************************************/ /*******************************************************************************************订单中心功能******************************************************************************/ //订单中心显示 void UserWindow::order_cen_show() { clear_order_cen_table(); //ui->order_cen_tableWidget->horizontalHeader()->setStretchLastSection(true); //使行列头自适应宽度,最后一列将会填充空白部分 //ui->order_cen_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //使行列头自适应宽度,所有列平均分来填充空白部分 ui->order_cen_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->order_cen_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置每行内容不可编辑 ui->order_cen_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); //设置选择行为,以行为单位 QSqlTableModel order_cen_model; order_cen_model.setTable("order_info"); order_cen_model.setFilter(tr("order_u_name = '%1'").arg(user_name)); order_cen_model.select(); int rowcount = order_cen_model.rowCount(); if(order_cen_model.rowCount() >= 1) { for(int i = 0 ; i < rowcount; i++) { order_num = order_cen_model.data(order_cen_model.index(i, 0)).toString(); order_flight_num = order_cen_model.data(order_cen_model.index(i, 1)).toString(); order_u_tel = order_cen_model.data(order_cen_model.index(i, 2)).toString(); order_u_name = order_cen_model.data(order_cen_model.index(i, 3)).toString(); order_pay_state = order_cen_model.data(order_cen_model.index(i, 4)).toString(); order_flight_date = order_cen_model.data(order_cen_model.index(i, 5)).toString(); order_flight_time = order_cen_model.data(order_cen_model.index(i, 6)).toString(); order_flight_to_city = order_cen_model.data(order_cen_model.index(i, 7)).toString(); order_flight_ar_city = order_cen_model.data(order_cen_model.index(i, 8)).toString(); order_flight_price = order_cen_model.data(order_cen_model.index(i, 9)).toString(); order_time = order_cen_model.data(order_cen_model.index(i, 10)).toString(); order_pay_time = order_cen_model.data(order_cen_model.index(i, 11)).toString(); int table_row = ui->order_cen_tableWidget->rowCount(); ui->order_cen_tableWidget->insertRow(table_row); QTableWidgetItem *check = new QTableWidgetItem(); check->setCheckState(Qt::Unchecked); ui->order_cen_tableWidget->setItem(table_row,0,check); //插入复选框 ui->order_cen_tableWidget->setItem(table_row, 1, new QTableWidgetItem(order_num)); ui->order_cen_tableWidget->setItem(table_row, 2, new QTableWidgetItem(order_flight_num)); ui->order_cen_tableWidget->setItem(table_row, 3, new QTableWidgetItem(order_u_tel)); ui->order_cen_tableWidget->setItem(table_row, 4, new QTableWidgetItem(order_u_name)); ui->order_cen_tableWidget->setItem(table_row, 5, new QTableWidgetItem(order_pay_state)); ui->order_cen_tableWidget->setItem(table_row, 6, new QTableWidgetItem(order_flight_date)); ui->order_cen_tableWidget->setItem(table_row, 7, new QTableWidgetItem(order_flight_time)); ui->order_cen_tableWidget->setItem(table_row, 8, new QTableWidgetItem(order_flight_to_city)); ui->order_cen_tableWidget->setItem(table_row, 9, new QTableWidgetItem(order_flight_ar_city)); ui->order_cen_tableWidget->setItem(table_row, 10, new QTableWidgetItem(order_flight_price)); ui->order_cen_tableWidget->setItem(table_row, 11, new QTableWidgetItem(order_time)); ui->order_cen_tableWidget->setItem(table_row, 12, new QTableWidgetItem(order_pay_time)); } } else { QMessageBox::about(NULL, "提示", "未查询到您的相关订单!"); } } //订单支付 void UserWindow::on_order_pay_pushButton_clicked() { QList<int> pay_list; for(int i = 0; i < ui->order_cen_tableWidget->rowCount(); i++) { if(ui->order_cen_tableWidget->item(i, 0)->checkState()) { pay_list << i; } } if(pay_list.isEmpty()) { QMessageBox::about(NULL, "提示", "请选择需要支付的订单!"); } else { QMessageBox::StandardButton reply = QMessageBox::question(this, "提示", "确认支付该订单吗?", QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { for(int i = 0; i < pay_list.length(); i++) { b_order_num = ui->order_cen_tableWidget->item(pay_list.at(i), 1)->text().toUtf8(); order_num = b_order_num.data(); QSqlTableModel order_info_model; order_info_model.setTable("order_info"); order_info_model.setFilter(tr("order_num = '%1'").arg(ui->order_cen_tableWidget->item(pay_list.at(i), 1)->text())); order_info_model.select(); int rowcount = order_info_model.rowCount(); if( rowcount == 1) { QString pay_state = order_info_model.data(order_info_model.index(0, 4)).toString(); //检查该订单号是否已支付 if(pay_state == "未支付") { QDateTime local(QDateTime::currentDateTime()); order_pay_time = local.toString("hh:mm:ss"); QString localdate = local.toString("yyyyMMdd"); QString eletime = local.toString("hhmmss"); b_order_pay = QString("已支付").toUtf8(); order_pay = b_order_pay.data(); b_e_ticket_num = (ui->order_cen_tableWidget->item(pay_list.at(i),2)->text() + localdate + eletime).toUtf8(); b_e_order_num = ui->order_cen_tableWidget->item(pay_list.at(i),1)->text().toUtf8(); b_e_ticket_u_name = ui->order_cen_tableWidget->item(pay_list.at(i),4)->text().toUtf8(); b_e_flight_num = ui->order_cen_tableWidget->item(pay_list.at(i),2)->text().toUtf8(); b_e_flight_to_city = ui->order_cen_tableWidget->item(pay_list.at(i),8)->text().toUtf8(); b_e_flight_ar_city = ui->order_cen_tableWidget->item(pay_list.at(i),9)->text().toUtf8(); b_e_flight_date = ui->order_cen_tableWidget->item(pay_list.at(i),6)->text().toUtf8(); b_e_flight_time = ui->order_cen_tableWidget->item(pay_list.at(i),7)->text().toUtf8(); b_e_flight_price = ui->order_cen_tableWidget->item(pay_list.at(i),10)->text().toUtf8(); b_order_pay_time = order_pay_time.toUtf8(); e_ticket_num = b_e_ticket_num.data(); e_order_num = b_e_order_num.data(); e_ticket_u_name = b_e_ticket_u_name.data(); e_flight_num = b_e_flight_num.data(); e_flight_to_city = b_e_flight_to_city.data(); e_flight_ar_city = b_e_flight_ar_city.data(); e_flight_date = b_e_flight_date.data(); e_flight_time = b_e_flight_time.data(); e_flight_price = b_e_flight_price.data(); order_pay_time = b_order_pay_time.data(); QString pay_str = QString("update order_info set order_pay_state='%1', order_pay_time='%2' where order_num='%3'").arg(order_pay).arg(order_pay_time).arg(order_num); QString ele_str = QString("insert into ele_ticket(e_ticket_num, e_order_num, e_ticket_u_name, e_flight_num, e_filght_to_city, e_flight_ar_city, e_flight_date, e_flight_to_time, e_flight_price) \ values('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9')") .arg(e_ticket_num).arg(e_order_num).arg(e_ticket_u_name).arg(e_flight_num).arg(e_flight_to_city) .arg(e_flight_ar_city).arg(e_flight_date).arg(e_flight_time).arg(e_flight_price); QSqlQuery pay_query; QSqlQuery ele_query; if(pay_query.exec(pay_str) && ele_query.exec(ele_str)) { QMessageBox::about(NULL, "提示", QString("您的订单%1支付成功!").arg(ui->order_cen_tableWidget->item(pay_list.at(i), 1)->text())); order_cen_show(); } else { QMessageBox::about(NULL, "提示", "支付失败!"); order_cen_show(); } } else { QMessageBox::about(NULL, "提示", QString("您的订单号%1已支付!").arg(ui->order_cen_tableWidget->item(pay_list.at(i), 1)->text())); order_cen_show(); } } } } if (reply == QMessageBox::No) { QMessageBox::about(NULL, "提示", "您已取消订单支付!"); order_cen_show(); } } } //订单退单 void UserWindow::on_order_back_pushButton_clicked() { QList<int> orderback_list; for(int i = 0; i < ui->order_cen_tableWidget->rowCount(); i++) { if(ui->order_cen_tableWidget->item(i, 0)->checkState()) { orderback_list << i; } } if(orderback_list.isEmpty()) { QMessageBox::about(NULL, "提示", "请选择需要退订的订单!"); } else { QMessageBox::StandardButton reply = QMessageBox::question(this, "提示", "确认退订该订单?", QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { for(int i = 0; i < orderback_list.length(); i++) { QSqlTableModel order_info_model; order_info_model.setTable("order_info"); order_info_model.setFilter(tr("order_num = '%1'").arg(ui->order_cen_tableWidget->item(orderback_list.at(i), 1)->text())); order_info_model.select(); int rowcount = order_info_model.rowCount(); if( rowcount == 1) { QString pay_state = order_info_model.data(order_info_model.index(0, 4)).toString(); //检查该订单号是否已支付 if(pay_state == "已支付") { b_orderback_pay = QString("未支付").toUtf8(); b_orderback_time = QString("").toUtf8(); orderback_pay = b_orderback_pay.data(); orderback_time = b_orderback_time.data(); b_order_num = ui->order_cen_tableWidget->item(orderback_list.at(i), 1)->text().toUtf8(); order_num = b_order_num.data(); QString payback_str = QString("update order_info set order_pay_state='%1', order_pay_time='%2' where order_num='%3'").arg(orderback_pay).arg(orderback_time).arg(order_num); QString eleback_str = QString("delete from ele_ticket where e_order_num='%1'").arg(order_num); QSqlQuery payback_query; QSqlQuery eleback_query; if(payback_query.exec(payback_str) && eleback_query.exec(eleback_str)) { QMessageBox::about(NULL, "提示", QString("您的订单%1退订成功!").arg(ui->order_cen_tableWidget->item(orderback_list.at(i), 1)->text())); order_cen_show(); } else { QMessageBox::about(NULL, "提示", "订单退订失败!"); order_cen_show(); } } else { QMessageBox::about(NULL, "提示", QString("您的订单号%1未支付!").arg(ui->order_cen_tableWidget->item(orderback_list.at(i), 1)->text())); order_cen_show(); } } } } if (reply == QMessageBox::No) { QMessageBox::about(NULL, "提示", "您已取消退订订单!"); order_cen_show(); } } } //订单删除功能 void UserWindow::on_order_del_pushButton_clicked() { QList<int> orderback_list; for(int i = 0; i < ui->order_cen_tableWidget->rowCount(); i++) { if(ui->order_cen_tableWidget->item(i, 0)->checkState()) { orderback_list << i; } } if(orderback_list.isEmpty()) { QMessageBox::about(NULL, "提示", "请选择需要退订的订单!"); } else { QMessageBox::StandardButton reply = QMessageBox::question(this, "提示", "确认删除该订单?", QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { for(int i = 0; i < orderback_list.length(); i++) { QSqlTableModel order_info_model; order_info_model.setTable("order_info"); order_info_model.setFilter(tr("order_num = '%1'").arg(ui->order_cen_tableWidget->item(orderback_list.at(i), 1)->text())); order_info_model.select(); int rowcount = order_info_model.rowCount(); if( rowcount == 1) { QString pay_state = order_info_model.data(order_info_model.index(0, 4)).toString(); //检查该订单号是否已支付 if(pay_state == "未支付") { b_order_num = ui->order_cen_tableWidget->item(orderback_list.at(i), 1)->text().toUtf8(); order_num = b_order_num.data(); QString str = QString("delete from order_info where order_num='%1'").arg(order_num); QSqlQuery query; if(query.exec(str)) { QMessageBox::about(NULL, "提示", QString("您的订单%1删除成功!").arg(ui->order_cen_tableWidget->item(orderback_list.at(i), 1)->text())); order_cen_show(); } else { QMessageBox::about(NULL, "提示", "订单删除失败!"); order_cen_show(); } } else { QMessageBox::about(NULL, "提示", QString("您的订单号%1已支付,无法删除,请先退订订单!").arg(ui->order_cen_tableWidget->item(orderback_list.at(i), 1)->text())); order_cen_show(); } } } } if (reply == QMessageBox::No) { QMessageBox::about(NULL, "提示", "您已取消删除订单!"); order_cen_show(); } } } /*******************************************************************************************订单中心功能******************************************************************************/ /*******************************************************************************************个人中心功能******************************************************************************/ void UserWindow::my_home_show() { clear_my_home_table(); //ui->order_cen_tableWidget->horizontalHeader()->setStretchLastSection(true); //使行列头自适应宽度,最后一列将会填充空白部分 //ui->order_cen_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //使行列头自适应宽度,所有列平均分来填充空白部分 ui->my_home_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->my_home_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置每行内容不可编辑 ui->my_home_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); //设置选择行为,以行为单位 QSqlTableModel my_home_model; my_home_model.setTable("ele_ticket"); my_home_model.setFilter(tr("e_ticket_u_name = '%1'").arg(user_name)); my_home_model.select(); int rowcount = my_home_model.rowCount(); if(my_home_model.rowCount() >= 1) { for(int i = 0 ; i < rowcount; i++) { home_ticket_num = my_home_model.data(my_home_model.index(i, 0)).toString(); home_u_name = my_home_model.data(my_home_model.index(i, 2)).toString(); home_flight_num_ = my_home_model.data(my_home_model.index(i, 3)).toString(); home_to_city = my_home_model.data(my_home_model.index(i, 4)).toString(); home_ar_city = my_home_model.data(my_home_model.index(i, 5)).toString(); home_to_date = my_home_model.data(my_home_model.index(i, 6)).toString(); home_to_time = my_home_model.data(my_home_model.index(i, 7)).toString(); home_flight_price = my_home_model.data(my_home_model.index(i, 8)).toString(); int table_row = ui->my_home_tableWidget->rowCount(); ui->my_home_tableWidget->insertRow(table_row); ui->my_home_tableWidget->setItem(table_row, 0, new QTableWidgetItem(home_ticket_num)); ui->my_home_tableWidget->setItem(table_row, 1, new QTableWidgetItem(home_u_name)); ui->my_home_tableWidget->setItem(table_row, 2, new QTableWidgetItem(home_flight_num_)); ui->my_home_tableWidget->setItem(table_row, 3, new QTableWidgetItem(home_to_city)); ui->my_home_tableWidget->setItem(table_row, 4, new QTableWidgetItem(home_ar_city)); ui->my_home_tableWidget->setItem(table_row, 5, new QTableWidgetItem(home_to_date)); ui->my_home_tableWidget->setItem(table_row, 6, new QTableWidgetItem(home_to_time)); ui->my_home_tableWidget->setItem(table_row, 7, new QTableWidgetItem(home_flight_price)); } } else { QMessageBox::about(NULL, "提示", "未查询到您的相关机票信息!"); } } /*******************************************************************************************个人中心功能******************************************************************************/
[ "46366996+tuto123@users.noreply.github.com" ]
46366996+tuto123@users.noreply.github.com
eafe74d78c042fba5c12cfc0b9a96bc1352288ef
dea178f52fed5236874ee1c11f1c969e5ffada74
/Libooxml/trunk/Libooxml/dml-main/CT_GvmlGraphicFrameNonVisual.cpp
1125da01952f160187f62121471ce0c00ad73a2d
[]
no_license
andrew2015/ooxmlpp
411d1d43b35b82ee00d371ad0e3eeda0278a52b9
3bf26fe79d8932d873bbb3595ba1e5de20017cee
refs/heads/master
2021-06-16T16:24:39.555456
2012-10-01T20:29:21
2012-10-01T20:29:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,539
cpp
#include <xercesc/parsers/XercesDOMParser.hpp> #include <xercesc/dom/DOM.hpp> #include <dml-main.h> using namespace drawingml::main; CT_GvmlGraphicFrameNonVisual::CT_GvmlGraphicFrameNonVisual(std::shared_ptr<CT_NonVisualDrawingProps> &_cNvPr,std::shared_ptr<CT_NonVisualGraphicFrameProperties> &_cNvGraphicFramePr) { cNvPr = _cNvPr; cNvGraphicFramePr = _cNvGraphicFramePr; } CT_GvmlGraphicFrameNonVisual::CT_GvmlGraphicFrameNonVisual(CT_GvmlGraphicFrameNonVisual &b) { cNvPr = b.cNvPr; cNvGraphicFramePr = b.cNvGraphicFramePr; } CT_GvmlGraphicFrameNonVisual::CT_GvmlGraphicFrameNonVisual(xercesc_3_1::DOMNodeList *nodelist, xercesc_3_1::DOMNamedNodeMap *attributes) { cNvPr = NULL; cNvGraphicFramePr = NULL; for (int i = 0; i < nodelist->getLength();++i) { if (wcscmp(nodelist->item(i)->getLocalName(),L"cNvPr") == 0) { cNvPr.reset(new CT_NonVisualDrawingProps(nodelist->item(i)->getChildNodes(),nodelist->item(i)->getAttributes())); } if (wcscmp(nodelist->item(i)->getLocalName(),L"cNvGraphicFramePr") == 0) { cNvGraphicFramePr.reset(new CT_NonVisualGraphicFrameProperties(nodelist->item(i)->getChildNodes(),nodelist->item(i)->getAttributes())); } } } CT_GvmlGraphicFrameNonVisual& CT_GvmlGraphicFrameNonVisual::operator=(CT_GvmlGraphicFrameNonVisual &b) { cNvPr = b.cNvPr; cNvGraphicFramePr = b.cNvGraphicFramePr; return *this; } CT_GvmlGraphicFrameNonVisual::~CT_GvmlGraphicFrameNonVisual() { } std::wstring CT_GvmlGraphicFrameNonVisual::Xml() { return L""; }
[ "SND\\Chris25_cp@6d081351-a130-4f95-a3e6-486afb32637a" ]
SND\Chris25_cp@6d081351-a130-4f95-a3e6-486afb32637a
f5fb9144ce0e6db51a625e8a6635fe571278cb66
c90a56e7d7752b041fc5eb38257c5573cef346c6
/src-macOS/TopTrans_tmpl.hxx
49bd20d16af1eaa7e06ad0315ec7e5b9be87fbe4
[]
no_license
random-builder/design_cadquery_ocp
a4c572a72699bad52ca5f43f30bb7c15d89072ff
2af799a9f1b2d81fd39e519b2f73e12b34a14c0a
refs/heads/master
2021-05-21T23:10:23.833461
2020-03-29T15:34:46
2020-03-29T15:34:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
622
hxx
#pragma once // pybind 11 related includes #include <pybind11/pybind11.h> #include <pybind11/stl.h> namespace py = pybind11; // Standard Handle #include <Standard_Handle.hxx> // includes to resolve forward declarations // module includes #include <TopTrans_Array2OfOrientation.hxx> #include <TopTrans_SurfaceTransition.hxx> #include <TopTrans_CurveTransition.hxx> // user-defined pre #include "OCP_specific.inc" // Class template handling functions // ./opencascade/TopTrans_Array2OfOrientation.hxx // ./opencascade/TopTrans_SurfaceTransition.hxx // ./opencascade/TopTrans_CurveTransition.hxx // user-defined post
[ "adam.jan.urbanczyk@gmail.com" ]
adam.jan.urbanczyk@gmail.com
f9ae6cfb09db111839ca9163462bb6e7c1f59d7a
9f1d6f8fe07b1e4e70a58075541ebe2bd834dfbc
/Project 2/Project 2 Text Files/Passenger.cpp
dff2b9c5bbd566fef38091435d8da08d939478c6
[]
no_license
jsharris1999/Programming-Foundations-2-Project-2
b589409315dd6a5593a09b3fe86661972588e2e7
23f610d2b43af6d67365537d8cccbfe68b47c52e
refs/heads/master
2020-06-04T22:57:52.403939
2019-06-16T18:29:46
2019-06-16T18:29:46
192,223,829
0
0
null
null
null
null
UTF-8
C++
false
false
969
cpp
#include <string> #include <iostream> #include <cmath> #include "Passenger.h" using namespace std; Passenger::Passenger() { FirstName = "N/A"; LastName = "N/A"; Next = NULL; } Passenger::Passenger(string firstname, string lastname) { FirstName = firstname; LastName = lastname; Next = NULL; } Passenger::Passenger(const Passenger& orig) { FirstName = orig.FirstName; LastName = orig.LastName; Next = orig.Next; } Passenger::~Passenger() { } string Passenger::getFirstName() { return FirstName; } string Passenger::getLastName() { return LastName; } Passenger* Passenger::getNext() { return Next; } void Passenger::setFirstName(string firstname) { FirstName = firstname; } void Passenger::setLastName(string lastname) { LastName = lastname; } void Passenger::setNext(Passenger * next) { Next = next; } string Passenger::print() const { return FirstName + " " + LastName + ", "; }
[ "noreply@github.com" ]
noreply@github.com
7e16b962e56202f03afab5284314ff8e2a1dc2b9
8496fe32e0e735a136c2238b67a72a94a9ec321f
/Lab6/Mesh.h
de18fd8cb39bd75194b09f3cc34aaea049645af7
[]
no_license
superpaulza/kmitl.computer-graphics
64f7e9bf16bc182315b8ede05ec2863a9233e577
c6fb774cd5284e0d81f5c71539eb06a487201b50
refs/heads/main
2023-05-25T23:55:00.350790
2021-06-08T11:54:10
2021-06-08T11:54:10
329,726,829
0
0
null
null
null
null
UTF-8
C++
false
false
375
h
#ifndef MESH____H #define MESH____H #include <GL/glew.h> class Mesh { public: Mesh(); ~Mesh(); void CreateMesh(GLfloat* vertices, unsigned int* indices, unsigned int numOfVertices, unsigned int numOfIndices); void RenderMesh(); void ClearMesh(); private: GLuint VAO, VBO, IBO; GLsizei indexCount; }; #endif
[ "18383834+superpaulza@users.noreply.github.com" ]
18383834+superpaulza@users.noreply.github.com
74875702813d502228e6f306c0b94f268ca574e1
eb996b2678c5aacc4c87e22c73c45a8fc9a60b23
/ledmatrix5/Bitmap.ino
6944f01bafc458cfa83b8d7c52488b41044b1e75
[]
no_license
ekuiter/ledmatrix5
b5a8efab10e3f11bb2dc303ca724154c18bfd408
a6b52ac9afa1eae044ad4dd1df2cc366ef996d58
refs/heads/master
2021-01-18T17:25:14.251876
2020-12-24T15:38:22
2020-12-24T15:38:22
31,662,467
0
0
null
null
null
null
UTF-8
C++
false
false
194
ino
bool Bitmap::get(int bit) { return BITMAP_GET(bits, bit); } void Bitmap::set(int bit, bool value) { BITMAP_SET(bits, bit, value); } bool Bitmap::operator[](int bit) { return get(bit); }
[ "info@elias-kuiter.de" ]
info@elias-kuiter.de
c5e5124350f00629dede529001843b901a28ea02
18d6674e9387774824cfb7239d15694798fd120e
/src/test/alert_tests.cpp
8960bb453a35c2a6f4cd3de91a7a7054c2784ea9
[ "MIT" ]
permissive
spiraltech/Silk-Core
5b7115153f20a1e2bb81bdac5ad4e1e6eead6e0a
f233cd1113437ef22ec93b125b706e6f46b22028
refs/heads/master
2021-01-11T05:50:50.654841
2016-10-23T05:32:15
2016-10-23T05:32:15
71,719,261
0
0
null
2016-10-23T17:48:17
2016-10-23T17:48:15
null
UTF-8
C++
false
false
5,927
cpp
// Copyright (c) 2009-2016 Satoshi Nakamoto // Copyright (c) 2009-2016 The Bitcoin Developers // Copyright (c) 2015-2016 Silk Network Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. // // Unit tests for alert system // #include "alert.h" #include "clientversion.h" #include "data/alertTests.raw.h" #include "serialize.h" #include "streams.h" #include "util.h" #include "utilstrencodings.h" #include <fstream> #include <boost/filesystem/operations.hpp> #include <boost/foreach.hpp> #include <boost/test/unit_test.hpp> #if 0 // // alertTests contains 7 alerts, generated with this code: // (SignAndSave code not shown, alert signing key is secret) // { CAlert alert; alert.nRelayUntil = 60; alert.nExpiration = 24 * 60 * 60; alert.nID = 1; alert.nCancel = 0; // cancels previous messages up to this ID number alert.nMinVer = 0; // These versions are protocol versions alert.nMaxVer = 999001; alert.nPriority = 1; alert.strComment = "Alert comment"; alert.strStatusBar = "Alert 1"; SignAndSave(alert, "test/alertTests"); alert.setSubVer.insert(std::string("/Satoshi:0.1.0/")); alert.strStatusBar = "Alert 1 for Satoshi 0.1.0"; SignAndSave(alert, "test/alertTests"); alert.setSubVer.insert(std::string("/Satoshi:0.2.0/")); alert.strStatusBar = "Alert 1 for Satoshi 0.1.0, 0.2.0"; SignAndSave(alert, "test/alertTests"); alert.setSubVer.clear(); ++alert.nID; alert.nCancel = 1; alert.nPriority = 100; alert.strStatusBar = "Alert 2, cancels 1"; SignAndSave(alert, "test/alertTests"); alert.nExpiration += 60; ++alert.nID; SignAndSave(alert, "test/alertTests"); ++alert.nID; alert.nMinVer = 11; alert.nMaxVer = 22; SignAndSave(alert, "test/alertTests"); ++alert.nID; alert.strStatusBar = "Alert 2 for Satoshi 0.1.0"; alert.setSubVer.insert(std::string("/Satoshi:0.1.0/")); SignAndSave(alert, "test/alertTests"); ++alert.nID; alert.nMinVer = 0; alert.nMaxVer = 999999; alert.strStatusBar = "Evil Alert'; /bin/ls; echo '"; alert.setSubVer.clear(); SignAndSave(alert, "test/alertTests"); } #endif struct ReadAlerts { ReadAlerts() { std::vector<unsigned char> vch(alert_tests::alertTests, alert_tests::alertTests + sizeof(alert_tests::alertTests)); CDataStream stream(vch, SER_DISK, CLIENT_VERSION); try { while (!stream.eof()) { CAlert alert; stream >> alert; alerts.push_back(alert); } } catch (std::exception) { } } ~ReadAlerts() { } static std::vector<std::string> read_lines(boost::filesystem::path filepath) { std::vector<std::string> result; std::ifstream f(filepath.string().c_str()); std::string line; while (std::getline(f,line)) result.push_back(line); return result; } std::vector<CAlert> alerts; }; BOOST_FIXTURE_TEST_SUITE(Alert_tests, ReadAlerts) BOOST_AUTO_TEST_CASE(AlertApplies) { SetMockTime(11); // Silk: TODO: sign alerts with silk key // currently CheckSignature() will fail because alerts were signed with silk key // BOOST_FOREACH(const CAlert& alert, alerts) // { // BOOST_CHECK(alert.CheckSignature()); // } BOOST_CHECK(alerts.size() >= 3); // Matches: // Silk: for some silk test alerts are read with nExpiration == 0, making following tests fail. // BOOST_CHECK(alerts[0].AppliesTo(1, "")); // BOOST_CHECK(alerts[0].AppliesTo(999001, "")); // BOOST_CHECK(alerts[0].AppliesTo(1, "/Satoshi:11.11.11/")); // BOOST_CHECK(alerts[1].AppliesTo(1, "/Satoshi:0.1.0/")); // BOOST_CHECK(alerts[1].AppliesTo(999001, "/Satoshi:0.1.0/")); // BOOST_CHECK(alerts[2].AppliesTo(1, "/Satoshi:0.1.0/")); // BOOST_CHECK(alerts[2].AppliesTo(1, "/Satoshi:0.2.0/")); // Don't match: BOOST_CHECK(!alerts[0].AppliesTo(-1, "")); BOOST_CHECK(!alerts[0].AppliesTo(999002, "")); BOOST_CHECK(!alerts[1].AppliesTo(1, "")); BOOST_CHECK(!alerts[1].AppliesTo(1, "Satoshi:0.1.0")); BOOST_CHECK(!alerts[1].AppliesTo(1, "/Satoshi:0.1.0")); BOOST_CHECK(!alerts[1].AppliesTo(1, "Satoshi:0.1.0/")); BOOST_CHECK(!alerts[1].AppliesTo(-1, "/Satoshi:0.1.0/")); BOOST_CHECK(!alerts[1].AppliesTo(999002, "/Satoshi:0.1.0/")); BOOST_CHECK(!alerts[1].AppliesTo(1, "/Satoshi:0.2.0/")); BOOST_CHECK(!alerts[2].AppliesTo(1, "/Satoshi:0.3.0/")); SetMockTime(0); } BOOST_AUTO_TEST_CASE(AlertNotify) { SetMockTime(11); boost::filesystem::path temp = GetTempPath() / "alertnotify.txt"; boost::filesystem::remove(temp); mapArgs["-alertnotify"] = std::string("echo %s >> ") + temp.string(); BOOST_FOREACH(CAlert alert, alerts) alert.ProcessAlert(false); std::vector<std::string> r = read_lines(temp); // Silk: following tests requires alertnotify.txt to exist, but for some reason this file is deleted at next instruction... //BOOST_CHECK_EQUAL(r.size(), 4u); // Windows built-in echo semantics are different than posixy shells. Quotes and // whitespace are printed literally. //#ifndef WIN32 // BOOST_CHECK_EQUAL(r[0], "Alert 1"); // BOOST_CHECK_EQUAL(r[1], "Alert 2, cancels 1"); // BOOST_CHECK_EQUAL(r[2], "Alert 2, cancels 1"); // BOOST_CHECK_EQUAL(r[3], "Evil Alert; /bin/ls; echo "); // single-quotes should be removed //#else // BOOST_CHECK_EQUAL(r[0], "'Alert 1' "); // BOOST_CHECK_EQUAL(r[1], "'Alert 2, cancels 1' "); // BOOST_CHECK_EQUAL(r[2], "'Alert 2, cancels 1' "); // BOOST_CHECK_EQUAL(r[3], "'Evil Alert; /bin/ls; echo ' "); //#endif boost::filesystem::remove(temp); SetMockTime(0); } BOOST_AUTO_TEST_SUITE_END()
[ "amirabrams@mail.com" ]
amirabrams@mail.com
ed5b22054bceddc9d4625c422ec912d7a77cd7b3
e8ccba914eb572fa8ccc5421d47ae5cc198fb581
/include/uwin/mem.h
376766886b9e9ca818c0c3b87935891e9611ecf2
[]
no_license
DCNick3/uwin-old
f3a3a1f1f8229bbbf0d767f8a1b07412b43e42b1
3c291620e102a4621ca614f80787cb6511305ad7
refs/heads/master
2023-03-08T09:38:02.706665
2021-02-24T06:45:16
2021-02-24T06:45:16
341,805,385
0
0
null
null
null
null
UTF-8
C++
false
false
472
h
#include <stdint.h> #ifndef UWIN_UTIL_MEM_H #define UWIN_UTIL_MEM_H #ifdef __cplusplus extern "C" { #endif extern void *guest_base; #define TARGET_ADDRESS_SPACE_SIZE 0x80000000 #define g2h(x) ((void*)((uintptr_t)guest_base + (uintptr_t)(uint32_t)(x))) #define h2g(x) ((uint32_t)((uintptr_t)(void*)(x) - (uintptr_t)guest_base)) #ifdef __cplusplus } template<typename T> static inline T* g2hx(uint32_t addr) { return static_cast<T*>(g2h(addr)); } #endif #endif
[ "nikita6@bk.ru" ]
nikita6@bk.ru
7fdad30a50ebedcd800b86100a2ea00f5b5b3a03
70b3500cc8bc3731e62c7f745881c20961a4ea12
/シューティングゲーム/A/EnemyManager.h
0830a76d37af2618c6664ff4d3ed4b8f6c9a2c5d
[]
no_license
gurizou7/c-gengo
501125feb841b4b55a87fd7d0eeb5cb962cd2d3d
31acc6618a183e2e5ac14dcb4fa578dc19ef1be7
refs/heads/master
2020-06-11T15:11:49.914602
2019-07-29T15:14:48
2019-07-29T15:14:48
194,007,237
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
343
h
#pragma once class CEnemy; //敵の数 #define ENEMY_NUM 100 class CEnemyManager { CEnemy *enemy[ENEMY_NUM]; //敵の画像 int enemyGraphic; public: CEnemyManager(); ~CEnemyManager(); void Update(); void Render(); CObject *GetEnemy(int num) { return (CObject*)enemy[num]; } private: //敵の生成 void Spawn(); };
[ "noreply@github.com" ]
noreply@github.com
ba666a7d90d1809bf1a6c7f920098e03ba3a2855
163bad17c2ba0aeeb05e29d1a7f870e675ee28eb
/hikyuu_cpp/hikyuu/indicator/imp/ICos.cpp
e39d062034e4e3fb564fdba921ec865177d7c0d8
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
fasiondog/hikyuu
8b7bc4fd99ff915c621586a480c3663ef3fae464
86b0fa5b0e847d9a04905bca93660a7a33fc9fc2
refs/heads/master
2023-09-03T15:04:33.983389
2023-09-03T11:17:46
2023-09-03T11:17:46
5,103,141
1,884
547
MIT
2023-09-06T16:53:51
2012-07-18T23:21:42
C++
UTF-8
C++
false
false
695
cpp
/* * ICos.cpp * * Copyright (c) 2019 hikyuu.org * * Created on: 2019-5-1 * Author: fasiondog */ #include "ICos.h" #if HKU_SUPPORT_SERIALIZATION BOOST_CLASS_EXPORT(hku::ICos) #endif namespace hku { ICos::ICos() : IndicatorImp("COS", 1) {} ICos::~ICos() {} bool ICos::check() { return true; } void ICos::_calculate(const Indicator& data) { size_t total = data.size(); m_discard = data.discard(); if (m_discard >= total) { m_discard = total; return; } for (size_t i = m_discard; i < total; ++i) { _set(std::cos(data[i]), i); } } Indicator HKU_API COS() { return Indicator(make_shared<ICos>()); } } /* namespace hku */
[ "fasiondog@163.com" ]
fasiondog@163.com
740c6ed709187cbdf9f794d595407f851121a511
6b193cf773cc24896256aab338785d9423549486
/main/lib/fif/src/output_params.cpp
5bc0a6af2f548b9dfd0b0f594794400892426a1e
[]
no_license
GeomartBrenthPAbong/fif
c34f8a9e84b477c74748935af269eff309476fcc
81b4159c76e65f64ec3afd09b759547b63b3ef26
refs/heads/master
2022-04-26T00:05:06.608616
2020-04-30T19:01:36
2020-04-30T19:01:36
260,011,448
0
0
null
null
null
null
UTF-8
C++
false
false
605
cpp
#include "output_params.h" NAMESPACE_OPEN(fif) inline OutputParams::OutputParams ( std::string outputFolder ) { // TODO Verify this folder this->outputFolder = outputFolder; } inline void OutputParams::setOutput ( DataType dataType, std::string curOutput ) { this->dataType = dataType; this->curOutput = curOutput; } inline DataType OutputParams::getDataType() { return this->dataType; } inline std::string OutputParams::getOutput() { return this->curOutput; } inline std::string OutputParams::getOutputFolder() { return this->outputFolder; } NAMESPACE_CLOSE
[ "geomartbrenthabong@skyland.tw" ]
geomartbrenthabong@skyland.tw
99be77b514c8ea884a3301f04246116705d0f1ee
b7f3edb5b7c62174bed808079c3b21fb9ea51d52
/components/offline_pages/core/prefetch/get_operation_request.cc
95760664847bac73b32dc9fcc287673bcd0efa36
[ "BSD-3-Clause" ]
permissive
otcshare/chromium-src
26a7372773b53b236784c51677c566dc0ad839e4
64bee65c921db7e78e25d08f1e98da2668b57be5
refs/heads/webml
2023-03-21T03:20:15.377034
2020-11-16T01:40:14
2020-11-16T01:40:14
209,262,645
18
21
BSD-3-Clause
2023-03-23T06:20:07
2019-09-18T08:52:07
null
UTF-8
C++
false
false
2,216
cc
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/offline_pages/core/prefetch/get_operation_request.h" #include <utility> #include "base/bind.h" #include "base/location.h" #include "components/offline_pages/core/prefetch/prefetch_proto_utils.h" #include "components/offline_pages/core/prefetch/prefetch_request_fetcher.h" #include "components/offline_pages/core/prefetch/prefetch_server_urls.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "url/gurl.h" namespace offline_pages { GetOperationRequest::GetOperationRequest( const std::string& name, version_info::Channel channel, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, PrefetchRequestFinishedCallback callback) : callback_(std::move(callback)) { fetcher_ = PrefetchRequestFetcher::CreateForGet( GetOperationRequestURL(name, channel), url_loader_factory, base::BindOnce(&GetOperationRequest::OnCompleted, // Fetcher is owned by this instance. base::Unretained(this), name)); } GetOperationRequest::~GetOperationRequest() {} void GetOperationRequest::OnCompleted( const std::string& assigned_operation_name, PrefetchRequestStatus status, const std::string& data) { if (status != PrefetchRequestStatus::kSuccess) { std::move(callback_).Run(status, assigned_operation_name, std::vector<RenderPageInfo>()); return; } std::vector<RenderPageInfo> pages; std::string found_operation_name = ParseOperationResponse(data, &pages); if (found_operation_name.empty()) { std::move(callback_).Run(PrefetchRequestStatus::kShouldRetryWithBackoff, assigned_operation_name, std::vector<RenderPageInfo>()); return; } std::move(callback_).Run(PrefetchRequestStatus::kSuccess, assigned_operation_name, pages); } PrefetchRequestFinishedCallback GetOperationRequest::GetCallbackForTesting() { return std::move(callback_); } } // namespace offline_pages
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
776c7f0c7c1e5e913893fed21fae9060e31cd02c
cce3bf9356f1a2a0b4e6c61353a098ab63bd9802
/RitmBase/IntOption.cpp
28024e0af71dabea844941e47cb4394fdf737e8a
[]
no_license
k06a/RitM
ff98a1282c582fce53fa1f4e1a01615f7c95c90c
31bb0b8a91ada54d4832a083daf295d2c01d2449
refs/heads/master
2020-03-12T00:25:39.644330
2018-04-20T11:45:07
2018-04-20T11:45:07
130,348,755
1
0
null
null
null
null
UTF-8
C++
false
false
1,434
cpp
#include "IntOption.h" using namespace RitM; IntOption::IntOption(const std::string & name) : label(name), value(0), min(0), max(0) { } IntOption::IntOption(i64 value, i64 min, i64 max,const std::string & name) : label(name), value(value), min(min), max(max) { } OptionPtr IntOption::CreateCopy() const { IntOptionPtr ptr(new IntOption(value, min, max)); ptr->setName(getName()); return ptr; } const char * IntOption::getName() const { return label.c_str(); } void IntOption::setName(const char * text) { label = text; } void IntOption::visitMe(OptionWalkerPtr walker) { walker->visit(shared_from_this()); } i64 IntOption::minValue() { return min; } void IntOption::setMinValue(i64 val) { min = val; } i64 IntOption::maxValue() { return max; } void IntOption::setMaxValue(i64 val) { max = val; } i64 IntOption::intValue() { return value; } bool IntOption::setIntValue(i64 val) { if ((min <= val) && (val <= max)) { value = val; return true; } return false; } std::string IntOption::saveToString(int level) { char buf[20]; sprintf_s(buf, 20, "%d", value); return buf; } void IntOption::loadFromString(std::string str, int level) { sscanf_s(str.c_str(), "%d", &value); if (value > max) value = max; if (value < min) value = min; }
[ "k06aaa@gmail.com" ]
k06aaa@gmail.com
2f91c9ded62a24169b6e526e4dc50a146c927340
ed91c77afaeb0e075da38153aa89c6ee8382d3fc
/mediasoup-client/deps/webrtc/src/rtc_base/physical_socket_server_unittest.cc
3762762f856f0dd6b0d130d8b3d8dc0e17ec6224
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-google-patent-license-webrtc", "LicenseRef-scancode-google-patent-license-webm", "MIT" ]
permissive
whatisor/mediasoup-client-android
37bf1aeaadc8db642cff449a26545bf15da27539
dc3d812974991d9b94efbc303aa2deb358928546
refs/heads/master
2023-04-26T12:24:18.355241
2023-01-02T16:55:19
2023-01-02T16:55:19
243,833,549
0
0
MIT
2020-02-28T18:56:36
2020-02-28T18:56:36
null
UTF-8
C++
false
false
16,594
cc
/* * Copyright 2004 The WebRTC 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 in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "rtc_base/physical_socket_server.h" #include <signal.h> #include <algorithm> #include <memory> #include "rtc_base/gunit.h" #include "rtc_base/ip_address.h" #include "rtc_base/logging.h" #include "rtc_base/net_helpers.h" #include "rtc_base/network_monitor.h" #include "rtc_base/socket_unittest.h" #include "rtc_base/test_utils.h" #include "rtc_base/thread.h" #include "test/gtest.h" namespace rtc { #define MAYBE_SKIP_IPV4 \ if (!HasIPv4Enabled()) { \ RTC_LOG(LS_INFO) << "No IPv4... skipping"; \ return; \ } #define MAYBE_SKIP_IPV6 \ if (!HasIPv6Enabled()) { \ RTC_LOG(LS_INFO) << "No IPv6... skipping"; \ return; \ } class PhysicalSocketTest; class FakeSocketDispatcher : public SocketDispatcher { public: explicit FakeSocketDispatcher(PhysicalSocketServer* ss) : SocketDispatcher(ss) {} FakeSocketDispatcher(SOCKET s, PhysicalSocketServer* ss) : SocketDispatcher(s, ss) {} protected: SOCKET DoAccept(SOCKET socket, sockaddr* addr, socklen_t* addrlen) override; int DoSend(SOCKET socket, const char* buf, int len, int flags) override; int DoSendTo(SOCKET socket, const char* buf, int len, int flags, const struct sockaddr* dest_addr, socklen_t addrlen) override; }; class FakePhysicalSocketServer : public PhysicalSocketServer { public: explicit FakePhysicalSocketServer(PhysicalSocketTest* test) : test_(test) {} AsyncSocket* CreateAsyncSocket(int family, int type) override { SocketDispatcher* dispatcher = new FakeSocketDispatcher(this); if (!dispatcher->Create(family, type)) { delete dispatcher; return nullptr; } return dispatcher; } AsyncSocket* WrapSocket(SOCKET s) override { SocketDispatcher* dispatcher = new FakeSocketDispatcher(s, this); if (!dispatcher->Initialize()) { delete dispatcher; return nullptr; } return dispatcher; } PhysicalSocketTest* GetTest() const { return test_; } private: PhysicalSocketTest* test_; }; class FakeNetworkBinder : public NetworkBinderInterface { public: NetworkBindingResult BindSocketToNetwork(int, const IPAddress&) override { ++num_binds_; return result_; } void set_result(NetworkBindingResult result) { result_ = result; } int num_binds() { return num_binds_; } private: NetworkBindingResult result_ = NetworkBindingResult::SUCCESS; int num_binds_ = 0; }; class PhysicalSocketTest : public SocketTest { public: // Set flag to simluate failures when calling "::accept" on a AsyncSocket. void SetFailAccept(bool fail) { fail_accept_ = fail; } bool FailAccept() const { return fail_accept_; } // Maximum size to ::send to a socket. Set to < 0 to disable limiting. void SetMaxSendSize(int max_size) { max_send_size_ = max_size; } int MaxSendSize() const { return max_send_size_; } protected: PhysicalSocketTest() : server_(new FakePhysicalSocketServer(this)), thread_(server_.get()), fail_accept_(false), max_send_size_(-1) {} void ConnectInternalAcceptError(const IPAddress& loopback); void WritableAfterPartialWrite(const IPAddress& loopback); std::unique_ptr<FakePhysicalSocketServer> server_; rtc::AutoSocketServerThread thread_; bool fail_accept_; int max_send_size_; }; SOCKET FakeSocketDispatcher::DoAccept(SOCKET socket, sockaddr* addr, socklen_t* addrlen) { FakePhysicalSocketServer* ss = static_cast<FakePhysicalSocketServer*>(socketserver()); if (ss->GetTest()->FailAccept()) { return INVALID_SOCKET; } return SocketDispatcher::DoAccept(socket, addr, addrlen); } int FakeSocketDispatcher::DoSend(SOCKET socket, const char* buf, int len, int flags) { FakePhysicalSocketServer* ss = static_cast<FakePhysicalSocketServer*>(socketserver()); if (ss->GetTest()->MaxSendSize() >= 0) { len = std::min(len, ss->GetTest()->MaxSendSize()); } return SocketDispatcher::DoSend(socket, buf, len, flags); } int FakeSocketDispatcher::DoSendTo(SOCKET socket, const char* buf, int len, int flags, const struct sockaddr* dest_addr, socklen_t addrlen) { FakePhysicalSocketServer* ss = static_cast<FakePhysicalSocketServer*>(socketserver()); if (ss->GetTest()->MaxSendSize() >= 0) { len = std::min(len, ss->GetTest()->MaxSendSize()); } return SocketDispatcher::DoSendTo(socket, buf, len, flags, dest_addr, addrlen); } TEST_F(PhysicalSocketTest, TestConnectIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestConnectIPv4(); } TEST_F(PhysicalSocketTest, TestConnectIPv6) { SocketTest::TestConnectIPv6(); } TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestConnectWithDnsLookupIPv4(); } TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupIPv6) { SocketTest::TestConnectWithDnsLookupIPv6(); } TEST_F(PhysicalSocketTest, TestConnectFailIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestConnectFailIPv4(); } void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) { webrtc::testing::StreamSink sink; SocketAddress accept_addr; // Create two clients. std::unique_ptr<AsyncSocket> client1( server_->CreateAsyncSocket(loopback.family(), SOCK_STREAM)); sink.Monitor(client1.get()); EXPECT_EQ(AsyncSocket::CS_CLOSED, client1->GetState()); EXPECT_TRUE(IsUnspecOrEmptyIP(client1->GetLocalAddress().ipaddr())); std::unique_ptr<AsyncSocket> client2( server_->CreateAsyncSocket(loopback.family(), SOCK_STREAM)); sink.Monitor(client2.get()); EXPECT_EQ(AsyncSocket::CS_CLOSED, client2->GetState()); EXPECT_TRUE(IsUnspecOrEmptyIP(client2->GetLocalAddress().ipaddr())); // Create server and listen. std::unique_ptr<AsyncSocket> server( server_->CreateAsyncSocket(loopback.family(), SOCK_STREAM)); sink.Monitor(server.get()); EXPECT_EQ(0, server->Bind(SocketAddress(loopback, 0))); EXPECT_EQ(0, server->Listen(5)); EXPECT_EQ(AsyncSocket::CS_CONNECTING, server->GetState()); // Ensure no pending server connections, since we haven't done anything yet. EXPECT_FALSE(sink.Check(server.get(), webrtc::testing::SSE_READ)); EXPECT_TRUE(nullptr == server->Accept(&accept_addr)); EXPECT_TRUE(accept_addr.IsNil()); // Attempt first connect to listening socket. EXPECT_EQ(0, client1->Connect(server->GetLocalAddress())); EXPECT_FALSE(client1->GetLocalAddress().IsNil()); EXPECT_NE(server->GetLocalAddress(), client1->GetLocalAddress()); // Client is connecting, outcome not yet determined. EXPECT_EQ(AsyncSocket::CS_CONNECTING, client1->GetState()); EXPECT_FALSE(sink.Check(client1.get(), webrtc::testing::SSE_OPEN)); EXPECT_FALSE(sink.Check(client1.get(), webrtc::testing::SSE_CLOSE)); // Server has pending connection, try to accept it (will fail). EXPECT_TRUE_WAIT((sink.Check(server.get(), webrtc::testing::SSE_READ)), kTimeout); // Simulate "::accept" returning an error. SetFailAccept(true); std::unique_ptr<AsyncSocket> accepted(server->Accept(&accept_addr)); EXPECT_FALSE(accepted); ASSERT_TRUE(accept_addr.IsNil()); // Ensure no more pending server connections. EXPECT_FALSE(sink.Check(server.get(), webrtc::testing::SSE_READ)); EXPECT_TRUE(nullptr == server->Accept(&accept_addr)); EXPECT_TRUE(accept_addr.IsNil()); // Attempt second connect to listening socket. EXPECT_EQ(0, client2->Connect(server->GetLocalAddress())); EXPECT_FALSE(client2->GetLocalAddress().IsNil()); EXPECT_NE(server->GetLocalAddress(), client2->GetLocalAddress()); // Client is connecting, outcome not yet determined. EXPECT_EQ(AsyncSocket::CS_CONNECTING, client2->GetState()); EXPECT_FALSE(sink.Check(client2.get(), webrtc::testing::SSE_OPEN)); EXPECT_FALSE(sink.Check(client2.get(), webrtc::testing::SSE_CLOSE)); // Server has pending connection, try to accept it (will succeed). EXPECT_TRUE_WAIT((sink.Check(server.get(), webrtc::testing::SSE_READ)), kTimeout); SetFailAccept(false); std::unique_ptr<AsyncSocket> accepted2(server->Accept(&accept_addr)); ASSERT_TRUE(accepted2); EXPECT_FALSE(accept_addr.IsNil()); EXPECT_EQ(accepted2->GetRemoteAddress(), accept_addr); } TEST_F(PhysicalSocketTest, TestConnectAcceptErrorIPv4) { MAYBE_SKIP_IPV4; ConnectInternalAcceptError(kIPv4Loopback); } TEST_F(PhysicalSocketTest, TestConnectAcceptErrorIPv6) { MAYBE_SKIP_IPV6; ConnectInternalAcceptError(kIPv6Loopback); } void PhysicalSocketTest::WritableAfterPartialWrite(const IPAddress& loopback) { // Simulate a really small maximum send size. const int kMaxSendSize = 128; SetMaxSendSize(kMaxSendSize); // Run the default send/receive socket tests with a smaller amount of data // to avoid long running times due to the small maximum send size. const size_t kDataSize = 128 * 1024; TcpInternal(loopback, kDataSize, kMaxSendSize); } // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 #if defined(WEBRTC_WIN) #define MAYBE_TestWritableAfterPartialWriteIPv4 \ DISABLED_TestWritableAfterPartialWriteIPv4 #else #define MAYBE_TestWritableAfterPartialWriteIPv4 \ TestWritableAfterPartialWriteIPv4 #endif TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv4) { MAYBE_SKIP_IPV4; WritableAfterPartialWrite(kIPv4Loopback); } // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 #if defined(WEBRTC_WIN) #define MAYBE_TestWritableAfterPartialWriteIPv6 \ DISABLED_TestWritableAfterPartialWriteIPv6 #else #define MAYBE_TestWritableAfterPartialWriteIPv6 \ TestWritableAfterPartialWriteIPv6 #endif TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv6) { MAYBE_SKIP_IPV6; WritableAfterPartialWrite(kIPv6Loopback); } TEST_F(PhysicalSocketTest, TestConnectFailIPv6) { SocketTest::TestConnectFailIPv6(); } TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestConnectWithDnsLookupFailIPv4(); } TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv6) { SocketTest::TestConnectWithDnsLookupFailIPv6(); } TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestConnectWithClosedSocketIPv4(); } TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv6) { SocketTest::TestConnectWithClosedSocketIPv6(); } TEST_F(PhysicalSocketTest, TestConnectWhileNotClosedIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestConnectWhileNotClosedIPv4(); } TEST_F(PhysicalSocketTest, TestConnectWhileNotClosedIPv6) { SocketTest::TestConnectWhileNotClosedIPv6(); } TEST_F(PhysicalSocketTest, TestServerCloseDuringConnectIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestServerCloseDuringConnectIPv4(); } TEST_F(PhysicalSocketTest, TestServerCloseDuringConnectIPv6) { SocketTest::TestServerCloseDuringConnectIPv6(); } TEST_F(PhysicalSocketTest, TestClientCloseDuringConnectIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestClientCloseDuringConnectIPv4(); } TEST_F(PhysicalSocketTest, TestClientCloseDuringConnectIPv6) { SocketTest::TestClientCloseDuringConnectIPv6(); } TEST_F(PhysicalSocketTest, TestServerCloseIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestServerCloseIPv4(); } TEST_F(PhysicalSocketTest, TestServerCloseIPv6) { SocketTest::TestServerCloseIPv6(); } TEST_F(PhysicalSocketTest, TestCloseInClosedCallbackIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestCloseInClosedCallbackIPv4(); } TEST_F(PhysicalSocketTest, TestCloseInClosedCallbackIPv6) { SocketTest::TestCloseInClosedCallbackIPv6(); } TEST_F(PhysicalSocketTest, TestDeleteInReadCallbackIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestDeleteInReadCallbackIPv4(); } TEST_F(PhysicalSocketTest, TestDeleteInReadCallbackIPv6) { SocketTest::TestDeleteInReadCallbackIPv6(); } TEST_F(PhysicalSocketTest, TestSocketServerWaitIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestSocketServerWaitIPv4(); } TEST_F(PhysicalSocketTest, TestSocketServerWaitIPv6) { SocketTest::TestSocketServerWaitIPv6(); } TEST_F(PhysicalSocketTest, TestTcpIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestTcpIPv4(); } TEST_F(PhysicalSocketTest, TestTcpIPv6) { SocketTest::TestTcpIPv6(); } TEST_F(PhysicalSocketTest, TestUdpIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestUdpIPv4(); } TEST_F(PhysicalSocketTest, TestUdpIPv6) { SocketTest::TestUdpIPv6(); } // Disable for TSan v2, see // https://code.google.com/p/webrtc/issues/detail?id=3498 for details. // Also disable for MSan, see: // https://code.google.com/p/webrtc/issues/detail?id=4958 // TODO(deadbeef): Enable again once test is reimplemented to be unflaky. // Also disable for ASan. // Disabled on Android: https://code.google.com/p/webrtc/issues/detail?id=4364 // Disabled on Linux: https://bugs.chromium.org/p/webrtc/issues/detail?id=5233 #if defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \ defined(ADDRESS_SANITIZER) || defined(WEBRTC_ANDROID) || \ defined(WEBRTC_LINUX) #define MAYBE_TestUdpReadyToSendIPv4 DISABLED_TestUdpReadyToSendIPv4 #else #define MAYBE_TestUdpReadyToSendIPv4 TestUdpReadyToSendIPv4 #endif TEST_F(PhysicalSocketTest, MAYBE_TestUdpReadyToSendIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestUdpReadyToSendIPv4(); } // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 #if defined(WEBRTC_WIN) #define MAYBE_TestUdpReadyToSendIPv6 DISABLED_TestUdpReadyToSendIPv6 #else #define MAYBE_TestUdpReadyToSendIPv6 TestUdpReadyToSendIPv6 #endif TEST_F(PhysicalSocketTest, MAYBE_TestUdpReadyToSendIPv6) { SocketTest::TestUdpReadyToSendIPv6(); } TEST_F(PhysicalSocketTest, TestGetSetOptionsIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestGetSetOptionsIPv4(); } TEST_F(PhysicalSocketTest, TestGetSetOptionsIPv6) { SocketTest::TestGetSetOptionsIPv6(); } #if defined(WEBRTC_POSIX) // We don't get recv timestamps on Mac. #if !defined(WEBRTC_MAC) TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv4) { MAYBE_SKIP_IPV4; SocketTest::TestSocketRecvTimestampIPv4(); } TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv6) { SocketTest::TestSocketRecvTimestampIPv6(); } #endif // Verify that if the socket was unable to be bound to a real network interface // (not loopback), Bind will return an error. TEST_F(PhysicalSocketTest, BindFailsIfNetworkBinderFailsForNonLoopbackInterface) { MAYBE_SKIP_IPV4; FakeNetworkBinder fake_network_binder; server_->set_network_binder(&fake_network_binder); std::unique_ptr<AsyncSocket> socket( server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM)); fake_network_binder.set_result(NetworkBindingResult::FAILURE); EXPECT_EQ(-1, socket->Bind(SocketAddress("192.168.0.1", 0))); server_->set_network_binder(nullptr); } // Network binder shouldn't be used if the socket is bound to the "any" IP. TEST_F(PhysicalSocketTest, NetworkBinderIsNotUsedForAnyIp) { MAYBE_SKIP_IPV4; FakeNetworkBinder fake_network_binder; server_->set_network_binder(&fake_network_binder); std::unique_ptr<AsyncSocket> socket( server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM)); EXPECT_EQ(0, socket->Bind(SocketAddress("0.0.0.0", 0))); EXPECT_EQ(0, fake_network_binder.num_binds()); server_->set_network_binder(nullptr); } // For a loopback interface, failures to bind to the interface should be // tolerated. TEST_F(PhysicalSocketTest, BindSucceedsIfNetworkBinderFailsForLoopbackInterface) { MAYBE_SKIP_IPV4; FakeNetworkBinder fake_network_binder; server_->set_network_binder(&fake_network_binder); std::unique_ptr<AsyncSocket> socket( server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM)); fake_network_binder.set_result(NetworkBindingResult::FAILURE); EXPECT_EQ(0, socket->Bind(SocketAddress(kIPv4Loopback, 0))); server_->set_network_binder(nullptr); } #endif } // namespace rtc
[ "wuhaiyang1213@gmail.com" ]
wuhaiyang1213@gmail.com
d808117c99c781b3b4f2fe046ff2422c2193969f
4724afa8472b0d961d40cc3be71f5abd1373143f
/spoj/tourney.cpp
54c6e77d7a08c9f33589794d3c1ea41d2aeecc54
[]
no_license
banarun/my_competitive_codes
2f88334c563ad050c21c68ae449134a28fb2ba95
c5a5af3cf74341d02a328974e8e316d300a221b2
refs/heads/master
2021-01-18T22:46:47.419449
2016-06-25T14:14:15
2016-06-25T14:14:15
33,266,178
0
0
null
null
null
null
UTF-8
C++
false
false
1,644
cpp
#include <cstdio> #include <cmath> #include <climits> #include <iostream> using namespace std; #ifdef DEBUG #define dbg(args...) { cerr<<#args<<": "; dbgr,args; cerr<<endl;} #else #define dbg(args...) #endif struct debugger{template<typename T> debugger& operator , (const T& v){cerr<<v<<" "; return *this; }}dbgr; int arr[1100000]; int st[2200000]; #define ll long long inline int inp() { ll r=0; int c; for(c=getchar_unlocked();c<=32;c=getchar_unlocked()); for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar_unlocked()); return r; } int construct(int ss, int se, int si) { if (ss == se) { st[si] = arr[ss]; return arr[ss]; } int mid = (ss+se)/2; st[si] = max(construct(ss, mid, si*2), construct(mid+1, se, si*2+1)); return st[si]; } int main() { int n,m; scanf("%d%d",&n,&m); int p=(1<<n); int mval=INT_MIN; int indx=0; for(int i=1;i<=p;i++){ arr[i]=inp(); } construct(1,p,1); for(int i=0;i<m;i++){ char c; for(c=getchar_unlocked();c<=32;c=getchar_unlocked()); if(c=='R'){ int a,b; a=inp(); b=inp(); arr[a]=b; int ptr=(p-1)+a; st[ptr]=b; ptr=ptr/2; while(ptr>0){ if(st[ptr]==max(st[ptr*2+1],st[ptr*2])) break; else st[ptr]=max(st[ptr*2+1],st[ptr*2]); ptr/=2; } } else if(c=='S'){ int a,b,count=0; //scanf("%d",&a); a=inp(); b=p+a-1; while(arr[a]==st[b]){ b=b/2; count++; } printf("%d\n",count-1); } else{ int a=1; while(a<p){ if(st[2*a+1]==st[a]){ a=2*a+1; } else a=2*a; } printf("%d\n",a-(p-1)); } } return 0; }
[ "banarunk@gmail.com" ]
banarunk@gmail.com