blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
ac52810910e91db19bc4bdf2ab697201e111db33
82dc3cc4c97c05e384812cc9aa07938e2dbfe24b
/tahoe/src-mirror/solvers/NLSolverX.cpp
17318aa5ffe97e443ddef6edf2f551cc834c0ca5
[ "BSD-3-Clause" ]
permissive
samanseifi/Tahoe
ab40da0f8d952491943924034fa73ee5ecb2fecd
542de50ba43645f19ce4b106ac8118c4333a3f25
refs/heads/master
2020-04-05T20:24:36.487197
2017-12-02T17:09:11
2017-12-02T17:24:23
38,074,546
3
0
null
null
null
null
UTF-8
C++
false
false
49
cpp
/home/saman/Tahoe/tahoe/src/solvers/NLSolverX.cpp
[ "saman@bu.(none)" ]
saman@bu.(none)
15b2df42865d422adf4da2f273b1194c61c11c84
8ea9fa0a919ad0f40ca79a75e2836ec5bb1e1608
/12_8/IKCSYSTEMOK/IKCSYSTEM.cpp
972ca426d672e8636cf88e13cbf5c0843f070e9b
[]
no_license
stronghzz/hzzcoding
d8f7da454c8f0a3681ddc6c8c2a833ea60f8e5eb
8a70b6132277aacc6ed7b945e9eab96aa4605dcf
refs/heads/master
2023-04-02T19:35:50.180068
2023-03-25T22:35:30
2023-03-25T22:35:30
154,313,309
1
0
null
null
null
null
UTF-8
C++
false
false
2,031
cpp
// IKCSYSTEM.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "IKCSYSTEM.h" #include "IKCSYSTEMDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CIKCSYSTEMApp BEGIN_MESSAGE_MAP(CIKCSYSTEMApp, CWinApp) //{{AFX_MSG_MAP(CIKCSYSTEMApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CIKCSYSTEMApp construction CIKCSYSTEMApp::CIKCSYSTEMApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CIKCSYSTEMApp object CIKCSYSTEMApp theApp; ///////////////////////////////////////////////////////////////////////////// // CIKCSYSTEMApp initialization BOOL CIKCSYSTEMApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CIKCSYSTEMDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
[ "760767745@qq.com" ]
760767745@qq.com
7bc2ab1784ad002f2b84c3bc96356456c715b1c5
548e9ba77b29e920be0382e9d83f849c5be6195a
/test33.cpp
707bd6be237d13f61f5189b297bef5c96ec087c4
[ "LicenseRef-scancode-boost-original" ]
permissive
sjzlyl406/Practice
2c345b246217eace1d5920da3682b1bed27a434a
6a1f4f0f9aaa728a2188d6ee0676e5fcbebf4886
refs/heads/master
2020-04-26T11:39:52.832526
2015-08-20T07:48:25
2015-08-20T07:48:25
38,287,730
0
0
null
null
null
null
UTF-8
C++
false
false
1,206
cpp
/************************************************************************* > File Name: test33.cpp > Author: leon > Mail: sjzlyl406@163.com > Created Time: 2015年07月03日 星期五 15时03分25秒 ************************************************************************/ /*************************************************************** * 删除子串,只要是原串中有相同的子串就删掉,不管有多少个都删除,返回子串个数。 * 输入字符串为:123abc12de234fg1hi34j123k,子串为:123 * 则输出为:abc12de234fg1hi34jk 2 * ************************************************************/ #include<iostream> #include<string> #include<algorithm> int deleteSubString(std::string &str, std::string substr) { int count = 0; size_t len = substr.size(); size_t pos = str.find(substr); while(pos != std::string::npos){ str.erase(pos, len); count++; pos = str.find(substr); } return count; } int main(void) { std::string str, substr; std::cout<<"input a string:"; std::cin>>str; std::cout<<"input a substring:"; std::cin>>substr; int count = deleteSubString(str, substr); std::cout<<str<<":"<<count<<":"<<substr<<std::endl; return 0; }
[ "sjzlyl406@163.com" ]
sjzlyl406@163.com
bf462e18b200c5c14c4c676ad1979f610deb6fc4
ddebf5769f514eff3caaf9b3e569af4480f97e70
/include/greenlib/TimePoint.hpp
987694f18d4aee1d6ab5db375a0f7be3b2b2c2de
[ "MIT" ]
permissive
aleksigron/greenlib
1f5fc3c13d7610d5262d348957ef4c4fd3a46c66
6e7d32e29b53e072060fd054a4c6229cd7889fa7
refs/heads/master
2016-09-06T11:56:31.421412
2015-04-19T01:40:52
2015-04-19T01:40:52
33,725,222
0
0
null
null
null
null
UTF-8
C++
false
false
1,501
hpp
#pragma once #include <cstdint> #include "TimeDuration.hpp" namespace grn { class TimePoint { private: std::uint64_t secondsSinceEpoch; public: TimePoint() : secondsSinceEpoch(0) {} explicit TimePoint(std::uint64_t secondsSinceEpoch) : secondsSinceEpoch(secondsSinceEpoch) {} std::uint64_t Uint64() const { return this->secondsSinceEpoch; } TimePoint& operator+=(const TimeDuration& rhs) { this->secondsSinceEpoch += rhs.durationSeconds; } TimePoint& operator-=(const TimeDuration& rhs) { this->secondsSinceEpoch -= rhs.durationSeconds; } TimePoint operator+(const TimeDuration& rhs) const { return TimePoint(this->secondsSinceEpoch + rhs.durationSeconds); } TimePoint operator-(const TimeDuration& rhs) const { return TimePoint(this->secondsSinceEpoch - rhs.durationSeconds); } TimeDuration operator-(const TimePoint& rhs) const { return TimeDuration(this->secondsSinceEpoch - rhs.secondsSinceEpoch); } bool operator==(const TimePoint& rhs) const { return this->secondsSinceEpoch == rhs.secondsSinceEpoch; } bool operator!=(const TimePoint& rhs) const { return this->operator==(rhs) == false; } bool operator<(const TimePoint& rhs) const { return this->secondsSinceEpoch < rhs.secondsSinceEpoch; } bool operator>(const TimePoint& rhs) const { return rhs.operator<(*this); } bool operator<=(const TimePoint& rhs) const { return rhs.operator<(*this) == false; } bool operator>=(const TimePoint& rhs) const { return this->operator<(rhs) == false; } }; }
[ "aleksi.gron@gmail.com" ]
aleksi.gron@gmail.com
b307d4dcd3513e99311dddd1e6ec06873fa39e68
cc327a4880fa7e4c9f699b634e17ca5242c06bc0
/src/Magnum/Shapes/Plane.h
c849aa100e9bd921f230027cc04d9e8ba72bc763
[ "MIT" ]
permissive
xqms/magnum
7cd3f2416dfbb6b305956173c5342bca8461a7cc
cef34e32db6f1fd6617870fd0f92492bbdafdf32
refs/heads/master
2021-06-19T13:19:18.729043
2019-02-07T08:02:51
2019-02-07T08:02:51
169,609,455
0
0
NOASSERTION
2019-02-07T17:09:32
2019-02-07T17:09:32
null
UTF-8
C++
false
false
5,747
h
#ifndef Magnum_Shapes_Plane_h #define Magnum_Shapes_Plane_h /* This file is part of Magnum. Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Vladimír Vondruš <mosra@centrum.cz> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** @file @brief Class @ref Magnum::Shapes::Plane @deprecated The @ref Magnum::Shapes library is a failed design experiment and is scheduled for removal in a future release. Related geometry algorithms were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; if you need a full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), which has Magnum integration in @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" as well. */ #include "Magnum/Magnum.h" #include "Magnum/Math/Vector3.h" #include "Magnum/Shapes/Shapes.h" #include "Magnum/Shapes/visibility.h" /* File-level deprecation warning issued from Shapes.h */ namespace Magnum { namespace Shapes { CORRADE_IGNORE_DEPRECATED_PUSH /** @brief Infinite plane, defined by position and normal (3D only) @deprecated The @ref Shapes library is a failed design experiment and is scheduled for removal in a future release. Related geometry algorithms were moved to @ref Math::Distance and @ref Math::Intersection; if you need a full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), which has Magnum integration in @ref BulletIntegration, or at [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" as well. Unlike other elements the plane expects uniform scaling. See @ref shapes for brief introduction. */ class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Plane { public: enum: UnsignedInt { Dimensions = 3 /**< Dimension count */ }; /** * @brief Default constructor * * Creates plane with zero-sized normal at origin. */ constexpr /*implicit*/ Plane() {} /** @brief Constructor */ constexpr /*implicit*/ Plane(const Vector3& position, const Vector3& normal): _position(position), _normal(normal) {} /** @brief Transformed shape */ Plane transformed(const Matrix4& matrix) const; /** @brief Position */ constexpr Vector3 position() const { return _position; } /** @brief Set position */ void setPosition(const Vector3& position) { _position = position; } /** @brief Normal */ constexpr Vector3 normal() const { return _normal; } /** @brief Set normal */ void setNormal(const Vector3& normal) { _normal = normal; } /** @brief Collision occurence with line */ bool operator%(const Line3D& other) const; /** @brief Collision occurence with line segment */ bool operator%(const LineSegment3D& other) const; private: Vector3 _position, _normal; }; /** @relatesalso Line @brief Collision occurence of @ref Line and @ref Plane @deprecated The @ref Shapes library is a failed design experiment and is scheduled for removal in a future release. Related geometry algorithms were moved to @ref Math::Distance and @ref Math::Intersection; if you need a full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), which has Magnum integration in @ref BulletIntegration, or at [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" as well. @see @ref Plane::operator%(const Line3D&) const */ inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Line3D& a, const Plane& b) { return b % a; } /** @relatesalso LineSegment @brief Collision occurence of @ref LineSegment and @ref Plane @deprecated The @ref Shapes library is a failed design experiment and is scheduled for removal in a future release. Related geometry algorithms were moved to @ref Math::Distance and @ref Math::Intersection; if you need a full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), which has Magnum integration in @ref BulletIntegration, or at [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" as well. @see @ref Plane::operator%(const LineSegment3D&) const */ inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const LineSegment3D& a, const Plane& b) { return b % a; } CORRADE_IGNORE_DEPRECATED_POP }} #endif
[ "mosra@centrum.cz" ]
mosra@centrum.cz
865c057042aad859983c9f0cd2bee73c828e11b5
1f0df339a3721d41e920353b79b645ea87f57864
/graphs/floyd_warshall.cpp
c08103c25c95e9f597256f3a20fb661e795fb20f
[ "MIT" ]
permissive
r1walz/cookbook
c81195e2bc07cbebd3e97c3db5ddee957a520c15
0f5326841e23d25b8f5d612ab32ae46faf61608e
refs/heads/master
2023-01-06T21:23:59.135967
2020-10-16T12:23:35
2020-10-16T12:23:35
304,295,904
0
2
MIT
2020-10-16T12:23:36
2020-10-15T10:52:15
C++
UTF-8
C++
false
false
1,186
cpp
/* * @author Samarth Agarwal * * Floyd-Warshall is an algorithm that finds the shortest distance * between each pair of nodes in a graph. It uses dynamic programming * to accomplish this task. * * Time Complexity: O(n^3) * Space Complexity: O(n^2) */ #include <iostream> using namespace std; const int N = 505; const int INF = 1000000007; int graph[N][N], dist[N][N]; void floyd_warshall(int n) { for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) dist[i][j] = graph[i][j]; for (int k = 1; k <= n; ++k) for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) if (dist[i][k] + dist[k][j] < dist[i][j]) dist[i][j] = dist[i][k] + dist[k][j]; } int main() { int n; cin >> n; // First we initialize the graph with some arbitirarily high value // and 0 for case when i == j for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) graph[i][j] = (i == j) ? 0 : INF; int edges; cin >> edges; for (int i = 1; i <= edges; ++i) { int u, v, weight; cin >> u >> v >> weight; graph[u][v] = graph[v][u] = weight; } floyd_warshall(n); int start, end; cin >> start >> end; cout << dist[start][end] << endl; }
[ "setu.samarth@gmail.com" ]
setu.samarth@gmail.com
b5ea29ce410595060b5e9c8623ae79c17fc734e7
82699a3f975bdfe3e91b632ebcee143764a75f4d
/programs codes/nandan.cpp
fcf6495add1e923d9c238480a8b7354f751ca711
[]
no_license
vishuchhabra/cpp_programs
ecfbb3c4eeb76442fb71c58ea096145eb5f3be80
ee0ce21bce57501b8465f5f254488adad7dbe0bb
refs/heads/master
2021-02-18T19:39:18.090206
2020-10-02T07:17:22
2020-10-02T07:17:22
278,788,375
0
3
null
2020-10-04T09:55:03
2020-07-11T04:35:13
C++
UTF-8
C++
false
false
115
cpp
#include<iostream> using namespace std; int main() { cout<<"my name is vishu chhabra "<<endl; return 0; }
[ "vishuchhabra1016@gmail.com" ]
vishuchhabra1016@gmail.com
e29a8f9c18a10c99811b3d842d8491821d05089e
ffe8b00c01428086ec5dc3f5269ef0125c04ee7f
/test/entt/entity/helper.cpp
d9311d6c310b5a235b745ee92beac5e4fecf13bb
[ "MIT", "CC-BY-4.0", "CC-BY-SA-4.0" ]
permissive
m-waka/entt
d689507b78f9571b6fd5ae1d5df63b6f4f29bf25
4913c9e6ecde672ed69182aa8a33c78f10c475ea
refs/heads/master
2021-07-13T04:38:06.635153
2018-12-11T11:41:15
2018-12-11T11:41:15
131,844,781
0
0
MIT
2018-12-10T12:54:17
2018-05-02T12:04:19
C++
UTF-8
C++
false
false
2,846
cpp
#include <gtest/gtest.h> #include <entt/core/hashed_string.hpp> #include <entt/entity/helper.hpp> #include <entt/entity/registry.hpp> TEST(Helper, AsView) { using entity_type = typename entt::registry<>::entity_type; entt::registry<> registry; const entt::registry<> cregistry; ([](entt::view<entity_type, int, char>) {})(entt::as_view{registry}); ([](entt::view<entity_type, const double>) {})(entt::as_view{cregistry}); ([](entt::persistent_view<entity_type, int, char>) {})(entt::as_view{registry}); ([](entt::persistent_view<entity_type, const double, const float>) {})(entt::as_view{cregistry}); ([](entt::raw_view<entity_type, int>) {})(entt::as_view{registry}); ([](entt::raw_view<entity_type, const double>) {})(entt::as_view{cregistry}); } TEST(Helper, Dependency) { entt::registry<> registry; const auto entity = registry.create(); entt::connect<double, float>(registry.construction<int>()); ASSERT_FALSE(registry.has<double>(entity)); ASSERT_FALSE(registry.has<float>(entity)); registry.assign<char>(entity); ASSERT_FALSE(registry.has<double>(entity)); ASSERT_FALSE(registry.has<float>(entity)); registry.assign<int>(entity); ASSERT_TRUE(registry.has<double>(entity)); ASSERT_TRUE(registry.has<float>(entity)); ASSERT_EQ(registry.get<double>(entity), .0); ASSERT_EQ(registry.get<float>(entity), .0f); registry.get<double>(entity) = .3; registry.get<float>(entity) = .1f; registry.remove<int>(entity); registry.assign<int>(entity); ASSERT_EQ(registry.get<double>(entity), .3); ASSERT_EQ(registry.get<float>(entity), .1f); registry.remove<int>(entity); registry.remove<float>(entity); registry.assign<int>(entity); ASSERT_TRUE(registry.has<float>(entity)); ASSERT_EQ(registry.get<double>(entity), .3); ASSERT_EQ(registry.get<float>(entity), .0f); registry.remove<int>(entity); registry.remove<double>(entity); registry.remove<float>(entity); entt::disconnect<double, float>(registry.construction<int>()); registry.assign<int>(entity); ASSERT_FALSE(registry.has<double>(entity)); ASSERT_FALSE(registry.has<float>(entity)); } TEST(Helper, Label) { entt::registry<> registry; const auto entity = registry.create(); registry.assign<entt::label<"foobar"_hs>>(entity); registry.assign<int>(entity, 42); int counter{}; ASSERT_FALSE(registry.has<entt::label<"barfoo"_hs>>(entity)); ASSERT_TRUE(registry.has<entt::label<"foobar"_hs>>(entity)); for(auto entity: registry.view<int, entt::label<"foobar"_hs>>()) { (void)entity; ++counter; } ASSERT_NE(counter, 0); for(auto entity: registry.view<entt::label<"foobar"_hs>>()) { (void)entity; --counter; } ASSERT_EQ(counter, 0); }
[ "michele.caini@gmail.com" ]
michele.caini@gmail.com
da57a671a91bdc2589fc91e6e0a5061af5da04e9
d779765b758d43ed9ae19ff1e83a894ec37e1e86
/Practice/05/C++/05/05/05.cpp
5c1411765a20878865c6bfb71f6ec1f8d4e2bc3e
[]
no_license
gamebars/Programming
2e0cc641056ba020f609f3f9a28228faafd5bb1d
9def7f353461062a0b33b10f8aa454bb16df4939
refs/heads/main
2023-05-09T09:57:58.775725
2021-06-05T18:50:59
2021-06-05T18:50:59
310,386,577
0
1
null
null
null
null
UTF-8
C++
false
false
424
cpp
#include <iostream> using namespace std; int main() { setlocale(LC_ALL, "Russian"); double x,t,v,g,L, S; g = 9.8; cout << "Введите начальное положение "; cin >> x; cout << "Введите время движения " ; cin >> t; cout << "Введите начальную скорость "; cin >> v; S= x + v * t + g * t * t / 2; cout << "\n Расстояние = " << S ; }
[ "freerancho@gmail.com" ]
freerancho@gmail.com
455bfd99a2afd787283257f64bc883dad3c4ed93
b816f8eaa33e1e74b201e4e1c729cb2e54c82298
/riegeli/bytes/file_mode_string.cc
d839ec153289ffe7ec0b35de69f5b394d46c8156
[ "Apache-2.0" ]
permissive
google/riegeli
b47af9d6705ba7fc4d13d60f66f506e528fa0879
c2f4362609db7c961c7de53387931f0901daf842
refs/heads/master
2023-08-17T16:54:54.694997
2023-08-11T13:33:07
2023-08-11T13:36:05
116,150,035
366
59
Apache-2.0
2023-04-09T21:13:32
2018-01-03T15:05:56
C++
UTF-8
C++
false
false
6,682
cc
// Copyright 2022 Google LLC // // 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 "riegeli/bytes/file_mode_string.h" #ifdef _WIN32 #include <fcntl.h> #endif #include <stddef.h> #include <string> #include "absl/base/optimization.h" #include "absl/strings/string_view.h" // Syntax of a file mode for `fopen()`: // * 'r', 'w', or 'a'. // * Single character modifiers, in any order. Some modifiers are standard: // '+', 'b', 'x' (since C++17 / C11), while others are OS-specific. // * ',ccs=<encoding>'. This is not standard but it is understood by glibc and // on Windows. To avoid breaking the encoding name which may use characters // ordinarily used as modifiers, functions below stop parsing at ','. namespace riegeli { namespace file_internal { void SetExisting(bool existing, std::string& mode) { if (ABSL_PREDICT_FALSE(mode.empty())) mode = "w"; if (existing) { mode[0] = 'r'; // Add '+' to modifiers unless it already exists there. for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == '+') return; if (mode[i] == ',') break; } mode.insert(1, "+"); } else { mode[0] = 'w'; // Remove '+' from modifiers. for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == '+') { mode.erase(i, 1); --i; continue; } if (mode[i] == ',') break; } } } void SetRead(bool read, std::string& mode) { if (ABSL_PREDICT_FALSE(mode.empty())) mode = "w"; if (read) { // Add '+' to modifiers unless it already exists there. for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == '+') return; if (mode[i] == ',') break; } mode.insert(1, "+"); } else { if (mode[0] == 'r') return; // Remove '+' from modifiers. for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == '+') { mode.erase(i, 1); --i; continue; } if (mode[i] == ',') break; } } } bool GetRead(absl::string_view mode) { if (ABSL_PREDICT_FALSE(mode.empty())) return false; if (mode[0] == 'r') return true; for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == '+') return true; if (mode[i] == ',') break; } return false; } void SetExclusive(bool exclusive, std::string& mode) { if (ABSL_PREDICT_FALSE(mode.empty())) mode = "w"; if (exclusive) { // Add 'x' to modifiers unless it already exists there. for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == 'x') return; if (mode[i] == ',') break; } size_t position = 1; while (mode.size() > position && (mode[position] == '+' || mode[position] == 'b' || mode[position] == 't')) { ++position; } mode.insert(position, "x"); } else { // Remove 'x' from modifiers. for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == 'x') { mode.erase(i, 1); --i; continue; } if (mode[i] == ',') break; } } } bool GetExclusive(absl::string_view mode) { if (ABSL_PREDICT_FALSE(mode.empty())) return false; for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == 'x') return true; if (mode[i] == ',') break; } return false; } namespace { void SetInheritableImpl(bool inheritable, std::string& mode) { #ifndef _WIN32 static constexpr char kModifier = 'e'; #else static constexpr char kModifier = 'N'; #endif static constexpr const char kModifierStr[2] = {kModifier, '\0'}; if (inheritable) { // Remove `kModifier` from modifiers. for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == kModifier) { mode.erase(i, 1); --i; continue; } if (mode[i] == ',') break; } } else { // Add `kModifier` to modifiers unless it already exists there. for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == kModifier) return; if (mode[i] == ',') break; } size_t position = 1; while (mode.size() > position && (mode[position] == '+' || mode[position] == 'b' || mode[position] == 't' || mode[position] == 'x')) { ++position; } mode.insert(position, kModifierStr); } } } // namespace void SetInheritableReading(bool inheritable, std::string& mode) { if (ABSL_PREDICT_FALSE(mode.empty())) mode = "r"; SetInheritableImpl(inheritable, mode); } void SetInheritableWriting(bool inheritable, std::string& mode) { if (ABSL_PREDICT_FALSE(mode.empty())) mode = "w"; SetInheritableImpl(inheritable, mode); } bool GetInheritable(absl::string_view mode) { #ifndef _WIN32 static constexpr char kModifier = 'e'; #else static constexpr char kModifier = 'N'; #endif if (ABSL_PREDICT_FALSE(mode.empty())) return true; for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == kModifier) return false; if (mode[i] == ',') break; } return true; } namespace { inline void SetTextImpl(bool text, std::string& mode) { #ifdef _WIN32 const char to_remove = text ? 'b' : 't'; const char to_add[2] = {text ? 't' : 'b', '\0'}; bool need_to_add = true; for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == to_remove) { if (need_to_add) { mode[i] = to_add[0]; need_to_add = false; } else { mode.erase(i, 1); --i; } continue; } if (mode[i] == to_add[0]) { need_to_add = false; continue; } if (mode[i] == ',') break; } if (need_to_add) { size_t position = 1; while (mode.size() > position && mode[position] == '+') ++position; mode.insert(position, to_add); } #endif } } // namespace void SetTextReading(bool text, std::string& mode) { if (ABSL_PREDICT_FALSE(mode.empty())) mode = "r"; SetTextImpl(text, mode); } void SetTextWriting(bool text, std::string& mode) { if (ABSL_PREDICT_FALSE(mode.empty())) mode = "w"; SetTextImpl(text, mode); } #ifdef _WIN32 int GetTextAsFlags(absl::string_view mode) { for (size_t i = 1; i < mode.size(); ++i) { if (mode[i] == 'b') return _O_BINARY; if (mode[i] == 't') return _O_TEXT; if (mode[i] == ',') break; } return 0; } #endif } // namespace file_internal } // namespace riegeli
[ "qrczak@google.com" ]
qrczak@google.com
a955548a5f4d7ae832cfdf47759947b21efc7a8e
b4145c423da8e47e2c3daf66cfbf51084ffe0edd
/MeshWork/table.h
08af637999db478f634c35ddf4ef419d8464d268
[]
no_license
yfguo91/remesh
7cf21938b4d39ee9746e15d2f5867c0a7bf0f331
31d020402b9cb826b0ab570e9642d17e615152e1
refs/heads/master
2023-01-06T07:11:58.015907
2023-01-03T09:51:42
2023-01-03T09:51:42
277,212,308
1
1
null
null
null
null
GB18030
C++
false
false
3,162
h
#ifndef FILE_TABLE #define FILE_TABLE /**************************************************************************/ /* File: table.hpp */ /* Date: 15. April. 2016 */ /**************************************************************************/ namespace meshwork { ///类的可见性设计还存在问题 /// generic class TABLE. template <class T> class Table { public: /// class linestruct { public: /// int size; /// int maxsize; /// T * col; T operator[] (int i) const { return col[i]; } }; /// vector<linestruct> data; public: /// Table (int size) { data.resize(size); for (int i = 0; i < size; i++) { data[i].maxsize = 0; data[i].size = 0; data[i].col = NULL; } } /// Table () { ; } /// ~Table () { for (int i = 0; i < data.size(); i++) { if(data[i].col != NULL) delete [] (T*)data[i].col; } } /// void SetSize (int size) { for (int i = 0; i < data.size(); i++) { if(data[i].col != NULL) delete [] (T*)data[i].col; } data.resize(size); for (int i = 0; i < size; i++) { data[i].maxsize = 0; data[i].size = 0; data[i].col = NULL; } } /// void ChangeSize (int size) { int oldsize = data.size(); if (size == oldsize) return; if (size < oldsize) for (int i = size; i < oldsize; i++) { if(data[i].col != NULL) delete [] (T*)data[i].col; } data.SetSize(size); for (int i = oldsize; i < size; i++) { data[i].maxsize = 0; data[i].size = 0; data[i].col = NULL; } } /// void Add (int i, const T & acont) { int oldsize = data.size(); if(data.size()<=i) { data.resize(i+1); for (int j = oldsize; j <= i; j++) { data[j].maxsize = 0; data[j].size = 0; data[j].col = NULL; } } linestruct & line = data[i]; if (line.size == line.maxsize) { T * p = new T [(line.maxsize+5)]; memcpy (p, line.col, line.maxsize*sizeof(T)); delete [] (T*)line.col; line.col = p; line.maxsize += 5; } line.size++; ((T*)data[i].col)[data[i].size-1] = acont; } ///共几行 int Size () const { return data.size(); } ///row行共几列 int RowSize (int row) const { return data[row].size; } ///没有检查是否越界,请慎用 vector<T> operator[] (int i) const { return vector<T> (data[i].col,data[i].col+data[i].size*sizeof(T)); } ///没有检查是否越界,请慎用 void Set (int i, int nr, const T & acont) { data[i].col[j] = acont; } ///没有检查是否越界,请慎用 T Get(int i,int j) const { return data[i][j]; } }; template <class T> ostream & operator<< (ostream & ost, const Table<T> & table) { for (int i = 0; i < table.Size(); i++) { ost << i << ": "; ost << "(" << table.data[i].size << ") "; for (int j = 0; j < table.data[i].size; j++) ost << table.data[i].col[j] << " "; ost << endl; } return ost; } } #endif
[ "1501111591@pku.edu.cn" ]
1501111591@pku.edu.cn
6126a2c5395b6c9618daf4be6ca51820dc66b193
2552be2e1e71c352979f2c8e2214b1abad81ba2f
/cost_dbns_chain_r2l.h
b48208d5b2786afdec07aa868e08ddc95f30dc99
[]
no_license
maxwellsayles/powcosts
e9cf3df3bfaf8a14de4e03ff25499faddd52144e
237da247ee3d081f77ee140020f7755d967e9f2f
refs/heads/master
2020-08-07T10:17:10.249593
2013-05-21T00:53:00
2013-05-21T00:53:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
602
h
#pragma once #ifndef COST_DBNS_CHAIN_R2L_H_ #define COST_DBNS_CHAIN_R2L_H_ #include "powcosts/i_cost_exp.h" class CostDBNSChainR2L : public ICostExp { public: double cost(const group_cost_t& cost, const mpz_c& in_n) const override; }; class CostDBNSChainR2L36 : public ICostExp { public: double cost(const group_cost_t& costs, const mpz_c& in_n) const override; }; class CostDBNSChainR2L36Prog : public ICostExp { public: CostDBNSChainR2L36Prog(const int mask) : mask_(mask) {} double cost(const group_cost_t& costs, const mpz_c& in_n) const override; private: int mask_; }; #endif
[ "maxwellsayles@gmail.com" ]
maxwellsayles@gmail.com
c2b771fb61ba79db8d37ebda6ae625ec82a4a81a
a1c6c3e5dbee5e8ca705700f0a626d7c9a040e1b
/Linked List/142 Linked List Cycle II/main.cpp
6623402b2d94e02942fbbcc982e1a482f482ff67
[]
no_license
Novak666/leetcode
00370458c3931eb2f29158232b8a397b5386a852
aac04bdfb38794e6b9007a7a72ae0d50b459601d
refs/heads/master
2021-07-05T17:56:19.309548
2019-03-13T02:07:12
2019-03-13T02:07:12
145,187,953
1
0
null
null
null
null
UTF-8
C++
false
false
741
cpp
#include <iostream> using namespace std; /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *detectCycle(ListNode *head) { ListNode *fast = head, *slow = head; while(fast && fast->next){ slow = slow->next; fast = fast->next->next; if(slow == fast) break; } if(!fast || !fast->next) return NULL; slow = head; while(slow != fast){ slow = slow->next; fast = fast->next; } return fast; } }; int main() { cout << "Hello world!" << endl; return 0; }
[ "huweiyu2008@163.com" ]
huweiyu2008@163.com
0726774fe1052a35fb4ac106e885c9642c4b6eb8
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/httpd/gumtree/httpd_old_log_1301.cpp
fb1ba33a5942c2fcf3374d364106d972e1b18da9
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
227
cpp
ap_log_cerror(APLOG_MARK, APLOG_INFO, rc, c, "SSL library error %d in handshake " "(server %s)", ssl_err, ssl_util_vhostid(c->pool, c->base_server));
[ "993273596@qq.com" ]
993273596@qq.com
cff4074f42eb7dfb2d9bea0e41169c94c6bb40ee
987a81599ff1cee5f4e3ba6e2b5dd03cce51b150
/3-4-spanning-trees/B/solve.cpp
b8a98476d40c655235a1e46b2092b90d7f98ff2c
[]
no_license
free0u/discrete-labs
19748f289f9a3f3f0dfdb806c8a1e19932cec887
0cf4fc94b032e518c6e29aef44db25b7b2da7176
refs/heads/master
2021-03-12T23:18:44.741783
2014-06-20T10:21:57
2014-06-20T10:21:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,411
cpp
#include <cstdio> #include <cstdlib> #include <cmath> #include <vector> #include <string> #include <iostream> #include <algorithm> using namespace std; #define task_name "spantree2" class DSU { public: DSU() {} DSU(int n) { par.resize(n); for (int i = 0; i < n; ++i) { par[i] = i; } } int find(int v) { if (v == par[v]) return v; return par[v] = find(par[v]); } void unite(int x, int y) { x = find(x); y = find(y); if (x != y) { if (rand() & 1) { par[x] = y; } else { par[y] = x; } } } private: vector<int> par; }; struct edge { int from, to, w; edge() {} edge(int from, int to, int w) : from(from), to(to), w(w) {} bool operator < (edge const& e) const { return w < e.w; } }; int main() { #ifndef HOME_free0u freopen(task_name".in", "r", stdin); freopen(task_name".out", "w", stdout); #else freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, m; cin >> n >> m; int from, to, w; vector<edge> edges; for (int i = 0; i < m; ++i) { scanf("%d%d%d", &from, &to, &w); from--; to--; edges.push_back(edge(from, to, w)); } sort(edges.begin(), edges.end()); DSU dsu(n); long long int ans = 0; for (int i = 0; i < m; ++i) { from = edges[i].from; to = edges[i].to; w = edges[i].w; if (dsu.find(from) != dsu.find(to)) { dsu.unite(from, to); ans += w; } } cout << ans; return 0; }
[ "free0u@gmail.com" ]
free0u@gmail.com
281df526b66aad069700c271d10d71cbedc4c26f
c2713198bbe246e697ac2a92c367f1c3ed50a447
/src/content/common/widget_messages.h
97ac51c185413f4673e3daee62317a175e5d4562
[ "BSD-3-Clause" ]
permissive
Igalia/chromium72
4f5fed7b0b2e820281128fb21d82cf18e8117970
ed2a6d143dfd2fc5af50e0c2720c80e9717f465c
refs/heads/master
2022-11-06T01:48:57.727914
2019-09-09T19:24:17
2019-09-09T22:26:51
210,885,925
0
0
null
2019-09-25T16:01:48
2019-09-25T16:01:47
null
UTF-8
C++
false
false
15,302
h
// Copyright 2018 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 CONTENT_COMMON_WIDGET_MESSAGES_H_ #define CONTENT_COMMON_WIDGET_MESSAGES_H_ // IPC messages for controlling painting and input events. #include "base/time/time.h" #include "cc/input/touch_action.h" #include "content/common/content_param_traits.h" #include "content/common/cursors/webcursor.h" #include "content/common/text_input_state.h" #include "content/common/visual_properties.h" #include "content/public/common/common_param_traits.h" #include "ipc/ipc_message_macros.h" #include "third_party/blink/public/common/screen_orientation/web_screen_orientation_type.h" #include "third_party/blink/public/platform/web_float_point.h" #include "third_party/blink/public/platform/web_float_rect.h" #include "third_party/blink/public/platform/web_intrinsic_sizing_info.h" #include "third_party/blink/public/web/web_device_emulation_params.h" #include "third_party/blink/public/web/web_text_direction.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/rect.h" #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START WidgetMsgStart // Traits for VisualProperties. IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDeviceEmulationParams::ScreenPosition, blink::WebDeviceEmulationParams::kScreenPositionLast) IPC_ENUM_TRAITS_MAX_VALUE(content::ScreenOrientationValues, content::SCREEN_ORIENTATION_VALUES_LAST) IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebScreenOrientationType, blink::kWebScreenOrientationUndefined, blink::WebScreenOrientationTypeLast) IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDisplayMode, blink::WebDisplayMode::kWebDisplayModeLast) IPC_STRUCT_TRAITS_BEGIN(content::VisualProperties) IPC_STRUCT_TRAITS_MEMBER(screen_info) IPC_STRUCT_TRAITS_MEMBER(auto_resize_enabled) IPC_STRUCT_TRAITS_MEMBER(min_size_for_auto_resize) IPC_STRUCT_TRAITS_MEMBER(max_size_for_auto_resize) IPC_STRUCT_TRAITS_MEMBER(new_size) IPC_STRUCT_TRAITS_MEMBER(compositor_viewport_pixel_size) IPC_STRUCT_TRAITS_MEMBER(browser_controls_shrink_blink_size) IPC_STRUCT_TRAITS_MEMBER(scroll_focused_node_into_view) IPC_STRUCT_TRAITS_MEMBER(top_controls_height) IPC_STRUCT_TRAITS_MEMBER(bottom_controls_height) IPC_STRUCT_TRAITS_MEMBER(local_surface_id_allocation) IPC_STRUCT_TRAITS_MEMBER(visible_viewport_size) IPC_STRUCT_TRAITS_MEMBER(is_fullscreen_granted) IPC_STRUCT_TRAITS_MEMBER(display_mode) IPC_STRUCT_TRAITS_MEMBER(capture_sequence_number) IPC_STRUCT_TRAITS_MEMBER(zoom_level) IPC_STRUCT_TRAITS_MEMBER(page_scale_factor) IPC_STRUCT_TRAITS_END() // Traits for WebDeviceEmulationParams. IPC_STRUCT_TRAITS_BEGIN(blink::WebFloatPoint) IPC_STRUCT_TRAITS_MEMBER(x) IPC_STRUCT_TRAITS_MEMBER(y) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(blink::WebFloatRect) IPC_STRUCT_TRAITS_MEMBER(x) IPC_STRUCT_TRAITS_MEMBER(y) IPC_STRUCT_TRAITS_MEMBER(width) IPC_STRUCT_TRAITS_MEMBER(height) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(blink::WebSize) IPC_STRUCT_TRAITS_MEMBER(width) IPC_STRUCT_TRAITS_MEMBER(height) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(blink::WebDeviceEmulationParams) IPC_STRUCT_TRAITS_MEMBER(screen_position) IPC_STRUCT_TRAITS_MEMBER(screen_size) IPC_STRUCT_TRAITS_MEMBER(view_position) IPC_STRUCT_TRAITS_MEMBER(device_scale_factor) IPC_STRUCT_TRAITS_MEMBER(view_size) IPC_STRUCT_TRAITS_MEMBER(scale) IPC_STRUCT_TRAITS_MEMBER(viewport_offset) IPC_STRUCT_TRAITS_MEMBER(viewport_scale) IPC_STRUCT_TRAITS_MEMBER(screen_orientation_angle) IPC_STRUCT_TRAITS_MEMBER(screen_orientation_type) IPC_STRUCT_TRAITS_END() IPC_ENUM_TRAITS_MAX_VALUE(blink::WebTextDirection, blink::WebTextDirection::kWebTextDirectionLast) IPC_STRUCT_BEGIN(WidgetHostMsg_SelectionBounds_Params) IPC_STRUCT_MEMBER(gfx::Rect, anchor_rect) IPC_STRUCT_MEMBER(blink::WebTextDirection, anchor_dir) IPC_STRUCT_MEMBER(gfx::Rect, focus_rect) IPC_STRUCT_MEMBER(blink::WebTextDirection, focus_dir) IPC_STRUCT_MEMBER(bool, is_anchor_first) IPC_STRUCT_END() // Traits for TextInputState. IPC_ENUM_TRAITS_MAX_VALUE(ui::TextInputMode, ui::TEXT_INPUT_MODE_MAX) IPC_STRUCT_TRAITS_BEGIN(content::TextInputState) IPC_STRUCT_TRAITS_MEMBER(type) IPC_STRUCT_TRAITS_MEMBER(mode) IPC_STRUCT_TRAITS_MEMBER(flags) IPC_STRUCT_TRAITS_MEMBER(value) IPC_STRUCT_TRAITS_MEMBER(selection_start) IPC_STRUCT_TRAITS_MEMBER(selection_end) IPC_STRUCT_TRAITS_MEMBER(composition_start) IPC_STRUCT_TRAITS_MEMBER(composition_end) IPC_STRUCT_TRAITS_MEMBER(can_compose_inline) IPC_STRUCT_TRAITS_MEMBER(show_ime_if_needed) IPC_STRUCT_TRAITS_MEMBER(reply_to_request) IPC_STRUCT_TRAITS_END() // // Browser -> Renderer Messages. // // Sent to inform the renderer to invoke a context menu. // The parameter specifies the location in the render widget's coordinates. IPC_MESSAGE_ROUTED2(WidgetMsg_ShowContextMenu, ui::MenuSourceType, gfx::Point /* location where menu should be shown */) // Tells the render widget to close. // Expects a Close_ACK message when finished. IPC_MESSAGE_ROUTED0(WidgetMsg_Close) // Tells the renderer to update visual properties. The resulting // CompositorFrame will produce a RenderFrameMetadata containing a new // LocalSurfaceId. This acts as a form of ACK for this message. IPC_MESSAGE_ROUTED1(WidgetMsg_SynchronizeVisualProperties, content::VisualProperties /* params */) // Enables device emulation. See WebDeviceEmulationParams for description. IPC_MESSAGE_ROUTED1(WidgetMsg_EnableDeviceEmulation, blink::WebDeviceEmulationParams /* params */) // Disables device emulation, enabled previously by EnableDeviceEmulation. IPC_MESSAGE_ROUTED0(WidgetMsg_DisableDeviceEmulation) // Sent to inform the widget that it was hidden. This allows it to reduce its // resource utilization. IPC_MESSAGE_ROUTED0(WidgetMsg_WasHidden) // Tells the render view that it is no longer hidden (see WasHidden). IPC_MESSAGE_ROUTED2(WidgetMsg_WasShown, base::TimeTicks /* show_request_timestamp */, bool /* was_evicted */) // Activate/deactivate the RenderWidget (i.e., set its controls' tint // accordingly, etc.). IPC_MESSAGE_ROUTED1(WidgetMsg_SetActive, bool /* active */) // Make the RenderWidget background transparent or opaque. IPC_MESSAGE_ROUTED1(WidgetMsg_SetBackgroundOpaque, bool /* opaque */) // Changes the text direction of the currently selected input field (if any). IPC_MESSAGE_ROUTED1(WidgetMsg_SetTextDirection, blink::WebTextDirection /* direction */) // Reply to WidgetHostMsg_RequestSetBounds, WidgetHostMsg_ShowWidget, and // FrameHostMsg_ShowCreatedWindow, to inform the renderer that the browser has // processed the bounds-setting. The browser may have ignored the new bounds, // but it finished processing. This is used because the renderer keeps a // temporary cache of the widget position while these asynchronous operations // are in progress. IPC_MESSAGE_ROUTED0(WidgetMsg_SetBounds_ACK) // Informs the RenderWidget of its position on the user's screen, as well as // the position of the native window holding the RenderWidget. IPC_MESSAGE_ROUTED2(WidgetMsg_UpdateScreenRects, gfx::Rect /* widget_screen_rect */, gfx::Rect /* window_screen_rect */) // Sent by the browser to ask the renderer to redraw. Robust to events that can // happen in renderer (abortion of the commit or draw, loss of output surface // etc.). IPC_MESSAGE_ROUTED1(WidgetMsg_ForceRedraw, int /* snapshot_id */) // Sets the viewport intersection and compositor raster area on the widget for // an out-of-process iframe. IPC_MESSAGE_ROUTED3(WidgetMsg_SetViewportIntersection, gfx::Rect /* viewport_intersection */, gfx::Rect /* compositor_visible_rect */, bool /* occluded or obscured */) // Sent to an OOPIF widget when the browser receives a FrameHostMsg_SetIsInert // from the target widget's embedding renderer changing its inertness. When a // widget is inert, it is unable to process input events. // // https://html.spec.whatwg.org/multipage/interaction.html#inert IPC_MESSAGE_ROUTED1(WidgetMsg_SetIsInert, bool /* inert */) // Sets the inherited effective touch action on an out-of-process iframe. IPC_MESSAGE_ROUTED1(WidgetMsg_SetInheritedEffectiveTouchAction, cc::TouchAction) // Toggles render throttling for an out-of-process iframe. IPC_MESSAGE_ROUTED2(WidgetMsg_UpdateRenderThrottlingStatus, bool /* is_throttled */, bool /* subtree_throttled */) // Sent by the browser to synchronize with the next compositor frame by // requesting an ACK be queued. Used only for tests. IPC_MESSAGE_ROUTED1(WidgetMsg_WaitForNextFrameForTests, int /* main_frame_thread_observer_routing_id */) // Tells the render side that a WidgetHostMsg_LockMouse message has been // processed. |succeeded| indicates whether the mouse has been successfully // locked or not. IPC_MESSAGE_ROUTED1(WidgetMsg_LockMouse_ACK, bool /* succeeded */) // Tells the render side that the mouse has been unlocked. IPC_MESSAGE_ROUTED0(WidgetMsg_MouseLockLost) // // Renderer -> Browser Messages. // // Sent by the renderer process to request that the browser close the widget. // This corresponds to the window.close() API, and the browser may ignore // this message. Otherwise, the browser will generate a WidgetMsg_Close // message to close the widget. IPC_MESSAGE_ROUTED0(WidgetHostMsg_Close) // Notification that the selection bounds have changed. IPC_MESSAGE_ROUTED1(WidgetHostMsg_SelectionBoundsChanged, WidgetHostMsg_SelectionBounds_Params) // Sent in response to a WidgetMsg_UpdateScreenRects so that the renderer can // throttle these messages. IPC_MESSAGE_ROUTED0(WidgetHostMsg_UpdateScreenRects_ACK) // Only used for SVGs inside of <object> and not for iframes. Informs the // browser that hte current frame's intrinsic sizing info has changed. The // browser can then notify a containing frame that the frame may need to // trigger a new layout. // // Also see FrameMsg_IntrinsicSizingInfoOfChildChanged. IPC_MESSAGE_ROUTED1(WidgetHostMsg_IntrinsicSizingInfoChanged, blink::WebIntrinsicSizingInfo) // Send the tooltip text for the current mouse position to the browser. IPC_MESSAGE_ROUTED2(WidgetHostMsg_SetTooltipText, base::string16 /* tooltip text string */, blink::WebTextDirection /* text direction hint */) // Updates the current cursor to be used by the browser for indicating the // location of a pointing device. IPC_MESSAGE_ROUTED1(WidgetHostMsg_SetCursor, content::WebCursor) // Request a non-decelerating synthetic fling animation to be latched on the // scroller at the start point, and whose velocity can be changed over time by // sending multiple AutoscrollFling gestures. Used for features like // middle-click autoscroll. IPC_MESSAGE_ROUTED1(WidgetHostMsg_AutoscrollStart, gfx::PointF /* start */) IPC_MESSAGE_ROUTED1(WidgetHostMsg_AutoscrollFling, gfx::Vector2dF /* velocity */) IPC_MESSAGE_ROUTED0(WidgetHostMsg_AutoscrollEnd) // Notifies the browser if the text input state has changed. Primarily useful // for IME as they need to know of all changes to update their interpretation // of the characters that have been input. IPC_MESSAGE_ROUTED1(WidgetHostMsg_TextInputStateChanged, content::TextInputState /* text_input_state */) // Sent by the renderer process to request that the browser change the bounds of // the widget. This corresponds to the window.resizeTo() and window.moveTo() // APIs, and the browser may ignore this message. IPC_MESSAGE_ROUTED1(WidgetHostMsg_RequestSetBounds, gfx::Rect /* bounds */) // Requests to lock the mouse. Will result in a WidgetMsg_LockMouse_ACK message // being sent back. // |privileged| is used by Pepper Flash. If this flag is set to true, we won't // pop up a bubble to ask for user permission or take mouse lock content into // account. IPC_MESSAGE_ROUTED2(WidgetHostMsg_LockMouse, bool /* user_gesture */, bool /* privileged */) // Requests to unlock the mouse. A WidgetMsg_MouseLockLost message will be sent // whenever the mouse is unlocked (which may or may not be caused by // WidgetHostMsg_UnlockMouse). IPC_MESSAGE_ROUTED0(WidgetHostMsg_UnlockMouse) // Message sent from renderer to the browser when the element that is focused // has been touched. A bool is passed in this message which indicates if the // node is editable. IPC_MESSAGE_ROUTED1(WidgetHostMsg_FocusedNodeTouched, bool /* editable */) // Sent by the renderer process in response to an earlier WidgetMsg_ForceRedraw // message. The reply includes the snapshot-id from the request. IPC_MESSAGE_ROUTED1(WidgetHostMsg_ForceRedrawComplete, int /* snapshot_id */) // Sends a set of queued messages that were being held until the next // CompositorFrame is being submitted from the renderer. These messages are // sent before the OnRenderFrameMetadataChanged message is sent (via mojo) and // before the CompositorFrame is sent to the viz service. The |frame_token| // will match the token in the about-to-be-submitted CompositorFrame. IPC_MESSAGE_ROUTED2(WidgetHostMsg_FrameSwapMessages, uint32_t /* frame_token */, std::vector<IPC::Message> /* messages */) // Indicates that the render widget has been closed in response to a // Close message. IPC_MESSAGE_CONTROL1(WidgetHostMsg_Close_ACK, int /* old_route_id */) // Sent from an inactive renderer for the browser to route to the active // renderer, instructing it to close. // // TODO(http://crbug.com/419087): Move this thing to Frame as it's a signal // from a swapped out frame to the mainframe of the frame tree. IPC_MESSAGE_ROUTED0(WidgetHostMsg_RouteCloseEvent) // Sent in reply to WidgetMsg_WaitForNextFrameForTests. IPC_MESSAGE_ROUTED0(WidgetHostMsg_WaitForNextFrameForTests_ACK) // Sent once a paint happens after the first non empty layout. In other words, // after the frame widget has painted something. IPC_MESSAGE_ROUTED0(WidgetHostMsg_DidFirstVisuallyNonEmptyPaint) // Sent once the RenderWidgetCompositor issues a draw command. IPC_MESSAGE_ROUTED0(WidgetHostMsg_DidCommitAndDrawCompositorFrame) // Notifies whether there are JavaScript touch event handlers or not. IPC_MESSAGE_ROUTED1(WidgetHostMsg_HasTouchEventHandlers, bool /* has_handlers */) // Sent by a widget to the browser to request a page scale animation in the // main-frame's widget. IPC_MESSAGE_ROUTED2(WidgetHostMsg_AnimateDoubleTapZoomInMainFrame, gfx::Point /* tap point */, gfx::Rect /* rect_to_zoom */) #if defined(USE_NEVA_APPRUNTIME) IPC_MESSAGE_ROUTED0(WidgetMsg_ActivateCompositor) IPC_MESSAGE_ROUTED0(WidgetMsg_DeactivateCompositor) #endif #endif // CONTENT_COMMON_WIDGET_MESSAGES_H_
[ "lokeshkumar.goel@lge.com" ]
lokeshkumar.goel@lge.com
dc383f0c0857dbcd56d7330c68b598275ec77339
50013a78fae7e06c2cf0c63777585044ec0c12eb
/ArduinoCode/SendRangeBasic-espVer2/SendRangeBasic-espVer2.ino
cf744e789721f979e0a3918d4a97d4fc1806f0c8
[]
no_license
KuroNguyen/IPSThesis
2767721636a65348a23735721a9647295f25cade
f1d7ee508367ebb083517e475ad001aae89f9777
refs/heads/master
2021-08-23T23:46:12.669757
2017-12-07T04:10:00
2017-12-07T04:10:00
109,517,292
0
0
null
null
null
null
UTF-8
C++
false
false
3,518
ino
/*--------------------------------------------------------------------------------------------- Open Sound Control (OSC) library for the ESP8266/ESP32 Example for sending messages from the ESP8266/ESP32 to a remote computer The example is sending "hello, osc." to the address "/test". This example code is in the public domain. --------------------------------------------------------------------------------------------- */ #if defined(ESP8266) #include <ESP8266WiFi.h> #else #include <WiFi.h> #endif #include <WiFiUdp.h> #include <OSCMessage.h> ////////////// //char data[10]; ////////////// const char *ssid = "KuroThesis"; // your network SSID (name) const char *pass = "HOILAMGI"; // your network password String str; char rangeValue1[7]; // Distance to Anchor1 //char rxValue[7]; char rangeValue2[7]; // Distance to Anchor2 //char rxValue[7]; char rangeValue3[7]; // Distance to Anchor3 //char rxValue[7]; boolean receiveState = false; //false if receive distance from anchor1, true if receive distance from anchor3 int i; //Counting variable of osc string message int b; //Counting variable of string char //boolean stringExceed = false; //int k; //State for sending message WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP const IPAddress outIp(192,168,0,3); // remote IP of your computer const unsigned int outPort = 12000; // remote port to receive OSC const unsigned int localPort = 8888; // local port to listen for OSC packets (actually not used for sending) void setup() { Serial.begin(115200); // Connect to WiFi network // Serial.println(); // Serial.println(); // Serial.print("Connecting to "); // Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); Serial.println("Starting UDP"); Udp.begin(localPort); Serial.print("Local port: "); #ifdef ESP32 Serial.println(localPort); #else Serial.println(Udp.localPort()); #endif delay(5000); } void loop() { //Receive serial data if (Serial.available()) { while (Serial.available()) { str = Serial.readStringUntil('\n'); } } if (str != "") { // Add range value of anchor1 if (str.charAt(0) == '1') { receiveState = false; for (i = 0; i<str.length();i++) { rangeValue1[i] = str.charAt(i+1); } rangeValue1[i] = '\0'; //Add null char for char array } // Add range value of anchor2 else if (str.charAt(0) == '2') { for (i = 0; i<str.length();i++) { rangeValue2[i] = str.charAt(i+1); } rangeValue2[i] = '\0'; //Add null char for char array } // Add range value of anchor3 else { receiveState = true; // Receive enough 3 distance value for (i = 0; i<str.length();i++) { rangeValue3[i] = str.charAt(i+1); } rangeValue3[i] = '\0'; //Add null char for char array } } if (receiveState) { //Create OSC message OSCMessage msg("/Anchor"); msg.add(rangeValue1); msg.add(rangeValue2); msg.add(rangeValue3); Udp.beginPacket(outIp, outPort); msg.send(Udp); Udp.endPacket(); msg.empty(); } }
[ "chanhtruck13@gmail.com" ]
chanhtruck13@gmail.com
5446516e03a5bcec2e179361abe5bfa7728e7d32
921e4370943fa7e20d464c2cd67ac6bbedbd9723
/TopCoder/NumericalSequence.cc
70da01b8caa2d51a24e49d94fb9430e733a73e07
[]
no_license
kokay/CodingPractice
7504cfbf049cbff5c8b4e56e36329f70b2774dda
da51603dad0617fb70e41ee6b5404d974d72d69f
refs/heads/master
2021-01-18T20:46:36.082137
2016-10-25T06:44:10
2016-10-25T06:44:10
69,950,440
0
0
null
null
null
null
UTF-8
C++
false
false
982
cc
#include <iostream> #include <vector> using namespace std; class NumericalSequence { public: int makePalindrome(vector<int> sequence) { int idx, operation = 0; while ((idx = findIdxForChange(sequence)) != -1) { if (idx < sequence.size() / 2) sequence[idx + 1] += sequence[idx]; else sequence[idx - 1] += sequence[idx]; sequence.erase(sequence.begin() + idx); ++operation; } return operation; } private: int findIdxForChange(vector<int>& sequence) { for (int i = 0; i < sequence.size() / 2; ++i) { int otherSideIdx = sequence.size() - 1 - i; if (sequence[i] != sequence[otherSideIdx]) { if (sequence[i] < sequence[otherSideIdx]) return i; else return otherSideIdx; } } return -1; } }; //int main() { // NumericalSequence numericalSequence; // cout << numericalSequence.makePalindrome({ 3,23,21,23,42,39,63,76,13,13,13,32,12,42,26 }) << endl; //}
[ "a.cz0512@gmail.com" ]
a.cz0512@gmail.com
bcc0e95b1b341b390ae9f3d63908bc0987506cf0
27633b77b013d04ba957d63dab06c5b561fee2a9
/d4122/code/security_probe/flux_control/source/FCSleepAndDoThread.h
84b204a1e07cf6acf8f5fb65c2fd46981bde166b
[]
no_license
Barrnett/web_replace_shell
6828fb1de3a0ba914d8536e2c66c2901c9eb7bcf
60eb3d0e086617827c1db9b6cd5ec428c52c99ad
refs/heads/master
2020-06-18T23:22:54.008226
2019-07-12T02:00:44
2019-07-12T02:00:44
196,490,295
0
0
null
null
null
null
UTF-8
C++
false
false
368
h
////////////////////////////////////////////////////////////////////////// //FCSleepAndDoThread.h #pragma once #include "cpf/SleepAndDoThread.h" class CFCSleepAndDoThread : public CSleepAndDoThread { public: CFCSleepAndDoThread(int type,int reason); virtual ~CFCSleepAndDoThread(void); protected: virtual int DoFunc(); private: int m_type; int m_reason; };
[ "877584721@qq.com" ]
877584721@qq.com
3d478c812af5813c03eeed99d3125afabc2bc4c3
db00f801f91c0e5f0937b37981fcdf9bdf5463da
/src/merkleblock.h
ee67c76e22c01a33e56f788e754d264558bbef1a
[ "MIT" ]
permissive
kitkatty/bitcoinrandom
bb3aef4fb008c85d2b2eba78912f0212ed294518
290e9e5c48f12b89147cf59220449ce92e2ab892
refs/heads/master
2020-03-20T12:22:19.282998
2018-06-24T18:33:52
2018-06-24T18:33:52
137,427,908
3
0
null
null
null
null
UTF-8
C++
false
false
5,874
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOINRANDOM_MERKLEBLOCK_H #define BITCOINRANDOM_MERKLEBLOCK_H #include "bloom.h" #include "primitives/block.h" #include "serialize.h" #include "uint256.h" #include <vector> /** Data structure that represents a partial merkle tree. * * It represents a subset of the txid's of a known block, in a way that * allows recovery of the list of txid's and the merkle root, in an * authenticated way. * * The encoding works as follows: we traverse the tree in depth-first order, * storing a bit for each traversed node, signifying whether the node is the * parent of at least one matched leaf txid (or a matched txid itself). In * case we are at the leaf level, or this bit is 0, its merkle node hash is * stored, and its children are not explored further. Otherwise, no hash is * stored, but we recurse into both (or the only) child branch. During * decoding, the same depth-first traversal is performed, consuming bits and * hashes as they written during encoding. * * The serialization is fixed and provides a hard guarantee about the * encoded size: * * SIZE <= 10 + ceil(32.25*N) * * Where N represents the number of leaf nodes of the partial tree. N itself * is bounded by: * * N <= total_transactions * N <= 1 + matched_transactions*tree_height * * The serialization format: * - uint32 total_transactions (4 bytes) * - varint number of hashes (1-3 bytes) * - uint256[] hashes in depth-first order (<= 32*N bytes) * - varint number of bytes of flag bits (1-3 bytes) * - byte[] flag bits, packed per 8 in a byte, least significant bit first (<= 2*N-1 bits) * The size constraints follow from this. */ class CPartialMerkleTree { protected: /** the total number of transactions in the block */ unsigned int nTransactions; /** node-is-parent-of-matched-txid bits */ std::vector<bool> vBits; /** txids and internal hashes */ std::vector<uint256> vHash; /** flag set when encountering invalid data */ bool fBad; /** helper function to efficiently calculate the number of nodes at given height in the merkle tree */ unsigned int CalcTreeWidth(int height) { return (nTransactions + (1 << height) - 1) >> height; } /** calculate the hash of a node in the merkle tree (at leaf level: the txid's themselves) */ uint256 CalcHash(int height, unsigned int pos, const std::vector<uint256>& vTxid); /** recursive function that traverses tree nodes, storing the data as bits and hashes */ void TraverseAndBuild(int height, unsigned int pos, const std::vector<uint256>& vTxid, const std::vector<bool>& vMatch); /** * recursive function that traverses tree nodes, consuming the bits and hashes produced by TraverseAndBuild. * it returns the hash of the respective node and its respective index. */ uint256 TraverseAndExtract(int height, unsigned int pos, unsigned int& nBitsUsed, unsigned int& nHashUsed, std::vector<uint256>& vMatch, std::vector<unsigned int>& vnIndex); public: /** serialization implementation */ ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(nTransactions); READWRITE(vHash); std::vector<unsigned char> vBytes; if (ser_action.ForRead()) { READWRITE(vBytes); CPartialMerkleTree& us = *(const_cast<CPartialMerkleTree*>(this)); us.vBits.resize(vBytes.size() * 8); for (unsigned int p = 0; p < us.vBits.size(); p++) us.vBits[p] = (vBytes[p / 8] & (1 << (p % 8))) != 0; us.fBad = false; } else { vBytes.resize((vBits.size() + 7) / 8); for (unsigned int p = 0; p < vBits.size(); p++) vBytes[p / 8] |= vBits[p] << (p % 8); READWRITE(vBytes); } } /** Construct a partial merkle tree from a list of transaction ids, and a mask that selects a subset of them */ CPartialMerkleTree(const std::vector<uint256>& vTxid, const std::vector<bool>& vMatch); CPartialMerkleTree(); /** * extract the matching txid's represented by this partial merkle tree * and their respective indices within the partial tree. * returns the merkle root, or 0 in case of failure */ uint256 ExtractMatches(std::vector<uint256>& vMatch, std::vector<unsigned int>& vnIndex); }; /** * Used to relay blocks as header + vector<merkle branch> * to filtered nodes. * * NOTE: The class assumes that the given CBlock has *at least* 1 transaction. If the CBlock has 0 txs, it will hit an assertion. */ class CMerkleBlock { public: /** Public only for unit testing */ CBlockHeader header; CPartialMerkleTree txn; public: /** Public only for unit testing and relay testing (not relayed) */ std::vector<std::pair<unsigned int, uint256>> vMatchedTxn; /** * Create from a CBlock, filtering transactions according to filter * Note that this will call IsRelevantAndUpdate on the filter for each transaction, * thus the filter will likely be modified. */ CMerkleBlock(const CBlock& block, CBloomFilter& filter); // Create from a CBlock, matching the txids in the set CMerkleBlock(const CBlock& block, const std::set<uint256>& txids); CMerkleBlock() {} ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(header); READWRITE(txn); } }; #endif // BITCOINRANDOM_MERKLEBLOCK_H
[ "34012208+kitkatty@users.noreply.github.com" ]
34012208+kitkatty@users.noreply.github.com
bfbab99dbbea8d4cbd4e1434bd4aa2269145282c
f9b7dcbd841a0b3dd0fcd2f0941d498346f88599
/chrome/browser/previews/previews_lite_page_redirect_url_loader.h
9aeb9723cb9c707e551a8811db432129ab383d5d
[ "BSD-3-Clause" ]
permissive
browser-auto/chromium
58bace4173da259625cb3c4725f9d7ec6a4d2e03
36d524c252b60b059deaf7849fb6b082bee3018d
refs/heads/master
2022-11-16T12:38:05.031058
2019-11-18T12:28:56
2019-11-18T12:28:56
222,449,220
1
0
BSD-3-Clause
2019-11-18T12:55:08
2019-11-18T12:55:07
null
UTF-8
C++
false
false
7,671
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_PREVIEWS_PREVIEWS_LITE_PAGE_REDIRECT_URL_LOADER_H_ #define CHROME_BROWSER_PREVIEWS_PREVIEWS_LITE_PAGE_REDIRECT_URL_LOADER_H_ #include "base/callback.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" #include "base/optional.h" #include "base/sequence_checker.h" #include "chrome/browser/availability/availability_prober.h" #include "chrome/browser/previews/previews_lite_page_redirect_serving_url_loader.h" #include "content/public/browser/url_loader_request_interceptor.h" #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/system/data_pipe.h" #include "net/url_request/redirect_info.h" #include "services/network/public/cpp/resource_response.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/mojom/url_loader.mojom.h" class PrefService; namespace previews { using HandleRequest = base::OnceCallback<void( std::unique_ptr<PreviewsLitePageRedirectServingURLLoader> serving_url_loader, content::URLLoaderRequestInterceptor::RequestHandler handler)>; // A URL loader that attempts to fetch an HTTPS server lite page, and if // successful, redirects to the lite page URL, and hands the underlying // network URLLoader to a success callback. Currently, it supports serving the // Preview and falling back to default behavior. If enabled, the origin server // will be probed in parallel with the request to the lite page server and the // probe must complete successfully before the success callback is run. class PreviewsLitePageRedirectURLLoader : public network::mojom::URLLoader, public AvailabilityProber::Delegate { public: PreviewsLitePageRedirectURLLoader( content::BrowserContext* browser_context, const network::ResourceRequest& tentative_resource_request, HandleRequest callback); ~PreviewsLitePageRedirectURLLoader() override; // Creates and starts |serving_url_loader_|. |chrome_proxy_headers| are added // to the request, and the other parameters are used to start the network // service URLLoader. void StartRedirectToPreview( const net::HttpRequestHeaders& chrome_proxy_headers, const scoped_refptr<network::SharedURLLoaderFactory>& network_loader_factory, int frame_tree_node_id); // Creates a redirect to |original_url|. void StartRedirectToOriginalURL(const GURL& original_url); // AvailabilityProber::Delegate: bool ShouldSendNextProbe() override; bool IsResponseSuccess(net::Error net_error, const network::mojom::URLResponseHead* head, std::unique_ptr<std::string> body) override; private: // network::mojom::URLLoader: void FollowRedirect(const std::vector<std::string>& removed_headers, const net::HttpRequestHeaders& modified_headers, const base::Optional<GURL>& new_url) override; void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override; void PauseReadingBodyFromNet() override; void ResumeReadingBodyFromNet() override; // Processes |result|. Used as a callback for |serving_url_loader_|. // |redirect_info| and |response| should be present if and only if |result| is // kRedirect. void OnResultDetermined(ServingLoaderResult result, base::Optional<net::RedirectInfo> redirect_info, scoped_refptr<network::ResourceResponse> response); // Called when the lite page can be successfully served. void OnLitePageSuccess(); // Called when a non-200, non-307 response is received from the previews // server. void OnLitePageFallback(); // Called when a redirect (307) is received from the previews server. void OnLitePageRedirect(const net::RedirectInfo& redirect_info, const network::ResourceResponseHead& response_head); // The handler when trying to serve the lite page to the user. Serves a // redirect to the lite page server URL. void StartHandlingRedirectToModifiedRequest( const network::ResourceRequest& resource_request, mojo::PendingReceiver<network::mojom::URLLoader> receiver, mojo::PendingRemote<network::mojom::URLLoaderClient> client); // Helper method for setting up and serving |redirect_info| to |client|. void StartHandlingRedirect( const network::ResourceRequest& /* resource_request */, mojo::PendingReceiver<network::mojom::URLLoader> receiver, mojo::PendingRemote<network::mojom::URLLoaderClient> client); // Helper method to create redirect information to |redirect_url| and modify // |redirect_info_| and |modified_resource_request_|. void CreateRedirectInformation(const GURL& redirect_url); // Mojo error handling. Deletes |this|. void OnConnectionClosed(); // Checks that both the origin probe and the previews request have completed // before calling |OnLitePageSuccess|. void MaybeCallOnLitePageSuccess(); // A callback passed to |origin_connectivity_prober_| to notify the completion // of a probe. void OnOriginProbeComplete(bool success); // Starts the origin probe given the original page url. void StartOriginProbe(const GURL& original_url, const scoped_refptr<network::SharedURLLoaderFactory>& network_loader_factory); // The underlying URLLoader that speculatively tries to fetch the lite page. std::unique_ptr<PreviewsLitePageRedirectServingURLLoader> serving_url_loader_; // A copy of the initial resource request that has been modified to fetch // the lite page. network::ResourceRequest modified_resource_request_; // Stores the response when a 307 (redirect) is received from the previews // server. network::ResourceResponseHead response_head_; // Information about the redirect to the lite page server. net::RedirectInfo redirect_info_; // Called upon success or failure to let content/ know whether this class // intends to intercept the request. Must be passed a handler if this class // intends to intercept the request. HandleRequest callback_; // Binding to the URLLoader interface. mojo::Binding<network::mojom::URLLoader> binding_; // The owning client. Used for serving redirects. mojo::Remote<network::mojom::URLLoaderClient> client_; // A reference to the profile's prefs. May be null. PrefService* pref_service_; // Before a preview can be triggered, we must check that the origin site is // accessible on the network. This prober manages that check and is only set // while determining if a preview can be served. std::unique_ptr<AvailabilityProber> origin_connectivity_prober_; // Used to remember if the origin probe completes successfully before the // litepage request. bool origin_probe_finished_successfully_; // Used to remember if the lite page request completes successfully before the // origin probe. bool litepage_request_finished_successfully_; SEQUENCE_CHECKER(sequence_checker_); base::WeakPtrFactory<PreviewsLitePageRedirectURLLoader> weak_ptr_factory_{ this}; DISALLOW_COPY_AND_ASSIGN(PreviewsLitePageRedirectURLLoader); }; } // namespace previews #endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_LITE_PAGE_REDIRECT_URL_LOADER_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
7a7ff239daccea2a22173213d5b2a9a1c3a662d5
77170cbcd2c87952763f770d50abd2d8b671f9d2
/aws-cpp-sdk-iam/source/model/DeleteSigningCertificateRequest.cpp
d0dac44cce4de13dbfcf611fe7de15f1b2f1ce90
[ "JSON", "MIT", "Apache-2.0" ]
permissive
bittorrent/aws-sdk-cpp
795f1cdffb92f6fccb4396d8f885f7bf99829ce7
3f84fee22a0f4d5926aadf8d3303ea15a76421fd
refs/heads/master
2020-12-03T00:41:12.194688
2016-03-04T01:41:51
2016-03-04T01:41:51
53,150,048
1
1
null
2016-03-04T16:43:12
2016-03-04T16:43:12
null
UTF-8
C++
false
false
1,363
cpp
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/iam/model/DeleteSigningCertificateRequest.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> using namespace Aws::IAM::Model; using namespace Aws::Utils; DeleteSigningCertificateRequest::DeleteSigningCertificateRequest() : m_userNameHasBeenSet(false), m_certificateIdHasBeenSet(false) { } Aws::String DeleteSigningCertificateRequest::SerializePayload() const { Aws::StringStream ss; ss << "Action=DeleteSigningCertificate&"; if(m_userNameHasBeenSet) { ss << "UserName=" << StringUtils::URLEncode(m_userName.c_str()) << "&"; } if(m_certificateIdHasBeenSet) { ss << "CertificateId=" << StringUtils::URLEncode(m_certificateId.c_str()) << "&"; } ss << "Version=2010-05-08"; return ss.str(); }
[ "henso@amazon.com" ]
henso@amazon.com
9c59746fe70467526f55e963d0a3003cc4dfce42
1ea4c630f96531f184cf17a7873f44c4ff2530b7
/src/common/ColladaLoader.hh
6aaba719c9fd82c39474288acadccd41796d17cd
[ "Apache-2.0" ]
permissive
pinkedge/gazebo
90e5a223b0b3e028e8a8050f116ae070d0be3e45
fff0aa30b4b5748e43c2b0aa54ffcd366e9f042a
refs/heads/master
2022-04-03T09:49:13.953676
2012-05-24T13:23:36
2012-05-24T13:23:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,377
hh
/* * Copyright 2011 Nate Koenig & Andrew Howard * * 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 COLLADALOADER_HH #define COLLADALOADER_HH #include <map> #include <string> #include <vector> #include "common/MeshLoader.hh" #include "math/MathTypes.hh" class TiXmlElement; namespace gazebo { namespace common { class Material; /// \addtogroup gazebo_common Common /// \{ /// \brief Class used to load Collada mesh files class ColladaLoader : public MeshLoader { /// \brief Constructor public: ColladaLoader(); /// \brief Destructor public: virtual ~ColladaLoader(); /// \brief Load a mesh public: virtual Mesh *Load(const std::string &filename); private: void LoadController(TiXmlElement *_contrXml, TiXmlElement *_skelXml, const math::Matrix4 _transform, Mesh *_mesh); private: void LoadAnimations(TiXmlElement *_xml, Skeleton *_skel); private: void LoadAnimationSet(TiXmlElement *_xml, Skeleton *_skel); private: SkeletonNode* LoadSkeletonNodes(TiXmlElement *_xml, SkeletonNode *_parent); private: void SetSkeletonNodeTransform(TiXmlElement *_elem, SkeletonNode *_node); private: void LoadGeometry(TiXmlElement *_xml, const math::Matrix4 &_transform, Mesh *_mesh); private: TiXmlElement *GetElementId(TiXmlElement *_parent, const std::string &_name, const std::string &_id); private: TiXmlElement *GetElementId(const std::string &_name, const std::string &_id); private: void LoadNode(TiXmlElement *_elem, Mesh *_mesh, const math::Matrix4 &_transform); private: math::Matrix4 LoadNodeTransform(TiXmlElement *_elem); private: void LoadVertices(const std::string &_id, const math::Matrix4 &_transform, std::vector<math::Vector3> &_verts, std::vector<math::Vector3> &_norms); private: void LoadPositions(const std::string &_id, const math::Matrix4 &_transform, std::vector<math::Vector3> &_values); private: void LoadNormals(const std::string &_id, const math::Matrix4 &_transform, std::vector<math::Vector3> &_values); private: void LoadTexCoords(const std::string &_id, std::vector<math::Vector2d> &_values); private: Material *LoadMaterial(const std::string &_name); private: void LoadColorOrTexture(TiXmlElement *_elem, const std::string &_type, Material *_mat); private: void LoadTriangles(TiXmlElement *_trianglesXml, const math::Matrix4 &_transform, Mesh *_mesh); private: void LoadPolylist(TiXmlElement *_polylistXml, const math::Matrix4 &_transform, Mesh *_mesh); private: void LoadLines(TiXmlElement *_xml, const math::Matrix4 &_transform, Mesh *_mesh); private: void LoadScene(Mesh *_mesh); private: float LoadFloat(TiXmlElement *_elem); private: void LoadTransparent(TiXmlElement *_elem, Material *_mat); private: double meter; private: std::map<std::string, std::string> materialMap; private: TiXmlElement *colladaXml; private: std::string path; }; } } #endif
[ "natekoenig@gmail.com" ]
natekoenig@gmail.com
7d9b161788280d9daaff38e7f8232391ed581b20
f2c3250674d484b91dd9385d7fac50017b034e4b
/bzoj/1076.cpp
c4daa3e59443f2516a63052b51baf4bcc2a40e2b
[]
no_license
DQSSSSS/Algorithm-Competition-Code
a01d4e8b3a9b9da02a400eb5bb4e063eaade33c9
574a0806fadf1433fcb4fac4489a237c58daab3c
refs/heads/master
2023-01-06T06:17:12.295671
2020-11-11T22:44:41
2020-11-11T22:44:41
309,434,336
0
0
null
null
null
null
UTF-8
C++
false
false
1,045
cpp
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,LL> pii; const int SZ = 40010; const int INF = 1e9 + 10; LL read() { LL n = 0; char a = getchar(); bool flag = 0; while(a < '0' || a > '9') { if(a == '-') flag = 1; a = getchar(); } while(a >= '0' && a <= '9') n = n * 10 + a - '0',a = getchar(); if(flag) n = -n; return n; } int m,n; LL val[SZ]; int pre[SZ]; double f[110][SZ]; int main() { m = read(),n = read(); for(int i = 0;i < n;i ++) { val[i] = read(); int x; while(scanf("%d",&x) && x) pre[i] |= 1 << (x - 1); } for(int i = m;i >= 1;i --) for(int S = 0;S < (1 << n);S ++) { for(int j = 0;j < n;j ++) { if((pre[j] & S) == pre[j]) f[i][S] += max(f[i + 1][S],f[i + 1][S | (1 << j)] + val[j]); else f[i][S] += f[i + 1][S]; } f[i][S] /= n; } printf("%.6f\n",f[1][0]); return 0; }
[ "1053181679@qq.com" ]
1053181679@qq.com
1f329be30720a9eeea6f68ba3ac47ba7437e0b48
fbd889ee87d8b078198660f1340010c182b10a3a
/atcoder/abc149_a.cpp
906a9cf382222c32e037264a5c1adb56ef6a3cd9
[]
no_license
en30/online-judge
66760ad982d2437c0c15b7d5b1db87c8c86acee0
20443311f5a94dbfd468ef91c3383008e6f85a84
refs/heads/master
2022-04-09T18:41:50.015048
2020-04-01T17:04:25
2020-04-01T17:15:28
190,676,995
0
0
null
null
null
null
UTF-8
C++
false
false
141
cpp
#include <bits/stdc++.h> #include "../include/template" string S, T; int main() { cin >> S >> T; cout << T << S << endl; return 0; }
[ "en30.git@gmail.com" ]
en30.git@gmail.com
b4b77d84221dc578c3036e7583cf7128f74a3173
33eaafc0b1b10e1ae97a67981fe740234bc5d592
/tests/RandomSAT/z3-master/src/util/mpq_inf.h
b041b6d4fc9d0e955e57ff5e08438eba385aa533
[ "MIT" ]
permissive
akinanop/mvl-solver
6c21bec03422bb2366f146cb02e6bf916eea6dd0
bfcc5b243e43bddcc34aba9c34e67d820fc708c8
refs/heads/master
2021-01-16T23:30:46.413902
2021-01-10T16:53:23
2021-01-10T16:53:23
48,694,935
6
2
null
2016-08-30T10:47:25
2015-12-28T13:55:32
C++
UTF-8
C++
false
false
7,461
h
/*++ Copyright (c) 2006 Microsoft Corporation Module Name: mpq_inf.h Abstract: MPQ numbers with infinitesimals Author: Leonardo de Moura (leonardo) 2011-06-28 Revision History: --*/ #ifndef MPQ_INF_H_ #define MPQ_INF_H_ #include"mpq.h" #include"hash.h" typedef std::pair<mpq, mpq> mpq_inf; template<bool SYNCH = true> class mpq_inf_manager { mpq_manager<SYNCH> m; double m_inf; public: typedef mpq_inf numeral; mpq_inf_manager(double inf = 0.0001) { set_inf(inf); } void set_inf(double inf) { m_inf = inf; } enum inf_kind { NEG=-1, ZERO, POS }; void reset(mpq_inf & a) { m.reset(a.first); m.reset(a.second); } unsigned hash(mpq_inf const & a) const { return hash_u_u(m.hash(a.first), m.hash(a.second)); } void del(mpq_inf & a) { m.del(a.first); m.del(a.second); } void swap(mpq_inf & a, mpq_inf & b) { m.swap(a.first, b.first); m.swap(a.second, b.second); } void set(mpq_inf & a, mpq_inf const & b) { m.set(a.first, b.first); m.set(a.second, b.second); } void set(mpq_inf & a, mpq const & r) { m.set(a.first, r); m.reset(a.second); } void set(mpq_inf & a, mpq const & r, inf_kind k) { m.set(a.first, r); switch (k) { case NEG: m.set(a.second, -1); break; case ZERO: m.reset(a.second); break; case POS: m.set(a.second, 1); break; } } void set(mpq_inf & a, mpq const & r, mpq const & i) { m.set(a.first, r); m.set(a.second, i); } bool is_int(mpq_inf const & a) const { return m.is_int(a.first) && m.is_zero(a.second); } bool is_pos(mpq_inf const & a) const { return m.is_pos(a.first) || (m.is_zero(a.first) && m.is_pos(a.second)); } bool is_neg(mpq_inf const & a) const { return m.is_neg(a.first) || (m.is_zero(a.first) && m.is_neg(a.second)); } bool is_rational(mpq_inf const & a) const { return m.is_zero(a.second); } void get_rational(mpq_inf const & a, mpq & r) { m.set(r, a.first); } void get_infinitesimal(mpq_inf const & a, mpq & r) { m.set(r, a.second); } double get_double(mpq_inf const & a) { double r = m.get_double(a.first); if (m.is_pos(a.second)) return r + m_inf; else if (m.is_neg(a.second)) return r - m_inf; else return r; } bool is_zero(mpq_inf const & a) const { return m.is_zero(a.first) && m.is_zero(a.second); } bool eq(mpq_inf const & a, mpq_inf const & b) { return m.eq(a.first, b.first) && m.eq(a.second, b.second); } bool eq(mpq_inf const & a, mpq const & b) { return m.eq(a.first, b) && m.is_zero(a.second); } bool eq(mpq_inf const & a, mpq const & b, inf_kind k) { if (!m.eq(a.first, b)) return false; switch (k) { case NEG: return m.is_minus_one(a.second); case ZERO: return m.is_zero(a.second); case POS: return m.is_one(a.second); } UNREACHABLE(); return false; } bool lt(mpq_inf const & a, mpq_inf const & b) { return m.lt(a.first, b.first) || (m.lt(a.second, b.second) && m.eq(a.first, b.first)); } bool lt(mpq_inf const & a, mpq const & b) { return m.lt(a.first, b) || (m.is_neg(a.second) && m.eq(a.first, b)); } bool lt(mpq_inf const & a, mpq const & b, inf_kind k) { if (m.lt(a.first, b)) return true; if (m.eq(a.first, b)) { switch (k) { case NEG: return m.lt(a.second, mpq(-1)); case ZERO: return m.is_neg(a.second); case POS: return m.lt(a.second, mpq(1)); } UNREACHABLE(); } return false; } bool gt(mpq_inf const & a, mpq_inf const & b) { return lt(b, a); } bool gt(mpq_inf const & a, mpq const & b) { return m.gt(a.first, b) || (m.is_pos(a.second) && m.eq(a.first, b)); } bool gt(mpq_inf const & a, mpq const & b, inf_kind k) { if (m.gt(a.first, b)) return true; if (m.eq(a.first, b)) { switch (k) { case NEG: return m.gt(a.second, mpq(-1)); case ZERO: return m.is_pos(a.second); case POS: return m.gt(a.second, mpq(1)); } UNREACHABLE(); } return false; } bool le(mpq_inf const & a, mpq_inf const & b) { return !gt(a, b); } bool le(mpq_inf const & a, mpq const & b) { return !gt(a, b); } bool le(mpq_inf const & a, mpq const & b, inf_kind k) { return !gt(a, b, k); } bool ge(mpq_inf const & a, mpq_inf const & b) { return !lt(a, b); } bool ge(mpq_inf const & a, mpq const & b) { return !lt(a, b); } bool ge(mpq_inf const & a, mpq const & b, inf_kind k) { return !lt(a, b, k); } void add(mpq_inf const & a, mpq_inf const & b, mpq_inf & c) { m.add(a.first, b.first, c.first); m.add(a.second, b.second, c.second); } void sub(mpq_inf const & a, mpq_inf const & b, mpq_inf & c) { m.sub(a.first, b.first, c.first); m.sub(a.second, b.second, c.second); } void add(mpq_inf const & a, mpq const & b, mpq_inf & c) { m.add(a.first, b, c.first); m.set(c.second, a.second); } void sub(mpq_inf const & a, mpq const & b, mpq_inf & c) { m.sub(a.first, b, c.first); m.set(c.second, a.second); } void mul(mpq_inf const & a, mpq const & b, mpq_inf & c) { m.mul(a.first, b, c.first); m.mul(a.second, b, c.second); } void mul(mpq_inf const & a, mpz const & b, mpq_inf & c) { m.mul(b, a.first, c.first); m.mul(b, a.second, c.second); } void div(mpq_inf const & a, mpq const & b, mpq_inf & c) { m.div(a.first, b, c.first); m.div(a.second, b, c.second); } void div(mpq_inf const & a, mpz const & b, mpq_inf & c) { m.div(a.first, b, c.first); m.div(a.second, b, c.second); } void inc(mpq_inf & a) { m.inc(a.first); } void dec(mpq_inf & a) { m.dec(a.first); } void neg(mpq_inf & a) { m.neg(a.first); m.neg(a.second); } void abs(mpq_inf & a) { if (is_neg(a)) { neg(a); } } void ceil(mpq_inf const & a, mpq & b) { if (m.is_int(a.first)) { // special cases for k - delta*epsilon where k is an integer if (m.is_pos(a.second)) m.add(a.first, mpq(1), b); // ceil(k + delta*epsilon) --> k+1 else m.set(b, a.first); } else { m.ceil(a.first, b); } } void floor(mpq_inf const & a, mpq & b) { if (m.is_int(a.first)) { if (m.is_neg(a.first)) m.sub(a.first, mpq(1), b); // floor(k - delta*epsilon) --> k-1 else m.set(b, a.first); } else { m.floor(a.first, b); } } std::string to_string(mpq_inf const & a); void display(std::ostream & out, mpq_inf const & a) { out << to_string(a); } mpq_manager<SYNCH>& get_mpq_manager() { return m; } }; typedef mpq_inf_manager<true> synch_mpq_inf_manager; typedef mpq_inf_manager<false> unsynch_mpq_inf_manager; #endif
[ "nikaponens@gmail.com" ]
nikaponens@gmail.com
3a319b97a02183163424f7d80534190f85e711cf
83377f3f59e04003563a003d23c4279d59f377e0
/Project/MainWindow/cell.cpp
636532cb4a794bd3fd240d8cf56f5b2375e4e32b
[]
no_license
lingdan2008/Qt
5b934ba72032bea0b6521f27f64a17383501287b
eb45fac59b5b2c8ce78fc69e715739fd5d5a162e
refs/heads/master
2022-01-06T12:05:38.966965
2018-09-08T07:22:49
2018-09-08T07:22:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,007
cpp
#include "cell.h" Cell::Cell() { setDirty(); } QTableWidgetItem* Cell::clone() const { return new Cell(*this); } void Cell::setData(int role, const QVariant& value) { QTableWidgetItem::setData(role, value); if (role == Qt::EditRole) { this->setDirty(); } } QVariant Cell::data(int role) const { if (role == Qt::DisplayRole) { if (value().isValid()) { return value().toString(); } else { return "####"; } } else if (role == Qt::TextAlignmentRole) { if (value().type() == QVariant::String) { return int(Qt::AlignLeft | Qt::AlignVCenter); } else { return int(Qt::AlignRight | Qt::AlignVCenter); } } else { return QTableWidgetItem::data(role); } } void Cell::setFormula(const QString& formula) { setData(Qt::EditRole, formula); } QString Cell::formula() const { return data(Qt::EditRole).toString(); } void Cell::setDirty() { cacheIsDirty = true; } const QVariant Invalid; QVariant Cell::value() const { if (cacheIsDirty) { cacheIsDirty = false; QString formulaStr = formula(); if (formulaStr.startsWith('\'')) { cachedValue = formulaStr.mid(1); } else if (formulaStr.startsWith('=')) { cachedValue = Invalid; QString expr = formulaStr.mid(1); expr.replace(" ", ""); expr.append(QChar::Null); int pos = 0; cachedValue = evalExpression(expr, pos); if (expr[pos] != QChar::Null) { cachedValue = Invalid; } } else { bool ok; double d = formulaStr.toDouble(&ok); if (ok) { cachedValue = d; } else { cachedValue = formulaStr; } } } return cachedValue; } QVariant Cell::evalExpression(const QString& str, int& pos) const { QVariant result = evalTerm(str, pos); while (str[pos] != QChar::Null) { QChar op = str[pos]; if (op != '+' && op != '-') { return result; } ++pos; QVariant term = evalTerm(str, pos); if (result.type() == QVariant::Double && term.type() == QVariant::Double) { if (op == '+') { result = result.toDouble() + term.toDouble(); } else { result = result.toDouble() - term.toDouble(); } } else { result = Invalid; } } return result; } QVariant Cell::evalTerm(const QString& str, int& pos) const { QVariant result = evalFactor(str, pos); while (str[pos] != QChar::Null) { QChar op = str[pos]; if (op != '*' && op != '/') { return result; } ++pos; QVariant factor = evalFactor(str, pos); if (result.type() == QVariant::Double && factor.type() == QVariant::Double) { if (op == '*') { result = result.toDouble() * factor.toDouble(); } else { if (factor.toDouble() == 0.0) { result = Invalid; } else { result = result.toDouble() / factor.toDouble(); } } } else { result = Invalid; } } return result; } QVariant Cell::evalFactor(const QString& str, int& pos) const { QVariant result; bool negative = false; if (str[pos] == '-') { negative = true; ++pos; } if (str[pos] == '(') { ++pos; result = evalExpression(str, pos); if (str[pos] != ')') result = Invalid; ++pos; } else { QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}"); QString token; while (str[pos].isLetterOrNumber() || str[pos] == '.') { token += str[pos]; ++pos; } if (regExp.exactMatch(token)) { int column = token[0].toUpper().unicode() - 'A'; int row = token.mid(1).toInt() - 1; Cell* c = static_cast<Cell*>(tableWidget()->item(row, column)); if (c) { result = c->value(); } else { result = 0.0; } } else { bool ok; result = token.toDouble(&ok); if (!ok) result = Invalid; } } if (negative) { if (result.type() == QVariant::Double) { result = -result.toDouble(); } else { result = Invalid; } } return result; }
[ "xiaohaijin@outlook.com" ]
xiaohaijin@outlook.com
661fc00aff48774f862bf93d1a270662ab7aaf0c
bb2e62cdd1c59ab68b0797b206df70ba4ec1465d
/binary_tree/mirrorTree.cpp
b56f15597e6edc1e5158b079fde16d10da17fd01
[]
no_license
Muzain187/level3
4bc2058cb124d0b31f7e42eaa7109d017c0444de
68cd66ca4d9931af3ae83220fe6ec5f3fe2d2b5e
refs/heads/main
2023-08-04T18:24:03.376536
2021-09-20T16:50:37
2021-09-20T16:50:37
405,149,801
0
0
null
null
null
null
UTF-8
C++
false
false
723
cpp
/********************************************************** Following is the Binary Tree Node class structure template <typename T> class BinaryTreeNode { public : T data; BinaryTreeNode<T> *left; BinaryTreeNode<T> *right; BinaryTreeNode(T data) { this -> data = data; left = NULL; right = NULL; } }; ***********************************************************/ void mirrorBinaryTree(BinaryTreeNode<int>* root) { // Write your code here if(root == NULL) return; mirrorBinaryTree(root->left); mirrorBinaryTree(root->right); BinaryTreeNode<int>* temp = root->right; root->right = root->left; root->left = temp; }
[ "muzain.ashraf@gmail.com" ]
muzain.ashraf@gmail.com
026dab0f53b5961d4ef9de779f070c1735f820c9
93cdf00e1dc718851d96fe9bbc51d972b72c26bd
/src/Protocol/DataPackageFactory.cpp
f2e230a5604c3f616285547997a5981dccc57c14
[]
no_license
ptryfon/loxim-stats
74e3310b46c7d61d01cc2ace9fee05a1287faf5b
d1048f3b348052186a962b9ab03596684024b7a9
refs/heads/master
2016-08-04T14:39:13.645024
2010-03-11T22:48:12
2010-03-11T22:48:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,568
cpp
/* This file is generated by lw_protogen. DO NOT EDIT.*/ #include <memory> #include <Protocol/Exceptions.h> #include <Protocol/DataPackageFactory.h> #include <Protocol/Enums/Enums.h> #include <Protocol/Packages/Data/BagPackage.h> #include <Protocol/Packages/Data/BindingPackage.h> #include <Protocol/Packages/Data/BobPackage.h> #include <Protocol/Packages/Data/BoolPackage.h> #include <Protocol/Packages/Data/DatePackage.h> #include <Protocol/Packages/Data/DatetimePackage.h> #include <Protocol/Packages/Data/DatetimetzPackage.h> #include <Protocol/Packages/Data/DoublePackage.h> #include <Protocol/Packages/Data/ExternalRefPackage.h> #include <Protocol/Packages/Data/LinkPackage.h> #include <Protocol/Packages/Data/RefPackage.h> #include <Protocol/Packages/Data/SequencePackage.h> #include <Protocol/Packages/Data/Sint16Package.h> #include <Protocol/Packages/Data/Sint32Package.h> #include <Protocol/Packages/Data/Sint64Package.h> #include <Protocol/Packages/Data/Sint8Package.h> #include <Protocol/Packages/Data/StructPackage.h> #include <Protocol/Packages/Data/TimePackage.h> #include <Protocol/Packages/Data/TimetzPackage.h> #include <Protocol/Packages/Data/Uint16Package.h> #include <Protocol/Packages/Data/Uint32Package.h> #include <Protocol/Packages/Data/Uint64Package.h> #include <Protocol/Packages/Data/Uint8Package.h> #include <Protocol/Packages/Data/VarcharPackage.h> #include <Protocol/Packages/Data/VoidPackage.h> #include <Protocol/Packages/WCHelloPackage.h> namespace Protocol{ std::auto_ptr<Package> DataPackageFactory::deserialize(const sigset_t &mask, const bool &cancel, uint8_t id, size_t &length, DataStream &stream) { switch (id) { case BAG_PACKAGE: return std::auto_ptr<Package>(new BagPackage(mask, cancel, length, stream)); case BINDING_PACKAGE: return std::auto_ptr<Package>(new BindingPackage(mask, cancel, length, stream)); case BOB_PACKAGE: return std::auto_ptr<Package>(new BobPackage(mask, cancel, length, stream)); case BOOL_PACKAGE: return std::auto_ptr<Package>(new BoolPackage(mask, cancel, length, stream)); case DATE_PACKAGE: return std::auto_ptr<Package>(new DatePackage(mask, cancel, length, stream)); case DATETIME_PACKAGE: return std::auto_ptr<Package>(new DatetimePackage(mask, cancel, length, stream)); case DATETIMETZ_PACKAGE: return std::auto_ptr<Package>(new DatetimetzPackage(mask, cancel, length, stream)); case DOUBLE_PACKAGE: return std::auto_ptr<Package>(new DoublePackage(mask, cancel, length, stream)); case EXTERNAL_REF_PACKAGE: return std::auto_ptr<Package>(new ExternalRefPackage(mask, cancel, length, stream)); case LINK_PACKAGE: return std::auto_ptr<Package>(new LinkPackage(mask, cancel, length, stream)); case REF_PACKAGE: return std::auto_ptr<Package>(new RefPackage(mask, cancel, length, stream)); case SEQUENCE_PACKAGE: return std::auto_ptr<Package>(new SequencePackage(mask, cancel, length, stream)); case SINT16_PACKAGE: return std::auto_ptr<Package>(new Sint16Package(mask, cancel, length, stream)); case SINT32_PACKAGE: return std::auto_ptr<Package>(new Sint32Package(mask, cancel, length, stream)); case SINT64_PACKAGE: return std::auto_ptr<Package>(new Sint64Package(mask, cancel, length, stream)); case SINT8_PACKAGE: return std::auto_ptr<Package>(new Sint8Package(mask, cancel, length, stream)); case STRUCT_PACKAGE: return std::auto_ptr<Package>(new StructPackage(mask, cancel, length, stream)); case TIME_PACKAGE: return std::auto_ptr<Package>(new TimePackage(mask, cancel, length, stream)); case TIMETZ_PACKAGE: return std::auto_ptr<Package>(new TimetzPackage(mask, cancel, length, stream)); case UINT16_PACKAGE: return std::auto_ptr<Package>(new Uint16Package(mask, cancel, length, stream)); case UINT32_PACKAGE: return std::auto_ptr<Package>(new Uint32Package(mask, cancel, length, stream)); case UINT64_PACKAGE: return std::auto_ptr<Package>(new Uint64Package(mask, cancel, length, stream)); case UINT8_PACKAGE: return std::auto_ptr<Package>(new Uint8Package(mask, cancel, length, stream)); case VARCHAR_PACKAGE: return std::auto_ptr<Package>(new VarcharPackage(mask, cancel, length, stream)); case VOID_PACKAGE: return std::auto_ptr<Package>(new VoidPackage(mask, cancel, length, stream)); default:throw ProtocolLogic(); } } std::auto_ptr<Package> DataPackageFactory::deserialize_unknown(const sigset_t &mask, const bool &cancel, size_t &length, DataStream &stream) { uint8_t id = stream.read_uint8(mask, cancel, length); return deserialize(mask, cancel, id, length, stream); } }
[ "siersciu@5ea2a027-5d39-4ba5-8bbd-4152af6b93f1" ]
siersciu@5ea2a027-5d39-4ba5-8bbd-4152af6b93f1
2100045869c25ae18d7713e58bb93adefdb6cdd8
51dfa01dc557abe17e4c2e3e5950a5212d82df1a
/PL0/PL0.h
da24a1b267dcf0a5e499be4eb0f5a60be8d5e7de
[]
no_license
asdlei99/PL0-Cpp
000d0f2d3c746b796f7a2c6686cb92228acc54d1
f41f0ecd28da09133901f822674679af013a90e8
refs/heads/master
2021-01-03T00:17:02.986996
2019-12-26T03:07:01
2019-12-26T03:07:01
null
0
0
null
null
null
null
GB18030
C++
false
false
495
h
#pragma once #include "PL0_WordParser.h" #include "PL0_ProgramParser.h" #include "PL0_VirtualMachine.h" #include "PL0_ErrorMsg.h" #ifdef _WIN64 #error "x64 is unsupported! Switch back to x86." #endif namespace PL0 { // 输出错误信息 void OutputErrorInfos(const std::string& content, const std::vector<ErrorInfo>& errorInfos); // 输出符号集 void OutputSymbols(const std::vector<Symbol>& symbols); // 输出程序信息 void OutputProgramInfo(const ProgramInfo& programInfo); }
[ "757919340@qq.com" ]
757919340@qq.com
9fe3a1fcd4d4ff3b4631a9ab571435d364115803
fe9d8bfa9ac64f321c3815f32b216710d42f5d94
/Src/DebugPage/UdpDebug/SAKUdpDeviceController.hh
09b1ab04ed6e86124ddbc0d9890a156c88aa4d03
[]
no_license
xibeilang524/QtSwissArmyKnife
4f42cd6d0f006fbbb61d64a1ae6f40b31d06b3c6
e0b6481c29548eff369e2e584bdd6796f628bf26
refs/heads/master
2020-08-19T15:09:27.352621
2019-10-15T17:00:23
2019-10-15T17:00:23
215,929,703
1
0
null
2019-10-18T02:58:32
2019-10-18T02:58:32
null
UTF-8
C++
false
false
1,395
hh
/* * Copyright (C) 2018-2019 wuuhii. All rights reserved. * * The file is encoding with utf-8 (with BOM). It is a part of QtSwissArmyKnife * project. The project is a open source project, you can get the source from: * https://github.com/wuuhii/QtSwissArmyKnife * https://gitee.com/wuuhii/QtSwissArmyKnife * * If you want to know more about the project, please join our QQ group(952218522). * In addition, the email address of the project author is wuuhii@outlook.com. * Welcome to bother. * * I write the comment in English, it's not because that I'm good at English, * but for "installing B". */ #ifndef SAKUDPDEVICECONTROLLER_HH #define SAKUDPDEVICECONTROLLER_HH #include <QWidget> #include <QCheckBox> #include <QComboBox> namespace Ui { class SAKUdpDeviceController; } class SAKUdpDeviceController:public QWidget { Q_OBJECT public: SAKUdpDeviceController(QWidget *parent = Q_NULLPTR); ~SAKUdpDeviceController(); QString localHost(); quint16 localPort(); QString targetHost(); quint16 targetPort(); bool enableCustomLocalSetting(); void refresh(); void setUiEnable(bool enable); private: Ui::SAKUdpDeviceController *ui; QComboBox *localhostComboBox; QLineEdit *localPortlineEdit; QCheckBox *enableLocalSettingCheckBox; QLineEdit *targetHostLineEdit; QLineEdit *targetPortLineEdit; }; #endif
[ "wuuhii@outlook.com" ]
wuuhii@outlook.com
1502bed2ec4b9e878ad27503f99d3c7eeac6c54c
1d3aeb778082aefdb800a4bb134e838b90e26d21
/z/152_maximum_product_subarray.cc
2568b744b7400daa9da500bf025fb85289f98c57
[]
no_license
Uranusz/leetcode
56b7942a5740cd37c5befe0fd10fd22b0bb7c808
52123452c64855b91a1fa222187a90e1edc86efc
refs/heads/master
2020-12-24T15:49:55.625399
2016-04-16T02:46:44
2016-04-16T02:46:44
42,388,221
0
1
null
2016-01-13T03:10:37
2015-09-13T07:59:49
C++
UTF-8
C++
false
false
2,471
cc
/* * ===================================================================================== * * Filename: 152_maximum_prodect_subarray.cc * * Description: * * Version: 1.0 * Created: 01/05/2016 09:53:27 PM * Revision: none * Compiler: gcc * * Author: YOUR NAME (), * Organization: * * ===================================================================================== */ #include <vector> #include <iostream> using namespace std; /* * ===================================================================================== * Class: Solution * Description: check 3 use cases to find the rule * 1. array with only 1 negative number * 2. array with 2 negative number * 2. array with 3 negative number * ===================================================================================== */ class Solution { public: /*----------------------------------------------------------------------------- * use DP. Construct subarray, it always contains the rightmost element in the * sub problem; *-----------------------------------------------------------------------------*/ int maxProduct(vector<int>& nums) { if (nums.size() == 0) return -1; int currentMax = 1, currentMin = 1; int result = nums[0]; for (vector<int>::iterator it = nums.begin(); it != nums.end(); ++it) { int tmp = currentMin; currentMin = min(*it, min(currentMin * (*it), currentMax * (*it))); currentMax = max(*it, max(tmp * (*it), currentMax * (*it))); result = max(result, currentMax); } return result; } }; /* ----- end of class Solution ----- */ /* * === FUNCTION ====================================================================== * Name: main * Description: * ===================================================================================== */ int main(int argc, char* argv[]) { vector<int> v; v.push_back(2); v.push_back(2); v.push_back(2); v.push_back(2); v.push_back(-3); v.push_back(2); v.push_back(2); v.push_back(2); v.push_back(2); v.push_back(2); cout << Solution().maxProduct(v) << endl; return EXIT_SUCCESS; } /* ---------- end of function main ---------- */
[ "uranus.superz@outlook.com" ]
uranus.superz@outlook.com
05ac006cd46e56b5da8f94b9605cd01994222780
1edef7d16cac066fdd84857db7deb42d5ef62f05
/teos_lib/command/teos_wallet_commands.cpp
b8f12bc1210261456e8d369debcf33d59fd8dd3f
[]
no_license
eosasia/eosfactory
2af3fcf81d5487b157c675f382f48907df7d2078
8b7e9e0559a958b09bc026e021fba23b1894e12f
refs/heads/master
2020-03-16T21:39:51.110022
2018-05-11T07:32:01
2018-05-11T07:32:01
133,009,009
3
2
null
2018-05-11T08:01:12
2018-05-11T08:01:12
null
UTF-8
C++
false
false
669
cpp
#include <teoslib/command/wallet_commands.hpp> const char* walletSubcommands = R"( ERROR: RequiredError: Subcommand required Interact with local wallet Usage : . / teos [OPTIONS] wallet SUBCOMMAND [OPTIONS] Subcommands: create Create a new wallet locally open Open an existing wallet lock Lock wallet lock_all Lock all unlocked wallets unlock Unlock wallet import Import private key into wallet list List opened wallets, *= unlocked keys List of private keys from all unlocked wallets in wif format. )"; const std::string walletCommandPath = "/v1/wallet/";
[ "stefan.zarembinski@gmail.com" ]
stefan.zarembinski@gmail.com
1e8b594e770e1c274ed2e20c37b1e0728d4514d4
f08b7dc508ff0d2b844c8380b7a33cf14bedb2ab
/crucesemaforos.ino
275e4d89a81c9751888c459bd69c0a413f5834eb
[]
no_license
SynysterGrowly/crucedesemaforo
023acb416d7f990120ad6ffd447364f012a0bba5
0ad7c71cdf4b664e13e67fa99dd3cd18dbf05bb7
refs/heads/master
2021-01-21T11:23:27.601145
2017-03-01T14:50:00
2017-03-01T14:50:00
83,565,135
0
0
null
null
null
null
UTF-8
C++
false
false
2,662
ino
/* Programa para un par de semaforos que cambian de uno a otro, y la implementacin de un boton para terminar el tiempo de la luz verde y pasar al otro. ****************************************************************** ***ALUMNOS DE 8VO CARRERA INGENIERIA EN SISTEMAS COMPUTACIONALES***** *************UNIVERSIDAD DEL SUR CANCUN, QUINTANA ROO************ ******************************************************************** */ // Declaramos la variable para el pin del boton const int button = 8; void setup() { // Con un ciclo activamos los pines del 2 al 7 como salidas for (int pin = 2; pin <= 7; pin++) { pinMode(pin, OUTPUT); } // El pin del boton lo ponemos como entrada pinMode(button, INPUT); } // Funcion para el primer semaforo y sus cambios de estado void semaphoreOne() { digitalWrite(2, HIGH); int count = 0; while (count < 30) { // El ciclo esta en espera mientras el boton no es presionado if (digitalRead(button) == true) { break; } count++; delay(200); } digitalWrite(2, LOW); delay(500); digitalWrite(2, HIGH); delay(500); digitalWrite(2, LOW); delay(500); digitalWrite(2, HIGH); delay(500); digitalWrite(2, LOW); delay(500); digitalWrite(2, HIGH); delay(500); digitalWrite(2, LOW); delay(500); digitalWrite(2, HIGH); delay(500); digitalWrite(2, LOW); digitalWrite(3, HIGH); delay(2500); digitalWrite(3, LOW); digitalWrite(4, HIGH); digitalWrite(7, LOW); // Mandamos a llamar al otro semaforo semaphoreTwo(); } // Funcion para el segundo semaforo y sus cambios de estado void semaphoreTwo() { digitalWrite(5, HIGH); int count = 0; while (count < 30) { if (digitalRead(button) == true) { break; } count++; delay(200); } digitalWrite(5, LOW); delay(500); digitalWrite(5, HIGH); delay(500); digitalWrite(5, LOW); delay(500); digitalWrite(5, HIGH); delay(500); digitalWrite(5, LOW); delay(500); digitalWrite(5, HIGH); delay(500); digitalWrite(5, LOW); delay(500); digitalWrite(5, HIGH); delay(500); digitalWrite(5, LOW); digitalWrite(6, HIGH); delay(2500); digitalWrite(6, LOW); digitalWrite(7, HIGH); digitalWrite(4, LOW); // Mandamos a llamar al otro semaforo semaphoreOne(); } // Iniciamos nuestro semaforo void loop() { // Cambiamos el estado de todos los leds para // que esten apagados todos al inicio for (int pin = 2; pin <= 7; pin++) { digitalWrite(pin, LOW); } // Prendemos el verde de un semaforo y el // rojo del otro semaforo digitalWrite(2, HIGH); digitalWrite(7, HIGH); // Iniciamos el primer semaforo semaphoreOne(); }
[ "carlos1204mex@gmail.com" ]
carlos1204mex@gmail.com
a261f13616feb92295f18499e44b63d954e5e1b8
dc94fe3a0770730dafd8cae7abf855f092155446
/StringToIntConverter.cpp
d60bb37f9b3657c4b835b7bfdaaec6f5ae12537b
[]
no_license
bartekw2213/B-Tree
9e1803a48ad059720b500a8911076a60a2fef4c8
24d6e8763633a33877ce84e4a4858a8d098cf12b
refs/heads/main
2023-06-06T13:14:20.434013
2021-06-24T12:54:53
2021-06-24T12:54:53
363,127,914
0
0
null
null
null
null
UTF-8
C++
false
false
482
cpp
#include "StringToIntConvereter.h" void StringToIntConverter::AddInt(const char newInt) { if(length == capacity) Resize(); string[length++] = newInt; string[length] = '\0'; } int StringToIntConverter::GetInt() { length = 0; return atoi(string); } void StringToIntConverter::Resize() { char* temp = new char[capacity*2]; for(int i = 0; i <= length; i++) temp[i] = string[i]; delete[] string; string = temp; capacity *= 2; }
[ "bartekw2213@gmail.com" ]
bartekw2213@gmail.com
e6c32bbea3b2305945455f85936208148aaf8fa5
21d8be0e44fef51f610d47ac163bea99c5c3e013
/arduino_6502.ino
831261d469dfedfbf531b4c1cd55b8d83551518b
[]
no_license
pingumacpenguin/STM32duino-6502-Emulator
078c68e304a6101607c95addb3731ee7de705942
742ad35eb7e04555029d2c933ff6bf07ed913251
refs/heads/master
2021-01-10T22:06:42.198338
2015-08-07T08:27:00
2015-08-07T08:27:00
39,225,227
10
2
null
null
null
null
UTF-8
C++
false
false
1,214
ino
#define BLINK_PIN PB0 uint8_t curkey = 0; // Create USB serial_debug port USBSerial serial_debug; extern "C" { uint16_t getpc(); uint8_t getop(); void exec6502(int32_t tickcount); void reset6502(); void serout(uint8_t val) { serial_debug.write(val); } uint8_t getkey() { //DEBUG // serial_debug.print(curkey); return(curkey); } void clearkey() { curkey = 0; } void printhex(uint16_t val) { serial_debug.print(val, HEX); serial_debug.println(); } } void setup () { /* // Flash the LED 3 times to prove we rebooted. pinMode(BLINK_PIN, OUTPUT); for ( int i = 0; i = 2 ; i++) { digitalWrite(BLINK_PIN, LOW); delay(1000); digitalWrite(BLINK_PIN, HIGH); delay(1000); } digitalWrite(BLINK_PIN, LOW); */ serial_debug.begin (9600); serial_debug.println (); reset6502(); } void loop () { exec6502(100); //if timing is enabled, this value is in 6502 clock ticks. otherwise, simply instruction count. if (serial_debug.available()) { // curkey = serial_debug.read() & 0x7F; curkey = serial_debug.read() ; //digitalWrite(BLINK_PIN, LOW); //delayMicroseconds(100); //digitalWrite(BLINK_PIN, HIGH); } }
[ "ahull@ibahn.com" ]
ahull@ibahn.com
a8c99b58a11c506282e67f01727091104e416d96
bd641e0ac3c355217cdac5d319bb84fead9f0d61
/source/KingKong.WidescreenFix/dllmain.cpp
b77d40682a4201edcfae2c4b80cf6250d129679c
[ "MIT" ]
permissive
Ivalaostia/WidescreenFixesPack
672a02bfe954cc2b31511f7291e395b273c84dce
4644660e99f097cc3f74e3e75129dbed1b3ffc29
refs/heads/master
2020-05-18T14:31:39.674845
2017-03-07T18:39:59
2017-03-07T18:39:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,728
cpp
#include "stdafx.h" #include <string> HWND hWnd; bool bDelay; bool bSettingsApp; uintptr_t pBarsPtr; uintptr_t pBarsJmp; struct Screen { int32_t Width; int32_t Height; float fWidth; float fHeight; float fFieldOfView; float fAspectRatio; float fCustomAspectRatioHor; float fCustomAspectRatioVer; int32_t Width43; float fWidth43; float fHudScale; float fHudOffset; float fCutOffArea; float fFMVScale; } Screen; void __declspec(naked) BarsHook() { __asm pushad if (*(uint32_t*)((*(uintptr_t*)pBarsPtr) + 0xCC) == 3) { __asm popad __asm jmp pBarsJmp } else { __asm popad __asm retn 0x0C } } DWORD WINAPI InitSettings(LPVOID) { auto pattern = hook::pattern("75 66 8D 4C 24 04 51"); if (pattern.size() > 0) { bSettingsApp = true; pattern = hook::pattern("75 66 8D 4C 24 04 51"); injector::MakeNOP(pattern.get(0).get<uintptr_t>(0), 2, true); //0x40BD3F pattern = hook::pattern("75 39 83 7C 24 08 01 75 32 8B"); //0x40BD6C struct RegHook { void operator()(injector::reg_pack& regs) { regs.ecx = *(uint32_t*)(regs.esp + 0x118); regs.edx = (regs.esp + 0x0C); GetModuleFileName(NULL, (char*)regs.edx, MAX_PATH); *(strrchr((char*)regs.edx, '\\') + 1) = '\0'; } }; injector::MakeInline<RegHook>(pattern.get(0).get<uintptr_t>(0), pattern.get(0).get<uintptr_t>(20)); } return 0; } DWORD WINAPI Init(LPVOID) { if (bSettingsApp) return 0; auto pattern = hook::pattern("33 DB 89 5D E0 53"); if (!(pattern.size() > 0) && !bDelay) { bDelay = true; CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&Init, NULL, 0, NULL); return 0; } if (bDelay) { while (!(pattern.size() > 0)) pattern = hook::pattern("33 DB 89 5D E0 53"); } CIniReader iniReader(""); static bool bCustomAR; char *szForceAspectRatio = iniReader.ReadString("MAIN", "ForceAspectRatio", "auto"); static bool bFullscreenFMVs = iniReader.ReadInteger("MAIN", "FullscreenFMVs", 1) != 0; static float fMouseSensitivityFactor = iniReader.ReadFloat("MAIN", "MouseSensitivityFactor", 0.0f); static float fFOVFactor = iniReader.ReadFloat("MAIN", "FOVFactor", 0.0f); if (strncmp(szForceAspectRatio, "auto", 4) != 0) { Screen.fCustomAspectRatioHor = static_cast<float>(std::stoi(szForceAspectRatio)); Screen.fCustomAspectRatioVer = static_cast<float>(std::stoi(strchr(szForceAspectRatio, ':') + 1)); bCustomAR = true; } pattern = hook::pattern("89 86 BC 02 00 00 89 8E C0 02 00 00 89 96 C4 02 00 00"); //0x9F2161 struct ResHook { void operator()(injector::reg_pack& regs) { Screen.Width = regs.eax; Screen.Height = regs.ecx; *(uint32_t*)(regs.esi + 0x2BC) = Screen.Width; *(uint32_t*)(regs.esi + 0x2C0) = Screen.Height; *(uint32_t*)(regs.esi + 0x2C4) = regs.edx; Screen.fWidth = static_cast<float>(Screen.Width); Screen.fHeight = static_cast<float>(Screen.Height); Screen.fAspectRatio = Screen.fWidth / Screen.fHeight; Screen.Width43 = static_cast<uint32_t>(Screen.fHeight * (4.0f / 3.0f)); Screen.fWidth43 = static_cast<float>(Screen.Width43); Screen.fHudOffset = (1.0f / (Screen.fHeight * (4.0f / 3.0f))) * ((Screen.fWidth - Screen.fHeight * (4.0f / 3.0f)) / 2.0f); Screen.fHudScale = Screen.fHeight / Screen.fWidth; Screen.fFieldOfView = 1.0f * (((4.0f / 3.0f)) / (Screen.fAspectRatio)); Screen.fCutOffArea = 0.5f / Screen.fFieldOfView; Screen.fFMVScale = 1.0f / (((4.0f / 3.0f)) / (Screen.fAspectRatio)); if (bCustomAR) { Screen.fAspectRatio = Screen.fCustomAspectRatioHor / Screen.fCustomAspectRatioVer; Screen.fHudScale = Screen.fCustomAspectRatioVer / Screen.fCustomAspectRatioHor; Screen.fFieldOfView = 1.0f * (((4.0f / 3.0f)) / (Screen.fAspectRatio)); Screen.fCutOffArea = 0.5f / Screen.fFieldOfView; } if (fFOVFactor) { Screen.fFieldOfView /= fFOVFactor; Screen.fCutOffArea = 0.5f / Screen.fFieldOfView; } } }; injector::MakeInline<ResHook>(pattern.get(0).get<uintptr_t>(0), pattern.get(0).get<uintptr_t>(18)); char pattern_str[20]; union { uint32_t* Int; unsigned char Byte[4]; } dword_temp; dword_temp.Int = *hook::pattern("D9 04 8D ? ? ? ? D9 5C 24 18 EB 0A").get(0).get<uint32_t*>(3); sprintf(pattern_str, "%02X %02X %c %02X %02X %02X %02X", 0xD9, 0x04, '?', dword_temp.Byte[0], dword_temp.Byte[1], dword_temp.Byte[2], dword_temp.Byte[3]); pattern = hook::pattern(pattern_str); //0xA01C67 for (size_t i = 0; i < pattern.size(); i++) { injector::MakeNOP(pattern.get(i).get<uint32_t>(0), 1, true); injector::WriteMemory<uint16_t>(pattern.get(i).get<uint32_t>(1), 0x05D9, true); injector::WriteMemory(pattern.get(i).get<uint32_t>(3), &Screen.fHudScale, true); } auto ptr = hook::get_pattern("D8 3D ? ? ? ? D9 5C 24 34 E8 ? ? ? ? D9", 2); //0xA01E6A injector::WriteMemory(ptr, &Screen.fFieldOfView, true); //objects disappear at screen edges with hor+, fixing that @0098B8CF ptr = hook::get_pattern("D8 0D ? ? ? ? D9 5C 24 10 8B 5C 24 10 53", 2); //0x98B8CF injector::WriteMemory(ptr, &Screen.fCutOffArea, true); //FMVs pattern = hook::pattern("89 50 18 8B 06 8B CE FF 50 14 8B 4F 08"); //0xA25984 struct FMVHook { void operator()(injector::reg_pack& regs) { //hor *(float*)(regs.eax - 0x54) /= Screen.fFMVScale; *(float*)(regs.eax - 0x38) /= Screen.fFMVScale; *(float*)(regs.eax - 0x1C) /= Screen.fFMVScale; *(float*)(regs.eax + 0x00) /= Screen.fFMVScale; if (bFullscreenFMVs) { static const float fFMVSize = (640.0f / 386.0f) / (480.0f / 386.0f); //hor *(float*)(regs.eax - 0x54) *= fFMVSize; *(float*)(regs.eax - 0x38) *= fFMVSize; *(float*)(regs.eax - 0x1C) *= fFMVSize; *(float*)(regs.eax + 0x00) *= fFMVSize; //ver *(float*)(regs.eax - 0x50) *= fFMVSize; *(float*)(regs.eax - 0x18) *= fFMVSize; *(float*)(regs.eax - 0x34) *= fFMVSize; *(float*)(regs.eax + 0x04) *= fFMVSize; } *(uintptr_t*)(regs.eax + 0x18) = regs.edx; regs.eax = *(uintptr_t*)(regs.esi); } }; injector::MakeInline<FMVHook>(pattern.get(0).get<uintptr_t>(0)); pattern = hook::pattern("68 ? ? ? ? E8 ? ? ? ? 50 55 56 E8 ? ? ? ? 0F B7 4F 06 0F B7 57 04"); //0x992C4C static auto unk_CC0E20 = *pattern.get(0).get<char*>(1); struct TextHook { void operator()(injector::reg_pack& regs) { if (strncmp(unk_CC0E20, "16/9", 4) == 0) { strncpy(unk_CC0E20, "Bars", 4); } else { if (strncmp(unk_CC0E20, "4/3", 3) == 0) { strncpy(unk_CC0E20, "Std", 4); } } regs.ecx = *(uint16_t*)(regs.edi + 6); regs.edx = *(uint16_t*)(regs.edi + 4); } }; injector::MakeInline<TextHook>(pattern.get(0).get<uintptr_t>(18), pattern.get(0).get<uintptr_t>(18 + 8)); pBarsPtr = *(uintptr_t*)hook::get_pattern("A1 ? ? ? ? 8B 88 00 08 00 00 81 C1 B4 68 06 00", 1); //0xCBFBE0 auto off_AD5CE8 = *hook::pattern("89 46 1C C7 06 ? ? ? ? 8B C6 5E C3").get(1).get<uintptr_t*>(5); injector::WriteMemory(off_AD5CE8 + 5, BarsHook, true); //0xAD5CFC pBarsJmp = (uintptr_t)hook::get_pattern("8B 41 10 6A 00 50 B9 ? ? ? ? E8", 0); //0xA2A350 if (fMouseSensitivityFactor) { pattern = hook::pattern("D9 85 ? ? ? ? D8 1D ? ? ? ? DF E0 F6 C4 41 75 1D D9 85 4C"); //0x45F048 struct MouseSensHook { void operator()(injector::reg_pack& regs) { *(float*)(regs.ebp - 0x1B0) *= fMouseSensitivityFactor; *(float*)(regs.ebp - 0x1B4) *= fMouseSensitivityFactor; float temp = *(float*)(regs.ebp - 0x1B4); _asm fld dword ptr[temp] } }; injector::MakeInline<MouseSensHook>(pattern.get(0).get<uintptr_t>(0), pattern.get(0).get<uintptr_t>(6)); } return 0; } BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/) { if (reason == DLL_PROCESS_ATTACH) { InitSettings(NULL); Init(NULL); } return TRUE; }
[ "thirteenag@gmail.com" ]
thirteenag@gmail.com
710d987383283d2e50dd4166f60ba23b3b8fe51c
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/ash/system/hotspot/hotspot_info_cache.h
cd9a386e2a8fa013d8ec1376225919999f47bb47
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
2,001
h
// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ASH_SYSTEM_HOTSPOT_HOTSPOT_INFO_CACHE_H_ #define ASH_SYSTEM_HOTSPOT_HOTSPOT_INFO_CACHE_H_ #include "ash/ash_export.h" #include "chromeos/ash/services/hotspot_config/public/mojom/cros_hotspot_config.mojom.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" class PrefRegistrySimple; namespace ash { // Queries the Hotspot info on startup, then monitors it for changes. // Used by code that needs to query the hotspot state synchronously (e.g. the // quick settings bubble). class ASH_EXPORT HotspotInfoCache : public hotspot_config::mojom::CrosHotspotConfigObserver { public: HotspotInfoCache(); HotspotInfoCache(const HotspotInfoCache&) = delete; HotspotInfoCache& operator=(const HotspotInfoCache&) = delete; ~HotspotInfoCache() override; // Registers the profile prefs for whether hotspot has been used. static void RegisterProfilePrefs(PrefRegistrySimple* registry); // Returns the cached hotspot info. hotspot_config::mojom::HotspotInfoPtr GetHotspotInfo(); // Returns whether the hotspot has been successfully used previously. bool HasHotspotUsedBefore(); private: // Binds to the mojo interface for hotspot config. void BindToCrosHotspotConfig(); // hotspot_config::mojom::CrosHotspotConfigObserver: void OnHotspotInfoChanged() override; void OnGetHotspotInfo(hotspot_config::mojom::HotspotInfoPtr hotspot_info); void SetHasHotspotUsedBefore(); mojo::Remote<hotspot_config::mojom::CrosHotspotConfig> remote_cros_hotspot_config_; mojo::Receiver<hotspot_config::mojom::CrosHotspotConfigObserver> hotspot_config_observer_receiver_{this}; hotspot_config::mojom::HotspotInfoPtr hotspot_info_; base::WeakPtrFactory<HotspotInfoCache> weak_ptr_factory_{this}; }; } // namespace ash #endif // ASH_SYSTEM_HOTSPOT_HOTSPOT_INFO_CACHE_H_
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
dd30e06d80e171077e57662c6138a2fb5b1237e9
0a007177fd16bd4930ef5d188a5a73f188bb4c8d
/mapnik_filegdb/filegdb_featureset.cpp
d2c7022c5c9fac807ceccd3a0a6a6fde6ed60fbf
[]
no_license
lozpeng/mapnik_filegdb
a9690a92dfd1fddfbdfdaebb170259e6a67e6289
587444813be4dabd4b6ac80180a830a737b2cc88
refs/heads/master
2021-01-23T18:21:51.672274
2013-08-26T05:04:19
2013-08-26T05:04:19
11,996,668
1
0
null
null
null
null
GB18030
C++
false
false
2,450
cpp
#include <iostream> // mapnik #include <mapnik/debug.hpp> #include <mapnik/feature_factory.hpp> #include <mapnik/unicode.hpp> #include <mapnik/geometry.hpp> // boost #include <boost/make_shared.hpp> // file gdb plugin #include "filegdb_featureset.hpp" #include "shape_buffer_io.hpp" using mapnik::geometry_type; using mapnik::feature_factory; using mapnik::context_ptr; template <typename filterT> filegdb_featureset<filterT>::filegdb_featureset(filterT const& filter, box2d<double> const& box,Table* gdbTable,int row_limit, std::string const& encoding,std::string where_clause) :filter_(filter), row_limit_(row_limit), box_(box), ctx_(boost::make_shared<mapnik::context_type>()), tr_(new transcoder(encoding)), where_clause_(where_clause) { FileGDBAPI::Envelope envelope; envelope.xMin =box_.minx();// -118.219; envelope.yMin =box_.miny();// 22.98; envelope.xMax =box_.maxx();// -117.988; envelope.yMax =box_.maxy();// 34.0; fgdbError hr; //根据条件检索出数据用于获取每一条记录 try { if(!where_clause_.empty()) { std::wstring w_clause; std::string str(where_clause_); str = gbk_to_utf8(str); w_clause = to_vwstring(w_clause,str); //where 条件最好调整为UTF-8编码格式 hr = gdbTable->Search(L"*", w_clause, envelope, true, spQueryRows); if (hr != S_OK) { //数据查询失败 } } else{ hr = gdbTable->Search(L"*", L"", envelope, true, spQueryRows); } if (hr != S_OK) { //spQueryRows =NULL; } } catch(...) { //spQueryRows = NULL; } } template <typename filterT> filegdb_featureset<filterT>::~filegdb_featureset() { try{ spQueryRows.Close(); } catch(...) { } } // template <typename filterT> mapnik::feature_ptr filegdb_featureset<filterT>::next() { //filter_in_box filter(box_); //如果有查询到的行集 fgdbError hr; Row spQueryRow; hr = spQueryRows.Next(spQueryRow); if(hr==S_OK) { int32 oid; hr = spQueryRow.GetOID(oid); if(hr!=S_OK) return mapnik::feature_ptr(); mapnik::value_integer fid(oid); feature_ptr feature(feature_factory::create(ctx_,fid)); shape_buffer_io::parse_esri_row(feature,&spQueryRow,*tr_); return feature; } // otherwise return an empty feature return mapnik::feature_ptr(); } //建立按范围查询模板类 template class filegdb_featureset<mapnik::filter_in_box>; //建立点位置查询模板类 template class filegdb_featureset<mapnik::filter_at_point>;
[ "lozpeng@gmail.com" ]
lozpeng@gmail.com
0ad1f1fffe93ba990de94fb3cded83432709f842
747238767e0520645687cf1af64a91081904c6d9
/ESPWiFiServer/Source/Client/Builders/ClientBuilderBase.h
2289f2af67e2302606e72b42a4ae549600b68ebd
[]
no_license
MaxGarden/ESPWiFiServer
5a66c9fa68dc7c5e53b34c03c3c6a76c4a6c0a48
e88154c2d091d65e25e714333f68d771f6b17d73
refs/heads/master
2020-04-09T05:02:17.174362
2019-02-24T16:54:23
2019-02-24T16:55:09
160,048,396
0
0
null
null
null
null
UTF-8
C++
false
false
412
h
#if !defined(__CLIENT_BUILDER_BASE_H__) #define __CLIENT_BUILDER_BASE_H__ #pragma once #include "Client/ClientBuilder.h" #include "Client/ClientController.h" class CClientBuilderBase : public IClientBuilder { public: CClientBuilderBase() = default; virtual ~CClientBuilderBase() override = default; virtual bool Build(IClientController& controller) override; }; #endif //__CLIENT_BUILDER_BASE_H__
[ "mserkies@artifexmundi.com" ]
mserkies@artifexmundi.com
49b635f050fd537cc9dcf73b3712a7ec248a1976
18814825f89fda6637258a02454850c738465ee3
/ex09/ex09_34.cpp
4222ba96ed37d70b6de3fc4e088e452300049ebc
[]
no_license
rcocco/Cpp_Primer_5th
ce3f961c47f10d6e23524bba9f7772816cc304d8
ae5b5d064acb353d8e1789066258c7673c1d9ad5
refs/heads/master
2020-04-18T18:39:47.635248
2019-02-21T15:09:28
2019-02-21T15:09:28
167,691,140
0
0
null
null
null
null
UTF-8
C++
false
false
403
cpp
#include <iostream> #include <vector> using std::vector; using std::cout; using std::endl; int main() { vector<int> vi = { 0,1,2,3,4,5,6,7,8,9 }; auto iter = vi.begin(); while (iter != vi.end()) { if (*iter % 2) { iter = vi.insert(iter, *iter); //++iter; } ++iter; cout << (iter-vi.begin()) << " "<< (vi.end() - iter) << endl; } for (auto v : vi) { cout << v << " "; } return 0; }
[ "araia@qq.com" ]
araia@qq.com
6b92e446906af4ab3ff9a04c3e9a7ca8c37ccced
f4e3c6a36d3bf47edeab4c83d32033cd8b5e63e9
/src/simple_layer.h
6b876d59c01457a04a8ee1227be7230d264627ed
[]
no_license
rozoalex/Simple_Layer
aaa8c13b2a30981c8fe001934b32038ec5809004
d8bb4df8e37722651c7b8aaa04eb6ed34fdca727
refs/heads/master
2021-08-30T11:46:04.668406
2017-12-17T20:21:55
2017-12-17T20:21:55
114,565,894
0
0
null
null
null
null
UTF-8
C++
false
false
973
h
//from http://wiki.ros.org/costmap_2d/Tutorials/Creating%20a%20New%20Layer #ifndef SIMPLE_LAYER_H_ #define SIMPLE_LAYER_H_ #include <ros/ros.h> #include <costmap_2d/layer.h> #include <costmap_2d/layered_costmap.h> #include <costmap_2d/GenericPluginConfig.h> #include <dynamic_reconfigure/server.h> namespace simple_layer_namespace { class SimpleLayer : public costmap_2d::Layer //http://docs.ros.org/jade/api/costmap_2d/html/classcostmap__2d_1_1Layer.html { public: SimpleLayer(); virtual void onInitialize(); virtual void updateBounds(double robot_x, double robot_y, double robot_yaw, double* min_x, double* min_y, double* max_x,double* max_y); virtual void updateCosts(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j); private: void reconfigureCB(costmap_2d::GenericPluginConfig &config, uint32_t level); double mark_x_, mark_y_; dynamic_reconfigure::Server<costmap_2d::GenericPluginConfig> *dsrv_; }; } #endif
[ "alexhubnds@icloud.com" ]
alexhubnds@icloud.com
1cd7649e412efd3202c0837c0f3227bf101b2356
9655c1a76de83187abaafe13c5f0ae0d38746a93
/Com/Programing technique/Programing technique 3/Valley of the kings.cpp
3f79102deae8446179cbad9cad9431bdc1ee3c2d
[]
no_license
PunnyOz2/POSN-Programming
26a2df48e4f4c164b3c364d00ebef85b5df78ccd
c89cf7765354f8b5ff1f6f95b8382251f5ca734c
refs/heads/main
2023-05-25T09:04:23.802021
2021-06-13T05:43:15
2021-06-13T05:43:15
376,192,660
0
0
null
null
null
null
UTF-8
C++
false
false
634
cpp
/* TASK: LANG: CPP AUTHOR: Pun SCHOOL: CRU */ #include<bits/stdc++.h> using namespace std; int a[1010],b[1010]; int main() { int q,i,n,j,ans; scanf("%d",&q); while(q--){ scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); for(i=0,j=0,ans=0;i<n; ){ if(a[i]==a[i+1]) ans++,i+=2; else b[j++]=a[i],i++; } printf("%d\n",ans); for(i=0;i<j;i++) printf("%d ",b[i]); if(j==0) printf("Empty"); } return 0; } /* 2 15 3 5 3 2 3 6 3 4 7 2 4 3 5 3 4 */
[ "punnyoz1103@gmail.com" ]
punnyoz1103@gmail.com
99914ada19eb257762c77e1e7585397e9061727a
2e035c3648ff09b3c8d0ecdf994970c560712baf
/tvshow2.gui/AUWMHDR.CPP
9b4803e111da395a343c1058a25eb24e2349d2e7
[]
no_license
OS2World/MM-TV-TVShow
678cb258349d561e9f037e882eb5f813cbda570a
46045fe55ab7c689e53c107362177f0ff8447e87
refs/heads/master
2021-01-22T09:41:59.710212
2013-07-04T17:10:17
2013-07-04T17:10:17
11,182,754
0
0
null
null
null
null
UTF-8
C++
false
false
701
cpp
#ifndef _IBASE_ //Make sure ibase.hpp is included #include <ibase.hpp> // since that is where IC_<environ> #endif // is defined. #include "auwmhdr.hpp" /******************************************************************************/ /* AUserMessageHandler::dispatchHandlerEvent - catch user events */ /******************************************************************************/ IBase::Boolean AUserMessageHandler::dispatchHandlerEvent( IEvent& evt ) { if ( evt.eventId() == userMessageId ) return userMessage( evt ); return false; } /* end AUserMessageHandler::dispatchHandlerEvent(...) */ 
[ "martiniturbide@gmail.com" ]
martiniturbide@gmail.com
4e23edb6c372d5cb6ec9328fded692f89cbf9f65
621917bd5fa4c2853d1dbc99170e728d7e8c75d8
/数据结构教程上机指导/数据结构上机指导-源程序/实验题10/exp10-7.cpp
c8561f504be5348c8d07235b03121432fd619a01
[]
no_license
mexbo/DataStruct_LiChunbao
cca5d86b82bdd4f9da9f02d35adaa032ef3fcfcf
85d037383abb4b7fe3ee6cf3ba6bcb78b000db28
refs/heads/master
2020-06-30T21:29:56.419711
2019-08-07T02:24:32
2019-08-07T02:24:32
200,956,159
11
1
null
null
null
null
GB18030
C++
false
false
2,230
cpp
//文件名:exp10-7.cpp #include <stdio.h> #include <malloc.h> #define MAXE 20 //线性表中最多元素个数 typedef int KeyType; typedef char InfoType[10]; typedef struct //记录类型 { KeyType key; //关键字项 InfoType data; //其他数据项,类型为InfoType } RecType; void Merge(RecType R[],int low,int mid,int high) //将两个有序表R[low..mid]和R[mid+1..high]归并为一个有序表R[low..high]中 { RecType *R1; int i=low,j=mid+1,k=0; //k是R1的下标,i、j分别为第1、2段的下标 R1=(RecType *)malloc((high-low+1)*sizeof(RecType)); //动态分配空间 while (i<=mid && j<=high) //在第1段和第2段均未扫描完时循环 if (R[i].key<=R[j].key) //将第1段中的记录放入R1中 { R1[k]=R[i]; i++;k++; } else //将第2段中的记录放入R1中 { R1[k]=R[j]; j++;k++; } while (i<=mid) //将第1段余下部分复制到R1 { R1[k]=R[i]; i++;k++; } while (j<=high) //将第2段余下部分复制到R1 { R1[k]=R[j]; j++;k++; } for (k=0,i=low;i<=high;k++,i++) //将R1复制回R中 R[i]=R1[k]; } void MergePass(RecType R[],int length,int n) //实现一趟归并 { int i; for (i=0;i+2*length-1<n;i=i+2*length) //归并length长的两相邻子表 Merge(R,i,i+length-1,i+2*length-1); if (i+length-1<n) //余下两个子表,后者长度小于length Merge(R,i,i+length-1,n-1); //归并这两个子表 } void MergeSort(RecType R[],int n) //二路归并排序算法 { int length,k,i=1; //i用于累计归并的趟数 for (length=1;length<n;length=2*length) { MergePass(R,length,n); printf(" 第%d趟归并:",i++); //输出每一趟的排序结果 for (k=0;k<n;k++) printf("%4d",R[k].key); printf("\n"); } } void main() { int i,k,n=10; KeyType a[]={18,2,20,34,12,32,6,16,5,8}; RecType R[MAXE]; for (i=0;i<n;i++) R[i].key=a[i]; printf("初始关键字:"); //输出初始关键字序列 for (k=0;k<n;k++) printf("%4d",R[k].key); printf("\n"); MergeSort(R,n); printf("最后结果: "); //输出初始关键字序列 for (k=0;k<n;k++) printf("%4d",R[k].key); printf("\n"); }
[ "mexbochen@foxmail.com" ]
mexbochen@foxmail.com
743e3fb50bc782c7d71bef02b897aa30e6bfb372
64269bd40e79dc7b56b2268aa5ce5a8fcc9e19eb
/ANN/Library.h
1c33a6da8e24d4674d6894884891d8527dcb0103
[]
no_license
ArakelMkrtchyan/BolzmANN
543160982586771343199c1cf514ceed196c890f
0483d3b628c90ebc737b0535c184dea8b08b3297
refs/heads/master
2020-05-23T11:16:51.559206
2015-12-14T17:25:54
2015-12-14T17:25:54
47,017,365
0
0
null
2015-11-28T09:13:07
2015-11-28T09:13:05
C++
UTF-8
C++
false
false
1,264
h
#ifndef LIBRARY_H #define LIBRARY_H #include <vector> #include <list> #include <map> #include <set> #include <stack> #include <queue> template<typename T> struct Vector : std::vector<T> { using My = Vector; bool contains(const T& x) const { return (std::find(My::begin(), My::end(), x) != My::end()); } }; template<typename T> struct List : std::list<T> { using My = List; bool contains(const T& x) const { return (My::find(x) != My::end()); } }; template<typename K, typename T> struct Map : std::map<K, T> { using My = Map; bool contains(const K& key) const { return (My::find(key) != My::end()); } }; template<typename K> struct Set : std::set<K> { using My = Set; bool contains(const K& key) const { return (My::find(key) != My::end()); } }; template<typename T> struct Stack : std::stack<T> { using My = Stack; bool contains(const T& x) const { return (std::find(My::begin(), My::end(), x) != My::end()); } }; template<typename T> struct Queue : std::queue<T> { using My = Queue; bool contains(const T& x) const { return (std::find(My::begin(), My::end(), x) != My::end()); } }; #endif // LIBRARY_H
[ "davittevanian@gmail.com" ]
davittevanian@gmail.com
09a02bfb3f35d50b4a6b3e654d23d43e288e1ab3
4f4d3ec9bca4e2acb085a0c77e5cd3ed1b43b98d
/Implementation/1168.cpp
bc8a8fa21416b803c927e01f22272344c4552f64
[]
no_license
Jeonghwan-Yoo/BOJ
5293c181e17ea3bcd7f15e3a9e1df08d3a885447
5f2018106a188ce36b15b9ae09cf68da4566ec99
refs/heads/master
2021-03-05T02:36:45.338480
2021-01-20T12:43:40
2021-01-20T12:43:40
246,088,916
0
0
null
null
null
null
UTF-8
C++
false
false
550
cpp
#include <iostream> #include <string> #include <vector> using namespace std; int N, K; int main() { freopen("in.txt", "r", stdin); cin >> N >> K; cout << "<"; vector<int> people; for (int i = 1; i <= N; ++i) { people.push_back(i); } int pos = 0; for (int i = 0; i < N; ++i) { pos += K - 1; pos %= people.size(); cout << people[pos]; if (people.size() - 1> 0) cout << ", "; people.erase(people.begin() + pos); } cout << ">"; return 0; }
[ "dwgbjdhks2@gmail.com" ]
dwgbjdhks2@gmail.com
e5d55f239292c2a988054150405c467786dbbf78
2fde7d8e325536d231c0de7f8fd6ee2b17c05bc5
/62.unique-paths.cpp
2ea8976580d04d62bb2f2c608e071afd486df471
[]
no_license
Sahanduiuc/leetcode-solutions
41326a43f5993dbc04f603cac1befb36849e8816
fecb9e13d81eafd284be7e9a8b89824cec85e0d6
refs/heads/master
2020-09-20T11:48:48.851581
2018-04-17T13:15:30
2018-04-17T13:15:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
394
cpp
class Solution { public: const int N = 200; int uniquePaths(int m, int n) { --m, --n; int dp[N][N]; for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) dp[i][j] = 0; for (int i = 0; i < N; ++i) dp[i][0] = dp[i][i] = 1; for (int i = 1; i < N; ++i) for (int j = 1; j < i; ++j) dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]; return dp[m + n][m]; } };
[ "gantheory@gantheorys-MacBook-Pro.local" ]
gantheory@gantheorys-MacBook-Pro.local
1ae7b8410b8a511f372ba1988217b2cb37600f3b
720d5e92b631cbcca07c7c074ebf9ec832765af7
/dashboard/serial.h
bcbe1aaf6ae5c9cef6c410a8fa166545e8a90522
[ "BSD-2-Clause" ]
permissive
comran/miranda-dashboard
e1d3dd1ca3c4738b0ed92224bc60cdac4f160f47
54079cb276ef4ee149e931d618b445a618c7c1c0
refs/heads/master
2021-01-12T04:06:24.676407
2017-01-06T01:41:36
2017-01-06T01:41:36
77,504,455
1
0
null
null
null
null
UTF-8
C++
false
false
566
h
#ifndef _SERIAL_H_ #define _SERIAL_H_ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <termios.h> #include <inttypes.h> #include <string.h> namespace dashboard { namespace sensor_reader { namespace serial { class Serial { public: void Init(); void Write(char const*); void Read(char *&); void Close(void); bool WaitForResponse(char const*, int); private: int serial_fd_ = -1; char const* port_name_ = "/dev/ttyUSB0"; }; } // namespace dashboard } // namespace sensor_reader } // namespace serial #endif
[ "comranmorsh@gmail.com" ]
comranmorsh@gmail.com
31942d699cef5ac2051007f4d78d44a25c2d361f
2d42a50f7f3b4a864ee19a42ea88a79be4320069
/source/application/application_config.h
443f2a94db1a7b97cc4ac508980d581c128985cc
[]
no_license
Mikalai/punk_project_a
8a4f55e49e2ad478fdeefa68293012af4b64f5d4
8829eb077f84d4fd7b476fd951c93377a3073e48
refs/heads/master
2016-09-06T05:58:53.039941
2015-01-24T11:56:49
2015-01-24T11:56:49
14,536,431
1
0
null
2014-06-26T06:40:50
2013-11-19T20:03:46
C
UTF-8
C++
false
false
435
h
#ifndef _H_PUNK_APPLICATION_CONFIG #define _H_PUNK_APPLICATION_CONFIG #include "../gpu/gpu_config.h" #include "../render/render_config.h" #include "../audio/audio_config.h" #include "../physics/physics_config.h" namespace Punk { struct Config { /* Gpu::Config gpu_config; LowLevelRender::Config render_config; Audio::Config audio_config; Physics::Config physics_config; */ }; } #endif // _H_PUNK_APPLICATION_CONFIG
[ "nickolaib2004@gmail.com" ]
nickolaib2004@gmail.com
6859ecfe86160d63ce81ecac5d64c1a51790dfc9
175390199ca6c8d6ba09c4828d9e0527d95efc85
/Chuong 13 - Cay nhi phan/bai862.cpp
c9da94dcb5c730baab904407819b5a23fe79c529
[]
no_license
DuyTran1234/1000ExerciseC-
4d8627eb2dedf25038557d5fdd07a17ff52fbd00
5b6c63aef3c060a49bf0556e7c4a02074f8a977e
refs/heads/master
2020-08-06T10:19:47.245586
2019-10-05T03:55:20
2019-10-05T03:55:20
212,940,676
0
0
null
null
null
null
UTF-8
C++
false
false
287
cpp
#include <iostream> using namespace std; struct PHANSO { double tuSo; double mauSo; }; struct node { PHANSO data; node *pLeft; node *pRight; }; int main() { } void KhoiTaoCay(node * &tree) { tree = NULL; } void ThemNodeVaoCay(node * &tree, PHANSO x) { }
[ "0985919093dd@gmail.com" ]
0985919093dd@gmail.com
5a42b7acf9c7859fc9fe91bd2462d5163932ba11
277b58437c5060fa1f442ecf73ac02d9c5e2bc95
/NtupleProducer/include/NtupleProducer.h
fe2f1b0348a8ccf4f63225272a225cbfc659bdcc
[]
no_license
cirkovic/tHFCNC
753db081a13778d5d08fddb6935145d246dc24e9
dbe353ee942701180bc34059e4ba1d2beca78c24
refs/heads/master
2020-07-26T02:40:14.483385
2017-01-31T10:02:47
2017-01-31T10:02:47
73,637,784
0
0
null
null
null
null
UTF-8
C++
false
false
405
h
#ifndef NTUPLEPRODUCER_H #define NTUPLEPRODUCER_H #include "Tree.h" #include "Electron.h" #include "Muon.h" #include "Event.h" #include "Jet.h" #include "Truth.h" #include "Ntuple.h" #include "BTagCalibrationStandalone.h" extern Tree *ntP; extern TChain *ch; extern Ntuple *nt; extern std::vector<int> *evdebug; extern BTagCalibration *calib; extern BTagCalibrationReader *reader_iterativefit; #endif
[ "Kirill.Skovpen@cern.ch" ]
Kirill.Skovpen@cern.ch
afd72e69ed0e40f118b00c385b0f6c5de2acaabe
2ee81cbf0bcd323e5094137bb4a9efd45c5580fd
/TestGame/source/game.cpp
1ced26cdd0c708863cf1f2350c32254d249c55e0
[]
no_license
Phariax/Frankly
c528c4c4779aa23f878ddad2e4652f115b5db014
00355cc214f048c407f3dd9129e365f42fc3166f
refs/heads/master
2020-07-11T11:00:40.371783
2019-08-26T16:50:25
2019-08-26T16:50:25
204,519,242
0
0
null
null
null
null
UTF-8
C++
false
false
1,302
cpp
//////////////////////////////////////////////////////////////////////////////////////// /* Startup for Frank Engine Copyright 2013 - Frank Force */ //////////////////////////////////////////////////////////////////////////////////////// #include "gameGlobals.h" //////////////////////////////////////////////////////////////////////////////////////// // Game Globals GameGui* g_gameGui = NULL; GameControl* g_gameControl = NULL; //////////////////////////////////////////////////////////////////////////////////////// // Main Entry Point int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ) { // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // startup the frank engine const int startWidth = 1280; const int startHeight = 720; FrankEngineStartup(gameTitle); // init frank engine with custom objects g_gameControl = new GameControl(); g_gameGui = new GameGui(); Camera* camera = new Camera(); FrankEngineInit(startWidth, startHeight, g_gameControl, g_gameGui, camera); // frank engine main loop FrankEngineLoop(); // shutdown frank engine FrankEngineShutdown(); // exit the program return DXUTGetExitCode(); }
[ "30328936+Phariax@users.noreply.github.com" ]
30328936+Phariax@users.noreply.github.com
fb5225a4b53c18b5ce932562734eab0560895b4b
c6499a4ae3a297948b259a81d95ba1f220f93cee
/PingPong/Entity.cpp
f559e5ffc46fa00486936df3b0546f0e0dcf743c
[]
no_license
adajoh/PingPong
3e6b9628e48580e9d0efe1323e2afca8b289af26
85d90a6e7ef39ecf9cf791b397056e7d495eb6dc
refs/heads/master
2021-07-19T16:01:43.080448
2017-10-26T15:15:07
2017-10-26T15:15:07
108,427,379
0
0
null
null
null
null
UTF-8
C++
false
false
627
cpp
#include "Entity.h" Entity::Entity(int x, int y, int width, int height) { rect.x = x; rect.y = y; rect.w = width; rect.h = height; } const void Entity::render(SDL_Renderer * renderer) { SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); renderRect.x = rect.x; renderRect.y = rect.y; renderRect.w = rect.w; renderRect.h = rect.h; SDL_RenderFillRect(renderer, &renderRect); } Rectangle &Entity::getRect() { return rect; } Entity::~Entity() { } bool Entity::clampHor() { if (rect.y <0) { rect.y = 0; return true; } if (rect.y+rect.h>480) { rect.y = 480-rect.h; return true; } return false; }
[ "adam.johansson00@gmail.com" ]
adam.johansson00@gmail.com
d85ca1ba7e9f973fdc03656e0360cd0152611199
9a3b9d80afd88e1fa9a24303877d6e130ce22702
/src/Providers/UNIXProviders/BlockStatisticsManifest/UNIX_BlockStatisticsManifest_LINUX.hpp
bd6cd1a6f60e06217558fad4a7bf0350ad7f01ff
[ "MIT" ]
permissive
brunolauze/openpegasus-providers
3244b76d075bc66a77e4ed135893437a66dd769f
f24c56acab2c4c210a8d165bb499cd1b3a12f222
refs/heads/master
2020-04-17T04:27:14.970917
2015-01-04T22:08:09
2015-01-04T22:08:09
19,707,296
0
0
null
null
null
null
UTF-8
C++
false
false
30,178
hpp
//%LICENSE//////////////////////////////////////////////////////////////// // // Licensed to The Open Group (TOG) under one or more contributor license // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with // this work for additional information regarding copyright ownership. // Each contributor licenses this file to you under the OpenPegasus Open // Source License; you may not use this file except in compliance with the // License. // // 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. // ////////////////////////////////////////////////////////////////////////// // //%///////////////////////////////////////////////////////////////////////// using PROVIDER_LIB_NS::CIMHelper; UNIX_BlockStatisticsManifest::UNIX_BlockStatisticsManifest(void) { } UNIX_BlockStatisticsManifest::~UNIX_BlockStatisticsManifest(void) { } Boolean UNIX_BlockStatisticsManifest::getInstanceID(CIMProperty &p) const { p = CIMProperty(PROPERTY_INSTANCE_ID, getInstanceID()); return true; } String UNIX_BlockStatisticsManifest::getInstanceID() const { return _instanceID; } void UNIX_BlockStatisticsManifest::setInstanceID(String &value) { _instanceID = value; } Boolean UNIX_BlockStatisticsManifest::getCaption(CIMProperty &p) const { p = CIMProperty(PROPERTY_CAPTION, getCaption()); return true; } String UNIX_BlockStatisticsManifest::getCaption() const { return _caption; } void UNIX_BlockStatisticsManifest::setCaption(String &value) { _caption = value; } Boolean UNIX_BlockStatisticsManifest::getDescription(CIMProperty &p) const { p = CIMProperty(PROPERTY_DESCRIPTION, getDescription()); return true; } String UNIX_BlockStatisticsManifest::getDescription() const { return _description; } void UNIX_BlockStatisticsManifest::setDescription(String &value) { _description = value; } Boolean UNIX_BlockStatisticsManifest::getElementName(CIMProperty &p) const { p = CIMProperty(PROPERTY_ELEMENT_NAME, getElementName()); return true; } String UNIX_BlockStatisticsManifest::getElementName() const { return _elementName; } void UNIX_BlockStatisticsManifest::setElementName(String &value) { _elementName = value; } Boolean UNIX_BlockStatisticsManifest::getGeneration(CIMProperty &p) const { p = CIMProperty(PROPERTY_GENERATION, getGeneration()); return true; } Uint64 UNIX_BlockStatisticsManifest::getGeneration() const { return _generation; } void UNIX_BlockStatisticsManifest::setGeneration(Uint64 &value) { _generation = value; } Boolean UNIX_BlockStatisticsManifest::getElementType(CIMProperty &p) const { p = CIMProperty(PROPERTY_ELEMENT_TYPE, getElementType()); return true; } Uint16 UNIX_BlockStatisticsManifest::getElementType() const { return _elementType; } void UNIX_BlockStatisticsManifest::setElementType(Uint16 &value) { _elementType = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeStartStatisticTime(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_START_STATISTIC_TIME, getIncludeStartStatisticTime()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeStartStatisticTime() const { return _includeStartStatisticTime; } void UNIX_BlockStatisticsManifest::setIncludeStartStatisticTime(Boolean &value) { _includeStartStatisticTime = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeStatisticTime(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_STATISTIC_TIME, getIncludeStatisticTime()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeStatisticTime() const { return _includeStatisticTime; } void UNIX_BlockStatisticsManifest::setIncludeStatisticTime(Boolean &value) { _includeStatisticTime = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeTotalIOs(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_TOTAL_IOS, getIncludeTotalIOs()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeTotalIOs() const { return _includeTotalIOs; } void UNIX_BlockStatisticsManifest::setIncludeTotalIOs(Boolean &value) { _includeTotalIOs = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesTransferred(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_K_BYTES_TRANSFERRED, getIncludeKBytesTransferred()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesTransferred() const { return _includeKBytesTransferred; } void UNIX_BlockStatisticsManifest::setIncludeKBytesTransferred(Boolean &value) { _includeKBytesTransferred = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeIOTimeCounter(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_IO_TIME_COUNTER, getIncludeIOTimeCounter()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeIOTimeCounter() const { return _includeIOTimeCounter; } void UNIX_BlockStatisticsManifest::setIncludeIOTimeCounter(Boolean &value) { _includeIOTimeCounter = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOs(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_READ_IOS, getIncludeReadIOs()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOs() const { return _includeReadIOs; } void UNIX_BlockStatisticsManifest::setIncludeReadIOs(Boolean &value) { _includeReadIOs = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOs(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_READ_HIT_IOS, getIncludeReadHitIOs()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOs() const { return _includeReadHitIOs; } void UNIX_BlockStatisticsManifest::setIncludeReadHitIOs(Boolean &value) { _includeReadHitIOs = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOTimeCounter(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_READ_IO_TIME_COUNTER, getIncludeReadIOTimeCounter()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOTimeCounter() const { return _includeReadIOTimeCounter; } void UNIX_BlockStatisticsManifest::setIncludeReadIOTimeCounter(Boolean &value) { _includeReadIOTimeCounter = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOTimeCounter(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_READ_HIT_IO_TIME_COUNTER, getIncludeReadHitIOTimeCounter()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOTimeCounter() const { return _includeReadHitIOTimeCounter; } void UNIX_BlockStatisticsManifest::setIncludeReadHitIOTimeCounter(Boolean &value) { _includeReadHitIOTimeCounter = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesRead(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_K_BYTES_READ, getIncludeKBytesRead()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesRead() const { return _includeKBytesRead; } void UNIX_BlockStatisticsManifest::setIncludeKBytesRead(Boolean &value) { _includeKBytesRead = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOs(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_WRITE_IOS, getIncludeWriteIOs()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOs() const { return _includeWriteIOs; } void UNIX_BlockStatisticsManifest::setIncludeWriteIOs(Boolean &value) { _includeWriteIOs = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOs(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_WRITE_HIT_IOS, getIncludeWriteHitIOs()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOs() const { return _includeWriteHitIOs; } void UNIX_BlockStatisticsManifest::setIncludeWriteHitIOs(Boolean &value) { _includeWriteHitIOs = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOTimeCounter(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_WRITE_IO_TIME_COUNTER, getIncludeWriteIOTimeCounter()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOTimeCounter() const { return _includeWriteIOTimeCounter; } void UNIX_BlockStatisticsManifest::setIncludeWriteIOTimeCounter(Boolean &value) { _includeWriteIOTimeCounter = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOTimeCounter(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_WRITE_HIT_IO_TIME_COUNTER, getIncludeWriteHitIOTimeCounter()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOTimeCounter() const { return _includeWriteHitIOTimeCounter; } void UNIX_BlockStatisticsManifest::setIncludeWriteHitIOTimeCounter(Boolean &value) { _includeWriteHitIOTimeCounter = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesWritten(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_K_BYTES_WRITTEN, getIncludeKBytesWritten()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesWritten() const { return _includeKBytesWritten; } void UNIX_BlockStatisticsManifest::setIncludeKBytesWritten(Boolean &value) { _includeKBytesWritten = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeIdleTimeCounter(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_IDLE_TIME_COUNTER, getIncludeIdleTimeCounter()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeIdleTimeCounter() const { return _includeIdleTimeCounter; } void UNIX_BlockStatisticsManifest::setIncludeIdleTimeCounter(Boolean &value) { _includeIdleTimeCounter = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeMaintOp(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_MAINT_OP, getIncludeMaintOp()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeMaintOp() const { return _includeMaintOp; } void UNIX_BlockStatisticsManifest::setIncludeMaintOp(Boolean &value) { _includeMaintOp = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeMaintTimeCounter(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_MAINT_TIME_COUNTER, getIncludeMaintTimeCounter()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeMaintTimeCounter() const { return _includeMaintTimeCounter; } void UNIX_BlockStatisticsManifest::setIncludeMaintTimeCounter(Boolean &value) { _includeMaintTimeCounter = value; } Boolean UNIX_BlockStatisticsManifest::getCSVSequence(CIMProperty &p) const { p = CIMProperty(PROPERTY_CS_V_SEQUENCE, getCSVSequence()); return true; } Array<String> UNIX_BlockStatisticsManifest::getCSVSequence() const { return _cSVSequence; } void UNIX_BlockStatisticsManifest::setCSVSequence(Array<String> &value) { _cSVSequence = value; } Boolean UNIX_BlockStatisticsManifest::getCSVRateSequence(CIMProperty &p) const { p = CIMProperty(PROPERTY_CS_V_RATE_SEQUENCE, getCSVRateSequence()); return true; } Array<String> UNIX_BlockStatisticsManifest::getCSVRateSequence() const { return _cSVRateSequence; } void UNIX_BlockStatisticsManifest::setCSVRateSequence(Array<String> &value) { _cSVRateSequence = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesReadRate(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_K_BYTES_READ_RATE, getIncludeKBytesReadRate()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesReadRate() const { return _includeKBytesReadRate; } void UNIX_BlockStatisticsManifest::setIncludeKBytesReadRate(Boolean &value) { _includeKBytesReadRate = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesTransferredRate(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_K_BYTES_TRANSFERRED_RATE, getIncludeKBytesTransferredRate()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesTransferredRate() const { return _includeKBytesTransferredRate; } void UNIX_BlockStatisticsManifest::setIncludeKBytesTransferredRate(Boolean &value) { _includeKBytesTransferredRate = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesWrittenRate(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_K_BYTES_WRITTEN_RATE, getIncludeKBytesWrittenRate()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeKBytesWrittenRate() const { return _includeKBytesWrittenRate; } void UNIX_BlockStatisticsManifest::setIncludeKBytesWrittenRate(Boolean &value) { _includeKBytesWrittenRate = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeMaintOpRate(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_MAINT_OP_RATE, getIncludeMaintOpRate()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeMaintOpRate() const { return _includeMaintOpRate; } void UNIX_BlockStatisticsManifest::setIncludeMaintOpRate(Boolean &value) { _includeMaintOpRate = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeRateIntervalEndTime(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_RATE_INTERVAL_END_TIME, getIncludeRateIntervalEndTime()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeRateIntervalEndTime() const { return _includeRateIntervalEndTime; } void UNIX_BlockStatisticsManifest::setIncludeRateIntervalEndTime(Boolean &value) { _includeRateIntervalEndTime = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeRateIntervalStartTime(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_RATE_INTERVAL_START_TIME, getIncludeRateIntervalStartTime()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeRateIntervalStartTime() const { return _includeRateIntervalStartTime; } void UNIX_BlockStatisticsManifest::setIncludeRateIntervalStartTime(Boolean &value) { _includeRateIntervalStartTime = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOsRate(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_READ_HIT_IOS_RATE, getIncludeReadHitIOsRate()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadHitIOsRate() const { return _includeReadHitIOsRate; } void UNIX_BlockStatisticsManifest::setIncludeReadHitIOsRate(Boolean &value) { _includeReadHitIOsRate = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOsRate(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_READ_IOS_RATE, getIncludeReadIOsRate()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeReadIOsRate() const { return _includeReadIOsRate; } void UNIX_BlockStatisticsManifest::setIncludeReadIOsRate(Boolean &value) { _includeReadIOsRate = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeTotalIOsRate(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_TOTAL_IOS_RATE, getIncludeTotalIOsRate()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeTotalIOsRate() const { return _includeTotalIOsRate; } void UNIX_BlockStatisticsManifest::setIncludeTotalIOsRate(Boolean &value) { _includeTotalIOsRate = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOsRate(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_WRITE_HIT_IOS_RATE, getIncludeWriteHitIOsRate()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteHitIOsRate() const { return _includeWriteHitIOsRate; } void UNIX_BlockStatisticsManifest::setIncludeWriteHitIOsRate(Boolean &value) { _includeWriteHitIOsRate = value; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOsRate(CIMProperty &p) const { p = CIMProperty(PROPERTY_INCLUDE_WRITE_IOS_RATE, getIncludeWriteIOsRate()); return true; } Boolean UNIX_BlockStatisticsManifest::getIncludeWriteIOsRate() const { return _includeWriteIOsRate; } void UNIX_BlockStatisticsManifest::setIncludeWriteIOsRate(Boolean &value) { _includeWriteIOsRate = value; } Boolean UNIX_BlockStatisticsManifest::getRateElementType(CIMProperty &p) const { p = CIMProperty(PROPERTY_RATE_ELEMENT_TYPE, getRateElementType()); return true; } Uint16 UNIX_BlockStatisticsManifest::getRateElementType() const { return _rateElementType; } void UNIX_BlockStatisticsManifest::setRateElementType(Uint16 &value) { _rateElementType = value; } void UNIX_BlockStatisticsManifest::clearInstance() { _instanceID = String (""); _caption = String (""); _description = String (""); _elementName = String("BlockStatisticsManifest"); _generation = Uint64(0); _elementType = Uint16(0); _includeStartStatisticTime = Boolean(false); _includeStatisticTime = Boolean(false); _includeTotalIOs = Boolean(false); _includeKBytesTransferred = Boolean(false); _includeIOTimeCounter = Boolean(false); _includeReadIOs = Boolean(false); _includeReadHitIOs = Boolean(false); _includeReadIOTimeCounter = Boolean(false); _includeReadHitIOTimeCounter = Boolean(false); _includeKBytesRead = Boolean(false); _includeWriteIOs = Boolean(false); _includeWriteHitIOs = Boolean(false); _includeWriteIOTimeCounter = Boolean(false); _includeWriteHitIOTimeCounter = Boolean(false); _includeKBytesWritten = Boolean(false); _includeIdleTimeCounter = Boolean(false); _includeMaintOp = Boolean(false); _includeMaintTimeCounter = Boolean(false); _cSVSequence.clear(); _cSVRateSequence.clear(); _includeKBytesReadRate = Boolean(false); _includeKBytesTransferredRate = Boolean(false); _includeKBytesWrittenRate = Boolean(false); _includeMaintOpRate = Boolean(false); _includeRateIntervalEndTime = Boolean(false); _includeRateIntervalStartTime = Boolean(false); _includeReadHitIOsRate = Boolean(false); _includeReadIOsRate = Boolean(false); _includeTotalIOsRate = Boolean(false); _includeWriteHitIOsRate = Boolean(false); _includeWriteIOsRate = Boolean(false); _rateElementType = Uint16(0); } Boolean UNIX_BlockStatisticsManifest::loadInstance(const CIMInstance &instance) { clearInstance(); Uint32 propertyCount = instance.getPropertyCount(); for(Uint32 i = 0; i < propertyCount; i++) { CIMConstProperty property = instance.getProperty(i); if (String::equal(property.getName().getString(), "InstanceID")) { String instanceIDValue; property.getValue().get(instanceIDValue); setInstanceID(instanceIDValue); } else if (String::equal(property.getName().getString(), "Caption")) { String captionValue; property.getValue().get(captionValue); setCaption(captionValue); } else if (String::equal(property.getName().getString(), "Description")) { String descriptionValue; property.getValue().get(descriptionValue); setDescription(descriptionValue); } else if (String::equal(property.getName().getString(), "ElementName")) { String elementNameValue; property.getValue().get(elementNameValue); setElementName(elementNameValue); } else if (String::equal(property.getName().getString(), "Generation")) { Uint64 generationValue; property.getValue().get(generationValue); setGeneration(generationValue); } else if (String::equal(property.getName().getString(), "ElementType")) { Uint16 elementTypeValue; property.getValue().get(elementTypeValue); setElementType(elementTypeValue); } else if (String::equal(property.getName().getString(), "IncludeStartStatisticTime")) { Boolean includeStartStatisticTimeValue; property.getValue().get(includeStartStatisticTimeValue); setIncludeStartStatisticTime(includeStartStatisticTimeValue); } else if (String::equal(property.getName().getString(), "IncludeStatisticTime")) { Boolean includeStatisticTimeValue; property.getValue().get(includeStatisticTimeValue); setIncludeStatisticTime(includeStatisticTimeValue); } else if (String::equal(property.getName().getString(), "IncludeTotalIOs")) { Boolean includeTotalIOsValue; property.getValue().get(includeTotalIOsValue); setIncludeTotalIOs(includeTotalIOsValue); } else if (String::equal(property.getName().getString(), "IncludeKBytesTransferred")) { Boolean includeKBytesTransferredValue; property.getValue().get(includeKBytesTransferredValue); setIncludeKBytesTransferred(includeKBytesTransferredValue); } else if (String::equal(property.getName().getString(), "IncludeIOTimeCounter")) { Boolean includeIOTimeCounterValue; property.getValue().get(includeIOTimeCounterValue); setIncludeIOTimeCounter(includeIOTimeCounterValue); } else if (String::equal(property.getName().getString(), "IncludeReadIOs")) { Boolean includeReadIOsValue; property.getValue().get(includeReadIOsValue); setIncludeReadIOs(includeReadIOsValue); } else if (String::equal(property.getName().getString(), "IncludeReadHitIOs")) { Boolean includeReadHitIOsValue; property.getValue().get(includeReadHitIOsValue); setIncludeReadHitIOs(includeReadHitIOsValue); } else if (String::equal(property.getName().getString(), "IncludeReadIOTimeCounter")) { Boolean includeReadIOTimeCounterValue; property.getValue().get(includeReadIOTimeCounterValue); setIncludeReadIOTimeCounter(includeReadIOTimeCounterValue); } else if (String::equal(property.getName().getString(), "IncludeReadHitIOTimeCounter")) { Boolean includeReadHitIOTimeCounterValue; property.getValue().get(includeReadHitIOTimeCounterValue); setIncludeReadHitIOTimeCounter(includeReadHitIOTimeCounterValue); } else if (String::equal(property.getName().getString(), "IncludeKBytesRead")) { Boolean includeKBytesReadValue; property.getValue().get(includeKBytesReadValue); setIncludeKBytesRead(includeKBytesReadValue); } else if (String::equal(property.getName().getString(), "IncludeWriteIOs")) { Boolean includeWriteIOsValue; property.getValue().get(includeWriteIOsValue); setIncludeWriteIOs(includeWriteIOsValue); } else if (String::equal(property.getName().getString(), "IncludeWriteHitIOs")) { Boolean includeWriteHitIOsValue; property.getValue().get(includeWriteHitIOsValue); setIncludeWriteHitIOs(includeWriteHitIOsValue); } else if (String::equal(property.getName().getString(), "IncludeWriteIOTimeCounter")) { Boolean includeWriteIOTimeCounterValue; property.getValue().get(includeWriteIOTimeCounterValue); setIncludeWriteIOTimeCounter(includeWriteIOTimeCounterValue); } else if (String::equal(property.getName().getString(), "IncludeWriteHitIOTimeCounter")) { Boolean includeWriteHitIOTimeCounterValue; property.getValue().get(includeWriteHitIOTimeCounterValue); setIncludeWriteHitIOTimeCounter(includeWriteHitIOTimeCounterValue); } else if (String::equal(property.getName().getString(), "IncludeKBytesWritten")) { Boolean includeKBytesWrittenValue; property.getValue().get(includeKBytesWrittenValue); setIncludeKBytesWritten(includeKBytesWrittenValue); } else if (String::equal(property.getName().getString(), "IncludeIdleTimeCounter")) { Boolean includeIdleTimeCounterValue; property.getValue().get(includeIdleTimeCounterValue); setIncludeIdleTimeCounter(includeIdleTimeCounterValue); } else if (String::equal(property.getName().getString(), "IncludeMaintOp")) { Boolean includeMaintOpValue; property.getValue().get(includeMaintOpValue); setIncludeMaintOp(includeMaintOpValue); } else if (String::equal(property.getName().getString(), "IncludeMaintTimeCounter")) { Boolean includeMaintTimeCounterValue; property.getValue().get(includeMaintTimeCounterValue); setIncludeMaintTimeCounter(includeMaintTimeCounterValue); } else if (String::equal(property.getName().getString(), "CSVSequence")) { Array<String> cSVSequenceValue; property.getValue().get(cSVSequenceValue); setCSVSequence(cSVSequenceValue); } else if (String::equal(property.getName().getString(), "CSVRateSequence")) { Array<String> cSVRateSequenceValue; property.getValue().get(cSVRateSequenceValue); setCSVRateSequence(cSVRateSequenceValue); } else if (String::equal(property.getName().getString(), "IncludeKBytesReadRate")) { Boolean includeKBytesReadRateValue; property.getValue().get(includeKBytesReadRateValue); setIncludeKBytesReadRate(includeKBytesReadRateValue); } else if (String::equal(property.getName().getString(), "IncludeKBytesTransferredRate")) { Boolean includeKBytesTransferredRateValue; property.getValue().get(includeKBytesTransferredRateValue); setIncludeKBytesTransferredRate(includeKBytesTransferredRateValue); } else if (String::equal(property.getName().getString(), "IncludeKBytesWrittenRate")) { Boolean includeKBytesWrittenRateValue; property.getValue().get(includeKBytesWrittenRateValue); setIncludeKBytesWrittenRate(includeKBytesWrittenRateValue); } else if (String::equal(property.getName().getString(), "IncludeMaintOpRate")) { Boolean includeMaintOpRateValue; property.getValue().get(includeMaintOpRateValue); setIncludeMaintOpRate(includeMaintOpRateValue); } else if (String::equal(property.getName().getString(), "IncludeRateIntervalEndTime")) { Boolean includeRateIntervalEndTimeValue; property.getValue().get(includeRateIntervalEndTimeValue); setIncludeRateIntervalEndTime(includeRateIntervalEndTimeValue); } else if (String::equal(property.getName().getString(), "IncludeRateIntervalStartTime")) { Boolean includeRateIntervalStartTimeValue; property.getValue().get(includeRateIntervalStartTimeValue); setIncludeRateIntervalStartTime(includeRateIntervalStartTimeValue); } else if (String::equal(property.getName().getString(), "IncludeReadHitIOsRate")) { Boolean includeReadHitIOsRateValue; property.getValue().get(includeReadHitIOsRateValue); setIncludeReadHitIOsRate(includeReadHitIOsRateValue); } else if (String::equal(property.getName().getString(), "IncludeReadIOsRate")) { Boolean includeReadIOsRateValue; property.getValue().get(includeReadIOsRateValue); setIncludeReadIOsRate(includeReadIOsRateValue); } else if (String::equal(property.getName().getString(), "IncludeTotalIOsRate")) { Boolean includeTotalIOsRateValue; property.getValue().get(includeTotalIOsRateValue); setIncludeTotalIOsRate(includeTotalIOsRateValue); } else if (String::equal(property.getName().getString(), "IncludeWriteHitIOsRate")) { Boolean includeWriteHitIOsRateValue; property.getValue().get(includeWriteHitIOsRateValue); setIncludeWriteHitIOsRate(includeWriteHitIOsRateValue); } else if (String::equal(property.getName().getString(), "IncludeWriteIOsRate")) { Boolean includeWriteIOsRateValue; property.getValue().get(includeWriteIOsRateValue); setIncludeWriteIOsRate(includeWriteIOsRateValue); } else if (String::equal(property.getName().getString(), "RateElementType")) { Uint16 rateElementTypeValue; property.getValue().get(rateElementTypeValue); setRateElementType(rateElementTypeValue); } } return true; } Boolean UNIX_BlockStatisticsManifest::initialize() { return false; } Boolean UNIX_BlockStatisticsManifest::load(int &pIndex) { _instanceID = String (""); _caption = String (""); _description = String (""); _elementName = String("BlockStatisticsManifest"); _generation = Uint64(0); _elementType = Uint16(0); _includeStartStatisticTime = Boolean(false); _includeStatisticTime = Boolean(false); _includeTotalIOs = Boolean(false); _includeKBytesTransferred = Boolean(false); _includeIOTimeCounter = Boolean(false); _includeReadIOs = Boolean(false); _includeReadHitIOs = Boolean(false); _includeReadIOTimeCounter = Boolean(false); _includeReadHitIOTimeCounter = Boolean(false); _includeKBytesRead = Boolean(false); _includeWriteIOs = Boolean(false); _includeWriteHitIOs = Boolean(false); _includeWriteIOTimeCounter = Boolean(false); _includeWriteHitIOTimeCounter = Boolean(false); _includeKBytesWritten = Boolean(false); _includeIdleTimeCounter = Boolean(false); _includeMaintOp = Boolean(false); _includeMaintTimeCounter = Boolean(false); _cSVSequence.clear(); _cSVRateSequence.clear(); _includeKBytesReadRate = Boolean(false); _includeKBytesTransferredRate = Boolean(false); _includeKBytesWrittenRate = Boolean(false); _includeMaintOpRate = Boolean(false); _includeRateIntervalEndTime = Boolean(false); _includeRateIntervalStartTime = Boolean(false); _includeReadHitIOsRate = Boolean(false); _includeReadIOsRate = Boolean(false); _includeTotalIOsRate = Boolean(false); _includeWriteHitIOsRate = Boolean(false); _includeWriteIOsRate = Boolean(false); _rateElementType = Uint16(0); return false; } Boolean UNIX_BlockStatisticsManifest::finalize() { return false; } Boolean UNIX_BlockStatisticsManifest::find(const Array<CIMKeyBinding> &kbArray) { CIMKeyBinding kb; String instanceIDKey; for(Uint32 i = 0; i < kbArray.size(); i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); if (keyName.equal(PROPERTY_INSTANCE_ID)) instanceIDKey = kb.getValue(); } /* Execute find with extracted keys */ for(int i = 0; load(i); i++) { if ((String::equalNoCase(getInstanceID(), instanceIDKey))) { return true; } } return false; } Boolean UNIX_BlockStatisticsManifest::createInstance(const OperationContext &ctx) { return false; } Boolean UNIX_BlockStatisticsManifest::modifyInstance(const OperationContext &ctx) { return false; } Boolean UNIX_BlockStatisticsManifest::deleteInstance(const OperationContext &ctx) { return false; } Boolean UNIX_BlockStatisticsManifest::validateInstance() { return true; }
[ "brunolauze@msn.com" ]
brunolauze@msn.com
bca5445c038b0802a8a6073fa58d3ded2ae6407e
16cbe0227d0b1e28e228a9c61780be470e11090d
/base/include/ncs/sim/DataSpace.h
20f1bd2c2d064738abf8898631dc927dbed59e2b
[ "BSD-2-Clause" ]
permissive
hjc19951212/ncs
e3bc4ae31b93cec4b15e87dd65ad02dbd87971eb
0ae53ad7bf378675161e23a25e09468d6b383ab0
refs/heads/master
2021-08-17T07:20:40.247968
2016-01-25T22:44:11
2016-01-25T22:44:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
218
h
#pragma once namespace ncs { namespace sim { class DataSpace { public: enum Space { Unknown = 0, Global = 1, Machine = 2, Device = 3, Plugin = 4 }; }; } // namespace sim } // namespace ncs
[ "rvhoang@gmail.com" ]
rvhoang@gmail.com
225e79b3bc78124c8f655d7654ce491eae860719
7a470e92e5c0fb5e097988092bf5384d781995b4
/include/Renderer/Camera.h
8215a52d0e769ced1043284e79ba1d05c6d66911
[]
no_license
game-works/OpenGL
98212c42933d41455da678f3ad8fc7fb160187df
d41c1497ef33cfb6f21a1e642bc060bdb4dfcdf5
refs/heads/master
2020-05-29T11:29:30.127016
2016-09-06T23:53:06
2016-09-06T23:53:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,227
h
#ifndef CAMERA_H #define CAMERA_H #include <glad/glad.h> #include <glm/glm.hpp> #include <glm/detail/type_mat.hpp> #include "EventDispatcher.h" class Camera { public: Camera(EventDispatcher &dispatcher); void update(double deltaTime); glm::mat4 getViewMatrix(); glm::mat4 getProjectionMatrix(); //Based on tiles void setPosition(float x, float y); void setLimits(int x, int y); private: void moveForward(); void moveLeft(); void moveRight(); void moveBack(); void zoomIn(); void zoomOut(); void checkWithinLimits(); void resizeCallback(Data data); EventDispatcher &m_dispatcher; glm::vec2 acceleration, velocity, position; bool heldX = false; bool heldY = false; GLfloat desiredZoom = 10.0f; GLfloat ZOOM_SENSITIVITY = 100.0f; GLfloat ZOOM = 10.0f; const GLfloat ZOOM_MAX = 100.0f; const GLfloat ZOOM_MIN = 10.0f; //Max distance from origin that camera can move in pixels GLint MAX_DIST_Y = 0; GLint MAX_DIST_X = 0; GLint window_width = 0; GLint window_height = 0; }; #endif
[ "git@keringar.xyz" ]
git@keringar.xyz
7814b591549d69d8a14c6801bc11ae4058513455
e37bdad8eee22cf859d74c4a841011910c106f70
/709/B - Checkpoints.cpp
17b3b8ac392027faa4ba18e1d730f35656feda9c
[]
no_license
ashlamp08/Codeforces
be61c84afe78f0e349ca8793ba7e7e248dd2843f
bf310c2cf36402483517bf312a03b85669c5c4b6
refs/heads/master
2021-01-12T17:22:16.613992
2016-10-21T10:02:29
2016-10-21T10:02:29
71,550,410
0
1
null
2016-10-31T20:08:58
2016-10-21T09:21:43
C++
UTF-8
C++
false
false
806
cpp
#include<bits/stdc++.h> using namespace std; int main() { int n; long long a; cin>>n>>a; long long arr[n+1]; long long sumL = 0; long long sumR = 0; for(int i=0;i<n;i++) cin>>arr[i]; if(n==1) { cout<<0; return 0; } if(n==2) { cout<<min(abs(arr[0]-a),abs(arr[1]-a)); return 0; } arr[n] = a; sort(arr,arr+n+1); if(arr[0]==a) { cout<<abs(a-arr[n-1]); return 0; } if(arr[n]==a) { cout<<abs(a-arr[1]); return 0; } sumL = abs(a-arr[0]); sumR = abs(a-arr[n]); long long ans; ans = min(sumL-abs(arr[1]-arr[0]) + 2*sumR,sumR-abs(arr[n]-arr[n-1]) + 2*sumL); ans = min(ans, (sumR-abs(arr[n]-arr[n-1]))*2 + sumL); ans = min(ans, (sumL-abs(arr[0]-arr[1]))*2 + sumR); cout<<ans; return 0; }
[ "dhungana.ashok08@gmail.com" ]
dhungana.ashok08@gmail.com
2912c64f536f9518ae82b9f652a707595fa78979
310166831ca6811dc2ad11fcf134fb35e7b8f7c5
/samples/05_modern_rt/main.cpp
fa1392ed1a4dee6a385fc0bb4c88688c15c58412
[ "MIT" ]
permissive
giordi91/SirMetal
1be0d10026ec0fb43ba2ed4c0ebbe22811b662d5
394b973a78faec2fec54479f895802ddb1e580c1
refs/heads/master
2023-04-17T07:58:58.226010
2021-04-28T10:56:53
2021-04-28T10:56:53
279,854,659
32
3
null
2021-04-28T10:56:54
2020-07-15T11:51:05
C++
UTF-8
C++
false
false
235
cpp
#include "sandbox.h" #include <iostream> #if ! __has_feature(objc_arc) #error "ARC is off" #endif int main(int argc, char *args[]) { std::cout<<args[0]<<std::endl; Sandbox::SandboxApplication sand; sand.run(); return 0; }
[ "marco.giordano.work@gmail.com" ]
marco.giordano.work@gmail.com
e8272b6779bd12dffa6ddb7c2678eb92699c8ccc
3e4fd5153015d03f147e0f105db08e4cf6589d36
/Cpp/SDK/MediaCompositing_classes.h
4af2ad8ecceb93e42c2ddb367fd0e05baed4f3e2
[]
no_license
zH4x-SDK/zTorchlight3-SDK
a96f50b84e6b59ccc351634c5cea48caa0d74075
24135ee60874de5fd3f412e60ddc9018de32a95c
refs/heads/main
2023-07-20T12:17:14.732705
2021-08-27T13:59:21
2021-08-27T13:59:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,109
h
#pragma once // Name: Torchlight3, Version: 4.26.1 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // Class MediaCompositing.MovieSceneMediaPlayerPropertySection // 0x0010 (FullSize[0x00F8] - InheritedSize[0x00E8]) class UMovieSceneMediaPlayerPropertySection : public UMovieSceneSection { public: class UMediaSource* MediaSource; // 0x00E8(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) bool bLoop; // 0x00F0(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) unsigned char UnknownData_OFIK[0x7]; // 0x00F1(0x0007) MISSED OFFSET (PADDING) static UClass* StaticClass() { static auto ptr = UObject::FindClass("Class MediaCompositing.MovieSceneMediaPlayerPropertySection"); return ptr; } }; // Class MediaCompositing.MovieSceneMediaPlayerPropertyTrack // 0x0008 (FullSize[0x00B0] - InheritedSize[0x00A8]) class UMovieSceneMediaPlayerPropertyTrack : public UMovieScenePropertyTrack { public: unsigned char UnknownData_9Z2C[0x8]; // 0x00A8(0x0008) MISSED OFFSET (PADDING) static UClass* StaticClass() { static auto ptr = UObject::FindClass("Class MediaCompositing.MovieSceneMediaPlayerPropertyTrack"); return ptr; } }; // Class MediaCompositing.MovieSceneMediaSection // 0x0030 (FullSize[0x0118] - InheritedSize[0x00E8]) class UMovieSceneMediaSection : public UMovieSceneSection { public: class UMediaSource* MediaSource; // 0x00E8(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) bool bLooping; // 0x00F0(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) unsigned char UnknownData_VKNL[0x3]; // 0x00F1(0x0003) MISSED OFFSET (FIX SPACE BETWEEN PREVIOUS PROPERTY) struct FFrameNumber StartFrameOffset; // 0x00F4(0x0004) (Edit, BlueprintVisible, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) class UMediaTexture* MediaTexture; // 0x00F8(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) class UMediaSoundComponent* MediaSoundComponent; // 0x0100(0x0008) (Edit, BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) bool bUseExternalMediaPlayer; // 0x0108(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, AdvancedDisplay, HasGetValueTypeHash, NativeAccessSpecifierPublic) unsigned char UnknownData_RPOR[0x7]; // 0x0109(0x0007) MISSED OFFSET (FIX SPACE BETWEEN PREVIOUS PROPERTY) class UMediaPlayer* ExternalMediaPlayer; // 0x0110(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, AdvancedDisplay, HasGetValueTypeHash, NativeAccessSpecifierPublic) static UClass* StaticClass() { static auto ptr = UObject::FindClass("Class MediaCompositing.MovieSceneMediaSection"); return ptr; } }; // Class MediaCompositing.MovieSceneMediaTrack // 0x0018 (FullSize[0x0090] - InheritedSize[0x0078]) class UMovieSceneMediaTrack : public UMovieSceneNameableTrack { public: unsigned char UnknownData_8D96[0x8]; // 0x0078(0x0008) MISSED OFFSET (FIX SPACE BETWEEN PREVIOUS PROPERTY) TArray<class UMovieSceneSection*> MediaSections; // 0x0080(0x0010) (ExportObject, ZeroConstructor, ContainsInstancedReference, NativeAccessSpecifierPrivate) static UClass* StaticClass() { static auto ptr = UObject::FindClass("Class MediaCompositing.MovieSceneMediaTrack"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "zp2kshield@gmail.com" ]
zp2kshield@gmail.com
d554e1807b914dcfba904c5f96eeb8a43190aa74
5f975169aeb67c7cd0a08683e6b9eee253f84183
/algorithms/medium/1110. Delete Nodes And Return Forest.h
453d41b90055bacf85912d478755274dd277ef77
[ "MIT" ]
permissive
MultivacX/leetcode2020
6b743ffb0d731eea436d203ccb221be14f2346d3
83bfd675052de169ae9612d88378a704c80a50f1
refs/heads/master
2023-03-17T23:19:45.996836
2023-03-16T07:54:45
2023-03-16T07:54:45
231,091,990
0
0
null
null
null
null
UTF-8
C++
false
false
1,512
h
// 1110. Delete Nodes And Return Forest // Runtime: 32 ms, faster than 65.59% of C++ online submissions for Delete Nodes And Return Forest. // Memory Usage: 20.5 MB, less than 100.00% of C++ online submissions for Delete Nodes And Return Forest. /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: vector<TreeNode*> delNodes(TreeNode* root, vector<int>& to_delete) { vector<TreeNode*> forest; unordered_set<int> _to_delete(begin(to_delete), end(to_delete)); f(nullptr, root, _to_delete, forest); return forest; } void f(TreeNode* parent, TreeNode* node, unordered_set<int>& to_delete, vector<TreeNode*>& forest) { if (!node) return; auto l = node->left; auto r = node->right; if (to_delete.count(node->val)) { to_delete.erase(node->val); if (parent) { if (node == parent->left) parent->left = nullptr; else parent->right = nullptr; } node->left = nullptr; node->right = nullptr; // delete node; node = nullptr; } else { if (!parent) forest.push_back(node); if (to_delete.empty()) return; } f(node, l, to_delete, forest); f(node, r, to_delete, forest); } };
[ "MultivacX@2020.china" ]
MultivacX@2020.china
05dd2f47fc5202129523b83fafbdf6edc670e8aa
08e1773590911eb45d40069534b89b1ada94a2d0
/sparse_table/sq.cpp
af943681781a87a823217c0ad1b35803f1257bd6
[]
no_license
YagaoLiu/WeightedSuffixArray
22d2d2781af26b69c5fe780a0b593cb9108b7b12
70284e505c50668e6d3bbfcd49cc3f09f4cdd3cc
refs/heads/master
2022-01-09T02:33:23.237984
2019-05-27T19:39:42
2019-05-27T19:39:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,817
cpp
/** Weighted Index Copyright (C) 2016 Carl Barton, Tomasz Kociumak, Chang Liu, Solon P. Pissis and Jakub Radoszewski. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. **/ #include <iostream> #include <fstream> #include <cmath> #include <string> #include <iomanip> #include <map> #include <queue> #include <vector> #include "node.h" #include "defs.h" using namespace std; char alphabet[4] = {'A', 'C', 'G', 'T'}; map < int, Node* > token_map; vector < string > sq; vector <int> heavy_string; void heavy_position ( double ** text, vector<int> &heavy_string, int pos ) { int heavy_letter = 0; double max = text[pos][0]; for ( int i = 1; i < 4; i++ ) { if ( max < text[pos][i] ) { max = text[pos][i]; heavy_letter = i; } } heavy_string[pos] = heavy_letter; } void token_track ( Node * token_node, Node * ancestor_node, string& token_sq ) { Node * track = token_node; while ( track != ancestor_node && track != NULL ) { token_sq[track->parent->pos] = alphabet[track->edge]; for ( int i = track->parent->pos+1; i < track->pos; i++ ) token_sq[i] = alphabet[heavy_string[i]]; track = track->parent; } } void breadth_first_track ( Node * root, vector < Node * > *bft_nodes ) { queue < Node * > q; if ( !root ) { return; } for ( q.push( root ); !q.empty(); q.pop() ) { Node * temp_node = q.front(); if ( temp_node->token.size() ) bft_nodes->push_back ( temp_node ); for ( unsigned int i = 0; i < temp_node->child.size(); i++ ) q.push( temp_node->child[i] ); } } void token_request ( Node * root ) { vector < Node * > bft_nodes; breadth_first_track ( root, &bft_nodes ); for ( bft_nodes.back(); !bft_nodes.empty(); bft_nodes.pop_back() ) { Node * T = bft_nodes.back(); for ( unsigned int i = 0; i < T->token.size(); i++ ) { if ( T->coreNode ) { if ( T->coreNode->token.size() ) { T->token[i] = T->coreNode->token[0]; T->coreNode->token.erase ( T->coreNode->token.begin() ); } else { T->token[i] = T->coreNode->subToken(); } token_track ( token_map[T->token[i]], T->coreNode, sq[T->token[i]]); token_map[T->token[i]] = T; } } } } void root_token ( double z, Node * new_root, Node * root ) { int parent_token = floor ( new_root->odds * z ); int child_token = 0; for ( unsigned int i = 0; i < new_root->child.size(); i++ ) child_token += floor ( new_root->child[i]->odds * z ); int num_token = parent_token - child_token; if ( num_token ) { new_root->token.resize( num_token ); for ( int i = 0; i < num_token; i++ ) { if ( root->token.size() ) { new_root->token[i] = root->token[0]; root->token.erase ( root->token.begin() ); } else { new_root->token[i] = root->subToken(); } token_track ( token_map[new_root->token[i]], root, sq[new_root->token[i]] ); token_map[new_root->token[i]] = new_root; } } } void print_out ( Node * x ) { cout << x << ":\tpos:" << x->pos << " || edge:" << x->edge << " || parent:" << x->parent<< " || probablity:" << x->odds; if ( x->token.size() ) { cout << "\ttoken: "; for ( unsigned int i = 0; i < x->token.size(); i++ ) cout << x->token[i] << " "; } else cout << "\tno token."; cout << endl; if ( x->child.size() ) { for ( unsigned int i = 0; i < x->child.size(); i++ ) print_out ( x->child[i] ); } } void weighted_index_building( double ** text, int n, double z, string * sq_return ) { heavy_string.resize(n); for ( int i = 0; i < n; i++ ) { heavy_position ( text, heavy_string, i ); } Node ** tree; tree = new Node * [2]; tree[0] = new Node; tree[0]->parent = NULL; tree[0]->odds = 1; tree[0]->pos = n; tree[0]->token.resize ( floor(z) ); sq.resize ( floor(z) ); for ( int i = 0; i < z; i++ ) { sq[i].resize(n, 'N'); } for ( int t = 0; t < floor(z); t++ ) { tree[0]->token[t] = t; token_map[t] = tree[0]; } int i = n - 1; while ( i>= 0 ) { tree[1] = new Node; tree[1]->parent = NULL; tree[1]->odds = 1; tree[1]->pos = i; for ( int j = 0; j < 4; j++ ) { if ( text[i][j] >= 1/z ) { Node * branch = new Node; branch->Copy ( tree[0] ); branch->parent = tree[1]; branch->odds = text[i][j]; branch->edge = j ; tree[1]->child.push_back( branch ); tree[1]->child.back()->Update( text[i][j], z ); } } tree[1]->Compact( 0 ); #if 1 token_request ( tree[1] ); root_token( z, tree[1], tree[0] ); // for ( unsigned int t = 0; t < tree[1]->token.size(); t++ ) // { // int l = ( n- i ) - sq[tree[1]->token[t]].size(); // if ( l > 0 ) // sq[tree[1]->token[t]].insert ( sq[tree[1]->token[t]].begin(), l, 'N' ); // } #endif swap ( tree[0], tree[1] ); tree[1]->deleteNode(); i--; // print_out(tree[0]); // cout << "=====================================================" << endl; } #if 1 for ( int j = 0; j < z; j++ ) { token_track(token_map[j], tree[0], sq[j] ); // sq[j].insert ( 0, temp ); } for ( int j = 0; j < z; j++ ) { if ( sq[j].size() != 0 ) { sq_return->append( sq[j] ); // sq_return->push_back ( '#' ); } } // sq_return->back() = '$'; #endif tree[0]->deleteNode(); delete[] tree; heavy_string.clear(); vector<int>().swap ( heavy_string ); }
[ "chang.liu.kcl@gmail.com" ]
chang.liu.kcl@gmail.com
03096034bd175926d3bc19030fdffbc95da20ef4
6c21d920b233c0b735fa0eba8aebe8634eb85632
/src/governance-vote.h
f7f76ebd085dd7abd17548d98d8276ea18425a4c
[ "MIT" ]
permissive
chickendinnerpay/chickendinnerpay
f73f9730cc7d710c3b67f1b0a0538b519c91971c
338d6a230e8d7600090655bf690fc4d61be1dc1e
refs/heads/master
2021-05-09T02:56:56.860071
2018-01-28T21:05:18
2018-01-28T21:05:18
119,225,990
0
0
null
null
null
null
UTF-8
C++
false
false
6,807
h
// Copyright (c) 2014-2017 The chickendinner Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef GOVERNANCE_VOTE_H #define GOVERNANCE_VOTE_H #include "key.h" #include "primitives/transaction.h" #include <boost/lexical_cast.hpp> using namespace std; class CGovernanceVote; class CConnman; // INTENTION OF MASTERNODES REGARDING ITEM enum vote_outcome_enum_t { VOTE_OUTCOME_NONE = 0, VOTE_OUTCOME_YES = 1, VOTE_OUTCOME_NO = 2, VOTE_OUTCOME_ABSTAIN = 3 }; // SIGNAL VARIOUS THINGS TO HAPPEN: enum vote_signal_enum_t { VOTE_SIGNAL_NONE = 0, VOTE_SIGNAL_FUNDING = 1, // -- fund this object for it's stated amount VOTE_SIGNAL_VALID = 2, // -- this object checks out in sentinel engine VOTE_SIGNAL_DELETE = 3, // -- this object should be deleted from memory entirely VOTE_SIGNAL_ENDORSED = 4, // -- officially endorsed by the network somehow (delegation) VOTE_SIGNAL_NOOP1 = 5, // FOR FURTHER EXPANSION VOTE_SIGNAL_NOOP2 = 6, VOTE_SIGNAL_NOOP3 = 7, VOTE_SIGNAL_NOOP4 = 8, VOTE_SIGNAL_NOOP5 = 9, VOTE_SIGNAL_NOOP6 = 10, VOTE_SIGNAL_NOOP7 = 11, VOTE_SIGNAL_NOOP8 = 12, VOTE_SIGNAL_NOOP9 = 13, VOTE_SIGNAL_NOOP10 = 14, VOTE_SIGNAL_NOOP11 = 15, VOTE_SIGNAL_CUSTOM1 = 16, // SENTINEL CUSTOM ACTIONS VOTE_SIGNAL_CUSTOM2 = 17, // 16-35 VOTE_SIGNAL_CUSTOM3 = 18, VOTE_SIGNAL_CUSTOM4 = 19, VOTE_SIGNAL_CUSTOM5 = 20, VOTE_SIGNAL_CUSTOM6 = 21, VOTE_SIGNAL_CUSTOM7 = 22, VOTE_SIGNAL_CUSTOM8 = 23, VOTE_SIGNAL_CUSTOM9 = 24, VOTE_SIGNAL_CUSTOM10 = 25, VOTE_SIGNAL_CUSTOM11 = 26, VOTE_SIGNAL_CUSTOM12 = 27, VOTE_SIGNAL_CUSTOM13 = 28, VOTE_SIGNAL_CUSTOM14 = 29, VOTE_SIGNAL_CUSTOM15 = 30, VOTE_SIGNAL_CUSTOM16 = 31, VOTE_SIGNAL_CUSTOM17 = 32, VOTE_SIGNAL_CUSTOM18 = 33, VOTE_SIGNAL_CUSTOM19 = 34, VOTE_SIGNAL_CUSTOM20 = 35 }; static const int MAX_SUPPORTED_VOTE_SIGNAL = VOTE_SIGNAL_ENDORSED; /** * Governance Voting * * Static class for accessing governance data */ class CGovernanceVoting { public: static vote_outcome_enum_t ConvertVoteOutcome(std::string strVoteOutcome); static vote_signal_enum_t ConvertVoteSignal(std::string strVoteSignal); static std::string ConvertOutcomeToString(vote_outcome_enum_t nOutcome); static std::string ConvertSignalToString(vote_signal_enum_t nSignal); }; // // CGovernanceVote - Allow a masternode node to vote and broadcast throughout the network // class CGovernanceVote { friend bool operator==(const CGovernanceVote& vote1, const CGovernanceVote& vote2); friend bool operator<(const CGovernanceVote& vote1, const CGovernanceVote& vote2); private: bool fValid; //if the vote is currently valid / counted bool fSynced; //if we've sent this to our peers int nVoteSignal; // see VOTE_ACTIONS above CTxIn vinMasternode; uint256 nParentHash; int nVoteOutcome; // see VOTE_OUTCOMES above int64_t nTime; std::vector<unsigned char> vchSig; public: CGovernanceVote(); CGovernanceVote(COutPoint outpointMasternodeIn, uint256 nParentHashIn, vote_signal_enum_t eVoteSignalIn, vote_outcome_enum_t eVoteOutcomeIn); bool IsValid() const { return fValid; } bool IsSynced() const { return fSynced; } int64_t GetTimestamp() const { return nTime; } vote_signal_enum_t GetSignal() const { return vote_signal_enum_t(nVoteSignal); } vote_outcome_enum_t GetOutcome() const { return vote_outcome_enum_t(nVoteOutcome); } const uint256& GetParentHash() const { return nParentHash; } void SetTime(int64_t nTimeIn) { nTime = nTimeIn; } void SetSignature(const std::vector<unsigned char>& vchSigIn) { vchSig = vchSigIn; } bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode); bool IsValid(bool fSignatureCheck) const; void Relay(CConnman& connman) const; std::string GetVoteString() const { return CGovernanceVoting::ConvertOutcomeToString(GetOutcome()); } const COutPoint& GetMasternodeOutpoint() const { return vinMasternode.prevout; } /** * GetHash() * * GET UNIQUE HASH WITH DETERMINISTIC VALUE OF THIS SPECIFIC VOTE */ uint256 GetHash() const { CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); ss << vinMasternode; ss << nParentHash; ss << nVoteSignal; ss << nVoteOutcome; ss << nTime; return ss.GetHash(); } std::string ToString() const { std::ostringstream ostr; ostr << vinMasternode.ToString() << ":" << nTime << ":" << CGovernanceVoting::ConvertOutcomeToString(GetOutcome()) << ":" << CGovernanceVoting::ConvertSignalToString(GetSignal()); return ostr.str(); } /** * GetTypeHash() * * GET HASH WITH DETERMINISTIC VALUE OF MASTERNODE-VIN/PARENT-HASH/VOTE-SIGNAL * * This hash collides with previous masternode votes when they update their votes on governance objects. * With 12.1 there's various types of votes (funding, valid, delete, etc), so this is the deterministic hash * that will collide with the previous vote and allow the system to update. * * -- * * We do not include an outcome, because that can change when a masternode updates their vote from yes to no * on funding a specific project for example. * We do not include a time because it will be updated each time the vote is updated, changing the hash */ uint256 GetTypeHash() const { // CALCULATE HOW TO STORE VOTE IN governance.mapVotes CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); ss << vinMasternode; ss << nParentHash; ss << nVoteSignal; // -- no outcome // -- timeless return ss.GetHash(); } ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(vinMasternode); READWRITE(nParentHash); READWRITE(nVoteOutcome); READWRITE(nVoteSignal); READWRITE(nTime); READWRITE(vchSig); } }; /** * 12.1.1 - CGovernanceVoteManager * ------------------------------- * GetVote(name, yes_no): - caching function - mark last accessed votes - load serialized files from filesystem if needed - calc answer - return result CacheUnused(): - Cache votes if lastused > 12h/24/48/etc */ #endif
[ "skywalk819@gmail.com" ]
skywalk819@gmail.com
6e96d669a8abb5ef818fedc886810691bc2b1c81
5354bf62bc7dcb890634a3cd0ed04ce3d8effca4
/0811/test1.cpp
32440913e1c6242f701e83feb943f7b486e3170f
[ "MIT" ]
permissive
xierensong/cppPGround
ad88dcbc5a8430ddac6f467e8a8c421c70ad7ad2
35fe41eb53269357452c59a536c17edace3424da
refs/heads/master
2020-07-02T23:12:03.932360
2019-10-09T01:22:23
2019-10-09T01:22:23
201,700,146
0
0
null
null
null
null
UTF-8
C++
false
false
268
cpp
#include<bits/stdc++.h> using namespace std; int main() { cout << "hello, my vs code!" << endl; vector<string> strings{"hello", " ", "world", "!"}; for (auto str:strings) { cout << str << ' '; } cout << endl; return 0; }
[ "283318608@qq.com" ]
283318608@qq.com
b846855bf5952e85503891784618a69c97bc8303
944079085751d03a9013d75060515c04aed9fff9
/src/Block.cpp
dd1b11fdee43ccf003c2fc41d5acab6ae8510f80
[]
no_license
EnterCheery/RCCT-1
fee4485c26f8415aee22a94307909a05230cec06
147cc05ba3ba4454c86f9b429f09df6c3bde5c0c
refs/heads/main
2023-02-25T22:53:35.016194
2021-01-29T05:10:50
2021-01-29T05:10:50
null
0
0
null
null
null
null
GB18030
C++
false
false
5,045
cpp
#include "Block.h" #include <iostream> #include <string> #include <regex> string Block::getTitle() { return title; } string Block::getType() { return type; } string Block::getNextTrue() { return next_true_block; } string Block::getNextFalse() { return next_false_block; } string Block::getPreds1() { return preds_1; } string Block::getPreds2() { return preds_2; } int Block::getLastLine() { return last_line_num; } vector<string> Block::getContent() { return content; } //get function void Block::setTitle(string title) { Block::title = title; } void Block::setTtileAndPreds(string oneline) { int p, q, r; //positions of the key chars //string title, preds_1, preds_2;; //the block name of current block and the two preds p = oneline.find(":"); title = oneline.substr(0, p); //cout << "titl:_" << title << endl; if ((q = oneline.find("preds")) != string::npos) { if ((r = oneline.find(",")) != string::npos) { //if there are two preds preds_1 = oneline.substr(q + 9, r - q - 9); preds_2 = oneline.substr(r + 3); //cout << "prdes1:_" << preds_1 << "_" << " prdes2:_" << preds_2 << "__" << endl; } else { preds_1 = oneline.substr(q + 9); //cout << "prdes1:_" << preds_1 << "_" << endl; } } } void Block::DecideType() { //Compile-according to the name of the block regex loop_cond("[for|while]+.cond[0-9]*"); //Regular matching, identify whether it is a cond block regex loop_body("[for|while]+.body[0-9]*"); //whether it is a body block smatch s; if (regex_search(title, s, loop_cond)) { type = "loop_cond"; } else if (regex_search(title, s, loop_body)) { type = "loop_body"; } else type = "other"; //Decompile //loop cond-according to the key instrctions of the block //regex phi_1("phi i64"), phi_2("phi %struct.Memory\\* "); regex phi("phi"); if (!preds_1.empty() && !preds_2.empty()) { //two preds are not null //cout << "the first :" << content[1] << endl; //cout << "the second :" << content[2] << endl; if (regex_search(content[1], s, phi) && regex_search(content[2], s, phi)) { //cout << "decompile loop cond foud" << endl; type = "loop_cond"; } } //loop body-according to the type of the preds } //old available void Block::setType(string type) { Block::type = type; } void Block::setNextLabels(bool isDecomplie) { //vector <string> names; string oneline = content.back(); int q, r; //positions of the key chars //br i1 %cmp, label %for.body, label %for.end br label %for.inc52 if (oneline.find("ret") != string::npos) { //ret is the last block next_true_block = next_false_block = ""; } else { q = oneline.find("label"); if ((r = oneline.find(",", q)) != string::npos) { //if there are two preds next_true_block = oneline.substr(q + 7, r - q - 7); next_false_block = oneline.substr(r + 9); if (isDecomplie) { //swap string temp = next_true_block; next_true_block = next_false_block; next_false_block = temp; } } else { next_true_block = oneline.substr(q + 7); next_false_block = ""; } } //cout << "true_label:_" << truelabel << "_" << " false_label:_" << falselabel << "_" << endl; } void Block::setNextTrue(string label) { next_true_block = label; } void Block::setNextFalse(string label) { next_false_block = label; } void Block::setPreds1(string preds1) { preds_1 = preds1; } void Block::setPreds2(string preds2) { preds_2 = preds2; } void Block::setLastLine(int linenum) { last_line_num = linenum; } void Block::setContent(string line) { content.push_back(line); } void Block::cleanContent() { content.clear(); } void Block::showBlock() { std::cout << "type:_" << type << std::endl; std::cout << "title and preds:_" << title << "_" << preds_1 << "_" << preds_2 << std::endl; //should add the <string>, becasue 简单的说就是string头文件和iostream头文件都有对string类型的声明。 //如果在程序中使用输入输出流iostream对string类型进行输入输出操作时程序就会报错。其原因在于iostream头文件中并没有重载与string类型相关的输入输出操作符,而该操作符的重载是在string头文件中实现的。 std::cout << "next two:-----" << next_true_block << "-----" << next_false_block << std::endl; std::cout << "line num:~." << last_line_num << ".~" << std::endl; std::cout << "---------------------------------------------" << std::endl; for (int i = 0; i < content.size(); i++) { std::cout << content[i] << std::endl; } std::cout << "---------------------------------------------" << std::endl; } Block::Block() { } Block::~Block() { } string Loop_cond_block::getRange() { return range; } string Loop_cond_block::getRangeVar() { return range_var; } void Loop_cond_block::setRange(string range) { Loop_cond_block::range = range; } void Loop_cond_block::setRangeVar(string var) { range_var = var; } string Loop_body_block::getPatternType() { vector<std::string> bodycontent = Loop_body_block::getContent(); return bodycontent[0]; }
[ "leibo@hust.edu.cn" ]
leibo@hust.edu.cn
68be9f7d5991e0548cdabfbc74da222850e4de4a
b03e4ee8cdf74e9da36d1e5dbf80fcce95e14dec
/output/name-mangler.cpp
5cd156d3867fff785ed3cbc90ede6dfab1ce96e4
[]
no_license
zheplusplus/stekin
5e60b2761ec91721c257b14f3df88874e2379f03
6578e45d78b0840564e9c3feeb2f2eb1722ce6b7
refs/heads/master
2022-10-04T18:22:10.663671
2012-09-27T09:18:39
2012-09-27T09:18:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
605
cpp
#include <util/string.h> #include "name-mangler.h" std::string output::formFuncName(util::serial_num func_sn) { return "_stk_func_template_" + util::str(func_sn.n); } std::string output::formType(std::string const& type_name) { return "_stk_type_" + type_name; } std::string output::formListType(std::string const& member_type_exported_name) { return "_stk_list<" + member_type_exported_name + " >"; } std::string output::emptyListType() { return "_stk_empty_list_type"; } std::string output::formFuncReferenceType(int size) { return "_stk_composite<" + util::str(size) + '>'; }
[ "Lene13@gmail.com" ]
Lene13@gmail.com
283446a367c3867a77e8dc2e5d8b863491ce4643
547a0e37998c836be10ee00f13b1cf201a381de5
/3.6小节——入门模拟->字符串处理/ProblemH.cpp
4af89c1349a53b8c6f2b5e968acd3284463eda62
[]
no_license
hegongshan/algorithm-notes
7232c3b3868f1a6ca4603756adc92edb3facbf6d
59e1ab7146858e5a4b4b11c9b7459289e2a93f16
refs/heads/master
2020-04-29T11:41:02.881872
2019-08-06T15:35:39
2019-08-06T15:35:39
176,108,059
0
0
null
null
null
null
UTF-8
C++
false
false
334
cpp
#include <cstdio> int main() { int m; scanf("%d", &m); char str[m][21]; for (int i = 0; i < m; i++) { scanf("%s", str[i]); int start = i >= 3 ? i - 3 : 0; // 逆序输出 for (int j = i; j >= start; j--) { printf("%d=%s", (i - j + 1), str[j]); if (j > 0) { printf(" "); } } printf("\n"); } return 0; }
[ "hegongshan@qq.com" ]
hegongshan@qq.com
43a42f2eae6d10c1bc0f26a42a4702315737683f
26e57f984d31b303c4aa1c67f47035a6799a0d84
/Lesson_3/task_1/main.cpp
a1085fb1981af143463759a18073782a29c05abc
[]
no_license
danilglinianiy/NG_2020_Danil_Glinianiy
4cb30955d602c2d1de20dfc9b9c8f20c230ad68c
12ea6e0154954dccff24d16cc20163718ee47680
refs/heads/master
2023-02-23T21:22:16.156252
2021-01-30T15:31:46
2021-01-30T15:31:46
334,214,230
0
0
null
null
null
null
UTF-8
C++
false
false
577
cpp
#include <iostream> using namespace std; int main() { char str[1000]; unsigned int word = 0; unsigned int i = 1; bool condition1 = false, condition2 = false; cout << "Enter string: "; cin.getline(str,1000); while(str[i] !='\0'){ condition1 = ((str[i] >= 'A') && (str[i]<='Z')) || ((str[i]>='a') && (str[i]<='z')); condition2 = !(((str[i+1] >= 'A') && (str[i+1]<='Z')) || ((str[i+1]>='a') && (str[i+1]<='z')) ); if ((condition1) && (condition2)) word++; i++; } cout<<"Result: "<<word<<endl; }
[ "danil_grant@danil.grant" ]
danil_grant@danil.grant
919606bf6a956ebff9d72e94058053eec60dadf3
34a61f441b3502d95570a538baf0735cd568b2e9
/Codechef/SNCKQL19/QUALPREL.cpp
fea0713d941660d858dbd345c3ebe9fc27e7df59
[ "MIT" ]
permissive
vishalpolley/Competitive-Programming
a68049f71ddbf1421ef433edec43dd0e17bbc0d4
da872198ad73538e244310e923e336b6ee148bc5
refs/heads/master
2021-06-29T15:24:34.110495
2019-10-17T06:22:04
2019-10-17T06:22:04
152,064,751
1
1
MIT
2023-03-11T12:09:56
2018-10-08T10:55:15
C++
UTF-8
C++
false
false
516
cpp
#include <bits/stdc++.h> using namespace std; int main() { // freopen("../../in.in", "r", stdin); ios_base::sync_with_stdio(false); int t; cin >> t; while(t--) { int n, k, c; cin >> n >> k; uint64_t *arr = new uint64_t[n]; for(int i = 0; i < n; ++i) cin >> arr[i]; sort(arr, arr + n, greater<uint64_t>()); c = k-1; while(arr[c] == arr[k-1] && c < n) c++; cout << c << endl; delete arr; } return 0; }
[ "vishalpolley290996@gmail.com" ]
vishalpolley290996@gmail.com
53866aef876202275cd235238e939a54437a90fb
cc13bdb0f445b8acf6bec24946fcfb5e854989b6
/Pods/Realm/include/core/realm/mixed.hpp
7584f469c7608994891c1d43b56be779e4a3fd99
[ "MIT", "Apache-2.0", "LicenseRef-scancode-generic-export-compliance", "LicenseRef-scancode-realm-platform-extension-2017" ]
permissive
devMEremenko/XcodeBenchmark
59eaf0f7d6cdaead6338511431489d9d2bf0bbb5
3aaaa6aa4400a20513dd4b6fdb372c48b8c9e772
refs/heads/master
2023-09-04T08:37:51.014081
2023-07-25T23:37:37
2023-07-25T23:37:37
288,524,849
2,335
346
MIT
2023-09-08T16:52:16
2020-08-18T17:47:47
Swift
UTF-8
C++
false
false
10,226
hpp
/************************************************************************* * * Copyright 2016 Realm 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 REALM_MIXED_HPP #define REALM_MIXED_HPP #include <cstdint> // int64_t - not part of C++03, not even required by C++11 (see C++11 section 18.4.1) #include <cstddef> // size_t #include <cstring> #include <realm/keys.hpp> #include <realm/binary_data.hpp> #include <realm/data_type.hpp> #include <realm/string_data.hpp> #include <realm/timestamp.hpp> #include <realm/util/assert.hpp> #include <realm/utilities.hpp> namespace realm { /// This class represents a polymorphic Realm value. /// /// At any particular moment an instance of this class stores a /// definite value of a definite type. If, for instance, that is an /// integer value, you may call get<int64_t>() to extract that value. You /// may call get_type() to discover what type of value is currently /// stored. Calling get<int64_t>() on an instance that does not store an /// integer, has undefined behavior, and likewise for all the other /// types that can be stored. /// /// It is crucial to understand that the act of extracting a value of /// a particular type requires definite knowledge about the stored /// type. Calling a getter method for any particular type, that is not /// the same type as the stored value, has undefined behavior. /// /// While values of numeric types are contained directly in a Mixed /// instance, character and binary data are merely referenced. A Mixed /// instance never owns the referenced data, nor does it in any other /// way attempt to manage its lifetime. /// /// For compatibility with C style strings, when a string (character /// data) is stored in a Realm database, it is always followed by a /// terminating null character. This is also true when strings are /// stored in a mixed type column. This means that in the following /// code, if the 'mixed' value of the 8th row stores a string, then \c /// c_str will always point to a null-terminated string: /// /// \code{.cpp} /// /// const char* c_str = my_table[7].mixed.data(); // Always null-terminated /// /// \endcode /// /// Note that this assumption does not hold in general for strings in /// instances of Mixed. Indeed there is nothing stopping you from /// constructing a new Mixed instance that refers to a string without /// a terminating null character. /// /// At the present time no soultion has been found that would allow /// for a Mixed instance to directly store a reference to a table. The /// problem is roughly as follows: From most points of view, the /// desirable thing to do, would be to store the table reference in a /// Mixed instance as a plain pointer without any ownership /// semantics. This would have no negative impact on the performance /// of copying and destroying Mixed instances, and it would serve just /// fine for passing a table as argument when setting the value of an /// entry in a mixed column. In that case a copy of the referenced /// table would be inserted into the mixed column. /// /// On the other hand, when retrieving a table reference from a mixed /// column, storing it as a plain pointer in a Mixed instance is no /// longer an acceptable option. The complex rules for managing the /// lifetime of a Table instance, that represents a subtable, /// necessitates the use of a "smart pointer" such as /// TableRef. Enhancing the Mixed class to be able to act as a /// TableRef would be possible, but would also lead to several new /// problems. One problem is the risk of a Mixed instance outliving a /// stack allocated Table instance that it references. This would be a /// fatal error. Another problem is the impact that the nontrivial /// table reference has on the performance of copying and destroying /// Mixed instances. /// /// \sa StringData class Mixed { public: Mixed() noexcept : m_type(0) { } Mixed(util::None) noexcept : Mixed() { } Mixed(int i) noexcept : Mixed(int64_t(i)) { } Mixed(int64_t) noexcept; Mixed(bool) noexcept; Mixed(float) noexcept; Mixed(double) noexcept; Mixed(util::Optional<int64_t>) noexcept; Mixed(util::Optional<bool>) noexcept; Mixed(util::Optional<float>) noexcept; Mixed(util::Optional<double>) noexcept; Mixed(StringData) noexcept; Mixed(BinaryData) noexcept; Mixed(Timestamp) noexcept; Mixed(ObjKey) noexcept; // These are shortcuts for Mixed(StringData(c_str)), and are // needed to avoid unwanted implicit conversion of char* to bool. Mixed(char* c_str) noexcept : Mixed(StringData(c_str)) { } Mixed(const char* c_str) noexcept : Mixed(StringData(c_str)) { } Mixed(const std::string& s) noexcept : Mixed(StringData(s)) { } ~Mixed() noexcept { } DataType get_type() const noexcept { REALM_ASSERT(m_type); return DataType(m_type - 1); } template <class T> T get() const noexcept; // These functions are kept to be backwards compatible int64_t get_int() const; bool get_bool() const; float get_float() const; double get_double() const; StringData get_string() const; BinaryData get_binary() const; Timestamp get_timestamp() const; bool is_null() const; int compare(const Mixed& b) const; bool operator==(const Mixed& other) const { return compare(other) == 0; } bool operator!=(const Mixed& other) const { return compare(other) != 0; } private: friend std::ostream& operator<<(std::ostream& out, const Mixed& m); uint32_t m_type; union { int32_t short_val; uint32_t ushort_val; }; union { int64_t int_val; bool bool_val; float float_val; double double_val; const char* str_val; }; }; // Implementation: inline Mixed::Mixed(int64_t v) noexcept { m_type = type_Int + 1; int_val = v; } inline Mixed::Mixed(bool v) noexcept { m_type = type_Bool + 1; bool_val = v; } inline Mixed::Mixed(float v) noexcept { m_type = type_Float + 1; float_val = v; } inline Mixed::Mixed(double v) noexcept { m_type = type_Double + 1; double_val = v; } inline Mixed::Mixed(util::Optional<int64_t> v) noexcept { if (v) { m_type = type_Int + 1; int_val = *v; } else { m_type = 0; } } inline Mixed::Mixed(util::Optional<bool> v) noexcept { if (v) { m_type = type_Bool + 1; bool_val = *v; } else { m_type = 0; } } inline Mixed::Mixed(util::Optional<float> v) noexcept { if (v) { m_type = type_Float + 1; float_val = *v; } else { m_type = 0; } } inline Mixed::Mixed(util::Optional<double> v) noexcept { if (v) { m_type = type_Double + 1; double_val = *v; } else { m_type = 0; } } inline Mixed::Mixed(StringData v) noexcept { if (!v.is_null()) { m_type = type_String + 1; str_val = v.data(); ushort_val = uint32_t(v.size()); } else { m_type = 0; } } inline Mixed::Mixed(BinaryData v) noexcept { if (!v.is_null()) { m_type = type_Binary + 1; str_val = v.data(); ushort_val = uint32_t(v.size()); } else { m_type = 0; } } inline Mixed::Mixed(Timestamp v) noexcept { if (!v.is_null()) { m_type = type_Timestamp + 1; int_val = v.get_seconds(); short_val = v.get_nanoseconds(); } else { m_type = 0; } } inline Mixed::Mixed(ObjKey v) noexcept { if (v) { m_type = type_Link + 1; int_val = v.value; } else { m_type = 0; } } template <> inline int64_t Mixed::get<int64_t>() const noexcept { REALM_ASSERT(get_type() == type_Int); return int_val; } inline int64_t Mixed::get_int() const { return get<int64_t>(); } template <> inline bool Mixed::get<bool>() const noexcept { REALM_ASSERT(get_type() == type_Bool); return bool_val; } inline bool Mixed::get_bool() const { return get<bool>(); } template <> inline float Mixed::get<float>() const noexcept { REALM_ASSERT(get_type() == type_Float); return float_val; } inline float Mixed::get_float() const { return get<float>(); } template <> inline double Mixed::get<double>() const noexcept { REALM_ASSERT(get_type() == type_Double); return double_val; } inline double Mixed::get_double() const { return get<double>(); } template <> inline StringData Mixed::get<StringData>() const noexcept { REALM_ASSERT(get_type() == type_String); return StringData(str_val, ushort_val); } inline StringData Mixed::get_string() const { return get<StringData>(); } template <> inline BinaryData Mixed::get<BinaryData>() const noexcept { REALM_ASSERT(get_type() == type_Binary); return BinaryData(str_val, ushort_val); } inline BinaryData Mixed::get_binary() const { return get<BinaryData>(); } template <> inline Timestamp Mixed::get<Timestamp>() const noexcept { REALM_ASSERT(get_type() == type_Timestamp); return Timestamp(int_val, short_val); } inline Timestamp Mixed::get_timestamp() const { return get<Timestamp>(); } template <> inline ObjKey Mixed::get<ObjKey>() const noexcept { REALM_ASSERT(get_type() == type_Link); return ObjKey(int_val); } inline bool Mixed::is_null() const { return (m_type == 0); } std::ostream& operator<<(std::ostream& out, const Mixed& m); } // namespace realm #endif // REALM_MIXED_HPP
[ "devMEremenko@gmail.com" ]
devMEremenko@gmail.com
a96350e50c22c58a7ef711fa972372aed4986cb7
327aaf871302aa9a725b5f6abded9477e46976ac
/external_tests/normal_dist_functions_et.h
2d26837a046370b4d5a61ad33b71a10f0452649d
[]
no_license
MichalSara99/sse_vectorised_functions_x64_tests
904f1f45968f2fbd050e5637e18ac9a40c2aeb08
6dca8b211fcdbd3de8acf3b6e15bd94b27bb3197
refs/heads/master
2023-04-17T03:32:53.793091
2021-05-03T16:20:12
2021-05-03T16:20:12
363,983,195
0
0
null
null
null
null
UTF-8
C++
false
false
14,455
h
#pragma once #if !defined(_NORMAL_DIST_FUNCTIONS_ET) #define _NORMAL_DIST_FUNCTIONS_ET #include <chrono> #include <iomanip> #include <iostream> #include <random> #include <sse_math_x64_lib.h> #include "macros/sse_macros.h" using namespace sse_normal_distribution; float norm_cdf(float x) { const float pi = sse_constants::pi<float>(); float ind = 0.0f; if (x <= 0.0f) ind = 1.0f; x = std::abs(x); float const cst = 1.0f / (std::sqrt(2.0f * pi)); float const first = std::exp(-0.5f * x * x); float const second = 0.226f + 0.64f * x + 0.33f * std::sqrt(x * x + 3.0f); float const res = 1.0f - ((first / second) * cst); return std::abs(ind - res); } double norm_cdf(double x) { const double pi = sse_constants::pi<double>(); double ind = 0.0; if (x <= 0.0) ind = 1.0; x = std::abs(x); double const cst = 1.0 / (std::sqrt(2.0 * pi)); double const first = std::exp(-0.5 * x * x); double const second = 0.226 + 0.64 * x + 0.33 * std::sqrt(x * x + 3.0); double const res = 1.0 - ((first / second) * cst); return std::abs(ind - res); } void testBasicNormCDFSSEDouble() { int const n = 16 + 1; std::size_t const align = 16; double *x = sse_utility::aligned_alloc<double>(n, align); double *res1 = sse_utility::aligned_alloc<double>(n, align); double *res2 = sse_utility::aligned_alloc<double>(n, align); // test some basic known values: const double pi = sse_constants::pi<double>(); x[0] = 0.0; x[1] = pi / 2.0; x[2] = pi; x[3] = 3.0 * pi / 2.0; x[4] = 5.0 * pi / 4.0; x[5] = 2.0 * pi; x[6] = 4.0 * pi; x[7] = 3.0 * pi; x[8] = 6.0 * pi / 3.0; x[9] = -2.0 * pi; x[10] = -pi / 4.0; x[11] = 7.0 * pi / 4.0; x[12] = 0.5; x[13] = pi / 3.0; x[14] = 3.5; x[15] = 4.0 * pi / 3.0; x[16] = 10.2; auto start_asm = std::chrono::system_clock::now(); bool rc1 = norm_cdf_sse(x, n, res1); auto end_asm = std::chrono::system_clock::now(); auto elapsed_asm = std::chrono::duration<double>(end_asm - start_asm).count(); auto start_cpp = std::chrono::system_clock::now(); for (int i = 0; i < n; ++i) { res2[i] = norm_cdf(x[i]); } auto end_cpp = std::chrono::system_clock::now(); auto elapsed_cpp = std::chrono::duration<double>(end_cpp - start_cpp).count(); SSE_ASSERT(rc1 == 1, "Failure in packed norm CDF SSE occured"); std::cout << " C++ Assembly (SSE) Difference\n"; std::cout << "=========================================================\n\n"; for (int i = 0; i < n; ++i) { std::cout << i << " | " << res2[i]; std::cout << " | " << res1[i]; std::cout << " | " << (res1[i] - res2[i]) << "\n"; } std::cout << "=========================================================\n\n"; std::cout << "\n" << "Elapsed (C++): " << elapsed_cpp; std::cout << "\n" << "Elapsed (Assembly): " << elapsed_asm << "\n"; sse_utility::aligned_free(x); sse_utility::aligned_free(res1); sse_utility::aligned_free(res2); } void testBasicNormCDFSSEFloat() { int const n = 16 + 1; std::size_t const align = 16; float *x = sse_utility::aligned_alloc<float>(n, align); float *res1 = sse_utility::aligned_alloc<float>(n, align); float *res2 = sse_utility::aligned_alloc<float>(n, align); // test some basic known values: const float pi = sse_constants::pi<float>(); x[0] = 0.0f; x[1] = pi / 2.0f; x[2] = pi; x[3] = 3.0f * pi / 2.0f; x[4] = 5.0f * pi / 4.0f; x[5] = 2.0f * pi; x[6] = 4.0f * pi; x[7] = 3.0f * pi; x[8] = 6.0f * pi / 3.0f; x[9] = -2.0f * pi; x[10] = -pi / 4.0f; x[11] = 7.0f * pi / 4.0f; x[12] = 0.5f; x[13] = pi / 3.0f; x[14] = 3.5f; x[15] = 4.0f * pi / 3.0f; x[16] = 10.2f; auto start_asm = std::chrono::system_clock::now(); bool rc1 = norm_cdf_sse(x, n, res1); auto end_asm = std::chrono::system_clock::now(); auto elapsed_asm = std::chrono::duration<double>(end_asm - start_asm).count(); auto start_cpp = std::chrono::system_clock::now(); for (int i = 0; i < n; ++i) { res2[i] = norm_cdf(x[i]); } auto end_cpp = std::chrono::system_clock::now(); auto elapsed_cpp = std::chrono::duration<double>(end_cpp - start_cpp).count(); SSE_ASSERT(rc1 == 1, "Failure in packed norm CDF SSE occured"); std::cout << " C++ Assembly (SSE) Difference\n"; std::cout << "=========================================================\n\n"; for (int i = 0; i < n; ++i) { std::cout << i << " | " << res2[i]; std::cout << " | " << res1[i]; std::cout << " | " << (res1[i] - res2[i]) << "\n"; } std::cout << "=========================================================\n\n"; std::cout << "\n" << "Elapsed (C++): " << elapsed_cpp; std::cout << "\n" << "Elapsed (Assembly): " << elapsed_asm << "\n"; sse_utility::aligned_free(x); sse_utility::aligned_free(res1); sse_utility::aligned_free(res2); } float norm_pdf(float x) { const float pi = sse_constants::pi<float>(); float const cst = 1.0f / (std::sqrt(2.0f * pi)); float const first = std::exp(-0.5f * x * x); return cst * first; } double norm_pdf(double x) { const double pi = sse_constants::pi<double>(); double const cst = 1.0 / (std::sqrt(2.0 * pi)); double const first = std::exp(-0.5 * x * x); return cst * first; } void testBasicNormPDFSSEDouble() { int const n = 16 + 1; std::size_t const align = 16; double *x = sse_utility::aligned_alloc<double>(n, align); double *res1 = sse_utility::aligned_alloc<double>(n, align); double *res2 = sse_utility::aligned_alloc<double>(n, align); // test some basic known values: const double pi = sse_constants::pi<double>(); x[0] = 0.0; x[1] = pi / 2.0; x[2] = pi; x[3] = 3.0 * pi / 2.0; x[4] = 5.0 * pi / 4.0; x[5] = 2.0 * pi; x[6] = 4.0 * pi; x[7] = 3.0 * pi; x[8] = 6.0 * pi / 3.0; x[9] = -2.0 * pi; x[10] = -pi / 4.0; x[11] = 7.0 * pi / 4.0; x[12] = 0.5; x[13] = pi / 3.0; x[14] = 3.5; x[15] = 4.0 * pi / 3.0; x[16] = 10.3; auto start_asm = std::chrono::system_clock::now(); bool rc1 = norm_pdf_sse(x, n, res1); auto end_asm = std::chrono::system_clock::now(); auto elapsed_asm = std::chrono::duration<double>(end_asm - start_asm).count(); auto start_cpp = std::chrono::system_clock::now(); for (int i = 0; i < n; ++i) { res2[i] = norm_pdf(x[i]); } auto end_cpp = std::chrono::system_clock::now(); auto elapsed_cpp = std::chrono::duration<double>(end_cpp - start_cpp).count(); SSE_ASSERT(rc1 == 1, "Failure in packed norm PDF SSE occured"); std::cout << " C++ Assembly (SSE) Difference\n"; std::cout << "=========================================================\n\n"; for (int i = 0; i < n; ++i) { std::cout << i << " | " << res2[i]; std::cout << " | " << res1[i]; std::cout << " | " << (res1[i] - res2[i]) << "\n"; } std::cout << "=========================================================\n\n"; std::cout << "\n" << "Elapsed (C++): " << elapsed_cpp; std::cout << "\n" << "Elapsed (Assembly): " << elapsed_asm << "\n"; sse_utility::aligned_free(x); sse_utility::aligned_free(res1); sse_utility::aligned_free(res2); } void testBasicNormPDFSSEFloat() { int const n = 16 + 1; std::size_t const align = 16; float *x = sse_utility::aligned_alloc<float>(n, align); float *res1 = sse_utility::aligned_alloc<float>(n, align); float *res2 = sse_utility::aligned_alloc<float>(n, align); // test some basic known values: const float pi = sse_constants::pi<float>(); x[0] = 0.0f; x[1] = pi / 2.0f; x[2] = pi; x[3] = 3.0f * pi / 2.0f; x[4] = 5.0f * pi / 4.0f; x[5] = 2.0f * pi; x[6] = 4.0f * pi; x[7] = 3.0f * pi; x[8] = 6.0f * pi / 3.0f; x[9] = -2.0f * pi; x[10] = -pi / 4.0f; x[11] = 7.0f * pi / 4.0f; x[12] = 0.5f; x[13] = pi / 3.0f; x[14] = 3.5f; x[15] = 4.0f * pi / 3.0f; x[16] = 10.3f; auto start_asm = std::chrono::system_clock::now(); bool rc1 = norm_pdf_sse(x, n, res1); auto end_asm = std::chrono::system_clock::now(); auto elapsed_asm = std::chrono::duration<double>(end_asm - start_asm).count(); auto start_cpp = std::chrono::system_clock::now(); for (int i = 0; i < n; ++i) { res2[i] = norm_pdf(x[i]); } auto end_cpp = std::chrono::system_clock::now(); auto elapsed_cpp = std::chrono::duration<double>(end_cpp - start_cpp).count(); SSE_ASSERT(rc1 == 1, "Failure in packed norm PDF SSE occured"); std::cout << " C++ Assembly (SSE) Difference\n"; std::cout << "=========================================================\n\n"; for (int i = 0; i < n; ++i) { std::cout << i << " | " << res2[i]; std::cout << " | " << res1[i]; std::cout << " | " << (res1[i] - res2[i]) << "\n"; } std::cout << "=========================================================\n\n"; std::cout << "\n" << "Elapsed (C++): " << elapsed_cpp; std::cout << "\n" << "Elapsed (Assembly): " << elapsed_asm << "\n"; sse_utility::aligned_free(x); sse_utility::aligned_free(res1); sse_utility::aligned_free(res2); } float rationalApproxIncCDF(float x) { float const c[3] = {2.515517f, 0.802853f, 0.010328f}; float const d[3] = {1.432788f, 0.189269f, 0.001308f}; return (x - ((c[2] * x + c[1]) * x + c[0]) / (((d[2] * x + d[1]) * x + d[0]) * x + 1.0f)); } float inv_cdf(float p) { int ind = 0; int inv = -1; if (p >= 0.5f) { ind = 1; inv = 1; } p = abs(ind - p); float const x = std::sqrt(-2.0f * std::log(p)); return (inv * rationalApproxIncCDF(x)); } void testBasicNormInvCDFSSEFloat() { int const n = 16 + 1; std::size_t const align = 16; float *x = sse_utility::aligned_alloc<float>(n, align); float *res1 = sse_utility::aligned_alloc<float>(n, align); float *res2 = sse_utility::aligned_alloc<float>(n, align); // test some basic known values: x[0] = 0.0000001f; x[1] = 0.00001f; x[2] = 0.001f; x[3] = 0.05f; x[4] = 0.15f; x[5] = 0.25f; x[6] = 0.35f; x[7] = 0.45f; x[8] = 0.55f; x[9] = 0.65f; x[10] = 0.75f; x[11] = 0.85f; x[12] = 0.95f; x[13] = 0.999f; x[14] = 0.99999f; x[15] = 0.999999f; x[16] = 0.9999999f; auto start_asm = std::chrono::system_clock::now(); bool rc1 = norm_inv_cdf_sse(x, n, res1); auto end_asm = std::chrono::system_clock::now(); auto elapsed_asm = std::chrono::duration<double>(end_asm - start_asm).count(); auto start_cpp = std::chrono::system_clock::now(); for (int i = 0; i < n; ++i) { res2[i] = inv_cdf(x[i]); } auto end_cpp = std::chrono::system_clock::now(); auto elapsed_cpp = std::chrono::duration<double>(end_cpp - start_cpp).count(); SSE_ASSERT(rc1 == 1, "Failure in packed norm INV CDF SSE occured"); std::cout << " C++ Assembly (SSE) Difference\n"; std::cout << "=========================================================\n\n"; for (int i = 0; i < n; ++i) { std::cout << i << " | " << res2[i]; std::cout << " | " << res1[i]; std::cout << " | " << (res1[i] - res2[i]) << "\n"; } std::cout << "=========================================================\n\n"; std::cout << "\n" << "Elapsed (C++): " << elapsed_cpp; std::cout << "\n" << "Elapsed (Assembly): " << elapsed_asm << "\n"; sse_utility::aligned_free(x); sse_utility::aligned_free(res1); sse_utility::aligned_free(res2); } double rationalApproxIncCDF(double x) { double const c[3] = {2.515517f, 0.802853f, 0.010328f}; double const d[3] = {1.432788f, 0.189269f, 0.001308f}; return (x - ((c[2] * x + c[1]) * x + c[0]) / (((d[2] * x + d[1]) * x + d[0]) * x + 1.0f)); } double inv_cdf(double p) { int ind = 0; int inv = -1; if (p >= 0.5f) { ind = 1; inv = 1; } p = abs(ind - p); double const x = std::sqrt(-2.0f * std::log(p)); return (inv * rationalApproxIncCDF(x)); } void testBasicNormInvCDFSSEDouble() { int const n = 16 + 1; std::size_t const align = 16; double *x = sse_utility::aligned_alloc<double>(n, align); double *res1 = sse_utility::aligned_alloc<double>(n, align); double *res2 = sse_utility::aligned_alloc<double>(n, align); // test some basic known values: x[0] = 0.0000001; x[1] = 0.00001; x[2] = 0.001; x[3] = 0.05; x[4] = 0.15; x[5] = 0.25; x[6] = 0.35; x[7] = 0.45; x[8] = 0.55; x[9] = 0.65; x[10] = 0.75; x[11] = 0.85; x[12] = 0.95; x[13] = 0.999; x[14] = 0.99999; x[15] = 0.999999; x[16] = 0.9999999; auto start_asm = std::chrono::system_clock::now(); bool rc1 = norm_inv_cdf_sse(x, n, res1); auto end_asm = std::chrono::system_clock::now(); auto elapsed_asm = std::chrono::duration<double>(end_asm - start_asm).count(); auto start_cpp = std::chrono::system_clock::now(); for (int i = 0; i < n; ++i) { res2[i] = inv_cdf(x[i]); } auto end_cpp = std::chrono::system_clock::now(); auto elapsed_cpp = std::chrono::duration<double>(end_cpp - start_cpp).count(); SSE_ASSERT(rc1 == 1, "Failure in packed norm INV CDF SSE occured"); std::cout << " C++ Assembly " "(SSE) Difference\n"; std::cout << "=========================================================\n\n"; for (int i = 0; i < n; ++i) { std::cout << i << " | " << res2[i]; std::cout << " | " << res1[i]; std::cout << " | " << (res1[i] - res2[i]) << "\n"; } std::cout << "=========================================================\n\n"; std::cout << "\n" << "Elapsed (C++): " << elapsed_cpp; std::cout << "\n" << "Elapsed (Assembly): " << elapsed_asm << "\n"; sse_utility::aligned_free(x); sse_utility::aligned_free(res1); sse_utility::aligned_free(res2); } #endif ///_NORMAL_DIST_FUNCTIONS_ET
[ "michal.sara99@gmail.com" ]
michal.sara99@gmail.com
bdd47518ca74d519688ba204a52937e466700eeb
300f1d03176e83785deea8d704fd86fcbcb0e1b2
/Assignment 3/Assignment 3/Problem 2/Problem 2.cpp
505350b597873d0d7defb29d667d36750dd52fb0
[]
no_license
csci-1730-group-7/Logans-Codes
96332dc03ef024fb4165a72f44b20cea12153b2d
18e340e86f2569674dccc7f4ed1c71fc572c87e9
refs/heads/master
2020-04-21T09:28:31.565585
2019-05-14T03:03:22
2019-05-14T03:03:22
169,449,933
0
0
null
null
null
null
UTF-8
C++
false
false
5,540
cpp
//Need to overload operators here for the arthimatic operations #include "pch.h" #include <iostream> #include <cmath> #include <windows.h> void sleep_seconds(const int sleepMSs) { Sleep(sleepMSs); } using namespace std; class Complex { public: //default constructor Complex(); Complex(double a, double b); Complex(double a, double b, double c, char i, char sign); //input functions friend ostream &operator << (ostream &os, const Complex &number); friend istream &operator >> (istream &is, Complex &number); //simple overloaded arithmatic functions const Complex operator+(const Complex &numberOne); const Complex operator-(const Complex &numberOne); const Complex operator*(const Complex &numberOne); const Complex operator/(const Complex &numberOne); friend bool operator==(Complex &numberOne); //not so simple mierda Complex checkEquality(); void convertComplex() { cout << 0 << "+" << b << i; } private: double a, b, c; char i = 'i', sign; }; ostream &operator << (ostream &os, const Complex &number) { if (number.a == 0) { os << "= " << number.b << "i" << endl; }//if a is zero, it will not be outputted else { if (number.b < 0) { os << "= " << number.a << number.b << number.i << endl << "one"; } else { os << "= " << number.a << "+" << number.b << number.i << endl << "two"; } } return os; } istream &operator >> (istream &is, Complex &number) { cout << "Enter a complex number a+bi\n"; is >> number.a >> number.sign >> number.b >> number.i; if (number.sign == '-') { number.b *= -1; } return is; } Complex::Complex() {} Complex::Complex(double a, double b) {} Complex::Complex(double a, double b, double c, char i, char sign) {} const Complex Complex::operator+ (const Complex &numberOne) { Complex q; q.a = numberOne.a + a; q.b = numberOne.b + b; return q; } const Complex Complex::operator- (const Complex &numberOne) { Complex q; q.a = a - numberOne.a; q.b = b - numberOne.b; return q; } const Complex Complex::operator* (const Complex &numberOne) { Complex q; q.a = ((a*numberOne.a) - (b*numberOne.b)); q.b = ((a*numberOne.b) + (b*numberOne.a)); return q; } const Complex Complex::operator/ (const Complex &numberOne) { Complex q; q.a = ((a*numberOne.a) + (numberOne.b*b)) / ((numberOne.a*numberOne.a) + (numberOne.b*numberOne.b)); q.b = ((b*numberOne.a) - (a*numberOne.b)) / ((numberOne.a*numberOne.a) + (numberOne.b*numberOne.b)); return q; } Complex Complex::checkEquality() { Complex z;//store a,b,c values for quadratic equation... little bit of self hatred involved here.. what am I doing here? Complex q;//store input variables Complex c;//store conjugate of inputted complex number Complex s;//store negative roots Complex i;//store positive roots //ostream &operator << (ostream &os, const Complex &number) cin >> q; if (q.sign == '-') { c.b = (q.b*-1); c.a = q.a; }//if the imaginary portion is negative, this will flip the conjugate's sign else { c.b = q.b; c.a = q.a; } cout << "Enter a: "; do { cin >> z.a; if (z.a == 0) { cout << endl << "a cannot be 0, please re-enter: "; } } while (z.a == 0); cout << "Enter b: "; cin >> z.b; cout << "Enter c: "; cin >> z.c; //declarations to get the coefficents correct z.c = ((z.b*z.b) + (-4.0*z.a*z.c));//defining c as the descriminant if (z.c >= 0) { cout << "The complex number " << q.a << q.sign << q.b << "i" << " is not a solution to the quadratic equation\n" << endl; } else { z.c = z.c * -1.0;//change descriminant so it is not negative z.a = 2 * z.a;//a now equals 2 * a z.b = (z.b*-1) / z.a;//-b in front of the quadratic equation z.c = (sqrt(z.c)) / z.a;// descriminant, imaginary portion of a+bi //collecting roots of quadratic equation i.a = z.b;//real number i.b = z.c;//positive imaginary root s.a = z.b;//real number s.b = (z.c*-1);//negative imaginary root //complex pairs from quadratic equation are : i.a + i.b , s.a - s.b //complex pairs for : q.a +- q.b , c.a +- q.b //q.b will always be positive //this if statment uses the } return q; } friend bool operator==(Complex &numberOne) { if ((abs(i.a - q.a) < 0.000001) && (abs(s.a - c.a) < 0.000001) && (abs(i.b - q.b) < 0.000001) && (abs(s.b) - abs(i.b)) < 0.000001) { return true; } else { cout << return false; } int main() { Complex I, N, Q; char operation; int resp; do { cout << "Select an option - (1) perform complex number arithmetic\n"; cout << " " << "(2) check for quadratic equation solution\n"; cout << " " << "(3) exit\n"; cin >> resp; switch (resp) { case 1: cin >> I; cout << "Enter an operation (+, -, *, /)\n"; cin >> operation; switch (operation) { case '+': cin >> N; Q = I.operator+(N); cout << Q; break; case '-': cin >> N; Q = I.operator-(N); cout<<Q; break; case '*': cin >> N; Q = I.operator*(N); cout << Q; break; case '/': cin >> N; Q = I.operator/(N); cout << Q; break; default: cout << "Please enter a valid arithmetic operation\n"; break; }//end of nested switch break; case 2: N.checkEquality(); break; case 3: cout << "Exiting"; sleep_seconds(2100); cout << "."; sleep_seconds(2100); cout << "."; sleep_seconds(2100); cout << "."; sleep_seconds(2100); break; default: cout << "I cannot do that at this time\n"; break; }//end of switch statement } while (resp != 3); return 0; }
[ "lkreun@oaala.com" ]
lkreun@oaala.com
0d69198e5c7f471ab27aada07945a7946f067635
6cba33d72856fd459cbb472f42ef1bd829984304
/05_signal_solt/mainwindow.cpp
6008992611282f8956266eeecee41716c8c72ed9
[ "MIT" ]
permissive
silence0201/audio-video-learn
e97a4c7792d1b07793e98aca666e38ebaf48ae50
2f8a6dc50bf9307ebc5ba0ead44e3bdcdb274ba0
refs/heads/main
2023-07-15T07:06:09.857818
2021-08-15T08:41:20
2021-08-15T08:41:20
378,644,581
0
0
null
null
null
null
UTF-8
C++
false
false
590
cpp
#include "mainwindow.h" #include <QPushButton> #include "sender.h" #include "receiver.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QPushButton *btn = new QPushButton; btn->setText("关闭"); btn->setFixedSize(100,30); btn->setParent(this); connect(btn, &QPushButton::clicked,this,&MainWindow::close); Sender *sender = new Sender; Receiver *reveiver = new Receiver; connect(sender,&Sender::exit,reveiver,&Receiver::handleExit); emit sender->exit(); delete sender; delete reveiver; } MainWindow::~MainWindow() { }
[ "374619540@qq.com" ]
374619540@qq.com
e69b3a4dffa706abc9547ab52e076401c6c1c5df
0150d34d5ced4266b6606c87fbc389f23ed19a45
/Cpp/SDK/UMG_Compass_Player_classes.h
511887781171eab43eab4dacd5fdce502626fd67
[ "Apache-2.0" ]
permissive
joey00186/Squad-SDK
9aa1b6424d4e5b0a743e105407934edea87cbfeb
742feb5991ae43d6f0cedd2d6b32b949923ca4f9
refs/heads/master
2023-02-05T19:00:05.452463
2021-01-03T19:03:34
2021-01-03T19:03:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,546
h
#pragma once // Name: S, Version: b #ifdef _MSC_VER #pragma pack(push, 0x01) #endif /*!!HELPER_DEF!!*/ /*!!DEFINE!!*/ namespace UFT { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // WidgetBlueprintGeneratedClass UMG_Compass_Player.UMG_Compass_Player_C // 0x0018 (FullSize[0x02C8] - InheritedSize[0x02B0]) class UUMG_Compass_Player_C : public USQCompassPlayer { public: struct FPointerToUberGraphFrame UberGraphFrame; // 0x02B0(0x0008) (ZeroConstructor, Transient, DuplicateTransient) class UImage* BP_Medic_IMG; // 0x02B8(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData, RepSkip, NoDestructor, PersistentInstance, HasGetValueTypeHash) class UImage* BPPlayer_IMG; // 0x02C0(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData, RepSkip, NoDestructor, PersistentInstance, HasGetValueTypeHash) static UClass* StaticClass() { static auto ptr = UObject::FindClass("WidgetBlueprintGeneratedClass UMG_Compass_Player.UMG_Compass_Player_C"); return ptr; } void Construct(); void BPInit(); void ExecuteUbergraph_UMG_Compass_Player(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "tahmaniak@gmail.com" ]
tahmaniak@gmail.com
8f30cf69e420324441a0c5e3be7e7111cb6a0aff
c70d0f437bf7fdd0539bbb61b89e0a922b36e4a8
/Sound Tool/AudioLib/Audio_Save_BGM.cpp
ee632a8268663dc109e1c499a32f38742f9c159e
[]
no_license
OriginofJustice/Game_Portfolio
5bfac7116310558599787ebf7323b35c4ec25089
d7df0a6c17b8fc3732283163b72eb7fd24a1913f
refs/heads/master
2021-01-01T18:27:46.097469
2013-10-20T13:05:35
2013-10-20T13:05:35
null
0
0
null
null
null
null
UHC
C++
false
false
676
cpp
#include "StdAfx.h" #include "Audio_Save.h" /** * \par 메소드 데이터 로드할 OGG 데이터들에 관한 정보를 출력하는 함수 * \param szName * \param OggData * \return */ bool Audio_Save::FileBgmExport(char* szName, vector<OggData> OggData) { FileOpen(szName); fprintf( m_pStream, "#Luade_BGM_Script_0.01\n"); fprintf( m_pStream, "%s\n","#Ogg_Data_List_Header"); fprintf( m_pStream, "\t%d\n",OggData.size()); fprintf( m_pStream, "%s\n","#Ogg_Data_List"); for (UINT i = 0 ; i < OggData.size(); i++) { fprintf( m_pStream, "\t%d\t%s\n",i, OggData[i].BufferName); } FileEnd(); // 파일 익스포트 종료 FileClose(); return true; }
[ "euiweon@euiweonjeong.com" ]
euiweon@euiweonjeong.com
19c08c861f5a73a74c8ea4e07277aacf731bad7b
c7512b7d589fd3cef72c85f9cda6370335c7d2fd
/HW06/StackInterface.h
cd3376fdc6f71c3ed3e88684eaf2186c5a2e16d2
[ "Apache-2.0" ]
permissive
fitsenegn/CSCI2421
b42b7a891aefdd509f40a9a32a20adceeab71bc9
8896330c15316e8dcd1b9476fd3e68ce230e1f36
refs/heads/master
2020-05-14T11:52:09.195182
2018-05-08T05:46:04
2018-05-08T05:46:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,129
h
#ifndef STACKINTERFACE_H_ #define STACKINTERFACE_H_ template <class ItemType> class StackInterface { public: /** Sees wether this stack is is empty \@return True if the stack is empty, or false if note */ virtual bool isEmpty() const = 0; /** Adds a new entry to the top of this stack. \@post If the operation was succesful, newEntry is at the top of the stack. \@param newEntry The object to be added as a new entry. \@return True if the addition is succesful or false if not */ virtual bool push(const ItemType& newEntry) = 0; /** Removes the top of this stack. \@post If the operation was succesful, the top of the stack has been removed. \@return True if the removal is succesful or false if not */ virtual bool pop() = 0; /** Returns a copy of the top of this stack. \@pre The stack is not empty. \@post A copy of the top of the stack has been returned, and the stack is unchanged. \@return A copy of the top of the stack. */ virtual ItemType peek() const = 0; /** Destroys this stack and frees its assigned memory. */ virtual ~StackInterface() { } }; # endif
[ "baby.hughee@gmail.com" ]
baby.hughee@gmail.com
dd4e410e32a7ccd51bc6764b782761dbd987d6cb
fddab5bb9e1fc9bba86f2e572f458763655b7861
/GameServer/src/Country/CountryOverlordCarbonLoader.cpp
37c7acee8ae682dba84fed679657e2a5ef686178
[]
no_license
hackerlank/Test-3
0d6484db857ebd4649362e64fe77d33d0b125d85
bfd5c332a09e0f6cf7a47abc89208e527bcb1ee8
refs/heads/master
2021-01-15T14:54:29.278366
2017-06-26T18:23:37
2017-06-26T18:23:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,863
cpp
/* * CountryOverlordCarbonLoader.cpp * * Created on: 2016年10月28日 * Author: root */ #include "CountryOverlordCarbonLoader.h" #include "CSVLoader.h" #include "StrArgPkg.h" #include "util.h" #include <math.h> CountryOverlordCarbonLoader::CountryOverlordCarbonLoader():m_nKillPlayer(0),m_nKillBoss(0),m_nAttackBoss(0) { m_nBothPont.clear(); m_nOverlordBaseData.clear(); m_nOverlordReward.clear(); } CountryOverlordCarbonLoader::~CountryOverlordCarbonLoader() { } int CountryOverlordCarbonLoader::Init(string &path) { string campKingWarData = path + "Data/CampKingWarData.csv"; string campKingWarReward = path + "Data/CampKingWarReward.csv"; if(InitCampKingWarData(campKingWarData) || InitCampKingWarReward(campKingWarReward)) { return -1; } return 0; } int CountryOverlordCarbonLoader::InitCampKingWarData(string& file) { CSVLoader loader; if(!loader.OpenFromFile(file.c_str())) { return -1; } for(unsigned int i=0; i<loader.GetRowCount(); ++i) { int count = 1; int nType = loader.GetInt(i, count++); switch(nType) { case 1: { pont p; p.xpos = loader.GetInt(i, count++); p.ypos = loader.GetInt(i, count++); m_nBothPont[eCountryID_sui] = p; break; } case 2: { pont p; p.xpos = loader.GetInt(i, count++); p.ypos = loader.GetInt(i, count++); m_nBothPont[eCountryID_tang] = p; break; } case 3: { OverlordBaseData info; info.m_nXpos = loader.GetInt(i, count++); info.m_nYpos = loader.GetInt(i, count++); info.m_nMosterId = loader.GetInt(i, count++); info.m_nCount = loader.GetInt(i, count++); info.m_nFlushTime = loader.GetInt(i, count++); m_nOverlordBaseData.push_back(info); break; } case 4: { m_nKillPlayer = loader.GetInt(i, count++); break; } case 5: { m_nKillBoss = loader.GetInt(i, count++); break; } case 6: { m_nAttackBoss = loader.GetInt(i, count++); break; } default: break; } } return 0; } int CountryOverlordCarbonLoader::InitCampKingWarReward(string& file) { CSVLoader loader; if(!loader.OpenFromFile(file.c_str())) { return -1; } for(unsigned int i=0; i<loader.GetRowCount(); ++i) { int count = 1; OverlordReward info; info.m_nType = loader.GetInt(i, count++); info.m_nNeedPoint = loader.GetInt(i, count++); info.m_nAwardExp = loader.GetInt(i, count++); info.m_nAwardMoney = loader.GetInt(i, count++); info.m_nAwardSprit = loader.GetInt(i, count++); info.m_nAwardCoun = loader.GetInt(i, count++); //限制使用物品 string funStrItem = loader.GetString(i, count++, ""); StrArgPkg funPkgItem("|", funStrItem); for(uint itemSize=0; itemSize<funPkgItem.size(); ++itemSize) { StrArgPkg limitPkg(":", getArg(funPkgItem, itemSize).c_str()); for(unsigned int i=0; i<limitPkg.size(); ++i) { info.m_nAward.push_back(atoi(getArg(limitPkg, i++).c_str())); info.m_nAwardNum.push_back(atoi(getArg(limitPkg, i).c_str())); } } m_nOverlordReward.push_back(info); } return 0; } void CountryOverlordCarbonLoader::GetBothPos(DWORD nType,int64 &xpos, int64 &ypos) { map<DWORD,pont>::iterator itr = m_nBothPont.find(nType); if(itr != m_nBothPont.end()) { xpos = itr->second.xpos; ypos = itr->second.ypos; } else { xpos = -1; ypos = -1; } } const OverlordBaseData* CountryOverlordCarbonLoader::GetOverlordBaseData() { vector<OverlordBaseData>::iterator itr = m_nOverlordBaseData.begin(); if(itr != m_nOverlordBaseData.end()) { return &(*itr); } return NULL; } const OverlordReward* CountryOverlordCarbonLoader::GetOverlordReward(DWORD nType,DWORD nNeed) { vector<OverlordReward>::iterator itr = m_nOverlordReward.begin(); for(; itr != m_nOverlordReward.end(); ++itr) { if(itr->m_nType == nType && itr->m_nNeedPoint == nNeed) { return &(*itr); } } return NULL; }
[ "cl_chenzhiyong@163.com" ]
cl_chenzhiyong@163.com
0c1320448d612d2657b432e0316959a8f15c843c
a92b18defb50c5d1118a11bc364f17b148312028
/src/prod/src/httpgateway/FabricOrchestrationUpgradeProgress.cpp
cf6e15e826e018cc9a18f9f06c08d875cb719cf0
[ "MIT" ]
permissive
KDSBest/service-fabric
34694e150fde662286e25f048fb763c97606382e
fe61c45b15a30fb089ad891c68c893b3a976e404
refs/heads/master
2023-01-28T23:19:25.040275
2020-11-30T11:11:58
2020-11-30T11:11:58
301,365,601
1
0
MIT
2020-11-30T11:11:59
2020-10-05T10:05:53
null
UTF-8
C++
false
false
1,036
cpp
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #include "stdafx.h" using namespace Common; using namespace Api; using namespace Management::UpgradeOrchestrationService; using namespace ServiceModel; using namespace Naming; using namespace HttpGateway; FabricOrchestrationUpgradeProgress::FabricOrchestrationUpgradeProgress() : upgradeState_(FABRIC_UPGRADE_STATE_INVALID) { } ErrorCode FabricOrchestrationUpgradeProgress::FromInternalInterface(IFabricOrchestrationUpgradeStatusResultPtr &resultPtr) { auto progress = resultPtr->GetProgress(); upgradeState_ = OrchestrationUpgradeState::ToPublicApi(progress->State); progressStatus_ = progress->ProgressStatus; configVersion_ = progress->ConfigVersion; details_ = progress->Details; return ErrorCode::Success(); }
[ "noreply-sfteam@microsoft.com" ]
noreply-sfteam@microsoft.com
1121424017c4f2246abaa5437c619e579d0a6bc0
485303ba578e154b2c0c110f8e0fec758d921ed0
/week-03/day-03/LineInTheMiddle/main.cpp
43ef7ed49313ad8292574e29fcddf3491221a72b
[]
no_license
green-fox-academy/mazurgab
0b6e3c3a7fe0a4940ff80c4e25f9f386b408ab7b
1eae9aae0338122a3d1536fecd2eb15dc7871a3e
refs/heads/master
2020-04-02T17:22:07.998691
2019-04-28T21:52:14
2019-04-28T21:52:14
154,655,053
0
0
null
null
null
null
UTF-8
C++
false
false
2,750
cpp
#include <iostream> #include <SDL.h> //Screen dimension constants const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; //Draws geometry on the canvas void draw(); //Starts up SDL and creates window bool init(); //Frees media and shuts down SDL void close(); //The window we'll be rendering to SDL_Window* gWindow = nullptr; //The window renderer SDL_Renderer* gRenderer = nullptr; void draw() { // draw a red horizontal line to the canvas' middle. SDL_SetRenderDrawColor( gRenderer, 0xFF, 0x00, 0x00, 0xFF ); SDL_RenderDrawLine(gRenderer, 0 , SCREEN_HEIGHT/2, SCREEN_WIDTH, SCREEN_HEIGHT/2); // draw a green vertical line to the canvas' middle. SDL_SetRenderDrawColor( gRenderer, 0x00, 0xFF, 0x00, 0xFF ); SDL_RenderDrawLine(gRenderer, SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT); } bool init() { //Initialize SDL if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { std::cout << "SDL could not initialize! SDL Error: " << SDL_GetError() << std::endl; return false; } //Create window gWindow = SDL_CreateWindow( "Line in the middle", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); if( gWindow == nullptr ) { std::cout << "Window could not be created! SDL Error: " << SDL_GetError() << std::endl; return false; } //Create renderer for window gRenderer = SDL_CreateRenderer( gWindow, -1, SDL_RENDERER_ACCELERATED ); if( gRenderer == nullptr ) { std::cout << "Renderer could not be created! SDL Error: " << SDL_GetError() << std::endl; return false; } //Initialize renderer color SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); return true; } void close() { //Destroy window SDL_DestroyRenderer( gRenderer ); SDL_DestroyWindow( gWindow ); gWindow = nullptr; gRenderer = nullptr; SDL_Quit(); } int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { std::cout << "Failed to initialize!" << std::endl; close(); return -1; } //Main loop flag bool quit = false; //Event handler SDL_Event e; //While application is running while( !quit ) { //Handle events on queue while (SDL_PollEvent(&e) != 0) { //User requests quit if (e.type == SDL_QUIT) { quit = true; } } //Clear screen SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF); SDL_RenderClear(gRenderer); draw(); //Update screen SDL_RenderPresent(gRenderer); } //Free resources and close SDL close(); return 0; }
[ "mazurgab@gmail.com" ]
mazurgab@gmail.com
fbe1c919ab602028e2a0529a365578d14ead8c40
64178ab5958c36c4582e69b6689359f169dc6f0d
/vscode/wg/sdk/UItem_Legs_C_03_C.hpp
bd018fbfcc2d52c26ffc81d7d75499a83b26f915
[]
no_license
c-ber/cber
47bc1362f180c9e8f0638e40bf716d8ec582e074
3cb5c85abd8a6be09e0283d136c87761925072de
refs/heads/master
2023-06-07T20:07:44.813723
2023-02-28T07:43:29
2023-02-28T07:43:29
40,457,301
5
5
null
2023-05-30T19:14:51
2015-08-10T01:37:22
C++
UTF-8
C++
false
false
847
hpp
#pragma once #include "UEquipableItem.hpp" #ifdef _MSC_VER #pragma pack(push, 1) #endif namespace PUBGSDK { struct alignas(1) UItem_Legs_C_03_C // Size: 0x2A8 : public UEquipableItem // Size: 0x2A8 { private: typedef UItem_Legs_C_03_C t_struct; typedef ExternalPtr<t_struct> t_structHelper; public: static ExternalPtr<struct UClass> StaticClass() { static ExternalPtr<struct UClass> ptr; if(!ptr) ptr = UObject::FindClassFast(91128); // id32("BlueprintGeneratedClass Item_Legs_C_03.Item_Legs_C_03_C") return ptr; } }; #ifdef VALIDATE_SDK namespace Validation{ auto constexpr sizeofUItem_Legs_C_03_C = sizeof(UItem_Legs_C_03_C); // 680 static_assert(sizeof(UItem_Legs_C_03_C) == 0x2A8, "Size of UItem_Legs_C_03_C is not correct."); } #endif } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "1395329153@qq.com" ]
1395329153@qq.com
296173911fae870607dffcc958a4d11f834b3d3b
6e4076f5b26b774f0fc7fd69bc936f6a80141b38
/http_tcpserver.h
17741ebb77201e12f05e0ed30e63015e6363afad
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
Light-City/http-server
e2ae14d95d920cce01aec3745f56935c4ad08419
2c728d4f1a46f45aa534bb32e60c20ea631b1d37
refs/heads/main
2023-08-23T05:45:41.768466
2021-10-17T18:15:00
2021-10-17T18:15:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
806
h
#ifndef INCLUDED_HTTP_TCPSERVER #define INCLUDED_HTTP_TCPSERVER #include <stdio.h> #include <winsock.h> #include <stdlib.h> #include <string> namespace http { class TcpServer { public: TcpServer(std::string ip_address, int port); ~TcpServer(); void startListen(); private: std::string m_ip_address; int m_port; SOCKET m_socket; SOCKET m_new_socket; long m_incomingMessage; struct sockaddr_in m_socketAddress; int m_socketAddress_len; std::string m_serverMessage; WSADATA m_wsaData; int startServer(); void closeServer(); void acceptConnection(SOCKET &new_socket); std::string buildResponse(); void sendResponse(); }; } // namespace http #endif
[ "osas.azamegbe@gmail.com" ]
osas.azamegbe@gmail.com
ad8d15fe9ad345af93fa0ca8c9f8ab1d18e8f32f
c4c4d7fa797fc4da4c0557effe20fffb7c3a2fed
/src/in_xsf_framework/XSFConfigDialog.h
fd705477c1a7ee42411136dd6ba2e89c2e58640c
[ "BSD-3-Clause" ]
permissive
bauxite69/in_xsf
61addc63e9a55ceb1eb9729d53e5f719f017c52e
6d78469746b17bf1a9356c7a26ecd2850ba46eb3
refs/heads/master
2023-04-04T22:08:02.382396
2021-04-20T01:20:36
2021-04-20T01:20:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,260
h
/* * xSF - Core configuration dialog * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] * * Partially based on the vio*sf framework */ #pragma once #ifdef __GNUC__ # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wold-style-cast" #elif defined(__clang__) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wold-style-cast" #endif #include <wx/msw/winundef.h> #include <wx/dialog.h> #include <wx/string.h> #ifdef __GNUC__ # pragma GCC diagnostic pop #elif defined(__clang__) # pragma clang diagnostic pop #endif class wxGridBagSizer; class wxPanel; class wxWindow; class XSFConfig; class XSFConfigDialog : public wxDialog { inline static const std::string timeRegex = R"(^\d+(:[0-5]\d){0,2}([.,]\d+)?$)"; wxGridBagSizer *mainSizer; XSFConfig &config; public: XSFConfigDialog(XSFConfig &newConfig, wxWindow *parent, const wxString &title); void Finalize(); wxPanel *generalPanel; wxGridBagSizer *generalSizer; wxPanel *outputPanel; wxGridBagSizer *outputSizer; bool playInfinitely = false; wxString defaultPlayLength; wxString defaultFadeoutLength; wxString skipSilenceOnStart; wxString detectSilence; double volume = 1; int replayGain; int clipProtect; int sampleRate; wxString titleFormat; };
[ "cyberbotx@cyberbotx.com" ]
cyberbotx@cyberbotx.com
8c540a81c0c4b73a40f377329ad30f298b3a920f
34d0bad8a2849447925fef0c752406122baae3f2
/ti_tools/linux_devkit/arm-arago-linux-gnueabi/usr/bin/qtopia/demos/qtdemo/examplecontent.cpp
206eb59761345d4807e665e891af2f82cca656e3
[]
no_license
pamsimochen/hardwork
5e05154fac35a0aacc0f8b64c21b2ca767fd4a3d
1e0a4cafdd1722eb58c4261bad68e602352f2079
refs/heads/master
2021-09-07T22:44:16.620515
2018-03-02T09:48:40
2018-03-02T09:48:40
103,899,662
1
0
null
null
null
null
UTF-8
C++
false
false
6,183
cpp
/**************************************************************************** ** ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** 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 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "examplecontent.h" #include "colors.h" #include "menumanager.h" #include "imageitem.h" #include "headingitem.h" ExampleContent::ExampleContent(const QString &name, QGraphicsScene *scene, QGraphicsItem *parent) : DemoItem(scene, parent) { this->name = name; this->heading = 0; this->description = 0; this->screenshot = 0; } void ExampleContent::prepare() { if (!this->prepared){ this->prepared = true; this->createContent(); } } void ExampleContent::animationStopped(int id) { if (id == DemoItemAnimation::ANIM_OUT){ // Free up some memory: delete this->heading; delete this->description; delete this->screenshot; this->heading = 0; this->description = 0; this->screenshot = 0; this->prepared = false; } } QString ExampleContent::loadDescription() { QByteArray ba = MenuManager::instance()->getHtml(this->name); QString errorMsg; int errorLine, errorColumn; QDomDocument exampleDoc; if (!exampleDoc.setContent(ba, false, &errorMsg, &errorLine, &errorColumn)) { qDebug() << errorMsg << errorLine << errorColumn; } QDomNodeList paragraphs = exampleDoc.elementsByTagName("p"); if (paragraphs.length() < 1 && Colors::verbose) qDebug() << "- ExampleContent::loadDescription(): Could not load description:" << MenuManager::instance()->info[this->name]["docfile"]; QString description = Colors::contentColor + QLatin1String(""); //QLatin1String("Could not load description. Ensure that the documentation for Qt is built."); // QTBUG-12522: If there is no description why show an error to the user when qDebug above communications the issue (if it is indeed an issue at all) when demos are built? for (int p = 0; p < int(paragraphs.length()); ++p) { description = this->extractTextFromParagraph(paragraphs.item(p)); if (this->isSummary(description)) { break; } } return Colors::contentColor + description; } bool ExampleContent::isSummary(const QString &text) { return (!text.contains("[") && text.indexOf(QRegExp(QString("(In )?((The|This) )?(%1 )?.*(tutorial|example|demo|application)").arg(this->name), Qt::CaseInsensitive)) != -1); } QString ExampleContent::extractTextFromParagraph(const QDomNode &parentNode) { QString description; QDomNode node = parentNode.firstChild(); while (!node.isNull()) { QString beginTag; QString endTag; if (node.isText()) description += Colors::contentColor + node.nodeValue(); else if (node.hasChildNodes()) { if (node.nodeName() == "b") { beginTag = "<b>"; endTag = "</b>"; } else if (node.nodeName() == "a") { beginTag = Colors::contentColor; endTag = "</font>"; } else if (node.nodeName() == "i") { beginTag = "<i>"; endTag = "</i>"; } else if (node.nodeName() == "tt") { beginTag = "<tt>"; endTag = "</tt>"; } description += beginTag + this->extractTextFromParagraph(node) + endTag; } node = node.nextSibling(); } return description; } void ExampleContent::createContent() { // Create the items: this->heading = new HeadingItem(this->name, this->scene(), this); this->description = new DemoTextItem(this->loadDescription(), Colors::contentFont(), Colors::heading, 500, this->scene(), this); int imgHeight = 340 - int(this->description->boundingRect().height()) + 50; this->screenshot = new ImageItem(QImage::fromData(MenuManager::instance()->getImage(this->name)), 550, imgHeight, this->scene(), this); // Place the items on screen: this->heading->setPos(0, 3); this->description->setPos(0, this->heading->pos().y() + this->heading->boundingRect().height() + 10); this->screenshot->setPos(0, this->description->pos().y() + this->description->boundingRect().height() + 10); } QRectF ExampleContent::boundingRect() const { return QRectF(0, 0, 500, 100); }
[ "82425509@qq.com" ]
82425509@qq.com
51c1ba09ec95a64c82dc2031cfc605ae87722542
8c5fd6d091a13637959939e880149c0927a27645
/Engine/AudioSystem/TremoloDSP.h
6009ba4c799c02335726721e3af0f527795aaba0
[ "MIT" ]
permissive
hulcyp/GuildhallProjects
f1223f0f83a947b256fbfad02c3591083c93bdaa
2c5c558992daa505867c4b37b73cec61e1c8d2d0
refs/heads/master
2021-01-17T17:06:31.480272
2014-03-13T16:00:21
2014-03-13T16:00:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,037
h
#pragma once #include "DSP.h" #include <XMLParser.h> namespace Monky { class TremoloDSP : public DSP { public: TremoloDSP(); TremoloDSP( XMLParser& parser, XMLNode* tremoloNode ); /* Frq in hz. Range: 0.1 - 20.0 */ void setFrequency( float frequency ); float getFrequency() const; /* Range: 0.0 - 1.0 */ void setDepth( float depth ); float getDepth() const; /* Shape morph between triangle and sine. Range: 0 - 1 */ void setShape( float shape ); float getShape() const; /* Time skewing. Range: -1.0 - 1.0 */ void setTimeSkewing( float skewing ); float getTImeSkewing() const; /* LFO on-time. Range: 0 - 1 */ void setDuty( float duty ); float getDuty() const; /* Flatness of the LFO shape. Range: 0.0 - 1.0 */ void setFlatness( float flatness ); float getFlatness() const; /* Instantaneous LFO phase. Range: 0 - 1 */ void setPhase( float phase ); float getPhase() const; /* Rotation / auto-pan effect. Range: -1 - 1 */ void setSpread( float spread ); float getSPread() const; }; }
[ "prestonhulcy@gmail.com" ]
prestonhulcy@gmail.com
b4f87ae0ae9b8faabd2f8a55f82d91b33e6a26d6
5700384db9467ebe3f08550d8bb1d42a4100f72c
/include/Configuration.h
ab026dc95acb14c0c33cec48441ccbde5db7a521
[ "MIT" ]
permissive
Poler2000/MarketSimulation
7757df606d608fc6d0e6411bdd23b77c005e3113
0ffbda1c68315da98e6def963a9ad9ac93cdaaa6
refs/heads/main
2023-06-18T13:05:03.275360
2021-07-24T12:29:49
2021-07-24T12:29:49
385,942,613
0
0
null
null
null
null
UTF-8
C++
false
false
3,749
h
#ifndef MARKETSIMULATION_CONFIGURATION_H #define MARKETSIMULATION_CONFIGURATION_H #include <vector> #include <array> #include <string_view> namespace poler::market { using namespace std::chrono_literals; static constexpr struct CustomerConfig { static constexpr int defaultNeedIncrease = 8; static constexpr int defaultNeedDecrease = 1; static constexpr auto interval = 100ms; static constexpr std::string_view dir = "sim1/customer/"; } customerConfig; static constexpr struct MarketConfig { static constexpr auto interval = 100ms; static constexpr double companyAvgMoney = 3000; static constexpr double companyMoneyRandomFactor = 500; static constexpr double customerAvgIncome = 500; static constexpr double customerIncomeRandomFactor = 200; static constexpr double productAvgPrice = 50; static constexpr double productPriceRandomFactor = 30; static constexpr double productPriceChange = 5; static constexpr double productMinPrice = 0.1; static constexpr std::string_view dir = "sim1/product/"; } marketConfig; static constexpr struct CompanyConfig { static constexpr auto interval = 100ms; static constexpr double basicDailyCosts = 50; static constexpr double newFactoryCosts = 100; static constexpr double factorySellPrice = 60; static constexpr double dangerousSDRatio = 2.0; static constexpr uint32_t maxStock = 100; static constexpr double probabilityOfStrategyChange = 0.3; static constexpr std::string_view dir = "sim1/company/"; } companyConfig; static constexpr std::array<std::string_view , 30> customerNames = { "Alex", "Alice", "Amy", "Anna", "Anastasia", "Bruce", "Daniel", "Dorothy", "Emily", "Eliza", "George", "Gustav", "Hans", "Harold", "Jack", "Juan", "Julia", "Kate", "Laura", "Martha", "Natalie", "Nelson", "Patrick", "Paul", "Peter", "Pierre", "Rachel", "Stefan", "Veronica", "Victoria", }; static constexpr std::array<std::string_view , 20> companyNames = { "Poler Inc.", "Constantinople Kebab", "JSON&Sons", "Cucumber Global", "Kinky! Interactive", "Dream Factory", "Wild West Company", "Big Bargain Burger", "QWERTY", "Kochanowski&Daughters", "Flying Penguins", "Wilhelm's Holdings", "Siskin Sisterhood", "WolfpackGroup", "Ancient Brewery", "Literal Heaven", "Caesar's ides of March", "Well Known Business Group", "Laziness Inc.", "SpaceY", }; static constexpr std::array<std::string_view, 20> productNames = { "Bicycles", "Mobile Phones", "Cars", "Oranges", "Beer", "Rubber Ducks", "Irish Whisky", "Programming Books", "TV", "Wine", "Sunglasses", "Frozen Chicken", "Masks", "Headphones", "Turkish Carpets", "Smart Microwave", "Smart Vacuum Cleaner", "Smart Fridge", "Smart Broom", "Wireless Wires", }; } #endif //MARKETSIMULATION_CONFIGURATION_H
[ "p.polerowicz@gmail.com" ]
p.polerowicz@gmail.com
96244a68f4749c960a9399d04b65656885b25d31
e9774bd2d0cd9aaad49eacd092ba97e95dbf9a5f
/problems/A - Average Height.cpp
77de0c8198c7ff98353c2695883ce3928e610415
[]
no_license
My-Competitive-Programming-Legacy/CodeForces
fb589c187706060d8a33eccf75597dad4dab904d
f9df0ffe76b1d37215f063e87920c0044fe226a4
refs/heads/master
2023-06-23T06:04:30.369027
2021-07-19T12:20:19
2021-07-19T12:20:19
387,414,460
0
0
null
null
null
null
UTF-8
C++
false
false
440
cpp
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> e, o; for (int i = 0; i < n; i++) { int t; cin >> t; if (t % 2) e.push_back(t); else o.push_back(t); } for (auto v : e) cout << v << " "; for (auto v : o) cout << v << " "; cout << endl; } int main() { int t; cin >> t; while (t--) { solve(); } return 0; }
[ "hamzahasssan835@gmail.com" ]
hamzahasssan835@gmail.com
2cbef3b3238da1f303387d26aba27fd908f529dd
ac5fff82f5e0481b6d5db6433a75328e06371496
/СП_6/CopyFileApp/CopyFileApp/Source.cpp
40aa367a0f6ace2f584b3b42a0e1147c6c56d91b
[]
no_license
siedex/WinAPI
2e517c9de9a404bc60a80916d86edfcef4803a75
1b1fd544fcd54e884d00b9d8b522fb3a2a80f090
refs/heads/master
2021-01-21T05:15:17.876735
2017-05-01T20:55:36
2017-05-01T20:55:36
83,159,160
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
400
cpp
#include <windows.h> #include "iostream" using namespace std; int main() { // копируем файл if (!CopyFile(TEXT("D:\\demo_file.dat"), TEXT("D:\\new_file.dat"), FALSE)) { cerr << "Copy file failed." << endl << "The last error code: " << GetLastError() << endl; cout << "Press any key to finish."; cin.get(); return 0; } cout << "The file is copied." << endl; return 0; }
[ "siedex@outlook.com" ]
siedex@outlook.com
fbaf6eeae39203efa805b073ccbb4e6fe33250ba
1c72b609dc0e8fbeafad4c46d0d9c757abc238da
/source/SMPPBindTransceiver.cpp
f22f529e8016b02ce634ec11eae074ff2c91f2e6
[ "Apache-2.0" ]
permissive
ict-project/libsmpp
100c1d8a7f04292b5afbf3a092d5b61399643fa7
c4f4045a62d3de90d96ccf5db8792d6753493561
refs/heads/master
2021-01-19T23:24:58.550325
2017-05-16T10:57:47
2017-05-16T10:57:47
88,975,511
1
0
null
null
null
null
UTF-8
C++
false
false
1,475
cpp
/* Copyright 2007 Majoron.com (developers@majoron.com) Original sources are available at www.majoron.com 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 "AntHillSMPP.hpp" #include "SMPPDecoder.hpp" #include "SMPPEncoder.hpp" #include "SMPPValidator.hpp" #include "SMPPBindTransceiver.hpp" namespace anthill { namespace smpp { SMPPBindTransceiver::SMPPBindTransceiver(void): SMPPBind(CommandId::CM_BIND_TRANSCEIVER){ } SMPPBindTransceiver::SMPPBindTransceiver(const unsigned nSequenceNumber): SMPPBind(CommandId::CM_BIND_TRANSCEIVER, nSequenceNumber){ } SMPPBindTransceiver::~SMPPBindTransceiver(){ } SMPPPDU* SMPPBindTransceiver::cloneSMPPPDU(void){ return new SMPPBindTransceiver(); } void SMPPBindTransceiver::fireOnReceived(SMPPSession* poSession){ SMPPBindTransceiver::SharedPtr poPtr(this); // poSession->fireOnReceived(this->shared_from_this()); } } }
[ "mariusz.ornowski@ict-project.pl" ]
mariusz.ornowski@ict-project.pl
05ee8f420e71dddf15f60e118ccfdb9c078e96db
fb7960d4abcf79c96d2c5671607393fecba79bd3
/IncomeManager.cpp
91f7791c0eb44c41b884da5a0a5807f8daa43dec
[]
no_license
Adamall123/console-financial-app
39ce99baa74858b36edb8c4d3ed3239dcba80f8a
c1ef551800e58fdc1484a2ccd31c39aef8f4d1b6
refs/heads/master
2023-03-03T01:25:22.503661
2020-12-15T13:33:04
2020-12-15T13:33:04
321,360,399
0
0
null
2023-02-28T02:29:22
2020-12-14T13:44:16
C++
UTF-8
C++
false
false
2,653
cpp
#include "IncomeManager.h" void IncomeManager::addIncome() { system("cls"); cout << "Adding Income" << endl; cout << "--------------------------------" << endl; string givenDate = giveDateToNewIncome(); string dateWithoutDashes = DateMethods::disposeOfDashesInDate(givenDate); int date = AuxiliaryMethods::convertFromStringToInt(dateWithoutDashes); Income income = giveDataForNewIncome(date); incomes.push_back(income); xmlFileWithIncomes.addIncomeToXMLFile(income); } Income IncomeManager::giveDataForNewIncome(int givenDate) { string strAmount; Income income; income.setIncomeID(xmlFileWithIncomes.returnLastIncomeId() + 1); //getting last id from xmfileIncomes.returnLastIncomeId() + 1; income.setUserID(ID_LOGGED_IN_USER); income.setDate(givenDate); cout << "Type a form of income: " ; income.setItem(AuxiliaryMethods::loadLine()); cout << "Type amount of income: "; cin >> strAmount; //checking if bigger than 0 and making maximum two number after period strAmount = AuxiliaryMethods::replaceCommasWithDots(strAmount); income.setAmount(AuxiliaryMethods::convertFromStringToFloat(strAmount)); return income; } string IncomeManager::giveDateToNewIncome() { //add to method - getCurrentDate() cout << "Get current time" << endl; time_t t = time(0); tm* now = localtime(&t); char choice; string currentTime, strYear, strMonth, strDay; int intYear, intMonth, intDay; bool presentDay = true; intYear = now->tm_year + 1900; intMonth = now->tm_mon + 1; intDay = now->tm_mday; strYear = AuxiliaryMethods::convertFromIntToString(intYear); strMonth = AuxiliaryMethods::convertFromIntToString(intMonth); strDay = AuxiliaryMethods::convertFromIntToString(intDay); currentTime = strYear + '-' + strMonth + '-' + strDay; cout << "Select Option" << endl; cout << "1. Adding Income with present date: "<< currentTime << endl; cout <<"2. Give date from income " << endl; do { choice = AuxiliaryMethods::loadSign(); if (choice == '2') presentDay = false; } while(choice != '1' && choice != '2' ); if(!presentDay) { string dateInCome = ""; string date = ""; do { system("cls"); cout << "Give data in a format rrrr-mm-dd" << endl; dateInCome = AuxiliaryMethods::loadLine(); date = DateMethods::checkCorecctnessOfGivenDate(dateInCome); } while(date == ""); return date; } return currentTime; } vector <Income> IncomeManager::getIncomes() { return incomes; }
[ "adam.wojdylo1234@gmail.com" ]
adam.wojdylo1234@gmail.com
bfa1ba203aeb0c1e7af317ecf7d82310bcbed9f4
04b1803adb6653ecb7cb827c4f4aa616afacf629
/third_party/blink/renderer/platform/network/form_data_encoder.cc
b2cf3241467710d745dd86ba1917028251059df8
[ "LGPL-2.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "MIT", "Apache-2.0", "BSD-3-Clause" ]
permissive
Samsung/Castanets
240d9338e097b75b3f669604315b06f7cf129d64
4896f732fc747dfdcfcbac3d442f2d2d42df264a
refs/heads/castanets_76_dev
2023-08-31T09:01:04.744346
2021-07-30T04:56:25
2021-08-11T05:45:21
125,484,161
58
49
BSD-3-Clause
2022-10-16T19:31:26
2018-03-16T08:07:37
null
UTF-8
C++
false
false
9,188
cc
/* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * (C) 2006 Alexey Proskuryakov (ap@nypop.com) * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. * (http://www.torchmobile.com/) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "third_party/blink/renderer/platform/network/form_data_encoder.h" #include <limits> #include "base/rand_util.h" #include "third_party/blink/renderer/platform/wtf/text/cstring.h" #include "third_party/blink/renderer/platform/wtf/text/text_encoding.h" namespace blink { // Helper functions static inline void Append(Vector<char>& buffer, char string) { buffer.push_back(string); } static inline void Append(Vector<char>& buffer, const char* string) { buffer.Append(string, static_cast<wtf_size_t>(strlen(string))); } static inline void Append(Vector<char>& buffer, const CString& string) { buffer.Append(string.data(), string.length()); } static inline void AppendPercentEncoded(Vector<char>& buffer, unsigned char c) { const char kHexChars[] = "0123456789ABCDEF"; const char tmp[] = {'%', kHexChars[c / 16], kHexChars[c % 16]}; buffer.Append(tmp, sizeof(tmp)); } static void AppendQuotedString(Vector<char>& buffer, const CString& string) { // Append a string as a quoted value, escaping quotes and line breaks. // FIXME: Is it correct to use percent escaping here? Other browsers do not // encode these characters yet, so we should test popular servers to find out // if there is an encoding form they can handle. size_t length = string.length(); for (size_t i = 0; i < length; ++i) { char c = string.data()[i]; switch (c) { case 0x0a: Append(buffer, "%0A"); break; case 0x0d: Append(buffer, "%0D"); break; case '"': Append(buffer, "%22"); break; default: Append(buffer, c); } } } WTF::TextEncoding FormDataEncoder::EncodingFromAcceptCharset( const String& accept_charset, const WTF::TextEncoding& fallback_encoding) { DCHECK(fallback_encoding.IsValid()); String normalized_accept_charset = accept_charset; normalized_accept_charset.Replace(',', ' '); Vector<String> charsets; normalized_accept_charset.Split(' ', charsets); for (const String& name : charsets) { WTF::TextEncoding encoding(name); if (encoding.IsValid()) return encoding; } return fallback_encoding; } Vector<char> FormDataEncoder::GenerateUniqueBoundaryString() { Vector<char> boundary; // TODO(rsleevi): crbug.com/575779: Follow the spec or fix the spec. // The RFC 2046 spec says the alphanumeric characters plus the // following characters are legal for boundaries: '()+_,-./:=? // However the following characters, though legal, cause some sites // to fail: (),./:=+ // // Note that our algorithm makes it twice as much likely for 'A' or 'B' // to appear in the boundary string, because 0x41 and 0x42 are present in // the below array twice. static const char kAlphaNumericEncodingMap[64] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42}; // Start with an informative prefix. Append(boundary, "----WebKitFormBoundary"); // Append 16 random 7bit ascii AlphaNumeric characters. char random_bytes[16]; base::RandBytes(random_bytes, sizeof(random_bytes)); for (char& c : random_bytes) c = kAlphaNumericEncodingMap[c & 0x3F]; boundary.Append(random_bytes, sizeof(random_bytes)); boundary.push_back( 0); // Add a 0 at the end so we can use this as a C-style string. return boundary; } void FormDataEncoder::BeginMultiPartHeader(Vector<char>& buffer, const CString& boundary, const CString& name) { AddBoundaryToMultiPartHeader(buffer, boundary); // FIXME: This loses data irreversibly if the input name includes characters // you can't encode in the website's character set. Append(buffer, "Content-Disposition: form-data; name=\""); AppendQuotedString(buffer, name); Append(buffer, '"'); } void FormDataEncoder::AddBoundaryToMultiPartHeader(Vector<char>& buffer, const CString& boundary, bool is_last_boundary) { Append(buffer, "--"); Append(buffer, boundary); if (is_last_boundary) Append(buffer, "--"); Append(buffer, "\r\n"); } void FormDataEncoder::AddFilenameToMultiPartHeader( Vector<char>& buffer, const WTF::TextEncoding& encoding, const String& filename) { // Characters that cannot be encoded using the form's encoding will // be escaped using numeric character references, e.g. &#128514; for // 😂. // // This behavior is intended to match existing Firefox and Edge // behavior. // // This aspect of multipart file upload (how to replace filename // characters not representable in the form charset) is not // currently specified in HTML, though it may be a good candidate // for future standardization. An HTML issue tracker entry has // been added for this: https://github.com/whatwg/html/issues/3223 // // This behavior also exactly matches the already-standardized // replacement behavior from HTML for entity names and values in // multipart form data. The HTML standard specifically overrides RFC // 7578 in this case and leaves the actual substitution mechanism // implementation-defined. // // See also: // // https://html.spec.whatwg.org/C/#multipart-form-data // https://www.chromestatus.com/features/5634575908732928 // https://crbug.com/661819 // https://encoding.spec.whatwg.org/#concept-encoding-process // https://tools.ietf.org/html/rfc7578#section-4.2 // https://tools.ietf.org/html/rfc5987#section-3.2 Append(buffer, "; filename=\""); AppendQuotedString(buffer, encoding.Encode(filename, WTF::kEntitiesForUnencodables)); Append(buffer, '"'); } void FormDataEncoder::AddContentTypeToMultiPartHeader(Vector<char>& buffer, const String& mime_type) { Append(buffer, "\r\nContent-Type: "); Append(buffer, mime_type.Utf8()); } void FormDataEncoder::FinishMultiPartHeader(Vector<char>& buffer) { Append(buffer, "\r\n\r\n"); } void FormDataEncoder::AddKeyValuePairAsFormData( Vector<char>& buffer, const CString& key, const CString& value, EncodedFormData::EncodingType encoding_type, Mode mode) { if (encoding_type == EncodedFormData::kTextPlain) { Append(buffer, key); Append(buffer, '='); Append(buffer, value); Append(buffer, "\r\n"); } else { if (!buffer.IsEmpty()) Append(buffer, '&'); EncodeStringAsFormData(buffer, key, mode); Append(buffer, '='); EncodeStringAsFormData(buffer, value, mode); } } void FormDataEncoder::EncodeStringAsFormData(Vector<char>& buffer, const CString& string, Mode mode) { // Same safe characters as Netscape for compatibility. static const char kSafeCharacters[] = "-._*"; // http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1 unsigned length = string.length(); for (unsigned i = 0; i < length; ++i) { unsigned char c = string.data()[i]; if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c != '\0' && strchr(kSafeCharacters, c))) { Append(buffer, c); } else if (c == ' ') { Append(buffer, '+'); } else { if (mode == kNormalizeCRLF) { if (c == '\n' || (c == '\r' && (i + 1 >= length || string.data()[i + 1] != '\n'))) { Append(buffer, "%0D%0A"); } else if (c != '\r') { AppendPercentEncoded(buffer, c); } } else { AppendPercentEncoded(buffer, c); } } } } } // namespace blink
[ "sunny.nam@samsung.com" ]
sunny.nam@samsung.com
89c33260a468556b3ad2b93e6ea60abd2de96922
fdb963647dc9317947943874a51f58c1240f994c
/project/Framework/Transition/MistTransitionMask.cpp
945c01ec16cdc43b6bdf7378f9c30106e0319c69
[ "MIT" ]
permissive
SomeTake/HF21MisotenH206
0f2e5e92a71ef4c89b43c4ebd8d3a0bf632f03b4
821d8d4ec8b40c236ac6b0e6e7ba5f89c06b950d
refs/heads/master
2020-07-25T07:44:09.728095
2020-01-17T10:15:03
2020-01-17T10:15:03
208,212,885
0
2
MIT
2020-01-17T08:00:14
2019-09-13T07:02:16
C++
SHIFT_JIS
C++
false
false
2,606
cpp
//===================================== // //ミストトランジションマスク処理[MistTransitionMask.cpp] //Author:GP12A332 21 立花雄太 // //===================================== #include "MistTransitionMask.h" #include "../Renderer2D/Polygon2D.h" /************************************** マクロ定義 ***************************************/ #define MISTTRANSITION_ALPHAREF_MAX (255.0f) #define MISTRANSITION_DURATION (60) #define MISTTRANSITION_TEX_NAME "data/TRANSITION/MistMask.png" /************************************** コンストラクタ ***************************************/ MistTransitionMask::MistTransitionMask() { //ポリゴン初期化 polygon = new Polygon2D(); polygon->SetSize((float)SCREEN_WIDTH, (float)SCREEN_HEIGHT); polygon->LoadTexture(MISTTRANSITION_TEX_NAME); polygon->SetPosition(D3DXVECTOR3((float)SCREEN_CENTER_X, (float)SCREEN_CENTER_Y, 0.0f)); } /************************************** デストラクタ ***************************************/ MistTransitionMask::~MistTransitionMask() { SAFE_DELETE(polygon); } /************************************** 更新処理 ***************************************/ MaskResult MistTransitionMask::Update() { if (!active) return MaskResult::Continuous; MaskResult res = MaskResult::Continuous; cntFrame++; float t = (float)cntFrame / MISTRANSITION_DURATION; alphaRef = (DWORD)Easing::EaseValue(t, startRef, endRef, type); if (cntFrame == MISTRANSITION_DURATION) { res = isTransitionOut ? MaskResult::FinishTransitionOut : MaskResult::FinishTransitionIn; active = false; } return res; } /************************************** 描画処理 ***************************************/ void MistTransitionMask::Draw() { if (!active) return; LPDIRECT3DDEVICE9 pDevice = GetDevice(); //マスク開始 BeginMask(); //元のアルファ参照値を保存し切り替え DWORD defAlphaRef; pDevice->GetRenderState(D3DRS_ALPHAREF, &defAlphaRef); pDevice->SetRenderState(D3DRS_ALPHAREF, alphaRef); //マスク領域描画 polygon->Draw(); //マスク終了 EndMask(); //アルファ参照値をもとに戻す pDevice->SetRenderState(D3DRS_ALPHAREF, defAlphaRef); } /************************************** セット処理 ***************************************/ void MistTransitionMask::Set(bool isOut) { if (active) return; alphaRef = 0; cntFrame = 0; active = true; isTransitionOut = isOut; type = isOut ? EaseType::OutCubic : EaseType::OutCubic; startRef = isOut ? MISTTRANSITION_ALPHAREF_MAX : 0; endRef = MISTTRANSITION_ALPHAREF_MAX - startRef; }
[ "yuta.tachibana0310@gmail.com" ]
yuta.tachibana0310@gmail.com
1c56bf5541bfdf2074af6b30e5c36128fa82e69d
937cbf2d0d90ab901cc3ed8d97948bb9b4c73460
/SimpleFramework/ClientDesign.h
f06ff6d79ee9a968089578684af3440977fe7143
[]
no_license
tkorays/wxWidgetsDemo
73029663d197d26e0ad0fbed87f4d6ba0181036c
efc49fe2e039b16535194fe37b6ab1375ff66a0b
refs/heads/master
2021-01-16T19:02:45.083884
2014-07-08T10:50:24
2014-07-08T10:50:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
146
h
#ifndef _TK_CLIENTDESIGN_H_ #define _TK_CLIENTDESIGN_H_ class ClientDesign{ private: public: ClientDesign(); }; #endif // _TK_CLIENTDESIGN_H_
[ "tkorays@hotmail.com" ]
tkorays@hotmail.com
6e46246e0cffdbab2dfb52c9047501f6cefdc0c7
388a2c6aa8cd0d6c15df8e8dae419a746f0ed7cc
/src/var/derived/multi_sum_var_node.hpp
ba05d533a21d928f1d67e8159b0799c71c7bea4f
[ "BSD-3-Clause" ]
permissive
standardgalactic/nomad
013b486ed9be3f3d512cc1ba8f76a61844f0371e
a21149ef9f4d53a198e6fdb06cfd0363d3df69e7
refs/heads/master
2022-02-28T21:16:21.863458
2015-01-29T11:30:45
2015-01-29T11:30:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,119
hpp
#ifndef nomad__src__var__derived__multi_sum_var_node_hpp #define nomad__src__var__derived__multi_sum_var_node_hpp #include <src/var/var_node.hpp> namespace nomad { template<short AutodiffOrder> class multi_sum_var_node: public var_node_base { public: static inline void* operator new(size_t /* ignore */) { if (unlikely(next_node_idx_ + 1 > max_node_idx)) expand_var_nodes<AutodiffOrder>(); // no partials if (unlikely(next_inputs_idx_ + next_inputs_delta > max_inputs_idx)) expand_inputs(); return var_nodes_ + next_node_idx_; } static inline void operator delete(void* /* ignore */) {} multi_sum_var_node(nomad_idx_t n_inputs): var_node_base(n_inputs) {} inline nomad_idx_t n_first_partials() { return 0; } inline nomad_idx_t n_second_partials() { return 0; } inline nomad_idx_t n_third_partials() { return 0; } inline static nomad_idx_t n_partials(nomad_idx_t n_inputs) { (void)n_inputs; return 0; } inline void first_order_forward_adj() { if (AutodiffOrder >= 1) { if (n_inputs_) first_grad() = 0; double g1 = 0; for (nomad_idx_t i = 0; i < n_inputs_; ++i) g1 += first_grad(input(i)); first_grad() += g1; } } inline void first_order_reverse_adj() { if (AutodiffOrder >= 1) { const double g1 = first_grad(); for (nomad_idx_t i = 0; i < n_inputs_; ++i) first_grad(input(i)) += g1; } } void second_order_forward_val() { if (AutodiffOrder >= 2) { if (n_inputs_) second_val() = 0; second_grad() = 0; double v2 = 0; for (nomad_idx_t i = 0; i < n_inputs_; ++i) v2 += second_val(input(i)); second_val() += v2; } } void second_order_reverse_adj() { if (AutodiffOrder >= 2) { const double g2 = second_grad(); for (nomad_idx_t i = 0; i < n_inputs_; ++i) second_grad(input(i)) += g2; } } void third_order_forward_val() { if (AutodiffOrder >= 3) { if (n_inputs_) { third_val() = 0; fourth_val() = 0; } third_grad() = 0; fourth_grad() = 0; double v3 = 0; double v4 = 0; for (nomad_idx_t i = 0; i < n_inputs_; ++i) { v3 += third_val(input(i)); v4 += fourth_val(input(i)); } third_val() = v3; fourth_val() = v4; } } // third_order_forward_val void third_order_reverse_adj() { if (AutodiffOrder >= 3) { const double g3 = third_grad(); const double g4 = fourth_grad(); for (nomad_idx_t i = 0; i < n_inputs_; ++i) { third_grad(input(i)) += g3; fourth_grad(input(i)) += g4; } } } // third_order_reverse_adj }; } #endif
[ "betanalpha@gmail.com" ]
betanalpha@gmail.com
951e9d003fb7a6755dc685a08846ca575456f847
157608821099c1837bb6bd2030aff54f7adb7074
/Zork_C++/QT-The King Of Fish(Liangyue Yu Yusen Wang)/thirdWidge/thirdWidge/mainwindow.cpp
d09f46971077326822829b02d4f0fd651ab27ebf
[]
no_license
Liangyue-1998/Event-Driven-Programming-2018
ac5d02e70b49d6b22054ea0e9d497c203479d3d7
fe3e8e35ba981522d529afc9d48a606f9de98e31
refs/heads/master
2023-02-10T15:31:56.722482
2021-01-10T00:09:47
2021-01-10T00:09:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,458
cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include "Room.h" #include <QLinkedList> #include <QHash> #include <QQueue> #include <QPointF> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); zorkUL.printWelcome(); updateRoomItemsView(); updateProgressBarState(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::paintRoomBorder(QPainter* painter,Room* room, int roomPixels, int roomLocX, int roomLocY, int offsetX, int offsetY){ int x = offsetX + roomPixels * roomLocX; int y = offsetY + roomPixels * roomLocY; painter->setPen(QPen(Qt::black,2,Qt::SolidLine)); painter->setBrush(QBrush(Qt::gray,Qt::SolidPattern)); painter->drawRect(x, y, roomPixels, roomPixels); if(room == this->zorkUL.getCurrentRoom()) { painter->setBrush(QBrush(Qt::lightGray,Qt::SolidPattern)); painter->drawRect(x, y, roomPixels, roomPixels); painter->setPen(QPen(Qt::yellow,0,Qt::SolidLine)); painter->setBrush(QBrush(Qt::yellow,Qt::SolidPattern)); //painter->drawEllipse(QPoint(x + roomPixels/2, y + roomPixels/2), 5, 5); painter->drawImage(QPoint(x + roomPixels/2 - 12, y + roomPixels/2 - 12), QImage(":/imgs/player.png"), QRect(0,0,24,24)); } } void MainWindow::paintRoomItems(QPainter* painter, Room* room,int roomPixels, int roomLocX, int roomLocY, int offsetX, int offsetY){ int basex = offsetX + roomPixels * roomLocX; int basey = offsetY + roomPixels * roomLocY; int count = room->numberOfItems(); for (int i=0;i<count;i++) { int x = basex + 5 + i*6; int y = basey + 5; painter->setPen(QPen(Qt::black,0,Qt::SolidLine)); painter->setBrush(QBrush(Qt::red,Qt::SolidPattern)); painter->drawEllipse(x, y, 3, 3); } if(room->getMonster()!=NULL) { int x = basex + 5; int y = basey + roomPixels - 30; painter->setPen(QPen(Qt::black,0,Qt::SolidLine)); painter->setBrush(QBrush(Qt::green,Qt::SolidPattern)); //painter->drawRect(x, y, 10, 10); painter->drawImage(QPoint(x, y), QImage(":/imgs/monster.png"), QRect(0,0,24,24)); } if(room->nextRoom("north")!=NULL) { QPointF points[3]; points[0] = QPointF(basex+roomPixels/2, basey); points[1] = QPointF(basex+roomPixels/2-4,basey+6); points[2] = QPointF(basex+roomPixels/2+4,basey+6); painter->setPen(QPen(Qt::black,0,Qt::SolidLine)); painter->setBrush(QBrush(Qt::black,Qt::SolidPattern)); painter->drawPolygon(points,3); setStyleSheet( "QPushButton{" "background-color:rgba(100,225,100,30);" "border-style:outset;" "border-width:4px;" "border-radius:10px;" "border-color:rgba(255,255,255,30);" "font:bold 20px;" "color:rgba(0,0,0,100);" "padding:10px;" "}" "QPushButton:pressed{" "background-color:rgba(100,255,100,200);" "border-color:rgba(255,255,255,30);" "border-style:inset;" "color:rgba(0,0,0,100);" "}" "QPushButton:hover{" "background-color:rgba(100,255,100,100);" "border-color:rgba(255,255,255,200);" "color:rgba(0,0,0,200);" "}"); } if(room->nextRoom("south")!=NULL) { QPointF points[3]; points[0] = QPointF(basex+roomPixels/2, basey+roomPixels); points[1] = QPointF(basex+roomPixels/2-4,basey+roomPixels-6); points[2] = QPointF(basex+roomPixels/2+4,basey+roomPixels-6); painter->setPen(QPen(Qt::black,0,Qt::SolidLine)); painter->setBrush(QBrush(Qt::black,Qt::SolidPattern)); painter->drawPolygon(points,3); } if(room->nextRoom("west")!=NULL) { QPointF points[3]; points[0] = QPointF(basex, basey+roomPixels/2); points[1] = QPointF(basex+6,basey+roomPixels/2-4); points[2] = QPointF(basex+6,basey+roomPixels/2+4); painter->setPen(QPen(Qt::black,0,Qt::SolidLine)); painter->setBrush(QBrush(Qt::black,Qt::SolidPattern)); painter->drawPolygon(points,3); } if(room->nextRoom("east")!=NULL) { QPointF points[3]; points[0] = QPointF(basex+roomPixels, basey+roomPixels/2); points[1] = QPointF(basex+roomPixels-6,basey+roomPixels/2-4); points[2] = QPointF(basex+roomPixels-6,basey+roomPixels/2+4); painter->setPen(QPen(Qt::black,0,Qt::SolidLine)); painter->setBrush(QBrush(Qt::black,Qt::SolidPattern)); painter->drawPolygon(points,3); } } void MainWindow::paintRoom(Room* room, QSet<Room*>& visited, QPainter* painter, int roomPixels, int roomLocX, int roomLocY, int offsetX, int offsetY) { if(visited.contains(room)) return; visited.insert(room); paintRoomBorder(painter,room, roomPixels, roomLocX, roomLocY, offsetX, offsetY); paintRoomItems(painter,room, roomPixels, roomLocX, roomLocY, offsetX, offsetY); Room* north_room = room->nextRoom("north"); Room* south_room = room->nextRoom("south"); Room* east_room = room->nextRoom("east"); Room* west_room = room->nextRoom("west"); if(north_room!=NULL) paintRoom(north_room, visited, painter, roomPixels, roomLocX, roomLocY-1, offsetX, offsetY); if(south_room!=NULL) paintRoom(south_room, visited, painter, roomPixels, roomLocX, roomLocY+1, offsetX, offsetY); if(east_room!=NULL) paintRoom(east_room, visited, painter, roomPixels, roomLocX+1, roomLocY, offsetX, offsetY); if(west_room!=NULL) paintRoom(west_room, visited, painter, roomPixels, roomLocX-1, roomLocY, offsetX, offsetY); } void MainWindow::paintEvent(QPaintEvent*) { QPainter painter(this); int roomPixels = 100; int offsetX = 50; int offsetY = 50; int roomLocX = 3; int roomLocY = 2; QSet<Room*> visited; paintRoom(this->zorkUL.getStartRoom(), visited, &painter, roomPixels, roomLocX, roomLocY, offsetX, offsetY); painter.end(); } void MainWindow::updateRoomItemsView() { auto curRoom = zorkUL.getCurrentRoom(); this->ui->lst_items->clear(); for (int i=0;i< curRoom->numberOfItems();i++) { Item* item = curRoom->getItem(i); if(item->getType()!="weapon") continue; Weapon* weapon = (Weapon*)item; string desp = item->getShortDescription() + "(+" + to_string(weapon->getPower()) + ")"; this->ui->lst_items->addItem(new QListWidgetItem(QString(desp.c_str()))); } } void MainWindow::updateInventory() { Character* player = zorkUL.getPlayer(); this->ui->lst_inventory->clear(); for(int i=0;i<player->itemsCount();i++) { Item* item = player->getItem(i); if(item->getType()!="weapon") continue; Weapon* weapon = (Weapon*)item; string desp = item->getShortDescription() + "(+" + to_string(weapon->getPower()) + ")"; this->ui->lst_inventory->addItem(new QListWidgetItem(QString(desp.c_str()))); } } void MainWindow::updateProgressBarState() { Room* room = zorkUL.getCurrentRoom(); Monster* monster = room->getMonster(); ui->prog_player->setValue(zorkUL.getPlayer()->getHealthy()*100.0/zorkUL.getPlayer()->getMaxHealthy()); if(monster==NULL) { ui->lbl_monster->hide(); ui->prog_monster->hide(); }else{ ui->prog_monster->setValue(monster->getHealthy()*100.0/monster->getMaxHealthy()); ui->lbl_monster->show(); ui->prog_monster->show(); } } void MainWindow::on_btn_left_clicked() { zorkUL.processCommand(Command("go","west")); updateRoomItemsView(); updateProgressBarState(); this->repaint(); // auto curRoom = this->zorkUL.getCurrentRoom(); // this->zorkUL.go("west"); // if(curRoom!=zorkUL.getCurrentRoom()){ // updateRoomItemsView(); // updateProgressBarState(); // this->repaint(); // } } void MainWindow::on_btn_down_clicked() { zorkUL.processCommand(Command("go","south")); updateRoomItemsView(); updateProgressBarState(); this->repaint(); // auto curRoom = this->zorkUL.getCurrentRoom(); // this->zorkUL.go("south"); // if(curRoom!=zorkUL.getCurrentRoom()){ // updateRoomItemsView(); // updateProgressBarState(); // this->repaint(); // } } void MainWindow::on_btn_right_clicked() { zorkUL.processCommand(Command("go","east")); updateRoomItemsView(); updateProgressBarState(); this->repaint(); // auto curRoom = this->zorkUL.getCurrentRoom(); // this->zorkUL.go("east"); // if(curRoom!=zorkUL.getCurrentRoom()){ // updateRoomItemsView(); // updateProgressBarState(); // this->repaint(); // } } void MainWindow::on_btn_up_clicked() { zorkUL.processCommand(Command("go","north")); updateRoomItemsView(); updateProgressBarState(); this->repaint(); // auto curRoom = this->zorkUL.getCurrentRoom(); // this->zorkUL.go("north"); // if(curRoom!=zorkUL.getCurrentRoom()){ // updateRoomItemsView(); // updateProgressBarState(); // this->repaint(); // } } void MainWindow::on_btn_pick_clicked() { int idx = -1; int count = ui->lst_items->count(); for(int i=0; i<count;i++) { auto item = ui->lst_items->item(i); if(item->isSelected()){ idx = i; } } if(idx>-1){ zorkUL.processCommand(Command("take",to_string(idx))); this->updateRoomItemsView(); this->updateInventory(); } } void MainWindow::on_btn_drop_clicked() { int idx = -1; int count = ui->lst_inventory->count(); for(int i=0; i<count;i++) { auto item = ui->lst_inventory->item(i); if(item->isSelected()){ idx = i; } } if(idx>-1){ zorkUL.processCommand(Command("put",to_string(idx))); this->updateRoomItemsView(); this->updateInventory(); } } void MainWindow::on_btn_attack_clicked() { Monster* monster = zorkUL.getCurrentRoom()->getMonster(); if(monster!=NULL) { zorkUL.processCommand(Command("attack","")); updateProgressBarState(); if(zorkUL.getPlayer()->getHealthy()==0) { QMessageBox::about(NULL, "Hint", "You Dead!"); this->close(); } this->repaint(); } if(zorkUL.isGameOver()) { QMessageBox::about(NULL, "Hint", "You Win!"); this->close(); } } void MainWindow::on_menu_exit_triggered() { this->close(); } void MainWindow::on_btn_teleport_clicked() { zorkUL.processCommand(Command("teleport","")); this->repaint(); this->updateRoomItemsView(); this->updateInventory(); } void MainWindow::on_pushButton_clicked() { zorkUL.processCommand(Command("quit","")); QMessageBox::about(NULL, "Titlt","Now, You have been transported the initial room.\n"); } void MainWindow::on_btn_info_clicked() { QMessageBox::about(NULL, "Rules", "1、Controlling the move of player by clicking 'up''left''roght''down'\n" "2、If there are equipment in the room, player can pick up it intp inventory\n" "3、Player can drop their equipment on the room where the player is standing\n" "4、Clicking the teleport can be transported to a random room\n" "5、Clicking the quit, player will go back to the initial room\n" "6、Clicking the attrack can hurt the monster, but the monster also can hurt the player\n" "7、If there is no blood to the monster, the player is win, else the player is lose\n"); }
[ "774389574@qq.com" ]
774389574@qq.com
de9eb9dd125bc1464592f2ac90125446b7ae25c2
1c9f99b2b2e3835038aba7ec0abc3a228e24a558
/Projects/elastix/elastix_sources_v4/src/Core/ComponentBaseClasses/elxOptimizerBase.h
f5617047dcd070e9ab57a8abe062058b756ed5f5
[]
no_license
mijc/Diploma
95fa1b04801ba9afb6493b24b53383d0fbd00b33
bae131ed74f1b344b219c0ffe0fffcd90306aeb8
refs/heads/master
2021-01-18T13:57:42.223466
2011-02-15T14:19:49
2011-02-15T14:19:49
1,369,569
0
0
null
null
null
null
UTF-8
C++
false
false
4,880
h
/*====================================================================== This file is part of the elastix software. Copyright (c) University Medical Center Utrecht. All rights reserved. See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php 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. ======================================================================*/ #ifndef __elxOptimizerBase_h #define __elxOptimizerBase_h /** Needed for the macros */ #include "elxMacro.h" #include "elxBaseComponentSE.h" #include "itkOptimizer.h" namespace elastix { using namespace itk; /** * \class OptimizerBase * \brief This class is the elastix base class for all Optimizers. * * This class contains all the common functionality for Optimizers. * * The parameters used in this class are: * \parameter NewSamplesEveryIteration: if this flag is set to "true" some * optimizers ask the metric to select a new set of spatial samples in * every iteration. This, if used in combination with the correct optimizer (such as the * StandardGradientDescent), and ImageSampler (Random, RandomCoordinate, or RandomSparseMask), * allows for a very low number of spatial samples (around 2000), even with large images * and transforms with a large number of parameters.\n * Choose one from {"true", "false"} for every resolution.\n * example: <tt>(NewSamplesEveryIteration "true" "true" "true")</tt> \n * Default is "false" for every resolution.\n * * \ingroup Optimizers * \ingroup ComponentBaseClasses */ template <class TElastix> class OptimizerBase : public BaseComponentSE<TElastix> { public: /** Standard ITK-stuff. */ typedef OptimizerBase Self; typedef BaseComponentSE<TElastix> Superclass; /** Run-time type information (and related methods). */ itkTypeMacro( OptimizerBase, BaseComponentSE ); /** Typedefs inherited from Elastix. */ typedef typename Superclass::ElastixType ElastixType; typedef typename Superclass::ElastixPointer ElastixPointer; typedef typename Superclass::ConfigurationType ConfigurationType; typedef typename Superclass::ConfigurationPointer ConfigurationPointer; typedef typename Superclass::RegistrationType RegistrationType; typedef typename Superclass::RegistrationPointer RegistrationPointer; /** ITKBaseType. */ typedef itk::Optimizer ITKBaseType; /** Typedef needed for the SetCurrentPositionPublic function. */ typedef typename ITKBaseType::ParametersType ParametersType; /** Cast to ITKBaseType. */ virtual ITKBaseType * GetAsITKBaseType(void) { return dynamic_cast<ITKBaseType *>(this); } /** Cast to ITKBaseType, to use in const functions. */ virtual const ITKBaseType * GetAsITKBaseType(void) const { return dynamic_cast<const ITKBaseType *>(this); } /** Add empty SetCurrentPositionPublic, so this function is known in every inherited class. */ virtual void SetCurrentPositionPublic( const ParametersType &param ); /** Execute stuff before each new pyramid resolution: * \li Find out if new samples are used every new iteration in this resolution. */ virtual void BeforeEachResolutionBase(); /** Method that sets the scales defined by a sinus * scale[i] = amplitude^( sin(i/nrofparam*2pi*frequency) ) */ virtual void SetSinusScales(double amplitude, double frequency, unsigned long numberOfParameters); protected: /** The constructor. */ OptimizerBase(); /** The destructor. */ virtual ~OptimizerBase() {} /** Force the metric to base its computation on a new subset of image samples. * Not every metric may have implemented this. */ virtual void SelectNewSamples(void); /** Check whether the user asked to select new samples every iteration. */ virtual const bool GetNewSamplesEveryIteration(void) const; private: /** The private constructor. */ OptimizerBase( const Self& ); // purposely not implemented /** The private copy constructor. */ void operator=( const Self& ); // purposely not implemented /** Member variable to store the user preference for using new * samples each iteration. */ bool m_NewSamplesEveryIteration; }; // end class OptimizerBase } // end namespace elastix #ifndef ITK_MANUAL_INSTANTIATION #include "elxOptimizerBase.hxx" #endif #endif // end #ifndef __elxOptimizerBase_h
[ "maik.stille@gmail.com" ]
maik.stille@gmail.com
b5d0d1ac988c2035f5f3e7ffb7070cc715fd5d04
a7fd3ffe2257dd8bdb9977c2ff38833d52455555
/src/main.cpp
5737c990fbe9d51e88513fb416f7ce195cbc7baa
[]
no_license
Edward-Elric233/MEA
66b498b20a93f826cb5004f0e3283a9581f46a0d
93238d067c6c9761d0d1911bba0b38a07062b13c
refs/heads/master
2023-08-10T01:24:24.833316
2021-09-16T16:49:44
2021-09-16T16:49:44
406,364,183
0
0
null
null
null
null
UTF-8
C++
false
false
1,174
cpp
#include "data.h" #include "work.h" #include "Solution.h" #include <iostream> #include <fstream> #include <cstring> #include <iterator> #include <ctime> #include <queue> using namespace std; int main(int argc, char *argv[]) { ios::sync_with_stdio(false); // clock_t start = clock(); data::time = atoi(argv[1]); data::seed = atoi(argv[2]); data::expires = clock() + (data::time - 5) * CLOCKS_PER_SEC; // ifstream is("../data/fjsp.brandimarte.Mk01.m6j10c3.txt"); read(std::cin); shared_ptr<Solution> ans = make_shared<Solution>(); for (int i = 0; i < 10; ++i) { auto S = MAE(); if (S->getMakeSpan() < ans->getMakeSpan()) { ans = S; } if (clock() > data::expires) break; } cout << *ans; // cout << (static_cast<double>(clock()) - start) / CLOCKS_PER_SEC << "s\n"; /* Solution S; cout << S << endl; cout << S.getMakeSpan() << endl; */ /* auto S = make_shared<Solution>(); string line; while(getline(cin, line)) { S = Solution::tabuSearch(S); cout << *S << endl; cout << S->getMakeSpan() << endl; } */ return 0; }
[ "2511136711@qq.com" ]
2511136711@qq.com
bd1d5c3e3cb2566af33acc23f9fce3e821fe025d
d184027d0fd8eed8e319800698491dfbc1f285b7
/src/my_robot_tutorials/src/number_counter.cpp
f107728cbab1c2bea1c4ca6de9d41af6a4715e0a
[]
no_license
davidsonic/ros-template
d983161fa2704add67a1de089377a5374f5a6a4a
8c08cbb035cfc08cc9c1dd945e7285c7ee171252
refs/heads/master
2020-05-23T18:02:48.035256
2019-05-18T06:04:39
2019-05-18T06:04:39
186,879,175
0
0
null
null
null
null
UTF-8
C++
false
false
1,003
cpp
#include <ros/ros.h> #include <std_msgs/Int64.h> #include <std_srvs/SetBool.h> int counter =0; ros::Publisher pub; void callback_number(const std_msgs::Int64&msg){ counter += msg.data; std_msgs::Int64 new_msg; new_msg.data = counter; pub.publish(new_msg); } bool callback_reset_counter(std_srvs::SetBool::Request &req, std_srvs::SetBool::Response &res){ if(req.data){ counter =0; res.success = true; res.message = "counter has been reset"; } else{ res.success = false; res.message="counter has not been reset"; } return true; } int main(int argc, char **argv){ ros::init(argc, argv, "number_counter"); ros::NodeHandle nh; ros::Subscriber sub = nh.subscribe("/number", 1000, callback_number); pub = nh.advertise<std_msgs::Int64>("/number_count", 10); ros::ServiceServer reset_service = nh.advertiseService("/reset_counter", callback_reset_counter); ros::spin(); }
[ "davidsonic@163.com" ]
davidsonic@163.com
148d6556ed132fa9019dca1e1d973575e1cc935c
16cce1bbe1a6c5171bd473299c78a4f4a8fda939
/snippets/segment_trees.cpp
ee44267a105cbbbe29e60688b382e649360e544f
[]
no_license
jscslg/Competitive-Programming
2922f3d875527db2f165a4d44d51e79aa006fab5
2a04009d897b89ac39506a5790eda5ebde65abaa
refs/heads/master
2023-07-17T00:43:39.607029
2021-09-06T09:54:20
2021-09-06T09:54:20
280,100,176
1
0
null
null
null
null
UTF-8
C++
false
false
1,160
cpp
template<class T> class SegTree{ vector<T> seg; int n; T build(const vector<T>&,int,int,int=0); T (*combine)(T,T); public: SegTree(vector<T> a,T (*combine)(T,T)){ n=a.size(); this->combine=combine; seg.assign(pow(2,ceil(log2(n))+1)-1,0); build(a,0,n-1); } void print(){ tr(e,seg) cout<<e<<" "; cout<<endl; } T update(int,int,int,T,int=0); T get(int,int,int,int,int=0); }; template <class T> T SegTree<T>::build(const vector<T> &a,int l,int r,int i){ if(l==r) return seg[i]=a[l]; int m=l+(r-l)/2; return seg[i]=combine(build(a,l,m,i*2+1),build(a,m+1,r,i*2+2)); } template <class T> T SegTree<T>::get(int l,int r,int ql, int qr, int i){ if(qr<l||ql>r) return 0; if(qr>=r&&ql<=l) return seg[i]; int m=l+(r-l)/2; return combine(get(l,m,ql,qr,i*2+1),get(m+1,r,ql,qr,i*2+2)); } template <class T> T SegTree<T>::update(int l,int r,int q,T val,int i){ if(l==r) return seg[i]=val; int m=l+(r-l)/2; if(q<=m) return seg[i]=combine(update(l,m,q,val,i*2+1),seg[i*2+2]); else return seg[i]=combine(seg[i*2+1],update(m+1,r,q,val,i*2+2)); }
[ "jscslg27@gmail.com" ]
jscslg27@gmail.com
04ad300499e02b366b54a55b95e1176627af6224
3af8b24f33fecaa9c890bf77e4710fd437ac9445
/Phase_1/3_Proposed_Solution/Source_Code/mem/cache/tags/lru.cc
848051e698332ba75146d413f449acefd9e5b785
[]
no_license
swethasiva/cacheEnhancement
9327ab4e09fecfc7125228cb8eca6d27dcdd72c0
d0e74b7621b308a6586108a1d7cd1eb29e14bbf0
refs/heads/master
2020-03-23T12:54:50.904860
2018-07-23T09:52:24
2018-07-23T09:52:24
141,589,601
1
2
null
null
null
null
UTF-8
C++
false
false
11,163
cc
/* * Copyright (c) 2012-2013 ARM Limited * All rights reserved. * * The license below extends only to copyright in the software and shall * not be construed as granting a license to any other intellectual * property including but not limited to intellectual property relating * to a hardware implementation of the functionality of the software * licensed hereunder. You may use the software subject to the license * terms below provided that you ensure that this notice is replicated * unmodified and in its entirety in all distributions of the software, * modified or unmodified, in source code or in binary form. * * Copyright (c) 2003-2005,2014 The Regents of The University of Michigan * 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 copyright holders 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. * * Authors: Erik Hallnor */ /** * @file * Definitions of a LRU tag store. */ #include "debug/CacheRepl.hh" #include "mem/cache/tags/lru.hh" #include "mem/cache/base.hh" LRU::LRU(const Params *p) : BaseSetAssoc(p) { } CacheBlk* LRU::accessBlock(Addr addr, bool is_secure, Cycles &lat, int master_id) { CacheBlk *blk = BaseSetAssoc::accessBlock(addr, is_secure, lat, master_id); if (blk != NULL) { /** Begin of Changes - Phase 1 */ int threshold = 8; char flag; if(blk->counter != threshold-1){ blk->counter++; blk->writeCount++; } else { flag = 'X'; for(int i = 1; i < assoc; i++){ BlkType *temp_blk = sets[blk->set].blks[i]; if(temp_blk->counter == 0){ /* Finding the number of transition for moving from hot block to cold block */ const uint8_t *incoming = blk->data; const uint8_t *existing = temp_blk->data; int parser = 0; while(parser < 8) { uint64_t new_data, old_data; new_data = (uint64_t) incoming[0] | (uint64_t) incoming[1] << 8 | (uint64_t) incoming[2] << 16 | (uint64_t) incoming[3] << 24 | (uint64_t) incoming[4] << 32 | (uint64_t) incoming[5] << 40 | (uint64_t) incoming[6] << 48 | (uint64_t) incoming[7] << 56; old_data = (uint64_t) existing[0] | (uint64_t) existing[1] << 8 | (uint64_t) existing[2] << 16 | (uint64_t) existing[3] << 24 | (uint64_t) existing[4] << 32 | (uint64_t) existing[5] << 40 | (uint64_t) existing[6] << 48 | (uint64_t) existing[7] << 56; int j = 0; while(j < 64){ bool old_bit = old_data & 1; bool new_bit = new_data & 1; /* Calculating the number of 0 to 1 transition & 1 to 0 transition */ if(old_bit != new_bit) { if(old_bit == 0){ temp_blk->transition_01++; blk->transition_10++; } else { temp_blk->transition_10++; blk->transition_01++; } temp_blk->total_trans++; blk->total_trans++; } old_data = old_data >> 1; new_data = new_data >> 1; j++; } incoming += 8; existing += 8; parser++; } /* Swapping the number of write hit value */ unsigned long int temp = temp_blk->writeCount; temp_blk->writeCount = blk->writeCount; blk->writeCount = temp; /* Swapping the number of read hit value */ temp = temp_blk->Totalwrite; temp_blk->Totalwrite = blk->Totalwrite; blk->Totalwrite = temp; /* Swapping the number of 0 to 1 transition */ temp = temp_blk->transition_01; temp_blk->transition_01 = blk->transition_01; blk->transition_01 = temp; /* Swapping the number of 1 to 0 transition */ temp = temp_blk->transition_10; temp_blk->transition_10 = blk->transition_10; blk->transition_10 = temp; /* Swapping the number of transition */ temp = temp_blk->total_trans; temp_blk->total_trans = blk->total_trans; blk->total_trans = temp; blk->counter = temp_blk->counter = threshold/2; flag = 'Y'; blk->writeCount++; temp_blk->writeCount++; blk->Totalwrite++; temp_blk->Totalwrite++; break; } } if(flag == 'X'){ for(int i = 1; i < assoc; i++){ BlkType *temp_blk = sets[blk->set].blks[i]; temp_blk->counter--; } blk->writeCount++; } } /** End of Changes - Phase 1 */ // move this block to head of the MRU list sets[blk->set].moveToHead(blk); DPRINTF(CacheRepl, "set %x: moving blk %x (%s) to MRU\n", blk->set, regenerateBlkAddr(blk->tag, blk->set), is_secure ? "s" : "ns"); } return blk; } CacheBlk* LRU::findVictim(Addr addr, PacketPtr pkt, bool isTopLevel) // change - Phase 1 { int set = extractSet(addr); // grab a replacement candidate /** Begin of Changes - Phase 1 */ const uint8_t *temp = pkt->getConstPtr<uint8_t>(); BlkType *target = NULL; if(isTopLevel){ target = sets[set].blks[assoc-1]; } else { char avail = 'N', inv = 'N'; int threshold = 8; int t_01 = 0, t_10 = 0, inv_01 = 0, inv_10 = 0, trans_01 = 513, trans_10 = 513; for(int i = 0; i < assoc; i++){ BlkType *check_blk = sets[set].blks[i]; if(check_blk->counter == 0){ avail = 'Y'; break; } } /** Integrating with LER */ for(int i = assoc-1; i >= 0; i--){ t_01 = 0, t_10 = 0, inv_01 = 0, inv_10 = 0; BlkType *blk = sets[set].blks[i]; if(blk->counter == threshold-1 && avail == 'Y') continue; const uint8_t *incoming = temp; const uint8_t *existing = blk->data; int parser = 0; while(parser < 8) { uint64_t new_data, old_data; new_data = (uint64_t) incoming[0] | (uint64_t) incoming[1] << 8 | (uint64_t) incoming[2] << 16 | (uint64_t) incoming[3] << 24 | (uint64_t) incoming[4] << 32 | (uint64_t) incoming[5] << 40 | (uint64_t) incoming[6] << 48 | (uint64_t) incoming[7] << 56; old_data = (uint64_t) existing[0] | (uint64_t) existing[1] << 8 | (uint64_t) existing[2] << 16 | (uint64_t) existing[3] << 24 | (uint64_t) existing[4] << 32 | (uint64_t) existing[5] << 40 | (uint64_t) existing[6] << 48 | (uint64_t) existing[7] << 56; if(blk->inv_flag == 'Y') old_data = ~old_data; int j = 0; while(j < 64){ bool old_bit = old_data & 1; bool new_bit = new_data & 1; if(old_bit != new_bit) { if(old_bit == 0) t_01++; else t_10++; } else { if(old_bit == 0) inv_01++; else inv_10++; } old_data = old_data >> 1; new_data = new_data >> 1; j++; } incoming += 8; existing += 8; parser++; } if(t_01 < trans_01 && t_01 < inv_01 && !(blk->isValid())){ trans_01 = t_01; trans_10 = t_10; target = blk; inv = 'N'; } else { trans_01 = inv_01; trans_10 = inv_10; target = blk; inv = 'Y'; } } if(target == NULL){ for(int i = assoc-1; i >= 0; i--){ t_01 = 0, t_10 = 0, inv_01 = 0, inv_10 = 0; BlkType *blk = sets[set].blks[i]; if(blk->counter == threshold-1 && avail == 'Y') continue; const uint8_t *incoming = temp; const uint8_t *existing = blk->data; int parser = 0; while(parser < 8) { uint64_t new_data, old_data; new_data = (uint64_t) incoming[0] | (uint64_t) incoming[1] << 8 | (uint64_t) incoming[2] << 16 | (uint64_t) incoming[3] << 24 | (uint64_t) incoming[4] << 32 | (uint64_t) incoming[5] << 40 | (uint64_t) incoming[6] << 48 | (uint64_t) incoming[7] << 56; old_data = (uint64_t) existing[0] | (uint64_t) existing[1] << 8 | (uint64_t) existing[2] << 16 | (uint64_t) existing[3] << 24 | (uint64_t) existing[4] << 32 | (uint64_t) existing[5] << 40 | (uint64_t) existing[6] << 48 | (uint64_t) existing[7] << 56; int j = 0; while(j < 64){ bool old_bit = old_data & 1; bool new_bit = new_data & 1; if(old_bit != new_bit) { if(old_bit == 0) t_01++; else t_10++; } else { if(old_bit == 0) inv_01++; else inv_10++; } old_data = old_data >> 1; new_data = new_data >> 1; j++; } incoming += 8; existing += 8; parser++; } if(t_01 < trans_01 && t_01 < inv_01){ trans_01 = t_01; trans_10 = t_10; target = blk; inv = 'N'; } else { trans_01 = inv_01; trans_10 = inv_10; target = blk; inv = 'Y'; } } } target->transition_01 += trans_01; target->transition_10 += trans_10; target->total_trans += trans_01 + trans_10; target->writeCount++; target->Totalwrite++; target->inv_flag = inv; if(target->counter == threshold-1 && avail == 'N'){ for(int i = 0; i < assoc; i++){ BlkType *check_blk = sets[set].blks[i]; if(check_blk != target) check_blk->counter--; } } else { target->counter++; } } /** End of Changes - Phase 1 */ if (target->isValid()) { DPRINTF(CacheRepl, "set %x: selecting blk %x for replacement\n", set, regenerateBlkAddr(target->tag, set)); } return target; } void LRU::insertBlock(PacketPtr pkt, BlkType *blk) { BaseSetAssoc::insertBlock(pkt, blk); int set = extractSet(pkt->getAddr()); sets[set].moveToHead(blk); } void LRU::invalidate(CacheBlk *blk) { BaseSetAssoc::invalidate(blk); // should be evicted before valid blocks int set = blk->set; sets[set].moveToTail(blk); } LRU* LRUParams::create() { return new LRU(this); }
[ "swethadav@gmail.com" ]
swethadav@gmail.com
3b62d8374db04507b2309222c3ce4fc8f28a5f11
16e2f9d88b7163edf13fac603157bec32a58e54d
/include/aka/rtl/object_base.h
47e6b219c3720a0c23cc7838423c7d6e3021dfde
[ "MIT" ]
permissive
vadim-platonov/aka
3823a60bb5c5aac21b6f814752627a330bd1dd0c
2d9fef3cd0490d07dad790d6f2d6db238ee26eb3
refs/heads/master
2021-01-22T21:21:53.740786
2017-03-19T14:44:38
2017-03-19T14:44:38
85,416,046
0
0
null
null
null
null
UTF-8
C++
false
false
599
h
#ifndef AKA_OBJECT_BASE_H #define AKA_OBJECT_BASE_H #include <atomic> namespace aka { template <typename I> class ObjectBase : public I { public: ObjectBase() : m_ref(1) { } std::uint32_t AddRef() override { return ++m_ref; } std::uint32_t Release() override { if } result_t QueryInteface(iid_t iid, ptr_t* object) override { if (iid == I::m_iid) { *object = this; *object->AddRef(); } } private: std::atomic<std::uint32_t> m_ref; }; } #endif //AKA_OBJECT_BASE_H
[ "Vadim Platonov" ]
Vadim Platonov