blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
10
150
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
15
license_type
stringclasses
2 values
repo_name
stringlengths
9
56
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
4 values
visit_date
timestamp[us]date
2016-09-05 08:58:04
2023-09-03 08:42:35
revision_date
timestamp[us]date
2012-03-19 11:33:32
2023-09-02 19:15:15
committer_date
timestamp[us]date
2012-03-19 11:33:32
2023-09-02 19:15:15
github_id
int64
3.03M
408M
star_events_count
int64
0
435
fork_events_count
int64
0
125
gha_license_id
stringclasses
3 values
gha_event_created_at
timestamp[us]date
2015-05-04 07:27:29
2023-03-20 11:52:19
gha_created_at
timestamp[us]date
2013-10-11 03:08:51
2021-09-19 21:14:59
gha_language
stringclasses
3 values
src_encoding
stringclasses
1 value
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
129
7.61k
extension
stringclasses
5 values
content
stringlengths
129
7.61k
authors
sequencelengths
1
1
author_id
stringlengths
1
46
9b6b1ec168b70a357f4e47169b73b0f2e0538b9b
6565182c28637e21087007f09d480a70b387382e
/code/901.股票价格跨度.cpp
61b63105d48efcafe008368d50a272d85d3e8c15
[]
no_license
liu-jianhao/leetcode
08c070f0f140b2dd56cffbbaf25868364addfe53
7cbbe0585778517c88aa6ac1d2f2f8478cc931e5
refs/heads/master
2021-07-17T05:54:58.228956
2020-08-17T07:03:52
2020-08-17T07:03:52
188,854,718
1
1
null
null
null
null
UTF-8
C++
false
false
792
cpp
/* * @lc app=leetcode.cn id=901 lang=cpp * * [901] 股票价格跨度 */ class StockSpanner { public: StockSpanner() { } int next(int price) { if(_i == 0 || price < _prices.back()) { _dp.push_back(1); } else { int j = _i - 1; while(j >= 0 && price >= _prices[j]) { j -= _dp[j]; } _dp.push_back(_i - j); } ++_i; _prices.push_back(price); return _dp.back(); } private: vector<int> _dp; vector<int> _prices; int _i = 0; }; /** * Your StockSpanner object will be instantiated and called as such: * StockSpanner* obj = new StockSpanner(); * int param_1 = obj->next(price); */
ab5bc031413c9ef1306cacfd08a9878b7b902ed5
35e79b51f691b7737db254ba1d907b2fd2d731ef
/AtCoder/ABC/007/D.cpp
1f7d6ef9dd955d37b91e67aebfabda6b728594c7
[]
no_license
rodea0952/competitive-programming
00260062d00f56a011f146cbdb9ef8356e6b69e4
9d7089307c8f61ea1274a9f51d6ea00d67b80482
refs/heads/master
2022-07-01T02:25:46.897613
2022-06-04T08:44:42
2022-06-04T08:44:42
202,485,546
0
0
null
null
null
null
UTF-8
C++
false
false
1,189
cpp
#include <bits/stdc++.h> #define chmin(a, b) ((a)=min((a), (b))) #define chmax(a, b) ((a)=max((a), (b))) #define fs first #define sc second #define eb emplace_back using namespace std; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> T; const ll MOD=1e9+7; const ll INF=1e18; int dx[]={1, -1, 0, 0}; int dy[]={0, 0, 1, -1}; template <typename T> inline string toString(const T &a){ostringstream oss; oss<<a; return oss.str();}; ll solve(string &s){ int n=s.size(); ll dp[20][2][2]; // dp[決めた桁数][未満フラグ][4または9を含むか] := 求める総数 memset(dp, 0, sizeof(dp)); dp[0][0][0]=1; for(int i=0; i<n; i++){ // 桁 int D=s[i]-'0'; for(int j=0; j<2; j++){ // 未満フラグ for(int k=0; k<2; k++){ // k=1 のとき4または9を含む for(int d=0; d<=(j?9:D); d++){ dp[i+1][j || (d<D)][k || d==4 || d==9]+=dp[i][j][k]; } } } } return dp[n][0][1]+dp[n][1][1]; } int main(){ ll a, b; cin>>a>>b; string A=toString(a-1), B=toString(b); cout << solve(B) - solve(A) << endl; }
f45da0032ec95894d113360f36e2c7e74a3b4bd2
be522f6110d4ed6f330da41a653460e4fb1ed3a7
/runtime/nf/httpparser/Buffer.cc
e4717f524b583c4cfdc3f533c545bdec74c3946c
[]
no_license
yxd886/nfa
2a796b10e6e2085470e54dd4f9a4a3721c0d27a9
209fd992ab931f955afea11562673fec943dd8a6
refs/heads/master
2020-06-17T22:09:37.259587
2017-03-24T03:07:38
2017-03-24T03:07:38
74,966,034
0
0
null
null
null
null
UTF-8
C++
false
false
981
cc
#include "Buffer.h" void CBuffer_Reset(struct CBuffer& Cbuf){ if(!Cbuf.buf){ Cbuf.buf = (char*) malloc(BUFFER_SIZE); memset(Cbuf.buf,0x00,Cbuf._free); } if(Cbuf.len > BUFFER_SIZE * 2 && Cbuf.buf){ //如果目前buf的大小是默认值的2倍,则对其裁剪内存,保持buf的大小为默认值,减小内存耗费 char* newbuf = (char*) realloc(Cbuf.buf,BUFFER_SIZE); if(newbuf != Cbuf.buf) Cbuf.buf = newbuf; } Cbuf.len = 0; Cbuf._free = BUFFER_SIZE; } bool Append(struct CBuffer& Cbuf,char* p, size_t size){ if(!p || !size) return true; if(size < Cbuf._free){ memcpy(Cbuf.buf + Cbuf.len, p , size); Cbuf.len += size; Cbuf._free -= size; }else{ return false; } return true; } char* GetBuf(struct CBuffer Cbuf,uint32_t& size){ size = Cbuf.len; return Cbuf.buf; } uint32_t GetBufLen(struct CBuffer Cbuf){ return Cbuf.len; } void Buf_init(struct CBuffer& Cbuf){ Cbuf.len=0; Cbuf._free=0; Cbuf.buf=0; CBuffer_Reset(Cbuf); }
e701e032706c6d0b6712cbf46f97a1491037c069
509ed385d3faa95ed92957f0f691fc3fe1d6816a
/src/Workers/Worker.h
db1536697c5f967497dfa8fe487e786329ac19ec
[]
no_license
xrenoder/Node-InfrastructureTorrent
d6540c725cb9239bcf421a7891e7ebbeb6505701
21c3eb739d0b41cb6858d747cd108708bbfdb73d
refs/heads/master
2023-08-29T01:02:15.760253
2021-09-20T10:03:30
2021-09-20T10:03:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
504
h
#ifndef WORKER_H_ #define WORKER_H_ #include <memory> #include <optional> #include "OopUtils.h" namespace torrent_node_lib { struct BlockInfo; class Worker: public common::no_copyable, common::no_moveable{ public: virtual void start() = 0; virtual void process(std::shared_ptr<BlockInfo> bi, std::shared_ptr<std::string> dump) = 0; virtual std::optional<size_t> getInitBlockNumber() const = 0; virtual ~Worker() = default; }; } #endif // WORKER_H_
bba7327fa47b292b7a2a12379dbea888640a0e70
58790459d953a3e4b6722ed3ee939f82d9de8c3e
/my/PDF插件/sdkDC_v1_win/Adobe/Acrobat DC SDK/Version 1/PluginSupport/PIBrokerSDK/simple-ipc-lib/src/pipe_win.h
4625bef0dc76752fdcc7b3a4966d087839cbd12f
[]
no_license
tisn05/VS
bb84deb993eb18d43d8edaf81afb753afa3d3188
da56d392a518ba21edcb1a367b4b4378d65506f0
refs/heads/master
2020-09-25T05:49:31.713773
2016-08-22T01:22:16
2016-08-22T01:22:16
66,229,337
0
1
null
null
null
null
UTF-8
C++
false
false
1,659
h
// Copyright (c) 2010 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef SIMPLE_IPC_PIPE_WIN_H_ #define SIMPLE_IPC_PIPE_WIN_H_ #include "os_includes.h" #include "ipc_constants.h" class PipePair { public: PipePair(bool inherit_fd2 = false); HANDLE fd1() const { return srv_; } HANDLE fd2() const { return cln_; } static HANDLE OpenPipeServer(const wchar_t* name, bool low_integrity = false); static HANDLE OpenPipeClient(const wchar_t* name, bool inherit, bool impersonate); private: HANDLE srv_; HANDLE cln_; }; class PipeWin { public: PipeWin(); ~PipeWin(); bool OpenClient(HANDLE pipe); bool OpenServer(HANDLE pipe, bool connect = false); bool Write(const void* buf, size_t sz); bool Read(void* buf, size_t* sz); bool IsConnected() const { return INVALID_HANDLE_VALUE != pipe_; } private: HANDLE pipe_; }; class PipeTransport : public PipeWin { public: static const size_t kBufferSz = 4096; size_t Send(const void* buf, size_t sz) { return Write(buf, sz) ? ipc::RcOK : ipc::RcErrTransportWrite; } char* Receive(size_t* size); private: IPCCharVector buf_; }; #endif // SIMPLE_IPC_PIPE_WIN_H_
b8319da5f12cfbbbd8ce6c9a50bab4c69b92531e
c4a320a9519cd63bad9be9bcfc022a4fcab5267b
/TETRIS_VS/TETRIS_VS/LobbyBoard.cpp
4e7ef9e1f59c43158f02345d8f894a183007f43e
[]
no_license
shield1203/TETRIS_VS
79dc3d8db0a1107352e46e69a96482a49490a290
3f67f0436674a10f9d37a98286a1f3531e6f7730
refs/heads/master
2020-12-22T00:11:37.323472
2020-03-05T15:28:32
2020-03-05T15:28:32
236,593,352
0
0
null
null
null
null
UTF-8
C++
false
false
401
cpp
#include "stdafx.h" #include "LobbyBoard.h" #include "InputSystem.h" #include "PacketManager.h" LobbyBoard::LobbyBoard() { m_packetManager = PacketManager::getInstance(); m_inputSystem = new InputSystem(); } LobbyBoard::~LobbyBoard() { SafeDelete(m_inputSystem); } void LobbyBoard::Update() { m_inputSystem->CheckKeyboardPressed(); if (m_inputSystem->IsEnterPressed()) { m_on = true; } }
33fa115e3d756b655d4b8fd3fc840eb94198c8be
012784e8de35581e1929306503439bb355be4c4f
/problems/37. 解数独/3.cc
84bf778bd32645766fc6275be6ca3a9a288a96dc
[]
no_license
silenke/my-leetcode
7502057c9394e41ddeb2e7fd6c1b8261661639e0
d24ef0970785c547709b1d3c7228e7d8b98b1f06
refs/heads/master
2023-06-05T02:05:48.674311
2021-07-01T16:18:29
2021-07-01T16:18:29
331,948,127
0
0
null
null
null
null
UTF-8
C++
false
false
1,979
cc
#include "..\..\leetcode.h" class Solution { public: void solveSudoku(vector<vector<char>>& board) { row = col = box = vector<int>(9); int count = 0; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (board[i][j] == '.') count++; else fill(i, j, i / 3 * 3 + j / 3, board[i][j] - '1'); } } dfs(count, board); } private: vector<int> row, col, box; void fill(int i, int j, int k, int n) { row[i] |= 1 << n; col[j] |= 1 << n; box[k] |= 1 << n; } void zero(int i, int j, int k, int n) { row[i] &= ~(1 << n); col[j] &= ~(1 << n); box[k] &= ~(1 << n); } int possible(int i, int j) { return ~(row[i] | col[j] | box[i / 3 * 3 + j / 3]) & ((1 << 9) - 1); } pair<int, int> next(vector<vector<char>>& board) { pair<int, int> res; int min_count = INT_MAX; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (board[i][j] != '.') continue; int c = count(possible(i, j)); if (c < min_count) { min_count = c; res = {i, j}; } } } return res; } bool dfs(int count, vector<vector<char>>& board) { if (count == 0) return true; auto [i, j] = next(board); int p = possible(i, j); int k = i / 3 * 3 + j / 3; while (p) { int n = __builtin_ctz(p & -p); board[i][j] = n + '1'; fill(i, j, k, n); if (dfs(count - 1, board)) return true; board[i][j] = '.'; zero(i, j, k, n); p &= p - 1; } return false; } int count(int p) { int count = 0; while (p) { count++; p &= p - 1; } return count; } };
06c1ab5ff8ab138987ba9ad1ed0f423d945bafe7
6817617489ef291d4d53ac844ba7a2b14cc17ae2
/11942.cpp
dcc6c32bd3395a76801df96fb6b8693215e020ec
[]
no_license
Asad51/UVA-Problem-Solving
1932f2cd73261cd702f58d4f189a4a134dbd6286
af28ae36a2074d4e2a67670dbbbd507438c56c3e
refs/heads/master
2020-03-23T14:52:49.420143
2019-10-24T17:03:37
2019-10-24T17:03:37
120,592,261
0
0
null
null
null
null
UTF-8
C++
false
false
449
cpp
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int t; cin>>t; cout<<"Lumberjacks:\n"; while(t--){ bool in = true; bool dec = true; int p; for(int i=0; i<10; i++){ int n; cin>>n; if(!i){ p = n; continue; } if(n<p || !in) in = false; if(n>p || !dec) dec = false; p = n; } if(!in && !dec) cout<<"Unordered\n"; else cout<<"Ordered\n"; } return 0; }
fa606684822edaeb65a3facbab4e69b8044c96ef
6aeccfb60568a360d2d143e0271f0def40747d73
/sandbox/SOC/2011/simd/boost/simd/toolbox/constant/include/constants/minexponent.hpp
0fd6c857f2cef5aa7fcc1f22aca4daf4a5f7a9c3
[]
no_license
ttyang/sandbox
1066b324a13813cb1113beca75cdaf518e952276
e1d6fde18ced644bb63e231829b2fe0664e51fac
refs/heads/trunk
2021-01-19T17:17:47.452557
2013-06-07T14:19:55
2013-06-07T14:19:55
13,488,698
1
3
null
2023-03-20T11:52:19
2013-10-11T03:08:51
C++
UTF-8
C++
false
false
232
hpp
#ifndef BOOST_SIMD_TOOLBOX_CONSTANT_INCLUDE_CONSTANTS_MINEXPONENT_HPP_INCLUDED #define BOOST_SIMD_TOOLBOX_CONSTANT_INCLUDE_CONSTANTS_MINEXPONENT_HPP_INCLUDED #include <boost/simd/toolbox/constant/constants/minexponent.hpp> #endif
e58b6df0e5b4c66f0d095c33c45ddcbea6ffceae
9929f9f832b21f641f41fc91cbf604643f9770dd
/src/txt/mainRegressionP.cpp
16ad10a2e0e2cf8996b46a19dd9d38b275156452
[]
no_license
JeanSar/rogue
1cd4d8d18fe8ae6ba7d32f3af556259f5a65b2fc
a4c8945a8ae09984a4b417a3bac5ffd029e46fa7
refs/heads/master
2023-03-01T01:24:12.351208
2021-01-28T19:53:17
2021-01-28T19:53:17
331,929,934
2
0
null
null
null
null
UTF-8
C++
false
false
1,062
cpp
#include "Personnages.h" using namespace std; int main(){ srand(time(NULL)); int ok = 0; Hero* h = new Hero("Player"); Ennemi* e = new Ennemi(4); cout << "Hero : " << h->getName() << endl << "x : " << h->getX() << endl << "y : " << h->getY() << endl << "pv : " << h->getPv() << endl << "lv : " << h->getLv() << endl << "atk : " << h->getAtk() << endl << "def : " << h->getDef() << "\n\n" << "Ennemi :" << endl << "x : " << e->getX() << endl << "y : " << e->getY() << endl << "pv : " << e->getPv() << endl << "lv : " << e->getLv() << endl << "atk : " << e->getAtk() << endl << "def : " << e->getDef() << "\n\n"; assert(ok == h->lvUp()); cout << "lv : " << h->getLv() << endl << "atk : " << h->getAtk() << endl << "def : " << h->getDef() << endl; assert(ok == h->combat(e)); cout << "Ennemie - pv : " << e->getPv() << endl; assert(ok == h->setName("Terrine")); assert(ok == e->combat(h)); cout << h->getName() << " - pv : " << h->getPv(); delete e; delete h; return 0; }
[ "=" ]
=
cbee84c2e52dc1341528f8254aaf41ac321f936c
2869112fdc836e565f9fe68e290affc1e223c1d8
/pythran/pythonic/include/__builtin__/set/isdisjoint.hpp
10ac38270e03ff35d15b79143e6164321a7b5afb
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
coyotte508/pythran
ab26e9ddb9a9e00e77b457df316aa33dc8435914
a5da78f2aebae712a2c6260ab691dab7d09e307c
refs/heads/master
2021-01-15T10:07:09.597297
2015-05-01T07:00:42
2015-05-01T07:00:42
35,020,532
0
0
null
2015-05-04T07:27:29
2015-05-04T07:27:29
null
UTF-8
C++
false
false
621
hpp
#ifndef PYTHONIC_INCLUDE_BUILTIN_SET_ISDISJOINT_HPP #define PYTHONIC_INCLUDE_BUILTIN_SET_ISDISJOINT_HPP #include "pythonic/utils/proxy.hpp" #include "pythonic/types/set.hpp" namespace pythonic { namespace __builtin__ { namespace set { template<class T, class U> bool isdisjoint(types::set<T> const& calling_set, U const& arg_set); template<class U> bool isdisjoint(types::empty_set const& calling_set, U const& arg_set); PROXY_DECL(pythonic::__builtin__::set, isdisjoint); } } } #endif
c1be7ed8331d413fbb32c4f4da225eabb0c94905
2d4346d0da0a4145f6bcc91a8cb2c0ab4d669d7e
/chat-up-server/src/Authentication/AuthenticationService.h
b172c8a7281e736007294715851af51947b6b669
[]
no_license
xgallom/chat-up
5570d069a495acf6398bdf1f62b1fb1d91289376
7cb664ce745cf041fb508b04165d2179563aa010
refs/heads/master
2020-04-18T05:40:58.487905
2019-01-29T22:36:04
2019-01-29T22:36:04
167,287,878
0
0
null
null
null
null
UTF-8
C++
false
false
608
h
// // Created by xgallom on 1/27/19. // #ifndef CHAT_UP_AUTHENTICATIONSERVICE_H #define CHAT_UP_AUTHENTICATIONSERVICE_H #include <Messaging/Message.h> #include <Messaging/MessageSender.h> #include <Outcome.h> #include <Authentication/User.h> class AuthenticationStorage; class AuthenticationService { AuthenticationStorage &m_storage; User m_user = User(); public: AuthenticationService() noexcept; Outcome::Enum run(MessageSender &sender, const Message &message); bool registerUser(const User &user); User user() const noexcept; }; #endif //CHAT_UP_AUTHENTICATIONSERVICE_H
cb50f617109e0944e114883af3fc3af8be9a6b7e
9030ce2789a58888904d0c50c21591632eddffd7
/SDK/ARKSurvivalEvolved_Buff_PreventDismount_functions.cpp
7e18c4f1010b3ae0b9f98e0ea4d779d40e1340ba
[ "MIT" ]
permissive
2bite/ARK-SDK
8ce93f504b2e3bd4f8e7ced184980b13f127b7bf
ce1f4906ccf82ed38518558c0163c4f92f5f7b14
refs/heads/master
2022-09-19T06:28:20.076298
2022-09-03T17:21:00
2022-09-03T17:21:00
232,411,353
14
5
null
null
null
null
UTF-8
C++
false
false
1,490
cpp
// ARKSurvivalEvolved (332.8) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_Buff_PreventDismount_parameters.hpp" namespace sdk { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function Buff_PreventDismount.Buff_PreventDismount_C.UserConstructionScript // () void ABuff_PreventDismount_C::UserConstructionScript() { static auto fn = UObject::FindObject<UFunction>("Function Buff_PreventDismount.Buff_PreventDismount_C.UserConstructionScript"); ABuff_PreventDismount_C_UserConstructionScript_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function Buff_PreventDismount.Buff_PreventDismount_C.ExecuteUbergraph_Buff_PreventDismount // () // Parameters: // int EntryPoint (Parm, ZeroConstructor, IsPlainOldData) void ABuff_PreventDismount_C::ExecuteUbergraph_Buff_PreventDismount(int EntryPoint) { static auto fn = UObject::FindObject<UFunction>("Function Buff_PreventDismount.Buff_PreventDismount_C.ExecuteUbergraph_Buff_PreventDismount"); ABuff_PreventDismount_C_ExecuteUbergraph_Buff_PreventDismount_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
b7c78a511904d321aa74ab25ce20a44c3a3f0a0e
d51d72f1b6e834d89c8551bb07487bed84cdaa31
/src/output/osg/customCode/osg/AnimationPath_pmoc.cpp
dc66ae9496a4b899d13c9038f85bec5d8cc50019
[]
no_license
wangfeilong321/osg4noob
221204aa15efa18f1f049548ad076ef27371ecad
99a15c3fd2523c4bd537fa3afb0b47e15c8f335a
refs/heads/master
2021-01-12T20:00:43.854775
2015-11-06T15:37:01
2015-11-06T15:37:01
48,840,543
0
1
null
2015-12-31T07:56:31
2015-12-31T07:56:31
null
UTF-8
C++
false
false
1,778
cpp
#include <osg/AnimationPath> //includes #include <MetaQQuickLibraryRegistry.h> #include <customCode/osg/AnimationPath_pmoc.hpp> using namespace pmoc; osg::QMLAnimationPath::QMLAnimationPath(pmoc::Instance *i,QObject* parent):QReflect_AnimationPath(i,parent){ //custom initializations } QQuickItem* osg::QMLAnimationPath::connect2View(QQuickItem*i){ this->_view=QReflect_AnimationPath::connect2View(i); ///connect this's signals/slot to its qml component//////////////////////////////////////////////////////////////// ///CustomiZE here return this->_view; } void osg::QMLAnimationPath::updateModel(){ QReflect_AnimationPath::updateModel(); ///update this according to state of _model when it has been changed via pmoc///////////////////////////////////////////// ///CustomiZE here } #ifndef AUTOMOCCPP #define AUTOMOCCPP 1 #include "moc_AnimationPath_pmoc.cpp" #endif #include <MetaQQuickLibraryRegistry.h> #include <customCode/osg/AnimationPath_pmoc.hpp> using namespace pmoc; osg::QMLAnimationPathCallback::QMLAnimationPathCallback(pmoc::Instance *i,QObject* parent):QReflect_AnimationPathCallback(i,parent){ //custom initializations } QQuickItem* osg::QMLAnimationPathCallback::connect2View(QQuickItem*i){ this->_view=QReflect_AnimationPathCallback::connect2View(i); ///connect this's signals/slot to its qml component//////////////////////////////////////////////////////////////// ///CustomiZE here return this->_view; } void osg::QMLAnimationPathCallback::updateModel(){ QReflect_AnimationPathCallback::updateModel(); ///update this according to state of _model when it has been changed via pmoc///////////////////////////////////////////// ///CustomiZE here } #ifndef AUTOMOCCPP #define AUTOMOCCPP 1 #include "moc_AnimationPath_pmoc.cpp" #endif
376f659de9de4170c19135d4e5e6f4fa7d95e938
bc33abf80f11c4df023d6b1f0882bff1e30617cf
/CPP/other/李泉彰/hhh.cpp
0e114bad33f893d5b9c3e166e74c22c9172ffe76
[]
no_license
pkuzhd/ALL
0fad250c710b4804dfd6f701d8f45381ee1a5d11
c18525decdfa70346ec32ca2f47683951f4c39e0
refs/heads/master
2022-07-11T18:20:26.435897
2019-11-20T13:25:24
2019-11-20T13:25:24
119,031,607
0
0
null
2022-06-21T21:10:42
2018-01-26T09:19:23
C++
UTF-8
C++
false
false
6,060
cpp
#include <stdio.h> #include <iostream> using namespace std; int qipan[15][15] = { 0 }; int times = 0; int print(); bool is_win(int x, int y, int flag); bool is_near(int x, int y); bool AI_set(int flag); int calc_value(int x, int y, int flag, int depth, int _max_value); int qixing(int x, int y); int main(int argc, char **argv) { int flag = 1; while (true) { ++times; print(); int x, y; if (flag == 1) { while (true) { cin >> x >> y; if (!qipan[x][y] || x < 0 || x >= 15 || y < 0 || y >= 15) break; } qipan[x][y] = flag; if (is_win(x, y, flag)) break; } else { if (AI_set(flag)) break; } flag *= -1; } if (flag == 1) { printf("black\n"); } else { printf("white\n"); } system("pause"); return 0; } int print() { for (int i = 0; i < 15; ++i) { for (int j = 0; j < 15; ++j) cout << (qipan[i][j] ? (qipan[i][j] == 1 ? "*" : "#") : "0"); cout << endl; } cout << endl; return 0; } bool is_win(int x, int y, int flag) { int number = 1; for (int i = x + 1; i < 15; ++i) { if (qipan[i][y] == flag) ++number; else break; } for (int i = x - 1; i >= 0; --i) { if (qipan[i][y] == flag) ++number; else break; } if (number >= 5) return true; number = 1; for (int i = y + 1; i < 15; ++i) { if (qipan[x][i] == flag) ++number; else break; } for (int i = y - 1; i >= 0; --i) { if (qipan[x][i] == flag) ++number; else break; } if (number >= 5) return true; number = 1; for (int j = 1; x + j < 15 && y + j < 15; ++j) { if (qipan[x + j][y + j] == flag) ++number; else break; } for (int j = 1; x - j >= 0 && y - j >= 0; ++j) { if (qipan[x - j][y - j] == flag) ++number; else break; } if (number >= 5) return true; number = 1; for (int j = 1; x + j < 15 && y - j >= 0; ++j) { if (qipan[x + j][y - j] == flag) ++number; else break; } for (int j = 1; x - j >= 0 && y + j < 15; ++j) { if (qipan[x - j][y + j] == flag) ++number; else break; } if (number >= 5) return true; return false; } bool is_near(int x, int y) { // cout << x << " " << y << endl; int _near = 2; for (int i = (x - _near >= 0 ? x - _near : 0); i <= (x + _near < 15 ? x + _near : 14); ++i) { for (int j = (y - _near >= 0 ? y - _near : 0); j <= (y + _near < 15 ? y + _near : 14); ++j) { if (qipan[i][j]) return true; } } return false; } bool AI_set(int flag) { int max_value = -10000000; int x = 7, y = 7; for (int i = 0; i < 15; ++i) { for (int j = 0; j < 15; ++j) { if (qipan[i][j]) continue; if (!is_near(i, j)) continue; int t_value = calc_value(i, j, flag, 0, max_value); if (is_win(i, j, flag)) { qipan[i][j] = flag; return true; } if (t_value > max_value) { max_value = t_value; x = i; y = j; } } } qipan[x][y] = flag; cout << x << " " << y << " " << flag << " " << is_win(x, y, flag)<< endl; return false; } int calc_value(int x, int y, int flag, int depth, int _max_value) { int _value = 0; qipan[x][y] = flag; if (depth < 4) { int max_value = -10000000; for (int i = 0; i < 15; ++i) { for (int j = 0; j < 15; ++j) { if (qipan[i][j] || !is_near(i, j)) continue; int t_value = calc_value(i, j, -flag, depth + 1, max_value); if (t_value > -_max_value) { qipan[x][y] = 0; return t_value; } if (is_win(i, j, -flag)) { qipan[x][y] = 0; return -10000000; } if (t_value > max_value) { max_value = t_value; } } } _value -= max_value; } else _value += qixing(x, y); qipan[x][y] = 0; return _value; } int qixing(int x, int y) { int flag = qipan[x][y]; bool dead = false; int number = 1; int _value = 0; int sz_qixing[2][6] = { 0 }; // x 方向 number = 1; dead = false; for (int i = x + 1; ; ++i) { if (i < 15 && qipan[i][y] == flag) ++number; else { if (i >= 15 || qipan[i][y]) dead = true; break; } } for (int i = x - 1; i >= 0; --i) { if (i >= 0 && qipan[i][y] == flag) ++number; else { if ((i < 0 || qipan[i][y]) && dead) break; else { if (dead || qipan[i][y]) dead = true; ++sz_qixing[dead][number]; } } } // y方向 number = 1; dead = false; for (int i = y + 1; ; ++i) { if (i < 15 && qipan[x][i] == flag) ++number; else { if (i >= 15 || qipan[x][i]) dead = true; break; } } for (int i = y - 1; i >= 0; --i) { if (i >= 0 && qipan[x][i] == flag) ++number; else { if ((i < 0 || qipan[x][i]) && dead) break; else { if (dead || qipan[x][i]) dead = true; ++sz_qixing[dead][number]; } } } // x y 方向 number = 1; dead = false; for (int i = 1; ; ++i) { if (x + i < 15 && y + i < 15 && qipan[x + i][y + i] == flag) ++number; else { if (x + i >= 15 || y + i >= 15 || qipan[x + i][y + i]) dead = true; break; } } for (int i = 1; ; ++i) { if (x - i >= 0 && y - i >= 0 && qipan[x - i][y - i] == flag) ++number; else { if ((x - i < 0 || y - i < 0 || qipan[x - i][y - i]) && dead) break; else { if (dead || qipan[x - i][y - i]) dead = true; ++sz_qixing[dead][number]; } } } // x -y 方向 number = 1; dead = false; for (int i = 1; ; ++i) { if (x + i < 15 && y - i >= 0 && qipan[x + i][y - i] == flag) ++number; else { if (x + i >= 15 || y - i < 0 || qipan[x + i][y - i]) dead = true; break; } } for (int i = 1; ; ++i) { if (x - i >= 0 && y + i < 15 && qipan[x - i][y + i] == flag) ++number; else { if ((x - i < 0 || y + i >= 15 || qipan[x - i][y + i]) && dead) break; else { if (dead || qipan[x - i][y + i]) dead = true; ++sz_qixing[dead][number]; } } } if (sz_qixing[false][4] || (sz_qixing[true][4] + sz_qixing[false][3]) >= 2) _value += 1000000; _value += sz_qixing[false][3] * 10000; _value += sz_qixing[true][3] * 1000; _value += sz_qixing[false][2] * 100; _value += sz_qixing[true][2] * 10; return _value; }
d906994d3f90133151039af0434882e3553ba719
1c02e13a776e5e8bc3e2a6182b5df4efb2c71d32
/core/unit_test/tstDeepCopy.hpp
b3fdab4da5ef0b61357d256cf996dae1b69884f0
[ "BSD-3-Clause" ]
permissive
junghans/Cabana
91b82827dd9fb8321bea9ea3750c196946a6aac0
7b9078f81bde68c949fd6ae913ce80eeaf0f8f8a
refs/heads/master
2021-06-14T09:57:01.658234
2019-01-04T22:24:45
2019-01-04T22:24:45
150,330,482
1
1
BSD-3-Clause
2019-01-07T16:24:20
2018-09-25T21:17:53
C++
UTF-8
C++
false
false
5,252
hpp
/**************************************************************************** * Copyright (c) 2018 by the Cabana authors * * All rights reserved. * * * * This file is part of the Cabana library. Cabana is distributed under a * * BSD 3-clause license. For the licensing terms see the LICENSE file in * * the top-level directory. * * * * SPDX-License-Identifier: BSD-3-Clause * ****************************************************************************/ #include <Cabana_DeepCopy.hpp> #include <Cabana_AoSoA.hpp> #include <Cabana_Types.hpp> #include <gtest/gtest.h> namespace Test { //---------------------------------------------------------------------------// // Check the data given a set of values. template<class aosoa_type> void checkDataMembers( aosoa_type aosoa, const float fval, const double dval, const int ival, const int dim_1, const int dim_2, const int dim_3 ) { auto slice_0 = aosoa.template slice<0>(); auto slice_1 = aosoa.template slice<1>(); auto slice_2 = aosoa.template slice<2>(); auto slice_3 = aosoa.template slice<3>(); for ( std::size_t idx = 0; idx < aosoa.size(); ++idx ) { // Member 0. for ( int i = 0; i < dim_1; ++i ) for ( int j = 0; j < dim_2; ++j ) for ( int k = 0; k < dim_3; ++k ) EXPECT_EQ( slice_0( idx, i, j, k ), fval * (i+j+k) ); // Member 1. EXPECT_EQ( slice_1( idx ), ival ); // Member 2. for ( int i = 0; i < dim_1; ++i ) EXPECT_EQ( slice_2( idx, i ), dval * i ); // Member 3. for ( int i = 0; i < dim_1; ++i ) for ( int j = 0; j < dim_2; ++j ) EXPECT_EQ( slice_3( idx, i, j ), dval * (i+j) ); } } //---------------------------------------------------------------------------// // Perform a deep copy test. template<class DstMemorySpace, class SrcMemorySpace, int DstVectorLength, int SrcVectorLength> void testDeepCopy() { // Data dimensions. const int dim_1 = 3; const int dim_2 = 2; const int dim_3 = 4; // Declare data types. using DataTypes = Cabana::MemberTypes<float[dim_1][dim_2][dim_3], int, double[dim_1], double[dim_1][dim_2] >; // Declare the AoSoA types. using DstAoSoA_t = Cabana::AoSoA<DataTypes,DstMemorySpace,DstVectorLength>; using SrcAoSoA_t = Cabana::AoSoA<DataTypes,SrcMemorySpace,SrcVectorLength>; // Create AoSoAs. int num_data = 357; DstAoSoA_t dst_aosoa( num_data ); SrcAoSoA_t src_aosoa( num_data ); // Initialize data with the rank accessors. float fval = 3.4; double dval = 1.23; int ival = 1; auto slice_0 = src_aosoa.template slice<0>(); auto slice_1 = src_aosoa.template slice<1>(); auto slice_2 = src_aosoa.template slice<2>(); auto slice_3 = src_aosoa.template slice<3>(); for ( std::size_t idx = 0; idx < src_aosoa.size(); ++idx ) { // Member 0. for ( int i = 0; i < dim_1; ++i ) for ( int j = 0; j < dim_2; ++j ) for ( int k = 0; k < dim_3; ++k ) slice_0( idx, i, j, k ) = fval * (i+j+k); // Member 1. slice_1( idx ) = ival; // Member 2. for ( int i = 0; i < dim_1; ++i ) slice_2( idx, i ) = dval * i; // Member 3. for ( int i = 0; i < dim_1; ++i ) for ( int j = 0; j < dim_2; ++j ) slice_3( idx, i, j ) = dval * (i+j); } // Deep copy Cabana::deep_copy( dst_aosoa, src_aosoa ); // Check values. checkDataMembers( dst_aosoa, fval, dval, ival, dim_1, dim_2, dim_3 ); } //---------------------------------------------------------------------------// // TESTS //---------------------------------------------------------------------------// TEST_F( TEST_CATEGORY, deep_copy_to_host_same_layout_test ) { testDeepCopy<Cabana::HostSpace,TEST_MEMSPACE,16,16>(); } //---------------------------------------------------------------------------// TEST_F( TEST_CATEGORY, deep_copy_from_host_same_layout_test ) { testDeepCopy<TEST_MEMSPACE,Cabana::HostSpace,16,16>(); } //---------------------------------------------------------------------------// TEST_F( TEST_CATEGORY, deep_copy_to_host_different_layout_test ) { testDeepCopy<Cabana::HostSpace,TEST_MEMSPACE,16,32>(); testDeepCopy<Cabana::HostSpace,TEST_MEMSPACE,64,8>(); } //---------------------------------------------------------------------------// TEST_F( TEST_CATEGORY, deep_copy_from_host_different_layout_test ) { testDeepCopy<TEST_MEMSPACE,Cabana::HostSpace,64,8>(); testDeepCopy<TEST_MEMSPACE,Cabana::HostSpace,16,32>(); } //---------------------------------------------------------------------------// } // end namespace Test
0f14955c67c8ded4e0b25301b31b8648ae16b52f
4985aad8ecfceca8027709cf488bc2c601443385
/build/Android/Debug/app/src/main/include/Fuse.Resources.Resour-7da5075.h
bb740adfa48c8d9b5e34d9b3bf2a2c23882e8030
[]
no_license
pacol85/Test1
a9fd874711af67cb6b9559d9a4a0e10037944d89
c7bb59a1b961bfb40fe320ee44ca67e068f0a827
refs/heads/master
2021-01-25T11:39:32.441939
2017-06-12T21:48:37
2017-06-12T21:48:37
93,937,614
0
0
null
null
null
null
UTF-8
C++
false
false
883
h
// This file was generated based on '../../AppData/Local/Fusetools/Packages/Fuse.Nodes/1.0.2/$.uno'. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.h> namespace g{namespace Fuse{namespace Resources{struct ResourceConverters;}}} namespace g{namespace Uno{namespace Collections{struct Dictionary;}}} namespace g{ namespace Fuse{ namespace Resources{ // internal static class ResourceConverters :3538 // { uClassType* ResourceConverters_typeof(); void ResourceConverters__Get_fn(uType* __type, uObject** __retval); struct ResourceConverters : uObject { static uSStrong< ::g::Uno::Collections::Dictionary*> _converters_; static uSStrong< ::g::Uno::Collections::Dictionary*>& _converters() { return ResourceConverters_typeof()->Init(), _converters_; } static uObject* Get(uType* __type); }; // } }}} // ::g::Fuse::Resources
8bfe178d65efb2f52470e306b87737b39f700ce6
f80d267d410b784458e61e4c4603605de368de9b
/TESTONE/exampleios/usr/local/include/fit_developer_field_description.hpp
a5af5c51d16055664f81433af69b821385dd83c5
[]
no_license
bleeckerj/Xcode-FIT-TEST
84bdb9e1969a93a6380a9c64dce0a0e715d81fe8
37490e3b1e913dc3dfabdae39b48bddea24f1023
refs/heads/master
2021-01-20T14:39:53.249495
2017-02-22T05:59:28
2017-02-22T05:59:28
82,766,547
0
0
null
null
null
null
UTF-8
C++
false
false
1,772
hpp
//////////////////////////////////////////////////////////////////////////////// // The following FIT Protocol software provided may be used with FIT protocol // devices only and remains the copyrighted property of Dynastream Innovations Inc. // The software is being provided on an "as-is" basis and as an accommodation, // and therefore all warranties, representations, or guarantees of any kind // (whether express, implied or statutory) including, without limitation, // warranties of merchantability, non-infringement, or fitness for a particular // purpose, are specifically disclaimed. // // Copyright 2017 Dynastream Innovations Inc. //////////////////////////////////////////////////////////////////////////////// // ****WARNING**** This file is auto-generated! Do NOT edit this file. // Profile Version = 20.24Release // Tag = production/akw/20.24.01-0-g5fa480b //////////////////////////////////////////////////////////////////////////////// #if !defined(FIT_DEVELOPER_FIELD_DESCRIPTION_HPP) #define FIT_DEVELOPER_FIELD_DESCRIPTION_HPP #include "fit_field_description_mesg.hpp" #include "fit_developer_data_id_mesg.hpp" #include <vector> namespace fit { class DeveloperFieldDescription { public: DeveloperFieldDescription() = delete; DeveloperFieldDescription(const DeveloperFieldDescription& other); DeveloperFieldDescription(const FieldDescriptionMesg& desc, const DeveloperDataIdMesg& developer); virtual ~DeveloperFieldDescription(); FIT_UINT32 GetApplicationVersion() const; FIT_UINT8 GetFieldDefinitionNumber() const; std::vector<FIT_UINT8> GetApplicationId() const; private: FieldDescriptionMesg* description; DeveloperDataIdMesg* developer; }; } // namespace fit #endif // defined(FIT_FIELD_DEFINITION_HPP)
e583e7116773107273d5fb8024b730ef48f23333
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/pdfium/xfa/fxfa/parser/cxfa_solid.cpp
da8de3f6aca0fae9e6ba41523e382edcb9d6be21
[ "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
1,216
cpp
// Copyright 2017 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "xfa/fxfa/parser/cxfa_solid.h" #include "fxjs/xfa/cjx_node.h" #include "xfa/fxfa/parser/cxfa_document.h" namespace { const CXFA_Node::PropertyData kSolidPropertyData[] = { {XFA_Element::Extras, 1, {}}, }; const CXFA_Node::AttributeData kSolidAttributeData[] = { {XFA_Attribute::Id, XFA_AttributeType::CData, nullptr}, {XFA_Attribute::Use, XFA_AttributeType::CData, nullptr}, {XFA_Attribute::Usehref, XFA_AttributeType::CData, nullptr}, }; } // namespace CXFA_Solid::CXFA_Solid(CXFA_Document* doc, XFA_PacketType packet) : CXFA_Node(doc, packet, {XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm}, XFA_ObjectType::Node, XFA_Element::Solid, kSolidPropertyData, kSolidAttributeData, cppgc::MakeGarbageCollected<CJX_Node>( doc->GetHeap()->GetAllocationHandle(), this)) {} CXFA_Solid::~CXFA_Solid() = default;
a0a7716d5870fb0a5b552fb6115b6e7b7937b018
c22dbf8b58f205c5b748eeff49dfaf04e3a40f39
/Cantera/clib/src/Storage.cpp
d5462bccbfad490f8de02daa46dd5a4a7f8d90af
[]
no_license
VishalKandala/Cantera1.8-Radcal
ee9fc49ae18ffb406be6cf6854daf2427e29c9ab
1d7c90244e80185910c88fdf247193ad3a1745f3
refs/heads/main
2023-01-20T17:07:23.385551
2020-11-29T05:50:51
2020-11-29T05:50:51
301,748,576
0
0
null
null
null
null
UTF-8
C++
false
false
3,004
cpp
/** * @file Storage.cpp */ /* * $Id: Storage.cpp,v 1.6 2009/07/11 17:16:09 hkmoffa Exp $ */ // Cantera includes #include "Kinetics.h" #include "TransportFactory.h" #include "Storage.h" using namespace std; using namespace Cantera; Storage::Storage() { addThermo(new ThermoPhase); addKinetics(new Kinetics); addTransport(newTransportMgr()); } Storage::~Storage() { clear(); } int Storage::addThermo(thermo_t* th) { if (th->index() >= 0) return th->index(); __thtable.push_back(th); int n = static_cast<int>(__thtable.size()) - 1; th->setIndex(n); //string id = th->id(); //if (__thmap.count(id) == 0) { // __thmap[id] = n; // th->setID(id); //} //else { // throw CanteraError("Storage::addThermo","id already used"); // return -1; //} return n; } int Storage::nThermo() { return static_cast<int>(__thtable.size()); } int Storage::addKinetics(Kinetics* kin) { if (kin->index() >= 0) return kin->index(); __ktable.push_back(kin); int n = static_cast<int>(__ktable.size()) - 1; kin->setIndex(n); return n; } int Storage::addTransport(Transport* tr) { if (tr->index() >= 0) return tr->index(); __trtable.push_back(tr); int n = static_cast<int>(__trtable.size()) - 1; tr->setIndex(n); return n; } // int Storage::addNewTransport(int model, char* dbase, int th, // int loglevel) { // try { // ThermoPhase* thrm = __thtable[th]; // Transport* tr = newTransportMgr(model, // string(dbase), thrm, loglevel); // __trtable.push_back(tr); // return __trtable.size() - 1; // } // catch (CanteraError) {return -1;} // catch (...) {return ERR;} // } int Storage::clear() { int i, n; n = static_cast<int>(__thtable.size()); for (i = 1; i < n; i++) { if (__thtable[i] != __thtable[0]) { delete __thtable[i]; __thtable[i] = __thtable[0]; } } n = static_cast<int>(__ktable.size()); for (i = 1; i < n; i++) { if (__ktable[i] != __ktable[0]) { delete __ktable[i]; __ktable[i] = __ktable[0]; } } n = static_cast<int>(__trtable.size()); for (i = 1; i < n; i++) { if (__trtable[i] != __trtable[0]) { delete __trtable[i]; __trtable[i] = __trtable[0]; } } return 0; } void Storage::deleteKinetics(int n) { if (n == 0) return; if (__ktable[n] != __ktable[0]) delete __ktable[n]; __ktable[n] = __ktable[0]; } void Storage::deleteThermo(int n) { if (n == 0) return; if (n < 0 || n >= (int) __thtable.size()) throw CanteraError("deleteThermo","illegal index"); __thtable[n] = __thtable[0]; } void Storage::deleteTransport(int n) { if (n == 0) return; if (__trtable[n] != __trtable[0]) delete __trtable[n]; __trtable[n] = __trtable[0]; } Storage* Storage::__storage = 0;
849e17e440d0e9523fb0dd1a5f7f9d2bf5e1f416
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5686313294495744_0/C++/vidhan13j07/test.cpp
5edfd10037fb916f2f5fbdef7cf9305b0b29d5b9
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
2,489
cpp
#include<bits/stdc++.h> #define sc(v) v.size() #define eb push_back #define pb pop_back #define f(i,a,b) for(int i=a;i<b;i++) #define TC() int t;cin>>t;while(t--) #define all(x) x.begin(),x.end() #define mk make_pair #define fi first #define se second #define endl "\n" #define eps 1e-9 #define pw(x) (1ll<<(x)) #define trace1(x) cout <<#x<<": "<<x<<endl; #define trace2(x, y) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl; #define trace3(x, y, z) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl; #define trace4(a, b, c, d) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl; #define trace5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl; using namespace std; typedef long long int ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<string,string> pi; typedef pair<ll,ll> pll; inline bool EQ(double a,double b) { return fabs(a - b) < 1e-9; } inline void set_bit(int & n, int b) { n |= pw(b); } inline void unset_bit(int & n, int b) { n &= ~pw(b); } int main() { #ifndef ONLINE_JUDGE //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); #endif clock_t tStart = clock(); int tc = 1; int n; map< pi,int > mp; vector< pi > v; set< pi > vv; vector<string> f,rr; string x,y; set<string> a,b; TC() { printf("Case #%d: ", tc++); mp.clear(); v.clear(); a.clear(); b.clear(); scanf("%d",&n); f(i,0,n) { cin>>x>>y; v.eb(mk(x,y)); mp[mk(x,y)] = 1; } int ans = 0; f(i,0,1 << n) { f.clear(); rr.clear(); vv.clear(); int c = 0; f(j,0,n) if(i&(1 << j)) { f.eb(v[j].fi); rr.eb(v[j].se); vv.insert(v[j]); } f(j,0,sc(f)) f(k,0,sc(rr)) { if(vv.find(mk(f[j],rr[k])) != vv.end()) continue; if(mp[mk(f[j],rr[k])]) c++; } ans = max(ans,c); } printf("%d\n",ans); } //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); return 0; }
83881de53e405fca71ff23806072066608fcd793
4dd6c13f3fc50d0d0ff84ba3d442eee2d3dae742
/Engine/Managers/EventManager.cpp
b7d2c47d7e90411950603f29a5718646637d73c3
[]
no_license
Marcos30004347/AzgardEngine
570773ad3c3f99628708ff06e4f0674dab0b8977
ee5f4e3de1b8bcefdab01b0b71e3d4fcca86b4e3
refs/heads/master
2022-12-08T17:06:06.632049
2020-08-29T01:44:12
2020-08-29T01:44:12
289,409,420
1
0
null
null
null
null
UTF-8
C++
false
false
1,180
cpp
#include<iostream> #include<assert.h> #include "EventManager.hpp" #include "definitions.hpp" #ifdef SDL2_IMP #include <SDL2/SDL.h> SDL_Event sdl2_event; #endif EventManager* EventManager::gInstance = nullptr; EventManager::EventManager() {} EventManager::~EventManager() {} EventManager* EventManager::GetSingletonPtr(void) { assert(EventManager::gInstance); return EventManager::gInstance; } EventManager& EventManager::GetSingleton(void) { assert(EventManager::gInstance); return *EventManager::gInstance; } void EventManager::StartUp() { std::cout << "starting up event manager" << std::endl; EventManager::gInstance = new EventManager(); } void EventManager::ShutDown() { std::cout << "shuting down event manager" << std::endl; delete EventManager::gInstance; } bool EventManager::Pool(Event *event) { #ifdef SDL2_IMP int pedding = SDL_PollEvent(&sdl2_event); switch (sdl2_event.type) { case SDL_QUIT: event->type = QUIT_EVENT; break; default: event->type = NULL_EVENT; break; } #else #error IMPLEMENTATION NOT DEFINED #endif return pedding; }
8b494503d9bf74ff5d28e840affc467e8a440a51
34a3165ded55c6ac5ffe2ff17c9996c66e0e80b5
/cpp/ETProtect.cpp
989ebb94e3100accc0e0e0fd02bff4f34144df29
[]
no_license
monkeyde17/et-protect-package
d806a3196c28c4176374bc21e7ec5769faa72347
77e04d1834d0723c2de7f424a1cbc1efd2321991
refs/heads/master
2016-09-06T05:53:58.824045
2014-12-07T02:29:37
2014-12-07T02:29:37
27,655,865
0
1
null
null
null
null
UTF-8
C++
false
false
1,888
cpp
// // ETProtect.cpp // testcpp // // Created by etond on 14/12/3. // // #include "ETProtect.h" bool ETProtect::isOriginPackage() { unsigned int uHashValue = calculateValueFromFile(); unsigned int uReadValue = readValueFromFile(); #if (ETPROTECTDEBUG) CCLOG("[log] -- hash %u", uHashValue); CCLOG("[log] -- read %u", uReadValue); #endif if (uReadValue == 0 || uHashValue == 0) { return false; } return uReadValue == uHashValue; } unsigned int ETProtect::readValueFromFile(std::string filename /* default = config.et */) { unsigned int uValue = 0; Data data = FileUtils::getInstance()->getDataFromFile(filename); if (data.getSize() > 0) { uValue = ((ETProtectData *)data.getBytes())->getHashValue(); } return uValue; } unsigned int ETProtect::calculateValueFromFile(unsigned int seed /* default = 0x12345678 */) { std::string path = ""; #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) JniMethodInfo minfo; bool isHave = JniHelper::getStaticMethodInfo(minfo, "org/cocos2dx/cpp/AppActivity", "getPath", "()Ljava/lang/String;"); if (isHave) { jobject jobj = minfo.env->CallStaticObjectMethod(minfo.classID, minfo.methodID); /* get the return value */ path = JniHelper::jstring2string((jstring)jobj).c_str(); CCLOG("JNI SUCCESS!"); } #endif unsigned int value = 0; if (path.length() > 0) { ssize_t len = 0; unsigned char *buf = FileUtils::getInstance()->getFileDataFromZip(path, "classes.dex", &len); if (buf) { value = XXH32(buf, len, seed); } delete[] buf; } return value; }
0acbecc764fbfcc61711e5ca5ce12561d4730135
399b5e377fdd741fe6e7b845b70491b9ce2cccfd
/LLVM_src/libcxx/test/std/utilities/time/time.cal/time.cal.ymwdlast/types.pass.cpp
e0580fac76fa9102f0058519d247d1d7895bce5a
[ "NCSA", "LLVM-exception", "MIT", "Apache-2.0" ]
permissive
zslwyuan/LLVM-9-for-Light-HLS
6ebdd03769c6b55e5eec923cb89e4a8efc7dc9ab
ec6973122a0e65d963356e0fb2bff7488150087c
refs/heads/master
2021-06-30T20:12:46.289053
2020-12-07T07:52:19
2020-12-07T07:52:19
203,967,206
1
3
null
2019-10-29T14:45:36
2019-08-23T09:25:42
C++
UTF-8
C++
false
false
802
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 // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 // <chrono> // class year_month_weekday_last_last; #include <chrono> #include <type_traits> #include <cassert> #include "test_macros.h" int main() { using year_month_weekday_last = std::chrono::year_month_weekday_last; static_assert(std::is_trivially_copyable_v<year_month_weekday_last>, ""); static_assert(std::is_standard_layout_v<year_month_weekday_last>, ""); }
7ade5627a226f91a37d1e00ba158ba1f1eace614
6a56f4e8bfa2da98cfc51a883b7cae01736c3046
/ovaldi-code-r1804-trunk/src/probes/unix/PasswordProbe.h
03062e89f9d72a9942bd7a1aac071a565a9a4ae6
[]
no_license
tmcclain-taptech/Ovaldi-Win10
6b11e495c8d37fd73aae6c0281287cadbc491e59
7214d742c66f3df808d70e880ba9dad69cea403d
refs/heads/master
2021-07-07T09:36:30.776260
2019-03-28T19:11:29
2019-03-28T19:11:29
164,451,763
2
1
null
null
null
null
UTF-8
C++
false
false
2,857
h
// // //****************************************************************************************// // Copyright (c) 2002-2014, The MITRE Corporation // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this list // of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, this // list of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // * Neither the name of The MITRE Corporation nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //****************************************************************************************// #ifndef PASSWORDPROBE_H #define PASSWORDPROBE_H #include "AbsProbe.h" #include "Item.h" #include "Object.h" #include <pwd.h> #include <string> /** This class is responsible for collecting information about unix password_objects. */ class PasswordProbe : public AbsProbe { public: virtual ~PasswordProbe(); /** Get all the files on the system that match the pattern and collect their attributes. */ virtual ItemVector* CollectItems(Object* object); /** Return a new Item created for storing file information */ virtual Item* CreateItem(); /** Ensure that the PasswordProbe is a singleton. */ static AbsProbe* Instance(); private: PasswordProbe(); /** Creates an item from a passwd struct */ Item *CreateItemFromPasswd(struct passwd const *pwInfo); /** Finds a single item by name. */ Item *GetSingleItem(const std::string& username); /** Finds multiple items according to the given object entity. */ ItemVector *GetMultipleItems(Object *passwordObject); /** Singleton instance */ static PasswordProbe* instance; }; #endif
f387d41d0e3251ca4e290372f77e819aa8f41c08
8c8ea797b0821400c3176add36dd59f866b8ac3d
/AOJ/aoj0578.cpp
9b35642e4fd0541224a11ccbbf275376f137bc2c
[]
no_license
fushime2/competitive
d3d6d8e095842a97d4cad9ca1246ee120d21789f
b2a0f5957d8ae758330f5450306b629006651ad5
refs/heads/master
2021-01-21T16:00:57.337828
2017-05-20T06:45:46
2017-05-20T06:45:46
78,257,409
0
0
null
null
null
null
UTF-8
C++
false
false
682
cpp
#include <iostream> #include <cstdio> #include <algorithm> #include <string> using namespace std; int N; bool isName(string shop, string board) { int m = board.length(); for(int step=1; step<=m; step++) { for(int i=0; i<m; i++) { string s = ""; for(int j=i; j<m; j+=step) { s += board[j]; } if(s.find(shop) != string::npos) return true; } } return false; } int main(void) { cin >> N; string shop, board; cin >> shop; int ans = 0; for(int i=0; i<N; i++) { cin >> board; if(isName(shop, board)) ans++; } cout << ans << endl; return 0; }
19203a417004197a3b51e22fe5a3dc21d6bcd8c4
57f87cd5fb9448bc6cdbf10769365393efae3a00
/firmware_v5/telelogger/teleclient.h
a6433b87bd84452fb52cfd90b903677e97fb909f
[]
no_license
NatroNx/Freematics
6a366805aef406d6f4deae050414f9611bbe710e
011ae3212f57fdee7648eb34171e141c55a413ed
refs/heads/master
2020-03-25T02:15:51.919396
2018-07-31T13:14:23
2018-07-31T13:14:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,569
h
class TeleClient { public: virtual void reset() { txCount = 0; txBytes = 0; rxBytes = 0; } virtual bool notify(byte event, const char* serverKey, const char* payload = 0) { return true; } virtual bool connect() { return true; } virtual bool transmit(const char* packetBuffer, unsigned int packetSize) { return true; } virtual void inbound() {} virtual bool begin() { return true; } virtual void end() {} uint32_t txCount = 0; uint32_t txBytes = 0; uint32_t rxBytes = 0; uint32_t lastSyncTime = 0; uint32_t lastSentTime = 0; uint16_t feedid = 0; }; class TeleClientUDP : public TeleClient { public: bool notify(byte event, const char* serverKey, const char* payload = 0); bool connect(); bool transmit(const char* packetBuffer, unsigned int packetSize); void inbound(); bool verifyChecksum(char* data); #if NET_DEVICE == NET_WIFI UDPClientWIFI net; #elif NET_DEVICE == NET_SIM800 UDPClientSIM800 net; #elif NET_DEVICE == NET_SIM5360 UDPClientSIM5360 net; #elif NET_DEVICE == NET_SIM7600 UDPClientSIM7600 net; #else NullClient net; #endif }; class TeleClientHTTP : public TeleClient { public: bool connect(); bool transmit(const char* packetBuffer, unsigned int packetSize); #if NET_DEVICE == NET_WIFI HTTPClientWIFI net; #elif NET_DEVICE == NET_SIM800 HTTPClientSIM800 net; #elif NET_DEVICE == NET_SIM5360 HTTPClientSIM5360 net; #elif NET_DEVICE == NET_SIM7600 HTTPClientSIM7600 net; #else NullClient net; #endif };
2ccf5828b8559f26a0292a7e1ba3df44cb793dc8
55bfe899250607e99aa6ed20c5d688200ce4225f
/spot_real/Control/Teensy/SpotMiniMini/lib/ros_lib/moveit_msgs/MoveGroupActionGoal.h
bcb0e3ee2eff64549f920d6d8621e436564d2a4b
[ "MIT" ]
permissive
OpenQuadruped/spot_mini_mini
96aef59505721779aa543aab347384d7768a1f3e
c7e4905be176c63fa0e68a09c177b937e916fa60
refs/heads/spot
2022-10-21T04:14:29.882620
2022-10-05T21:33:53
2022-10-05T21:33:53
251,706,548
435
125
MIT
2022-09-02T07:06:56
2020-03-31T19:13:59
C++
UTF-8
C++
false
false
1,428
h
#ifndef _ROS_moveit_msgs_MoveGroupActionGoal_h #define _ROS_moveit_msgs_MoveGroupActionGoal_h #include <stdint.h> #include <string.h> #include <stdlib.h> #include "ros/msg.h" #include "std_msgs/Header.h" #include "actionlib_msgs/GoalID.h" #include "moveit_msgs/MoveGroupGoal.h" namespace moveit_msgs { class MoveGroupActionGoal : public ros::Msg { public: typedef std_msgs::Header _header_type; _header_type header; typedef actionlib_msgs::GoalID _goal_id_type; _goal_id_type goal_id; typedef moveit_msgs::MoveGroupGoal _goal_type; _goal_type goal; MoveGroupActionGoal(): header(), goal_id(), goal() { } virtual int serialize(unsigned char *outbuffer) const { int offset = 0; offset += this->header.serialize(outbuffer + offset); offset += this->goal_id.serialize(outbuffer + offset); offset += this->goal.serialize(outbuffer + offset); return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; offset += this->header.deserialize(inbuffer + offset); offset += this->goal_id.deserialize(inbuffer + offset); offset += this->goal.deserialize(inbuffer + offset); return offset; } const char * getType(){ return "moveit_msgs/MoveGroupActionGoal"; }; const char * getMD5(){ return "df11ac1a643d87b6e6a6fe5af1823709"; }; }; } #endif
77e95d74adb0d91068d318a9f567bd723eb4bd30
8a970882a0be9f3d85edbf6ecec0050b762e8d80
/GazEngine/gazengine/Entity.h
ded187d2149547f453fc7c141f5bfa9b3cc59aa9
[]
no_license
simplegsb/gazengine
472d1de8d300c8406ffec148844911fd21d5c1e0
b0a7300aa535b14494789fb88c16d6dda1c4e622
refs/heads/master
2016-09-05T21:02:49.531802
2013-04-29T08:33:16
2013-04-29T08:33:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,553
h
#ifndef ENTITY_H_ #define ENTITY_H_ #include <memory> #include <string> #include <vector> class Component; class Entity { public: static const unsigned short UNCATEGORIZED = 0; Entity(unsigned short category = UNCATEGORIZED, const std::string& name = std::string()); virtual ~Entity(); /** * <p> * Adds a component. * </p> * * @param component The component to add. */ void addComponent(Component* component); unsigned short getCategory() const; /** * <p> * Retrieves the components. * </p> * * @return The components. */ template<typename ComponentType> std::vector<ComponentType*> getComponents() const; unsigned int getId() const; /** * <p> * Retrieves the name of this <code>Entity</code>. * </p> * * @return The name of this <code>Entity</code>. */ const std::string& getName() const; /** * <p> * Retrieves a single component. * </p> * * @return The single component. */ template<typename ComponentType> ComponentType* getSingleComponent() const; /** * <p> * Removes a component. * </p> * * @param component The component to remove. */ void removeComponent(const Component& component); private: unsigned short category; /** * <p> * The components. * </p> */ std::vector<Component*> components; unsigned int id; /** * <p> * The name of this <code>Entity</code>. * </p> */ std::string name; static unsigned int nextId; }; #include "Entity.tpp" #endif /* ENTITY_H_ */
434ebd600ce44c7ba66bbb59c8173127dd69edb7
ad842c1f357e8e7146f0f241bcca4e2cad1e6375
/apps/gsvlabel/descriptor.cpp
1e17e7e4048e452658130f353795aa70dbbc2854
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
bmatejek/gsvgaps
19164523327e9fcccb83908fabdaa91cc6caabe7
4beb271167d306ad7e87b214895670f3d7c65dbd
refs/heads/main
2023-01-21T16:29:33.491450
2020-11-26T02:04:26
2020-11-26T02:04:26
316,090,459
0
0
null
null
null
null
UTF-8
C++
false
false
2,290
cpp
//////////////////////////////////////////////////////////////////////// // Source file for object descriptor class //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// // Include files //////////////////////////////////////////////////////////////////////// #include "object.h" //////////////////////////////////////////////////////////////////////// // Functions //////////////////////////////////////////////////////////////////////// ObjectDescriptor:: ObjectDescriptor(const double *values, int nvalues) : nvalues(nvalues), values(NULL) { // Initialize values if (nvalues > 0) { this->values = new double [ nvalues ]; for (int i = 0; i < nvalues; i++) { this->values[i] = (values) ? values[i] : 0.0; } } } ObjectDescriptor:: ObjectDescriptor(const ObjectDescriptor& descriptor) : nvalues(descriptor.nvalues), values(NULL) { // Initialize values if (nvalues > 0) { values = new double [ nvalues ]; for (int i = 0; i < nvalues; i++) { values[i] = descriptor.values[i]; } } } ObjectDescriptor:: ~ObjectDescriptor(void) { // Delete values if (values) delete [] values; } ObjectDescriptor& ObjectDescriptor:: operator=(const ObjectDescriptor& descriptor) { // Copy values Reset(descriptor.values, descriptor.nvalues); return *this; } void ObjectDescriptor:: Reset(const double *values, int nvalues) { // Delete old values if ((this->nvalues > 0) && (this->values)) { delete [] this->values; this->values = NULL; this->nvalues = 0; } // Assign new values if (nvalues > 0) { // Allocate new values this->nvalues = nvalues; this->values = new double [ this->nvalues ]; // Copy values for (int i = 0; i < nvalues; i++) { this->values[i] = (values) ? values[i] : 0.0; } } } double ObjectDescriptor:: SquaredDistance(const ObjectDescriptor& descriptor) const { // Check dimensionality assert(nvalues == descriptor.nvalues); // Sum squared distances double sum = 0; for (int i = 0; i < nvalues; i++) { double delta = values[i] - descriptor.values[i]; sum += delta * delta; } // Return squared distance return sum; }
c215bbe245ccb34412185018ca3f5d02da4e0b33
34b22618cc53750a239ee7d3c98314d8e9b19093
/framework/deprecated/core/cofiles/src/xercesc/XMLNode.cpp
dd4c70894a3fcc72010e7bf9a7fccc4302847f08
[]
no_license
ivan-kits/cframework
7beef16da89fb4f9559c0611863d05ac3de25abd
30015ddf1e5adccd138a2988455fe8010d1d9f50
refs/heads/master
2023-06-12T05:09:30.355989
2021-07-04T09:00:00
2021-07-04T09:00:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,369
cpp
#include "cofiles/XML/Xerces/XMLNode.h" #include <xercesc/parsers/XercesDOMParser.hpp> #include <xercesc/dom/DOMNamedNodeMap.hpp> #include <xercesc/dom/DOMNodeList.hpp> #include <xercesc/dom/DOMElement.hpp> #include <xercesc/dom/DOMException.hpp> #include <xercesc/dom/DOMImplementation.hpp> #include "cofiles/Makros.h" #include "cofiles/XML/Xerces/XMLElement.h" #include "cofiles/XML/Xerces/XMLText.h" using namespace CoFiles; XERCES_CPP_NAMESPACE_USE DOMNode* ToDOMNode( void* _pNode ) { DOMNode* pNode = static_cast< DOMNode* >( _pNode ); return pNode; } const DOMNode* ToDOMNode( const void* _pNode ) { const DOMNode* pNode = static_cast< const DOMNode* >( _pNode ); return pNode; } Xerces::XMLNode::XMLNode() : m_pNode( NULL ), m_eNodeType( XML_NODE_TYPE_NONE ) { } void Xerces::XMLNode::SetNodeType( XMLNodeType _eNodeType ) { m_eNodeType = _eNodeType; } XMLNodeType Xerces::XMLNode::GetNodeType() const { return m_eNodeType; } bool Xerces::XMLNode::IsValid() const { return GetXMLNode() != NULL; } bool Xerces::XMLNode::HasChildren() const { if( IsValid() ) { return !ToDOMNode( GetXMLNode() )->getChildNodes()->getLength(); } else { return false; } } XMLNodePtr Xerces::XMLNode::GetFirstChild() const { m_spFirstChild.reset(); if ( ToDOMNode( GetXMLNode() ) != NULL ) { DOMNode *pNode = ToDOMNode( GetXMLNode() )->getFirstChild(); while ( pNode != NULL && !IsValidXMLNode( pNode ) ) { pNode = pNode->getNextSibling(); } if ( pNode != NULL ) { m_spFirstChild = CreateNode( pNode ); } } return m_spFirstChild; } XMLNodePtr Xerces::XMLNode::GetNextSibling() const { m_spNextSibling.reset(); if ( GetXMLNode() == NULL ) { return XMLNodePtr(); } DOMNode *pNode = ToDOMNode( GetXMLNode() )->getNextSibling(); while( pNode != NULL && !IsValidXMLNode( pNode ) ) { pNode = pNode->getNextSibling(); } if ( pNode != NULL ) { m_spNextSibling = CreateNode( pNode ); } return m_spNextSibling; } void Xerces::XMLNode::InsertChildFirst( CoFiles::XMLNode& _clChildNode ) { if ( IsValid() ) { try { ToDOMNode( GetXMLNode() )->insertBefore( ToDOMNode( _clChildNode.GetXMLNode() ), NULL ); } catch ( const DOMException& e ) { CO_WARN( "XMLNode::InsertChildFirst: %s", XMLString::transcode( e.msg ) ); } } } void Xerces::XMLNode::InsertChildBefore( CoFiles::XMLNode& _clChildNode, CoFiles::XMLNode& _clBefore ) { if( IsValid() ) { ToDOMNode( GetXMLNode() )->insertBefore( ToDOMNode( _clChildNode.GetXMLNode() ), ToDOMNode( _clBefore.GetXMLNode() ) ); } } void Xerces::XMLNode::InsertChildAfter( CoFiles::XMLNode& _clChildNode, CoFiles::XMLNode& _clAfter ) { if( IsValid() ) { if( _clAfter.GetXMLNode() != NULL ) { ToDOMNode( GetXMLNode() )->insertBefore( ToDOMNode( _clChildNode.GetXMLNode() ), ToDOMNode( _clAfter.GetXMLNode() )->getNextSibling() ); } else { ToDOMNode( GetXMLNode() )->appendChild( ToDOMNode( _clChildNode.GetXMLNode() ) ); } } } void Xerces::XMLNode::InsertChildLast( CoFiles::XMLNode& _clChildNode ) { if( IsValid() ) { DOMNode* pDOMNode = ToDOMNode( GetXMLNode() ); DOMNode* pChildDOMNode = ToDOMNode( _clChildNode.GetXMLNode() ); if ( pDOMNode != NULL && pChildDOMNode != NULL ) { try { pDOMNode->appendChild( pChildDOMNode ); } catch ( const DOMException& e ) { CO_WARN( "XMLNode::InsertChildLast: %s", XMLString::transcode( e.msg ) ); } } } } bool Xerces::XMLNode::IsDocument() const { return m_eNodeType == DOCUMENT_NODE; } bool Xerces::XMLNode::IsElement() const { return m_eNodeType == ELEMENT_NODE; } bool Xerces::XMLNode::IsText() const { return m_eNodeType == TEXT_NODE; } const void* Xerces::XMLNode::GetXMLNode() const { return m_pNode; } void* Xerces::XMLNode::GetXMLNode() { return m_pNode; } void Xerces::XMLNode::SetXMLNode( void* pNode ) { m_pNode = ToDOMNode( pNode ); } XMLNodePtr Xerces::XMLNode::CreateNode( DOMNode* _pNode ) { if ( _pNode == NULL ) { return XMLNodePtr(); } CoFiles::XMLNodePtr spNewNode; if ( _pNode->getNodeType() == DOMNode::ELEMENT_NODE ) { XMLElement* pElement = new Xerces::XMLElement(); spNewNode = CoFiles::XMLNodePtr( pElement ); } else if ( _pNode->getNodeType() == DOMNode::TEXT_NODE ) { XMLText* pText = new Xerces::XMLText(); spNewNode = CoFiles::XMLNodePtr( pText ); } if ( spNewNode!= NULL ) { spNewNode->SetXMLNode( _pNode ); } return spNewNode; } bool Xerces::XMLNode::IsValidXMLNode( DOMNode* pNode ) { if ( pNode == NULL ) { return false; } if ( pNode->getNodeType() == DOMNode::COMMENT_NODE ) { return false; } else if ( pNode->getNodeType() == DOMNode::NOTATION_NODE ) { return false; } else if ( pNode->getNodeType() == DOMNode::TEXT_NODE ) { XMLText clTextNode; clTextNode.SetXMLNode( pNode ); String sText = clTextNode.GetText(); if( sText == "" ) { return false; } } return true; }
ca83a558bcc72c5055c6fbf661b26acbaf1aeb08
6701a2c3fb95baba0da5754b88d23f79a2b10f7f
/protocol/mcbp/libmcbp/mcbp_packet_printer.cc
6329b15ffaeaf2a08d698518c5c195e5ef3a5e8b
[]
no_license
teligent-ru/kv_engine
80630b4271d72df9c47b505a586f2e8275895d3e
4a1b741ee22ae3e7a46e21a423451c58186a2374
refs/heads/master
2018-11-07T20:52:54.132785
2018-01-15T16:34:10
2018-01-17T08:29:54
117,808,163
1
0
null
2018-01-17T08:34:05
2018-01-17T08:34:05
null
UTF-8
C++
false
false
4,594
cc
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2017 Couchbase, 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 <getopt.h> #include <mcbp/mcbp.h> #include <platform/dirutils.h> #include <platform/memorymap.h> #include <platform/sized_buffer.h> #include <algorithm> #include <iostream> enum class Format { Raw, Gdb, Lldb }; Format parseFormat(std::string format) { std::transform(format.begin(), format.end(), format.begin(), toupper); if (format == "RAW") { return Format::Raw; } if (format == "GDB") { return Format::Gdb; } if (format == "LLDB") { return Format::Lldb; } throw std::invalid_argument("Unknown format: " + format); } int main(int argc, char** argv) { Format format{Format::Raw}; static struct option longopts[] = { {"format", required_argument, nullptr, 'f'}, {nullptr, 0, nullptr, 0}}; int cmd; while ((cmd = getopt_long(argc, argv, "f:", longopts, nullptr)) != -1) { switch (cmd) { case 'f': try { format = parseFormat(optarg); } catch (const std::invalid_argument& e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } break; default: std::cerr << "Usage: " << cb::io::basename(argv[0]) << " [options] file1-n" << std::endl << std::endl << "\t--format=raw|gdb|lldb\tThe format for the input file" << std::endl << std::endl << "For gdb the expected output would be produced by " "executing: " << std::endl << std::endl << "(gdb) x /24xb c->rcurr" << std::endl << "0x7f43387d7e7a: 0x81 0x0d 0x00 0x00 0x00 0x00 0x00 0x00" << std::endl << "0x7f43387d7e82: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00" << std::endl << "0x7f43387d7e8a: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00" << std::endl << std::endl << "For lldb the expected output would be generated by " "executing: " << std::endl << std::endl << "(lldb) x -c 32 c->rbuf" << std::endl << "0x7f43387d7e7a: 81 0d 00 01 04 00 00 00 00 00 00 06 00 " "00 00 06 ................" << std::endl << "0x7f43387d7e7a: 14 bf f4 26 8a e0 00 00 00 00 00 00 61 " "61 81 0a ................" << std::endl << std::endl; return EXIT_FAILURE; } } if (optind == argc) { std::cerr << "No file specified" << std::endl; return EXIT_FAILURE; } while (optind < argc) { try { cb::byte_buffer buf; std::vector<uint8_t> data; cb::MemoryMappedFile map(argv[optind], cb::MemoryMappedFile::Mode::RDONLY); map.open(); buf = {static_cast<uint8_t*>(map.getRoot()), map.getSize()}; switch (format) { case Format::Raw: break; case Format::Gdb: data = cb::mcbp::gdb::parseDump(buf); buf = {data.data(), data.size()}; break; case Format::Lldb: data = cb::mcbp::lldb::parseDump(buf); buf = {data.data(), data.size()}; break; } cb::mcbp::dumpStream(buf, std::cout); } catch (const std::exception& error) { std::cerr << error.what() << std::endl; return EXIT_FAILURE; } ++optind; } return EXIT_SUCCESS; }
d46a3b3f4252a9ed58f62fd5e8068ade7c69129b
aa701c8621b90137f250151db3c74881767acb6d
/core/nes/mapper/042.cpp
20039b24a52dade8d098a2f5e8052ce2675d369c
[]
no_license
ptnnx/e-mulator-PSP
3215bbfe0870a41b341f207ba11a2d1fe2b64b56
538c700096fcef34bba9145750f7f9e44d3e7446
refs/heads/main
2023-02-05T09:57:34.046277
2020-12-31T08:59:04
2020-12-31T08:59:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,026
cpp
STATIC void NES_mapper42_Init(); STATIC void NES_mapper42_Reset(); STATIC void NES_mapper42_MemoryWrite(u32 addr, u8 data); STATIC void NES_mapper42_HSync(u32 scanline); ///////////////////////////////////////////////////////////////////// // Mapper 42 STATIC void NES_mapper42_Init() { g_NESmapper.Reset = NES_mapper42_Reset; g_NESmapper.MemoryWrite = NES_mapper42_MemoryWrite; g_NESmapper.HSync = NES_mapper42_HSync; } STATIC void NES_mapper42_Reset() { // set CPU bank pointers g_NESmapper.set_CPU_bank3(0); g_NESmapper.set_CPU_bank4(g_NESmapper.num_8k_ROM_banks-4); g_NESmapper.set_CPU_bank5(g_NESmapper.num_8k_ROM_banks-3); g_NESmapper.set_CPU_bank6(g_NESmapper.num_8k_ROM_banks-2); g_NESmapper.set_CPU_bank7(g_NESmapper.num_8k_ROM_banks-1); // set PPU bank pointers g_NESmapper.set_PPU_banks8(0,1,2,3,4,5,6,7); } STATIC void NES_mapper42_MemoryWrite(u32 addr, u8 data) { switch(addr & 0xE003) { case 0x8000: g_NESmapper.set_PPU_banks8(((data&0x1f)<<3)+0,((data&0x1f)<<3)+1,((data&0x1f)<<3)+2,((data&0x1f)<<3)+3,((data&0x1f)<<3)+4,((data&0x1f)<<3)+5,((data&0x1f)<<3)+6,((data&0x1f)<<3)+7); break; case 0xE000: { g_NESmapper.set_CPU_bank3(data & 0x0F); } break; case 0xE001: { if(data & 0x08) { g_NESmapper.set_mirroring2(NES_PPU_MIRROR_HORIZ); } else { g_NESmapper.set_mirroring2(NES_PPU_MIRROR_VERT); } } break; case 0xE002: { if(data & 0x02) { g_NESmapper.Mapper42.irq_enabled = 1; } else { g_NESmapper.Mapper42.irq_enabled = 0; g_NESmapper.Mapper42.irq_counter = 0; } } break; } // LOG("W " << HEX(addr,4) << " " << HEX(data,2) << endl); } STATIC void NES_mapper42_HSync(u32 scanline) { if(g_NESmapper.Mapper42.irq_enabled) { if(g_NESmapper.Mapper42.irq_counter < 215) { g_NESmapper.Mapper42.irq_counter++; } if(g_NESmapper.Mapper42.irq_counter == 215) { NES6502_DoIRQ(); g_NESmapper.Mapper42.irq_enabled = 0; } } } /////////////////////////////////////////////////////////////////////
7726abf0e5e7eb0906fdf74387dd474018ac3154
81f6419ea475836b1f1b24bcd2de77a316bc46a1
/codeforces/BEducational25-06-2020.cpp
03fd55ab7c09117fe485917441cb42c7ab252cb1
[]
no_license
Pramodjais517/competitive-coding
f4e0f6f238d98c0a39f8a9c940265f886ce70cb3
2a8ad013246f2db72a4dd53771090d931ab406cb
refs/heads/master
2023-02-25T12:09:47.382076
2021-01-28T06:57:26
2021-01-28T06:57:26
208,445,032
0
0
null
null
null
null
UTF-8
C++
false
false
1,335
cpp
#include<bits/stdc++.h> using namespace std; // template starts here #define ll long long #define ull unsigned long long #define rs reserve #define pb push_back #define ff first #define ss second #define mp make_pair #define fi(i,s,e,inc) for(auto i=s;i<e;i+=inc) #define fie(i,s,e,inc) for(auto i=s;i<=e;i+=inc) #define fd(i,s,e,dec) for(auto i=s;i>e;i-=dec) #define fde(i,s,e,dec) for(auto i=s;i>=e;i-=dec) #define itr(i,ar) for(auto i=ar.begin();i!=ar.end();i++) #define mod 1000000007 ll N = 1000000; vector<bool> prime(N+1,true); void sieve() { prime[0] = false,prime[1] = false; for(ll i=2;i*i <= N;i++) { if(prime[i]) { for(ll j = i*i; j<= N ;j+=i) prime[j] = false; } } } ll pow(ll a, ll b) { if(b==0) return 1; if(b==1) return a; ll r = pow(a,b/2); if(b&1) return r*a*r; return r*r; } // template ends here int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t; cin>>t; while(t--) { string s; cin>>s; ll n=0; ll a[s.length()]; memset(a,0,sizeof(a)); if(s[0]=='-') a[0] = -1; else a[0] = 1; fi(i,1,s.length(),1) { if(s[i]=='-') a[i] = a[i-1]-1; else a[i] = a[i-1] + 1; } ll b[s.length()]; fi(i,0,s.length(),1) { b[i] = (a[i] + i); } ll ans=0,i=0; while(i<s.length() and b[i]<0) { ans+=(i+1); i++; } ans+=s.length(); cout<<ans<<"\n"; } return 0; }
cb70bcdd5ff36e2a7d758db629c0ae1cdf415f34
6cc00c07a75bf18a2b1824383c3acc050098d9ed
/CodeChef/Easy/E0034.cpp
8b0e042dd591f11ae41cddc5d38bbbd3f36fd170
[ "MIT" ]
permissive
Mohammed-Shoaib/Coding-Problems
ac681c16c0f7c6d83f7cb46be71ea304d238344e
ccfb9fc2f0d8dff454439d75ce519cf83bad7c3b
refs/heads/master
2022-06-14T02:24:10.316962
2022-03-20T20:04:16
2022-03-20T20:04:16
145,226,886
75
31
MIT
2020-10-02T07:46:58
2018-08-18T14:31:33
C++
UTF-8
C++
false
false
372
cpp
// Problem Code: ALEXNUMB #include <iostream> #include <vector> using namespace std; long magicPairs(vector<int> &a){ long N = a.size(); return N*(N-1)/2; } int main(){ int T, n, num; vector<int> a; cin >> T; while(T--){ cin >> n; for(int i=0 ; i<n ; i++){ cin >> num; a.push_back(num); } cout << magicPairs(a) << endl; a.clear(); } return 0; }
7394745b36ae5104c00825320576a873b5d50654
c5ed2d57496cafa1b10925814b4fc670fb9d84af
/Opensankore/build-Sankore_3.1-Unnamed-Release/build/win32/release/moc/moc_UBExportCFF.cpp
ccd670b2c223a0e089afb0adb057245688ac9bac
[]
no_license
Educabile/Ardesia
5f5175fef5d7a15ea79469901bdd4c068cc8fec7
9b7b0bfe1c89e89c0ef28f93f6b1e0ac8c348230
refs/heads/master
2020-03-31T17:16:50.538146
2018-10-10T12:34:43
2018-10-10T12:34:43
152,416,207
0
0
null
null
null
null
UTF-8
C++
false
false
2,429
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'UBExportCFF.h' ** ** Created: Fri 4. May 12:28:36 2018 ** by: The Qt Meta Object Compiler version 63 (Qt 4.8.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../../../../Sankore-3.1/src/adaptors/UBExportCFF.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'UBExportCFF.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 63 #error "This file was generated using the moc from 4.8.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_UBExportCFF[] = { // content: 6, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount 0 // eod }; static const char qt_meta_stringdata_UBExportCFF[] = { "UBExportCFF\0" }; void UBExportCFF::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { Q_UNUSED(_o); Q_UNUSED(_id); Q_UNUSED(_c); Q_UNUSED(_a); } const QMetaObjectExtraData UBExportCFF::staticMetaObjectExtraData = { 0, qt_static_metacall }; const QMetaObject UBExportCFF::staticMetaObject = { { &UBExportAdaptor::staticMetaObject, qt_meta_stringdata_UBExportCFF, qt_meta_data_UBExportCFF, &staticMetaObjectExtraData } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &UBExportCFF::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *UBExportCFF::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void *UBExportCFF::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_UBExportCFF)) return static_cast<void*>(const_cast< UBExportCFF*>(this)); return UBExportAdaptor::qt_metacast(_clname); } int UBExportCFF::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = UBExportAdaptor::qt_metacall(_c, _id, _a); if (_id < 0) return _id; return _id; } QT_END_MOC_NAMESPACE
[ "salvatore.naddeo@€ducabile.it" ]
salvatore.naddeo@€ducabile.it
fdb075167409c531a8ffa63f4eb5c358ff9f4c08
8da9d3c3e769ead17f5ad4a4cba6fb3e84a9e340
/src/chila/lib/node/util.hpp
51b98169af1da8738e7ec4fea35fe3d0da6b3455
[]
no_license
blockspacer/chila
6884a540fafa73db37f2bf0117410c33044adbcf
b95290725b54696f7cefc1c430582f90542b1dec
refs/heads/master
2021-06-05T10:22:53.536352
2016-08-24T15:07:49
2016-08-24T15:07:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,721
hpp
/* Copyright 2011-2015 Roberto Daniel Gimenez Gamarra ([email protected]) * (C.I.: 1.439.390 - Paraguay) */ #ifndef CHILA_LIB_NODE__UTIL_HPP #define CHILA_LIB_NODE__UTIL_HPP #include <chila/lib/misc/util.hpp> #include "exceptions.hpp" #define my_assert CHILA_LIB_MISC__ASSERT #define CHILA_META_NODE__DEF_CHECK_BASES_ELEM(n, data, elem) \ chila::lib::node::checkAndAdd(list, [&]{ elem::check(newData.get()); }); #define CHILA_META_NODE__DEF_CHECK_BASES(Bases, defMyCheck) \ BOOST_PP_IF(defMyCheck, chila::lib::node::CheckDataUPtr createCheckData(chila::lib::node::CheckData *data) const;, ); \ BOOST_PP_IF(defMyCheck, void myCheck(chila::lib::node::CheckData *data = nullptr) const;, ); \ void check(chila::lib::node::CheckData *data = nullptr) const override \ { \ chila::lib::node::CheckExceptionList list; \ auto newData = BOOST_PP_IF(defMyCheck, createCheckData(data), chila::lib::node::CheckDataUPtr()); \ BOOST_PP_SEQ_FOR_EACH(CHILA_META_NODE__DEF_CHECK_BASES_ELEM,,Bases) \ BOOST_PP_IF(defMyCheck, BOOST_PP_IDENTITY(\ chila::lib::node::checkAndAdd(list, [&]{ myCheck(newData.get()); }); \ ), BOOST_PP_EMPTY)(); \ if (!list.exceptions.empty()) throw list; \ } #define CHILA_META_NODE__DEF_CHECK \ void check(chila::lib::node::CheckData *data = nullptr) const override; #include "nspDef.hpp" MY_NSP_START { template <typename CheckFun> void checkAndAdd(chila::lib::node::CheckExceptionList &list, const CheckFun &checkFun) try { checkFun(); } catch (ExceptionWrapper &ex) { list.add(ex.ex); } catch (CheckExceptionList &ex) { list.add(ex); } catch (Exception &ex) { list.add(ex); } chila::lib::misc::Path getNodePath(const Node &node); // to avoid cyclical dependency template <typename Fun> inline auto catchThrow(const Node &node, const Fun &fun) -> decltype(fun()) try { return fun(); } catch (const boost::exception &ex) { ex << chila::lib::misc::ExceptionInfo::Path(getNodePath(node)); throw; } template <typename ToType, typename Node> inline const ToType &castNode(const Node &node) try { return catchThrow(node, [&]() -> const ToType& { return chila::lib::misc::dynamicCast<ToType>(node); }); } catch (const boost::exception &ex) { InvalidNode exx; insert_error_info(chila::lib::misc::ExceptionInfo::TypeFrom) insert_error_info(chila::lib::misc::ExceptionInfo::TypeTo) insert_error_info(chila::lib::misc::ExceptionInfo::ActualType) insert_error_info(chila::lib::misc::ExceptionInfo::Path) BOOST_THROW_EXCEPTION(exx); } template <typename ToType, typename Node> inline ToType &castNode(Node &node) try { return catchThrow(node, [&]() -> ToType& { return chila::lib::misc::dynamicCast<ToType>(node); }); } catch (const boost::exception &ex) { InvalidNode exx; insert_error_info(chila::lib::misc::ExceptionInfo::TypeFrom) insert_error_info(chila::lib::misc::ExceptionInfo::TypeTo) insert_error_info(chila::lib::misc::ExceptionInfo::ActualType) insert_error_info(chila::lib::misc::ExceptionInfo::Path) BOOST_THROW_EXCEPTION(exx); } NodeWithChildren &mainParent(NodeWithChildren &node); PathVec getReferences( NodeWithChildren &node, const chila::lib::misc::Path &path); void replaceReferences(NodeWithChildren &node, const PathVec &paths, const Node &newRefNode); } MY_NSP_END #include "nspUndef.hpp" #endif
3839e99ec45940f1c94baf2131e7849a8871b51c
4f37081ed62e44afa0b2465388a8adf9b5490b13
/ash/login/ui/login_user_view.h
4d27549c5a7f8e8dda6fd0bc769f65efd3439630
[ "BSD-3-Clause" ]
permissive
zowhair/chromium
05b9eed58a680941c3595d52c3c77b620ef2c3ac
d84d5ef83e401ec210fcb14a92803bf339e1ccce
refs/heads/master
2023-03-04T23:15:10.914156
2018-03-15T11:27:44
2018-03-15T11:27:44
125,359,706
1
0
null
2018-03-15T11:50:44
2018-03-15T11:50:43
null
UTF-8
C++
false
false
3,544
h
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ASH_LOGIN_UI_LOGIN_USER_VIEW_H_ #define ASH_LOGIN_UI_LOGIN_USER_VIEW_H_ #include "ash/ash_export.h" #include "ash/login/ui/login_display_style.h" #include "ash/public/interfaces/login_user_info.mojom.h" #include "base/macros.h" #include "ui/views/controls/button/button.h" #include "ui/views/view.h" namespace ash { class HoverNotifier; class LoginBubble; class LoginButton; // Display the user's profile icon, name, and a menu icon in various layout // styles. class ASH_EXPORT LoginUserView : public views::View, public views::ButtonListener { public: // TestApi is used for tests to get internal implementation details. class ASH_EXPORT TestApi { public: explicit TestApi(LoginUserView* view); ~TestApi(); LoginDisplayStyle display_style() const; const base::string16& displayed_name() const; views::View* user_label() const; views::View* tap_button() const; bool is_opaque() const; private: LoginUserView* const view_; }; using OnTap = base::RepeatingClosure; // Returns the width of this view for the given display style. static int WidthForLayoutStyle(LoginDisplayStyle style); LoginUserView(LoginDisplayStyle style, bool show_dropdown, bool show_domain, const OnTap& on_tap); ~LoginUserView() override; // Update the user view to display the given user information. void UpdateForUser(const mojom::LoginUserInfoPtr& user, bool animate); // Set if the view must be opaque. void SetForceOpaque(bool force_opaque); // Enables or disables tapping the view. void SetTapEnabled(bool enabled); const mojom::LoginUserInfoPtr& current_user() const { return current_user_; } // views::View: const char* GetClassName() const override; gfx::Size CalculatePreferredSize() const override; void Layout() override; // views::ButtonListener: void ButtonPressed(views::Button* sender, const ui::Event& event) override; private: class UserDomainInfoView; class UserImage; class UserLabel; class TapButton; // Called when hover state changes. void OnHover(bool has_hover); // Updates UI element values so they reflect the data in |current_user_|. void UpdateCurrentUserState(); // Updates view opacity based on input state and |force_opaque_|. void UpdateOpacity(); void SetLargeLayout(); void SetSmallishLayout(); // Executed when the user view is pressed. OnTap on_tap_; // The user that is currently being displayed (or will be displayed when an // animation completes). mojom::LoginUserInfoPtr current_user_; // Used to dispatch opacity update events. std::unique_ptr<HoverNotifier> hover_notifier_; LoginDisplayStyle display_style_; UserImage* user_image_ = nullptr; UserLabel* user_label_ = nullptr; LoginButton* user_dropdown_ = nullptr; TapButton* tap_button_ = nullptr; std::unique_ptr<LoginBubble> user_menu_; // Show the domain information for public account user. UserDomainInfoView* user_domain_ = nullptr; // True iff the view is currently opaque (ie, opacity = 1). bool is_opaque_ = false; // True if the view must be opaque (ie, opacity = 1) regardless of input // state. bool force_opaque_ = false; DISALLOW_COPY_AND_ASSIGN(LoginUserView); }; } // namespace ash #endif // ASH_LOGIN_UI_LOGIN_USER_VIEW_H_
b563f5db9b84bcb6839aacebc6f4c582b248900b
424d9d65e27cd204cc22e39da3a13710b163f4e7
/chrome/browser/ui/views/frame/tab_strip_region_view.h
96ccf699770a115e0ce3985d40a4dc5a9fae614d
[ "BSD-3-Clause" ]
permissive
bigben0123/chromium
7c5f4624ef2dacfaf010203b60f307d4b8e8e76d
83d9cd5e98b65686d06368f18b4835adbab76d89
refs/heads/master
2023-01-10T11:02:26.202776
2020-10-30T09:47:16
2020-10-30T09:47:16
275,543,782
0
0
BSD-3-Clause
2020-10-30T09:47:18
2020-06-28T08:45:11
null
UTF-8
C++
false
false
2,458
h
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_TAB_STRIP_REGION_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_FRAME_TAB_STRIP_REGION_VIEW_H_ #include "chrome/browser/ui/views/tabs/tab_strip.h" #include "ui/views/accessible_pane_view.h" class TabSearchButton; class TabStrip; // Container for the tabstrip, new tab button, and reserved grab handle space. class TabStripRegionView final : public views::AccessiblePaneView, views::ViewObserver { public: explicit TabStripRegionView(std::unique_ptr<TabStrip> tab_strip); ~TabStripRegionView() override; // Returns true if the specified rect intersects the window caption area of // the browser window. |rect| is in the local coordinate space // of |this|. bool IsRectInWindowCaption(const gfx::Rect& rect); // A convenience function which calls |IsRectInWindowCaption()| with a rect of // size 1x1 and an origin of |point|. |point| is in the local coordinate space // of |this|. bool IsPositionInWindowCaption(const gfx::Point& point); // Called when the colors of the frame change. void FrameColorsChanged(); TabSearchButton* tab_search_button() { return tab_search_button_; } // views::AccessiblePaneView: const char* GetClassName() const override; void ChildPreferredSizeChanged(views::View* child) override; gfx::Size GetMinimumSize() const override; void OnThemeChanged() override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override; views::View* GetDefaultFocusableChild() override; // views::ViewObserver: void OnViewPreferredSizeChanged(View* view) override; // TODO(958173): Override OnBoundsChanged to cancel tabstrip animations. private: DISALLOW_COPY_AND_ASSIGN(TabStripRegionView); int CalculateTabStripAvailableWidth(); // Scrolls the tabstrip towards the first tab in the tabstrip. void ScrollTowardsLeadingTab(); // Scrolls the tabstrip towards the last tab in the tabstrip. void ScrollTowardsTrailingTab(); views::View* tab_strip_container_; views::View* reserved_grab_handle_space_; TabStrip* tab_strip_; TabSearchButton* tab_search_button_ = nullptr; views::ImageButton* leading_scroll_button_; views::ImageButton* trailing_scroll_button_; }; #endif // CHROME_BROWSER_UI_VIEWS_FRAME_TAB_STRIP_REGION_VIEW_H_
378d41da667801b00bd623eb7fc43dcdb5cc28d6
2bd4fa284f4c891fa35b7465449ea04534ea01fb
/hdmaproifilter/src/perception/lib/base/registerer.cpp
6c5407d1b73c0605cbf0c3b88b4f854a302b290e
[]
no_license
Playfish/apollo_perception
cdd74e4a802159ceadc513e9f46ae1799e911ba1
6a50f529f0f6d789d2a06077480e79c9f4bc68c8
refs/heads/master
2021-09-14T13:42:07.159927
2018-05-14T13:51:20
2018-05-14T13:51:20
113,520,993
1
0
null
null
null
null
UTF-8
C++
false
false
1,536
cpp
/****************************************************************************** * Copyright 2017 The Apollo Authors. 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 "perception/lib/base/registerer.h" #include <string> #include <vector> namespace apollo { namespace perception { BaseClassMap& GlobalFactoryMap() { static BaseClassMap factory_map; return factory_map; } bool GetRegisteredClasses( const std::string& base_class_name, std::vector<std::string>* registered_derived_classes_names) { CHECK_NOTNULL(registered_derived_classes_names); BaseClassMap& map = GlobalFactoryMap(); auto iter = map.find(base_class_name); if (iter == map.end()) { AERROR << "class not registered:" << base_class_name; return false; } for (auto pair : iter->second) { registered_derived_classes_names->push_back(pair.first); } return true; } } // namespace perception } // namespace apollo
534e4d3031dc97052ded75575351d0ed28da9bfb
0d653408de7c08f1bef4dfba5c43431897097a4a
/cmajor/cmbs/Error.cpp
5cb9fc81316595d5daf239f5c41f65152671bd75
[]
no_license
slaakko/cmajorm
948268634b8dd3e00f86a5b5415bee894867b17c
1f123fc367d14d3ef793eefab56ad98849ee0f25
refs/heads/master
2023-08-31T14:05:46.897333
2023-08-11T11:40:44
2023-08-11T11:40:44
166,633,055
7
2
null
null
null
null
UTF-8
C++
false
false
2,609
cpp
// ================================= // Copyright (c) 2022 Seppo Laakko // Distributed under the MIT license // ================================= #include <cmajor/cmbs/Error.hpp> #include <cmajor/symbols/Module.hpp> #include <cmajor/symbols/ModuleCache.hpp> #include <soulng/util/Unicode.hpp> namespace cmbs { using namespace soulng::unicode; CompileError ParsingExceptionToError(const soulng::lexer::ParsingException& ex) { CompileError error; error.message = ex.Message(); error.project = ex.Project(); error.file = ex.FileName(); soulng::lexer::Span span = ex.GetSpan(); error.line = span.line; cmajor::symbols::Module* mod = static_cast<cmajor::symbols::Module*>(ex.Module()); if (mod) { int startCol = 0; int endCol = 0; mod->GetColumns(span, startCol, endCol); error.scol = startCol; error.ecol = endCol; } return error; } std::vector<CompileError> SymbolsExceptionToErrors(const cmajor::symbols::Exception& ex) { std::vector<CompileError> errors; CompileError mainError; mainError.message = ex.Message(); cmajor::symbols::Module* mod = cmajor::symbols::GetModuleById(ex.DefinedModuleId()); if (mod) { Span span = ex.Defined(); std::u32string code = mod->GetErrorLines(span); mainError.message.append("\n").append(ToUtf8(code)); mainError.project = ToUtf8(mod->Name()); mainError.file = mod->GetFilePath(span.fileIndex); mainError.line = span.line; int startCol = 0; int endCol = 0; mod->GetColumns(span, startCol, endCol); mainError.scol = startCol; mainError.ecol = endCol; } errors.push_back(mainError); for (const std::pair<Span, boost::uuids::uuid>& spanModuleId : ex.References()) { CompileError referenceError; referenceError.message = "See:"; cmajor::symbols::Module* mod = cmajor::symbols::GetModuleById(spanModuleId.second); if (mod) { std::u32string code = mod->GetErrorLines(spanModuleId.first); referenceError.message.append("\n").append(ToUtf8(code)); referenceError.file = mod->GetFilePath(spanModuleId.first.fileIndex); referenceError.line = spanModuleId.first.line; int startCol = 0; int endCol = 0; mod->GetColumns(spanModuleId.first, startCol, endCol); referenceError.scol = startCol; referenceError.ecol = endCol; errors.push_back(referenceError); } } return errors; } } // namespace cmbs
594e71c07f5c14b0e47d84c3887fb2634517984c
7a5a713cc999fdc1f64457949b003980e288567a
/Classes/ExplodeSmoke.h
a878d13147d91a026074988ee4903c9dfe3be564
[]
no_license
highfence/ShootingGameProject
2b564d09ea02ae64fb65d85b59ecb6e0d170ec53
61e57136d52e8b1d980eec304dd474774f239f94
refs/heads/master
2021-01-20T12:28:31.574956
2017-04-05T06:49:42
2017-04-05T06:49:42
82,655,552
0
0
null
2017-03-16T10:04:44
2017-02-21T08:33:06
C++
UTF-8
C++
false
false
328
h
#pragma once #include "Effect.h" class ExplodeSmoke : public Effect { public : ExplodeSmoke() = delete; ExplodeSmoke(const _In_ Vec); ExplodeSmoke( const _In_ Vec, const _In_ FLOAT, const _In_ Vec); ~ExplodeSmoke(); private : void init(); void LoadInitialImg() override; void InitialDataSubstitude() override; };
4f382278b8d5b2babc07007ecf53e4df951a580f
fc087820e4dc33146341cd6b71a000c227cda819
/Majority Element II.cpp
8f6a0b3226ec9ceea590fa7c8715ee973817c422
[]
no_license
jyqi/leetcode
1396b27fd97aa29687392dceda2e0bed2dc8fd31
9682e03fa91dca44654439029fb11d73e86a61d8
refs/heads/master
2022-02-16T09:14:54.012699
2022-02-14T07:54:11
2022-02-14T07:54:11
56,414,779
0
0
null
null
null
null
UTF-8
C++
false
false
1,032
cpp
#include <iostream> #include <vector> using namespace std; class Solution { public: vector<int> majorityElement(vector<int>& nums) { int cnt1 = 0, cnt2 = 0, maj1 = 0, maj2 = 0; int len = nums.size(); vector<int> res; //cout << 1 << endl; for(int i = 0; i < len; i++) { if(cnt1 == 0 && nums[i] != maj2) { maj1 = nums[i]; cnt1 = 1; } else if(nums[i] == maj1) { cnt1++; } else if(cnt2 == 0 && nums[i] != maj1) { maj2 = nums[i]; cnt2 = 1; } else if(nums[i] == maj2) { cnt2++; } else { cnt1--; cnt2--; } } cnt1 = cnt2 = 0; for(int i = 0; i < len; i++) { if(nums[i] == maj1) cnt1++; else if(nums[i] == maj2) cnt2++; } if(cnt1 > len / 3) res.push_back(maj1); if(cnt2 > len / 3) res.push_back(maj2); return res; } }; int main() { int arr[] = {1, 2, 1, 2, 1, 3, 3}; Solution s; vector<int> v(arr, arr + 7); vector<int> res; res = s.majorityElement(v); for(int i = 0; i < res.size(); i++) { cout << res[i] << endl; } return 0; }
48c0f65f815f5a8f95648c04f8d7974b965a502f
a88750ab34c33c8a00a7d653205c15fd429aac94
/src/bip32/hdwalletutil.cpp
15c54a63cda010516a0f02bb86512a3b6f4d10dd
[ "MIT" ]
permissive
FromHDDtoSSD/SorachanCoin-qt
8ccb4b1341b0e8228f93e101b75f741b99d49de0
9dff8dccd71518eea9a1ff80671cccf31915ca09
refs/heads/master
2022-09-08T01:14:20.838440
2022-08-27T16:39:36
2022-08-27T16:39:36
144,701,661
9
3
null
null
null
null
UTF-8
C++
false
false
3,845
cpp
// Copyright (c) 2017-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <bip32/hdwalletutil.h> #include <util/logging.h> #include <util/system.h> #include <util/args.h> fs::path hdwalletutil::GetWalletDir() { fs::path path; if (ARGS.IsArgSet("-walletdir")) { path = ARGS.GetArg("-walletdir", ""); if (! fs::is_directory(path)) { // If the path specified doesn't exist, we return the deliberately // invalid empty string. path = ""; } } else { path = lutil::GetDataDir(); // If a wallets directory exists, use that, otherwise default to GetDataDir if (fs::is_directory(path / "wallets")) { path /= "wallets"; } } return path; } static bool IsBerkeleyBtree(const fs::path &path) { // A Berkeley DB Btree file has at least 4K. // This check also prevents opening lock files. boost::system::error_code ec; auto size = fs::file_size(path, ec); if (ec) logging::LogPrintf("%s: %s %s\n", __func__, ec.message(), path.string()); if (size < 4096) return false; fsbridge::ifstream file(path, std::ios::binary); if (! file.is_open()) return false; file.seekg(12, std::ios::beg); // Magic bytes start at offset 12 uint32_t data = 0; file.read((char*) &data, sizeof(data)); // Read 4 bytes of file to compare against magic // Berkeley DB Btree magic bytes, from: // https://github.com/file/file/blob/5824af38469ec1ca9ac3ffd251e7afe9dc11e227/magic/Magdir/database#L74-L75 // - big endian systems - 00 05 31 62 // - little endian systems - 62 31 05 00 return data == 0x00053162 || data == 0x62310500; } std::vector<fs::path> hdwalletutil::ListWalletDir() { const fs::path wallet_dir = GetWalletDir(); const size_t offset = wallet_dir.string().size() + 1; std::vector<fs::path> paths; boost::system::error_code ec; for (auto it = fs::recursive_directory_iterator(wallet_dir, ec); it != fs::recursive_directory_iterator(); it.increment(ec)) { if (ec) { logging::LogPrintf("%s: %s %s\n", __func__, ec.message(), it->path().string()); continue; } // Get wallet path relative to walletdir by removing walletdir from the wallet path. // This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60. const fs::path path = it->path().string().substr(offset); if (it->status().type() == fs::directory_file && IsBerkeleyBtree(it->path() / "wallet.dat")) { // Found a directory which contains wallet.dat btree file, add it as a wallet. paths.emplace_back(path); } else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && IsBerkeleyBtree(it->path())) { if (it->path().filename() == "wallet.dat") { // Found top-level wallet.dat btree file, add top level directory "" // as a wallet. paths.emplace_back(); } else { // Found top-level btree file not called wallet.dat. Current bitcoin // software will never create these files but will allow them to be // opened in a shared database environment for backwards compatibility. // Add it to the list of available wallets. paths.emplace_back(path); } } } return paths; } hdwalletutil::WalletLocation::WalletLocation(const std::string &name) : m_name(name) , m_path(fs::absolute(name, GetWalletDir())) { } bool hdwalletutil::WalletLocation::Exists() const { return fs::symlink_status(m_path).type() != fs::file_not_found; }
c00af421b2b38fc9ea7376fde3f61ce25a7df7cf
258cb026f59dff826ada21702e6efa3f952981c4
/Test/frametest/frametest/P2C5_LitPyramid.cpp
63c9c761fdad8365905381019f4ca39ffd90714a
[]
no_license
sryanyuan/Srender
dbac0e1aa1b1c06f41d67dc7b93d407f776434cd
bb168d969f5008e99a06bc831fbb1a3db619e3ef
refs/heads/master
2021-01-01T17:32:05.017317
2014-08-14T08:06:53
2014-08-14T08:06:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,298
cpp
#include "stdafx.h" #include "P2C5_LitPyramid.h" #include <core/SRColor.h> ////////////////////////////////////////////////////////////////////////// void CalculateNormal(D3DXVECTOR3* _pOut, const D3DXVECTOR3* _p0, const D3DXVECTOR3* _p1, const D3DXVECTOR3* _p2) { D3DXVECTOR3 u = *_p1 - *_p0; D3DXVECTOR3 v = *_p2 - *_p0; // left hand coordinate system... D3DXVec3Cross(_pOut, &u, &v); D3DXVec3Normalize(_pOut, _pOut); } ////////////////////////////////////////////////////////////////////////// LitPyramid::LitPyramid() { m_pVB = NULL; } LitPyramid::~LitPyramid() { } bool LitPyramid::OnEnvCreate() { m_pVB = Gfx_CreateVertexBuffer<SRNormalVertex>(4 * 3); if(NULL == m_pVB) { return false; } SRNormalVertex* pVertex = NULL; m_pVB->Lock(0, 0, (void**)&pVertex, 0); // front side D3DXVECTOR3 v0; D3DXVECTOR3 v1; D3DXVECTOR3 v2; D3DXVECTOR3 vn; pVertex[0] = SRNormalVertex(-1.0f, 0.0f, -1.0f); pVertex[1] = SRNormalVertex(0.0f, 1.0f, 0.0f); pVertex[2] = SRNormalVertex(1.0f, 0.0f, -1.0f); v0.x = pVertex[0].GetX(); v0.y = pVertex[0].GetY(); v0.z = pVertex[0].GetZ(); v1.x = pVertex[1].GetX(); v1.y = pVertex[1].GetY(); v1.z = pVertex[1].GetZ(); v2.x = pVertex[2].GetX(); v2.y = pVertex[2].GetY(); v2.z = pVertex[2].GetZ(); CalculateNormal(&vn, &v0, &v1, &v2); pVertex[0].SetNormalXYZ(vn.x, vn.y, vn.z); pVertex[1].SetNormalXYZ(vn.x, vn.y, vn.z); pVertex[2].SetNormalXYZ(vn.x, vn.y, vn.z); // left side pVertex[3] = SRNormalVertex(-1.0f, 0.0f, 1.0f); pVertex[4] = SRNormalVertex(0.0f, 1.0f, 0.0f); pVertex[5] = SRNormalVertex(-1.0f, 0.0f, -1.0f); v0.x = pVertex[3].GetX(); v0.y = pVertex[3].GetY(); v0.z = pVertex[3].GetZ(); v1.x = pVertex[4].GetX(); v1.y = pVertex[4].GetY(); v1.z = pVertex[4].GetZ(); v2.x = pVertex[5].GetX(); v2.y = pVertex[5].GetY(); v2.z = pVertex[5].GetZ(); CalculateNormal(&vn, &v0, &v1, &v2); pVertex[3].SetNormalXYZ(vn.x, vn.y, vn.z); pVertex[4].SetNormalXYZ(vn.x, vn.y, vn.z); pVertex[5].SetNormalXYZ(vn.x, vn.y, vn.z); // right side pVertex[6] = SRNormalVertex(1.0f, 0.0f, -1.0f); pVertex[7] = SRNormalVertex(0.0f, 1.0f, 0.0f); pVertex[8] = SRNormalVertex(1.0f, 0.0f, 1.0f); v0.x = pVertex[6].GetX(); v0.y = pVertex[6].GetY(); v0.z = pVertex[6].GetZ(); v1.x = pVertex[7].GetX(); v1.y = pVertex[7].GetY(); v1.z = pVertex[7].GetZ(); v2.x = pVertex[8].GetX(); v2.y = pVertex[8].GetY(); v2.z = pVertex[8].GetZ(); CalculateNormal(&vn, &v0, &v1, &v2); pVertex[6].SetNormalXYZ(vn.x, vn.y, vn.z); pVertex[7].SetNormalXYZ(vn.x, vn.y, vn.z); pVertex[8].SetNormalXYZ(vn.x, vn.y, vn.z); // back side pVertex[9] = SRNormalVertex(1.0f, 0.0f, 1.0f); pVertex[10] = SRNormalVertex(0.0f, 1.0f, 0.0f); pVertex[11] = SRNormalVertex(-1.0f, 0.0f, 1.0f); v0.x = pVertex[9].GetX(); v0.y = pVertex[9].GetY(); v0.z = pVertex[9].GetZ(); v1.x = pVertex[10].GetX(); v1.y = pVertex[10].GetY(); v1.z = pVertex[10].GetZ(); v2.x = pVertex[11].GetX(); v2.y = pVertex[11].GetY(); v2.z = pVertex[11].GetZ(); CalculateNormal(&vn, &v0, &v1, &v2); pVertex[9].SetNormalXYZ(vn.x, vn.y, vn.z); pVertex[10].SetNormalXYZ(vn.x, vn.y, vn.z); pVertex[11].SetNormalXYZ(vn.x, vn.y, vn.z); m_pVB->Unlock(); m_pD3Dev9->SetRenderState(D3DRS_LIGHTING, TRUE); D3DMATERIAL9 mtrl; mtrl.Ambient = SRColor::GetCommonColor(SRColor::CC_WHITE); mtrl.Diffuse = SRColor::GetCommonColor(SRColor::CC_WHITE); mtrl.Specular = SRColor::GetCommonColor(SRColor::CC_WHITE); mtrl.Emissive = SRColor::GetCommonColor(SRColor::CC_BLACK); mtrl.Power = 5.0f; m_pD3Dev9->SetMaterial(&mtrl); D3DLIGHT9 lgt; ZeroMemory(&lgt, sizeof(lgt)); lgt.Type = D3DLIGHT_DIRECTIONAL; lgt.Diffuse = SRColor::GetCommonColor(SRColor::CC_WHITE); lgt.Specular = SRColor::GetCommonColor(SRColor::CC_WHITE) * 0.3f; lgt.Ambient = SRColor::GetCommonColor(SRColor::CC_WHITE) * 0.6f; lgt.Direction = D3DXVECTOR3(1.0f, 0.0f, 0.0f); m_pD3Dev9->SetLight(0, &lgt); m_pD3Dev9->LightEnable(0, TRUE); m_pD3Dev9->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE); m_pD3Dev9->SetRenderState(D3DRS_SPECULARENABLE, TRUE); D3DXVECTOR3 pos(0.0f, 1.0f, -3.0f); Gfx_SetViewTransform(&pos); Gfx_SetProjectionTransform(); return true; } void LitPyramid::OnEnvDestroy() { SSAFE_RELEASE(m_pVB); } void LitPyramid::OnDrawFrame() { SRRenderApp* pApp = SRRenderApp::GetInstancePtr(); static float s_fRotateY = 0.0f; s_fRotateY += pApp->GetTimeDelta(); static float s_fRotateX = 0.0f; s_fRotateX += pApp->GetTimeDelta() * 0.5f; D3DXMATRIX roty; D3DXMatrixRotationY(&roty, s_fRotateY); D3DXMATRIX rotx; D3DXMatrixRotationX(&rotx, s_fRotateX); D3DXMATRIX rot = rotx * roty; if(s_fRotateY > 6.28f) { s_fRotateY = 0.0f; } if(s_fRotateX > 6.28f) { s_fRotateX = 0.0f; } m_pD3Dev9->SetTransform(D3DTS_WORLD, &roty); m_pD3Dev9->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0); m_pD3Dev9->BeginScene(); m_pD3Dev9->SetStreamSource(0, m_pVB, 0, sizeof(SRNormalVertex)); m_pD3Dev9->SetFVF(SRNormalVertex::FVF); m_pD3Dev9->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 4); m_pD3Dev9->EndScene(); m_pD3Dev9->Present(0, 0, 0, 0); }
c0b9cd92c56f6f91ed9a7a6f7b5ae7a03a9d9b74
406b6f3e8355bcab9add96f3cff044823186fe37
/src/Simulation/osg_2d_simulation/quad.cpp
01c1fcc1ce18c295f1b29ec90b3b6adace8f46c2
[]
no_license
Micalson/puppet
96fd02893f871c6bbe0abff235bf2b09f14fe5d9
d51ed9ec2f2e4bf65dc5081a9d89d271cece28b5
refs/heads/master
2022-03-28T22:43:13.863185
2019-12-26T13:52:00
2019-12-26T13:52:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,295
cpp
#include "quad.h" #include <osgWrapper\UtilCreator.h> Quad::Quad() { m_node = new OSGWrapper::QuadAttributeUtilNode(1); m_geometry = OSGWrapper::UtilCreator::CreateUnitQuad(); m_node->AddChild(m_geometry); } Quad::~Quad() { } void Quad::SetOffset(const osg::Vec2f& offset) { m_offset = offset; UpdateGeometry(); } void Quad::SetSize(const osg::Vec2f& size) { m_size = size; UpdateGeometry(); } void Quad::SetRect(const osg::Vec2f& offset, const osg::Vec2f& size) { m_offset = offset; m_size = size; UpdateGeometry(); } void Quad::UpdateGeometry() { osg::Vec2Array* coord_array = dynamic_cast<osg::Vec2Array*>(m_geometry->getVertexAttribArray(0)); if (coord_array) { coord_array->at(0) = m_offset; coord_array->at(1) = m_offset + osg::Vec2f(m_size.x(), 0.0f); coord_array->at(2) = m_offset + osg::Vec2f(m_size.x(), m_size.y()); coord_array->at(3) = m_offset + osg::Vec2f(0.0f, m_size.y()); coord_array->dirty(); } } OSGWrapper::QuadAttributeUtilNode* Quad::Generate() { return m_node; } OSGWrapper::UIQuad* Quad::HitTest(float x, float y) { OSGWrapper::UIQuad* q = OSGWrapper::UIQuad::HitTest(x, y); if (q) return q; if (x >= m_offset.x() && x <= m_offset.x() + m_size.x() && y >= m_offset.y() && y <= m_offset.y() + m_size.y()) return this; return 0; }
24db047e3e13fafc5ddd4547fc9e46520a696d7f
b301ab714ad4d4625d4a79005a1bda6456a283ec
/UVa/334.cpp
f025069dbdd616fd733ba2408d048555a145a5a6
[]
no_license
askeySnip/OJ_records
220fd83d406709328e8450df0f6da98ae57eb2d9
4b77e3bb5cf19b98572fa6583dff390e03ff1a7c
refs/heads/master
2022-06-26T02:14:34.957580
2022-06-11T13:56:33
2022-06-11T13:56:33
117,955,514
1
0
null
null
null
null
UTF-8
C++
false
false
2,302
cpp
/* ID: leezhen TASK: practice LANG: C++11 */ #include <iostream> #include <fstream> #include <string> #include <vector> #include <algorithm> #include <cstdio> #include <cstring> #include <set> #include <map> #include <stack> #include <queue> #include <cmath> #include <bitset> using namespace std; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<pair<int, int> > vii; // struct #define inf 1e6 // data int nc, ne, nm; int dist[404][404]; char e[2][10]; vector<string> vstr; map<string, int> mpsi; int main() { int kase = 0; while(scanf("%d", &nc), nc) { mpsi.clear(); vstr.clear(); for(int i=0; i<404; i++) { for(int j=0; j<404; j++) { if(i == j) dist[i][j] = 0; else dist[i][j] = inf; } } for(int i=0; i<nc; i++) { scanf("%d", &ne); scanf("%s", e[0]); if(mpsi.find(e[0]) == mpsi.end()) { vstr.push_back(e[0]); mpsi[e[0]] = vstr.size()-1; } int last = 0; for(int j=1; j<ne; j++) { scanf("%s", e[1-last]); if(mpsi.find(e[1-last]) == mpsi.end()) { mpsi[e[1-last]] = vstr.size(); vstr.push_back(e[1-last]); } dist[mpsi[e[last]]][mpsi[e[1-last]]] = 1; last = 1-last; } } scanf("%d", &nm); for(int i=0; i<nm; i++) { scanf("%s %s", e[0], e[1]); dist[mpsi[e[0]]][mpsi[e[1]]] = 1; } int n = vstr.size(); 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]) { dist[i][j] = dist[i][k] + dist[k][j]; } } } } vii ans; for(int i=0; i<n; i++) { for(int j=i+1; j<n; j++) { if(dist[i][j] == inf && dist[j][i] == inf) ans.push_back(ii(i, j)); } } if(ans.empty())printf("Case %d, no concurrent events.\n", ++kase); else { printf("Case %d, %d concurrent events:\n", ++kase, (int)ans.size()); if((int)ans.size() == 1) { printf("(%s,%s) \n", vstr[ans[0].first].c_str(), vstr[ans[0].second].c_str()); } else { printf("(%s,%s) (%s,%s) \n", vstr[ans[0].first].c_str(), vstr[ans[0].second].c_str(), vstr[ans[1].first].c_str(), vstr[ans[1].second].c_str()); } } } return 0; }
9c3fa67cf4ece508073c0b6822db284debea7229
70fe255d0a301952a023be5e1c1fefd062d1e804
/LintCode/37.cpp
f1154a8fa46ae6f897c35bd74ec803f12ec70812
[ "MIT" ]
permissive
LauZyHou/Algorithm-To-Practice
524d4318032467a975cf548d0c824098d63cca59
66c047fe68409c73a077eae561cf82b081cf8e45
refs/heads/master
2021-06-18T01:48:43.378355
2021-01-27T14:44:14
2021-01-27T14:44:14
147,997,740
8
1
null
null
null
null
UTF-8
C++
false
false
255
cpp
class Solution { public: /** * @param number: A 3-digit number. * @return: Reversed number. */ int reverseInteger(int number) { int a = number%10; int b = number/10%10; int c = number/100; return a*100+b*10+c; } };
6af9d762a27675c814e1f06738962bbda04fa16b
311525f7de84975434f55c00b545ccf7fe3dcce6
/oi/japan/joisc/2017/day2/arranging_tickets.cpp
d2f48dc83125e17fcf6fcfd2ff8db33c7cff6918
[]
no_license
fishy15/competitive_programming
60f485bc4022e41efb0b7d2e12d094213d074f07
d9bca2e6bea704f2bfe5a30e08aa0788be6a8022
refs/heads/master
2023-08-16T02:05:08.270992
2023-08-06T01:00:21
2023-08-06T01:00:21
171,861,737
29
5
null
null
null
null
UTF-8
C++
false
false
7,612
cpp
/* * We can first split the circle at 0, initially marking each range from the lower number to the higher * number. First, we note that we never want to flip both [a, b) and [c, d) where a < b <= c < d. This * increases the count at each location not within the ranges by 2, and the values within the ranges don't * change. Therefore, this only makes the situation worse. * * We can then binary search for the answer. Let the answer we are checking for be m. We can also define * two other parameters: n will be the total number of ranges flipped, and t will be a point that all the * ranges flipped will have in common (which must exist as we have shown earlier). For a given point, if * there are currently a people that go over the point and there are n' tickets left to assign, then the * amount of ranges we have to flip is max(ceil((a + n' - m) / 2), 0). We maintain a set of ranges to flip * and then greedily flip the rightmost edges in the set, flipping as many as we need. Afterwards, we can * do a final check to see if it works. Overall, this is O(n^2 m log(n) log(sum of c)). * * We can do two optimizations to this. First, we will try to limit the values of n that we will check. * Let a_i denote the initial values, and b_i be the values after doing all necessary flips. We will prove * that we can always pick a value of t such that b_t = or b_t = max(b_i) - 1. First of all, t can * be any value in the intersection of all the ranges picked, so we can choose t to have the maximum value * in the range. Now, suppose that there is some value outside of the intersection i such that b_i > b_t. * We can then unflip both the flipped intervals with the leftmost right bound and the rightmost left bound * If both ranges are distinct, then the b_i value of everything within the intersection will increase by * +2 (increase by +1 if the ranges are not distinct). By repeating this process, we will either end up * with b_t = m or b_t = m - 1, so our proof is done. Since n ranges will cover t, the b_t = a_t - n, * so n = a_t - m or n = a_t - m + 1. * * Now, we want to limit the values of t that we have to check. We can first limit the candidates to t to * be the values of i where a_i is the maximum of the array. If we let x_i denote the number of ranges * flipped that include location i, then we know that x_j < x_t if j is not in the intersection. Taking the * maximum possible value of b_j, we have b_j <= b_t + 1 and x_j + 1 <= x_t. Since a_i = x_i + b_i, we get * that a_j <= a_t if j is not in the interesction, so a_t must be the maxmimum of a. * * Next, we will show that we only need to check the leftmost and rightmost indices where a_i is at its * maximum. Denote these left and right indices by l and r. First, we will show that there is no need to * flip a range [c, d) where l < c < d <= r. Suppose that there is some such range that we flip. If we * unflip it, then everything outside the range decrements by 1, so it is still valid. Everything inside * of the range increments by 1 as well. However, since x_l > x_t since l is not within the intersection * of all flipped intervals, b_l > b_t originally, so incrementing b_t by 1 does not make the configuration * invalid. Therefore, every interval that we flip must either include l or r. If there exists two intervals * where one does not include l and the other does not include r, then we can unflip both of them. Let b' * represent the new values at each location. For similar reasons as before, b'_l >= b'_i for l <= i <= r * because a_l and a_r are the max values of a over the entire array, but x'_l and x'_r are still the * lowest values between l and r (since they are the farthest from t). Everything outside of l and r will * either not change in value or decrease by 2, so overall, the combination is still valid. We can keep * repeating this process until all remaining ranges contain either l or r, so we could have chosen t = l * or t = r. Therefore, we only need to check these two location. * * Overall, this cuts a factor of O(nm) from the solution, so the new time complexity is * O(n log(n) log(sum of c)), which passes. */ #include <iostream> #include <iomanip> #include <fstream> #include <vector> #include <array> #include <algorithm> #include <utility> #include <map> #include <queue> #include <set> #include <cmath> #include <cstdio> #include <cstring> #define ll long long #define ld long double #define eps 1e-8 #define MOD 1000000007 #define INF 0x3f3f3f3f #define INFLL 0x3f3f3f3f3f3f3f3f // change if necessary #define MAXN 200010 using namespace std; int n, m; vector<array<int, 3>> range[MAXN]; ll init[MAXN]; int min_check, max_check; struct cmp { bool operator()(const array<int, 3> &a, const array<int, 3> &b) const { if (a[1] == b[1]) { if (a[0] == b[0]) { return a[2] < b[2]; } return a[0] > b[0]; } return a[1] < b[1]; } }; struct bit { ll vals[MAXN]; void reset() { for (int i = 0; i < n + 10; i++) { vals[i] = 0; } for (int i = 0; i < n; i++) { ll x = init[i]; if (i) x -= init[i - 1]; upd(i, x); } } void upd(int x, ll v) { x++; while (x < n + 10) { vals[x] += v; x += x & -x; } } void upd(int l, int r, ll v) { upd(l, v); upd(r, -v); } ll qry(int x) { x++; ll res = 0; while (x) { res += vals[x]; x -= x & -x; } return res; } } b; ll check(ll m, ll n, ll t) { b.reset(); priority_queue<array<int, 3>, vector<array<int, 3>>, cmp> pq; for (int i = 0; i <= t; i++) { ll need_rem = max((b.qry(i) + n - m + 1) / 2, 0LL); n -= need_rem; for (auto &arr : range[i]) { if (arr[1] > t) { pq.push(arr); } } while (need_rem) { if (pq.empty()) { return false; } auto t = pq.top(); pq.pop(); ll to_rem = min<ll>(t[2], need_rem); b.upd(0, t[0], to_rem); b.upd(t[0], t[1], -to_rem); b.upd(t[1], ::n, to_rem); t[2] -= to_rem; need_rem -= to_rem; if (t[2]) pq.push(t); } } for (int i = 0; i < ::n; i++) { if (b.qry(i) > m) { return false; } } return true; } ll check(ll m) { ll a = init[min_check]; return check(m, a - m, min_check) || check(m, a - m + 1, min_check) || check(m, a - m, max_check) || check(m, a - m + 1, max_check); } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for (int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; a--; b--; if (a > b) swap(a, b); init[a] += c; init[b] -= c; range[a].push_back({a, b, c}); } for (int i = 1; i < n; i++) { init[i] += init[i - 1]; } for (int i = 0; i < n; i++) { if (init[i] > init[min_check]) { min_check = i; max_check = i; } else if (init[i] == init[min_check]) { max_check = i; } } ll l = 0; ll r = init[min_check]; ll ans = init[min_check]; while (l <= r) { ll m = (l + r) / 2; if (check(m)) { ans = m; r = m - 1; } else { l = m + 1; } } cout << ans << '\n'; return 0; }
6f9e2a1251e0d80527ebef9b1764f62a60cc7984
c26e9d3f92d95f7ce9d0fd5ef2c18dd95ec209a5
/hackerrank/graph/murderer.cpp
1fb9dd65652537e7209bab94ed2d7f66c6acb818
[]
no_license
crystal95/Competetive-Programming-at-different-platforms
c9ad1684f6258539309d07960ed6abfa7d1a16d0
92d283171b0ae0307e9ded473c6eea16f62cb60e
refs/heads/master
2021-01-09T21:44:28.175506
2016-03-27T21:26:26
2016-03-27T21:26:26
54,848,617
0
0
null
null
null
null
UTF-8
C++
false
false
1,083
cpp
using namespace std; #include <stdio.h> #include <stdlib.h> #include <string.h> #include <vector> #include <iostream> #include <queue> #include <algorithm> #include <unordered_set> typedef long long int ll; typedef pair<int,int> ii; void bfs(vector<vector<int> > &adj,int s,vector<int> &dis,int n) { int i ; unordered_set<int> unvisited; for(i=1;i<=n;i++) unvisited.insert(i); queue<int> q; q.push(s); unvisited.erase(s); while(!q.empty()) { int tmp=q.front(); q.pop(); for(auto it=unvisited.begin();it!=unvisited.end();++it) { if(find(adj[tmp].begin(),adj[tmp].end(),*it)==adj[tmp].end()) { q.push(*it); dis[*it]=dis[tmp]+1; unvisited.erase(*it); } } } } int main() { int T; cin>>T; while(T--) { int i,n,m,u,v,s,w,start; cin>>n>>m; vector<vector<int > > adj(n+1); vector<int> dis(n+1,0); for(i=0;i<m;i++) { cin>>u>>v; adj[u].push_back(v); adj[v].push_back(u); } cin>>start; bfs(adj,start,dis,n); for(i=1;i<=n;i++) { if(start!=i) cout<<dis[i]<<" "; } cout<<endl; } return 0; }
6ac48384b37ee2583609e4478de1a2f61b0ef09a
a7ec77cc491d24998e00a68a203c54b9e121ef79
/SDK/include/SoT_Interaction_enums.hpp
b48b3df2a125a4b79427c6855e7e76f7316ab0bd
[]
no_license
EO-Zanzo/zSoT-DLL
a213547ca63a884a009991b9a5c49f7c08ecffcb
3b241befbb47062cda3cebc3ac0cf12e740ddfd7
refs/heads/master
2020-12-26T21:21:14.909021
2020-02-01T17:39:43
2020-02-01T17:39:43
237,647,839
4
1
null
2020-02-01T17:05:08
2020-02-01T17:05:08
null
UTF-8
C++
false
false
866
hpp
#pragma once // Sea of Thieves (2.0) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif namespace SDK { //--------------------------------------------------------------------------- //Enums //--------------------------------------------------------------------------- // Enum Interaction.EInteractionBlockReason enum class EInteractionBlockReason : uint8_t { EInteractionBlockReason__None = 0, EInteractionBlockReason__Radial = 1, EInteractionBlockReason__Other = 2, EInteractionBlockReason__EInteractionBlockReason_MAX = 3 }; // Enum Interaction.EInteractionObject enum class EInteractionObject : uint8_t { EInteractionObject__None = 0, EInteractionObject__Shop = 1, EInteractionObject__Chest = 2, EInteractionObject__Barrel = 3, EInteractionObject__EInteractionObject_MAX = 4 }; } #ifdef _MSC_VER #pragma pack(pop) #endif
8ab716daca33856e610a208732527f0dd9de4e8e
70d18762f2443bb5df8df38967bcd38277573cdb
/arch/generic/kernel/gen_ke_arch64.cpp
1f2b16ecf52f14ac9a8389e3bec0a1176360b3fd
[]
no_license
15831944/evita-common-lisp
f829defc5386cd1988754c59f2056f0367c77ed7
cb2cbd3cc541878d25dcedb4abd88cf8e2c881d9
refs/heads/master
2021-05-27T16:35:25.208083
2013-12-01T06:21:32
2013-12-01T06:21:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,776
cpp
////////////////////////////////////////////////////////////////////////////// // // evcl - kernel - arch 64 // kernel/ke_arch64.cpp // // This file is part of Evita Common Lisp. // // Copyright (C) 1996-2006 by Project Vogue. // Written by Yoshifumi "VOGUE" INOUE. ([email protected]) // // @(#)$Id: //proj/evcl3/mainline/arch/generic/kernel/gen_ke_arch64.cpp#3 $ // #if SIZEOF_VAL == 8 #include "../../../kernel/ke_arch.h" namespace Kernel { const uint64 Kernel::Arch64::k_rgfBit[64] = { 1ull << 0, 1ull << 1, 1ull << 2, 1ull << 3, 1ull << 4, 1ull << 5, 1ull << 6, 1ull << 7, 1ull << 8, 1ull << 9, 1ull << 10, 1ull << 11, 1ull << 12, 1ull << 13, 1ull << 14, 1ull << 15, 1ull << 16, 1ull << 17, 1ull << 18, 1ull << 19, 1ull << 20, 1ull << 21, 1ull << 22, 1ull << 23, 1ull << 24, 1ull << 25, 1ull << 26, 1ull << 27, 1ull << 28, 1ull << 29, 1ull << 30, 1ull << 31, 1ull << 32, 1ull << 33, 1ull << 34, 1ull << 35, 1ull << 36, 1ull << 37, 1ull << 38, 1ull << 39, 1ull << 40, 1ull << 41, 1ull << 42, 1ull << 43, 1ull << 44, 1ull << 45, 1ull << 46, 1ull << 47, 1ull << 48, 1ull << 49, 1ull << 50, 1ull << 51, 1ull << 52, 1ull << 53, 1ull << 54, 1ull << 55, 1ull << 56, 1ull << 57, 1ull << 58, 1ull << 59, 1ull << 60, 1ull << 61, 1ull << 62, 1ull << 63 }; // Kernel::Arch64::k_rgfBit ////////////////////////////////////////////////////////////////////// // // Mask For Bit Stream Leader and Trailer // // Bit Stream: // LLLL LLLL xxxx xxxx ... xxxx xxxx TTTT TTTT // // x = bits for processing // L = leader bits (not affect) // T = trailer bits (not affect) // // Note: Bit stream is stored in each 32bit word from LSB to MSB. // // // (loop for i below 64 do (format t "0x~16,'0Xull, // ~D~%" (1- (ash 1 i)) i)) const Arch64::BitEltT Arch64::k_rgnLeaderMask[64] = { 0x0000000000000000ull, // 0 0x0000000000000001ull, // 1 0x0000000000000003ull, // 2 0x0000000000000007ull, // 3 0x000000000000000Full, // 4 0x000000000000001Full, // 5 0x000000000000003Full, // 6 0x000000000000007Full, // 7 0x00000000000000FFull, // 8 0x00000000000001FFull, // 9 0x00000000000003FFull, // 10 0x00000000000007FFull, // 11 0x0000000000000FFFull, // 12 0x0000000000001FFFull, // 13 0x0000000000003FFFull, // 14 0x0000000000007FFFull, // 15 0x000000000000FFFFull, // 16 0x000000000001FFFFull, // 17 0x000000000003FFFFull, // 18 0x000000000007FFFFull, // 19 0x00000000000FFFFFull, // 20 0x00000000001FFFFFull, // 21 0x00000000003FFFFFull, // 22 0x00000000007FFFFFull, // 23 0x0000000000FFFFFFull, // 24 0x0000000001FFFFFFull, // 25 0x0000000003FFFFFFull, // 26 0x0000000007FFFFFFull, // 27 0x000000000FFFFFFFull, // 28 0x000000001FFFFFFFull, // 29 0x000000003FFFFFFFull, // 30 0x000000007FFFFFFFull, // 31 0x00000000FFFFFFFFull, // 32 0x00000001FFFFFFFFull, // 33 0x00000003FFFFFFFFull, // 34 0x00000007FFFFFFFFull, // 35 0x0000000FFFFFFFFFull, // 36 0x0000001FFFFFFFFFull, // 37 0x0000003FFFFFFFFFull, // 38 0x0000007FFFFFFFFFull, // 39 0x000000FFFFFFFFFFull, // 40 0x000001FFFFFFFFFFull, // 41 0x000003FFFFFFFFFFull, // 42 0x000007FFFFFFFFFFull, // 43 0x00000FFFFFFFFFFFull, // 44 0x00001FFFFFFFFFFFull, // 45 0x00003FFFFFFFFFFFull, // 46 0x00007FFFFFFFFFFFull, // 47 0x0000FFFFFFFFFFFFull, // 48 0x0001FFFFFFFFFFFFull, // 49 0x0003FFFFFFFFFFFFull, // 50 0x0007FFFFFFFFFFFFull, // 51 0x000FFFFFFFFFFFFFull, // 52 0x001FFFFFFFFFFFFFull, // 53 0x003FFFFFFFFFFFFFull, // 54 0x007FFFFFFFFFFFFFull, // 55 0x00FFFFFFFFFFFFFFull, // 56 0x01FFFFFFFFFFFFFFull, // 57 0x03FFFFFFFFFFFFFFull, // 58 0x07FFFFFFFFFFFFFFull, // 59 0x0FFFFFFFFFFFFFFFull, // 60 0x1FFFFFFFFFFFFFFFull, // 61 0x3FFFFFFFFFFFFFFFull, // 62 0x7FFFFFFFFFFFFFFFull, // 63 }; // k_rgnLeaderMask // (loop with x = (1- (ash 1 64)) for i below 64 for m = (1- (ash 1 i)) // do (format t " 0x~16,'0Xull, // ~D~%" (- x m) i) ) const Arch64::BitEltT Arch64::k_rgnTrailerMask[64] = { 0xFFFFFFFFFFFFFFFFull, // 0 0xFFFFFFFFFFFFFFFEull, // 1 0xFFFFFFFFFFFFFFFCull, // 2 0xFFFFFFFFFFFFFFF8ull, // 3 0xFFFFFFFFFFFFFFF0ull, // 4 0xFFFFFFFFFFFFFFE0ull, // 5 0xFFFFFFFFFFFFFFC0ull, // 6 0xFFFFFFFFFFFFFF80ull, // 7 0xFFFFFFFFFFFFFF00ull, // 8 0xFFFFFFFFFFFFFE00ull, // 9 0xFFFFFFFFFFFFFC00ull, // 10 0xFFFFFFFFFFFFF800ull, // 11 0xFFFFFFFFFFFFF000ull, // 12 0xFFFFFFFFFFFFE000ull, // 13 0xFFFFFFFFFFFFC000ull, // 14 0xFFFFFFFFFFFF8000ull, // 15 0xFFFFFFFFFFFF0000ull, // 16 0xFFFFFFFFFFFE0000ull, // 17 0xFFFFFFFFFFFC0000ull, // 18 0xFFFFFFFFFFF80000ull, // 19 0xFFFFFFFFFFF00000ull, // 20 0xFFFFFFFFFFE00000ull, // 21 0xFFFFFFFFFFC00000ull, // 22 0xFFFFFFFFFF800000ull, // 23 0xFFFFFFFFFF000000ull, // 24 0xFFFFFFFFFE000000ull, // 25 0xFFFFFFFFFC000000ull, // 26 0xFFFFFFFFF8000000ull, // 27 0xFFFFFFFFF0000000ull, // 28 0xFFFFFFFFE0000000ull, // 29 0xFFFFFFFFC0000000ull, // 30 0xFFFFFFFF80000000ull, // 31 0xFFFFFFFF00000000ull, // 32 0xFFFFFFFE00000000ull, // 33 0xFFFFFFFC00000000ull, // 34 0xFFFFFFF800000000ull, // 35 0xFFFFFFF000000000ull, // 36 0xFFFFFFE000000000ull, // 37 0xFFFFFFC000000000ull, // 38 0xFFFFFF8000000000ull, // 39 0xFFFFFF0000000000ull, // 40 0xFFFFFE0000000000ull, // 41 0xFFFFFC0000000000ull, // 42 0xFFFFF80000000000ull, // 43 0xFFFFF00000000000ull, // 44 0xFFFFE00000000000ull, // 45 0xFFFFC00000000000ull, // 46 0xFFFF800000000000ull, // 47 0xFFFF000000000000ull, // 48 0xFFFE000000000000ull, // 49 0xFFFC000000000000ull, // 50 0xFFF8000000000000ull, // 51 0xFFF0000000000000ull, // 52 0xFFE0000000000000ull, // 53 0xFFC0000000000000ull, // 54 0xFF80000000000000ull, // 55 0xFF00000000000000ull, // 56 0xFE00000000000000ull, // 57 0xFC00000000000000ull, // 58 0xF800000000000000ull, // 59 0xF000000000000000ull, // 60 0xE000000000000000ull, // 61 0xC000000000000000ull, // 62 0x8000000000000000ull, // 63 }; // k_rgnTrailerMask CASSERT(sizeof(Arch64::k_rgnLeaderMask) == sizeof(Arch64::k_rgnTrailerMask)); } // Kernel #endif // SIZEOF_VAL == 8
22b4b85995b27b9bf5a3b2c844bcb56c4ab65e55
090243cf699213f32f870baf2902eb4211f825d6
/cf/621/D.cpp
27cba968aae8be25270c8a561e72debc59131184
[]
no_license
zhu-he/ACM-Source
0d4d0ac0668b569846b12297e7ed4abbb1c16571
02e3322e50336063d0d2dad37b2761ecb3d4e380
refs/heads/master
2021-06-07T18:27:19.702607
2016-07-10T09:20:48
2016-07-10T09:20:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
625
cpp
#include <cstdio> #include <cmath> const char s[12][10] = {"x^y^z", "x^z^y", "(x^y)^z", "(x^z)^y", "y^x^z", "y^z^x", "(y^x)^z", "(y^z)^x", "z^x^y", "z^y^x", "(z^x)^y", "(z^y)^x"}; double d[12]; int main() { double x, y, z; scanf("%lf %lf %lf", &x, &y, &z); d[0] = pow(y, z) * log(x); d[1] = pow(z, y) * log(x); d[2] = d[3] = y * z * log(x); d[4] = pow(x, z) * log(y); d[5] = pow(z, x) * log(y); d[6] = d[7] = x * z * log(y); d[8] = pow(x, y) * log(z); d[9] = pow(y, x) * log(z); d[10] = d[11] = x * y * log(z); int mx = 0; for (int i = 1; i < 12; ++i) if (d[i] > d[mx]) mx = i; puts(s[mx]); return 0; }
71b57f5243d516e395976e4bdf4e9b22391da34d
46de5c99419f112b4507fd386f398769626ad328
/thinkbig2.cpp
16cfc1eba8eed89495a53e3254d4d0856bad3cb9
[]
no_license
sanu11/Codes
20a7903d95d600078db8b0bf0e12a3731615c3c1
dd58a5577b51ade54f95c96003fc2c99609c15eb
refs/heads/master
2021-01-21T04:50:36.855876
2019-07-09T05:12:56
2019-07-09T05:12:56
48,174,017
2
0
null
null
null
null
UTF-8
C++
false
false
768
cpp
#include<bits/stdc++.h> using namespace std; int main() { int n,m; cin>>n; int arr[n]; int x,y; map<int,int>a; map<int,int>::iterator p; for(int i=0;i<n;i++) { cin>>arr[i]; cin>>x; for(int j=0;j<x;j++) { cin>>y; p=a.find(y); if(p==a.end()) a.insert(make_pair(y,1)); } } p=a.begin(); for(int i=0;i<n;i++) { p=a.begin(); while(p!=a.end()) { // cout<<arr[i]<<" "<<p->first<<endl; if(arr[i]==p->first) p->second--; p++; } } p=a.begin(); int sum=0; while(p!=a.end()) { //cout<<p->first<<" "<<p->second<<endl; sum+=p->second; p++; } cout<<sum<<endl; return 0; }
ec71eee9144a294508e930330ca1e438fb3fc919
32b88f828b33279cfe33420c2ed969131a7df987
/Code/Core/Mem/MemTracker.cpp
777a97039b84548fb8dbfdacb216b93ff26a076f
[ "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference" ]
permissive
punitchandra/fastbuild
53b51f001350104629e71434bb5e521a1bb63cae
8a445d77343bc4881b33a5ebcf31a2ec8777ae2d
refs/heads/master
2021-01-15T13:23:26.995800
2017-08-21T15:05:32
2017-08-21T15:05:32
38,138,811
0
0
null
2015-06-26T23:30:24
2015-06-26T23:30:23
null
UTF-8
C++
false
false
7,281
cpp
// MemTracker.cpp //------------------------------------------------------------------------------ // Includes //------------------------------------------------------------------------------ #include "Core/PrecompiledHeader.h" #include "MemTracker.h" //------------------------------------------------------------------------------ #if defined( MEMTRACKER_ENABLED ) // Includes //------------------------------------------------------------------------------ #include "Core/Mem/MemPoolBlock.h" #include "Core/Process/Atomic.h" #include "Core/Process/Thread.h" #include "Core/Tracing/Tracing.h" // system #include <memory.h> // for memset // Static Data //------------------------------------------------------------------------------ /*static*/ uint32_t MemTracker::s_Id( 0 ); /*static*/ bool MemTracker::s_Enabled( true ); /*static*/ bool MemTracker::s_Initialized( false ); /*static*/ uint32_t MemTracker::s_AllocationCount( 0 ); /*static*/ uint64_t MemTracker::s_Mutex[]; /*static*/ MemTracker::Allocation ** MemTracker::s_AllocationHashTable = nullptr; /*static*/ MemPoolBlock * MemTracker::s_Allocations( nullptr ); // Thread-Local Data //------------------------------------------------------------------------------ THREAD_LOCAL uint32_t g_MemTrackerDisabledOnThisThread( 0 ); // Defines #define ALLOCATION_MINIMUM_ALIGN ( 0x4 ) // assume at least 4 byte alignment #define ALLOCATION_HASH_SHIFT ( 0x2 ) // shift off lower bits #define ALLOCATION_HASH_SIZE ( 0x100000 ) // one megabyte #define ALLOCATION_HASH_MASK ( 0x0FFFFF ) // mask off upper bits // Alloc //------------------------------------------------------------------------------ /*static*/ void MemTracker::Alloc( void * ptr, size_t size, const char * file, int line ) { if ( !s_Enabled ) { return; } // handle allocations during initialization if ( g_MemTrackerDisabledOnThisThread ) { return; } ++g_MemTrackerDisabledOnThisThread; if ( !s_Initialized ) { Init(); } const size_t hashIndex = ( ( (size_t)ptr >> ALLOCATION_HASH_SHIFT ) & ALLOCATION_HASH_MASK ); { MutexHolder mh( GetMutex() ); Allocation * a = (Allocation *)s_Allocations->Alloc( sizeof( Allocation ) ); ++s_AllocationCount; a->m_Id = ++s_Id; a->m_Ptr = ptr; a->m_Size = size; a->m_Next = s_AllocationHashTable[ hashIndex ]; a->m_File = file; a->m_Line = line; static size_t breakOnSize = (size_t)-1; static uint32_t breakOnId = 0; if ( ( size == breakOnSize ) || ( a->m_Id == breakOnId ) ) { BREAK_IN_DEBUGGER; } s_AllocationHashTable[ hashIndex ] = a; } --g_MemTrackerDisabledOnThisThread; } // Free //------------------------------------------------------------------------------ /*static*/ void MemTracker::Free( void * ptr ) { if ( !s_Enabled ) { return; } if ( !s_Initialized ) { return; } if ( g_MemTrackerDisabledOnThisThread ) { return; } const size_t hashIndex = ( ( (size_t)ptr >> ALLOCATION_HASH_SHIFT ) & ALLOCATION_HASH_MASK ); MutexHolder mh( GetMutex() ); Allocation * a = s_AllocationHashTable[ hashIndex ]; Allocation * prev = nullptr; while ( a ) { if ( a->m_Ptr == ptr ) { if ( prev == nullptr ) { s_AllocationHashTable[ hashIndex ] = a->m_Next; } else { prev->m_Next = a->m_Next; } ++g_MemTrackerDisabledOnThisThread; s_Allocations->Free( a ); --s_AllocationCount; --g_MemTrackerDisabledOnThisThread; break; } prev = a; a = a->m_Next; } } // DumpAllocations //------------------------------------------------------------------------------ /*static*/ void MemTracker::DumpAllocations() { if ( s_Enabled == false ) { OUTPUT( "DumpAllocations failed - MemTracker not enabled\n" ); return; } if ( s_Initialized == false ) { OUTPUT( "DumpAllocations : No allocations\n" ); return; } MutexHolder mh( GetMutex() ); if ( s_AllocationCount == 0 ) { OUTPUT( "DumpAllocations : No allocations\n" ); return; } uint64_t total = 0; uint64_t numAllocs = 0; // for each leak, we'll print a view of the memory unsigned char displayChar[256]; memset( displayChar, '.', sizeof( displayChar ) ); const unsigned char * okChars = (const unsigned char *)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`1234567890-=!@#$^&*()_+[]{};:'\",<>/?|\\"; const unsigned char * ok = okChars; for ( ;; ) { unsigned char c = *ok; if ( c == 0 ) break; displayChar[ c ] = c; ++ok; } char memView[ 32 ] = { 0 }; OUTPUT( "--- DumpAllocations ------------------------------------------------\n" ); for ( size_t i=0; i<ALLOCATION_HASH_SIZE; ++i ) { Allocation * a = s_AllocationHashTable[ i ]; while ( a ) { uint32_t id = a->m_Id; uint64_t addr = (size_t)a->m_Ptr; uint64_t size = a->m_Size; // format a view of the memory contents const char * src = (const char *)addr; char * dst = memView; const size_t num = Math::Min< size_t >( (size_t)size, 31 ); for ( uint32_t j=0; j<num; ++j ) { unsigned char c = *src; *dst = displayChar[ c ]; ++src; ++dst; } *dst = 0; OUTPUT( "%s(%u): Id %u : %u bytes @ 0x%016llx (Mem: %s)\n", a->m_File, a->m_Line, id, size, addr, memView ); ++numAllocs; total += size; a = a->m_Next; } } OUTPUT( "--------------------------------------------------------------------\n" ); OUTPUT( "Total: %llu bytes in %llu allocs\n", total, numAllocs ); OUTPUT( "--------------------------------------------------------------------\n" ); } // Reset //------------------------------------------------------------------------------ /*static*/ void MemTracker::Reset() { MutexHolder mh( GetMutex() ); ++g_MemTrackerDisabledOnThisThread; // free all allocation tracking for ( size_t i=0; i<ALLOCATION_HASH_SIZE; ++i ) { Allocation * a = s_AllocationHashTable[ i ]; while ( a ) { s_Allocations->Free( a ); --s_AllocationCount; a = a->m_Next; } s_AllocationHashTable[ i ] = nullptr; } ASSERT( s_AllocationCount == 0 ); s_Id = 0; --g_MemTrackerDisabledOnThisThread; } // Init //------------------------------------------------------------------------------ /*static*/ void MemTracker::Init() { CTASSERT( sizeof( MemTracker::s_Mutex ) == sizeof( Mutex ) ); ASSERT( g_MemTrackerDisabledOnThisThread ); // first caller does init static uint32_t threadSafeGuard( 0 ); if ( AtomicIncU32( &threadSafeGuard ) != 1 ) { // subsequent callers wait for init while ( !s_Initialized ) {} return; } // construct primary mutex in-place INPLACE_NEW ( &GetMutex() ) Mutex; // init hash table s_AllocationHashTable = new Allocation*[ ALLOCATION_HASH_SIZE ]; memset( s_AllocationHashTable, 0, ALLOCATION_HASH_SIZE * sizeof( Allocation * ) ); // init pool for allocation structures s_Allocations = new MemPoolBlock( sizeof( Allocation ), __alignof( Allocation ) ); MemoryBarrier(); s_Initialized = true; } //------------------------------------------------------------------------------ #endif // MEMTRACKER_ENABLED //------------------------------------------------------------------------------
a35449fec2af60cbb23f7da0b8bae35a4ce64aef
1dc05c3cb3a57aea5f64052f329eaf458f73c832
/topic/LeetCode/0807maxIncreaseKeepingSkyline.cpp
603cf6950b266ec0a72ef42137f69d3f137e23ee
[]
no_license
ITShadow/practiceCode
0b1fcbb6b150a1ee91283e8ac7a8d928b4751eda
4b407ad98e3abc0be5eadc97ff32165f9f367104
refs/heads/master
2023-04-08T05:53:21.734166
2021-04-26T03:45:46
2021-04-26T03:45:46
295,429,631
0
0
null
null
null
null
UTF-8
C++
false
false
2,203
cpp
/* 在二维数组grid中,grid[i][j]代表位于某处的建筑物的高度。 我们被允许增加任何数量(不同建筑物的数量可能不同)的建筑物的高度。 高度 0 也被认为是建筑物。 最后,从新数组的所有四个方向(即顶部,底部,左侧和右侧)观看的“天际线”必须与原始数组的天际线相同。 城市的天际线是从远处观看时,由所有建筑物形成的矩形的外部轮廓。 请看下面的例子。 建筑物高度可以增加的最大总和是多少? 例子: 输入: grid = [[3,0,8,4],[2,4,5,7],[9,2,6,3],[0,3,1,0]] 输出: 35 解释: The grid is: [ [3, 0, 8, 4], [2, 4, 5, 7], [9, 2, 6, 3], [0, 3, 1, 0] ] 从数组竖直方向(即顶部,底部)看“天际线”是:[9, 4, 8, 7] 从水平水平方向(即左侧,右侧)看“天际线”是:[8, 7, 9, 3] 在不影响天际线的情况下对建筑物进行增高后,新数组如下: gridNew = [ [8, 4, 8, 7], [7, 4, 7, 7], [9, 4, 8, 7], [3, 3, 3, 3] ] 说明: 1 < grid.length = grid[0].length <= 50。  grid[i][j] 的高度范围是: [0, 100]。 一座建筑物占据一个grid[i][j]:换言之,它们是 1 x 1 x grid[i][j] 的长方体。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/max-increase-to-keep-city-skyline 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 class Solution { public: int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) { if (grid.empty()) return 0; int R = grid.size(); int C = grid[0].size(); vector<int> row_max(R, 0); vector<int> col_max(C, 0); for (int i = 0; i < R; ++i) { for (int j = 0; j < C; ++j) { row_max[i] = max(row_max[i], grid[i][j]); col_max[j] = max(col_max[j], grid[i][j]); } } int res = 0; for (int i = 0; i < R; ++i) { for (int j = 0; j < C; ++j) { res += min(row_max[i], col_max[j]) - grid[i][j]; } } return res; } }; */ /* 就是找行列最大 */
f2fd573fb8ac9dde4919620147f9c6d1cc0536a0
d47ad8721876e05cc92a48ea772981dd2541d27c
/FPMLib/lib/bfc/autores.h
78620a35bff0d40b0b1f790be9dc42de2b418042
[]
no_license
cjld/ANNO-video
5ac5f604d43e00a3ee8b2a40050413ffd8334c3e
e8ad4f1d617f8b2393db5241a40f98c156127e52
refs/heads/master
2021-01-25T06:45:24.164963
2017-06-12T15:54:19
2017-06-12T15:54:19
93,606,386
2
0
null
null
null
null
UTF-8
C++
false
false
5,150
h
#ifndef _FF_BFC_AUTORES_H #define _FF_BFC_AUTORES_H #include <utility> #include <iterator> #include"ffdef.h" _FF_BEG //To help implement reference-counter in @AutoRes. template<typename ValT> class ReferenceCounter { typedef std::pair<int,ValT> _CounterT; private: _CounterT *_pdata; void _inc() const { ++_pdata->first; } void _dec() const { --_pdata->first; } public: ReferenceCounter() :_pdata(new _CounterT(1,ValT())) { } ReferenceCounter(const ValT& val) :_pdata(new _CounterT(1,val)) { } ReferenceCounter(const ReferenceCounter& right) :_pdata(right._pdata) { this->_inc(); } ReferenceCounter& operator=(const ReferenceCounter& right) { if(_pdata!=right._pdata) { if(this->IsLast()) delete _pdata; else this->_dec(); _pdata=right._pdata; right._inc(); } return *this; } //whether current reference is the last one. bool IsLast() const { return _pdata->first==1; } //get the value stored with the counter. const ValT& Value() const { return _pdata->second; } ValT& Value() { return _pdata->second; } //swap two counters. void Swap(ReferenceCounter& right) { std::swap(this->_pdata,right._pdata); } ~ReferenceCounter() { if(this->IsLast()) delete _pdata; else this->_dec(); } }; //auto-resource, which is the base to implement AutoPtr,AutoArrayPtr and AutoComPtr. template<typename PtrT,typename RetPtrT,typename ReleaseOpT> class AutoRes { enum{_F_DETACHED=0x01}; struct _ValT { PtrT ptr; ReleaseOpT rel_op; int flag; public: _ValT() :ptr(PtrT()),flag(0) { } _ValT(const PtrT & _ptr,const ReleaseOpT & _rel_op, int _flag=0) :ptr(_ptr),rel_op(_rel_op),flag(_flag) { } void release() { if((flag&_F_DETACHED)==0) rel_op(ptr); } }; typedef ReferenceCounter<_ValT> _CounterT; protected: _CounterT _counter; void _release() { //release the referenced object with the stored operator. _counter.Value().release(); } public: AutoRes() { } explicit AutoRes(PtrT ptr,const ReleaseOpT& op=ReleaseOpT()) :_counter(_ValT(ptr,op)) { } AutoRes& operator=(const AutoRes& right) { if(this!=&right) { if(_counter.IsLast()) this->_release(); _counter=right._counter; } return *this; } RetPtrT operator->() const { return &*_counter.Value().ptr; } typename std::iterator_traits<RetPtrT>::reference operator*() const { return *_counter.Value().ptr; } void Swap(AutoRes& right) { _counter.Swap(right._counter); } //detach the referenced object from @*this. RetPtrT Detach() { _counter.Value().flag|=_F_DETACHED; return &*_counter.Value().ptr; } operator PtrT() { return _counter.Value().ptr; } ~AutoRes() throw() { if(_counter.IsLast()) this->_release(); } }; //operator to delete a single object. class DeleteObj { public: template<typename _PtrT> void operator()(_PtrT ptr) { delete ptr; } }; template<typename _ObjT> class AutoPtr :public AutoRes<_ObjT*,_ObjT*,DeleteObj> { public: explicit AutoPtr(_ObjT* ptr=NULL) :AutoRes<_ObjT*,_ObjT*,DeleteObj>(ptr) { } }; //operator to delete array of objects. class DeleteArray { public: template<typename _PtrT> void operator()(_PtrT ptr) { delete[]ptr; } }; template<typename _ObjT> class AutoArrayPtr :public AutoRes<_ObjT*,_ObjT*,DeleteArray> { public: explicit AutoArrayPtr(_ObjT* ptr=NULL) :AutoRes<_ObjT*,_ObjT*,DeleteArray>(ptr) { } //_ObjT& operator[](int i) const //{ // return this->_counter.Value().ptr[i]; //} }; class OpCloseFile { public: void operator()(const FILE *fp) { if(fp) fclose((FILE*)fp); } }; class AutoFilePtr :public AutoRes<FILE*,FILE*,OpCloseFile> { public: explicit AutoFilePtr(FILE *fp=NULL) :AutoRes<FILE*,FILE*,OpCloseFile>(fp) { } }; //operator to release COM object. class ReleaseObj { public: template<typename _PtrT> void operator()(_PtrT ptr) { if(ptr) ptr->Release(); } }; template<typename _ObjT> class AutoComPtr :public AutoRes<_ObjT*,_ObjT*,ReleaseObj> { public: explicit AutoComPtr(_ObjT* ptr=NULL) :AutoRes<_ObjT*,_ObjT*,ReleaseObj>(ptr) { } }; class DestroyObj { public: template<typename _PtrT> void operator()(_PtrT ptr) { if(ptr) ptr->Destroy(); } }; template<typename _ObjT> class AutoDestroyPtr :public AutoRes<_ObjT*,_ObjT*,DestroyObj> { public: explicit AutoDestroyPtr(_ObjT* ptr=NULL) :AutoRes<_ObjT*,_ObjT*,DestroyObj>(ptr) { } }; template<typename _ServerPtrT> class ReleaseClientOp { private: _ServerPtrT m_pServer; public: ReleaseClientOp(_ServerPtrT pServer=_ServerPtrT()) :m_pServer(pServer) { } template<typename _ClientPtrT> void operator()(_ClientPtrT ptr) { if(m_pServer) m_pServer->ReleaseClient(ptr); } }; template<typename _ServerPtrT,typename _ClientPtrT> class AutoClientPtr :public AutoRes<_ClientPtrT,_ClientPtrT,ReleaseClientOp<_ServerPtrT> > { typedef AutoRes<_ClientPtrT,_ClientPtrT,ReleaseClientOp<_ServerPtrT> > _MyBaseT; public: explicit AutoClientPtr(_ServerPtrT pServer=_ServerPtrT(),_ClientPtrT pClient=_ClientPtrT()) :_MyBaseT(pClient,ReleaseClientOp<_ServerPtrT>(pServer)) { } }; _FF_END #endif
2b17e47589ce2b7bb6579f599aad8e4a664896b5
b8487f927d9fb3fa5529ad3686535714c687dd50
/include/hermes/VM/JIT/DenseUInt64.h
7cb45f61cba99d132ac4e42fc17f6b4a3b55cbc0
[ "MIT" ]
permissive
hoangtuanhedspi/hermes
4a1399f05924f0592c36a9d4b3fd1f804f383c14
02dbf3c796da4d09ec096ae1d5808dcb1b6062bf
refs/heads/master
2020-07-12T21:21:53.781167
2019-08-27T22:58:17
2019-08-27T22:59:55
204,908,743
1
0
MIT
2019-08-28T17:44:49
2019-08-28T10:44:49
null
UTF-8
C++
false
false
2,568
h
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the LICENSE * file in the root directory of this source tree. */ #ifndef HERMES_VM_JIT_DENSEUINT64_H #define HERMES_VM_JIT_DENSEUINT64_H #include "hermes/VM/HermesValue.h" #include "llvm/ADT/DenseMapInfo.h" namespace hermes { namespace vm { /// A wrapper for using uint64_t with llvm::DenseMap/Set. class DenseUInt64 { public: /// Enum to differentiate between LLVM's empty/tombstone and normal values. enum class MapKeyType { empty, tombstone, valid, }; DenseUInt64(uint64_t cval) : keyType_(MapKeyType::valid), rawValue_(cval) {} DenseUInt64(void *addr) : keyType_(MapKeyType::valid), rawValue_((uint64_t)addr) {} DenseUInt64(HermesValue hv) : keyType_(MapKeyType::valid), rawValue_(hv.getRaw()) {} DenseUInt64(double v) : DenseUInt64(HermesValue::encodeDoubleValue(v)) {} DenseUInt64(MapKeyType keyType) : keyType_(keyType), rawValue_(0) { assert(keyType_ != MapKeyType::valid && "valid entries must have a value"); } bool operator==(const DenseUInt64 &other) const { return keyType_ == other.keyType_ && rawValue_ == other.rawValue_; } HermesValue valueAsHV() const { assert( keyType_ == MapKeyType::valid && "attempting to get the value of tombstone/empty entry"); return HermesValue(rawValue_); } void *valueAsAddr() const { assert( keyType_ == MapKeyType::valid && "attempting to get the value of tombstone/empty entry"); return (void *)rawValue_; } uint64_t rawValue() const { return rawValue_; } private: /// The type of value we have: empty/tombstone/normal. MapKeyType keyType_; /// A raw uint64_t: it could be a HermesValue or an address uint64_t rawValue_; }; } // namespace vm } // namespace hermes namespace llvm { /// Traits to enable using UInt64Constant with llvm::DenseSet/Map. template <> struct DenseMapInfo<hermes::vm::DenseUInt64> { using UInt64Constant = hermes::vm::DenseUInt64; using MapKeyType = UInt64Constant::MapKeyType; static inline UInt64Constant getEmptyKey() { return MapKeyType::empty; } static inline UInt64Constant getTombstoneKey() { return MapKeyType::tombstone; } static inline unsigned getHashValue(UInt64Constant x) { return DenseMapInfo<uint64_t>::getHashValue(x.rawValue()); } static inline bool isEqual(UInt64Constant a, UInt64Constant b) { return a == b; } }; } // namespace llvm #endif // HERMES_VM_JIT_DENSEUINT64_H
759a015ca9170f3456ab0ac5f3a1626efca68ad7
483428f23277dc3fd2fad6588de334fc9b8355d2
/hpp/iOSDevice32/Release/uTPLb_MemoryStreamPool.hpp
bee8378fa9718a035cca20b9ad1bd10f11e6c5d4
[]
no_license
gzwplato/LockBox3-1
7084932d329beaaa8169b94729c4b05c420ebe44
89e300b47f8c1393aefbec01ffb89ddf96306c55
refs/heads/master
2021-05-10T18:41:18.748523
2015-07-04T09:48:06
2015-07-04T09:48:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,375
hpp
// CodeGear C++Builder // Copyright (c) 1995, 2015 by Embarcadero Technologies, Inc. // All rights reserved // (DO NOT EDIT: machine generated header) 'uTPLb_MemoryStreamPool.pas' rev: 29.00 (iOS) #ifndef Utplb_memorystreampoolHPP #define Utplb_memorystreampoolHPP #pragma delphiheader begin #pragma option push #pragma option -w- // All warnings off #pragma option -Vx // Zero-length empty class member #pragma pack(push,8) #include <System.hpp> #include <SysInit.hpp> #include <System.Classes.hpp> //-- user supplied ----------------------------------------------------------- namespace Utplb_memorystreampool { //-- forward type declarations ----------------------------------------------- __interface IMemoryStreamPool; typedef System::DelphiInterface<IMemoryStreamPool> _di_IMemoryStreamPool; class DELPHICLASS TPooledMemoryStream; //-- type declarations ------------------------------------------------------- __interface INTERFACE_UUID("{ADB2D4BA-40F6-4249-923E-201D4719609B}") IMemoryStreamPool : public System::IInterface { virtual int __fastcall BayCount(void) = 0 ; virtual void __fastcall GetUsage(int Size, int &Current, int &Peak) = 0 ; virtual int __fastcall GetSize(int Idx) = 0 ; virtual System::Classes::TMemoryStream* __fastcall NewMemoryStream(int InitSize) = 0 ; }; #pragma pack(push,4) class PASCALIMPLEMENTATION TPooledMemoryStream : public System::Classes::TMemoryStream { typedef System::Classes::TMemoryStream inherited; protected: _di_IMemoryStreamPool FPool; int FCoVector; virtual void * __fastcall Realloc(int &NewCapacity); public: __fastcall TPooledMemoryStream(const _di_IMemoryStreamPool Pool1); public: /* TMemoryStream.Destroy */ inline __fastcall virtual ~TPooledMemoryStream(void) { } }; #pragma pack(pop) //-- var, const, procedure --------------------------------------------------- extern DELPHI_PACKAGE _di_IMemoryStreamPool __fastcall NewPool(void); } /* namespace Utplb_memorystreampool */ #if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_UTPLB_MEMORYSTREAMPOOL) using namespace Utplb_memorystreampool; #endif #pragma pack(pop) #pragma option pop #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // Utplb_memorystreampoolHPP
28ccee844626dc8f532b974e14b830d2f77d8276
fce00ed7da745340691c8c6cf47905ba4fe5a08e
/UchClient/FrmMain.cpp
632d7a2b262d04091ced8c1a66af203405b47a34
[ "Unlicense" ]
permissive
EAirPeter/Uch
bc9bae801721a9241afbfe8add293cf5dcf7a322
193ee52fb98d2d224cd22483b2523caf02805cfe
refs/heads/master
2021-07-24T15:06:17.555444
2017-11-05T14:25:50
2017-11-05T14:25:50
109,581,211
0
0
null
null
null
null
UTF-8
C++
false
false
6,153
cpp
#include "Common.hpp" #include "FrmFileRecv.hpp" #include "FrmFileSend.hpp" #include "FrmMain.hpp" #include "Ucl.hpp" #include <nana/gui/filebox.hpp> using namespace nana; FrmMain::FrmMain() : form(nullptr, {768, 480}, appear::decorate< appear::taskbar, appear::minimize, appear::maximize, appear::sizable >()) { caption(Title(L"Client")); events().destroy(std::bind(&FrmMain::X_OnDestroy, this, std::placeholders::_1)); events().user(std::bind(&FrmMain::X_OnUser, this, std::placeholders::_1)); events().unload([this] (const arg_unload &e) { msgbox mbx {nullptr, TitleU8(L"Exit"), msgbox::yes_no}; mbx.icon(msgbox::icon_question); mbx << L"Are you sure to exit Uch?"; if (mbx() != mbx.pick_yes) e.cancel = true; }); x_btnSend.caption(L"Send"); x_btnSend.events().click(std::bind(&FrmMain::X_OnSend, this)); x_btnSend.events().key_press([this] (const arg_keyboard &e) { if (e.key == keyboard::enter) X_OnSend(); }); x_btnFile.caption(L"Send File"); x_btnFile.events().click(std::bind(&FrmMain::X_OnFile, this)); x_btnFile.events().key_press([this] (const arg_keyboard &e) { if (e.key == keyboard::enter) X_OnFile(); }); x_btnExit.caption(L"Exit"); x_btnExit.events().click(std::bind(&FrmMain::close, this)); x_btnExit.events().key_press([this] (const arg_keyboard &e) { if (e.key == keyboard::enter) close(); }); x_txtMessage.multi_lines(false).tip_string(u8"Message:"); x_txtMessage.events().focus([this] (const arg_focus &e) { x_txtMessage.select(e.getting); }); x_txtMessage.events().key_press([this] (const arg_keyboard &e) { if (e.key == keyboard::enter) X_OnSend(); }); x_lbxUsers.enable_single(true, false); x_lbxUsers.append_header(L"Who", 110); x_lbxUsers.append({L"Online", L"Offline"}); x_lbxMessages.sortable(false); x_lbxMessages.append_header(L"When", 80); x_lbxMessages.append_header(L"How", 180); x_lbxMessages.append_header(L"What", 310); x_pl.div( "margin=[14,16]" " <weight=120 List> <weight=8>" " <vert" " <Msgs> <weight=7>" " <weight=25 Imsg> <weight=7>" " <weight=25 <> <weight=259 gap=8 Btns>>" " >" ); x_pl["List"] << x_lbxUsers; x_pl["Msgs"] << x_lbxMessages; x_pl["Imsg"] << x_txtMessage; x_pl["Btns"] << x_btnExit << x_btnFile << x_btnSend; x_pl.collocate(); Ucl::Bus().Register(*this); } void FrmMain::OnEvent(event::EvMessage &e) noexcept { constexpr static auto kszFmt = L"(%s) %s => %s"; x_lbxMessages.at(0).append({ FormattedTime(), FormatString(L"(%s) %s => %s", e.sCat.c_str(), e.sFrom.c_str(), e.sTo.c_str()), e.sWhat }); x_lbxMessages.scroll(true); } void FrmMain::OnEvent(event::EvListUon &e) noexcept { x_lbxUsers.at(1).model<std::recursive_mutex>( e.vecUon, [] (auto &c) { return AsWideString(c.front().text); }, [] (auto &s) { return std::vector<listbox::cell> {AsUtf8String(s)}; } ); } void FrmMain::OnEvent(event::EvListUff &e) noexcept { x_lbxUsers.at(2).model<std::recursive_mutex>( e.vecUff, [] (auto &c) { return AsWideString(c.front().text); }, [] (auto &s) { return std::vector<listbox::cell> {AsUtf8String(s)}; } ); } void FrmMain::OnEvent(event::EvFileReq &e) noexcept { user(std::make_unique<event::EvFileReq>(e).release()); } void FrmMain::X_OnSend() { auto vec = x_lbxUsers.selected(); if (vec.empty()) { msgbox mbx {nullptr, TitleU8(L"Send message"), msgbox::ok}; mbx.icon(msgbox::icon_error); mbx << L"Please select a recipient"; mbx(); return; } auto &idx = vec.front(); auto sUser = AsWideString(x_lbxUsers.at(idx.cat).at(idx.item).text(0)); switch (idx.cat) { case 1: // Online X_AddMessage({kszCatChat, kszSelf, sUser, x_txtMessage.caption_wstring()}); (*Ucl::Pmg())[sUser].PostPacket(protocol::EvpMessage { x_txtMessage.caption_wstring() }); break; case 2: // Offline X_AddMessage({kszCatFmsg, kszSelf, sUser, x_txtMessage.caption_wstring()}); Ucl::Con()->PostPacket(protocol::EvcMessageTo { sUser, x_txtMessage.caption_wstring() }); break; default: throw ExnIllegalState {}; } x_txtMessage.caption(String {}); } void FrmMain::X_OnFile() { auto vec = x_lbxUsers.selected(); if (vec.empty()) { msgbox mbx {TitleU8(L"Send file")}; mbx.icon(msgbox::icon_error); mbx << L"Please select a recipient"; mbx(); return; } auto &idx = vec.front(); if (idx.cat != 1) { msgbox mbx {TitleU8(L"Send file")}; mbx.icon(msgbox::icon_error); mbx << L"Please select an online user"; mbx(); return; } auto sUser = AsWideString(x_lbxUsers.at(idx.cat).at(idx.item).text(0)); filebox fbx {nullptr, true}; if (!fbx()) return; auto sPath = AsWideString(fbx.file()); UccPipl *pPipl; try { pPipl = &(*Ucl::Pmg())[sUser]; } catch (std::out_of_range) { msgbox mbx {TitleU8(L"Send file")}; mbx << L"The user if offline"; mbx(); return; } form_loader<FrmFileSend>() (*this, pPipl, sPath).show(); } void FrmMain::X_OnDestroy(const nana::arg_destroy &e) { Ucl::Con()->PostPacket(protocol::EvcExit {Ucl::Usr()}); Ucl::Con()->Shutdown(); Ucl::Pmg()->Shutdown(); Ucl::Bus().Unregister(*this); } void FrmMain::X_OnUser(const nana::arg_user &e) { std::unique_ptr<event::EvFileReq> up { reinterpret_cast<event::EvFileReq *>(e.param) }; try { form_loader<FrmFileRecv>() (*this, up->pPipl, up->eReq).show(); } catch (ExnIllegalState) {} } void FrmMain::X_AddMessage(event::EvMessage &&e) noexcept { OnEvent(e); }
18296b24c1a4c774d930261e017e37a0cf8d04fa
d0601b28a3060105e82c2a839d435c4329fe82a9
/OpenGL_Material/build-OpenGL_Material-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug/debug/moc_mainwindow.cpp
51b68186ab06892d4bfefdfe122cf57267d5fcdf
[]
no_license
guoerba/opengl
9458b1b3827e24884bcd0a1b91d122ab6a252f8e
103da63ada1703a3f450cfde19f41b04e922187e
refs/heads/master
2020-07-10T15:40:49.828059
2019-08-25T13:52:58
2019-08-25T13:52:58
204,300,456
0
0
null
null
null
null
UTF-8
C++
false
false
2,706
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'mainwindow.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../OpenGL_Material/mainwindow.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'mainwindow.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.8.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_MainWindow_t { QByteArrayData data[1]; char stringdata0[11]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = { { QT_MOC_LITERAL(0, 0, 10) // "MainWindow" }, "MainWindow" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_MainWindow[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount 0 // eod }; void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { Q_UNUSED(_o); Q_UNUSED(_id); Q_UNUSED(_c); Q_UNUSED(_a); } const QMetaObject MainWindow::staticMetaObject = { { &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow.data, qt_meta_data_MainWindow, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *MainWindow::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *MainWindow::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_MainWindow.stringdata0)) return static_cast<void*>(const_cast< MainWindow*>(this)); return QMainWindow::qt_metacast(_clname); } int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
fc66a1678930bf9093bd076f90dd380635b60366
ceeddddcf3e99e909c4af5ff2b9fad4a8ecaeb2a
/branches/releases/1.3.NET/source/Irrlicht/CGUIColorSelectDialog.h
fed63371d4d75b6f6d20e164aab8c2e8f2527655
[ "Zlib", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
jivibounty/irrlicht
d9d6993bd0aee00dce2397a887b7f547ade74fbb
c5c80cde40b6d14fe5661440638d36a16b41d7ab
refs/heads/master
2021-01-18T02:56:08.844268
2015-07-21T08:02:25
2015-07-21T08:02:25
39,405,895
0
0
null
2015-07-20T20:07:06
2015-07-20T20:07:06
null
UTF-8
C++
false
false
1,684
h
// Copyright (C) 2002-2007 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #ifndef __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ #define __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__ #include "IGUIColorSelectDialog.h" #include "IGUIButton.h" #include "IGUIEditBox.h" #include "IGUIScrollBar.h" #include "IGUIImage.h" #include "irrArray.h" namespace irr { namespace gui { class CGUIColorSelectDialog : public IGUIColorSelectDialog { public: //! constructor CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id); //! destructor virtual ~CGUIColorSelectDialog(); //! called if an event happened. virtual bool OnEvent(SEvent event); //! draws the element and its children virtual void draw(); private: //! sends the event that the file has been selected. void sendSelectedEvent(); //! sends the event that the file choose process has been canceld void sendCancelEvent(); core::position2d<s32> DragStart; bool Dragging; IGUIButton* CloseButton; IGUIButton* OKButton; IGUIButton* CancelButton; struct SBatteryItem { f32 Incoming; f32 Outgoing; IGUIEditBox * Edit; IGUIScrollBar *Scrollbar; }; core::array< SBatteryItem > Battery; struct SColorCircle { IGUIImage * Control; video::ITexture * Texture; }; SColorCircle ColorRing; void buildColorRing( const core::dimension2d<s32> & dim, s32 supersample, const u32 borderColor ); }; } // end namespace gui } // end namespace irr #endif
[ "hybrid@dfc29bdd-3216-0410-991c-e03cc46cb475" ]
hybrid@dfc29bdd-3216-0410-991c-e03cc46cb475
38f7c8a3cad67c635c35e49aa86561033dd5059e
b2b9e4d616a6d1909f845e15b6eaa878faa9605a
/Genemardon/20150726浙大月赛/H.cpp
a21dd35a335cc1f9d08f48963c32541c661122f1
[]
no_license
JinbaoWeb/ACM
db2a852816d2f4e395086b2b7f2fdebbb4b56837
021b0c8d9c96c1bc6e10374ea98d0706d7b509e1
refs/heads/master
2021-01-18T22:32:50.894840
2016-06-14T07:07:51
2016-06-14T07:07:51
55,882,694
0
0
null
null
null
null
UTF-8
C++
false
false
737
cpp
#include <stdio.h> #include <string.h> #include <algorithm> #include <vector> using namespace std; vector<int>tab[50010]; int n,m,q; int ans[50010]; int main(int argc, char const *argv[]) { while (scanf("%d%d%d",&n,&m,&q) != EOF) { memset(ans,0,sizeof(ans)); for (int i=1;i<=n;i++) tab[i].clear(); for (int i=0;i<m;i++) { int u,v; scanf("%d%d",&u,&v); if (v<u) tab[u].push_back(v); } int m1=n,m2=n; for (int i=n;i>1;i--) { for (int j=0;j<tab[i].size();j++) if (tab[i][j]<m1) { m2=m1; m1=tab[i][j]; } else if (tab[i][j]<m2) { m2=tab[i][j]; } ans[i]=max(i-m2,0); } int ask; for (int i=0;i<q;i++) { scanf("%d",&ask); printf("%d\n", ans[ask]); } } return 0; }
088e07cf5b8e57147205361a7bb8da08825fbeeb
8dc84558f0058d90dfc4955e905dab1b22d12c08
/third_party/blink/renderer/core/html/link_element_loading_test.cc
c82c7593f5fe8ef11d8e34e702f07dfa1a2f5fb7
[ "LGPL-2.0-only", "BSD-2-Clause", "LGPL-2.1-only", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
meniossin/src
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
44f73f7e76119e5ab415d4593ac66485e65d700a
refs/heads/master
2022-12-16T20:17:03.747113
2020-09-03T10:43:12
2020-09-03T10:43:12
263,710,168
1
0
BSD-3-Clause
2020-05-13T18:20:09
2020-05-13T18:20:08
null
UTF-8
C++
false
false
1,395
cc
// Copyright 2016 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 "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/html/html_link_element.h" #include "third_party/blink/renderer/core/testing/sim/sim_request.h" #include "third_party/blink/renderer/core/testing/sim/sim_test.h" namespace blink { class LinkElementLoadingTest : public SimTest {}; TEST_F(LinkElementLoadingTest, ShouldCancelLoadingStyleSheetIfLinkElementIsDisconnected) { SimRequest main_resource("https://example.com/test.html", "text/html"); SimRequest css_resource("https://example.com/test.css", "text/css"); LoadURL("https://example.com/test.html"); main_resource.Start(); main_resource.Write( "<!DOCTYPE html><link id=link rel=stylesheet href=test.css>"); // Sheet is streaming in, but not ready yet. css_resource.Start(); // Remove a link element from a document HTMLLinkElement* link = ToHTMLLinkElement(GetDocument().getElementById("link")); EXPECT_NE(nullptr, link); link->remove(); // Finish the load. css_resource.Complete(); main_resource.Finish(); // Link element's sheet loading should be canceled. EXPECT_EQ(nullptr, link->sheet()); } } // namespace blink
e5da24000808179faf59b1240f2745fd73190189
129136fed2665b6554223cb95407b1bbb7c421e2
/Programming/1-2_sem/Qsort_opt/Qsort_opt.cpp
61fe73c950928a8237e6ccb996816d7ad125f5f5
[]
no_license
PotapovaSofia/DIHT-MIPT
e28f62c3ef91137d86ee8585ad4daefb1930a890
aef75ac5154d22ce0e424b3874bf15bae779fbf0
refs/heads/master
2016-09-05T16:44:46.501488
2016-02-20T21:46:23
2016-02-20T21:46:23
32,089,336
2
1
null
null
null
null
UTF-8
C++
false
false
2,077
cpp
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> void generation(int* Arr, int n) { int i; srand(time(NULL)); for ( i=0;i<n;++i) { Arr[i] = rand()%100 - 50; printf("%d ", Arr[i]); } printf("\n"); } int cmp_(void* a, void* b){ return (*(int*)a - *(int*)b); } void swap(void* a, void* b, size_t size) { char* x = (char*)(malloc(size)); memcpy(x, a, size); memcpy(a, b, size); memcpy(b, x, size); free(x); } void QuickSort ( void* Arr, int first, int last, size_t size, int(*cmp)(void*, void*)) { if ((last - first) > 10) { int i, j; i = first; j = last; int key = (rand() % last + first) % last; char *buf = (char*)malloc(size); memcpy(buf, (char*)Arr + key*size, size); do { while (cmp((char*)Arr + i*size, buf) < 0) i++; while (cmp((char*)Arr + j*size, buf) > 0) j--; if(i <= j) { if (i < j) swap((char*)Arr + i*size, (char*)Arr + j*size, size); i++; j--; } } while (i <= j); if (i < last) QuickSort(Arr, i, last, size, cmp); if (first < j) QuickSort(Arr, first,j, size, cmp); } } void InsertSort(void* a, int n, size_t size, int(*cmp)(void*, void*)) { int i; for (i = 1; i < n; ++i) { char* key = (char*)(malloc(size)); memcpy(key, (char*)a + i* size, size); int j = i - 1; while ((j >= 0) && (cmp((char*)a + j * size, key) > 0)) { swap((char*)a + j*size, (char*)a + (j + 1) * size, size); j--; } memcpy((char*)a + (j + 1) * size, key, size); } } int main() { int i, n; printf("Number: "); scanf("%d", &n); printf ("\n"); int* Arr = (int*)(malloc(sizeof(int)*n)); generation(Arr, n); int(*p)(void*, void*); p = cmp_; QuickSort(Arr, 0, n - 1, sizeof(int), p); InsertSort(Arr, n, sizeof(int), p); for (i = 0; i < n; ++i) { printf("%d ", Arr[i]); } free(Arr); return 0; }
508d55d75ab154fe547faf8438d150f7652f0e14
52a3c93c38bef127eaee4420f36a89d929a321c5
/SDK/SoT_BP_FishingFish_Wrecker_05_Colour_05_Moon_classes.hpp
8be34a73802fcedf704075651af56099a98ab051
[]
no_license
RDTCREW/SoT-SDK_2_0_7_reserv
8e921275508d09e5f81b10f9a43e47597223cb35
db6a5fc4cdb9348ddfda88121ebe809047aa404a
refs/heads/master
2020-07-24T17:18:40.537329
2019-09-11T18:53:58
2019-09-11T18:53:58
207,991,316
0
0
null
null
null
null
UTF-8
C++
false
false
883
hpp
#pragma once // Sea of Thieves (2.0) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "SoT_BP_FishingFish_Wrecker_05_Colour_05_Moon_structs.hpp" namespace SDK { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_FishingFish_Wrecker_05_Colour_05_Moon.BP_FishingFish_Wrecker_05_Colour_05_Moon_C // 0x0000 (0x0990 - 0x0990) class ABP_FishingFish_Wrecker_05_Colour_05_Moon_C : public ABP_FishingFish_Wrecker_05_C { public: static UClass* StaticClass() { static auto ptr = UObject::FindObject<UClass>(_xor_("BlueprintGeneratedClass BP_FishingFish_Wrecker_05_Colour_05_Moon.BP_FishingFish_Wrecker_05_Colour_05_Moon_C")); return ptr; } void UserConstructionScript(); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
3046cc516b94d3d61b5944e8e72cb324eb8e83b2
2f10f807d3307b83293a521da600c02623cdda82
/deps/boost/win/debug/include/boost/hana/fwd/concept/sequence.hpp
422e52578079c9edc98e149f855e4d4868c1d9cf
[]
no_license
xpierrohk/dpt-rp1-cpp
2ca4e377628363c3e9d41f88c8cbccc0fc2f1a1e
643d053983fce3e6b099e2d3c9ab8387d0ea5a75
refs/heads/master
2021-05-23T08:19:48.823198
2019-07-26T17:35:28
2019-07-26T17:35:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
129
hpp
version https://git-lfs.github.com/spec/v1 oid sha256:2995f98908d109d3d0c6f3843c95855164d1b5d8229cdc1d99bcf3b7094d3655 size 7412
9db88d488c6ffd2b10d44ee4753ddf7f6822594e
81bb77804b2481a92c0d48ad2f76e5b79d29e9ec
/src/base58.h
458f045ad5289379066b5ccc631231dae4dcac16
[ "MIT" ]
permissive
AndrewJEON/qtum
a5216a67c25e818b11266366f37d0b7bcf5a573f
5373115c4550a9dbd99f360dd50cc4f67722dc91
refs/heads/master
2021-06-11T16:50:00.126511
2017-03-14T17:12:40
2017-03-14T17:12:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,741
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. /** * Why base-58 instead of standard base-64 encoding? * - Don't want 0OIl characters that look the same in some fonts and * could be used to create visually identical looking data. * - A string with non-alphanumeric characters is not as easily accepted as input. * - E-mail usually won't line-break if there's no punctuation to break at. * - Double-clicking selects the whole string as one word if it's all alphanumeric. */ #ifndef QUANTUM_BASE58_H #define QUANTUM_BASE58_H #include "chainparams.h" #include "key.h" #include "pubkey.h" #include "script/script.h" #include "script/standard.h" #include "support/allocators/zeroafterfree.h" #include <string> #include <vector> /** * Encode a byte sequence as a base58-encoded string. * pbegin and pend cannot be NULL, unless both are. */ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend); /** * Encode a byte vector as a base58-encoded string */ std::string EncodeBase58(const std::vector<unsigned char>& vch); /** * Decode a base58-encoded string (psz) into a byte vector (vchRet). * return true if decoding is successful. * psz cannot be NULL. */ bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet); /** * Decode a base58-encoded string (str) into a byte vector (vchRet). * return true if decoding is successful. */ bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet); /** * Encode a byte vector into a base58-encoded string, including checksum */ std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn); /** * Decode a base58-encoded string (psz) that includes a checksum into a byte * vector (vchRet), return true if decoding is successful */ inline bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet); /** * Decode a base58-encoded string (str) that includes a checksum into a byte * vector (vchRet), return true if decoding is successful */ inline bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet); /** * Base class for all base58-encoded data */ class CBase58Data { protected: //! the version byte(s) std::vector<unsigned char> vchVersion; //! the actually encoded data typedef std::vector<unsigned char, zero_after_free_allocator<unsigned char> > vector_uchar; vector_uchar vchData; CBase58Data(); void SetData(const std::vector<unsigned char> &vchVersionIn, const void* pdata, size_t nSize); void SetData(const std::vector<unsigned char> &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend); public: bool SetString(const char* psz, unsigned int nVersionBytes = 1); bool SetString(const std::string& str); std::string ToString() const; int CompareTo(const CBase58Data& b58) const; bool operator==(const CBase58Data& b58) const { return CompareTo(b58) == 0; } bool operator<=(const CBase58Data& b58) const { return CompareTo(b58) <= 0; } bool operator>=(const CBase58Data& b58) const { return CompareTo(b58) >= 0; } bool operator< (const CBase58Data& b58) const { return CompareTo(b58) < 0; } bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; } }; /** base58-encoded Quantum addresses. * Public-key-hash-addresses have version 0 (or 111 testnet). * The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key. * Script-hash-addresses have version 5 (or 196 testnet). * The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script. */ class CQuantumAddress : public CBase58Data { public: bool Set(const CKeyID &id); bool Set(const CScriptID &id); bool Set(const CTxDestination &dest); bool IsValid() const; bool IsValid(const CChainParams &params) const; CQuantumAddress() {} CQuantumAddress(const CTxDestination &dest) { Set(dest); } CQuantumAddress(const std::string& strAddress) { SetString(strAddress); } CQuantumAddress(const char* pszAddress) { SetString(pszAddress); } CTxDestination Get() const; bool GetKeyID(CKeyID &keyID) const; bool IsScript() const; }; /** * A base58-encoded secret key */ class CQuantumSecret : public CBase58Data { public: void SetKey(const CKey& vchSecret); CKey GetKey(); bool IsValid() const; bool SetString(const char* pszSecret); bool SetString(const std::string& strSecret); CQuantumSecret(const CKey& vchSecret) { SetKey(vchSecret); } CQuantumSecret() {} }; template<typename K, int Size, CChainParams::Base58Type Type> class CQuantumExtKeyBase : public CBase58Data { public: void SetKey(const K &key) { unsigned char vch[Size]; key.Encode(vch); SetData(Params().Base58Prefix(Type), vch, vch+Size); } K GetKey() { K ret; if (vchData.size() == Size) { //if base58 encouded data not holds a ext key, return a !IsValid() key ret.Decode(&vchData[0]); } return ret; } CQuantumExtKeyBase(const K &key) { SetKey(key); } CQuantumExtKeyBase(const std::string& strBase58c) { SetString(strBase58c.c_str(), Params().Base58Prefix(Type).size()); } CQuantumExtKeyBase() {} }; typedef CQuantumExtKeyBase<CExtKey, BIP32_EXTKEY_SIZE, CChainParams::EXT_SECRET_KEY> CQuantumExtKey; typedef CQuantumExtKeyBase<CExtPubKey, BIP32_EXTKEY_SIZE, CChainParams::EXT_PUBLIC_KEY> CQuantumExtPubKey; #endif // QUANTUM_BASE58_H
a4b0f42c09efa2ae00be3b45fa8c4aee80eac3e7
575731c1155e321e7b22d8373ad5876b292b0b2f
/examples/native/ios/Pods/boost-for-react-native/boost/metaparse/v1/impl/push_back_c.hpp
c6868c0dc16cb49fd78c00b976ceed9edb14fad6
[ "BSL-1.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Nozbe/zacs
802a84ffd47413a1687a573edda519156ca317c7
c3d455426bc7dfb83e09fdf20781c2632a205c04
refs/heads/master
2023-06-12T20:53:31.482746
2023-06-07T07:06:49
2023-06-07T07:06:49
201,777,469
432
10
MIT
2023-01-24T13:29:34
2019-08-11T14:47:50
JavaScript
UTF-8
C++
false
false
1,027
hpp
#ifndef BOOST_METAPARSE_V1_PUSH_BACK_C_HPP #define BOOST_METAPARSE_V1_PUSH_BACK_C_HPP // Copyright Abel Sinkovics ([email protected]) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <boost/metaparse/config.hpp> #include <boost/metaparse/v1/fwd/string.hpp> #include <boost/metaparse/v1/impl/update_c.hpp> #include <boost/metaparse/v1/impl/size.hpp> namespace boost { namespace metaparse { namespace v1 { namespace impl { template <class S, char C> struct push_back_c; #ifdef BOOST_METAPARSE_VARIADIC_STRING template <char... Cs, char C> struct push_back_c<string<Cs...>, C> : string<Cs..., C> {}; #else template <class S, char C> struct push_back_c : update_c<typename S::type, size<typename S::type>::type::value, C> {}; #endif } } } } #endif
72a8c8e1d5a24677d25f802676368885cde7f460
c712c82341b30aad4678f6fbc758d6d20bd84c37
/CAC_Source_1.7884/RecusalBookDialog.h
43ecb8655aa472f0ac07fe40bdad7923e117ad1a
[]
no_license
governmentbg/EPEP_2019_d2
ab547c729021e1d625181e264bdf287703dcb46c
5e68240f15805c485505438b27de12bab56df91e
refs/heads/master
2022-12-26T10:00:41.766991
2020-09-28T13:55:30
2020-09-28T13:55:30
292,803,726
0
0
null
null
null
null
UTF-8
C++
false
false
358
h
class TRecusalBookDialog : public TFloatDialog { public: TRecusalBookDialog(TWindow* parent, TRecusalBookGroup *group, int resId = IDD_RECUSAL_BOOK); protected: TCharListFace *types; TCharAutoListFace *compositions; TDateFace *minDate; TDateFace *maxDate; TLongFace *autogen; TCheckFace *filtered; TCheckFace *recujed; virtual bool IsValid(); };
b807966f3409def6e402e0f4154383a68f8e5e97
b21b07fc237a764474eb9995783c1b714356bf5f
/src/Xyz/SimplexNoise.cpp
d605c33842509507b55cb3da1b68390f4969d9a0
[ "BSD-2-Clause" ]
permissive
jebreimo/Xyz
a26b7d93fbb112ebf6c13369c16313db82b68550
2f3a6773345c28ad2925e24e89cab296561b42c5
refs/heads/master
2023-08-31T03:10:18.086392
2023-08-20T14:46:15
2023-08-20T14:46:15
48,961,224
0
0
null
null
null
null
UTF-8
C++
false
false
5,995
cpp
//**************************************************************************** // Copyright © 2022 Jan Erik Breimo. All rights reserved. // Created by Jan Erik Breimo on 2022-05-07. // // This file is distributed under the BSD License. // License text is included with the source distribution. //**************************************************************************** #include "Xyz/SimplexNoise.hpp" #include <algorithm> // Copied (and slightly adapted) // from https://gist.github.com/Flafla2/f0260a861be0ebdeef76 namespace { // Hash lookup table as defined by Ken SimplexNoise. This is a randomly // arranged array of all numbers from 0-255 inclusive. uint8_t PERMUTATION[256] = { 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 }; double gradient(int hash, double x, double y, double z) { switch (hash & 0xF) { case 0x0: return x + y; case 0x1: return -x + y; case 0x2: return x - y; case 0x3: return -x - y; case 0x4: return x + z; case 0x5: return -x + z; case 0x6: return x - z; case 0x7: return -x - z; case 0x8: return y + z; case 0x9: return -y + z; case 0xA: return y - z; case 0xB: return -y - z; case 0xC: return y + x; case 0xD: return -y + z; case 0xE: return y - x; case 0xF: return -y - z; default: return 0; } } double fade(double t) { // Fade function as defined by Ken SimplexNoise. This eases coordinate // values so that they will "ease" towards integral values. // This ends up smoothing the final output. return t * t * t * (t * (t * 6 - 15) + 10); // 6t^5 - 15t^4 + 10t^3 } double lerp(double a, double b, double x) { return a + x * (b - a); } } SimplexNoise::SimplexNoise() { std::copy(std::begin(PERMUTATION), std::end(PERMUTATION), permutation_); std::copy(std::begin(PERMUTATION), std::end(PERMUTATION), permutation_ + 256); } double SimplexNoise::simplex(double x, double y, double z) { // Calculate the "unit cube" that the point asked will be located in. // The left bound is ( |_x_|,|_y_|,|_z_| ) and the right bound is that // plus 1. Next we calculate the location (from 0.0 to 1.0) in that cube. // We also fade the location to smooth the result. int xi = int(x) & 255; int yi = int(y) & 255; int zi = int(z) & 255; double xf = x - int(x); double yf = y - int(y); double zf = z - int(z); double u = fade(xf); double v = fade(yf); double w = fade(zf); int aaa, aba, aab, abb, baa, bba, bab, bbb; aaa = permutation_[permutation_[permutation_[xi] + yi] + zi]; aba = permutation_[permutation_[permutation_[xi] + ++yi] + zi]; aab = permutation_[permutation_[permutation_[xi] + yi] + ++zi]; abb = permutation_[permutation_[permutation_[xi] + ++yi] + ++zi]; baa = permutation_[permutation_[permutation_[++xi] + yi] + zi]; bba = permutation_[permutation_[permutation_[++xi] + ++yi] + zi]; bab = permutation_[permutation_[permutation_[++xi] + yi] + ++zi]; bbb = permutation_[permutation_[permutation_[++xi] + ++yi] + ++zi]; double x1, x2, y1, y2; // The gradient function calculates the dot product between a pseudorandom // gradient vector and the vector from the input coordinate to the 8 // surrounding points in its unit cube. x1 = lerp(gradient(aaa, xf, yf, zf), gradient(baa, xf - 1, yf, zf), u); // This is all then lerped together as a sort of weighted average based on // the faded (u,v,w) values we made earlier. x2 = lerp(gradient(aba, xf, yf - 1, zf), gradient(bba, xf - 1, yf - 1, zf), u); y1 = lerp(x1, x2, v); x1 = lerp(gradient(aab, xf, yf, zf - 1), gradient(bab, xf - 1, yf, zf - 1), u); x2 = lerp(gradient(abb, xf, yf - 1, zf - 1), gradient(bbb, xf - 1, yf - 1, zf - 1), u); y2 = lerp(x1, x2, v); // For convenience, we reduce it to 0 - 1 (theoretical min/max before // is -1 - 1) return (lerp(y1, y2, w) + 1) / 2; } double SimplexNoise::simplex(double x, double y, double z, int octaves, double persistence) { double total = 0; double frequency = 1; double amplitude = 1; double max_value = 0; for (int i = 0; i < octaves; i++) { total += simplex(x * frequency, y * frequency, z * frequency) * amplitude; max_value += amplitude; amplitude *= persistence; frequency *= 2; } return total / max_value; }
181a9dfd827524c75789617744e569536f5485aa
8c8ea797b0821400c3176add36dd59f866b8ac3d
/AOJ/aoj0025.cpp
c2403359a69322f0b035d629e82f658fe2bce624
[]
no_license
fushime2/competitive
d3d6d8e095842a97d4cad9ca1246ee120d21789f
b2a0f5957d8ae758330f5450306b629006651ad5
refs/heads/master
2021-01-21T16:00:57.337828
2017-05-20T06:45:46
2017-05-20T06:45:46
78,257,409
0
0
null
null
null
null
UTF-8
C++
false
false
594
cpp
#include <iostream> #include <map> #include <vector> using namespace std; #define N 4 int main(void) { ios::sync_with_stdio(false); int a[N], b[N]; int hit, blow; while(cin >> a[0] >> a[1] >> a[2] >> a[3], !cin.eof()) { for(int i=0; i<N; i++) cin >> b[i]; hit = blow = 0; for(int i=0; i<N; i++) { for(int j=0; j<N; j++) { if(a[i] == b[j]) { if(i == j) hit++; else blow++; } } } cout << hit << " " << blow << endl; } return 0; }
d5b10fd840e59b756c211cab4d2eb6bb258e3e76
ef15a4a77b6e1fbb3220a5047885ba7568a80b74
/src/core/Core/SignalToStop.hpp
b66f5a6ec1be9ca38fff701986ce19cd9dde6921
[]
no_license
el-bart/ACARM-ng
22ad5a40dc90a2239206f18dacbd4329ff8377de
de277af4b1c54e52ad96cbe4e1f574bae01b507d
refs/heads/master
2020-12-27T09:24:14.591095
2014-01-28T19:24:34
2014-01-28T19:24:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
843
hpp
/* * SignalToStop.hpp * */ #ifndef INCLUDE_CORE_SIGNALTOSTOP_HPP_FILE #define INCLUDE_CORE_SIGNALTOSTOP_HPP_FILE /* public header */ #include "System/SignalRegistrator.hpp" #include "Logger/Node.hpp" #include "Core/WorkThreads.hpp" namespace Core { /** \brief handles given signal's registration and unregistration. * * when given signal is received system is triggered to stop. */ class SignalToStop: public System::SignalRegistrator { public: /** \brief registers handle for signal. * \param signum signal number to be handled. * \param wt main system threads. if NULL, signal is ignored. */ SignalToStop(int signum, WorkThreads *wt); /** \brief unregisters signal handle. */ ~SignalToStop(void); private: int signum_; Logger::Node log_; }; // class SignalToStop } // namespace Core #endif
69721892a768fac6808ee60dfd9672acacbdc19b
b33a9177edaaf6bf185ef20bf87d36eada719d4f
/qtdeclarative/src/qml/jsruntime/qv4profiling_p.h
6c54fc9bbdf19a1654d96b536ae8d0244adb9e27
[ "Qt-LGPL-exception-1.1", "LGPL-2.1-only", "LGPL-2.0-or-later", "LGPL-3.0-only", "GPL-3.0-only", "LGPL-2.1-or-later", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference", "GPL-2.0-only", "GFDL-1.3-only", "LicenseRef-scancode-digia-qt-preview", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-generic-exception" ]
permissive
wgnet/wds_qt
ab8c093b8c6eead9adf4057d843e00f04915d987
8db722fd367d2d0744decf99ac7bafaba8b8a3d3
refs/heads/master
2021-04-02T11:07:10.181067
2020-06-02T10:29:03
2020-06-02T10:34:19
248,267,925
1
0
Apache-2.0
2020-04-30T12:16:53
2020-03-18T15:20:38
null
UTF-8
C++
false
false
6,825
h
/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** As a special exception, The Qt Company gives you certain additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QV4PROFILING_H #define QV4PROFILING_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include "qv4global_p.h" #include "qv4engine_p.h" #include "qv4function_p.h" #include <QElapsedTimer> QT_BEGIN_NAMESPACE namespace QV4 { namespace Profiling { enum Features { FeatureFunctionCall, FeatureMemoryAllocation }; enum MemoryType { HeapPage, LargeItem, SmallItem }; struct FunctionCallProperties { qint64 start; qint64 end; QString name; QString file; int line; int column; }; struct MemoryAllocationProperties { qint64 timestamp; qint64 size; MemoryType type; }; class FunctionCall { public: FunctionCall() : m_function(0), m_start(0), m_end(0) { Q_ASSERT_X(false, Q_FUNC_INFO, "Cannot construct a function call without function"); } FunctionCall(Function *function, qint64 start, qint64 end) : m_function(function), m_start(start), m_end(end) { m_function->compilationUnit->addref(); } FunctionCall(const FunctionCall &other) : m_function(other.m_function), m_start(other.m_start), m_end(other.m_end) { m_function->compilationUnit->addref(); } ~FunctionCall() { m_function->compilationUnit->release(); } FunctionCall &operator=(const FunctionCall &other) { if (&other != this) { if (m_function) m_function->compilationUnit->release(); m_function = other.m_function; m_start = other.m_start; m_end = other.m_end; m_function->compilationUnit->addref(); } return *this; } FunctionCallProperties resolve() const; private: friend bool operator<(const FunctionCall &call1, const FunctionCall &call2); Function *m_function; qint64 m_start; qint64 m_end; }; #define Q_V4_PROFILE_ALLOC(engine, size, type)\ (engine->profiler &&\ (engine->profiler->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\ engine->profiler->trackAlloc(size, type) : size) #define Q_V4_PROFILE_DEALLOC(engine, pointer, size, type) \ (engine->profiler &&\ (engine->profiler->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\ engine->profiler->trackDealloc(pointer, size, type) : pointer) #define Q_V4_PROFILE(engine, function)\ (engine->profiler &&\ (engine->profiler->featuresEnabled & (1 << Profiling::FeatureFunctionCall)) ?\ Profiling::FunctionCallProfiler::profileCall(engine->profiler, engine, function) :\ function->code(engine, function->codeData)) class Q_QML_EXPORT Profiler : public QObject { Q_OBJECT Q_DISABLE_COPY(Profiler) public: Profiler(QV4::ExecutionEngine *engine); size_t trackAlloc(size_t size, MemoryType type) { MemoryAllocationProperties allocation = {m_timer.nsecsElapsed(), (qint64)size, type}; m_memory_data.append(allocation); return size; } void *trackDealloc(void *pointer, size_t size, MemoryType type) { MemoryAllocationProperties allocation = {m_timer.nsecsElapsed(), -(qint64)size, type}; m_memory_data.append(allocation); return pointer; } quint64 featuresEnabled; public slots: void stopProfiling(); void startProfiling(quint64 features); void reportData(); void setTimer(const QElapsedTimer &timer) { m_timer = timer; } signals: void dataReady(const QVector<QV4::Profiling::FunctionCallProperties> &, const QVector<QV4::Profiling::MemoryAllocationProperties> &); private: QV4::ExecutionEngine *m_engine; QElapsedTimer m_timer; QVector<FunctionCall> m_data; QVector<MemoryAllocationProperties> m_memory_data; friend class FunctionCallProfiler; }; class FunctionCallProfiler { Q_DISABLE_COPY(FunctionCallProfiler) public: // It's enough to ref() the function in the destructor as it will probably not disappear while // it's executing ... FunctionCallProfiler(Profiler *profiler, Function *function) : profiler(profiler), function(function), startTime(profiler->m_timer.nsecsElapsed()) {} ~FunctionCallProfiler() { profiler->m_data.append(FunctionCall(function, startTime, profiler->m_timer.nsecsElapsed())); } static ReturnedValue profileCall(Profiler *profiler, ExecutionEngine *engine, Function *function) { FunctionCallProfiler callProfiler(profiler, function); return function->code(engine, function->codeData); } Profiler *profiler; Function *function; qint64 startTime; }; } // namespace Profiling } // namespace QV4 Q_DECLARE_TYPEINFO(QV4::Profiling::MemoryAllocationProperties, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QV4::Profiling::FunctionCallProperties, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QV4::Profiling::FunctionCall, Q_MOVABLE_TYPE); QT_END_NAMESPACE Q_DECLARE_METATYPE(QVector<QV4::Profiling::FunctionCallProperties>) Q_DECLARE_METATYPE(QVector<QV4::Profiling::MemoryAllocationProperties>) #endif // QV4PROFILING_H
e063d1a76d7610f8d626233ecb551423c89f987c
3dbe2d0454979091d3f1f23c3bda6f8371efe8be
/arm_compute/runtime/CL/ICLGEMMKernelSelection.h
69b941109d33bf329ad9fe1ab326458b98ddd52e
[ "MIT", "LicenseRef-scancode-dco-1.1" ]
permissive
alexjung/ComputeLibrary
399339e097a34cf28f64ac23b3ccb371e121a4c9
a9d47c17791ebce45427ea6331bd6e35f7d721f4
refs/heads/master
2022-11-25T22:34:48.281986
2020-07-30T14:38:20
2020-07-30T14:38:20
283,794,492
0
0
MIT
2020-07-30T14:16:27
2020-07-30T14:16:26
null
UTF-8
C++
false
false
2,579
h
/* * Copyright (c) 2020 ARM Limited. * * SPDX-License-Identifier: MIT * * 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. */ #ifndef ARM_COMPUTE_ICLGEMMKERNELSELECTION_H #define ARM_COMPUTE_ICLGEMMKERNELSELECTION_H #include "arm_compute/core/GPUTarget.h" #include "arm_compute/core/Types.h" #include "arm_compute/runtime/CL/CLTypes.h" namespace arm_compute { namespace cl_gemm { /** Basic interface for the GEMM kernel selection */ class ICLGEMMKernelSelection { public: /** Constructor * * @param[in] arch GPU target */ ICLGEMMKernelSelection(GPUTarget arch) : _target(arch) { } /** Default Move Constructor. */ ICLGEMMKernelSelection(ICLGEMMKernelSelection &&) = default; /** Default move assignment operator */ ICLGEMMKernelSelection &operator=(ICLGEMMKernelSelection &&) = default; /** Virtual destructor */ virtual ~ICLGEMMKernelSelection() = default; /** Given the input parameters passed through @ref CLGEMMKernelSelectionParams, this method returns the @ref CLGEMMKernelType to use * * @param[in] params Input parameters used by the function to return the OpenCL GEMM's kernel * * @return @ref CLGEMMKernelType */ virtual CLGEMMKernelType select_kernel(const CLGEMMKernelSelectionParams &params) = 0; protected: GPUTarget _target; /**< GPU target could be used to call a dedicated heuristic for each GPU IP for a given GPU architecture */ }; } // namespace cl_gemm } // namespace arm_compute #endif /*ARM_COMPUTE_ICLGEMMKERNELSELECTION_H */
abb4494d31f83c59e62840a3cbee255fc3dd0ca4
3011f9e4204f2988c983b8815187f56a6bf58ebd
/src/ys_library/ysglcpp/src/nownd/ysglbuffermanager_nownd.h
af34a97c2e372bd4ad528a98ad9a18d6f039d852
[]
no_license
hvantil/AR-BoardGames
9e80a0f2bb24f8bc06902785d104178a214d0d63
71b9620df66d80c583191b8c8e8b925a6df5ddc3
refs/heads/master
2020-03-17T01:36:47.674272
2018-05-13T18:11:16
2018-05-13T18:11:16
133,160,216
0
0
null
null
null
null
UTF-8
C++
false
false
1,763
h
/* //////////////////////////////////////////////////////////// File Name: ysglbuffermanager_nownd.h Copyright (c) 2017 Soji Yamakawa. All rights reserved. http://www.ysflight.com Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //////////////////////////////////////////////////////////// */ #ifndef YSGLBUFFERMANAGER_GL2_IS_INCLUDED #define YSGLBUFFERMANAGER_GL2_IS_INCLUDED /* { */ #include <ysclass.h> #include <ysglbuffermanager.h> class YsGLBufferManager::ActualBuffer { public: }; /* } */ #endif
7256649c1b45655ea0cc7a7affc81c5f3fe54265
adbc979313cbc1f0d42c79ac4206d42a8adb3234
/Source Code/李沿橙 2017-10-23/source/李沿橙/bus/bus.cpp
0e0ba6ecc02f0bc9722cb827d7c4ccb465cb67b0
[]
no_license
UnnamedOrange/Contests
a7982c21e575d1342d28c57681a3c98f8afda6c0
d593d56921d2cde0c473b3abedb419bef4cf3ba4
refs/heads/master
2018-10-22T02:26:51.952067
2018-07-21T09:32:29
2018-07-21T09:32:29
112,301,400
1
0
null
null
null
null
UTF-8
C++
false
false
3,218
cpp
#pragma G++ optimize("O3") #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <string> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <bitset> using std::cin; using std::cout; using std::endl; typedef int INT; inline INT readIn() { INT a = 0; bool minus = false; char ch = getchar(); while (!(ch == '-' || ch >= '0' && ch <= '9')) ch = getchar(); if (ch == '-') { minus = true; ch = getchar(); } while (ch >= '0' && ch <= '9') { a *= 10; a += ch; a -= '0'; ch = getchar(); } if (minus) a = -a; return a; } inline void printOut(INT x) { if (!x) { putchar('0'); } else { char buffer[12]; INT length = 0; bool minus = x < 0; if (minus) x = -x; while (x) { buffer[length++] = x % 10 + '0'; x /= 10; } if (minus) buffer[length++] = '-'; do { putchar(buffer[--length]); } while (length); } putchar(' '); } const INT maxn = INT(1e6) + 5; INT n, maxc; INT c[maxn]; INT v[maxn]; struct stack : public std::vector<INT> { INT back2() { return std::vector<INT>::operator[](std::vector<INT>::size() - 2); } }; #define RunInstance(x) delete new x struct cheat1 { static const INT maxN = 5005; INT f[maxN]; cheat1() : f() { f[0] = 0; for (int i = 1; i <= n; i++) { f[i] = -1; for (int j = 0; j < i; j++) { if ((i - j) % c[j] || f[j] == -1) continue; INT t = f[j] + (i - j) / c[j] * v[j]; if (f[i] == -1 || f[i] > t) f[i] = t; } printOut(f[i]); } putchar('\n'); } }; struct cheat2 { cheat2() { INT cnt = v[0]; INT sum = 0; for (int i = 1; i <= n; i++) { printOut(sum += cnt); cnt = std::min(cnt, v[i]); } } }; struct work { INT f[maxn]; stack q[11][10]; INT y(INT s) { return c[s] * f[s] - s * v[s]; } INT x(INT s) { return v[s]; } INT y(INT i, INT j) { return y(i) - y(j); } INT x(INT i, INT j) { return x(j) - x(i); } double slope(INT i, INT j) { INT x2 = x(i, j); if (!x2) return 1e100; return double(y(i, j)) / x2; } INT dp(INT i, INT j) { return f[j] + (i - j) / c[j] * v[j]; } work() : f() { f[0] = 0; q[c[0]][0].push_back(0); for (int i = 1; i <= n; i++) { INT& ans = f[i]; ans = -1; for (int j = 1; j <= maxc; j++) { stack& s = q[j][i % j]; if (s.empty()) continue; while (s.size() > 1 && dp(i, s.back()) >= dp(i, s.back2())) s.pop_back(); INT k = s.back(); INT t = dp(i, k); if (ans == -1 || ans > t) ans = t; } printOut(ans); if (i != n && f[i] != -1) { stack& s = q[c[i]][i % c[i]]; while (s.size() && v[s.back()] >= v[i]) s.pop_back(); while (s.size() > 1 && slope(i, s.back()) >= slope(s.back(), s.back2())) s.pop_back(); s.push_back(i); } } } }; void run() { n = readIn(); maxc = readIn(); for (int i = 0; i < n; i++) { c[i] = readIn(); v[i] = readIn(); } //if (n <= 5000) // RunInstance(cheat1); //else if (maxc == 1) // RunInstance(cheat2); //else RunInstance(work); } int main() { #ifndef JUDGE freopen("bus.in", "r", stdin); freopen("bus.out", "w", stdout); #endif run(); return 0; }
1b1db33275ca9020ab39e1df49702ad2e1dfa7d8
e1c8e3767bac2d7d2bb83e56aa46bfad6286f734
/games/anarchy/fireDepartment.h
6856c29f0c39dee9a08ac9c174999225c4c62dfb
[ "MIT" ]
permissive
joeykuhn/Joueur.cpp
df2709357aae71be84100bf8c39f859ffe965a86
9b3f9d9a37f79aad958f179cb89c4f08706387b8
refs/heads/master
2021-01-24T09:19:20.206407
2016-09-27T23:04:41
2016-09-27T23:04:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,872
h
// Generated by Creer at 01:31AM on December 23, 2015 UTC, git hash: '1b69e788060071d644dd7b8745dca107577844e1' // Can put out fires completely. #ifndef JOUEUR_ANARCHY_FIREDEPARTMENT_H #define JOUEUR_ANARCHY_FIREDEPARTMENT_H #include "anarchy.h" #include "building.h" // <<-- Creer-Merge: includes -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs. // you can add addtional #includes(s) here. // <<-- /Creer-Merge: includes -->> /// <summary> /// Can put out fires completely. /// </summary> class Anarchy::FireDepartment : public Anarchy::Building { friend Anarchy::GameManager; protected: virtual void deltaUpdateField(const std::string& fieldName, boost::property_tree::ptree& delta); FireDepartment() {}; ~FireDepartment() {}; public: /// <summary> /// The amount of fire removed from a building when bribed to extinguish a building. /// </summary> int fireExtinguished; // <<-- Creer-Merge: fields -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs. // you can add addtional fields(s) here. None of them will be tracked or updated by the server. // <<-- /Creer-Merge: fields -->> /// <summary> /// Bribes this FireDepartment to extinguish the some of the fire in a building. /// </summary> /// <param name="building">The Building you want to extinguish.</param> /// <returns>true if the bribe worked, false otherwise</returns> bool extinguish(Anarchy::Building* building); // <<-- Creer-Merge: methods -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs. // you can add addtional method(s) here. // <<-- /Creer-Merge: methods -->> }; #endif
0ebecc26962b4a030a103e91a8befd0cfbb7a7ea
95273e09057dea3ee4d8b2c7405c62c511d76e6c
/src/ESPectroBase_GpioEx.cpp
cf2412036d67e8a1d928b4cc1a1afd5715308196
[]
no_license
alwint3r/EspX
a3af26c86f7bdace1adfe8f3ab5b50a8344bcc05
eed8cb93a18a11a6b72be85326e2fef900427dd7
refs/heads/master
2020-05-29T08:40:33.140368
2017-01-07T19:04:28
2017-01-07T19:04:28
69,655,952
0
0
null
2016-09-30T10:02:22
2016-09-30T10:02:22
null
UTF-8
C++
false
false
979
cpp
// // Created by Andri Yadi on 8/1/16. // #include "ESPectroBase_GpioEx.h" ESPectroBase_GpioEx::ESPectroBase_GpioEx(uint8_t address): SX1508(address), i2cDeviceAddress_(address) { } ESPectroBase_GpioEx::~ESPectroBase_GpioEx() { } byte ESPectroBase_GpioEx::begin(byte address, byte resetPin) { byte addr = (address != ESPECTRO_BASE_GPIOEX_ADDRESS)? address: i2cDeviceAddress_; byte res = SX1508::begin(addr, resetPin); if (res) { SX1508::pinMode(ESPECTRO_BASE_GPIOEX_LED_PIN, OUTPUT); clock(INTERNAL_CLOCK_2MHZ, 4); } return res; } void ESPectroBase_GpioEx::turnOnLED() { SX1508::digitalWrite(ESPECTRO_BASE_GPIOEX_LED_PIN, LOW); } void ESPectroBase_GpioEx::turnOffLED() { SX1508::digitalWrite(ESPECTRO_BASE_GPIOEX_LED_PIN, HIGH); } void ESPectroBase_GpioEx::blinkLED(unsigned long tOn, unsigned long tOff, byte onIntensity, byte offIntensity) { blink(ESPECTRO_BASE_GPIOEX_LED_PIN, tOn, tOff, onIntensity, offIntensity); }
0811a45932f781306c79c102a317affdaf89c095
fae45a23a885b72cd27c0ad1b918ad754b5de9fd
/benchmarks/shenango/parsec/pkgs/tools/cmake/src/Source/cmSeparateArgumentsCommand.cxx
ea6f065af9c9f954ceb35d70187934ff3500acf4
[ "Apache-2.0", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-other-permissive", "MIT" ]
permissive
bitslab/CompilerInterrupts
6678700651c7c83fd06451c94188716e37e258f0
053a105eaf176b85b4c0d5e796ac1d6ee02ad41b
refs/heads/main
2023-06-24T18:09:43.148845
2021-07-26T17:32:28
2021-07-26T17:32:28
342,868,949
3
3
MIT
2021-07-19T15:38:30
2021-02-27T13:57:16
C
UTF-8
C++
false
false
1,314
cxx
/*========================================================================= Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSeparateArgumentsCommand.cxx,v $ Language: C++ Date: $Date: 2012/03/29 17:21:08 $ Version: $Revision: 1.1.1.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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 notices for more information. =========================================================================*/ #include "cmSeparateArgumentsCommand.h" // cmSeparateArgumentsCommand bool cmSeparateArgumentsCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { if(args.size() != 1 ) { this->SetError("called with incorrect number of arguments"); return false; } const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str()); if(!cacheValue) { return true; } std::string value = cacheValue; cmSystemTools::ReplaceString(value," ", ";"); this->Makefile->AddDefinition(args[0].c_str(), value.c_str()); return true; }
7a8ee6e89234f511f0c9621e346ef8e385c5868b
9d4ad6d7f3122f8d32a4a713f06b81ecb7a47c6e
/headers/boost/1.31.0/boost/python/slice_nil.hpp
b77d06cb2248fb3ab7dd61b1ea1fd671d6904430
[]
no_license
metashell/headers
226d6d55eb659134a2ae2aa022b56b893bff1b30
ceb6da74d7ca582791f33906992a5908fcaca617
refs/heads/master
2021-01-20T23:26:51.811362
2018-08-25T07:06:19
2018-08-25T07:06:19
13,360,747
0
1
null
null
null
null
UTF-8
C++
false
false
913
hpp
// Copyright David Abrahams 2002. Permission to copy, use, // modify, sell and distribute this software is granted provided this // copyright notice appears in all copies. This software is provided // "as is" without express or implied warranty, and with no claim as // to its suitability for any purpose. #ifndef SLICE_NIL_DWA2002620_HPP # define SLICE_NIL_DWA2002620_HPP # include <boost/python/detail/prefix.hpp> namespace boost { namespace python { namespace api { class object; enum slice_nil { # ifndef _ // Watch out for GNU gettext users, who #define _(x) _ # endif }; template <class T> struct slice_bound { typedef object type; }; template <> struct slice_bound<slice_nil> { typedef slice_nil type; }; } using api::slice_nil; # ifndef _ // Watch out for GNU gettext users, who #define _(x) using api::_; # endif }} // namespace boost::python #endif // SLICE_NIL_DWA2002620_HPP
b54eacb64f1d68645984c5b1e71e92db1c534771
332515cb827e57f3359cfe0562c5b91d711752df
/Application_UWP_WinRT/Generated Files/winrt/impl/Windows.UI.Xaml.Printing.2.h
5e5ea5bc06e58dbf3fb9e73050c826b0a0063b8c
[ "MIT" ]
permissive
GCourtney27/DX12-Simple-Xbox-Win32-Application
7c1f09abbfb768a1d5c2ab0d7ee9621f66ad85d5
4f0bc4a52aa67c90376f05146f2ebea92db1ec57
refs/heads/master
2023-02-19T06:54:18.923600
2021-01-24T08:18:19
2021-01-24T08:18:19
312,744,674
1
0
null
null
null
null
UTF-8
C++
false
false
4,542
h
// WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.201113.7 #ifndef WINRT_Windows_UI_Xaml_Printing_2_H #define WINRT_Windows_UI_Xaml_Printing_2_H #include "winrt/impl/Windows.UI.Xaml.1.h" #include "winrt/impl/Windows.UI.Xaml.Printing.1.h" WINRT_EXPORT namespace winrt::Windows::UI::Xaml::Printing { struct AddPagesEventHandler : Windows::Foundation::IUnknown { AddPagesEventHandler(std::nullptr_t = nullptr) noexcept {} AddPagesEventHandler(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IUnknown(ptr, take_ownership_from_abi) {} template <typename L> AddPagesEventHandler(L lambda); template <typename F> AddPagesEventHandler(F* function); template <typename O, typename M> AddPagesEventHandler(O* object, M method); template <typename O, typename M> AddPagesEventHandler(com_ptr<O>&& object, M method); template <typename O, typename M> AddPagesEventHandler(weak_ref<O>&& object, M method); auto operator()(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Printing::AddPagesEventArgs const& e) const; }; struct GetPreviewPageEventHandler : Windows::Foundation::IUnknown { GetPreviewPageEventHandler(std::nullptr_t = nullptr) noexcept {} GetPreviewPageEventHandler(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IUnknown(ptr, take_ownership_from_abi) {} template <typename L> GetPreviewPageEventHandler(L lambda); template <typename F> GetPreviewPageEventHandler(F* function); template <typename O, typename M> GetPreviewPageEventHandler(O* object, M method); template <typename O, typename M> GetPreviewPageEventHandler(com_ptr<O>&& object, M method); template <typename O, typename M> GetPreviewPageEventHandler(weak_ref<O>&& object, M method); auto operator()(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Printing::GetPreviewPageEventArgs const& e) const; }; struct PaginateEventHandler : Windows::Foundation::IUnknown { PaginateEventHandler(std::nullptr_t = nullptr) noexcept {} PaginateEventHandler(void* ptr, take_ownership_from_abi_t) noexcept : Windows::Foundation::IUnknown(ptr, take_ownership_from_abi) {} template <typename L> PaginateEventHandler(L lambda); template <typename F> PaginateEventHandler(F* function); template <typename O, typename M> PaginateEventHandler(O* object, M method); template <typename O, typename M> PaginateEventHandler(com_ptr<O>&& object, M method); template <typename O, typename M> PaginateEventHandler(weak_ref<O>&& object, M method); auto operator()(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Printing::PaginateEventArgs const& e) const; }; struct __declspec(empty_bases) AddPagesEventArgs : Windows::UI::Xaml::Printing::IAddPagesEventArgs { AddPagesEventArgs(std::nullptr_t) noexcept {} AddPagesEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : Windows::UI::Xaml::Printing::IAddPagesEventArgs(ptr, take_ownership_from_abi) {} AddPagesEventArgs(); }; struct __declspec(empty_bases) GetPreviewPageEventArgs : Windows::UI::Xaml::Printing::IGetPreviewPageEventArgs { GetPreviewPageEventArgs(std::nullptr_t) noexcept {} GetPreviewPageEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : Windows::UI::Xaml::Printing::IGetPreviewPageEventArgs(ptr, take_ownership_from_abi) {} GetPreviewPageEventArgs(); }; struct __declspec(empty_bases) PaginateEventArgs : Windows::UI::Xaml::Printing::IPaginateEventArgs { PaginateEventArgs(std::nullptr_t) noexcept {} PaginateEventArgs(void* ptr, take_ownership_from_abi_t) noexcept : Windows::UI::Xaml::Printing::IPaginateEventArgs(ptr, take_ownership_from_abi) {} PaginateEventArgs(); }; struct __declspec(empty_bases) PrintDocument : Windows::UI::Xaml::Printing::IPrintDocument, impl::base<PrintDocument, Windows::UI::Xaml::DependencyObject>, impl::require<PrintDocument, Windows::UI::Xaml::IDependencyObject, Windows::UI::Xaml::IDependencyObject2> { PrintDocument(std::nullptr_t) noexcept {} PrintDocument(void* ptr, take_ownership_from_abi_t) noexcept : Windows::UI::Xaml::Printing::IPrintDocument(ptr, take_ownership_from_abi) {} PrintDocument(); [[nodiscard]] static auto DocumentSourceProperty(); }; } #endif
b4d0120da0bc869691692d0bb26876d0ff0995bf
90e02ef236ec48414dcdb5bd08665c865605f984
/src/cisst-saw/sawTrajectories/include/sawTrajectories/osaTrajectory.h
8cb23c2f0b8f4d37ab48e3a23ee07f8097863e12
[]
no_license
NicholasDascanio/dvrk_moveit
3033ccda21d140a5feda0a7a42585c94784a1f13
4d23fa74f3663551791b958f96203f4196b1d765
refs/heads/master
2021-01-03T00:43:10.683504
2020-03-11T17:54:20
2020-03-11T17:54:20
239,836,095
1
0
null
null
null
null
UTF-8
C++
false
false
6,035
h
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */ /* $Id: osaTrajectory.h 4202 2013-05-17 15:39:06Z adeguet1 $ Author(s): Simon Leonard Created on: 2012 (C) Copyright 2012-2014 Johns Hopkins University (JHU), All Rights Reserved. --- begin cisst license - do not edit --- This software is provided "as is" under an open source license, with no warranty. The complete license can be found in license.txt and http://www.cisst.org/cisst/license.txt. --- end cisst license --- */ #ifndef _osaTrajectory_h #define _osaTrajectory_h #include <cisstRobot/robFunction.h> #include <cisstRobot/robManipulator.h> #include <cisstVector/vctFrame4x4.h> #include <cisstVector/vctDynamicVectorTypes.h> #include <list> #include <sawTrajectories/sawTrajectoriesExport.h> class CISST_EXPORT osaTrajectory : public robManipulator{ public: enum Errno { ESUCCESS, EPENDING, EEXPIRED, EEMPTY, EUNSUPPORTED, ETRANSITION, EINVALID }; private: double currenttime; vctDynamicVector<double> q; robFunction* function; enum Space{ R3, RN, SO3, SE3 }; // segment base class class Segment{ private: osaTrajectory::Space inspace; osaTrajectory::Space outspace; protected: double duration; public: Segment( osaTrajectory::Space is, osaTrajectory::Space os ) : inspace( is ), outspace( os ), duration( -1.0 ){} virtual ~Segment() {} virtual osaTrajectory::Space InputSpace() const { return inspace; } virtual osaTrajectory::Space OutputSpace() const { return outspace; } }; std::list< osaTrajectory::Segment* > segments; osaTrajectory::Errno LoadNextSegment(); // Inverse kinematics segment class IKSegment : public Segment { private: vctFrame4x4<double> Rtstart; /**< start Cartesian position */ vctFrame4x4<double> Rtfinal; /**< final Carteisan position */ double v; /**< linear velocity */ double w; /**< angular velocity */ public: IKSegment( const vctFrame4x4<double>& Rts, const vctFrame4x4<double>& Rtf, double v, double w); //! Get segment start position (Cartesian pos 4x4 matrix) vctFrame4x4<double> StateStart() const { return Rtstart; } //! Get segment final position (Cartesian pos 4x4 matrix) vctFrame4x4<double> StateFinal() const { return Rtfinal; } //! Get segment linear velocity double VelocityLinear() const { return v; } //! Get segment angular velocity double VelocityAngular() const { return w; } }; // IK segment // ZC: NOT USED ? // Forward kinematics segment class FKSegment : public Segment { private: vctDynamicVector<double> qstart; vctDynamicVector<double> qfinal; public: FKSegment( const vctDynamicVector<double>& qs, const vctDynamicVector<double>& qf, double ) : Segment( osaTrajectory::SE3, osaTrajectory::RN ), qstart( qs ), qfinal( qf ){} //! Get segment start position (joint space ??? ZC) vctDynamicVector<double> StateStart() const { return qstart; } //! Get segment final position (joint space ??? ZC) vctDynamicVector<double> StateFinal() const { return qfinal; } }; // FK segment // Joint segment class RnSegment : public Segment { private: vctDynamicVector<double> qstart; /**< start joint position */ vctDynamicVector<double> qfinal; /**< final joint position */ vctDoubleVec vel; /**< joint velocity */ public: RnSegment( const vctDynamicVector<double>& qs, const vctDynamicVector<double>& qf, double ); //! Get segment start position (joint space ??? ZC) vctDynamicVector<double> StateStart() const { return qstart; } //! Get segment final position (joint space ??? ZC) vctDynamicVector<double> StateFinal() const { return qfinal; } //! Get segment linear velocity vctDoubleVec VelocityJoint() const { return vel; } }; // Joint segment double GetTime() const { return currenttime; } void SetTime( double t ){ currenttime = t; } osaTrajectory::Errno PostProcess(); public: osaTrajectory( const std::string& robotfilename, const vctFrame4x4<double>& Rtw0, const vctDynamicVector<double>& qinit ); /** * @brief Insert inverse kinematic segment * * @param Rt2 * @param vmax * @param wmax * @return osaTrajectory::Errno Error number */ osaTrajectory::Errno InsertIK( const vctFrame4x4<double>& Rt2, double vmax, double wmax ); osaTrajectory::Errno Insert( const vctFrame4x4<double>& Rt2, double dt ); osaTrajectory::Errno Evaluate( double t, vctFrame4x4<double>& Rt, vctDynamicVector<double>& q ); friend std::ostream& operator<<( std::ostream& os, const osaTrajectory::Errno& e ){ switch( e ){ case osaTrajectory::ESUCCESS: os << "SUCCESS"; break; case osaTrajectory::EPENDING: os << "EPENDING"; break; case osaTrajectory::EEXPIRED: os << "EEXPIRED"; break; case osaTrajectory::EEMPTY: os << "EEMPTY"; break; case osaTrajectory::EUNSUPPORTED: os << "EUNSUPPORTED"; break; case osaTrajectory::ETRANSITION: os << "ETRANSITION"; break; case osaTrajectory::EINVALID: os << "EINVALID"; break; } return os; } }; #endif // _osaTrajectory_h
60e5fb32350ab045ec71c799a0a5c28e815d2ca9
948f4e13af6b3014582909cc6d762606f2a43365
/testcases/juliet_test_suite/testcases/CWE122_Heap_Based_Buffer_Overflow/s04/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_wchar_t_loop_82_goodG2B.cpp
c33c8d71ef39b59ac89102c07f1b01680ea08a75
[]
no_license
junxzm1990/ASAN--
0056a341b8537142e10373c8417f27d7825ad89b
ca96e46422407a55bed4aa551a6ad28ec1eeef4e
refs/heads/master
2022-08-02T15:38:56.286555
2022-06-16T22:19:54
2022-06-16T22:19:54
408,238,453
74
13
null
2022-06-16T22:19:55
2021-09-19T21:14:59
null
UTF-8
C++
false
false
1,351
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_wchar_t_loop_82_goodG2B.cpp Label Definition File: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806.label.xml Template File: sources-sink-82_goodG2B.tmpl.cpp */ /* * @description * CWE: 122 Heap Based Buffer Overflow * BadSource: Initialize data as a large string * GoodSource: Initialize data as a small string * Sinks: loop * BadSink : Copy data to string using a loop * Flow Variant: 82 Data flow: data passed in a parameter to a virtual method called via a pointer * * */ #ifndef OMITGOOD #include "std_testcase.h" #include "CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_wchar_t_loop_82.h" namespace CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_wchar_t_loop_82 { void CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_wchar_t_loop_82_goodG2B::action(wchar_t * data) { { wchar_t dest[50] = L""; size_t i, dataLen; dataLen = wcslen(data); /* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */ for (i = 0; i < dataLen; i++) { dest[i] = data[i]; } dest[50-1] = L'\0'; /* Ensure the destination buffer is null terminated */ printWLine(data); delete [] data; } } } #endif /* OMITGOOD */
bedd6b0597395d00f57558d719997af8cb55958f
6c7cd2aecd2f055a34396cd555c3539d6bf521f1
/sm_kinematics/src/Transformation.cpp
1876fb255d4f7261f685e742d17a5c1e1a9e9a0b
[]
no_license
tsandy/Schweizer-Messer
4dc3b100bd51eee78cdf9827db0143072dd7e5d3
77ba4c6c5668526f8dc8696375d44f5a85db0208
refs/heads/master
2021-01-21T00:01:20.531790
2013-03-22T10:35:17
2013-03-22T10:35:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,250
cpp
#include <sm/kinematics/Transformation.hpp> #include <sm/kinematics/quaternion_algebra.hpp> #include <sm/kinematics/rotations.hpp> #include <sm/random.hpp> #include <sm/kinematics/UncertainHomogeneousPoint.hpp> #include <sm/kinematics/UncertainTransformation.hpp> #include <sm/kinematics/transformations.hpp> namespace sm { namespace kinematics { Transformation::Transformation() : _q_a_b(quatIdentity()), _t_a_b_a(0.0, 0.0, 0.0) { } Transformation::Transformation(Eigen::Matrix4d const & T_a_b) : _q_a_b( r2quat(T_a_b.topLeftCorner<3,3>()) ), _t_a_b_a( T_a_b.topRightCorner<3,1>() ) { } Transformation::Transformation(const Eigen::Vector4d & q_a_b, const Eigen::Vector3d t_a_b_a) : _q_a_b(q_a_b), _t_a_b_a(t_a_b_a) { _q_a_b.normalize(); } Transformation::~Transformation(){} /// @return the rotation matrix Eigen::Matrix3d Transformation::C() const { return quat2r(_q_a_b); } /// @return the translation vector const Eigen::Vector3d & Transformation::t() const { return _t_a_b_a; } const Eigen::Vector4d & Transformation::q() const { return _q_a_b; } Eigen::Matrix4d Transformation::T() const { Eigen::Matrix4d T_a_b; // \todo...make this do less copying. T_a_b.topLeftCorner<3,3>() = quat2r(_q_a_b); T_a_b.topRightCorner<3,1>() = _t_a_b_a; T_a_b.bottomLeftCorner<1,3>().setZero(); T_a_b(3,3) = 1.0; return T_a_b; } Eigen::Matrix<double, 3,4> Transformation::T3x4() const { Eigen::Matrix<double, 3, 4> T3x4; // \todo...make this do less copying. T3x4.topLeftCorner<3,3>() = quat2r(_q_a_b); T3x4.topRightCorner<3,1>() = _t_a_b_a; return T3x4; } Transformation Transformation::inverse() const { // \todo Make this do less copying. return Transformation(quatInv(_q_a_b), quatRotate(quatInv(_q_a_b),-_t_a_b_a)); } void Transformation::checkTransformationIsValid( void ) const { // \todo. } Transformation Transformation::operator*(const Transformation & rhs) const { return Transformation(qplus(_q_a_b,rhs._q_a_b), quatRotate(_q_a_b,rhs._t_a_b_a) + _t_a_b_a); } Eigen::Vector3d Transformation::operator*(const Eigen::Vector3d & rhs) const { return quatRotate(_q_a_b, rhs) + _t_a_b_a; } Eigen::Vector4d Transformation::operator*(const Eigen::Vector4d & rhs) const { Eigen::Vector4d rval; rval.head<3>() = quatRotate(_q_a_b, rhs.head<3>()) + rhs[3] * _t_a_b_a; rval[3] = rhs[3]; return rval; } HomogeneousPoint Transformation::operator*(const HomogeneousPoint & rhs) const { Eigen::Vector4d rval = rhs.toHomogeneous(); rval.head<3>() = (quatRotate(_q_a_b, rhs.toHomogeneous().head<3>()) + rval[3] * _t_a_b_a).eval(); return HomogeneousPoint(rval); } void Transformation::setRandom() { _q_a_b = quatRandom(); _t_a_b_a = (Eigen::Vector3d::Random().array() - 0.5) * 100.0; } bool Transformation::isBinaryEqual(const Transformation & rhs) const { return _q_a_b == rhs._q_a_b && _t_a_b_a == rhs._t_a_b_a; } /// \brief The update step for this transformation from a minimal update. void Transformation::oplus(const Eigen::Matrix<double,6,1> & dt) { _q_a_b = updateQuat( _q_a_b, dt.tail<3>() ); _t_a_b_a += dt.head<3>(); } Eigen::Matrix<double,6,6> Transformation::S() const { Eigen::Matrix<double,6,6> S; S.setIdentity(); S.topRightCorner<3,3>() = -crossMx(_t_a_b_a); return S; } void Transformation::setIdentity() { _q_a_b = quatIdentity(); _t_a_b_a.setZero(); } /// \brief Set this to a random transformation. void Transformation::setRandom( double translationMaxMeters, double rotationMaxRadians) { // Create a random unit-length axis. Eigen::Vector3d axis = Eigen::Vector3d::Random().array() - 0.5; // Create a random rotation angle in radians. double angle = sm::random::randLU(0.0, rotationMaxRadians); // Now a random axis/angle.cp axis.array() *= angle/axis.norm(); Eigen::Vector3d t; t.setRandom(); t.array() -= 0.5; t.array() *= sm::random::randLU(0.0, translationMaxMeters)/t.norm(); _q_a_b = axisAngle2quat(axis); _t_a_b_a = t; } UncertainTransformation Transformation::operator*(const UncertainTransformation & UT_b_c) const { const Transformation & T_a_b = *this; const Transformation & T_b_c = UT_b_c; Transformation T_a_c = T_a_b * T_b_c; UncertainTransformation::covariance_t T_a_b_boxtimes = boxTimes(T_a_b.T()); UncertainTransformation::covariance_t U_a_c = T_a_b_boxtimes * UT_b_c.U() * T_a_b_boxtimes.transpose(); return UncertainTransformation(T_a_c, U_a_c); } UncertainHomogeneousPoint Transformation::operator*(const UncertainHomogeneousPoint & p_1) const { const Transformation & T_0_1 = *this; Eigen::Vector4d p_0 = T_0_1 * p_1.toHomogeneous(); Eigen::Matrix4d T01 = T_0_1.T(); UncertainHomogeneousPoint::covariance_t U = T01 * p_1.U4() * T01.transpose(); return UncertainHomogeneousPoint(p_0,U); } /// \brief rotate a point (do not translate) Eigen::Vector3d Transformation::rotate(const Eigen::Vector3d & p) const { return quatRotate(_q_a_b, p); } /// \brief rotate a point (do not translate) Eigen::Vector4d Transformation::rotate(const Eigen::Vector4d & p) const { Eigen::Vector4d rval = p; rval.head<3>() = quatRotate(_q_a_b, rval.head<3>()); return rval; } UncertainVector3 Transformation::rotate(const UncertainVector3 & p) const { Eigen::Vector3d mean = rotate(p.mean()); Eigen::Matrix3d R = C(); Eigen::Matrix3d P = R * p.covariance() * R.transpose(); return UncertainVector3(mean, P); } } // namespace kinematics } // namespace sm
4c76f75b20942941b0554679ea78f9c18c709f74
c27df8ce4903389256023f71fc8004c6caf41d21
/examples/common/15_tim_usonic/main.cpp
6de553fd9ed6fd2a348a75f8890e2366befaf687
[]
no_license
atu-guda/stm32oxc
be8f584e6978fa40482bbd5df4a23bd6b41329eb
591b43246b8928329642b06bad8b9de6802e62ed
refs/heads/master
2023-09-03T08:42:36.058233
2023-09-02T19:15:15
2023-09-02T19:15:15
34,165,176
5
0
null
null
null
null
UTF-8
C++
false
false
3,877
cpp
#include <oxc_auto.h> #include <oxc_tim.h> using namespace std; using namespace SMLRL; USE_DIE4LED_ERROR_HANDLER; BOARD_DEFINE_LEDS; BOARD_CONSOLE_DEFINES; const char* common_help_string = "App to test US-014 ultrasonic sensor with timer" NL; TIM_HandleTypeDef tim_h; void init_usonic(); // --- local commands; int cmd_test0( int argc, const char * const * argv ); CmdInfo CMDINFO_TEST0 { "test0", 'T', cmd_test0, " [n] - test sensor" }; const CmdInfo* global_cmds[] = { DEBUG_CMDS, &CMDINFO_TEST0, nullptr }; int main(void) { BOARD_PROLOG; UVAR('t') = 1000; UVAR('n') = 20; BOARD_POST_INIT_BLINK; pr( NL "##################### " PROJ_NAME NL ); srl.re_ps(); oxc_add_aux_tick_fun( led_task_nortos ); init_usonic(); delay_ms( 50 ); std_main_loop_nortos( &srl, nullptr ); return 0; } // TEST0 int cmd_test0( int argc, const char * const * argv ) { int n = arg2long_d( 1, argc, argv, UVAR('n'), 0 ); uint32_t t_step = UVAR('t'); std_out << NL "Test0: n= " << n << " t= " << t_step << NL; tim_print_cfg( TIM_EXA ); delay_ms( 10 ); uint32_t tm0 = HAL_GetTick(); break_flag = 0; for( int i=0; i<n && !break_flag; ++i ) { std_out << "[" << i << "] l= " << UVAR('l') << NL; std_out.flush(); delay_ms_until_brk( &tm0, t_step ); } return 0; } // ----------------------------- configs ---------------- void init_usonic() { // 5.8 mks approx 1mm 170000 = v_c/2 in mm/s, 998 or 846 tim_h.Init.Prescaler = calc_TIM_psc_for_cnt_freq( TIM_EXA, 170000 ); tim_h.Instance = TIM_EXA; tim_h.Init.Period = 8500; // F approx 20Hz: for future motor PWM tim_h.Init.ClockDivision = 0; tim_h.Init.CounterMode = TIM_COUNTERMODE_UP; tim_h.Init.RepetitionCounter = 0; if( HAL_TIM_PWM_Init( &tim_h ) != HAL_OK ) { UVAR('e') = 1; // like error return; } TIM_ClockConfigTypeDef sClockSourceConfig; sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; HAL_TIM_ConfigClockSource( &tim_h, &sClockSourceConfig ); TIM_OC_InitTypeDef tim_oc_cfg; tim_oc_cfg.OCMode = TIM_OCMODE_PWM1; tim_oc_cfg.OCPolarity = TIM_OCPOLARITY_HIGH; tim_oc_cfg.OCNPolarity = TIM_OCNPOLARITY_HIGH; tim_oc_cfg.OCFastMode = TIM_OCFAST_DISABLE; tim_oc_cfg.OCIdleState = TIM_OCIDLESTATE_RESET; tim_oc_cfg.OCNIdleState = TIM_OCNIDLESTATE_RESET; tim_oc_cfg.Pulse = 3; // 3 = approx 16 us if( HAL_TIM_PWM_ConfigChannel( &tim_h, &tim_oc_cfg, TIM_CHANNEL_1 ) != HAL_OK ) { UVAR('e') = 11; return; } if( HAL_TIM_PWM_Start( &tim_h, TIM_CHANNEL_1 ) != HAL_OK ) { UVAR('e') = 12; return; } TIM_IC_InitTypeDef tim_ic_cfg; // tim_ic_cfg.ICPolarity = TIM_ICPOLARITY_RISING; tim_ic_cfg.ICPolarity = TIM_ICPOLARITY_BOTHEDGE; // rising - start, falling - stop tim_ic_cfg.ICSelection = TIM_ICSELECTION_DIRECTTI; tim_ic_cfg.ICPrescaler = TIM_ICPSC_DIV1; tim_ic_cfg.ICFilter = 0; // 0 - 0x0F if( HAL_TIM_IC_ConfigChannel( &tim_h, &tim_ic_cfg, TIM_CHANNEL_2 ) != HAL_OK ) { UVAR('e') = 21; return; } HAL_NVIC_SetPriority( TIM_EXA_IRQ, 7, 0 ); HAL_NVIC_EnableIRQ( TIM_EXA_IRQ ); if( HAL_TIM_IC_Start_IT( &tim_h, TIM_CHANNEL_2 ) != HAL_OK ) { UVAR('e') = 23; } } void TIM_EXA_IRQHANDLER(void) { HAL_TIM_IRQHandler( &tim_h ); } void HAL_TIM_IC_CaptureCallback( TIM_HandleTypeDef *htim ) { uint32_t cap2; static uint32_t c_old = 0xFFFFFFFF; if( htim->Channel == HAL_TIM_ACTIVE_CHANNEL_2 ) { cap2 = HAL_TIM_ReadCapturedValue( htim, TIM_CHANNEL_2 ); if( cap2 > c_old ) { UVAR('l') = cap2 - c_old ; leds.reset( BIT2 ); } else { leds.set( BIT2 ); } c_old = cap2; UVAR('m') = cap2; UVAR('z') = htim->Instance->CNT; } } // vim: path=.,/usr/share/stm32cube/inc/,/usr/arm-none-eabi/include,/usr/share/stm32oxc/inc
1a9621510a5890e6f3891087573b7d14d8e3f50b
794decce384b8e0ba625e421cc35681b16eba577
/tensorflow/core/data/service/snapshot/utils.h
3ea632e5e304dbb17318c166b6eb6c58c530abb7
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause" ]
permissive
911gt3/tensorflow
a6728e86100a2d5328280cfefcfa8e7c8de24c4c
423ea74f41d5f605933a9d9834fe2420989fe406
refs/heads/master
2023-04-09T14:27:29.072195
2023-04-03T06:20:23
2023-04-03T06:22:54
258,948,634
0
0
Apache-2.0
2020-04-26T05:36:59
2020-04-26T05:36:58
null
UTF-8
C++
false
false
1,592
h
/* Copyright 2022 The TensorFlow Authors. 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. ==============================================================================*/ #ifndef TENSORFLOW_CORE_DATA_SERVICE_SNAPSHOT_UTILS_H_ #define TENSORFLOW_CORE_DATA_SERVICE_SNAPSHOT_UTILS_H_ #include <cstdint> #include <vector> #include "absl/strings/string_view.h" #include "tensorflow/core/framework/tensor.h" #include "tensorflow/tsl/platform/status.h" namespace tensorflow { namespace data { int64_t EstimatedSizeBytes(const std::vector<Tensor>& tensors); // Returns a `Status` that indicates the snapshot stream assignment has changed // and the worker should retry unless it's cancelled. Status StreamAssignmentChanged(absl::string_view worker_address, int64_t stream_index); // Returns true if `status` indicates the snapshot stream assignment has changed // returned by `StreamAssignmentChanged`. bool IsStreamAssignmentChanged(const Status& status); } // namespace data } // namespace tensorflow #endif // TENSORFLOW_CORE_DATA_SERVICE_SNAPSHOT_UTILS_H_
8a5aab971b95db02883d20232314fe4fad3c19c2
f12e53b806ba418a58f814ebc87c4446a422b2f5
/solutions/uri/1789/1789.cpp
c14cdae8df69b14fd26b05dda0d6eeafcb2cf0b5
[ "MIT" ]
permissive
biadelmont/playground
f775cd86109e30ed464d4d6eff13f9ded40627cb
93c6248ec6cd25d75f0efbda1d50e0705bbd1e5a
refs/heads/master
2021-05-06T15:49:43.253788
2017-11-07T13:00:31
2017-11-07T13:00:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
402
cpp
#include <cstdio> int main() { int l, v, fastest; while (scanf("%d", &l) != EOF) { fastest = 0; while (l--) { scanf("%d", &v); if (v > fastest) fastest = v; } if (fastest < 10) { puts("1"); } else if (fastest < 20) { puts("2"); } else { puts("3"); } } return 0; }
04f3bf59a6968978a904c83f0712ca5e0ffa488f
be8718f6882f2b4b124b245d10d1d05c2e09a901
/Engine/Source/Shared/Import/Mdl/MdlNode.cpp
124f9d419de8f8cb5e8219e2d627270585d87776
[]
no_license
kolhammer/Psybrus
fd907a8e25b488327846d46853ca219c55cca81b
21c794568eed41aaacb633cd87dedd5ce2793115
refs/heads/master
2016-09-05T08:58:04.427316
2012-03-19T11:33:32
2012-03-19T11:33:32
3,031,999
1
1
null
null
null
null
UTF-8
C++
false
false
6,811
cpp
/************************************************************************** * * File: MdlNode.cpp * Author: Neil Richardson * Ver/Date: * Description: * Model node. * * * * **************************************************************************/ #include "MdlNode.h" #include "MdlMesh.h" #include "MdlMorph.h" #include "MdlEntity.h" #include "Base/BcDebug.h" #include "Base/BcString.h" ////////////////////////////////////////////////////////////////////////// // Ctor MdlNode::MdlNode(): NodeType_( eNT_EMPTY ), pParent_( NULL ), pChild_( NULL ), pNext_( NULL ) { RelativeTransform_.identity(); AbsoluteTransform_.identity(); pNodeMeshObject_ = NULL; pNodeSkinObject_ = NULL; pNodeColMeshObject_ = NULL; pNodeMorphObject_ = NULL; pNodeEntityObject_ = NULL; pNodeLightObject_ = NULL; pNodeProjectorObject_ = NULL; } ////////////////////////////////////////////////////////////////////////// // Dtor MdlNode::~MdlNode() { delete pNodeMeshObject_; delete pNodeSkinObject_; delete pNodeColMeshObject_; delete pNodeMorphObject_; delete pNodeEntityObject_; delete pNodeLightObject_; delete pNodeProjectorObject_; ///* NOTE: Memory corruption somewhere. MdlNode* pNext = pChild_; while( pNext != NULL ) { MdlNode* pTheNext = pNext->pNext_; delete pNext; pNext = pTheNext; } } ////////////////////////////////////////////////////////////////////////// // name void MdlNode::name( const BcChar* Name ) { BcStrCopy( Name_, Name ); } const BcChar* MdlNode::name() { return Name_; } ////////////////////////////////////////////////////////////////////////// // parentNode BcBool MdlNode::parentNode( MdlNode* pNode, const BcChar* ParentName ) { BcBool bParented = BcFalse; // Parent another node to this tree. if( ParentName == NULL || BcStrCompare( ParentName, Name_ ) ) { // Tell the node who its parent is. pNode->pParent_ = this; // If we have a child already we need our next to match. if( pChild_ != NULL ) { MdlNode* pParentNode = pChild_; // Find the last node while( pParentNode->pNext_ != NULL ) { BcAssert( pParentNode != pParentNode->pNext_ ); pParentNode = pParentNode->pNext_; } // pParentNode->pNext_ = pNode; bParented = BcTrue; } else { pChild_ = pNode; bParented = BcTrue; } } else { // If we are not the destined parent pass it to next and child. // Find the last node MdlNode* pNextNode = pChild_; while( pNextNode != NULL ) { bParented |= pNextNode->parentNode( pNode, ParentName ); pNextNode = pNextNode->pNext_; } } return bParented; } ////////////////////////////////////////////////////////////////////////// // makeRelativeTransform void MdlNode::makeRelativeTransform( const BcMat4d& ParentAbsolute ) { // Parent another node to this tree. MdlNode* pNextNode = pChild_; // BcMat4d InverseParent = ParentAbsolute; InverseParent.inverse(); RelativeTransform_ = AbsoluteTransform_ * InverseParent; // For all the nodes parented to the same as us. while( pNextNode != NULL ) { pNextNode->makeRelativeTransform( AbsoluteTransform_ ); pNextNode = pNextNode->pNext_; } } ////////////////////////////////////////////////////////////////////////// // makeAbsoluteTransform void MdlNode::makeAbsoluteTransform( const BcMat4d& ParentAbsolute ) { // Parent another node to this tree. MdlNode* pNextNode = pChild_; // BcMat4d InverseParent = ParentAbsolute; InverseParent.inverse(); AbsoluteTransform_ = ParentAbsolute * RelativeTransform_; // For all the nodes parented to the same as us. while( pNextNode != NULL ) { pNextNode->makeAbsoluteTransform( AbsoluteTransform_ ); pNextNode = pNextNode->pNext_; } } ////////////////////////////////////////////////////////////////////////// // flipTransform void MdlNode::flipTransform( BcMat4d& Transform ) { Transform.transpose(); Transform[0][2] = -Transform[0][2]; Transform[1][2] = -Transform[1][2]; Transform[2][0] = -Transform[2][0]; Transform[2][1] = -Transform[2][1]; Transform[2][3] = -Transform[2][3]; Transform.transpose(); } ////////////////////////////////////////////////////////////////////////// // flipTransforms void MdlNode::flipCoordinateSpace() { // Parent another node to this tree. MdlNode* pNextNode = pChild_; // Flip absolute and inverse bind pose transforms. flipTransform( AbsoluteTransform_ ); flipTransform( InverseBindpose_ ); // If we've got a mesh, flip it's coordinate space. if( type() & eNT_MESH ) { pNodeMeshObject_->flipCoordinateSpace(); } if( type() & eNT_SKIN ) { pNodeSkinObject_->flipCoordinateSpace(); } if( type() & eNT_MORPH ) { pNodeMorphObject_->flipCoordinateSpace(); } // For all the nodes parented to the same as us. while( pNextNode != NULL ) { pNextNode->flipCoordinateSpace(); pNextNode = pNextNode->pNext_; } } ////////////////////////////////////////////////////////////////////////// // type void MdlNode::type( BcU32 NodeType ) { if( NodeType != eNT_COLMESH && NodeType != eNT_ENTITY ) { BcAssert( ( NodeType_ & ~NodeType ) == 0 ); } if( ( NodeType_ & NodeType ) == 0 ) { NodeType_ |= NodeType; switch( NodeType ) { case eNT_EMPTY: break; case eNT_MESH: pNodeMeshObject_ = new MdlMesh(); break; case eNT_SKIN: pNodeSkinObject_ = new MdlMesh(); break; case eNT_COLMESH: // Naughty. //pNodeColMeshObject_ = new MdlMesh(); BcAssert( pNodeMeshObject_ != NULL ); break; case eNT_MORPH: pNodeMorphObject_ = new MdlMesh(); break; case eNT_ENTITY: pNodeEntityObject_ = new MdlEntity(); break; case eNT_LIGHT: pNodeLightObject_ = new MdlLight(); break; case eNT_PROJECTOR: pNodeProjectorObject_ = new MdlProjector(); break; } } } ////////////////////////////////////////////////////////////////////////// // countJoints void MdlNode::countJoints( BcU32& iCount ) { if( type() & eNT_JOINT ) { iCount++; } MdlNode* pNextNode = pChild_; while( pNextNode != NULL ) { if( pNextNode->type() & eNT_JOINT ) { pNextNode->countJoints( iCount ); } pNextNode = pNextNode->pNext_; } } ////////////////////////////////////////////////////////////////////////// // void MdlNode::findAllAABBs() { MdlNode* pNextNode = pChild_; // If our AABB is empty, calculate our bounds based on child nodes. if( AABB_.isEmpty() ) { while( pNextNode != NULL ) { // Find our childs.. pNextNode->findAllAABBs(); // Add its AABB to ours. if( pNextNode->AABB_.isEmpty() == BcFalse ) { AABB_.expandBy( pNextNode->AABB_ ); } // pNextNode = pNextNode->pNext_; } // Transform our AABB if( AABB_.isEmpty() == BcFalse ) { AABB_ = AABB_.transform( AbsoluteTransform_ ); } } else { // Transform ours. AABB_ = AABB_.transform( AbsoluteTransform_ ); } }
8788db759d2467f2e5ce1f3747107a50c10284ea
c102d77e7e363d043e017360d329c93b9285a6be
/Sources/Samples/AI/UnitPathManager.h
4c85b601bbdd834052649cd9ee5cd19276a8484b
[ "MIT" ]
permissive
jdelezenne/Sonata
b7b1faee54ea9dbd273eab53a7dedbf106373110
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
refs/heads/master
2020-07-15T22:32:47.094973
2019-09-01T11:07:03
2019-09-01T11:07:03
205,662,360
4
0
null
null
null
null
UTF-8
C++
false
false
3,466
h
/*============================================================================= UnitPathManager.h Project: Sonata Engine Copyright �by7 Julien Delezenne =============================================================================*/ #ifndef _SE_UNITPATHMANAGER_H_ #define _SE_UNITPATHMANAGER_H_ #include "Common.h" #include "World.h" extern int8 TileUnitCosts[TileType_Count][UnitType_Count]; enum PathfinderType { PathfinderType_AStar }; class UnitPathMap : public AI::AStarPathfinderMap { public: UnitPathMap(); virtual int GetNeighbourCount(AI::PathfinderNode* node); virtual AI::PathfinderNodeID GetNeighbour(AI::PathfinderNode* node, int neighbour); virtual void SetAStarFlags(AI::PathfinderNodeID node, uint32 flags); virtual uint32 GetAStarFlags(AI::PathfinderNodeID node); virtual void InitializeNeighbour(AI::AStarPathfinderNode* parent, AI::AStarPathfinderNode* child); AI::PathfinderNodeID CellToPathfinderNodeID(Cell* cell); Cell* PathfinderNodeIDToCell(AI::PathfinderNodeID node); void Initialize(Map* map); Map* GetMap() const { return _Map; } protected: Map* _Map; }; class UnitPathGoal : public AI::AStarPathfinderGoal { public: UnitPathGoal(); virtual void SetDestinationNode(AI::PathfinderNodeID node); virtual bool IsNodeValid(AI::PathfinderNodeID node); virtual real32 GetHeuristic(AI::AStarPathfinderNode* node); virtual real32 GetCost(AI::AStarPathfinderNode* nodeA, AI::AStarPathfinderNode* nodeB); virtual bool IsSearchFinished(AI::AStarPathfinderNode* node); void Initialize(UnitPathMap* map, Unit* unit); protected: AI::PathfinderNodeID _DestinationNode; UnitPathMap* _Map; Unit* _Unit; }; template <class T> class RefComparer : public IComparer<T> { public: virtual int Compare(const T& x, const T& y) const { if (*x < *y) return -1; else if (*x > *y) return 1; else return 0; } }; class PriorityQueueStorage : public AI::AStarPathfinderStorage { public: PriorityQueueStorage(); virtual ~PriorityQueueStorage(); virtual void Reset(); virtual void AddToOpenList(AI::AStarPathfinderNode* node, AI::AStarPathfinderMap* map); virtual void AddToClosedList(AI::AStarPathfinderNode* node, AI::AStarPathfinderMap* map); virtual void RemoveFromOpenList(AI::AStarPathfinderNode* node); virtual void RemoveFromClosedList(AI::AStarPathfinderNode* node); virtual AI::AStarPathfinderNode* FindInOpenList(AI::PathfinderNodeID node); virtual AI::AStarPathfinderNode* FindInClosedList(AI::PathfinderNodeID node); virtual AI::AStarPathfinderNode* RemoveBestOpenNode(); protected: typedef PriorityQueue< AI::AStarPathfinderNode*, RefComparer<AI::AStarPathfinderNode*> > OpenList; OpenList _OpenList; typedef Array<AI::AStarPathfinderNode*> ClosedList; ClosedList _ClosedList; }; class UnitPathStorage : public PriorityQueueStorage { public: UnitPathStorage(); virtual AI::AStarPathfinderNode* CreateNode(AI::PathfinderNodeID node); virtual void DestroyNode(AI::AStarPathfinderNode* node); }; class UnitPathManager { public: UnitPathManager(); virtual ~UnitPathManager(); void Initialize(PathfinderType type); bool HasPath(Unit* unit, Cell* source, Cell* destination); bool FindPath(Unit* unit, Cell* source, Cell* destination, UnitPath* path); protected: AI::PathfinderNode* FindPath(Unit* unit, Cell* source, Cell* destination); protected: AI::AStarPathfinder* _Pathfinder; PriorityQueueStorage* _Storage; UnitPathGoal* _Goal; UnitPathMap* _Map; }; #endif