blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
cc6dcbed6fff70d5292ffc25e335edf217157e5d
c2d270aff0a4d939f43b6359ac2c564b2565be76
/src/chrome/app/chrome_crash_reporter_client.cc
e9d3fa825b547f184a8f1f9d588b8380289e2188
[ "BSD-3-Clause" ]
permissive
bopopescu/QuicDep
dfa5c2b6aa29eb6f52b12486ff7f3757c808808d
bc86b705a6cf02d2eade4f3ea8cf5fe73ef52aa0
refs/heads/master
2022-04-26T04:36:55.675836
2020-04-29T21:29:26
2020-04-29T21:29:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,630
cc
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/app/chrome_crash_reporter_client.h" #include "base/command_line.h" #include "base/environment.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/path_service.h" #include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths_internal.h" #include "chrome/common/chrome_result_codes.h" #include "chrome/common/crash_keys.h" #include "chrome/common/env_vars.h" #include "chrome/installer/util/google_update_settings.h" #include "content/public/common/content_switches.h" #if defined(OS_POSIX) && !defined(OS_MACOSX) #include "components/upload_list/crash_upload_list.h" #include "components/version_info/version_info_values.h" #endif #if defined(OS_POSIX) #include "base/debug/dump_without_crashing.h" #endif #if defined(OS_ANDROID) #include "chrome/common/descriptors_android.h" #endif #if defined(OS_CHROMEOS) #include "chrome/common/channel_info.h" #include "chromeos/chromeos_switches.h" #include "components/version_info/version_info.h" #endif ChromeCrashReporterClient::ChromeCrashReporterClient() {} ChromeCrashReporterClient::~ChromeCrashReporterClient() {} #if !defined(OS_MACOSX) void ChromeCrashReporterClient::SetCrashReporterClientIdFromGUID( const std::string& client_guid) { crash_keys::SetMetricsClientIdFromGUID(client_guid); } #endif #if defined(OS_POSIX) && !defined(OS_MACOSX) void ChromeCrashReporterClient::GetProductNameAndVersion( const char** product_name, const char** version) { DCHECK(product_name); DCHECK(version); #if defined(OS_ANDROID) *product_name = "Chrome_Android"; #elif defined(OS_CHROMEOS) *product_name = "Chrome_ChromeOS"; #else // OS_LINUX #if !defined(ADDRESS_SANITIZER) *product_name = "Chrome_Linux"; #else *product_name = "Chrome_Linux_ASan"; #endif #endif *version = PRODUCT_VERSION; } base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() { return base::FilePath(CrashUploadList::kReporterLogFilename); } #endif bool ChromeCrashReporterClient::GetCrashDumpLocation( base::FilePath* crash_dir) { // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate // location to write breakpad crash dumps can be set. std::unique_ptr<base::Environment> env(base::Environment::Create()); std::string alternate_crash_dump_location; if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_crash_dump_location)) { base::FilePath crash_dumps_dir_path = base::FilePath::FromUTF8Unsafe(alternate_crash_dump_location); PathService::Override(chrome::DIR_CRASH_DUMPS, crash_dumps_dir_path); } return PathService::Get(chrome::DIR_CRASH_DUMPS, crash_dir); } size_t ChromeCrashReporterClient::RegisterCrashKeys() { return crash_keys::RegisterChromeCrashKeys(); } bool ChromeCrashReporterClient::IsRunningUnattended() { std::unique_ptr<base::Environment> env(base::Environment::Create()); return env->HasVar(env_vars::kHeadless); } bool ChromeCrashReporterClient::GetCollectStatsConsent() { #if defined(GOOGLE_CHROME_BUILD) bool is_official_chrome_build = true; #else bool is_official_chrome_build = false; #endif #if defined(OS_CHROMEOS) bool is_guest_session = base::CommandLine::ForCurrentProcess()->HasSwitch( chromeos::switches::kGuestSession); bool is_stable_channel = chrome::GetChannel() == version_info::Channel::STABLE; if (is_guest_session && is_stable_channel) return false; #endif // defined(OS_CHROMEOS) #if defined(OS_ANDROID) // TODO(jcivelli): we should not initialize the crash-reporter when it was not // enabled. Right now if it is disabled we still generate the minidumps but we // do not upload them. return is_official_chrome_build; #else // !defined(OS_ANDROID) return is_official_chrome_build && GoogleUpdateSettings::GetCollectStatsConsent(); #endif // defined(OS_ANDROID) } #if defined(OS_ANDROID) int ChromeCrashReporterClient::GetAndroidMinidumpDescriptor() { return kAndroidMinidumpDescriptor; } #endif bool ChromeCrashReporterClient::EnableBreakpadForProcess( const std::string& process_type) { return process_type == switches::kRendererProcess || process_type == switches::kPpapiPluginProcess || process_type == switches::kZygoteProcess || process_type == switches::kGpuProcess || process_type == switches::kUtilityProcess; }
[ "rdeshm0@aptvm070-6.apt.emulab.net" ]
rdeshm0@aptvm070-6.apt.emulab.net
acd9709523f34be72cf5b1491cb5bf1339997bf4
e0e7c6ec2a65ddcae2f40f33aaecdf2aca372577
/hackerrank/data-structures/linked lists/reverse-a-doubly-linked-list.cpp
d2dcbb00c49937fcb00a8c91f3b5812612c3f461
[ "MIT" ]
permissive
ParinVachhani/coding-practice
c77349f603634031d68e1a3df60bef6a7ae801fb
2268215b1e1f26bfe09d0dfb4f94366594a6ef37
refs/heads/master
2020-03-15T20:47:52.334115
2018-07-12T22:17:15
2018-07-12T22:17:15
132,341,183
2
0
null
null
null
null
UTF-8
C++
false
false
2,736
cpp
// https://www.hackerrank.com/challenges/reverse-a-doubly-linked-list #include <bits/stdc++.h> using namespace std; class DoublyLinkedListNode { public: int data; DoublyLinkedListNode *next; DoublyLinkedListNode *prev; DoublyLinkedListNode(int node_data) { this->data = node_data; this->next = nullptr; this->prev = nullptr; } }; class DoublyLinkedList { public: DoublyLinkedListNode *head; DoublyLinkedListNode *tail; DoublyLinkedList() { this->head = nullptr; this->tail = nullptr; } void insert_node(int node_data) { DoublyLinkedListNode* node = new DoublyLinkedListNode(node_data); if (!this->head) { this->head = node; } else { this->tail->next = node; node->prev = this->tail; } this->tail = node; } }; void print_doubly_linked_list(DoublyLinkedListNode* node, string sep, ofstream& fout) { while (node) { fout << node->data; node = node->next; if (node) { fout << sep; } } } void free_doubly_linked_list(DoublyLinkedListNode* node) { while (node) { DoublyLinkedListNode* temp = node; node = node->next; free(temp); } } // Complete the reverse function below. /* * For your reference: * * DoublyLinkedListNode { * int data; * DoublyLinkedListNode* next; * DoublyLinkedListNode* prev; * }; * */ DoublyLinkedListNode* reverse(DoublyLinkedListNode* head) { DoublyLinkedListNode* temp = head; DoublyLinkedListNode* newHead = head; while(temp){ DoublyLinkedListNode* prev = temp->prev; temp->prev = temp->next; temp->next = prev; newHead = temp; temp = temp->prev; } return newHead; } int main() { ofstream fout(getenv("OUTPUT_PATH")); int t; cin >> t; cin.ignore(numeric_limits<streamsize>::max(), '\n'); for (int t_itr = 0; t_itr < t; t_itr++) { DoublyLinkedList* llist = new DoublyLinkedList(); int llist_count; cin >> llist_count; cin.ignore(numeric_limits<streamsize>::max(), '\n'); for (int i = 0; i < llist_count; i++) { int llist_item; cin >> llist_item; cin.ignore(numeric_limits<streamsize>::max(), '\n'); llist->insert_node(llist_item); } DoublyLinkedListNode* llist1 = reverse(llist->head); print_doubly_linked_list(llist1, " ", fout); fout << "\n"; free_doubly_linked_list(llist1); } fout.close(); return 0; }
[ "vachhaniparin@gmail.com" ]
vachhaniparin@gmail.com
44c3ab2c47bc42e1189c026e2504032174f149ae
c06d20cb9b5174fac7f3ce407b6006cbcf4e53c3
/src/m_argv.cpp
7ef202ab854ad75d132b2a896a913b676e15bfc8
[]
no_license
dptetc/DooMB
a4484b24f12a2213fb46fcab2338141b06d4dc47
18425e260227d819b0c6d084473f8f1bbbc21243
refs/heads/master
2022-12-14T21:56:56.556756
2020-09-20T21:23:53
2020-09-20T21:23:53
127,284,332
0
1
null
null
null
null
UTF-8
C++
false
false
3,147
cpp
// Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // // $Id:$ // // Copyright (C) 1993-1996 by id Software, Inc. // // This source is available for distribution and/or modification // only under the terms of the DOOM Source Code License as // published by id Software. All rights reserved. // // The source is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License // for more details. // // $Log:$ // // DESCRIPTION: // //----------------------------------------------------------------------------- #include <string.h> #include "m_argv.h" #include "cmdlib.h" IMPLEMENT_CLASS (DArgs, DObject) DArgs::DArgs () { m_ArgC = 0; m_ArgV = NULL; } DArgs::DArgs (int argc, char **argv) { CopyArgs (argc, argv); } DArgs::DArgs (const DArgs &other) { CopyArgs (other.m_ArgC, other.m_ArgV); } DArgs::~DArgs () { FlushArgs (); } DArgs &DArgs::operator= (const DArgs &other) { FlushArgs (); CopyArgs (other.m_ArgC, other.m_ArgV); return *this; } void DArgs::SetArgs (int argc, char **argv) { FlushArgs (); CopyArgs (argc, argv); } void DArgs::CopyArgs (int argc, char **argv) { int i; m_ArgC = argc; m_ArgV = new char *[argc]; for (i = 0; i < argc; i++) m_ArgV[i] = copystring (argv[i]); } void DArgs::FlushArgs () { int i; for (i = 0; i < m_ArgC; i++) delete[] m_ArgV[i]; delete[] m_ArgV; m_ArgC = 0; m_ArgV = NULL; } // // CheckParm // Checks for the given parameter in the program's command line arguments. // Returns the argument number (1 to argc-1) or 0 if not present // int DArgs::CheckParm (const char *check) const { int i; for (i = 1; i < m_ArgC; i++) if (!stricmp (check, m_ArgV[i])) return i; return 0; } char *DArgs::CheckValue (const char *check) const { int i = CheckParm (check); if (i > 0 && i < m_ArgC - 1) return m_ArgV[i+1]; else return NULL; } char *DArgs::GetArg (int arg) const { if (arg >= 0 && arg < m_ArgC) return m_ArgV[arg]; else return NULL; } char **DArgs::GetArgList (int arg) const { if (arg >= 0 && arg < m_ArgC) return &m_ArgV[arg]; else return NULL; } int DArgs::NumArgs () const { return m_ArgC; } void DArgs::AppendArg (const char *arg) { char **temp = new char *[m_ArgC + 1]; if (m_ArgV) { memcpy (temp, m_ArgV, sizeof(*m_ArgV) * m_ArgC); delete[] m_ArgV; } temp[m_ArgC] = copystring (arg); m_ArgV = temp; m_ArgC++; } DArgs *DArgs::GatherFiles (const char *param, const char *extension, bool acceptNoExt) const { DArgs *out = new DArgs; int i; int extlen = strlen (extension); for (i = 1; i < m_ArgC && *m_ArgV[i] != '-' && *m_ArgV[i] != '+'; i++) { int len = strlen (m_ArgV[i]); if (len >= extlen && stricmp (m_ArgV[i] + len - extlen, extension) == 0) out->AppendArg (m_ArgV[i]); else if (acceptNoExt && !strrchr (m_ArgV[i], '.')) out->AppendArg (m_ArgV[i]); } i = CheckParm (param); if (i) { for (i++; i < m_ArgC && *m_ArgV[i] != '-' && *m_ArgV[i] != '+'; i++) out->AppendArg (m_ArgV[i]); } return out; }
[ "SIMPSON-NEKEK@mail.ru" ]
SIMPSON-NEKEK@mail.ru
dcfdcb208b208373cbc452b496f63130e10d2a9e
eb74bc3eba5306327f2903d46a377bd752c16ee3
/Demo/Vertex.cpp
156b6efb343f0f57b278d0a7a68577a9b08880f5
[]
no_license
Roy-zZZ08/WavePacket
51e75fa92e9614102162c52e4e29c7f4dd1f93b8
181e856e57e4a6cee14a1d067acf906f650154bc
refs/heads/master
2023-06-17T02:27:16.165718
2021-07-07T08:21:21
2021-07-07T08:21:21
378,196,683
0
0
null
null
null
null
UTF-8
C++
false
false
1,986
cpp
#include "Vertex.h" const D3D11_INPUT_ELEMENT_DESC VertexPos::inputLayout[1] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; const D3D11_INPUT_ELEMENT_DESC VertexPosColor::inputLayout[2] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; const D3D11_INPUT_ELEMENT_DESC VertexPosTex::inputLayout[2] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; const D3D11_INPUT_ELEMENT_DESC VertexPosSize::inputLayout[2] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "SIZE", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; const D3D11_INPUT_ELEMENT_DESC VertexPosNormalColor::inputLayout[3] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; const D3D11_INPUT_ELEMENT_DESC VertexPosNormalTex::inputLayout[3] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; const D3D11_INPUT_ELEMENT_DESC VertexPosNormalTangentTex::inputLayout[4] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TANGENT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 40, D3D11_INPUT_PER_VERTEX_DATA, 0 } };
[ "57007138+Roy-zZZ08@users.noreply.github.com" ]
57007138+Roy-zZZ08@users.noreply.github.com
b87bd443bfe4010177b9bb81034ebbc3617802c7
1b0aadb6dc881bf363cbebbc59ac0c41a956ed5c
/xtk/Samples/Controls/WindowPos/WindowPos.cpp
f81fa3df6a1dea420a345c91718558406e51d523
[]
no_license
chinatiny/OSS
bc60236144d73ab7adcbe52cafbe610221292ba6
87b61b075f00b67fd34cfce557abe98ed6f5be70
refs/heads/master
2022-09-21T03:11:09.661243
2018-01-02T10:12:35
2018-01-02T10:12:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,218
cpp
// WindowPos.cpp : Defines the class behaviors for the application. // // This file is a part of the XTREME TOOLKIT PRO MFC class library. // (c)1998-2007 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "WindowPos.h" #include "MainFrm.h" #include "ChildFrm.h" #include "WindowPosDoc.h" #include "WindowPosView.h" #include "AboutDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CWindowPosApp BEGIN_MESSAGE_MAP(CWindowPosApp, CWinApp) //{{AFX_MSG_MAP(CWindowPosApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP // Standard file based document commands ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) // Standard print setup command ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWindowPosApp construction CWindowPosApp::CWindowPosApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CWindowPosApp object CWindowPosApp theApp; ///////////////////////////////////////////////////////////////////////////// // CWindowPosApp initialization BOOL CWindowPosApp::InitInstance() { AfxEnableControlContainer(); CXTPWinDwmWrapper().SetProcessDPIAware(); // 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. #if _MSC_VER <= 1200 // MFC 6.0 or earlier #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif #endif // MFC 6.0 or earlier // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("Codejock Software Sample Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_WINDOWTYPE, RUNTIME_CLASS(CWindowPosDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CWindowPosView)); AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The main window has been initialized, so show and update it. pMainFrame->ShowWindowEx(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; } // App command to run the dialog void CWindowPosApp::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } ///////////////////////////////////////////////////////////////////////////// // CWindowPosApp message handlers
[ "w.z.y2006@163.com" ]
w.z.y2006@163.com
2efc900e1806de46a6c38d34181be3567fc47b2e
beaeefee8412d35e8afee2643098dbc3870d47bc
/src/EAWebkit/Webkit-owb/generated_sources/WebCore/JSDocumentType.h
00d1927f0f861e1ae340f559d7bc706ce688876f
[]
no_license
weimingtom/duibrowser
831d13626c8560b2b4c270dcc8d2bde746fe8dba
74f4b51f741978f5a9d3b3509e6267fd261e9d3f
refs/heads/master
2021-01-10T01:36:36.573836
2012-05-11T16:38:17
2012-05-11T16:38:17
43,038,328
1
0
null
null
null
null
UTF-8
C++
false
false
2,353
h
/* This file is part of the WebKit open source project. This file has been generated by generate-bindings.pl. DO NOT MODIFY! 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. */ #ifndef JSDocumentType_h #define JSDocumentType_h #include "JSNode.h" #include "DocumentType.h" namespace WebCore { class DocumentType; class JSDocumentType : public JSNode { typedef JSNode Base; public: JSDocumentType(KJS::JSObject* prototype, DocumentType*); virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier& propertyName, KJS::PropertySlot&); KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const; virtual const KJS::ClassInfo* classInfo() const { return &s_info; } static const KJS::ClassInfo s_info; static KJS::JSValue* getConstructor(KJS::ExecState*); enum { // Attributes NameAttrNum, EntitiesAttrNum, NotationsAttrNum, PublicIdAttrNum, SystemIdAttrNum, InternalSubsetAttrNum, // The Constructor Attribute ConstructorAttrNum }; DocumentType* impl() const { return static_cast<DocumentType*>(Base::impl()); } }; DocumentType* toDocumentType(KJS::JSValue*); class JSDocumentTypePrototype : public KJS::JSObject { public: static KJS::JSObject* self(KJS::ExecState*); virtual const KJS::ClassInfo* classInfo() const { return &s_info; } static const KJS::ClassInfo s_info; JSDocumentTypePrototype(KJS::ExecState* exec) : KJS::JSObject(JSNodePrototype::self(exec)) { } }; } // namespace WebCore #endif
[ "achellies@hotmail.com" ]
achellies@hotmail.com
f543dd1c612ea4009663c143246348f7495f0da3
bb3908bf65ea7afad20de582b9c3d60920e5bfae
/kumattcp/src/mulio.cpp
1758b11f188867a0e1d9d5c298c635459a97155f
[]
no_license
kumagi/skip-graph
16f3c6ddd51e7086874d6aad71f2781e86e0ef40
4e183875fd3f86c3f5ff7d52c3f3980e4d9b4ba1
refs/heads/master
2021-01-13T14:20:27.511201
2010-03-03T16:56:53
2010-03-03T16:56:53
373,037
3
0
null
null
null
null
UTF-8
C++
false
false
3,527
cpp
#include "mulio.h" int mulio::calcMaxFd(void){ int max=0; mSocketList.sort(); if( mSocketList.back() > max ){ max = mSocketList.back(); } if( mAcceptSocket > max ){ max = mAcceptSocket; } if( awaker[0] > max ){ max = awaker[0]; } if( awaker[1] > max ){ max = awaker[1]; } return max; } int mulio::fds_set_all(fd_set* fds){ FD_ZERO(fds); FD_SET(mAcceptSocket,fds); FD_SET(awaker[0],fds); mSocketList.sort(); std::list<int>::iterator it = mSocketList.begin(); while( it != mSocketList.end() ){ FD_SET( *it, fds ); ++it; } --it; int max = mAcceptSocket > awaker[0] ? mAcceptSocket : awaker[0]; max = max > *it ? max : *it; return max; } void mulio::SetCallback(int (*cb)(int)){ callback = cb; } void mulio::SetAcceptSocket(int socket){ mAcceptSocket = socket; if( socket > mMaxFd ){ mMaxFd = socket; } } void mulio::worker(void){ fd_set fds_clone; mMaxFd = fds_set_all(&fds); while(1){ memcpy(&fds_clone,&fds,sizeof(fds)); select(mMaxFd+1, &fds_clone, NULL ,NULL ,NULL); if(FD_ISSET(awaker[0],&fds_clone)){ // rebuild fds and mSocketList char dummy; read(awaker[0],&dummy,1); // delete by DeleteList for(unsigned int i=0; i < mDeleteSocket.size(); i++){ FD_CLR(mDeleteSocket[i],&fds_clone); mSocketList.remove(mDeleteSocket[i]); if( mDeleteSocket[i] == mMaxFd ){ mMaxFd = calcMaxFd(); } } mDeleteSocket.clear(); // add by AddList for(unsigned int i=0; i < mAddSocket.size(); i++){ FD_SET(mAddSocket[i],&fds_clone); mSocketList.push_back(mAddSocket[i]); if( mAddSocket[i] > mMaxFd ){ mMaxFd = mAddSocket[i]; } } mAddSocket.clear(); } if(FD_ISSET(mAcceptSocket,&fds_clone)){ // accept sockaddr_in clientaddr; socklen_t addrlen = sizeof(sockaddr_in); int newsocket = accept(mAcceptSocket, (struct sockaddr*)&clientaddr, &addrlen); mSocketList.push_back(newsocket); FD_SET( newsocket ,&fds ); if( mMaxFd < newsocket){ mMaxFd = newsocket; } }else { // read std::list<int>::iterator it = mSocketList.begin(); while( it != mSocketList.end() ){ if( FD_ISSET(*it,&fds )){ FD_CLR(*it, &fds); mActiveSocket.push_back(*it); sem_post(&sem_active); } ++it; } } } } void mulio::eventloop(void){ int socket,deleteflag; while(1){ sem_wait(&sem_active); socket = mActiveSocket[0]; mActiveSocket.pop_front(); deleteflag = (*callback)(socket); if( deleteflag == 0 ){ mAddSocket.push_back( socket ); write(awaker[1],"",1); }else { mDeleteSocket.push_back( socket ); write(awaker[1],"",1); } } } void mulio::run(void){ assert(mAcceptSocket && "set the Listening Socket"); assert(callback != NULL && "set the callback function"); pthread_create(&mythread,NULL,thread_pass,this); } mulio::mulio(void){ pipe(awaker); sem_init(&sem_active,0,0); mMaxFd=awaker[0]; } mulio::~mulio(void){ close(awaker[0]); close(awaker[1]); std::list<int>::iterator it = mSocketList.begin(); while( it != mSocketList.end() ){ close(*it); ++it; } pthread_cancel(mythread); sem_destroy(&sem_active); } void* thread_pass(void* Imulio){ class mulio* Imuliop=(class mulio*)Imulio; Imuliop->worker(); return NULL; } /* class CHoge { private: void ChildThread() { while( 1 ); } friend int child_thread( void* pThis ); }; namespace { int child_thread( void* pThis ) { ( (CHoge*) pThis )->ChildThread(); } }//namespace CHoge hoge; beginthread( child_thread, &hoge ); */
[ "rintyo@gmail.com" ]
rintyo@gmail.com
3c7288ec1844b1e50ea30c9288c56017cd6a0250
884cd6f2668af90611fde11318bec2c17fbc1c8c
/Source/FirstParty/AllInOneSolution/AllInOneSolution/Core/gui/Cursor.hpp
f8d3155fd1cf1b0e40b21635e8fa2f4cef2c8a6f
[]
no_license
Roflo/spieleprogrammierer-forenprojekt
3cde5a4cbe92b226e5936aa03b1aeef1eb76b2ab
65621c9426a2ca4d0ac349480a8344884a1812b2
refs/heads/master
2021-01-01T20:01:29.368451
2015-03-08T19:51:22
2015-03-08T19:51:22
39,471,729
0
0
null
null
null
null
UTF-8
C++
false
false
535
hpp
#pragma once #ifndef CURSOR_HPP #define CURSOR_HPP #include "../resources/ResourceManager.hpp" #include "../rendering/DrawParameter.hpp" #include <SFML/Graphics/RenderWindow.hpp> /// Mouse cursor replacing the system cursor. class Cursor : public Drawable { public: Cursor(ResourceManager& resourceManager, const sf::RenderWindow& screen); void update(); void draw(const DrawParameter& params); private: sf::Sprite m_sprite; const sf::RenderWindow& m_screen; }; #endif // CURSOR_HPP
[ "qword5E@gmail.com" ]
qword5E@gmail.com
c5ea78478e571ba5d9da4eb8a0780c1fb997de3c
f6df646005a75fb598bd773a717773f56c017d59
/1.cc
4acf0618d97098b2240f8433299b3906382fedcc
[]
no_license
Tillychang/ProducerandConsumer
b276f6f0c43aaf880f88b454cdb1d986916c4f9a
b596a640bd4ebbc8c2c5888bb59118d6702ade09
refs/heads/master
2021-01-18T14:19:24.127849
2014-10-07T08:52:36
2014-10-07T08:52:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
205
cc
#include <iostream> #include <string> #include <vector> #include "Thread.h" using namespace std; int main(int argc, const char *argv[]) { Thread t; t.start() ; t.join() ; return 0; }
[ "test@ubuntu.(none)" ]
test@ubuntu.(none)
f5527504b2fc3aea3ea4f5f693248402c2d33606
5a2d11ba611dff4b0a3dbfeb3251928108886023
/src/test03/chartview.h
73122bd35adb7178169ef2db17b620f176dcb213
[]
no_license
animic/coin3dtest
37bdf406bdb271eb67624ff7f8f9248e5154d45e
7c8eff24688b717b4a4cb334f65d86a1ad15f833
refs/heads/main
2023-04-25T20:47:55.960514
2021-05-30T10:46:10
2021-05-30T10:46:10
361,610,914
0
0
null
null
null
null
UTF-8
C++
false
false
2,065
h
/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Charts module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 or (at your option) any later version ** approved by the KDE Free Qt Foundation. The licenses are as published by ** the Free Software Foundation and appearing in the file LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef CHARTVIEW_H #define CHARTVIEW_H #include <QtCharts/QChartView> #include <QtWidgets/QRubberBand> QT_CHARTS_USE_NAMESPACE //![1] class ChartView : public QChartView //![1] { public: ChartView(QWidget *parent = 0); ~ChartView(); public: void init(); //![2] protected: bool viewportEvent(QEvent *event); void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void keyPressEvent(QKeyEvent *event); void connectMarkers(); void disconnectMarkers(); public slots: void handleMarkerClicked(); //![2] private: bool m_isTouching; }; #endif
[ "448395347@qq.com" ]
448395347@qq.com
7538652ef137c84a74115b761a20c57f00c745bd
61602e75ce83d23673f7d445acbaaa2677047a93
/11727.cpp
9d1091903737e37b215de4ed68d2254fab6dca64
[]
no_license
chae-chae/BaekJoon
2b3615f54b0d34e9ccb0730471a00caf03f9bb35
189b10d9d53880be636bcc31ee92cf6b9fce3e87
refs/heads/master
2023-08-23T12:32:06.952224
2023-08-23T11:55:35
2023-08-23T11:55:35
222,130,458
0
0
null
2020-01-04T15:34:19
2019-11-16T16:51:21
C++
UTF-8
C++
false
false
465
cpp
// // 11727.cpp // BaekJoon // // Created by 채채 on 11/01/2020. // Copyright © 2020 chaechae. All rights reserved. // #include <stdio.h> int d[1001]; int calc(int n); int main(void){ int n; scanf("%d", &n); printf("%d\n", calc(n)); return 0; } int calc(int n){ if (n == 1) return 1; if (n == 2) return 3; if (d[n] != 0) return d[n]; return d[n] = (calc(n-1) + 2*calc(n-2)) % 10007; // 점화식 찾기 연습 더하기 }
[ "noreply@github.com" ]
noreply@github.com
9e4ee4e1c803f2342ccc9ca5118e5baba69370bc
b4828cf9403fedde5dd346b3338a5f4bf0f1eb96
/leetcode_sol/1510-Stone_Game_IV.cpp
9594045842dab5367390ee5d7cd3818b94137a72
[]
no_license
Masters-Akt/CS_codes
9ab3d87ca384ebd364c7b87c8da94b753082a7e3
1aaa107439f2e208bb67b0bcca676f90b6bc6a11
refs/heads/master
2023-01-24T00:11:05.151592
2023-01-21T18:45:57
2023-01-21T18:45:57
292,529,160
6
7
null
null
null
null
UTF-8
C++
false
false
329
cpp
class Solution { public: bool winnerSquareGame(int n) { vector<bool> dp(n+1, false); for(int i=1;i<=n;i++){ for(int j=1;j*j<=i;j++) { if(!dp[i-j*j]){ dp[i]=true; break; } } } return dp[n]; } };
[ "64123046+Masters-Akt@users.noreply.github.com" ]
64123046+Masters-Akt@users.noreply.github.com
bde0b2ce31a1b63d927486e18f7f17b16fe5bdf5
4e5452470d072483d610e194db4c08150eecb72e
/main.cpp
27017ecda4c61df9c017c304e184d477a487e11a
[]
no_license
liyandong1/Coroutine
48a7640d585f7144c79222ef043ea2433e2a6473
ba4fdf4ffbbbdd9a6e741ddd2b534179ee72a5cd
refs/heads/master
2020-05-23T22:17:47.916436
2019-05-16T07:04:08
2019-05-16T07:04:08
186,970,933
0
0
null
null
null
null
UTF-8
C++
false
false
1,238
cpp
#include <iostream> #include <functional> #include <sys/time.h> #include "Schedule.h" using namespace std; using namespace coroutine; using namespace std::placeholders; void func1(Schedule* schedule) { while(1) { cout << "Id =" << schedule->getRunningCoroutineId() << endl; schedule->suspendCurrentCoroutine(); } } void func2(Schedule* schedule) { while(1) { cout << "Id =" << schedule->getRunningCoroutineId() << endl; schedule->suspendCurrentCoroutine(); } } int main() { Schedule schedule; int coutotine1 = schedule.createCoroutine(func1); int coutotine2 = schedule.createCoroutine(func2); const int kMicrosecondsPerSecond = 1000 * 1000; struct timeval tv_start; gettimeofday(&tv_start, NULL); int64_t start = static_cast<int64_t>(tv_start.tv_sec) * kMicrosecondsPerSecond + tv_start.tv_usec; for(int i = 0; i < 1000000; i ++) { schedule.runCoroutineById(coutotine1); schedule.runCoroutineById(coutotine2); } struct timeval tv_end; gettimeofday(&tv_end, NULL); int64_t end = static_cast<int64_t>(tv_end.tv_sec) * kMicrosecondsPerSecond + tv_end.tv_usec; cout << "Total time of switching 40M times: " << \ static_cast<double>(end - start)/kMicrosecondsPerSecond << "s" << endl; return 0; }
[ "416620418@qq.com" ]
416620418@qq.com
9dc4e5d4e87a45a26a88f5655747e342fb6d3be1
7c002430d8ba1f9f6efee4c494e6685538f41b96
/Assignments_CPP/MP2_AcceleratedRayTracing/MP2_AcceleratedRayTracing/BVHNode.h
46fa86af21be9d89b3c230b0317cf3c40c5065b8
[]
no_license
SukritGaneshUIUC/CS419
9eca50479a2fe6bf40b21fc3a7f33a50bd526bfc
50356c6bdd1ee82cb510a5102584d3391c47fdde
refs/heads/main
2023-04-04T13:10:09.320995
2021-04-06T22:55:29
2021-04-06T22:55:29
341,309,069
0
0
null
null
null
null
UTF-8
C++
false
false
1,441
h
#pragma once #include "Object.h" #include "Arithmetic.h" #include "SceneObject.h" #include "TriangleMesh.h" class BVHNode : public Object { private: std::shared_ptr<Object> left; std::shared_ptr<Object> right; AABB3D box; bool leaf; public: BVHNode(); BVHNode(const std::shared_ptr<TriangleMesh>& triangleMesh); BVHNode(const std::vector<std::shared_ptr<SceneObject>>& list); BVHNode(const std::vector<std::shared_ptr<Object>> list); BVHNode(const std::vector<std::shared_ptr<Object>>& src_objects, size_t start, size_t end); const std::shared_ptr<Object>& getLeft() const; const std::shared_ptr<Object>& getRight() const; const AABB3D& getBoundingBox() const; const bool& isLeaf() const; bool generateBoundingBox(AABB3D& output_box) const; AABB3D surroundingBox(const AABB3D& box0, const AABB3D& box1) const; bool box_compare(const std::shared_ptr<Object>& a, const std::shared_ptr<Object>& b, int axis) const; int intersection(const Ray3D& ray, const double& t_min, const double& t_max, HitRecord& hitRecord) const; std::string toStringHelper(const BVHNode* curr, size_t level) const; std::string toString() const; // JUST TO COMPLY const ColorRGB& getAmbient() const; const ColorRGB& getDiffuse() const; const ColorRGB& getSpecular() const; const double& getAlpha() const; Vec3D normal(const Point3D& intersection) const; };
[ "sukritganesh@gmail.com" ]
sukritganesh@gmail.com
04d305b1df07b288222714d8292726f905dcf62b
cb5d330c2e0546b45881850d94c9c2b35a98603a
/external/GSL/tests/string_span_tests.cpp
fd3e3e6cacee79f0348b6c8319114e90a064aaa0
[ "MIT" ]
permissive
youngseokyoon/ModernCppChallengeStudy
b1777d14878c7b471290de20770d2d22bab50169
abbd038b2e8217449b3cc8af0c93584f437223e8
refs/heads/master
2020-03-31T07:08:33.916483
2018-10-17T15:52:20
2018-10-18T02:35:08
152,009,306
0
0
MIT
2018-10-08T02:46:37
2018-10-08T02:46:37
null
UTF-8
C++
false
false
31,486
cpp
/////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2015 Microsoft Corporation. All rights reserved. // // This code is licensed under the MIT License (MIT). // // 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. // /////////////////////////////////////////////////////////////////////////////// #ifdef _MSC_VER // blanket turn off warnings from CppCoreCheck from catch // so people aren't annoyed by them when running the tool. #pragma warning(disable : 26440 26426) // from catch #endif #include <catch/catch.hpp> // for AssertionHandler, StringRef, CHECK, TEST_... #include <gsl/gsl_assert> // for Expects, fail_fast (ptr only) #include <gsl/pointers> // for owner #include <gsl/span> // for span, dynamic_extent #include <gsl/string_span> // for basic_string_span, operator==, ensure_z #include <algorithm> // for move, find #include <cstddef> // for size_t #include <map> // for map #include <string> // for basic_string, string, char_traits, operat... #include <type_traits> // for remove_reference<>::type #include <vector> // for vector, allocator using namespace std; using namespace gsl; // Generic string functions namespace generic { template <typename CharT> GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute GSL_SUPPRESS(f.23) // NO-FORMAT: attribute auto strlen(const CharT* s) { auto p = s; while (*p) ++p; return p - s; } template <typename CharT> GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute auto strnlen(const CharT* s, std::size_t n) { return std::find(s, s + n, CharT{0}) - s; } } // namespace generic GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("TestLiteralConstruction") { cwstring_span<> v = ensure_z(L"Hello"); CHECK(5 == v.length()); #ifdef CONFIRM_COMPILATION_ERRORS wstring_span<> v2 = ensure0(L"Hello"); #endif } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("TestConstructFromStdString") { std::string s = "Hello there world"; cstring_span<> v = s; CHECK(v.length() == static_cast<cstring_span<>::index_type>(s.length())); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("TestConstructFromStdVector") { std::vector<char> vec(5, 'h'); string_span<> v{vec}; CHECK(v.length() == static_cast<string_span<>::index_type>(vec.size())); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("TestStackArrayConstruction") { wchar_t stack_string[] = L"Hello"; { cwstring_span<> v = ensure_z(stack_string); CHECK(v.length() == 5); } { cwstring_span<> v = stack_string; CHECK(v.length() == 5); } { wstring_span<> v = ensure_z(stack_string); CHECK(v.length() == 5); } { wstring_span<> v = stack_string; CHECK(v.length() == 5); } } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("TestConstructFromConstCharPointer") { const char* s = "Hello"; cstring_span<> v = ensure_z(s); CHECK(v.length() == 5); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("TestConversionToConst") { char stack_string[] = "Hello"; string_span<> v = ensure_z(stack_string); cstring_span<> v2 = v; CHECK(v.length() == v2.length()); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("TestConversionFromConst") { char stack_string[] = "Hello"; cstring_span<> v = ensure_z(stack_string); (void) v; #ifdef CONFIRM_COMPILATION_ERRORS string_span<> v2 = v; string_span<> v3 = "Hello"; #endif } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("TestToString") { auto s = gsl::to_string(cstring_span<>{}); CHECK(s.length() == 0); char stack_string[] = "Hello"; cstring_span<> v = ensure_z(stack_string); auto s2 = gsl::to_string(v); CHECK(static_cast<cstring_span<>::index_type>(s2.length()) == v.length()); CHECK(s2.length() == 5); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("TestToBasicString") { auto s = gsl::to_basic_string<char, std::char_traits<char>, ::std::allocator<char>>( cstring_span<>{}); CHECK(s.length() == 0); char stack_string[] = "Hello"; cstring_span<> v = ensure_z(stack_string); auto s2 = gsl::to_basic_string<char, std::char_traits<char>, ::std::allocator<char>>(v); CHECK(static_cast<cstring_span<>::index_type>(s2.length()) == v.length()); CHECK(s2.length() == 5); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute TEST_CASE("EqualityAndImplicitConstructors") { { cstring_span<> span = "Hello"; cstring_span<> span1; // comparison to empty span CHECK(span1 != span); CHECK(span != span1); } { cstring_span<> span = "Hello"; cstring_span<> span1 = "Hello1"; // comparison to different span CHECK(span1 != span); CHECK(span != span1); } { cstring_span<> span = "Hello"; const char ar[] = {'H', 'e', 'l', 'l', 'o'}; const char ar1[] = "Hello"; const char ar2[10] = "Hello"; const char* ptr = "Hello"; const std::string str = "Hello"; const std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; gsl::span<const char> sp = ensure_z("Hello"); // comparison to literal CHECK(span == cstring_span<>("Hello")); // comparison to static array with no null termination CHECK(span == cstring_span<>(ar)); // comparison to static array with null at the end CHECK(span == cstring_span<>(ar1)); // comparison to static array with null in the middle CHECK(span == cstring_span<>(ar2)); // comparison to null-terminated c string CHECK(span == cstring_span<>(ptr, 5)); // comparison to string CHECK(span == cstring_span<>(str)); // comparison to vector of charaters with no null termination CHECK(span == cstring_span<>(vec)); // comparison to span CHECK(span == cstring_span<>(sp)); // comparison to string_span CHECK(span == span); } { char ar[] = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = ar; char ar1[] = "Hello"; char ar2[10] = "Hello"; char* ptr = ar; std::string str = "Hello"; std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; gsl::span<char> sp = ensure_z(ar1); // comparison to static array with no null termination CHECK(span == string_span<>(ar)); // comparison to static array with null at the end CHECK(span == string_span<>(ar1)); // comparison to static array with null in the middle CHECK(span == string_span<>(ar2)); // comparison to null-terminated c string CHECK(span == string_span<>(ptr, 5)); // comparison to string CHECK(span == string_span<>(str)); // comparison to vector of charaters with no null termination CHECK(span == string_span<>(vec)); // comparison to span CHECK(span == string_span<>(sp)); // comparison to string_span CHECK(span == span); } { const char ar[] = {'H', 'e', 'l', 'l', 'o'}; const char ar1[] = "Hello"; const char ar2[10] = "Hello"; const std::string str = "Hello"; const std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const gsl::span<const char> sp = ensure_z("Hello"); cstring_span<> span = "Hello"; // const span, const other type CHECK(span == "Hello"); CHECK(span == ar); CHECK(span == ar1); CHECK(span == ar2); #ifdef CONFIRM_COMPILATION_ERRORS const char* ptr = "Hello"; CHECK(span == ptr); #endif CHECK(span == str); CHECK(span == vec); CHECK(span == sp); CHECK("Hello" == span); CHECK(ar == span); CHECK(ar1 == span); CHECK(ar2 == span); #ifdef CONFIRM_COMPILATION_ERRORS CHECK(ptr == span); #endif CHECK(str == span); CHECK(vec == span); CHECK(sp == span); // const span, non-const other type char _ar[] = {'H', 'e', 'l', 'l', 'o'}; char _ar1[] = "Hello"; char _ar2[10] = "Hello"; char* _ptr = _ar; std::string _str = "Hello"; std::vector<char> _vec = {'H', 'e', 'l', 'l', 'o'}; gsl::span<char> _sp{_ar, 5}; CHECK(span == _ar); CHECK(span == _ar1); CHECK(span == _ar2); #ifdef CONFIRM_COMPILATION_ERRORS CHECK(span == _ptr); #endif CHECK(span == _str); CHECK(span == _vec); CHECK(span == _sp); CHECK(_ar == span); CHECK(_ar1 == span); CHECK(_ar2 == span); #ifdef CONFIRM_COMPILATION_ERRORS CHECK(_ptr == span); #endif CHECK(_str == span); CHECK(_vec == span); CHECK(_sp == span); string_span<> _span{_ptr, 5}; // non-const span, non-const other type CHECK(_span == _ar); CHECK(_span == _ar1); CHECK(_span == _ar2); #ifdef CONFIRM_COMPILATION_ERRORS CHECK(_span == _ptr); #endif CHECK(_span == _str); CHECK(_span == _vec); CHECK(_span == _sp); CHECK(_ar == _span); CHECK(_ar1 == _span); CHECK(_ar2 == _span); #ifdef CONFIRM_COMPILATION_ERRORS CHECK(_ptr == _span); #endif CHECK(_str == _span); CHECK(_vec == _span); CHECK(_sp == _span); // non-const span, const other type CHECK(_span == "Hello"); CHECK(_span == ar); CHECK(_span == ar1); CHECK(_span == ar2); #ifdef CONFIRM_COMPILATION_ERRORS CHECK(_span == ptr); #endif CHECK(_span == str); CHECK(_span == vec); CHECK(_span == sp); CHECK("Hello" == _span); CHECK(ar == _span); CHECK(ar1 == _span); CHECK(ar2 == _span); #ifdef CONFIRM_COMPILATION_ERRORS CHECK(ptr == _span); #endif CHECK(str == _span); CHECK(vec == _span); CHECK(sp == _span); // two spans CHECK(_span == span); CHECK(span == _span); } { std::vector<char> str1 = {'H', 'e', 'l', 'l', 'o'}; cstring_span<> span1 = str1; std::vector<char> str2 = std::move(str1); cstring_span<> span2 = str2; // comparison of spans from the same vector before and after move (ok) CHECK(span1 == span2); } } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute TEST_CASE("ComparisonAndImplicitConstructors") { { cstring_span<> span = "Hello"; const char ar[] = {'H', 'e', 'l', 'l', 'o'}; const char ar1[] = "Hello"; const char ar2[10] = "Hello"; const char* ptr = "Hello"; const std::string str = "Hello"; const std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; // comparison to literal CHECK(span < cstring_span<>("Helloo")); CHECK(span > cstring_span<>("Hell")); // comparison to static array with no null termination CHECK(span >= cstring_span<>(ar)); // comparison to static array with null at the end CHECK(span <= cstring_span<>(ar1)); // comparison to static array with null in the middle CHECK(span >= cstring_span<>(ar2)); // comparison to null-terminated c string CHECK(span <= cstring_span<>(ptr, 5)); // comparison to string CHECK(span >= cstring_span<>(str)); // comparison to vector of charaters with no null termination CHECK(span <= cstring_span<>(vec)); } { char ar[] = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = ar; char larr[] = "Hell"; char rarr[] = "Helloo"; char ar1[] = "Hello"; char ar2[10] = "Hello"; char* ptr = ar; std::string str = "Hello"; std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; // comparison to static array with no null termination CHECK(span <= string_span<>(ar)); CHECK(span < string_span<>(rarr)); CHECK(span > string_span<>(larr)); // comparison to static array with null at the end CHECK(span >= string_span<>(ar1)); // comparison to static array with null in the middle CHECK(span <= string_span<>(ar2)); // comparison to null-terminated c string CHECK(span >= string_span<>(ptr, 5)); // comparison to string CHECK(span <= string_span<>(str)); // comparison to vector of charaters with no null termination CHECK(span >= string_span<>(vec)); } } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(r.11) // NO-FORMAT: attribute GSL_SUPPRESS(r.3) // NO-FORMAT: attribute GSL_SUPPRESS(r.5) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute TEST_CASE("ConstrutorsEnsureZ") { // remove z from literals { cstring_span<> sp = "hello"; CHECK((sp.length() == 5)); } // take the string as is { auto str = std::string("hello"); cstring_span<> sp = str; CHECK((sp.length() == 5)); } // ensure z on c strings { gsl::owner<char*> ptr = new char[3]; ptr[0] = 'a'; ptr[1] = 'b'; ptr[2] = '\0'; string_span<> span = ensure_z(ptr); CHECK(span.length() == 2); delete[] ptr; } } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute TEST_CASE("Constructors") { // creating cstring_span // from span of a final extent { span<const char, 6> sp = "Hello"; cstring_span<> span = sp; CHECK(span.length() == 6); } // from const span of a final extent to non-const string_span #ifdef CONFIRM_COMPILATION_ERRORS { span<const char, 6> sp = "Hello"; string_span<> span = sp; CHECK(span.length() == 6); } #endif // from string temporary #ifdef CONFIRM_COMPILATION_ERRORS { cstring_span<> span = std::string("Hello"); } #endif // default { cstring_span<> span; CHECK(span.length() == 0); } // from string literal { cstring_span<> span = "Hello"; CHECK(span.length() == 5); } // from const static array { const char ar[] = {'H', 'e', 'l', 'l', 'o'}; cstring_span<> span = ar; CHECK(span.length() == 5); } // from non-const static array { char ar[] = {'H', 'e', 'l', 'l', 'o'}; cstring_span<> span = ar; CHECK(span.length() == 5); } // from const ptr and length { const char* ptr = "Hello"; cstring_span<> span{ptr, 5}; CHECK(span.length() == 5); } // from const ptr and length, include 0 { const char* ptr = "Hello"; cstring_span<> span{ptr, 6}; CHECK(span.length() == 6); } // from const ptr and length, 0 inside { const char* ptr = "He\0lo"; cstring_span<> span{ptr, 5}; CHECK(span.length() == 5); } // from non-const ptr and length { char ar[] = {'H', 'e', 'l', 'l', 'o'}; char* ptr = ar; cstring_span<> span{ptr, 5}; CHECK(span.length() == 5); } // from non-const ptr and length, 0 inside { char ar[] = {'H', 'e', '\0', 'l', 'o'}; char* ptr = ar; cstring_span<> span{ptr, 5}; CHECK(span.length() == 5); } // from const string { const std::string str = "Hello"; const cstring_span<> span = str; CHECK(span.length() == 5); } // from non-const string { std::string str = "Hello"; const cstring_span<> span = str; CHECK(span.length() == 5); } // from const vector { const std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const cstring_span<> span = vec; CHECK(span.length() == 5); } // from non-const vector { std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const cstring_span<> span = vec; CHECK(span.length() == 5); } // from const span { const std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const span<const char> inner = vec; const cstring_span<> span = inner; CHECK(span.length() == 5); } // from non-const span { std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const span<char> inner = vec; const cstring_span<> span = inner; CHECK(span.length() == 5); } // from const string_span { const std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const cstring_span<> tmp = vec; const cstring_span<> span = tmp; CHECK(span.length() == 5); } // from non-const string_span { std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> tmp = vec; cstring_span<> span = tmp; CHECK(span.length() == 5); } // creating string_span // from string literal { #ifdef CONFIRM_COMPILATION_ERRORS string_span<> span = "Hello"; #endif } // from const static array { #ifdef CONFIRM_COMPILATION_ERRORS const char ar[] = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = ar; CHECK(span.length() == 5); #endif } // from non-const static array { char ar[] = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = ar; CHECK(span.length() == 5); } // from const ptr and length { #ifdef CONFIRM_COMPILATION_ERRORS const char* ptr = "Hello"; string_span<> span{ptr, 5}; CHECK(span.length() == 5); #endif } // from non-const ptr and length { char ar[] = {'H', 'e', 'l', 'l', 'o'}; char* ptr = ar; string_span<> span{ptr, 5}; CHECK(span.length() == 5); } // from const string { #ifdef CONFIRM_COMPILATION_ERRORS const std::string str = "Hello"; string_span<> span = str; CHECK(span.length() == 5); #endif } // from non-const string { std::string str = "Hello"; string_span<> span = str; CHECK(span.length() == 5); } // from const vector { #ifdef CONFIRM_COMPILATION_ERRORS const std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = vec; CHECK(span.length() == 5); #endif } // from non-const vector { std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = vec; CHECK(span.length() == 5); } // from const span { #ifdef CONFIRM_COMPILATION_ERRORS std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const span<const char> inner = vec; string_span<> span = inner; CHECK(span.length() == 5); #endif } // from non-const span { std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; span<char> inner = vec; string_span<> span = inner; CHECK(span.length() == 5); } // from non-const span of non-const data from const vector { #ifdef CONFIRM_COMPILATION_ERRORS const std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const span<char> inner = vec; string_span<> span = inner; CHECK(span.length() == 5); #endif } // from const string_span { #ifdef CONFIRM_COMPILATION_ERRORS std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; cstring_span<> tmp = vec; string_span<> span = tmp; CHECK(span.length() == 5); #endif } // from non-const string_span { std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const string_span<> tmp = vec; const string_span<> span = tmp; CHECK(span.length() == 5); } // from non-const string_span from const vector { #ifdef CONFIRM_COMPILATION_ERRORS const std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> tmp = vec; string_span<> span = tmp; CHECK(span.length() == 5); #endif } // from const string_span of non-const data { std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; const string_span<> tmp = vec; const string_span<> span = tmp; CHECK(span.length() == 5); } } template <typename T> T move_wrapper(T&& t) { return std::move(t); } template <class T> T create() { return T{}; } template <class T> void use(basic_string_span<T, gsl::dynamic_extent>) { } TEST_CASE("MoveConstructors") { // move string_span { cstring_span<> span = "Hello"; const auto span1 = std::move(span); CHECK(span1.length() == 5); } { cstring_span<> span = "Hello"; const auto span1 = move_wrapper(std::move(span)); CHECK(span1.length() == 5); } { cstring_span<> span = "Hello"; const auto span1 = move_wrapper(std::move(span)); CHECK(span1.length() == 5); } // move span { span<const char> span = ensure_z("Hello"); const cstring_span<> span1 = std::move(span); CHECK(span1.length() == 5); } { span<const char> span = ensure_z("Hello"); const cstring_span<> span2 = move_wrapper(std::move(span)); CHECK(span2.length() == 5); } // move string { #ifdef CONFIRM_COMPILATION_ERRORS std::string str = "Hello"; string_span<> span = std::move(str); CHECK(span.length() == 5); #endif } { #ifdef CONFIRM_COMPILATION_ERRORS std::string str = "Hello"; string_span<> span = move_wrapper<std::string>(std::move(str)); CHECK(span.length() == 5); #endif } { #ifdef CONFIRM_COMPILATION_ERRORS use<char>(create<string>()); #endif } // move container { #ifdef CONFIRM_COMPILATION_ERRORS std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = std::move(vec); CHECK(span.length() == 5); #endif } { #ifdef CONFIRM_COMPILATION_ERRORS std::vector<char> vec = {'H', 'e', 'l', 'l', 'o'}; string_span<> span = move_wrapper<std::vector<char>>(std::move(vec)); CHECK(span.length() == 5); #endif } { #ifdef CONFIRM_COMPILATION_ERRORS use<char>(create<std::vector<char>>()); #endif } } TEST_CASE("Conversion") { #ifdef CONFIRM_COMPILATION_ERRORS cstring_span<> span = "Hello"; cwstring_span<> wspan{span}; CHECK(wspan.length() == 5); #endif } czstring_span<> CreateTempName(string_span<> span) { Expects(span.size() > 1); int last = 0; if (span.size() > 4) { span[0] = 't'; span[1] = 'm'; span[2] = 'p'; last = 3; } span[last] = '\0'; auto ret = span.subspan(0, 4); return {ret}; } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute TEST_CASE("zstring") { // create zspan from zero terminated string { char buf[1]; buf[0] = '\0'; zstring_span<> zspan({buf, 1}); CHECK(generic::strlen(zspan.assume_z()) == 0); CHECK(zspan.as_string_span().size() == 0); CHECK(zspan.ensure_z().size() == 0); } // create zspan from non-zero terminated string { char buf[1]; buf[0] = 'a'; auto workaround_macro = [&]() { const zstring_span<> zspan({buf, 1}); }; CHECK_THROWS_AS(workaround_macro(), fail_fast); } // usage scenario: create zero-terminated temp file name and pass to a legacy API { char buf[10]; auto name = CreateTempName({buf, 10}); if (!name.empty()) { czstring<> str = name.assume_z(); CHECK(generic::strlen(str) == 3); CHECK(*(str + 3) == '\0'); } } } cwzstring_span<> CreateTempNameW(wstring_span<> span) { Expects(span.size() > 1); int last = 0; if (span.size() > 4) { span[0] = L't'; span[1] = L'm'; span[2] = L'p'; last = 3; } span[last] = L'\0'; auto ret = span.subspan(0, 4); return {ret}; } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute TEST_CASE("wzstring") { // create zspan from zero terminated string { wchar_t buf[1]; buf[0] = L'\0'; wzstring_span<> zspan({buf, 1}); CHECK(generic::strnlen(zspan.assume_z(), 1) == 0); CHECK(zspan.as_string_span().size() == 0); CHECK(zspan.ensure_z().size() == 0); } // create zspan from non-zero terminated string { wchar_t buf[1]; buf[0] = L'a'; const auto workaround_macro = [&]() { const wzstring_span<> zspan({buf, 1}); }; CHECK_THROWS_AS(workaround_macro(), fail_fast); } // usage scenario: create zero-terminated temp file name and pass to a legacy API { wchar_t buf[10]; const auto name = CreateTempNameW({buf, 10}); if (!name.empty()) { cwzstring<> str = name.assume_z(); CHECK(generic::strnlen(str, 10) == 3); CHECK(*(str + 3) == L'\0'); } } } cu16zstring_span<> CreateTempNameU16(u16string_span<> span) { Expects(span.size() > 1); int last = 0; if (span.size() > 4) { span[0] = u't'; span[1] = u'm'; span[2] = u'p'; last = 3; } span[last] = u'\0'; auto ret = span.subspan(0, 4); return {ret}; } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute TEST_CASE("u16zstring") { // create zspan from zero terminated string { char16_t buf[1]; buf[0] = L'\0'; u16zstring_span<> zspan({buf, 1}); CHECK(generic::strnlen(zspan.assume_z(), 1) == 0); CHECK(zspan.as_string_span().size() == 0); CHECK(zspan.ensure_z().size() == 0); } // create zspan from non-zero terminated string { char16_t buf[1]; buf[0] = u'a'; const auto workaround_macro = [&]() { const u16zstring_span<> zspan({buf, 1}); }; CHECK_THROWS_AS(workaround_macro(), fail_fast); } // usage scenario: create zero-terminated temp file name and pass to a legacy API { char16_t buf[10]; const auto name = CreateTempNameU16({buf, 10}); if (!name.empty()) { cu16zstring<> str = name.assume_z(); CHECK(generic::strnlen(str, 10) == 3); CHECK(*(str + 3) == L'\0'); } } } cu32zstring_span<> CreateTempNameU32(u32string_span<> span) { Expects(span.size() > 1); int last = 0; if (span.size() > 4) { span[0] = U't'; span[1] = U'm'; span[2] = U'p'; last = 3; } span[last] = U'\0'; auto ret = span.subspan(0, 4); return {ret}; } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute TEST_CASE("u32zstring") { // create zspan from zero terminated string { char32_t buf[1]; buf[0] = L'\0'; u32zstring_span<> zspan({buf, 1}); CHECK(generic::strnlen(zspan.assume_z(), 1) == 0); CHECK(zspan.as_string_span().size() == 0); CHECK(zspan.ensure_z().size() == 0); } // create zspan from non-zero terminated string { char32_t buf[1]; buf[0] = u'a'; const auto workaround_macro = [&]() { const u32zstring_span<> zspan({buf, 1}); }; CHECK_THROWS_AS(workaround_macro(), fail_fast); } // usage scenario: create zero-terminated temp file name and pass to a legacy API { char32_t buf[10]; const auto name = CreateTempNameU32({buf, 10}); if (!name.empty()) { cu32zstring<> str = name.assume_z(); CHECK(generic::strnlen(str, 10) == 3); CHECK(*(str + 3) == L'\0'); } } } TEST_CASE("Issue305") { std::map<gsl::cstring_span<>, int> foo = {{"foo", 0}, {"bar", 1}}; CHECK(foo["foo"] == 0); CHECK(foo["bar"] == 1); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute TEST_CASE("char16_t type") { gsl::cu16string_span<> ss1 = gsl::ensure_z(u"abc"); CHECK(ss1.size() == 3); CHECK(ss1.size_bytes() == 6); std::u16string s1 = gsl::to_string(ss1); CHECK(s1 == u"abc"); std::u16string s2 = u"abc"; gsl::u16string_span<> ss2 = s2; CHECK(ss2.size() == 3); gsl::u16string_span<> ss3 = ss2.subspan(1, 1); CHECK(ss3.size() == 1); CHECK(ss3[0] == u'b'); char16_t buf[4]{u'a', u'b', u'c', u'\0'}; gsl::u16string_span<> ss4{buf, 4}; CHECK(ss4[3] == u'\0'); gsl::cu16zstring_span<> ss5(u"abc"); CHECK(ss5.as_string_span().size() == 3); gsl::cu16string_span<> ss6 = ss5.as_string_span(); CHECK(ss6 == ss1); std::vector<char16_t> v7 = {u'a', u'b', u'c'}; gsl::cu16string_span<> ss7{v7}; CHECK(ss7 == ss1); gsl::cu16string_span<> ss8 = gsl::ensure_z(u"abc"); gsl::cu16string_span<> ss9 = gsl::ensure_z(u"abc"); CHECK(ss8 == ss9); ss9 = gsl::ensure_z(u"abd"); CHECK(ss8 < ss9); CHECK(ss8 <= ss9); CHECK(ss8 != ss9); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute TEST_CASE("char32_t type") { gsl::cu32string_span<> ss1 = gsl::ensure_z(U"abc"); CHECK(ss1.size() == 3); CHECK(ss1.size_bytes() == 12); std::u32string s1 = gsl::to_string(ss1); CHECK(s1 == U"abc"); std::u32string s2 = U"abc"; gsl::u32string_span<> ss2 = s2; CHECK(ss2.size() == 3); gsl::u32string_span<> ss3 = ss2.subspan(1, 1); CHECK(ss3.size() == 1); CHECK(ss3[0] == U'b'); char32_t buf[4]{U'a', U'b', U'c', U'\0'}; gsl::u32string_span<> ss4{buf, 4}; CHECK(ss4[3] == u'\0'); gsl::cu32zstring_span<> ss5(U"abc"); CHECK(ss5.as_string_span().size() == 3); gsl::cu32string_span<> ss6 = ss5.as_string_span(); CHECK(ss6 == ss1); gsl::cu32string_span<> ss8 = gsl::ensure_z(U"abc"); gsl::cu32string_span<> ss9 = gsl::ensure_z(U"abc"); CHECK(ss8 == ss9); ss9 = gsl::ensure_z(U"abd"); CHECK(ss8 < ss9); CHECK(ss8 <= ss9); CHECK(ss8 != ss9); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("as_bytes") { cwzstring_span<> v(L"qwerty"); const auto s = v.as_string_span(); const auto bs = as_bytes(s); CHECK(static_cast<const void*>(bs.data()) == static_cast<const void*>(s.data())); CHECK(bs.size() == s.size_bytes()); } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("as_writeable_bytes") { wchar_t buf[]{L"qwerty"}; wzstring_span<> v(buf); const auto s = v.as_string_span(); const auto bs = as_writeable_bytes(s); CHECK(static_cast<const void*>(bs.data()) == static_cast<const void*>(s.data())); CHECK(bs.size() == s.size_bytes()); }
[ "earwigz32@gmail.com" ]
earwigz32@gmail.com
0caf4368abb63e8438a6e58d1dba55a75889609c
66994bb8d69d970863804295443ab8f2a5afc816
/cpp/toy.cpp
a98d2b302397887e079549c04141fe046a91a9d0
[]
no_license
mobi12/study
d93860e846b1706dcc0d4b97fe7e0027d83b9161
638b2e868b70b4231524dc8b4cfdfbab343e1e5f
refs/heads/master
2020-04-04T02:30:23.664442
2017-02-24T13:42:59
2017-02-24T13:42:59
33,184,741
8
1
null
null
null
null
UTF-8
C++
false
false
430
cpp
#include <iostream> using namespace std; int main() { union alpha { int a; float b; char c[20]; }; cout << "选择选项一输入名字" << endl; cout << "选择选项二输入身高" << endl; cout << "选择选项三输入年龄" << endl; alpha beta; int chose; cin >> chose; if (chose == 1) { cin >> beta.c; } if (chose == 2) { cin >> beta.b; } if (chose == 3) { cin >> beta.a; } return 0; }
[ "mc1a1@hotmail.com" ]
mc1a1@hotmail.com
552184123063849b19c2c493c9b3ae47dc51a2bf
9ca6885d197aaf6869e2080901b361b034e4cc37
/GeneratorInterface/CosmicMuonGenerator/interface/CosMuoGenEDFilter.h
a28663c0c8be8c48e3e00b228f843ddc1ff700c8
[]
no_license
ktf/cmssw-migration
153ff14346b20086f908a370029aa96575a2c51a
583340dd03481dff673a52a2075c8bb46fa22ac6
refs/heads/master
2020-07-25T15:37:45.528173
2013-07-11T04:54:56
2013-07-11T04:54:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,454
h
#ifndef CosMuoGenEDFilter_h #define CosMuoGenEDFilter_h // // CosmicMuonEDFilter by sonne (12/JUL/2010) // #include "HepMC/GenEvent.h" #include "FWCore/Framework/interface/EDFilter.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Run.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/Exception.h" #include "GeneratorInterface/CosmicMuonGenerator/interface/CosmicMuonGenerator.h" namespace edm { class CosMuoGenEDFilter : public EDFilter { public: CosMuoGenEDFilter(const ParameterSet& ); virtual ~CosMuoGenEDFilter(); private: //virtual bool produce(Event & e, const EventSetup& es); virtual bool filter(Event & e, const EventSetup& es); virtual bool endRun(Run & r, const EventSetup & es); void clear(); // define the configurable generator parameters int32_t RanS; // seed of random number generator (from Framework) double MinP; // min. P [GeV] double MinP_CMS; // min. P at CMS surface [GeV]; default is MinP_CMS=MinP, thus no bias from access-shaft double MaxP; // max. P [GeV] double MinT; // min. theta [deg] double MaxT; // max. theta [deg] double MinPh; // min. phi [deg] double MaxPh; // max. phi [deg] double MinS; // min. t0 [ns] double MaxS; // max. t0 [ns] double ELSF; // scale factor for energy loss double RTarget; // Radius of target-cylinder which cosmics HAVE to hit [mm], default is CMS-dimensions double ZTarget; // z-length of target-cylinder which cosmics HAVE to hit [mm], default is CMS-dimensions double ZCTarget; // z-position of centre of target-cylinder which cosmics HAVE to hit [mm], default is Nominal Interaction Point bool TrackerOnly; //if set to "true" detector with tracker-only setup is used, so no material or B-field outside is considerd bool MultiMuon; //read in multi-muon events from file instead of generating single muon events std::string MultiMuonFileName; //file containing multi muon events, to be read in int32_t MultiMuonFileFirstEvent; int32_t MultiMuonNmin; bool TIFOnly_constant; //if set to "true" cosmics can also be generated below 2GeV with unphysical constant energy dependence bool TIFOnly_linear; //if set to "true" cosmics can also be generated below 2GeV with unphysical linear energy dependence bool MTCCHalf; //if set to "true" muons are sure to hit half of CMS important for MTCC, //still material and B-field of whole CMS is considered //Plug position (default = on shaft) double PlugVtx; double PlugVtz; //material densities in g/cm^3 double VarRhoAir; double VarRhoWall; double VarRhoRock; double VarRhoClay; double VarRhoPlug; double ClayLayerWidth; //[mm] //For upgoing muon generation: Neutrino energy limits double MinEn; double MaxEn; double NuPrdAlt; bool AllMu; //Accepting All Muons regardeless of direction // external cross section and filter efficiency double extCrossSect; double extFilterEff; CosmicMuonGenerator* CosMuoGen; // the event format itself HepMC::GenEvent* fEvt; bool cmVerbosity_; }; } #endif
[ "sha1-a57afd2f0b08e67a847818a4abaa2c774bef8f5c@cern.ch" ]
sha1-a57afd2f0b08e67a847818a4abaa2c774bef8f5c@cern.ch
b721c847e5b3ff9c8932d4d7913ec3aa0ad7fafc
4c53f1c2b38ab97531be88828cbae38e3aa5e951
/chromeos/services/multidevice_setup/eligible_host_devices_provider_impl_unittest.cc
5f857cffc5b976a009616a123d717c008d1b9746
[ "BSD-3-Clause" ]
permissive
piotrzarycki/chromium
7d1e8c688986d962eecbd1b5d2ca93e1d167bd29
f9965cd785ea5898a2f84d9a7c05054922e02988
refs/heads/master
2023-02-26T03:58:58.895546
2019-11-13T18:09:45
2019-11-13T18:09:45
221,524,087
1
0
BSD-3-Clause
2019-11-13T18:19:59
2019-11-13T18:19:59
null
UTF-8
C++
false
false
11,070
cc
// 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. #include "chromeos/services/multidevice_setup/eligible_host_devices_provider_impl.h" #include <memory> #include "base/containers/flat_set.h" #include "base/macros.h" #include "base/stl_util.h" #include "base/test/scoped_feature_list.h" #include "chromeos/components/multidevice/remote_device_test_util.h" #include "chromeos/components/multidevice/software_feature.h" #include "chromeos/components/multidevice/software_feature_state.h" #include "chromeos/constants/chromeos_features.h" #include "chromeos/services/device_sync/proto/cryptauth_api.pb.h" #include "chromeos/services/device_sync/public/cpp/fake_device_sync_client.h" #include "chromeos/services/device_sync/public/mojom/device_sync.mojom.h" #include "testing/gtest/include/gtest/gtest.h" namespace chromeos { namespace multidevice_setup { namespace { const size_t kNumTestDevices = 5; } // namespace class MultiDeviceSetupEligibleHostDevicesProviderImplTest : public testing::TestWithParam<bool> { protected: MultiDeviceSetupEligibleHostDevicesProviderImplTest() : test_devices_( multidevice::CreateRemoteDeviceRefListForTest(kNumTestDevices)) {} ~MultiDeviceSetupEligibleHostDevicesProviderImplTest() override = default; // testing::Test: void SetUp() override { use_get_devices_activity_status_ = GetParam(); scoped_feature_list_.InitWithFeatureState( chromeos::features::kCryptAuthV2DeviceActivityStatus, use_get_devices_activity_status_); fake_device_sync_client_ = std::make_unique<device_sync::FakeDeviceSyncClient>(); fake_device_sync_client_->set_synced_devices(test_devices_); provider_ = EligibleHostDevicesProviderImpl::Factory::Get()->BuildInstance( fake_device_sync_client_.get()); } device_sync::FakeDeviceSyncClient* fake_device_sync_client() { return fake_device_sync_client_.get(); } multidevice::RemoteDeviceRefList& test_devices() { return test_devices_; } EligibleHostDevicesProvider* provider() { return provider_.get(); } void SetBitsOnTestDevices() { // Devices 0, 1, and 2 are supported. GetMutableRemoteDevice(test_devices()[0]) ->software_features[multidevice::SoftwareFeature::kBetterTogetherHost] = multidevice::SoftwareFeatureState::kSupported; GetMutableRemoteDevice(test_devices()[1]) ->software_features[multidevice::SoftwareFeature::kBetterTogetherHost] = multidevice::SoftwareFeatureState::kSupported; GetMutableRemoteDevice(test_devices()[2]) ->software_features[multidevice::SoftwareFeature::kBetterTogetherHost] = multidevice::SoftwareFeatureState::kSupported; // Device 3 is enabled. GetMutableRemoteDevice(test_devices()[3]) ->software_features[multidevice::SoftwareFeature::kBetterTogetherHost] = multidevice::SoftwareFeatureState::kEnabled; // Device 4 is not supported. GetMutableRemoteDevice(test_devices()[4]) ->software_features[multidevice::SoftwareFeature::kBetterTogetherHost] = multidevice::SoftwareFeatureState::kNotSupported; } bool use_get_devices_activity_status() { return use_get_devices_activity_status_; } private: multidevice::RemoteDeviceRefList test_devices_; std::unique_ptr<device_sync::FakeDeviceSyncClient> fake_device_sync_client_; std::unique_ptr<EligibleHostDevicesProvider> provider_; bool use_get_devices_activity_status_; base::test::ScopedFeatureList scoped_feature_list_; DISALLOW_COPY_AND_ASSIGN(MultiDeviceSetupEligibleHostDevicesProviderImplTest); }; TEST_P(MultiDeviceSetupEligibleHostDevicesProviderImplTest, Empty) { EXPECT_TRUE(provider()->GetEligibleHostDevices().empty()); } TEST_P(MultiDeviceSetupEligibleHostDevicesProviderImplTest, NoEligibleDevices) { GetMutableRemoteDevice(test_devices()[0]) ->software_features[multidevice::SoftwareFeature::kBetterTogetherHost] = multidevice::SoftwareFeatureState::kNotSupported; GetMutableRemoteDevice(test_devices()[1]) ->software_features[multidevice::SoftwareFeature::kBetterTogetherHost] = multidevice::SoftwareFeatureState::kNotSupported; multidevice::RemoteDeviceRefList devices{test_devices()[0], test_devices()[1]}; fake_device_sync_client()->set_synced_devices(devices); fake_device_sync_client()->NotifyNewDevicesSynced(); EXPECT_TRUE(provider()->GetEligibleHostDevices().empty()); } TEST_P(MultiDeviceSetupEligibleHostDevicesProviderImplTest, SupportedAndEnabled) { SetBitsOnTestDevices(); GetMutableRemoteDevice(test_devices()[0])->last_update_time_millis = 1999; GetMutableRemoteDevice(test_devices()[1])->last_update_time_millis = 25; GetMutableRemoteDevice(test_devices()[2])->last_update_time_millis = 2525; GetMutableRemoteDevice(test_devices()[3])->last_update_time_millis = 500; GetMutableRemoteDevice(test_devices()[4])->last_update_time_millis = 1000; multidevice::RemoteDeviceRefList devices{test_devices()[0], test_devices()[1], test_devices()[2], test_devices()[3], test_devices()[4]}; fake_device_sync_client()->set_synced_devices(devices); fake_device_sync_client()->NotifyNewDevicesSynced(); multidevice::RemoteDeviceRefList eligible_devices = provider()->GetEligibleHostDevices(); EXPECT_EQ(4u, eligible_devices.size()); EXPECT_EQ(test_devices()[2], eligible_devices[0]); EXPECT_EQ(test_devices()[0], eligible_devices[1]); EXPECT_EQ(test_devices()[3], eligible_devices[2]); EXPECT_EQ(test_devices()[1], eligible_devices[3]); } TEST_P(MultiDeviceSetupEligibleHostDevicesProviderImplTest, GetDevicesActivityStatus) { SetBitsOnTestDevices(); GetMutableRemoteDevice(test_devices()[0])->last_update_time_millis = 1; GetMutableRemoteDevice(test_devices()[1])->last_update_time_millis = 25; GetMutableRemoteDevice(test_devices()[2])->last_update_time_millis = 10; GetMutableRemoteDevice(test_devices()[3])->last_update_time_millis = 100; GetMutableRemoteDevice(test_devices()[4])->last_update_time_millis = 10000; multidevice::RemoteDeviceRefList devices{test_devices()[0], test_devices()[1], test_devices()[2], test_devices()[3], test_devices()[4]}; fake_device_sync_client()->set_synced_devices(devices); fake_device_sync_client()->NotifyNewDevicesSynced(); std::vector<device_sync::mojom::DeviceActivityStatusPtr> device_activity_statuses; device_activity_statuses.emplace_back( device_sync::mojom::DeviceActivityStatus::New( "publicKey0", base::Time::FromTimeT(50), cryptauthv2::ConnectivityStatus::ONLINE)); device_activity_statuses.emplace_back( device_sync::mojom::DeviceActivityStatus::New( "publicKey1", base::Time::FromTimeT(100), cryptauthv2::ConnectivityStatus::OFFLINE)); device_activity_statuses.emplace_back( device_sync::mojom::DeviceActivityStatus::New( "publicKey2", base::Time::FromTimeT(200), cryptauthv2::ConnectivityStatus::ONLINE)); device_activity_statuses.emplace_back( device_sync::mojom::DeviceActivityStatus::New( "publicKey3", base::Time::FromTimeT(50), cryptauthv2::ConnectivityStatus::ONLINE)); if (use_get_devices_activity_status()) { fake_device_sync_client()->InvokePendingGetDevicesActivityStatusCallback( device_sync::mojom::NetworkRequestResult::kSuccess, std::move(device_activity_statuses)); } if (use_get_devices_activity_status()) { multidevice::DeviceWithConnectivityStatusList eligible_devices = provider()->GetEligibleActiveHostDevices(); EXPECT_EQ(4u, eligible_devices.size()); EXPECT_EQ(test_devices()[2], eligible_devices[0].remote_device); EXPECT_EQ(test_devices()[3], eligible_devices[1].remote_device); EXPECT_EQ(test_devices()[0], eligible_devices[2].remote_device); EXPECT_EQ(test_devices()[1], eligible_devices[3].remote_device); EXPECT_EQ(cryptauthv2::ConnectivityStatus::ONLINE, eligible_devices[0].connectivity_status); EXPECT_EQ(cryptauthv2::ConnectivityStatus::ONLINE, eligible_devices[1].connectivity_status); EXPECT_EQ(cryptauthv2::ConnectivityStatus::ONLINE, eligible_devices[2].connectivity_status); EXPECT_EQ(cryptauthv2::ConnectivityStatus::OFFLINE, eligible_devices[3].connectivity_status); } else { multidevice::RemoteDeviceRefList eligible_devices = provider()->GetEligibleHostDevices(); EXPECT_EQ(4u, eligible_devices.size()); EXPECT_EQ(test_devices()[3], eligible_devices[0]); EXPECT_EQ(test_devices()[1], eligible_devices[1]); EXPECT_EQ(test_devices()[2], eligible_devices[2]); EXPECT_EQ(test_devices()[0], eligible_devices[3]); } } TEST_P(MultiDeviceSetupEligibleHostDevicesProviderImplTest, GetDevicesActivityStatusFailedRequest) { if (!use_get_devices_activity_status()) { return; } SetBitsOnTestDevices(); GetMutableRemoteDevice(test_devices()[0])->last_update_time_millis = 5; GetMutableRemoteDevice(test_devices()[1])->last_update_time_millis = 4; GetMutableRemoteDevice(test_devices()[2])->last_update_time_millis = 3; GetMutableRemoteDevice(test_devices()[3])->last_update_time_millis = 2; GetMutableRemoteDevice(test_devices()[4])->last_update_time_millis = 1; multidevice::RemoteDeviceRefList devices{test_devices()[0], test_devices()[1], test_devices()[2], test_devices()[3], test_devices()[4]}; fake_device_sync_client()->set_synced_devices(devices); fake_device_sync_client()->NotifyNewDevicesSynced(); fake_device_sync_client()->InvokePendingGetDevicesActivityStatusCallback( device_sync::mojom::NetworkRequestResult::kInternalServerError, base::nullopt); multidevice::DeviceWithConnectivityStatusList eligible_active_devices = provider()->GetEligibleActiveHostDevices(); multidevice::RemoteDeviceRefList eligible_devices = provider()->GetEligibleHostDevices(); EXPECT_EQ(test_devices()[0], eligible_active_devices[0].remote_device); EXPECT_EQ(test_devices()[1], eligible_active_devices[1].remote_device); EXPECT_EQ(test_devices()[2], eligible_active_devices[2].remote_device); EXPECT_EQ(test_devices()[3], eligible_active_devices[3].remote_device); EXPECT_EQ(test_devices()[0], eligible_devices[0]); EXPECT_EQ(test_devices()[1], eligible_devices[1]); EXPECT_EQ(test_devices()[2], eligible_devices[2]); EXPECT_EQ(test_devices()[3], eligible_devices[3]); } INSTANTIATE_TEST_SUITE_P(, MultiDeviceSetupEligibleHostDevicesProviderImplTest, testing::Bool()); } // namespace multidevice_setup } // namespace chromeos
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
fab89c24059b5049d62af71e617c503d7841a63b
86ce1b12909ed91453ca6dfa223e156ac0c4aea1
/Problem Solving/Summer_Day4/anagramSearch.cpp
ff7f2b30ccdfb536294ef869698dfbcdf48cb4ff
[]
no_license
LahariReddyMuthyala/MRNDSummer_Systems
bbb745114cb03d993143dda66e24528bb723dd45
0331d041ca9d2843dc702704d73fca30604e8bcc
refs/heads/master
2020-05-31T13:39:21.143803
2019-06-27T10:42:18
2019-06-27T10:42:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,624
cpp
#include <stdio.h> #include <string.h> #include <stdlib.h> #define MaxChild 27 struct nodeLL{ char *word; struct nodeLL *next; }; struct Node{ struct Node **children; struct nodeLL *dictionaryWords; }; typedef struct Node node; void displayLL(nodeLL *head){ while (head != NULL){ printf("%s ", head->word); head = head->next; } } node* createNewNode(){ node *newNode = (node*)malloc(sizeof(node)); newNode->children = (node**)calloc(MaxChild, sizeof(node*)); newNode->dictionaryWords = NULL; return newNode; } nodeLL* createNewNodeLL(char *str){ if (strlen(str) == 0) return NULL; nodeLL* newNode = (nodeLL*)malloc(sizeof(nodeLL)); newNode->next = NULL; newNode->word = (char*)calloc(20, sizeof(char)); strcpy(newNode->word, str); return newNode; } void insertWord(node *head, char *word, int index, nodeLL *headLL){ if (index == strlen(word)-1){ head->dictionaryWords = headLL; return; } else{ node *curr = head; if (word[index] == '-'){ if (curr->children[26] == NULL){ curr->children[26] = createNewNode(); curr = curr->children[26]; } else{ curr = curr->children[26]; } } else if (curr->children[word[index] - 'a'] == NULL){ curr->children[word[index] - 'a'] = createNewNode(); curr = curr->children[word[index] - 'a']; } insertWord(curr, word, index + 1, headLL); } } nodeLL* getLL(char *str){ char *firstWord = (char*)calloc(20, sizeof(char)); int i = 0; while (str[i] != ' ' && str[i] != '\0') firstWord[i] = str[i++]; firstWord[i] = '\0'; i++; nodeLL *head = createNewNodeLL(firstWord); nodeLL *curr = head; char *buffer = (char*)calloc(20, sizeof(char)); int k = 0; while(str[i] != '\0'){ if (str[i] == ' ' || str[i] == '\t'){ buffer[k] = '\0'; curr->next = createNewNodeLL(buffer); curr = curr->next; k = 0; i++; } else{ buffer[k++] = str[i++]; } } buffer[k] = '\0'; curr->next = createNewNodeLL(buffer); return head; } void sort(char *str){ int i = 0, j = 0; char temp; for (i = 0; i < strlen(str) - 1; i++) { for (j = i + 1; j < strlen(str); j++) { if (str[i] > str[j]) { temp = str[i]; str[i] = str[j]; str[j] = temp; } } } } void readAndCreateTrie(node *head, char *fileName){ FILE *fptr = fopen(fileName, "r+"); char ch; int i = 0, k = 0; char *buffer = (char*)malloc(60*sizeof(char)); char *buffer2 = (char*)calloc(15, sizeof(char)); char *sortedWord = (char*)calloc(30, sizeof(char)); char *words = (char*)calloc(75, sizeof(char)); while (!feof(fptr)){ k = 0; do{ ch = fgetc(fptr); buffer[k++] = ch; } while (ch != '\n' && !feof(fptr)); buffer[k] = '\0'; k = 0; i = 0; while (buffer[k] != ' ') sortedWord[i++] = buffer[k++]; sortedWord[i] = '\0'; k++; i = 0; while (buffer[k] != '\0') words[i++] = buffer[k++]; words[i] = '\0'; nodeLL *headLL = getLL(words); insertWord(head, sortedWord, 0, headLL); } } nodeLL* search(node *head, char *str, int index){ if (head == NULL){ return NULL; } if (index == strlen(str)-1){ return head->dictionaryWords; } printf("%c", str[index]); if (str[index] == '-'){ return search(head->children[26], str, index + 1); } return search(head->children[str[index]-'a'], str, index + 1); } void test_anagramSearch(){ node *head = createNewNode(); readAndCreateTrie(head, "prep.txt"); char *word = (char*)calloc(20, sizeof(char)); printf("Enter the word: "); scanf("%s", word); sort(word); nodeLL *headLL = search(head, word, 0); if (headLL == NULL){ printf("No anagrams in dictionary\n"); } else{ printf("Anagrams : "); displayLL(headLL); printf("\n"); } }
[ "laharireddy4@gmail.com" ]
laharireddy4@gmail.com
55f95ab6ecae04ab235e3037eb8641d368e2a68c
b1f401a34cc70c34ef4aa1ef39ae1ecfe42311b6
/src/db/MojDbUtils.cpp
42a67b06b2951ffeca383c209b4cdcc49602e4c0
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
webOS101/db8
a2e34ba872bbd136b9d57d55c2e5497f74515b4e
d70ea8eb0f88360ae2fbef9ebcc5ce85952a395c
refs/heads/master
2021-01-15T19:50:29.575541
2012-08-14T22:46:55
2012-08-14T22:46:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,793
cpp
/* @@@LICENSE * * Copyright (c) 2012 Hewlett-Packard Development Company, L.P. * * 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. * * LICENSE@@@ */ #include "db/MojDbUtils.h" #include "core/MojString.h" struct MojDbCollationStrInfo { const MojChar* m_str; MojDbCollationStrength m_coll; }; static MojDbCollationStrInfo s_collStrings[] = { {_T("primary"), MojDbCollationPrimary}, {_T("secondary"), MojDbCollationSecondary}, {_T("tertiary"), MojDbCollationTertiary}, {_T("quaternary"), MojDbCollationQuaternary}, {_T("identical"), MojDbCollationIdentical}, {_T("invalid"), MojDbCollationInvalid} }; const MojChar* MojDbUtils::collationToString(MojDbCollationStrength coll) { const MojChar* str = NULL; MojDbCollationStrInfo* info = s_collStrings; do { str = info->m_str; if (info->m_coll == coll) break; } while ((info++)->m_coll != MojDbCollationInvalid); return str; } MojErr MojDbUtils::collationFromString(const MojString& str, MojDbCollationStrength& collOut) { collOut = MojDbCollationInvalid; MojDbCollationStrInfo* info = s_collStrings; do { collOut = info->m_coll; if (str == info->m_str) break; } while ((info++)->m_coll != MojDbCollationInvalid); if (collOut == MojDbCollationInvalid) MojErrThrow(MojErrDbInvalidCollation); return MojErrNone; }
[ "steve.winston@gmail.com" ]
steve.winston@gmail.com
f98ee5443ff2bda706f42dd480b2165ec6cf0d79
772e505b365d81b2948ffbeba3c8227fccedeb30
/lab23/src/data.h
96af66e5ff328b8e67281677e39d05dcb995a30c
[]
no_license
KotKHPI/Programing_Radievych
97a07b8062feb7600d22cb7c6cdbc7fdb8abc2d6
76044900dc37c9737dd7004a2f7fcf3b1c7bb150
refs/heads/main
2023-05-13T17:57:54.791892
2021-06-03T04:29:14
2021-06-03T04:29:14
308,354,107
0
1
null
null
null
null
UTF-8
C++
false
false
3,669
h
/** * @file data.h * @brief Файл з описом класу птиць, перерахуванням критеріїв птиць та методами оперування птахами * * @author Radievych V. * @date 20-may-2021 * @version 1.0 */ #pragma once #include <cstdio> #include <cstring> /** * Так або ні */ enum Yes_no { Так, //0 Ні //1 }; /** * Стать птиці */ enum Sex { Чоловіча, Жіноча }; /** * Клас домівки птаха */ class Feature { private: int square; /**< площа домівки, см^2 */ int height; /**< висота домівки, см */ int number_of_feeders; /**< кількість годівниць */ enum Yes_no nest_nest; /**< наявність гнізда */ public: Feature(): square(0), height(0), number_of_feeders(0), nest_nest(Так) { } //данные по умолчанию (конструктор) Feature(int square1, int height1, int number_of_feeders1, Yes_no nest_nest1){ square = square1; height = height1; number_of_feeders = number_of_feeders1; nest_nest = nest_nest1; } void SetSquare (int x) { square = x; } int GetSquare () const{ return square; } void SetHeight (int x) { height = x; } int GetHeight() const{ return height; } void SetNumber_of_feeders (int x) { number_of_feeders = x; } int GetNumber_of_feeders () const { return number_of_feeders; } void SetNest_nest (Yes_no x) { nest_nest = x; } Yes_no GetNest_nest() const { return nest_nest; } Feature (const Feature &other) { //копирование this->square = other.square; this->height = other.height; this->number_of_feeders = other.number_of_feeders; this->nest_nest = other.nest_nest; } virtual ~Feature() { // :/ Bay-bay! } }; /** * Базовий клас "Птах" */ class Basic { private: enum Yes_no label; /**< чи окольцьована птаха */ char name[15]; /**< назва виду*/ int age; /**< вік птаха, місяців*/ Feature home; /**< структура домівки птаха (@link Feature) */ enum Sex sex; /**< стать птаха */ public: Basic(): label(Так), name("Птиця"), age(0), sex(Чоловіча) { } //конструктор1 Basic(Yes_no label1, char name1[], int age1, Feature home1, Sex sex1) { //конструктор2 label = label1; strcpy(name, name1); age = age1; home = home1; sex = sex1; } void SetLabel (Yes_no x){ label = x; } Yes_no GetLabel() const{ return label; } void SetName (char n[15]) { strcpy(name, n); } /** * Метод виводу на екран * * Метод виводе всі даніх елементу типу Basic */ void printAll() const; void SetSex (Sex x){ sex = x; } Sex GetSex() const{ return sex; } void SetAge(int x) { age = x; } int GetAge()const { return age; } Feature GetHome() { return home; } Basic (const Basic& other){ //копирование this->label = other.label; strcpy(this->name, other.name); this->age = other.age; this->home = other.home; this->sex = other.sex; } virtual ~Basic() { // :/ } };
[ "prototype2428@gmail.com" ]
prototype2428@gmail.com
c742e6f77bc223c75c7d55a41f2ed8065dc858c6
64588347a45ce54bafdf0a4ddcfa41c0c9bd4017
/C++/IPR2/IPR2/Source.cpp
f390491aff897b9dffbcb357f48b8f69c41b876f
[]
no_license
Yariko-chan/Education
274e53fc38d509142bf3751b660765eb93611bb4
a92e58f5b11f0d15378434736551bef1b933405b
refs/heads/master
2021-07-13T14:19:46.620099
2019-01-04T13:19:33
2019-01-04T13:19:33
124,668,954
0
0
null
null
null
null
UTF-8
C++
false
false
2,251
cpp
#include <iostream> using namespace std; class Rectangle { private: int width; int height; public: Rectangle(); Rectangle(int, int); Rectangle(const Rectangle &); ~Rectangle(); int get_width() const; int get_height() const; void set_width(int); void set_height(int); int square() const; int perimeter() const; void print_rectangle() const; }; int main(void) { int width, height; cout << "Rectangle" << endl; cout << "Enter width: "; cin >> width; cout << "Enter height: "; cin >> height; Rectangle r; try { r.set_width(width); r.set_height(height); } catch (invalid_argument e) { cout << "Exception: " << e.what() << endl; cout << "Created rectangular with default values" << endl; r.set_width(1); r.set_height(1); } r.print_rectangle(); int sq = r.square(); int per = r.perimeter(); cout << "Square " << sq << endl; cout << "Perimeter " << per << endl; getchar(); getchar(); } Rectangle::Rectangle() { width = 1; height = 1; } Rectangle::Rectangle(int w, int h) { if (w <= 0 || h <= 0) { throw invalid_argument("Width and height must be greater than 0."); } else { width = w; height = h; } } Rectangle::Rectangle(const Rectangle & r) { width = r.get_width(); height = r.get_height(); } Rectangle::~Rectangle() { } int Rectangle::get_width() const { return width; } int Rectangle::get_height() const { return height; } void Rectangle::set_width(int w) { if (w <= 0) { throw invalid_argument("Width must be greater than 0."); } else { width = w; } } void Rectangle::set_height(int h) { if (h <= 0) { throw invalid_argument("Height must be greater than 0."); } else { height = h; } } int Rectangle::square() const { return width*height; } int Rectangle::perimeter() const { return 2 * (width + height); } void Rectangle::print_rectangle() const { cout << "Rectangle" << endl; cout << "width = " << width << endl; cout << "height = " << height << endl; cout << " "; for (int i = 0; i < width; i++) { cout << "_"; } cout << endl; for (int i = 0; i < height; i++) { cout << "|"; for (int j = 0; j < width; j++) { cout << " "; } cout << "|" << endl; } cout << " "; for (int i = 0; i < width; i++) { cout << "_"; } cout << endl; }
[ "lililala1991@gmail.com" ]
lililala1991@gmail.com
701bd2c5e00b0248265612d49a6440582415b77d
2de859cf5e8a4e7c0e6b4804495a2dae7404d226
/GeometricTools/Graphics/DX11/DX11InputLayout.cpp
862a12a5bb54e3f637363f1023f2a40a8af19afd
[]
no_license
thecsapprentice/world-builder-dependencies
ac20734b9b9f5305f5342b0b737d7e34aa6a3bb6
9528ad27fc35f953e1e446fbd9493e291c92aaa8
refs/heads/master
2020-08-27T16:52:39.356801
2019-10-26T20:36:00
2019-10-26T20:36:00
217,438,016
1
0
null
null
null
null
UTF-8
C++
false
false
2,538
cpp
// David Eberly, Geometric Tools, Redmond WA 98052 // Copyright (c) 1998-2019 // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // Version: 4.0.2019.08.13 #include <Graphics/DX11/GTGraphicsDX11PCH.h> #include <Graphics/DX11/DX11InputLayout.h> using namespace gte; DX11InputLayout::~DX11InputLayout() { DX11::FinalRelease(mLayout); } DX11InputLayout::DX11InputLayout(ID3D11Device* device, VertexBuffer const* vbuffer, Shader const* vshader) : mLayout(nullptr), mNumElements(0) { LogAssert(vbuffer != nullptr && vshader != nullptr, "Invalid inputs."); std::memset(&mElements[0], 0, VA_MAX_ATTRIBUTES*sizeof(mElements[0])); VertexFormat const& format = vbuffer->GetFormat(); mNumElements = format.GetNumAttributes(); for (int i = 0; i < mNumElements; ++i) { VASemantic semantic; DFType type; unsigned int unit, offset; format.GetAttribute(i, semantic, type, unit, offset); D3D11_INPUT_ELEMENT_DESC& element = mElements[i]; element.SemanticName = msSemantic[semantic]; element.SemanticIndex = unit; element.Format = static_cast<DXGI_FORMAT>(type); element.InputSlot = 0; // TODO: Streams not yet supported. element.AlignedByteOffset = offset; element.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; element.InstanceDataStepRate = 0; } auto const& compiledCode = vshader->GetCompiledCode(); DX11Log(device->CreateInputLayout(mElements, (UINT)mNumElements, &compiledCode[0], compiledCode.size(), &mLayout)); } void DX11InputLayout::Enable(ID3D11DeviceContext* context) { if (mLayout) { context->IASetInputLayout(mLayout); } } void DX11InputLayout::Disable(ID3D11DeviceContext* context) { if (mLayout) { // TODO: Verify that mLayout is the active input layout. context->IASetInputLayout(nullptr); } } HRESULT DX11InputLayout::SetName(std::string const& name) { mName = name; return DX11::SetPrivateName(mLayout, mName); } char const* DX11InputLayout::msSemantic[VA_NUM_SEMANTICS] = { "", "POSITION", "BLENDWEIGHT", "BLENDINDICES", "NORMAL", "PSIZE", "TEXCOORD", "TANGENT", "BINORMAL", "TESSFACTOR", "POSITIONT", "COLOR", "FOG", "DEPTH", "SAMPLE" };
[ "nmitchel@cs.wisc.edu" ]
nmitchel@cs.wisc.edu
7018432ddff6bd4cbbd97e860a9575a324a9c0d9
86bd5562f967e9b8316e2f730bdad6a1cc29a7a1
/length-of-last-word/length-of-last-word.cpp
a4eb40fbf3b1656a14aad3276f9e88e192583e96
[]
no_license
Aman0002/Leetcode
225c0100c7d7f3c6cca2999f3d2a1acc83698fda
6dbdbb984df97619397103a8b8d396ecc4e050c0
refs/heads/main
2023-07-15T09:50:08.250773
2021-09-01T10:43:49
2021-09-01T10:43:49
362,705,508
1
0
null
null
null
null
UTF-8
C++
false
false
293
cpp
class Solution { public: int lengthOfLastWord(string A) { int cnt = 0, i = A.size()-1 ; while (i>0 && A[i]==' ') i--; for (;i>=0 ;i--) { if (A[i]!=' ') cnt++; else break; } return cnt; } };
[ "amancadet98@gmail.com" ]
amancadet98@gmail.com
7467af17a8aa2d5471a906fcc462668cb7c94c87
967beec9b6614be5b084005f48368ba4b8c5b3ec
/nngpuLib/nngpuLib/conv/convlayer.cpp
c553781351935fe7199e1674ea2ab969a5c94d55
[]
no_license
amonnphillip/nngpu
a8d99c08d8a78f8bb8054c0492f4caf8731d578f
e8463a679b458714df7f40bbca3372b6c8e286bf
refs/heads/master
2021-01-17T16:02:53.779740
2017-06-28T01:40:09
2017-06-28T01:40:09
82,978,955
0
0
null
null
null
null
UTF-8
C++
false
false
14,367
cpp
#include <algorithm> #include <iostream> #include <cassert> #include "convlayerconfig.h" #include "convlayer.h" #include "layersize.h" #include "layerexception.h" #include "cuda_runtime.h" #include "layer.h" #include "testutils.h" extern void ConvLayer_Forward(ConvNode *node, double* filters, LayerSize filterSize, int filterCount, LayerSize layerSize, LayerSize previousLayerSize, double *previousLayerOutput, double *output, int pad); extern void ConvLayer_Backward(ConvNode *node, double* filters, double* backFilters, LayerSize filterSize, int filterCount, LayerSize layerSize, LayerSize previousLayerSize, LayerSize nextLayerSize, double *previousLayerOutput, double *nextLayerOutput, double *output, int pad, double learnRate, int* backFilterLookUp, int backFilterLookUpSize); ConvLayer::ConvLayer(ConvLayerConfig* config, INNetworkLayer* previousLayer) { pad = config->GetPad(); stride = config->GetStride(); layerWidth = (int)std::floor(((double)(previousLayer->GetWidth() + pad * 2 - config->GetFilterWidth()) / (double)stride) + 1); layerHeight = (int)std::floor(((double)(previousLayer->GetHeight() + pad * 2 - config->GetFilterHeight()) / (double)stride) + 1); layerDepth = config->GetFilterCount(); filterWidth = config->GetFilterWidth(); filterHeight = config->GetFilterHeight(); filterDepth = previousLayer->GetForwardDepth(); filterSize = filterWidth * filterHeight; filterCount = config->GetFilterCount(); backwardWidth = previousLayer->GetForwardWidth(); backwardHeight = previousLayer->GetForwardHeight(); backwardDepth = previousLayer->GetForwardDepth(); forwardCount = layerWidth * layerHeight * layerDepth; nodeCount = forwardCount; Layer::Initialize( LayerType::Convolution, forwardCount, backwardWidth * backwardHeight * backwardDepth, nodeCount, true); ConvNode* nodes = nodeHostMem.get(); for (int index = 0; index < nodeCount; index++) { nodes->bias = 0; nodes++; } filterHostMem = std::unique_ptr<double>(new double[filterSize * filterDepth * filterCount]); if (filterHostMem.get() == nullptr) { throw std::bad_alloc(); } double filterValue = 1.0 / (double)(filterSize * filterDepth); std::fill_n(filterHostMem.get(), filterSize * filterDepth * filterCount, (double)filterValue); if (cudaMalloc((void**)&filterDeviceMem, filterSize * filterDepth * filterCount * sizeof(double)) != cudaError::cudaSuccess) { throw std::bad_alloc(); } if (cudaMemcpy(filterDeviceMem, filterHostMem.get(), filterSize * filterDepth * filterCount * sizeof(double), cudaMemcpyHostToDevice) != cudaError::cudaSuccess) { throw std::runtime_error("ConvLayer cudaMemcpy returned an error"); } backFilterHostMem = std::unique_ptr<double>(new double[filterSize * filterDepth * filterCount]); if (backFilterHostMem.get() == nullptr) { throw std::bad_alloc(); } std::fill_n(backFilterHostMem.get(), filterSize * filterDepth * filterCount, (double)0.0); if (cudaMalloc((void**)&backFilterDeviceMem, filterSize * filterDepth * filterCount * sizeof(double)) != cudaError::cudaSuccess) { throw std::bad_alloc(); } if (cudaMemcpy(backFilterDeviceMem, backFilterHostMem.get(), filterSize * filterDepth * filterCount * sizeof(double), cudaMemcpyHostToDevice) != cudaError::cudaSuccess) { throw std::runtime_error("ConvLayer cudaMemcpy returned an error"); } SetMemory(forwardHostMem.get(), forwardDeviceMem, forwardCount, 0); } void ConvLayer::Dispose() { if (filterDeviceMem != nullptr) { if (cudaFree(filterDeviceMem) != cudaError::cudaSuccess) { throw std::bad_alloc(); } filterDeviceMem = nullptr; } if (backFilterDeviceMem != nullptr) { if (cudaFree(backFilterDeviceMem) != cudaError::cudaSuccess) { throw std::bad_alloc(); } backFilterDeviceMem = nullptr; } if (backFilterLookUpDeviceMem != nullptr) { if (cudaFree(backFilterLookUpDeviceMem) != cudaError::cudaSuccess) { throw std::bad_alloc(); } backFilterLookUpDeviceMem = nullptr; } Layer::Dispose(); } void ConvLayer::Forward(double* input, int inputSize) { throw LayerException("Forward variant not valid for ConvLayer layer"); } void ConvLayer::Forward(INNetworkLayer* previousLayer, INNetworkLayer* nextLayer) { SetMemory(forwardHostMem.get(), forwardDeviceMem, forwardCount, 0); layerPerf.Start(layerWidth * layerHeight * layerDepth); ConvLayer_Forward( nodeDeviceMem, filterDeviceMem, LayerSize(filterWidth, filterHeight, filterDepth), filterCount, LayerSize(layerWidth, layerHeight, layerDepth), LayerSize(previousLayer->GetForwardWidth(), previousLayer->GetForwardHeight(), previousLayer->GetForwardDepth()), previousLayer->GetForwardDeviceMem(), forwardDeviceMem, pad); layerPerf.Stop(); #ifdef _UNITTEST //DebugPrint(); #endif } void ConvLayer::Backward(double* input, int inputSize, double learnRate) { throw LayerException("Backward variant not valid for ConvLayer layer"); } void ConvLayer::Backward(INNetworkLayer* previousLayer, INNetworkLayer* nextLayer, double learnRate) { if (backFilterLookUpHostMem.get() == nullptr) { ComputeBackFilterLookUp(previousLayer, nextLayer); // TODO: PUT THIS SOME PLACE SENSIBLE! } std::fill_n(backwardHostMem.get(), GetBackwardNodeCount(), (double)0.0); if (cudaMemcpy(backwardDeviceMem, backwardHostMem.get(), GetBackwardNodeCount() * sizeof(double), cudaMemcpyHostToDevice) != cudaError::cudaSuccess) { throw std::runtime_error("ConvLayer cudaMemcpy returned an error"); } std::fill_n(backFilterHostMem.get(), filterSize * filterDepth * filterCount, (double)0.0); if (cudaMemcpy(backFilterDeviceMem, backFilterHostMem.get(), filterSize * filterDepth * filterCount * sizeof(double), cudaMemcpyHostToDevice) != cudaError::cudaSuccess) { throw std::runtime_error("ConvLayer cudaMemcpy returned an error"); } //layerPerf.Start(layerWidth * layerHeight * layerDepth); ConvLayer_Backward( nodeDeviceMem, filterDeviceMem, backFilterDeviceMem, LayerSize(filterWidth, filterHeight, filterDepth), filterCount, LayerSize(layerWidth, layerHeight, layerDepth), LayerSize(previousLayer->GetForwardWidth(), previousLayer->GetForwardHeight(), previousLayer->GetForwardDepth()), LayerSize(nextLayer->GetBackwardWidth(), nextLayer->GetBackwardHeight(), nextLayer->GetBackwardDepth()), previousLayer->GetForwardDeviceMem(), nextLayer->GetBackwardDeviceMem(), backwardDeviceMem, pad, learnRate, backFilterLookUpDeviceMem, backFilterLookupSize); //layerPerf.Stop(); #ifdef _UNITTEST //DebugPrint(); #endif } double* ConvLayer::GetForwardHostMem(bool copyFromDevice) { if (copyFromDevice) { if (cudaMemcpy(forwardHostMem.get(), forwardDeviceMem, forwardCount * sizeof(double), cudaMemcpyDeviceToHost) != cudaError::cudaSuccess) { throw std::runtime_error("ConvLayer forward cudaMemcpy returned an error"); } } return forwardHostMem.get(); } double* ConvLayer::GetBackwardHostMem(bool copyFromDevice) { if (copyFromDevice) { if (cudaMemcpy(backwardHostMem.get(), backwardDeviceMem, GetBackwardNodeCount() * sizeof(double), cudaMemcpyDeviceToHost) != cudaError::cudaSuccess) { throw std::runtime_error("ConvLayer backward cudaMemcpy returned an error"); } } return backwardHostMem.get(); } double* ConvLayer::GetForwardDeviceMem() { return forwardDeviceMem; } double* ConvLayer::GetBackwardDeviceMem() { return backwardDeviceMem; } int ConvLayer::GetForwardNodeCount() { return forwardCount; } int ConvLayer::GetForwardWidth() { return layerWidth; } int ConvLayer::GetForwardHeight() { return layerHeight; } int ConvLayer::GetForwardDepth() { return layerDepth; } int ConvLayer::GetBackwardNodeCount() { return backwardWidth * backwardHeight * backwardDepth; } int ConvLayer::GetBackwardWidth() { return backwardWidth; } int ConvLayer::GetBackwardHeight() { return backwardHeight; } int ConvLayer::GetBackwardDepth() { return backwardDepth; } int ConvLayer::GetWidth() { return layerWidth; } int ConvLayer::GetHeight() { return layerHeight; } int ConvLayer::GetDepth() { return layerDepth; } LayerType ConvLayer::GetLayerType() { return Layer::GetLayerType(); } void ConvLayer::GetLayerData(LayerDataList& layerDataList) { LayerData* layerData = new LayerData[2 + (filterDepth * filterCount)]; layerDataList.layerDataCount = 2 + (filterDepth * filterCount); layerDataList.layerType = LayerType::Convolution; layerDataList.layerData = layerData; layerData->type = LayerDataType::Forward; layerData->width = GetForwardWidth(); layerData->height = GetForwardHeight(); layerData->depth = GetForwardDepth(); layerData->data = GetForwardHostMem(true); layerData++; layerData->type = LayerDataType::Backward; layerData->width = GetBackwardWidth(); layerData->height = GetBackwardHeight(); layerData->depth = GetBackwardDepth(); layerData->data = GetBackwardHostMem(true); layerData++; double* filter = GetFilterHostMem(true); for (int depthIndex = 0; depthIndex < filterDepth; depthIndex++) { for (int countIndex = 0; countIndex < filterCount; countIndex++) { layerData->type = LayerDataType::ConvForwardFilter; layerData->width = filterWidth; layerData->height = filterHeight; layerData->depth = 1; layerData->data = filter; layerData++; filter += filterSize; } } } double* ConvLayer::GetFilterHostMem(bool copyFromDevice) { if (copyFromDevice) { if (cudaMemcpy(filterHostMem.get(), filterDeviceMem, filterSize * filterDepth * filterCount * sizeof(double), cudaMemcpyDeviceToHost) != cudaError::cudaSuccess) { throw std::runtime_error("ConvLayer cudaMemcpy returned an error"); } } return filterHostMem.get(); } int ConvLayer::GetFilterMemNodeCount() { return filterSize * filterDepth * filterCount; } double* ConvLayer::GetBackFilterHostMem(bool copyFromDevice) { if (copyFromDevice) { if (cudaMemcpy(backFilterHostMem.get(), backFilterDeviceMem, filterSize * filterDepth * filterCount * sizeof(double), cudaMemcpyDeviceToHost) != cudaError::cudaSuccess) { throw std::runtime_error("ConvLayer cudaMemcpy returned an error"); } } return backFilterHostMem.get(); } int ConvLayer::GetBackFilterMemNodeCount() { return filterSize * filterDepth * filterCount; } ConvNode* ConvLayer::GetNodeMem(bool copyFromDevice) { if (copyFromDevice) { if (cudaMemcpy(nodeHostMem.get(), nodeDeviceMem, nodeCount * sizeof(ConvNode), cudaMemcpyDeviceToHost) != cudaError::cudaSuccess) { throw std::runtime_error("CudaMemcpy returned an error"); } } return nodeHostMem.get(); } void ConvLayer::ComputeBackFilterLookUp(INNetworkLayer* previousLayer, INNetworkLayer* nextLayer) { LayerSize layerSize = LayerSize(layerWidth, layerHeight, layerDepth); LayerSize filterSize = LayerSize(filterWidth, filterHeight, filterDepth); LayerSize previousLayerSize = LayerSize(previousLayer->GetForwardWidth(), previousLayer->GetForwardHeight(), previousLayer->GetForwardDepth()); LayerSize nextLayerSize = LayerSize(nextLayer->GetBackwardWidth(), nextLayer->GetBackwardHeight(), nextLayer->GetBackwardDepth()); int lookupSize = layerSize.width * layerSize.height * filterSize.width * filterSize.height; int maxHits = layerSize.width * layerSize.height; backFilterLookupSize = lookupSize; backFilterLookUpHostMem = std::unique_ptr<int>(new int[lookupSize * 2]); std::fill_n(backFilterLookUpHostMem.get(), lookupSize * 2, (int)-1); int* hitCount = new int[filterSize.width * filterSize.height]; std::fill_n(hitCount, filterSize.width * filterSize.height, (int)0); int* backFilterLookUp = backFilterLookUpHostMem.get(); for (int y = 0; y<layerSize.height; y++) { for (int x = 0; x<layerSize.width; x++) { int posx = x - pad; int posy = y - pad; int gradIndex = ((layerSize.width * y) + x) * nextLayerSize.depth; for (int filterPosy = 0; filterPosy < filterSize.height; filterPosy++) { for (int filterPosx = 0; filterPosx < filterSize.width; filterPosx++) { if (filterPosy + posy >= 0 && filterPosy + posy < layerSize.height && filterPosx + posx >= 0 && filterPosx + posx < layerSize.width) { int index1 = ((layerSize.width * (filterPosy + posy)) + filterPosx + posx) * previousLayerSize.depth; int index2 = ((filterSize.width * filterPosy) + filterPosx); backFilterLookUp[(index2 * maxHits * 2) + (hitCount[index2] * 2)] = index1; backFilterLookUp[(index2 * maxHits * 2) + (hitCount[index2] * 2) + 1] = gradIndex; hitCount[index2] ++; } } } } } if (cudaMalloc((void**)&backFilterLookUpDeviceMem, backFilterLookupSize * sizeof(int) * 2) != cudaError::cudaSuccess) { throw std::bad_alloc(); } if (cudaMemcpy(backFilterLookUpDeviceMem, backFilterLookUpHostMem.get(), backFilterLookupSize * sizeof(int) * 2, cudaMemcpyHostToDevice) != cudaError::cudaSuccess) { throw std::runtime_error("ConvLayer cudaMemcpy returned an error"); } } void ConvLayer::GetLayerPerformance(unsigned int& averageTime, double& averageBytes) { layerPerf.CalculateAverages(averageTime, averageBytes); } void ConvLayer::DebugPrint() { std::cout << "conv layer:\r\n"; #if 0 std::cout << "back filters:\r\n"; double sum = 0; double* backFilters = GetBackFilterHostMem(true); for (int c = 0; c < filterCount; c++) { for (int d = 0; d < filterDepth; d++) { for (int y = 0; y < filterWidth; y++) { for (int x = 0; x < filterHeight; x++) { std::cout << *backFilters << " "; sum += *backFilters; backFilters++; } std::cout << "\r\n"; } std::cout << "\r\n"; } } std::cout << "sum: " << sum << "\r\n"; #endif std::cout << "backward:\r\n"; TestUtils::DebugPrintRectangularMemory(GetBackwardHostMem(true), backwardWidth, backwardHeight, backwardDepth); #if 1 std::cout << "forward filters:\r\n"; double* forwardFilters = GetFilterHostMem(true); for (int c = 0; c < filterCount; c++) { //sum = 0; for (int d = 0; d < filterDepth; d++) { for (int y = 0; y < filterWidth; y++) { for (int x = 0; x < filterHeight; x++) { std::cout << *forwardFilters << " "; //sum += *forwardFilters; forwardFilters++; } std::cout << "\r\n"; } std::cout << "\r\n"; } //std::cout << "sum: " << sum << "\r\n"; } #endif std::cout << "forward:\r\n"; TestUtils::DebugPrintRectangularMemory(GetForwardHostMem(true), layerWidth, layerHeight, layerDepth); }
[ "amonnphillip@gmail.com" ]
amonnphillip@gmail.com
99d819893bec23085c65ba9d5811c2ebcfd9362f
bbac388eb6b53daec63190e2f271a18fe9bfb163
/abc129/AAirplane.cpp
5a73ef20945d4ce37e51b3c24f6ed266ce3cf68e
[]
no_license
tatsumack/atcoder
8d94cf29160b6553b0c089cb795c54efd3fb0f7b
fbe1e1eab80c4c0680ec046acdc6214426b19650
refs/heads/master
2023-06-17T23:09:54.056132
2021-07-04T13:03:59
2021-07-04T13:03:59
124,963,709
0
0
null
null
null
null
UTF-8
C++
false
false
1,354
cpp
#include <iostream> #include <limits.h> #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #include <queue> #include <unordered_map> #include <unordered_set> #define int long long #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i) #define REV(i, a, b) for (int i = (a); i >= (b); --i) #define CLR(a, b) memset((a), (b), sizeof(a)) #define DUMP(x) cout << #x << " = " << (x) << endl; #define INF 1001001001001001001ll #define fcout cout << fixed << setprecision(12) using namespace std; typedef pair<int, int> P; class AAirplane { public: static constexpr int kStressIterations = 0; static void generateTest(std::ostream& test) { } void solve(std::istream& cin, std::ostream& cout) { vector<int> v(3); REP(i, 3) { cin >> v[i]; } sort(v.begin(), v.end()); cout << v[0] + v[1] << endl; } };
[ "tatsu.mack@gmail.com" ]
tatsu.mack@gmail.com
42576ffd1d0452cf97fc304dcf58d2f5ce4c9969
117c7b7e9bc01ddb11d9b4f72a6f3e1fed116f9d
/quic/congestion_control/Bbr.h
997dd99c927400f5182d2657a411c9094047f4f5
[ "MIT" ]
permissive
feiyunwill/mvfst
f23a150c38bb9fa7940d652f64bde5ed46c1ce25
3d26794719e1b5c88064db3240a1df62b01d4d39
refs/heads/master
2020-09-28T14:22:58.008720
2019-12-07T23:47:13
2019-12-07T23:48:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,154
h
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ // Copyright 2004-present Facebook. All rights reserved. #pragma once #include <quic/congestion_control/Bandwidth.h> #include <quic/congestion_control/third_party/windowed_filter.h> #include <quic/state/StateData.h> namespace quic { // Cwnd and pacing gain during STARSTUP constexpr float kStartupGain = 2.885f; // 2/ln(2) // Cwnd gain during ProbeBw constexpr float kProbeBwGain = 2.0f; // The expected of bandwidth growth in each round trip time during STARTUP constexpr float kExpectedStartupGrowth = 1.25f; // How many rounds of rtt to stay in STARUP when the bandwidth isn't growing as // fast as kExpectedStartupGrowth constexpr uint8_t kStartupSlowGrowRoundLimit = 3; // Number of pacing cycles constexpr uint8_t kNumOfCycles = 8; // Pacing cycles constexpr std::array<float, kNumOfCycles> kPacingGainCycles = {1.25, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; // During ProbeRtt, we need to stay in low inflight condition for at least // kProbeRttDuration. constexpr std::chrono::milliseconds kProbeRttDuration{200}; // The cwnd gain to use when BbrConfig.largeProbeRttCwnd is set. constexpr float kLargeProbeRttCwndGain = 0.75f; // Bandwidth WindowFilter length, in unit of RTT. This value is from Chromium // code. I don't know why. constexpr uint64_t kBandwidthWindowLength = kNumOfCycles + 2; // RTT Sampler default expiration constexpr std::chrono::seconds kDefaultRttSamplerExpiration{10}; // 64K, used in sendQuantum calculation: constexpr uint64_t k64K = 64 * 1024; // TODO: rate based startup mode // TODO: send extra bandwidth probers when pipe isn't sufficiently full class BbrCongestionController : public CongestionController { public: /** * A class to collect RTT samples, tracks the minimal one among them, and * expire the min rtt sample after some period of time. */ class MinRttSampler { public: virtual ~MinRttSampler() = default; virtual std::chrono::microseconds minRtt() const = 0; /** * Returns: true iff we have min rtt sample and it has expired. */ virtual bool minRttExpired() const = 0; /** * rttSample: current rtt sample * sampledTime: the time point this sample is collected * * return: whether min rtt is updated by the new sample */ virtual bool newRttSample( std::chrono::microseconds rttSample, TimePoint sampledTime) noexcept = 0; /** * Mark timestamp as the minrtt time stamp. Min rtt will expire at * timestampe + expiration_duration. */ virtual void timestampMinRtt(TimePoint timestamp) noexcept = 0; }; class BandwidthSampler { public: virtual ~BandwidthSampler() = default; virtual Bandwidth getBandwidth() const = 0; virtual void onPacketAcked( const CongestionController::AckEvent&, uint64_t roundTripCounter) = 0; virtual void onAppLimited() = 0; virtual bool isAppLimited() const = 0; }; // TODO: a way to give config to bbr struct BbrConfig { bool conservativeRecovery{false}; /** * When largeProbeRttCwnd is true, kLargeProbeRttCwndGain * BDP will be used * as cwnd during ProbeRtt state, otherwise, 4MSS will be the ProbeRtt cwnd. */ bool largeProbeRttCwnd{false}; // Whether ack aggregation is also calculated during Startup phase bool enableAckAggregationInStartup{false}; /** * Whether we should enter ProbeRtt if connection has been app-limited since * last time we ProbeRtt. */ bool probeRttDisabledIfAppLimited{false}; /** * Whether BBR should advance pacing gain cycle when BBR is draining and we * haven't reached the drain target. */ bool drainToTarget{false}; }; // TODO: i may move the configuration into a separate function BbrCongestionController( QuicConnectionStateBase& conn, const BbrConfig& config); // TODO: these should probably come in as part of a builder. but I'm not sure // if the sampler interface is here to stay atm, so bear with me void setRttSampler(std::unique_ptr<MinRttSampler> sampler) noexcept; void setBandwidthSampler(std::unique_ptr<BandwidthSampler> sampler) noexcept; enum class BbrState : uint8_t { Startup, Drain, ProbeBw, ProbeRtt, }; enum class RecoveryState : uint8_t { NOT_RECOVERY = 0, CONSERVATIVE = 1, GROWTH = 2, }; void onRemoveBytesFromInflight(uint64_t bytesToRemove) override; void onPacketSent(const OutstandingPacket&) override; void onPacketAckOrLoss( folly::Optional<AckEvent> ackEvent, folly::Optional<LossEvent> lossEvent) override; uint64_t getWritableBytes() const noexcept override; uint64_t getCongestionWindow() const noexcept override; CongestionControlType type() const noexcept override; void setAppIdle(bool idle, TimePoint eventTime) noexcept override; void setAppLimited() override; bool isAppLimited() const noexcept override; // TODO: some of these do not have to be in public API. bool inRecovery() const noexcept; BbrState state() const noexcept; private: /* prevInflightBytes: the inflightBytes_ value before the current * onPacketAckOrLoss invocation. * hasLoss: whether current onPacketAckOrLoss has loss. */ void onPacketAcked(const AckEvent& ack, uint64_t prevInflightBytes, bool hasLoss); void onPacketLoss(const LossEvent&, uint64_t ackedBytes); void updatePacing() noexcept; /** * Update the ack aggregation states * * return: the excessive bytes from ack aggregation. * * Ack Aggregation: starts when ack arrival rate is slower than estimated * bandwidth, lasts until it's faster than estimated bandwidth. */ uint64_t updateAckAggregation(const AckEvent& ack); /** * Check if we have found the bottleneck link bandwidth with the current ack. */ void detectBottleneckBandwidth(bool); bool shouldExitStartup() noexcept; bool shouldExitDrain() noexcept; bool shouldProbeRtt(TimePoint ackTime) noexcept; void transitToDrain() noexcept; void transitToProbeBw(TimePoint congestionEventTime); void transitToProbeRtt() noexcept; void transitToStartup() noexcept; // Pick a random pacing cycle except 1 size_t pickRandomCycle(); // Special handling of AckEvent when connection is in ProbeRtt state void handleAckInProbeRtt(bool newRoundTrip, TimePoint ackTime) noexcept; /** * Special handling of AckEvent when connection is in ProbeBw state. * * prevInflightBytes: the inflightBytes_ value before the current * onPacketAckOrLoss invocation. * hasLoss: whether the current onpacketAckOrLoss has loss. */ void handleAckInProbeBw( TimePoint ackTime, uint64_t prevInflightBytes, bool hasLoss) noexcept; /* * Return if we are at the start of a new round trip. */ bool updateRoundTripCounter(TimePoint largestAckedSentTime) noexcept; void updateRecoveryWindowWithAck(uint64_t bytesAcked) noexcept; uint64_t calculateTargetCwnd(float gain) const noexcept; void updateCwnd(uint64_t ackedBytes, uint64_t excessiveBytes) noexcept; std::chrono::microseconds minRtt() const noexcept; Bandwidth bandwidth() const noexcept; QuicConnectionStateBase& conn_; BbrConfig config_; BbrState state_{BbrState::Startup}; RecoveryState recoveryState_{RecoveryState::NOT_RECOVERY}; // Number of round trips the connection has witnessed uint64_t roundTripCounter_{0}; // When a packet with send time later than endOfRoundTrip_ is acked, the // current round strip is ended. TimePoint endOfRoundTrip_; // When a packet with send time later than endOfRecovery_ is acked, the // connection is no longer in recovery folly::Optional<TimePoint> endOfRecovery_; // Cwnd in bytes uint64_t cwnd_; // Initial cwnd in bytes uint64_t initialCwnd_; // Congestion window when the connection is in recovery uint64_t recoveryWindow_; // inflight bytes uint64_t inflightBytes_{0}; // Number of bytes we expect to send over one RTT when paced write. uint64_t pacingWindow_{0}; float cwndGain_{kStartupGain}; float pacingGain_{kStartupGain}; // Whether we have found the bottleneck link bandwidth bool btlbwFound_{false}; uint64_t sendQuantum_{0}; std::unique_ptr<MinRttSampler> minRttSampler_; std::unique_ptr<BandwidthSampler> bandwidthSampler_; Bandwidth previousStartupBandwidth_; // Counter of continuous round trips in STARTUP that bandwidth isn't growing // fast enough uint8_t slowStartupRoundCounter_{0}; // Current cycle index in kPacingGainCycles size_t pacingCycleIndex_{0}; // The starting time of this pacing cycle. The cycle index will proceed by 1 // when we are one minrtt away from this time point. TimePoint cycleStart_; // Once in ProbeRtt state, we cannot exit ProbeRtt before at least we spend // some duration with low inflight bytes. earliestTimeToExitProbeRtt_ is that // time point. folly::Optional<TimePoint> earliestTimeToExitProbeRtt_; // We also cannot exit ProbeRtt if are not at least at the low inflight bytes // mode for one RTT round. probeRttRound_ tracks that. folly::Optional<uint64_t> probeRttRound_; WindowedFilter< uint64_t /* ack bytes count */, MaxFilter<uint64_t>, uint64_t /* roundtrip count */, uint64_t /* roundtrip count */> maxAckHeightFilter_; folly::Optional<TimePoint> ackAggregationStartTime_; uint64_t aggregatedAckBytes_{0}; bool appLimitedSinceProbeRtt_{false}; // The connection was very inactive and we are leaving that. bool exitingQuiescene_{false}; friend std::ostream& operator<<( std::ostream& os, const BbrCongestionController& bbr); }; std::ostream& operator<<(std::ostream& os, const BbrCongestionController& bbr); std::string bbrStateToString(BbrCongestionController::BbrState state); std::string bbrRecoveryStateToString( BbrCongestionController::RecoveryState recoveryState); } // namespace quic
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
dc5ceefac8138618085552983aee700e002be963
20133b9bb11d2c01d690ecb55d708bf1c18e2e51
/op/OpInterface.cpp
247dd18a2e4c6ba7e408621ed95b3334ad14d047
[]
no_license
lineCode/op
a9e5ad98815abd79888857304c8bac620c192a6a
00921d64710d7bb9cf484e2d306710608f2c1f9b
refs/heads/master
2022-02-03T18:24:44.192349
2019-07-19T13:35:51
2019-07-19T13:35:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
24,363
cpp
// OpInterface.cpp: OpInterface 的实现 #include "stdafx.h" #include "OpInterface.h" #include "Cmder.h" #include "Injecter.h" #include "Tool.h" #include "AStar.hpp" #include <filesystem> // OpInterface STDMETHODIMP OpInterface::Ver(BSTR* ret) { //Tool::setlog("address=%d,str=%s", ver, ver); CComBSTR newstr; newstr.Append(OP_VERSION); newstr.CopyTo(ret); return S_OK; } STDMETHODIMP OpInterface::SetPath(BSTR path, LONG* ret) { std::filesystem::path p = path; auto fullpath = std::filesystem::absolute(p); _curr_path = fullpath.generic_wstring(); _image_proc._curr_path = _curr_path; *ret = 1; return S_OK; } STDMETHODIMP OpInterface::GetPath(BSTR* path) { CComBSTR bstr; bstr.Append(_curr_path.c_str()); bstr.CopyTo(path); return S_OK; } STDMETHODIMP OpInterface::GetBasePath(BSTR* path){ CComBSTR bstr; wchar_t basepath[256]; ::GetModuleFileName(gInstance, basepath, 256); bstr.Append(basepath); bstr.CopyTo(path); return S_OK; } STDMETHODIMP OpInterface::SetShowErrorMsg(LONG show_type, LONG* ret){ gShowError = show_type; *ret = 1; return S_OK; } STDMETHODIMP OpInterface::Sleep(LONG millseconds, LONG* ret) { ::Sleep(millseconds); *ret = 1; return S_OK; } STDMETHODIMP OpInterface::InjectDll(BSTR process_name, BSTR dll_name, LONG* ret) { //auto proc = _wsto_string(process_name); //auto dll = _wsto_string(dll_name); //Injecter::EnablePrivilege(TRUE); //auto h = Injecter::InjectDll(process_name, dll_name); *ret = 0; return S_OK; } STDMETHODIMP OpInterface::EnablePicCache(LONG enable, LONG* ret) { _image_proc._enable_cache = enable; *ret = 1; return S_OK; } STDMETHODIMP OpInterface::AStarFindPath(LONG mapWidth, LONG mapHeight, BSTR disable_points, LONG beginX, LONG beginY, LONG endX, LONG endY, BSTR* path) { AStar as; vector<Vector2i>walls; vector<wstring> vstr; Vector2i tp; split(disable_points, vstr, L"|"); for (auto&it : vstr) { if (swscanf(it.c_str(), L"%d,%d", &tp[0], &tp[1]) != 2) break; walls.push_back(tp); } list<Vector2i> paths; as.set_map( mapWidth, mapHeight , walls); as.findpath(beginX,beginY , endX,endY , paths); wstring pathstr; wchar_t buf[20]; for (auto it = paths.rbegin(); it != paths.rend(); ++it) { auto v = *it; wsprintf(buf, L"%d,%d", v[0], v[1]); pathstr += buf; pathstr.push_back(L'|'); } if (!pathstr.empty()) pathstr.pop_back(); CComBSTR newstr; newstr.Append(pathstr.c_str()); newstr.CopyTo(path); return S_OK; } STDMETHODIMP OpInterface::EnumWindow(LONG parent, BSTR title, BSTR class_name, LONG filter, BSTR* retstr) { // TODO: 在此添加实现代码 std::unique_ptr<wchar_t> retstring(new wchar_t[MAX_PATH * 200]); memset(retstring.get(), 0, sizeof(wchar_t)*MAX_PATH * 200); _winapi.EnumWindow((HWND)parent, title, class_name, filter, retstring.get()); //*retstr=_bstr_t(retstring); CComBSTR newbstr; auto hr=newbstr.Append(retstring.get()); hr=newbstr.CopyTo(retstr); return hr; } STDMETHODIMP OpInterface::EnumWindowByProcess(BSTR process_name, BSTR title, BSTR class_name, LONG filter, BSTR* retstring) { // TODO: 在此添加实现代码 std::unique_ptr<wchar_t> retstr(new wchar_t[MAX_PATH * 200]); memset(retstr.get(), 0, sizeof(wchar_t) * MAX_PATH * 200); _winapi.EnumWindow((HWND)0, title, class_name, filter, retstr.get(), process_name); //*retstring=_bstr_t(retstr); CComBSTR newbstr; newbstr.Append(retstr.get()); newbstr.CopyTo(retstring); return S_OK; } STDMETHODIMP OpInterface::EnumProcess(BSTR name, BSTR* retstring) { // TODO: 在此添加实现代码 std::unique_ptr<wchar_t> retstr(new wchar_t[MAX_PATH * 200]); memset(retstr.get(), 0, sizeof(wchar_t) * MAX_PATH * 200); _winapi.EnumProcess(name, retstr.get()); //*retstring=_bstr_t(retstr); CComBSTR newbstr; newbstr.Append(retstr.get()); newbstr.CopyTo(retstring); return S_OK; } STDMETHODIMP OpInterface::ClientToScreen(LONG ClientToScreen, VARIANT* x, VARIANT* y, LONG* bret) { // TODO: 在此添加实现代码 x->vt = VT_I4; y->vt = VT_I4; *bret = _winapi.ClientToScreen(ClientToScreen, x->lVal, y->lVal); return S_OK; } STDMETHODIMP OpInterface::FindWindow(BSTR class_name, BSTR title, LONG* rethwnd) { // TODO: 在此添加实现代码 *rethwnd = _winapi.FindWindow(class_name, title); return S_OK; } STDMETHODIMP OpInterface::FindWindowByProcess(BSTR process_name, BSTR class_name, BSTR title, LONG* rethwnd) { // TODO: 在此添加实现代码 _winapi.FindWindowByProcess(class_name, title, *rethwnd, process_name); return S_OK; } STDMETHODIMP OpInterface::FindWindowByProcessId(LONG process_id, BSTR class_name, BSTR title, LONG* rethwnd) { // TODO: 在此添加实现代码 _winapi.FindWindowByProcess(class_name, title, *rethwnd, NULL, process_id); return S_OK; } STDMETHODIMP OpInterface::FindWindowEx(LONG parent, BSTR class_name, BSTR title, LONG* rethwnd) { // TODO: 在此添加实现代码 *rethwnd = _winapi.FindWindowEx(parent,class_name, title); return S_OK; } STDMETHODIMP OpInterface::GetClientRect(LONG hwnd, VARIANT* x1, VARIANT* y1, VARIANT* x2, VARIANT* y2, LONG* nret) { // TODO: 在此添加实现代码 x1->vt = VT_I4; y1->vt = VT_I4; x2->vt = VT_I4; y2->vt = VT_I4; *nret = _winapi.GetClientRect(hwnd, x1->lVal, y1->lVal, x2->lVal, y2->lVal); return S_OK; } STDMETHODIMP OpInterface::GetClientSize(LONG hwnd, VARIANT* width, VARIANT* height, LONG* nret) { // TODO: 在此添加实现代码 width->vt = VT_I4; height->vt = VT_I4; *nret = _winapi.GetClientSize(hwnd, width->lVal, height->lVal); return S_OK; } STDMETHODIMP OpInterface::GetForegroundFocus(LONG* rethwnd) { // TODO: 在此添加实现代码 *rethwnd = (LONG)::GetFocus(); return S_OK; } STDMETHODIMP OpInterface::GetForegroundWindow(LONG* rethwnd) { // TODO: 在此添加实现代码 *rethwnd = (LONG)::GetForegroundWindow(); return S_OK; } STDMETHODIMP OpInterface::GetMousePointWindow(LONG* rethwnd) { // TODO: 在此添加实现代码 //::Sleep(2000); _winapi.GetMousePointWindow(*rethwnd); return S_OK; } STDMETHODIMP OpInterface::GetPointWindow(LONG x, LONG y, LONG* rethwnd) { // TODO: 在此添加实现代码 _winapi.GetMousePointWindow(*rethwnd, x, y); return S_OK; } STDMETHODIMP OpInterface::GetProcessInfo(LONG pid, BSTR* retstring) { // TODO: 在此添加实现代码 wchar_t retstr[MAX_PATH] = { 0 }; _winapi.GetProcessInfo(pid, retstr); //* retstring=_bstr_t(retstr); CComBSTR newbstr; newbstr.Append(retstr); newbstr.CopyTo(retstring); return S_OK; } STDMETHODIMP OpInterface::GetSpecialWindow(LONG flag, LONG* rethwnd) { // TODO: 在此添加实现代码 *rethwnd = 0; if (flag == 0) *rethwnd = (LONG)GetDesktopWindow(); else if (flag == 1) { *rethwnd = (LONG)::FindWindow(L"Shell_TrayWnd", NULL); } return S_OK; } STDMETHODIMP OpInterface::GetWindow(LONG hwnd, LONG flag, LONG* nret) { // TODO: 在此添加实现代码 _winapi.TSGetWindow(hwnd, flag, *nret); return S_OK; } STDMETHODIMP OpInterface::GetWindowClass(LONG hwnd, BSTR* retstring) { // TODO: 在此添加实现代码 wchar_t classname[MAX_PATH] = { 0 }; ::GetClassName((HWND)hwnd, classname, MAX_PATH); //* retstring=_bstr_t(classname); CComBSTR newbstr; newbstr.Append(classname); newbstr.CopyTo(retstring); return S_OK; } STDMETHODIMP OpInterface::GetWindowProcessId(LONG hwnd, LONG* nretpid) { // TODO: 在此添加实现代码 DWORD pid = 0; ::GetWindowThreadProcessId((HWND)hwnd, &pid); *nretpid = pid; return S_OK; } STDMETHODIMP OpInterface::GetWindowProcessPath(LONG hwnd, BSTR* retstring) { // TODO: 在此添加实现代码 DWORD pid = 0; ::GetWindowThreadProcessId((HWND)hwnd, &pid); wchar_t process_path[MAX_PATH] = { 0 }; _winapi.GetProcesspath(pid, process_path); //* retstring=_bstr_t(process_path); CComBSTR newbstr; newbstr.Append(process_path); newbstr.CopyTo(retstring); return S_OK; } STDMETHODIMP OpInterface::GetWindowRect(LONG hwnd, VARIANT* x1, VARIANT* y1, VARIANT* x2, VARIANT* y2, LONG* nret) { // TODO: 在此添加实现代码 x1->vt = VT_I4; x2->vt = VT_I4; y1->vt = VT_I4; y2->vt = VT_I4; RECT winrect; *nret = ::GetWindowRect((HWND)hwnd, &winrect); x1->intVal = winrect.left; y1->intVal = winrect.top; x2->intVal = winrect.right; y2->intVal = winrect.bottom; return S_OK; } STDMETHODIMP OpInterface::GetWindowState(LONG hwnd, LONG flag, LONG* rethwnd) { // TODO: 在此添加实现代码 *rethwnd = _winapi.GetWindowState(hwnd, flag); return S_OK; } STDMETHODIMP OpInterface::GetWindowTitle(LONG hwnd, BSTR* rettitle) { // TODO: 在此添加实现代码 wchar_t title[MAX_PATH] = { 0 }; ::GetWindowText((HWND)hwnd, title, MAX_PATH); //* rettitle=_bstr_t(title); CComBSTR newbstr; newbstr.Append(title); newbstr.CopyTo(rettitle); return S_OK; } STDMETHODIMP OpInterface::MoveWindow(LONG hwnd, LONG x, LONG y, LONG* nret) { // TODO: 在此添加实现代码 RECT winrect; ::GetWindowRect((HWND)hwnd, &winrect); int width = winrect.right - winrect.left; int hight = winrect.bottom - winrect.top; *nret = ::MoveWindow((HWND)hwnd, x, y, width, hight, false); return S_OK; } STDMETHODIMP OpInterface::ScreenToClient(LONG hwnd, VARIANT* x, VARIANT* y, LONG* nret) { // TODO: 在此添加实现代码 x->vt = VT_I4; y->vt = VT_I4; POINT point; *nret = ::ScreenToClient((HWND)hwnd, &point); x->intVal = point.x; y->intVal = point.y; return S_OK; } STDMETHODIMP OpInterface::SendPaste(LONG hwnd, LONG* nret) { // TODO: 在此添加实现代码 *nret = _winapi.SendPaste(hwnd); return S_OK; } STDMETHODIMP OpInterface::SetClientSize(LONG hwnd, LONG width, LONG hight, LONG* nret) { // TODO: 在此添加实现代码 *nret = _winapi.SetWindowSize(hwnd, width, hight); return S_OK; } STDMETHODIMP OpInterface::SetWindowState(LONG hwnd, LONG flag, LONG* nret) { // TODO: 在此添加实现代码 *nret = _winapi.SetWindowState(hwnd, flag); return S_OK; } STDMETHODIMP OpInterface::SetWindowSize(LONG hwnd, LONG width, LONG height, LONG* nret) { // TODO: 在此添加实现代码 *nret = _winapi.SetWindowSize(hwnd, width, height, 1); return S_OK; } STDMETHODIMP OpInterface::SetWindowText(LONG hwnd, BSTR title, LONG* nret) { // TODO: 在此添加实现代码 //*nret=gWindowObj.TSSetWindowState(hwnd,flag); *nret = ::SetWindowText((HWND)hwnd, title); return S_OK; } STDMETHODIMP OpInterface::SetWindowTransparent(LONG hwnd, LONG trans, LONG* nret) { // TODO: 在此添加实现代码 *nret = _winapi.SetWindowTransparent(hwnd, trans); return S_OK; } STDMETHODIMP OpInterface::SendString(LONG hwnd, BSTR str, LONG* ret) { *ret = _winapi.SendString((HWND)hwnd, str); return S_OK; } STDMETHODIMP OpInterface::SendStringIme(LONG hwnd, BSTR str, LONG* ret) { *ret = _winapi.SendStringIme((HWND)hwnd, str); return S_OK; } STDMETHODIMP OpInterface::RunApp(BSTR cmdline, LONG mode, LONG* ret) { *ret = _winapi.RunApp(cmdline, mode); return S_OK; } STDMETHODIMP OpInterface::WinExec(BSTR cmdline, LONG cmdshow, LONG* ret) { auto str = _ws2string(cmdline); *ret = ::WinExec(str.c_str(), cmdshow) > 31 ? 1 : 0; return S_OK; } STDMETHODIMP OpInterface::GetCmdStr(BSTR cmd, LONG millseconds, BSTR* retstr) { CComBSTR bstr; auto strcmd = _ws2string(cmd); Cmder cd; auto str = cd.GetCmdStr(strcmd, millseconds <= 0 ? 5 : millseconds); auto hr = bstr.Append(str.c_str()); hr = bstr.CopyTo(retstr); return hr; } STDMETHODIMP OpInterface::BindWindow(LONG hwnd, BSTR display, BSTR mouse, BSTR keypad, LONG mode, LONG *ret) { if (_bkproc.IsBind()) _bkproc.UnBindWindow(); *ret = _bkproc.BindWindow(hwnd, display, mouse, keypad, mode); if (*ret == 1) { _image_proc.set_offset(_bkproc._pbkdisplay->_client_x, _bkproc._pbkdisplay->_client_y); } return S_OK; } STDMETHODIMP OpInterface::UnBindWindow(LONG* ret) { *ret = _bkproc.UnBindWindow(); return S_OK; } STDMETHODIMP OpInterface::GetCursorPos(VARIANT* x, VARIANT* y, LONG* ret) { x->vt = y->vt = VT_I4; *ret = _bkproc._bkmouse.GetCursorPos(x->lVal, y->lVal); return S_OK; } STDMETHODIMP OpInterface::MoveR(LONG x, LONG y, LONG* ret) { *ret = _bkproc._bkmouse.MoveR(x, y); return S_OK; } //把鼠标移动到目的点(x,y) STDMETHODIMP OpInterface::MoveTo(LONG x, LONG y, LONG* ret) { *ret = _bkproc._bkmouse.MoveTo(x, y); return S_OK; } STDMETHODIMP OpInterface::MoveToEx(LONG x, LONG y, LONG w, LONG h, LONG* ret) { *ret = _bkproc._bkmouse.MoveToEx(x, y, w, h); return S_OK; } STDMETHODIMP OpInterface::LeftClick(LONG* ret) { *ret = _bkproc._bkmouse.LeftClick(); return S_OK; } STDMETHODIMP OpInterface::LeftDoubleClick(LONG* ret) { *ret = _bkproc._bkmouse.LeftDoubleClick(); return S_OK; } STDMETHODIMP OpInterface::LeftDown(LONG* ret) { *ret = _bkproc._bkmouse.LeftDown(); return S_OK; } STDMETHODIMP OpInterface::LeftUp(LONG* ret) { *ret = _bkproc._bkmouse.LeftUp(); return S_OK; } STDMETHODIMP OpInterface::MiddleClick(LONG* ret) { *ret = _bkproc._bkmouse.MiddleClick(); return S_OK; } STDMETHODIMP OpInterface::MiddleDown(LONG* ret) { *ret = _bkproc._bkmouse.MiddleDown(); return S_OK; } STDMETHODIMP OpInterface::MiddleUp(LONG* ret) { *ret = _bkproc._bkmouse.MiddleUp(); return S_OK; } STDMETHODIMP OpInterface::RightClick(LONG* ret) { *ret = _bkproc._bkmouse.RightClick(); return S_OK; } STDMETHODIMP OpInterface::RightDown(LONG* ret) { *ret = _bkproc._bkmouse.RightDown(); return S_OK; } STDMETHODIMP OpInterface::RightUp(LONG* ret) { *ret = _bkproc._bkmouse.RightUp(); return S_OK; } STDMETHODIMP OpInterface::WheelDown(LONG* ret) { *ret = _bkproc._bkmouse.WheelDown(); return S_OK; } STDMETHODIMP OpInterface::WheelUp(LONG* ret) { *ret = _bkproc._bkmouse.WheelUp(); return S_OK; } STDMETHODIMP OpInterface::GetKeyState(LONG vk_code, LONG* ret) { *ret = _bkproc._keypad.GetKeyState(vk_code); return S_OK; } STDMETHODIMP OpInterface::KeyDown(LONG vk_code, LONG* ret) { *ret = _bkproc._keypad.KeyDown(vk_code); return S_OK; } STDMETHODIMP OpInterface::KeyDownChar(BSTR vk_code, LONG* ret) { auto nlen = ::SysStringLen(vk_code); *ret = 0; if (nlen > 0) { long vk = _vkmap.count(vk_code) ? _vkmap[vk_code] : vk_code[0]; *ret = _bkproc._keypad.KeyDown(vk); } return S_OK; } STDMETHODIMP OpInterface::KeyUp(LONG vk_code, LONG* ret) { *ret = _bkproc._keypad.KeyUp(vk_code); return S_OK; } STDMETHODIMP OpInterface::KeyUpChar(BSTR vk_code, LONG* ret) { auto nlen = ::SysStringLen(vk_code); *ret = 0; if (nlen > 0) { long vk = _vkmap.count(vk_code) ? _vkmap[vk_code] : vk_code[0]; *ret = _bkproc._keypad.KeyUp(vk); } return S_OK; } STDMETHODIMP OpInterface::WaitKey(LONG vk_code, LONG time_out, LONG* ret) { if (time_out < 0)time_out = 0; *ret = _bkproc._keypad.WaitKey(vk_code, time_out); return S_OK; } STDMETHODIMP OpInterface::KeyPress(LONG vk_code, LONG* ret) { *ret = _bkproc._keypad.KeyPress(vk_code); return S_OK; } STDMETHODIMP OpInterface::KeyPressChar(BSTR vk_code, LONG* ret) { auto nlen = ::SysStringLen(vk_code); *ret = 0; if (nlen > 0) { long vk = _vkmap.count(vk_code) ? _vkmap[vk_code] : vk_code[0]; *ret = _bkproc._keypad.KeyPress(vk); } return S_OK; } //抓取指定区域(x1, y1, x2, y2)的图像, 保存为file STDMETHODIMP OpInterface::Capture(LONG x1, LONG y1, LONG x2, LONG y2, BSTR file_name, LONG* ret) { *ret = 0; if (_bkproc.check_bind()&& _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); *ret = _image_proc.Capture(file_name); } return S_OK; } //比较指定坐标点(x,y)的颜色 STDMETHODIMP OpInterface::CmpColor(LONG x, LONG y, BSTR color, DOUBLE sim, LONG* ret) { //LONG rx = -1, ry = -1; *ret = 0; if (_bkproc.check_bind()) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), 0, 0, _bkproc.get_widht(), _bkproc.get_height(), _bkproc.get_image_type()); _bkproc.unlock_data(); *ret = _image_proc.CmpColor(x, y, color, sim); } return S_OK; } //查找指定区域内的颜色 STDMETHODIMP OpInterface::FindColor(LONG x1, LONG y1, LONG x2, LONG y2, BSTR color, DOUBLE sim, LONG dir, VARIANT* x, VARIANT* y, LONG* ret) { LONG rx = -1, ry = -1; *ret = 0; x->vt = y->vt = VT_I4; x->lVal = rx; y->lVal = ry; if (_bkproc.check_bind() && _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); } x->lVal = rx; y->lVal = ry; return S_OK; } //查找指定区域内的所有颜色 STDMETHODIMP OpInterface::FindColorEx(LONG x1, LONG y1, LONG x2, LONG y2, BSTR color, DOUBLE sim, LONG dir, BSTR* retstr) { CComBSTR newstr; if (_bkproc.check_bind()&& _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); std::wstring str; _image_proc.FindColoEx(color, sim, dir, str); newstr.Append(str.c_str()); } newstr.CopyTo(retstr); return S_OK; } //根据指定的多点查找颜色坐标 STDMETHODIMP OpInterface::FindMultiColor(LONG x1, LONG y1, LONG x2, LONG y2, BSTR first_color, BSTR offset_color, DOUBLE sim, LONG dir, VARIANT* x, VARIANT* y, LONG* ret) { LONG rx = -1, ry = -1; *ret = 0; x->vt = y->vt = VT_I4; x->lVal = rx; y->lVal = ry; if (_bkproc.check_bind()&& _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); *ret = _image_proc.FindMultiColor(first_color, offset_color, sim, dir, rx, ry); /*if (*ret) { rx += x1; ry += y1; rx -= _bkproc._pbkdisplay->_client_x; ry -= _bkproc._pbkdisplay->_client_y; }*/ } x->lVal = rx; y->lVal = ry; return S_OK; } //根据指定的多点查找所有颜色坐标 STDMETHODIMP OpInterface::FindMultiColorEx(LONG x1, LONG y1, LONG x2, LONG y2, BSTR first_color, BSTR offset_color, DOUBLE sim, LONG dir, BSTR* retstr) { CComBSTR newstr; if (_bkproc.check_bind()&& _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); std::wstring str; _image_proc.FindMultiColorEx(first_color, offset_color, sim, dir, str); newstr.Append(str.c_str()); } newstr.CopyTo(retstr); return S_OK; } //查找指定区域内的图片 STDMETHODIMP OpInterface::FindPic(LONG x1, LONG y1, LONG x2, LONG y2, BSTR files, BSTR delta_color, DOUBLE sim, LONG dir, VARIANT* x, VARIANT* y, LONG* ret) { LONG rx = -1, ry = -1; *ret = 0; x->vt = y->vt = VT_I4; x->lVal = rx; y->lVal = ry; if (_bkproc.check_bind()&& _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); *ret = _image_proc.FindPic(files, delta_color, sim, 0, rx, ry); /*if (*ret) { rx += x1; ry += y1; rx -= _bkproc._pbkdisplay->_client_x; ry -= _bkproc._pbkdisplay->_client_y; }*/ } x->lVal = rx; y->lVal = ry; return S_OK; } //查找多个图片 STDMETHODIMP OpInterface::FindPicEx(LONG x1, LONG y1, LONG x2, LONG y2, BSTR files, BSTR delta_color, DOUBLE sim, LONG dir, BSTR* retstr) { CComBSTR newstr; HRESULT hr; if (_bkproc.check_bind() && _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); std::wstring str; _image_proc.FindPicEx(files, delta_color, sim, dir, str); hr=newstr.Append(str.c_str()); } hr=newstr.CopyTo(retstr); return hr; } //获取(x,y)的颜色 STDMETHODIMP OpInterface::GetColor(LONG x, LONG y, BSTR* ret) { color_t cr; if (_bkproc.check_bind()) { x += _bkproc._pbkdisplay->_client_x; y += _bkproc._pbkdisplay->_client_y; } if (x >= 0 && y >= 0 && x < _bkproc.get_widht() && y < _bkproc.get_height()) { auto p = _bkproc.GetScreenData() + (y*_bkproc.get_widht() * 4 + x * 4); cr = *(color_t*)p; } auto str = cr.tostr(); CComBSTR newstr; newstr.Append(str.c_str()); newstr.CopyTo(ret); return S_OK; } //设置字库文件 STDMETHODIMP OpInterface::SetDict(LONG idx, BSTR file_name, LONG* ret) { *ret = _image_proc.SetDict(idx, file_name); return S_OK; } //使用哪个字库文件进行识别 STDMETHODIMP OpInterface::UseDict(LONG idx, LONG* ret) { *ret = _image_proc.UseDict(idx); return S_OK; } //识别屏幕范围(x1,y1,x2,y2)内符合color_format的字符串,并且相似度为sim,sim取值范围(0.1-1.0), STDMETHODIMP OpInterface::Ocr(LONG x1, LONG y1, LONG x2, LONG y2, BSTR color, DOUBLE sim, BSTR* ret_str) { wstring str; if (_bkproc.check_bind() && _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); _image_proc.OCR(color, sim, str); } CComBSTR newstr; newstr.Append(str.c_str()); newstr.CopyTo(ret_str); return S_OK; } //回识别到的字符串,以及每个字符的坐标. STDMETHODIMP OpInterface::OcrEx(LONG x1, LONG y1, LONG x2, LONG y2, BSTR color, DOUBLE sim, BSTR* ret_str) { wstring str; if (_bkproc.check_bind() && _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); _image_proc.OcrEx(color, sim, str); } CComBSTR newstr; newstr.Append(str.c_str()); newstr.CopyTo(ret_str); return S_OK; } //在屏幕范围(x1,y1,x2,y2)内,查找string(可以是任意个字符串的组合),并返回符合color_format的坐标位置 STDMETHODIMP OpInterface::FindStr(LONG x1, LONG y1, LONG x2, LONG y2, BSTR strs, BSTR color, DOUBLE sim, VARIANT* retx, VARIANT* rety,LONG* ret) { wstring str; retx->vt = rety->vt = VT_INT; retx->lVal = rety->lVal = -1; if (_bkproc.check_bind() && _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); *ret = _image_proc.FindStr(strs, color, sim, retx->lVal, rety->lVal); } return S_OK; } //返回符合color_format的所有坐标位置 STDMETHODIMP OpInterface::FindStrEx(LONG x1, LONG y1, LONG x2, LONG y2, BSTR strs, BSTR color, DOUBLE sim, BSTR* retstr) { wstring str; if (_bkproc.check_bind() && _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); _image_proc.FindStrEx(strs, color, sim, str); } CComBSTR newstr; newstr.Append(str.c_str()); newstr.CopyTo(retstr); return S_OK; } STDMETHODIMP OpInterface::OcrAuto(LONG x1, LONG y1, LONG x2, LONG y2, DOUBLE sim, BSTR* retstr) { wstring str; if (_bkproc.check_bind() && _bkproc.RectConvert(x1, y1, x2, y2)) { _bkproc.lock_data(); _image_proc.input_image(_bkproc.GetScreenData(), _bkproc.get_widht(), _bkproc.get_height(), x1, y1, x2, y2, _bkproc.get_image_type()); _bkproc.unlock_data(); _image_proc.OcrAuto(sim, str); } CComBSTR newstr; newstr.Append(str.c_str()); newstr.CopyTo(retstr); return S_OK; } //从文件中识别图片 STDMETHODIMP OpInterface::OcrFromFile(BSTR file_name, BSTR color_format, DOUBLE sim, BSTR* retstr) { CComBSTR newstr; wstring str; _image_proc.OcrFromFile(file_name, color_format, sim, str); newstr.Append(str.data()); newstr.CopyTo(retstr); return S_OK; } //从文件中识别图片,无需指定颜色 STDMETHODIMP OpInterface::OcrAutoFromFile(BSTR file_name, DOUBLE sim, BSTR* retstr){ CComBSTR newstr; wstring str; _image_proc.OcrAutoFromFile(file_name, sim, str); newstr.Append(str.data()); newstr.CopyTo(retstr); return S_OK; }
[ "784942619@qq.com" ]
784942619@qq.com
a286885882b3c5f2d63fb8b0629b6f8f62bb321b
aa85d0e5cb166680e4264ec9750a8b1d4128fc84
/CS1 and 1080C/Labs/Lab 4/Task 1/main.cpp
eb361797f78c247da1b4b2149cfefc9dd36d4a95
[]
no_license
kavanamw/Data-Structures
78b8e04fa7be6352654ef71e1c69a96e133a406e
7645d0bb4dcc6e6dabe6829311e33d4200d21f14
refs/heads/master
2021-07-17T12:30:13.924987
2017-10-24T18:34:09
2017-10-24T18:34:09
104,476,601
0
0
null
null
null
null
UTF-8
C++
false
false
518
cpp
#include <iostream> #include <math.h> using namespace std; double AngD = 0, AngR = 0; double degreesToRadians(double AngD) { const double PI = atan(1.0)*4.0; AngR = AngD * PI/180; return AngR; } //const double PI = atan(1.0)*4.0; // PI is a global constant int main() { double x; //cout << "Degrees to Radians Test Driver" << endl; cout << "Enter angle in degrees: "; cin >> AngD; degreesToRadians(AngD); cout << "Angle in Radians: " << AngR; return 0; }
[ "kavanamw@mail.uc.edu" ]
kavanamw@mail.uc.edu
1baa8e700dc5d04219f24e9ba48d8d2e91a422f2
4781b4c6755d32726189708aac4a1482de1470b8
/Digital Lab/main.cpp
dc073d808ed7b688810e0c642be05544134bfe26
[]
no_license
CbIpok/repos
f7cc1262c769a3a82131f4a5fcb85da6d8cccaa9
968fbb8027ddd0e60123670eabebe714212c3568
refs/heads/master
2020-04-07T11:34:54.508904
2018-11-29T19:04:24
2018-11-29T19:04:24
158,332,350
0
0
null
null
null
null
UTF-8
C++
false
false
204
cpp
#include <iostream> #include <fstream> #include "DigitalLab.h" using namespace std; int main() { ifstream file("input.txt"); if (!file) { abort(); } DigitalLab d(file); d.scan(); d.print(cout); }
[ "dmitrienkomy@gmail.com" ]
dmitrienkomy@gmail.com
c713b964c9ee388d824be979a6a715c356e8a379
a8f15b0016936013e611771c22c116fba8be1f04
/JuceLibraryCode/modules/juce_graphics/geometry/juce_PathStrokeType.cpp
7d9b0c9fce57f7390aa571c59d9b78beb35ece03
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
fishuyo/loop-juce
7ba126250eb80f4aea823fd416c796c7109e09b9
9a03f12234d335acb387c373117d4984f6d296fc
refs/heads/master
2021-05-27T16:56:16.293042
2012-06-20T02:45:32
2012-06-20T02:45:32
4,293,037
2
0
null
null
null
null
UTF-8
C++
false
false
26,626
cpp
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ PathStrokeType::PathStrokeType (const float strokeThickness, const JointStyle jointStyle_, const EndCapStyle endStyle_) noexcept : thickness (strokeThickness), jointStyle (jointStyle_), endStyle (endStyle_) { } PathStrokeType::PathStrokeType (const PathStrokeType& other) noexcept : thickness (other.thickness), jointStyle (other.jointStyle), endStyle (other.endStyle) { } PathStrokeType& PathStrokeType::operator= (const PathStrokeType& other) noexcept { thickness = other.thickness; jointStyle = other.jointStyle; endStyle = other.endStyle; return *this; } PathStrokeType::~PathStrokeType() noexcept { } bool PathStrokeType::operator== (const PathStrokeType& other) const noexcept { return thickness == other.thickness && jointStyle == other.jointStyle && endStyle == other.endStyle; } bool PathStrokeType::operator!= (const PathStrokeType& other) const noexcept { return ! operator== (other); } //============================================================================== namespace PathStrokeHelpers { bool lineIntersection (const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4, float& intersectionX, float& intersectionY, float& distanceBeyondLine1EndSquared) noexcept { if (x2 != x3 || y2 != y3) { const float dx1 = x2 - x1; const float dy1 = y2 - y1; const float dx2 = x4 - x3; const float dy2 = y4 - y3; const float divisor = dx1 * dy2 - dx2 * dy1; if (divisor == 0) { if (! ((dx1 == 0 && dy1 == 0) || (dx2 == 0 && dy2 == 0))) { if (dy1 == 0 && dy2 != 0) { const float along = (y1 - y3) / dy2; intersectionX = x3 + along * dx2; intersectionY = y1; distanceBeyondLine1EndSquared = intersectionX - x2; distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared; if ((x2 > x1) == (intersectionX < x2)) distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared; return along >= 0 && along <= 1.0f; } else if (dy2 == 0 && dy1 != 0) { const float along = (y3 - y1) / dy1; intersectionX = x1 + along * dx1; intersectionY = y3; distanceBeyondLine1EndSquared = (along - 1.0f) * dx1; distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared; if (along < 1.0f) distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared; return along >= 0 && along <= 1.0f; } else if (dx1 == 0 && dx2 != 0) { const float along = (x1 - x3) / dx2; intersectionX = x1; intersectionY = y3 + along * dy2; distanceBeyondLine1EndSquared = intersectionY - y2; distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared; if ((y2 > y1) == (intersectionY < y2)) distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared; return along >= 0 && along <= 1.0f; } else if (dx2 == 0 && dx1 != 0) { const float along = (x3 - x1) / dx1; intersectionX = x3; intersectionY = y1 + along * dy1; distanceBeyondLine1EndSquared = (along - 1.0f) * dy1; distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared; if (along < 1.0f) distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared; return along >= 0 && along <= 1.0f; } } intersectionX = 0.5f * (x2 + x3); intersectionY = 0.5f * (y2 + y3); distanceBeyondLine1EndSquared = 0.0f; return false; } else { const float along1 = ((y1 - y3) * dx2 - (x1 - x3) * dy2) / divisor; intersectionX = x1 + along1 * dx1; intersectionY = y1 + along1 * dy1; if (along1 >= 0 && along1 <= 1.0f) { const float along2 = ((y1 - y3) * dx1 - (x1 - x3) * dy1); if (along2 >= 0 && along2 <= divisor) { distanceBeyondLine1EndSquared = 0.0f; return true; } } distanceBeyondLine1EndSquared = along1 - 1.0f; distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared; distanceBeyondLine1EndSquared *= (dx1 * dx1 + dy1 * dy1); if (along1 < 1.0f) distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared; return false; } } intersectionX = x2; intersectionY = y2; distanceBeyondLine1EndSquared = 0.0f; return true; } void addEdgeAndJoint (Path& destPath, const PathStrokeType::JointStyle style, const float maxMiterExtensionSquared, const float width, const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4, const float midX, const float midY) { if (style == PathStrokeType::beveled || (x3 == x4 && y3 == y4) || (x1 == x2 && y1 == y2)) { destPath.lineTo (x2, y2); destPath.lineTo (x3, y3); } else { float jx, jy, distanceBeyondLine1EndSquared; // if they intersect, use this point.. if (lineIntersection (x1, y1, x2, y2, x3, y3, x4, y4, jx, jy, distanceBeyondLine1EndSquared)) { destPath.lineTo (jx, jy); } else { if (style == PathStrokeType::mitered) { if (distanceBeyondLine1EndSquared < maxMiterExtensionSquared && distanceBeyondLine1EndSquared > 0.0f) { destPath.lineTo (jx, jy); } else { // the end sticks out too far, so just use a blunt joint destPath.lineTo (x2, y2); destPath.lineTo (x3, y3); } } else { // curved joints float angle1 = std::atan2 (x2 - midX, y2 - midY); float angle2 = std::atan2 (x3 - midX, y3 - midY); const float angleIncrement = 0.1f; destPath.lineTo (x2, y2); if (std::abs (angle1 - angle2) > angleIncrement) { if (angle2 > angle1 + float_Pi || (angle2 < angle1 && angle2 >= angle1 - float_Pi)) { if (angle2 > angle1) angle2 -= float_Pi * 2.0f; jassert (angle1 <= angle2 + float_Pi); angle1 -= angleIncrement; while (angle1 > angle2) { destPath.lineTo (midX + width * std::sin (angle1), midY + width * std::cos (angle1)); angle1 -= angleIncrement; } } else { if (angle1 > angle2) angle1 -= float_Pi * 2.0f; jassert (angle1 >= angle2 - float_Pi); angle1 += angleIncrement; while (angle1 < angle2) { destPath.lineTo (midX + width * std::sin (angle1), midY + width * std::cos (angle1)); angle1 += angleIncrement; } } } destPath.lineTo (x3, y3); } } } } void addLineEnd (Path& destPath, const PathStrokeType::EndCapStyle style, const float x1, const float y1, const float x2, const float y2, const float width) { if (style == PathStrokeType::butt) { destPath.lineTo (x2, y2); } else { float offx1, offy1, offx2, offy2; float dx = x2 - x1; float dy = y2 - y1; const float len = juce_hypot (dx, dy); if (len == 0) { offx1 = offx2 = x1; offy1 = offy2 = y1; } else { const float offset = width / len; dx *= offset; dy *= offset; offx1 = x1 + dy; offy1 = y1 - dx; offx2 = x2 + dy; offy2 = y2 - dx; } if (style == PathStrokeType::square) { // sqaure ends destPath.lineTo (offx1, offy1); destPath.lineTo (offx2, offy2); destPath.lineTo (x2, y2); } else { // rounded ends const float midx = (offx1 + offx2) * 0.5f; const float midy = (offy1 + offy2) * 0.5f; destPath.cubicTo (x1 + (offx1 - x1) * 0.55f, y1 + (offy1 - y1) * 0.55f, offx1 + (midx - offx1) * 0.45f, offy1 + (midy - offy1) * 0.45f, midx, midy); destPath.cubicTo (midx + (offx2 - midx) * 0.55f, midy + (offy2 - midy) * 0.55f, offx2 + (x2 - offx2) * 0.45f, offy2 + (y2 - offy2) * 0.45f, x2, y2); } } } struct Arrowhead { float startWidth, startLength; float endWidth, endLength; }; void addArrowhead (Path& destPath, const float x1, const float y1, const float x2, const float y2, const float tipX, const float tipY, const float width, const float arrowheadWidth) { Line<float> line (x1, y1, x2, y2); destPath.lineTo (line.getPointAlongLine (-(arrowheadWidth / 2.0f - width), 0)); destPath.lineTo (tipX, tipY); destPath.lineTo (line.getPointAlongLine (arrowheadWidth - (arrowheadWidth / 2.0f - width), 0)); destPath.lineTo (x2, y2); } struct LineSection { float x1, y1, x2, y2; // original line float lx1, ly1, lx2, ly2; // the left-hand stroke float rx1, ry1, rx2, ry2; // the right-hand stroke }; void shortenSubPath (Array<LineSection>& subPath, float amountAtStart, float amountAtEnd) { while (amountAtEnd > 0 && subPath.size() > 0) { LineSection& l = subPath.getReference (subPath.size() - 1); float dx = l.rx2 - l.rx1; float dy = l.ry2 - l.ry1; const float len = juce_hypot (dx, dy); if (len <= amountAtEnd && subPath.size() > 1) { LineSection& prev = subPath.getReference (subPath.size() - 2); prev.x2 = l.x2; prev.y2 = l.y2; subPath.removeLast(); amountAtEnd -= len; } else { const float prop = jmin (0.9999f, amountAtEnd / len); dx *= prop; dy *= prop; l.rx1 += dx; l.ry1 += dy; l.lx2 += dx; l.ly2 += dy; break; } } while (amountAtStart > 0 && subPath.size() > 0) { LineSection& l = subPath.getReference (0); float dx = l.rx2 - l.rx1; float dy = l.ry2 - l.ry1; const float len = juce_hypot (dx, dy); if (len <= amountAtStart && subPath.size() > 1) { LineSection& next = subPath.getReference (1); next.x1 = l.x1; next.y1 = l.y1; subPath.remove (0); amountAtStart -= len; } else { const float prop = jmin (0.9999f, amountAtStart / len); dx *= prop; dy *= prop; l.rx2 -= dx; l.ry2 -= dy; l.lx1 -= dx; l.ly1 -= dy; break; } } } void addSubPath (Path& destPath, Array<LineSection>& subPath, const bool isClosed, const float width, const float maxMiterExtensionSquared, const PathStrokeType::JointStyle jointStyle, const PathStrokeType::EndCapStyle endStyle, const Arrowhead* const arrowhead) { jassert (subPath.size() > 0); if (arrowhead != nullptr) shortenSubPath (subPath, arrowhead->startLength, arrowhead->endLength); const LineSection& firstLine = subPath.getReference (0); float lastX1 = firstLine.lx1; float lastY1 = firstLine.ly1; float lastX2 = firstLine.lx2; float lastY2 = firstLine.ly2; if (isClosed) { destPath.startNewSubPath (lastX1, lastY1); } else { destPath.startNewSubPath (firstLine.rx2, firstLine.ry2); if (arrowhead != nullptr) addArrowhead (destPath, firstLine.rx2, firstLine.ry2, lastX1, lastY1, firstLine.x1, firstLine.y1, width, arrowhead->startWidth); else addLineEnd (destPath, endStyle, firstLine.rx2, firstLine.ry2, lastX1, lastY1, width); } int i; for (i = 1; i < subPath.size(); ++i) { const LineSection& l = subPath.getReference (i); addEdgeAndJoint (destPath, jointStyle, maxMiterExtensionSquared, width, lastX1, lastY1, lastX2, lastY2, l.lx1, l.ly1, l.lx2, l.ly2, l.x1, l.y1); lastX1 = l.lx1; lastY1 = l.ly1; lastX2 = l.lx2; lastY2 = l.ly2; } const LineSection& lastLine = subPath.getReference (subPath.size() - 1); if (isClosed) { const LineSection& l = subPath.getReference (0); addEdgeAndJoint (destPath, jointStyle, maxMiterExtensionSquared, width, lastX1, lastY1, lastX2, lastY2, l.lx1, l.ly1, l.lx2, l.ly2, l.x1, l.y1); destPath.closeSubPath(); destPath.startNewSubPath (lastLine.rx1, lastLine.ry1); } else { destPath.lineTo (lastX2, lastY2); if (arrowhead != nullptr) addArrowhead (destPath, lastX2, lastY2, lastLine.rx1, lastLine.ry1, lastLine.x2, lastLine.y2, width, arrowhead->endWidth); else addLineEnd (destPath, endStyle, lastX2, lastY2, lastLine.rx1, lastLine.ry1, width); } lastX1 = lastLine.rx1; lastY1 = lastLine.ry1; lastX2 = lastLine.rx2; lastY2 = lastLine.ry2; for (i = subPath.size() - 1; --i >= 0;) { const LineSection& l = subPath.getReference (i); addEdgeAndJoint (destPath, jointStyle, maxMiterExtensionSquared, width, lastX1, lastY1, lastX2, lastY2, l.rx1, l.ry1, l.rx2, l.ry2, l.x2, l.y2); lastX1 = l.rx1; lastY1 = l.ry1; lastX2 = l.rx2; lastY2 = l.ry2; } if (isClosed) { addEdgeAndJoint (destPath, jointStyle, maxMiterExtensionSquared, width, lastX1, lastY1, lastX2, lastY2, lastLine.rx1, lastLine.ry1, lastLine.rx2, lastLine.ry2, lastLine.x2, lastLine.y2); } else { // do the last line destPath.lineTo (lastX2, lastY2); } destPath.closeSubPath(); } void createStroke (const float thickness, const PathStrokeType::JointStyle jointStyle, const PathStrokeType::EndCapStyle endStyle, Path& destPath, const Path& source, const AffineTransform& transform, const float extraAccuracy, const Arrowhead* const arrowhead) { jassert (extraAccuracy > 0); if (thickness <= 0) { destPath.clear(); return; } const Path* sourcePath = &source; Path temp; if (sourcePath == &destPath) { destPath.swapWithPath (temp); sourcePath = &temp; } else { destPath.clear(); } destPath.setUsingNonZeroWinding (true); const float maxMiterExtensionSquared = 9.0f * thickness * thickness; const float width = 0.5f * thickness; // Iterate the path, creating a list of the // left/right-hand lines along either side of it... PathFlatteningIterator it (*sourcePath, transform, PathFlatteningIterator::defaultTolerance / extraAccuracy); Array <LineSection> subPath; subPath.ensureStorageAllocated (512); LineSection l; l.x1 = 0; l.y1 = 0; const float minSegmentLength = 0.0001f; while (it.next()) { if (it.subPathIndex == 0) { if (subPath.size() > 0) { addSubPath (destPath, subPath, false, width, maxMiterExtensionSquared, jointStyle, endStyle, arrowhead); subPath.clearQuick(); } l.x1 = it.x1; l.y1 = it.y1; } l.x2 = it.x2; l.y2 = it.y2; float dx = l.x2 - l.x1; float dy = l.y2 - l.y1; const float hypotSquared = dx*dx + dy*dy; if (it.closesSubPath || hypotSquared > minSegmentLength || it.isLastInSubpath()) { const float len = std::sqrt (hypotSquared); if (len == 0) { l.rx1 = l.rx2 = l.lx1 = l.lx2 = l.x1; l.ry1 = l.ry2 = l.ly1 = l.ly2 = l.y1; } else { const float offset = width / len; dx *= offset; dy *= offset; l.rx2 = l.x1 - dy; l.ry2 = l.y1 + dx; l.lx1 = l.x1 + dy; l.ly1 = l.y1 - dx; l.lx2 = l.x2 + dy; l.ly2 = l.y2 - dx; l.rx1 = l.x2 - dy; l.ry1 = l.y2 + dx; } subPath.add (l); if (it.closesSubPath) { addSubPath (destPath, subPath, true, width, maxMiterExtensionSquared, jointStyle, endStyle, arrowhead); subPath.clearQuick(); } else { l.x1 = it.x2; l.y1 = it.y2; } } } if (subPath.size() > 0) addSubPath (destPath, subPath, false, width, maxMiterExtensionSquared, jointStyle, endStyle, arrowhead); } } void PathStrokeType::createStrokedPath (Path& destPath, const Path& sourcePath, const AffineTransform& transform, const float extraAccuracy) const { PathStrokeHelpers::createStroke (thickness, jointStyle, endStyle, destPath, sourcePath, transform, extraAccuracy, 0); } void PathStrokeType::createDashedStroke (Path& destPath, const Path& sourcePath, const float* dashLengths, int numDashLengths, const AffineTransform& transform, const float extraAccuracy) const { jassert (extraAccuracy > 0); if (thickness <= 0) return; // this should really be an even number.. jassert ((numDashLengths & 1) == 0); Path newDestPath; PathFlatteningIterator it (sourcePath, transform, PathFlatteningIterator::defaultTolerance / extraAccuracy); bool first = true; int dashNum = 0; float pos = 0.0f, lineLen = 0.0f, lineEndPos = 0.0f; float dx = 0.0f, dy = 0.0f; for (;;) { const bool isSolid = ((dashNum & 1) == 0); const float dashLen = dashLengths [dashNum++ % numDashLengths]; jassert (dashLen > 0); // must be a positive increment! if (dashLen <= 0) break; pos += dashLen; while (pos > lineEndPos) { if (! it.next()) { if (isSolid && ! first) newDestPath.lineTo (it.x2, it.y2); createStrokedPath (destPath, newDestPath, AffineTransform::identity, extraAccuracy); return; } if (isSolid && ! first) newDestPath.lineTo (it.x1, it.y1); else newDestPath.startNewSubPath (it.x1, it.y1); dx = it.x2 - it.x1; dy = it.y2 - it.y1; lineLen = juce_hypot (dx, dy); lineEndPos += lineLen; first = it.closesSubPath; } const float alpha = (pos - (lineEndPos - lineLen)) / lineLen; if (isSolid) newDestPath.lineTo (it.x1 + dx * alpha, it.y1 + dy * alpha); else newDestPath.startNewSubPath (it.x1 + dx * alpha, it.y1 + dy * alpha); } } void PathStrokeType::createStrokeWithArrowheads (Path& destPath, const Path& sourcePath, const float arrowheadStartWidth, const float arrowheadStartLength, const float arrowheadEndWidth, const float arrowheadEndLength, const AffineTransform& transform, const float extraAccuracy) const { PathStrokeHelpers::Arrowhead head; head.startWidth = arrowheadStartWidth; head.startLength = arrowheadStartLength; head.endWidth = arrowheadEndWidth; head.endLength = arrowheadEndLength; PathStrokeHelpers::createStroke (thickness, jointStyle, endStyle, destPath, sourcePath, transform, extraAccuracy, &head); }
[ "fishuyo@gmail.com" ]
fishuyo@gmail.com
24d7549a43b8060a4bc58dea194a62c132bf5475
46d4712c82816290417d611a75b604d51b046ecc
/Samples/Win7Samples/dataaccess/oledb/tablecopy/step3.cpp
9380e02fb657a095904805f2ef2cf90a9d570cd5
[ "MIT" ]
permissive
ennoherr/Windows-classic-samples
00edd65e4808c21ca73def0a9bb2af9fa78b4f77
a26f029a1385c7bea1c500b7f182d41fb6bcf571
refs/heads/master
2022-12-09T20:11:56.456977
2022-12-04T16:46:55
2022-12-04T16:46:55
156,835,248
1
0
NOASSERTION
2022-12-04T16:46:55
2018-11-09T08:50:41
null
UTF-8
C++
false
false
16,946
cpp
//----------------------------------------------------------------------------- // Microsoft OLE DB TABLECOPY Sample // Copyright (C) 1995-2000 Microsoft Corporation // // @doc // // @module STEP3.CPP // //----------------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////// // Includes // ///////////////////////////////////////////////////////////////////// #include "wizard.h" #include "common.h" #include "Tablecopy.h" #include "Table.h" ///////////////////////////////////////////////////////////////////// // CS3Dialog::CS3Dialog // ///////////////////////////////////////////////////////////////////// CS3Dialog::CS3Dialog(HWND hWnd, HINSTANCE hInst, CTableCopy* pCTableCopy) : CDialogBase(hWnd, hInst) { ASSERT(pCTableCopy); m_pCTableCopy = pCTableCopy; } ///////////////////////////////////////////////////////////////////// // CS3Dialog::~CS3Dialog // ///////////////////////////////////////////////////////////////////// CS3Dialog::~CS3Dialog() { } ///////////////////////////////////////////////////////////////////////////// // ULONG CS3Dialog::Display // ///////////////////////////////////////////////////////////////////////////// INT_PTR CS3Dialog::Display() { //Create a modal dialog box return DialogBoxParam(m_hInst, MAKEINTRESOURCE(IDD_TO_INFO), NULL, (DLGPROC)DlgProc, (LPARAM)this); } ///////////////////////////////////////////////////////////////////// // CS3Dialog::DlgProc // ///////////////////////////////////////////////////////////////////// BOOL WINAPI CS3Dialog::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static WCHAR wszBuffer[MAX_NAME_LEN+1]; switch(msg) { case WM_INITDIALOG: { Busy(); //Store the "this" pointer, since this is a static method CS3Dialog* pThis = (CS3Dialog*)lParam; SetWindowLongPtrA(hWnd, GWLP_USERDATA, (LONG_PTR)pThis); //On INIT we know we have a valid hWnd to store CenterDialog(hWnd); pThis->m_hWnd = hWnd; //Init all controls to the default values pThis->InitControls(); //Limit the length of User Entered TableName SendDlgItemMessage(hWnd, IDE_TO_TABLE, EM_LIMITTEXT, (WPARAM)MAX_NAME_LEN-1, 0L); pThis->RefreshControls(); pThis->m_pCTableCopy->m_pCWizard->DestroyPrevStep(WIZ_STEP3); return HANDLED_MSG; } case WM_COMMAND: { //Obtain the "this" pointer CS3Dialog* pThis = (CS3Dialog*)GetWindowLongPtrA(hWnd, GWLP_USERDATA); CTable *pCFromTable = pThis->m_pCTableCopy->m_pCFromTable; CTable *pCToTable = pThis->m_pCTableCopy->m_pCToTable; CDataSource *pCToDataSource = pCToTable->m_pCDataSource; CDataSource *pCFromDataSource = pCFromTable->m_pCDataSource; // All buttons are handled the same way switch(GET_WM_COMMAND_ID(wParam, lParam)) { case IDB_TO_CONNECT: { //kill implicit connection pCToDataSource->Disconnect(); //on connect get whatever is now listed in the drop down LRESULT iSel = 0; if((iSel = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETCURSEL, 0, 0L)) != CB_ERR) { //Since we have the CBS_SORT turned on, the order in the Combo Box does //not match our array, so we pass the array index (lParam) as the item data LRESULT lParam = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETITEMDATA, iSel, 0L); pCFromTable->m_pCDataSource->m_pwszProviderName = pCFromDataSource->m_rgProviderInfo[lParam].wszName; /* if((lParam < (LONG)pCToDataSource->m_cProviderInfo) && (wcscmp(pCFromDataSource->m_rgProviderInfo[lParam].wszName, pCFromDataSource->m_pwszProviderName)!=0)) { //Clear Table/Column List Views SendMessage(GetDlgItem(hWnd, IDL_TABLES), TVM_DELETEITEM, (WPARAM)0, (LPARAM)TVI_ROOT); SendMessage(GetDlgItem(hWnd, IDL_COLUMNS), LVM_DELETEALLITEMS, (WPARAM)0, (LPARAM)0); //Clear Table info memset(&pCToTable->m_TableInfo, 0, sizeof(TABLEINFO)); pCToTable->m_wszQualTableName[0] = EOL; //Disconnect from the DataSource and Update controls pCToTable->m_pCDataSource->Disconnect(); } */ } else { //The user must have typed in a Provider Name directly //This may not map to a provider in the list, so assume the name is a ProgID/CLSID wSendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), WM_GETTEXT, MAX_NAME_LEN, wszBuffer); pCToTable->m_pCDataSource->m_pwszProviderName = wszBuffer; } Busy(); if(pThis->Connect()) { Busy(); pThis->RefreshControls(); SetFocus(GetDlgItem(hWnd, IDE_TO_TABLE)); SendMessage(GetDlgItem(hWnd, IDE_TO_TABLE), EM_SETSEL, 0, -1); //Highlight TableName } return HANDLED_MSG; } case IDOK: { //Get the TableName Busy(); wSendMessage(GetDlgItem(hWnd, IDE_TO_TABLE), WM_GETTEXT, MAX_NAME_LEN-1, pCToTable->m_TableInfo.wszTableName); //If the TableNames are the same (ignoring case) and the //DataSource is the same then the copy is worthless (a no-op) if(_wcsicmp(pCToTable->m_TableInfo.wszTableName, pCFromTable->m_TableInfo.wszTableName)==0 && pCToDataSource->IsEqual(pCFromDataSource)) { //Need to enter a different table name from the source wMessageBox(hWnd, MB_TASKMODAL | MB_ICONEXCLAMATION | MB_OK, wsz_ERROR, wsz_SAME_TABLE_NAME, pCToDataSource->m_pwszTableTerm); SetFocus(GetDlgItem(hWnd, IDE_TO_TABLE)); SendMessage(GetDlgItem(hWnd, IDE_TO_TABLE), EM_SETSEL, 0, -1); //Highlight TableName return HANDLED_MSG; } StringCchCopyW(pCToTable->m_wszQualTableName, sizeof(pCToTable->m_wszQualTableName)/sizeof(WCHAR), pCToTable->m_TableInfo.wszTableName); pThis->m_pCTableCopy->m_pCWizard->DisplayStep(WIZ_STEP4); return HANDLED_MSG; } case IDB_PREV: //Get the TableName Busy(); wSendMessage(GetDlgItem(hWnd, IDE_TO_TABLE), WM_GETTEXT, MAX_NAME_LEN-1, pCToTable->m_TableInfo.wszTableName); StringCchCopyW(pCToTable->m_wszQualTableName, sizeof(pCToTable->m_wszQualTableName)/sizeof(WCHAR), pCToTable->m_TableInfo.wszTableName); pThis->m_pCTableCopy->m_pCWizard->DisplayStep(WIZ_STEP2); return HANDLED_MSG; case IDCANCEL: Busy(); EndDialog(hWnd, GET_WM_COMMAND_ID(wParam, lParam)); return HANDLED_MSG; } // Now look for notification messages switch(GET_WM_COMMAND_CMD(wParam, lParam)) { case LBN_SELCHANGE: { /* //A Provider Change requires a refresh if(IDC_PROVIDER_NAME == GET_WM_COMMAND_ID(wParam, lParam)) { //Get new selection Busy(); LONG iSel = 0; if((iSel = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETCURSEL, 0, 0L)) != CB_ERR) { //Since we have the CBS_SORT turned on, the order in the Combo Box does //not match our array, so we pass the array index (lParam) as the item data LONG lParam = SendMessage(GetDlgItem(pThis->m_hWnd, IDC_PROVIDER_NAME), CB_GETITEMDATA, iSel, 0L); if((lParam < (LONG)pCToDataSource->m_cProviderInfo) && (wcscmp(pCToDataSource->m_rgProviderInfo[lParam].wszName, pCToDataSource->m_pwszProviderName)!=0)) { pCToDataSource->Disconnect(); } } } pThis->RefreshControls(); */ } case EN_CHANGE: { pThis->EnableTable(); return HANDLED_MSG; } } } } return UNHANDLED_MSG; } ///////////////////////////////////////////////////////////////////////////// // BOOL CS3Dialog::InitControls // ///////////////////////////////////////////////////////////////////////////// BOOL CS3Dialog::InitControls() { //Initialize the Provider List (if not done so already) CDataSource* pCDataSource = m_pCTableCopy->m_pCToTable->m_pCDataSource; CDataSource* pCFromDataSource = m_pCTableCopy->m_pCFromTable->m_pCDataSource; if(pCDataSource->m_rgProviderInfo == NULL) pCDataSource->GetProviders(); WCHAR wszBuffer[MAX_NAME_LEN*2]; HWND hWndProv = GetDlgItem(m_hWnd, IDC_PROVIDER_NAME); //Fill out the provider name combo box. for(ULONG i=0; i<pCDataSource->m_cProviderInfo; i++) { //Add the name to the list //Since we have the CBS_SORT turned on, the order in the Combo Box does //not match our array, so we pass the array index (lParam) as the item data StringCchPrintfW(wszBuffer, sizeof(wszBuffer)/sizeof(WCHAR), wsz_PROVIDER_INFO_, pCDataSource->m_rgProviderInfo[i].wszName); LRESULT iIndex = wSendMessage(hWndProv, CB_ADDSTRING, (WPARAM)0, wszBuffer); SendMessage(hWndProv, CB_SETITEMDATA, (WPARAM)iIndex, (LPARAM)i); } //By default, it selects the same provider chossen in Step1 if(pCDataSource->m_pwszProviderName == NULL) pCDataSource->m_pwszProviderName = pCFromDataSource->m_pwszProviderName; //Try and select the previous selected Provider if(CB_ERR == wSendMessage(hWndProv, CB_SELECTSTRING, 0, pCDataSource->m_pwszProviderName)) { //If not found, just select the first one SendMessage(hWndProv, CB_SETCURSEL, 0, 0); } //By default, try and Connect to the same DataSource as in Step1 //if using the same provider as in Step1 if(!m_pCTableCopy->m_pCToTable->IsConnected() && wcscmp(pCDataSource->m_pwszProviderName, pCFromDataSource->m_pwszProviderName)==0) { //The Provider must support more than 1 active session as well to do //this functionality by default... if(pCFromDataSource->m_ulActiveSessions==0 || pCFromDataSource->m_ulActiveSessions>=2) Connect(pCFromDataSource); } // Enable Connect button only if there are providers installed. EnableWindow(GetDlgItem(m_hWnd, IDB_FROM_CONNECT), SendMessage(hWndProv, CB_GETCURSEL, 0, 0L) != CB_ERR); // Set the "Source" info //CONNECT_STRING wSetDlgItemText(m_hWnd, IDT_FROM_CONNECT, wsz_CONNECT_STRING_, pCFromDataSource->m_pwszProviderName, pCFromDataSource->m_pwszDataSource, pCFromDataSource->m_pwszDBMS, pCFromDataSource->m_pwszDBMSVer, pCFromDataSource->m_pwszProviderFileName, pCFromDataSource->m_pwszProviderVer); //TABLE wSetDlgItemText(m_hWnd, IDE_FROM_TABLE, m_pCTableCopy->m_pCFromTable->m_wszQualTableName); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // BOOL CS3Dialog::RefreshControls // ///////////////////////////////////////////////////////////////////////////// BOOL CS3Dialog::RefreshControls() { BOOL fConnected; CTable* pCToTable = m_pCTableCopy->m_pCToTable; CTable* pCFromTable = m_pCTableCopy->m_pCFromTable; CDataSource* pCDataSource = pCToTable->m_pCDataSource; // Must have a connection to edit other controls fConnected = pCToTable->IsConnected(); //Enable certain dialog controls, only if connected EnableWindow(GetDlgItem(m_hWnd, IDE_TO_TABLE), fConnected); EnableWindow(GetDlgItem(m_hWnd, IDT_TARGET), fConnected); EnableWindow(GetDlgItem(m_hWnd, IDT_TOTABLEHELP), fConnected); //Store the selected ProviderName and ProviderDesc LRESULT iSel = 0; if((iSel = SendMessage(GetDlgItem(m_hWnd, IDC_PROVIDER_NAME), CB_GETCURSEL, 0, 0L)) != CB_ERR) { //Since we have the CBS_SORT turned on, the order in the Combo Box does //not match our array, so we pass the array index (lParam) as the item data LRESULT lParam = SendMessage(GetDlgItem(m_hWnd, IDC_PROVIDER_NAME), CB_GETITEMDATA, iSel, 0L); ASSERT(lParam < (LONG)pCDataSource->m_cProviderInfo); pCDataSource->m_pwszProviderName = pCDataSource->m_rgProviderInfo[lParam].wszName; pCDataSource->m_pwszProviderParseName = pCDataSource->m_rgProviderInfo[lParam].wszParseName; } // Show user the connection string, and enable Next that requires connection if(fConnected) { //CONNECTSTATUS SetDlgItemText(m_hWnd, IDT_CONNECTSTATUS, ""); //CONNECT_STRING wSetDlgItemText(m_hWnd, IDT_TO_CONNECT, wsz_CONNECT_STRING_, pCDataSource->m_pwszProviderName, pCDataSource->m_pwszDataSource, pCDataSource->m_pwszDBMS, pCDataSource->m_pwszDBMSVer, pCDataSource->m_pwszProviderFileName, pCDataSource->m_pwszProviderVer); //TABLEHELPMSG wSetDlgItemText(m_hWnd, IDT_TOTABLEHELP, wsz_TOTABLEHELP_, pCDataSource->m_pwszTableTerm); } else { //CONNECTSTATUS wSetDlgItemText(m_hWnd, IDT_CONNECTSTATUS, wsz_NOT_CONNECTED); //CONNECT_STRING wSetDlgItemText(m_hWnd, IDT_TO_CONNECT, L""); } // If there is already a Table from previous selections, just use that one wSetDlgItemText(m_hWnd, IDE_TO_TABLE, pCToTable->m_TableInfo.wszTableName[0] ? pCToTable->m_TableInfo.wszTableName : pCFromTable->m_TableInfo.wszTableName); // Determine if there is enough information to move on return EnableTable(); } ///////////////////////////////////////////////////////////////////////////// // BOOL CS3Dialog::Connect // ///////////////////////////////////////////////////////////////////////////// BOOL CS3Dialog::Connect(CDataSource* pCDataSource) { CDataSource *pCToDataSource = m_pCTableCopy->m_pCToTable->m_pCDataSource; CDataSource *pCFromDataSource = m_pCTableCopy->m_pCFromTable->m_pCDataSource; BOOL fReturn = FALSE; //Connect to the DataSource HRESULT hr = m_pCTableCopy->m_pCToTable->Connect(m_hWnd, pCDataSource); //If Connected if SUCCEEDED(hr) { // Verify we can use this data source // Just give a warning to the user, since the DataSource may actually // be updatable, but it is returning the wrong property value. if(pCToDataSource->m_fReadOnly) { wMessageBox(m_hWnd, MB_TASKMODAL | MB_ICONEXCLAMATION | MB_OK, wsz_WARNING, wsz_READONLY_DATASOURCE_, pCToDataSource->m_pwszDataSource); } //See if this is a similar DSN than the Source //If DSN's are not similar, then we need to translate m_pCTableCopy->m_fTranslate = !pCToDataSource->IsSimilar(pCFromDataSource); fReturn = TRUE; } return TRUE; } ///////////////////////////////////////////////////////////////////////////// // BOOL CS3Dialog::EnableTable // ///////////////////////////////////////////////////////////////////////////// BOOL CS3Dialog::EnableTable() { BOOL fConnected = m_pCTableCopy->m_pCToTable->IsConnected(); EnableWindow(GetDlgItem(m_hWnd, IDOK), fConnected && SendDlgItemMessage(m_hWnd, IDE_TO_TABLE, WM_GETTEXTLENGTH, 0, 0L)); return TRUE; }
[ "chrisg@microsoft.com" ]
chrisg@microsoft.com
9a5bf85140f319556caf387f0f7b66a4bb31f872
64c6639c1fececb0b9c47cc450635780981a6d6f
/orb/MegaBrite.cpp
f72c5e18cda946b206d741abd4960d15bafc0b44
[ "MIT" ]
permissive
Turbolaterne/orb
33af4a2b5ece7e5f42f2552abb155a1e014b9fb2
8c89894dc1eabfd99743f16d35786ff354dcc4e5
refs/heads/master
2021-01-22T11:15:20.690535
2012-08-19T22:55:34
2012-08-19T22:55:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,604
cpp
#include "MegaBrite.h" #include "ArduinoUno.h" #include <binary.h> #define LED_FADE_STEP_SLOW 2 #define LED_FADE_STEP_FAST 32 #define FADE_UP 1 #define FADE_DOWN -1 #define CLOCK_PIN 13U #define ENABLE_PIN 10U #define LATCH_PIN 9U #define DATA_PIN 11U MegaBrite::MegaBrite() { for (int i =0; i < 3; i++) { pulse[i] = false; toggle[i] = false; step[i] = LED_FADE_STEP_SLOW; value[i] = 0; direction[i] = FADE_UP; } previousRed = -1; previousGreen = -1; previousBlue = -1; } /* Does all the hardware related outside of the constructor otherwise this generates an exception during compile time because of the mocks */ void MegaBrite::setup() { ArduinoUno_SetPinToOutputMode(CLOCK_PIN); ArduinoUno_SetPinToOutputMode(ENABLE_PIN); ArduinoUno_SetPinToOutputMode(LATCH_PIN); ArduinoUno_SetPinToOutputMode(DATA_PIN); ArduinoUno_SetSPIControlRegister((1<<SPE)|(1<<MSTR)|(0<<SPR1)|(0<<SPR0)); ArduinoUno_DigitalWrite(LATCH_PIN, LOW); ArduinoUno_DigitalWrite(ENABLE_PIN, LOW); setControlRegister(); setPWMRegister(); } void MegaBrite::pulseOn(unsigned short led, unsigned short speed) { if (speed == SLOW) { step[led] = LED_FADE_STEP_SLOW; } else { step[led] = LED_FADE_STEP_FAST; } toggleOff(led); pulse[led] = true; } void MegaBrite::pulseOff(unsigned short led) { pulse[led] = false; } void MegaBrite::toggleOn(unsigned short led) { pulseOff(led); toggle[led] = true; } void MegaBrite::toggleOff(unsigned short led) { toggle[led] = false; } void MegaBrite::on(unsigned short led) { pulseOff(led); toggleOff(led); value[led] = 1023; } void MegaBrite::off(unsigned short led) { pulseOff(led); toggleOff(led); value[led] = 0; } void MegaBrite::animate() { bool toggled = false; static long lastToggled = 0; for (int i =0; i < 3; i++) { if (pulse[i]) { value[i] += (direction[i] * step[i]); if (value[i] >= 1024) { value[i] = 1023; direction[i] = FADE_DOWN; } if (value[i] <= 0) { value[i] = 0; direction[i] = FADE_UP; } } } if (ArduinoUno_Millis() - lastToggled > 1000) { for (int i =0; i < 3; i++) { if (toggle[i]) { if (value[i] == 0 && !toggled) { value[i] = 1023; toggled = true; lastToggled = ArduinoUno_Millis(); } else { value[i] = 0; } } } } setPWMRegister(); } void MegaBrite::setPWMRegister() { if (previousRed != value[RED] || previousGreen != value[GREEN] || previousBlue != value[BLUE]) { // Write to the PWM registers sendPacket(0, value[RED], value[GREEN], value[BLUE]); ArduinoUno_DelayMicroseconds(15); ArduinoUno_DigitalWrite(LATCH_PIN, HIGH); // LATCH_PIN data into registers ArduinoUno_DelayMicroseconds(15); ArduinoUno_DigitalWrite(LATCH_PIN, LOW); previousRed = value[RED]; previousGreen = value[GREEN]; previousBlue = value[BLUE]; } } /* Send command to set control register. http://docs.macetech.com/doku.php/megabrite */ void MegaBrite::setControlRegister() { sendPacket(1, B1111111, B1100100, B1100100); ArduinoUno_DelayMicroseconds(15); ArduinoUno_DigitalWrite(LATCH_PIN, HIGH); // LATCH_PIN data into registers ArduinoUno_DelayMicroseconds(15); ArduinoUno_DigitalWrite(LATCH_PIN, LOW); } /* |---------------------------\ |----------------------------| |---------------------------| |----------------------------| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 P00 P01 P02 P03 P04 P05 P06 P07 P08 P09 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 P24 P25 P26 P27 P28 P29 0 X GREEN RED BLUE D00 D01 D02 D03 D04 D05 D06 Clk Clk X D10 D11 D12 D13 D14 D15 D16 X X X D20 D21 D22 D23 D24 D25 D26 X ATB ATB 1 X */ void MegaBrite::sendPacket(int mode, int red, int green, int blue) { // 0100 0110 ArduinoUno_SetSPIDataRegister(mode << 6 | blue >> 4); while(!(ArduinoUno_GetSPIStatusRegister() & (1<<SPIF))); // 0100 0001 ArduinoUno_SetSPIDataRegister(blue << 4 | red >> 6); while(!(ArduinoUno_GetSPIStatusRegister() & (1<<SPIF))); // 1111 1100 ArduinoUno_SetSPIDataRegister(red << 2 | green >> 8); while(!(ArduinoUno_GetSPIStatusRegister() & (1<<SPIF))); // 0110 0100 ArduinoUno_SetSPIDataRegister(green); while(!(ArduinoUno_GetSPIStatusRegister() & (1<<SPIF))); }
[ "georges@ternarylabs.com" ]
georges@ternarylabs.com
bc3f81d0d565cfb95eb325ae20bd6b6459e950a4
4c23be1a0ca76f68e7146f7d098e26c2bbfb2650
/3WeekTutorial/day1/elbow_tri/36/U
4529d8afb7ba0efcbadeb700dffda7a70f48ffcf
[]
no_license
labsandy/OpenFOAM_workspace
a74b473903ddbd34b31dc93917e3719bc051e379
6e0193ad9dabd613acf40d6b3ec4c0536c90aed4
refs/heads/master
2022-02-25T02:36:04.164324
2019-08-23T02:27:16
2019-08-23T02:27:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
26,994
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "36"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 918 ( (0.985047 -0.000706339 0) (0.00534001 2.96624 0) (-0.0227736 0.812266 0) (0.979573 0.00195808 0) (-0.0913483 1.77594 -5.5918e-20) (-0.00708433 2.94855 -2.81303e-18) (0.819765 1.14099 3.70035e-19) (0.328176 0.121499 -1.71182e-20) (0.999918 -0.000248532 0) (0.0728491 0.762638 0) (-0.00687391 0.542473 0) (0.736373 -0.0145055 0) (0.0101906 2.9316 0) (0.00362961 2.79434 0) (-0.000689637 3.19202 7.64604e-19) (-0.0146945 1.82075 -6.84208e-20) (0.386204 0.0311972 1.13123e-18) (0.238534 1.15294 2.79435e-19) (0.964515 0.00666806 0) (-0.00298007 0.622184 0) (0.095278 0.189762 -8.06382e-19) (1.00184 -0.00456915 0) (0.999853 -0.00893701 0) (0.975146 -0.00606761 0) (0.600177 -0.0357158 0) (0.0230527 2.64314 0) (-0.0123175 2.91198 1.04609e-18) (-0.0136499 0.840835 0) (-0.0537354 1.01704 0) (-0.0137592 0.816913 0) (-0.133821 2.56181 0) (-0.103113 1.90693 4.43996e-20) (-0.0476677 1.72448 0) (-0.0221652 2.9876 -1.02094e-22) (-0.0165051 3.0055 2.18607e-18) (0.00230296 3.00061 0) (0.870986 -0.00938085 0) (0.374616 0.917268 2.08597e-19) (0.821831 1.15183 -4.06993e-19) (0.957518 1.00562 4.49246e-19) (0.686793 1.23605 -8.4263e-20) (0.698141 1.20791 4.92565e-19) (0.3601 0.217906 1.67002e-20) (0.342663 0.102711 0) (1.13589 0.514939 0) (0.325872 0.222349 7.61554e-20) (0.299487 0.142211 -7.90285e-20) (0.920355 -0.00697054 0) (1.00025 7.73396e-05 0) (0.999909 0.000313611 0) (1.00369 -0.00729558 0) (1.00091 -0.00095 0) (1.0001 -2.00667e-05 0) (0.0986692 1.82297 -9.00296e-19) (0.0390264 0.921553 0) (0.121164 0.834858 0) (0.0124993 0.88153 0) (0.05158 0.693714 0) (0.016707 2.00918 0) (0.000304437 0.744682 0) (0.0111436 0.560774 0) (-0.00346441 0.743945 0) (-0.0174836 0.551523 0) (0.838967 -0.0147251 0) (0.846001 0.0310265 0) (0.767858 -0.00375067 0) (0.818918 0.0418413 0) (0.700004 -0.0190663 0) (0.0139556 3.00019 1.04727e-18) (0.0111852 3.00589 0) (0.00630314 3.00391 0) (0.0118847 2.99707 1.19416e-23) (0.00827731 2.95874 -1.55649e-18) (0.0122056 2.98297 0) (0.00902913 2.90487 0) (0.021232 2.93138 2.48555e-24) (0.00407801 2.82394 0) (0.0263533 2.91876 0) (-0.00102126 2.74465 0) (0.31038 3.59244 0) (-0.122715 3.6759 0) (0.152729 3.28304 -7.11628e-19) (0.00626027 3.01535 0) (-0.0935737 2.27087 0) (-0.0193893 2.10296 6.74776e-20) (0.00390079 1.86661 -6.98263e-20) (0.46343 0.135141 -3.91429e-19) (0.387892 0.00147685 -3.77941e-19) (0.444704 0.162595 -1.17594e-18) (0.372925 0.0512613 -7.74087e-19) (0.25595 0.981137 0) (0.340057 1.28131 -3.0239e-19) (0.413861 1.18105 5.00765e-19) (0.987975 0.00806097 0) (0.943445 0.00579695 0) (1.00029 0.000674264 0) (1.00254 0.00907141 0) (1.00315 0.00891009 -2.99629e-18) (0.992125 0.0095163 2.26418e-18) (-0.00515625 0.782228 0) (-0.0191917 0.611469 0) (0.0206402 0.87406 0) (-0.0261075 0.799502 0) (-0.00468892 0.62728 0) (0.127364 0.201568 2.49599e-19) (0.177973 0.175419 0) (0.993603 -0.00769663 0) (0.953971 -0.0064737 0) (0.77031 0.05008 0) (0.705718 0.0554278 0) (0.659204 -0.0253607 0) (0.964589 -0.00644625 0) (0.63447 0.0584509 0) (0.462142 -0.0384109 1.65202e-18) (-0.040515 2.86217 8.65417e-19) (0.0337451 2.91415 0) (0.0427807 2.89147 0) (0.00379674 2.701 0) (-0.00882341 2.98629 1.00717e-18) (-0.0143757 2.8948 0) (-0.0110513 2.99184 -3.08864e-18) (-0.0115934 2.92968 1.04953e-18) (0.023133 1.24229 0) (-0.0202691 1.3254 0) (-0.0294838 2.0587 -1.76834e-21) (-0.0647007 1.97273 0) (-0.0261009 1.79026 0) (0.938044 -0.0056071 0) (0.855833 -0.0103365 0) (0.863874 0.00628959 0) (0.949083 -0.00637899 0) (0.883017 -0.00791174 0) (0.499236 1.1186 -2.62219e-19) (0.547093 1.19019 0) (0.335461 0.849556 3.81074e-20) (0.279416 0.714637 0) (0.917885 1.04191 -1.2212e-19) (1.03168 0.841736 2.34421e-19) (0.401504 1.34145 0) (0.548916 1.29586 0) (0.598895 1.22997 0) (0.0928298 0.17245 -3.24257e-19) (0.378455 0.210367 0) (0.34091 0.0977478 2.19162e-19) (0.994168 0.897568 0) (1.05861 0.740206 0) (1.08831 0.673618 -1.6049e-19) (1.1157 0.582943 0) (1.17028 0.370215 4.46723e-20) (0.957139 -0.00724482 0) (0.962541 -0.00820962 0) (0.900505 -0.00723373 0) (0.983879 -0.0081434 0) (0.974331 -0.00809268 0) (0.936416 -0.00651693 0) (1.0002 0.00250522 0) (1.00077 0.00125479 0) (0.999998 0.000778892 0) (0.039607 2.07395 4.94169e-19) (0.147155 1.76678 0) (0.010267 2.19 7.85143e-19) (0.0622576 1.87759 -6.75281e-19) (0.172886 1.13482 -2.27622e-19) (0.0557418 0.998853 0) (0.122489 0.998927 0) (0.0126896 0.834798 0) (0.0312642 0.647884 0) (-0.00791797 2.22941 -1.78428e-21) (0.0284687 2.00244 0) (-0.00917195 2.20888 -9.42975e-20) (0.0154761 2.01154 1.78093e-19) (0.00957175 0.800434 0) (0.0160097 0.766575 0) (0.025956 0.607484 0) (-0.00894664 0.750507 0) (-0.0153351 0.565057 0) (0.935852 0.0132355 0) (0.849852 -0.011256 0) (0.926118 0.00431848 0) (0.842909 -0.0119752 0) (0.81291 0.00099659 0) (0.901454 0.0207383 0) (0.87765 0.0252922 0) (0.789561 -0.00140198 0) (0.0101882 3.06761 -9.88282e-21) (0.0151372 3.05897 0) (0.0123873 2.97031 0) (0.00761085 2.87665 0) (0.901006 3.99114 0) (1.19649 3.3844 9.32183e-19) (0.0831804 3.09677 0) (-0.0158031 2.92145 0) (0.0862741 1.47936 0) (0.0221026 1.94648 0) (-0.0247547 1.77114 0) (-0.0928521 2.51064 4.14841e-20) (-0.0878545 2.40158 0) (-0.132534 2.48338 0) (0.0135006 1.97749 1.26118e-21) (-0.0184446 2.14076 6.15564e-20) (-0.019727 2.12472 7.10553e-20) (0.0163956 1.92329 0) (0.479051 0.110325 5.91589e-19) (0.392746 -0.0109598 -5.81339e-19) (0.228499 1.57515 0) (0.278413 0.725741 -3.43197e-19) (0.180624 1.67203 -1.14499e-18) (0.241955 1.19092 1.14594e-18) (0.902018 0.00628265 0) (0.967251 0.0104136 0) (0.975144 0.00973484 0) (0.923193 0.00610482 0) (-0.0326793 0.771082 0) (-0.0257605 0.784019 0) (-0.0188083 0.588448 0) (0.281682 0.217737 7.00389e-19) (0.235697 0.204146 -8.29789e-19) (0.248952 0.153412 0) (1.08587 0.0850454 3.25675e-20) (1.06911 0.038566 0) (1.00583 0.0410762 0) (0.904574 -0.00411368 0) (0.504 0.0862505 0) (0.554776 0.0607135 -2.64853e-18) (0.410702 -0.0196782 9.98008e-19) (0.0111812 2.97743 8.99914e-19) (-0.032704 2.86204 4.61128e-20) (0.00848326 3.05327 -2.07728e-20) (0.0155842 3.04339 7.77561e-19) (-0.011835 2.99999 3.4422e-20) (-0.0123422 2.95229 -1.38771e-22) (-0.0150222 3.01334 -6.39207e-19) (0.0142103 3.02675 4.4912e-19) (0.00755762 3.03468 -7.31922e-19) (0.933036 0.0015438 0) (0.938464 -0.00185237 0) (0.845863 -0.0101654 0) (0.956709 0.0113138 0) (0.943104 0.0125836 0) (0.882093 0.00606125 0) (0.917676 0.0167444 0) (0.926394 0.0143217 0) (0.838595 0.00370505 0) (0.673734 1.42072 -3.72472e-20) (0.692595 1.53244 0) (0.124376 0.312127 7.80825e-20) (0.197341 0.63099 6.19178e-19) (0.232928 0.684192 -3.60279e-19) (0.218373 0.516905 7.16025e-19) (0.32154 0.795195 1.70459e-18) (0.12043 0.221768 4.01417e-19) (0.422542 0.182007 8.23171e-19) (0.404862 0.204467 2.12472e-19) (0.361581 0.072759 4.08423e-19) (1.16069 0.434772 2.9379e-21) (1.18396 0.237843 -2.04348e-21) (-0.00141404 2.23137 3.18012e-19) (0.05011 1.9356 0) (0.964814 0.0308622 0) (0.941559 0.0179804 0) (0.863753 -0.0164673 0) (0.0125687 3.07475 0) (0.0169723 2.94418 1.39023e-18) (0.0139583 2.95689 0) (0.0057526 2.84972 -1.37965e-18) (0.00907851 3.09124 3.41115e-19) (0.0114877 3.08278 0) (0.71364 1.83104 -1.58648e-19) (1.24088 2.63996 5.38605e-19) (0.698741 2.01018 -1.36571e-18) (0.0226813 2.97719 -7.97324e-19) (0.0413989 3.00047 0) (-0.0382763 2.88044 0) (-0.0116349 2.18632 -6.93369e-21) (-0.0171284 2.1636 -1.34415e-19) (0.0102056 1.99788 -6.51644e-21) (0.262559 1.37589 1.10452e-18) (0.263942 0.513581 -7.56519e-19) (0.0687632 1.99085 8.34432e-19) (0.121307 1.8617 -9.91539e-19) (0.207464 1.513 1.01399e-19) (0.0073133 3.11996 -1.92049e-18) (0.0134511 3.12095 2.11388e-18) (-0.00500779 2.98023 9.52957e-19) (-0.00126654 2.97511 -9.22477e-19) (-0.0180289 2.8776 -9.70624e-19) (0.012644 3.09948 -2.54349e-18) (0.00457016 3.10577 2.58124e-18) (0.244238 0.668466 0) (0.197097 0.636084 -1.30836e-18) (0.0644818 0.209484 5.74495e-19) (0.335668 0.910864 1.19227e-18) (0.186008 0.262923 -1.8375e-18) (1.17001 0.170284 8.4997e-20) (1.18326 0.296297 0) (1.16443 0.117311 -3.35599e-20) (-0.00875268 2.23812 -2.48911e-21) (-0.00563115 2.23652 0) (0.0355738 1.97298 0) (0.309119 1.30037 -3.94805e-19) (0.347843 1.13624 -8.51897e-19) (0.213323 0.368574 1.52119e-18) (1.00642 -0.00975354 0) (1.00773 -0.00781615 5.51518e-19) (0.0439792 1.22998 0) (0.00384707 1.1189 0) (1.00245 0.00331696 1.39801e-21) (1.00327 0.00797691 1.1307e-18) (-0.0827809 2.52206 -5.3086e-20) (-0.0624103 2.53986 0) (0.0423982 3.1743 5.88621e-19) (0.380202 3.5549 0) (1.11741 0.684438 -9.397e-20) (1.01212 0.010817 -2.75038e-21) (1.02074 -0.00914169 0) (1.00162 0.000208068 1.36324e-22) (0.104861 1.36063 0) (0.144425 2.59784 0) (0.0256797 1.32048 0) (-0.00530194 2.63914 8.92461e-20) (-0.026605 2.58858 6.9517e-20) (1.00023 0.0259005 2.53542e-21) (1.06152 0.00485337 0) (1.09777 0.0259355 0) (-0.00881972 1.89225 0) (-0.0347292 2.5751 0) (0.0249567 1.25406 0) (0.282422 1.48076 -1.06366e-19) (1.01145 -0.00909643 0) (1.0097 -0.0130497 0) (1.00229 0.000924241 7.07122e-19) (1.00549 -0.00498039 -8.32226e-19) (1.00114 -0.000893183 0) (0.0800383 1.59017 0) (0.068525 1.33569 0) (0.0442928 1.50705 0) (0.0253153 1.23226 0) (0.0157293 1.1529 0) (-0.0147254 1.09693 0) (1.03492 -0.00479062 0) (1.01971 0.0149286 -9.66914e-22) (0.782152 1.30401 2.06736e-19) (1.00232 0.000361549 -7.05046e-19) (1.00342 0.00456008 8.41529e-19) (1.00132 0.00213496 0) (1.0114 0.00971257 7.03354e-19) (1.00708 0.00752098 -8.54656e-19) (1.00744 0.0113949 0) (-0.0454876 2.59103 0) (-0.0543688 2.55667 7.72753e-20) (-0.0461132 2.5745 -5.37318e-20) (1.22253 0.261168 7.10211e-19) (1.15553 0.0826094 0) (0.0465146 3.09054 -1.12163e-18) (0.0512064 2.87038 -7.90117e-20) (0.105877 3.20163 1.50395e-18) (0.12419 3.21428 -3.44047e-19) (0.146913 3.26254 0) (0.0228799 3.13802 3.11276e-19) (0.062599 3.16183 1.11775e-18) (0.0629181 3.17944 -5.81339e-19) (0.0274795 3.1288 0) (0.652631 0.309657 0) (0.599295 0.350205 0) (1.09924 0.714767 2.47881e-19) (1.06629 0.851731 -2.72893e-19) (1.16027 0.605495 0) (1.19283 0.533454 0) (1.0159 0.0119886 -1.30801e-18) (1.01479 0.0127794 1.64507e-18) (1.02548 -0.00890203 0) (1.02382 -0.0104246 0) (1.00656 0.00278402 0) (1.01075 0.00407623 0) (1.00447 0.00212104 0) (1.00956 0.00653603 0) (1.00708 0.00519499 0) (1.00452 0.00534828 0) (0.0925084 1.35751 0) (0.0739586 1.34197 0) (0.131873 1.4027 0) (0.127203 1.41141 0) (0.151022 2.62194 0) (0.193641 2.68826 -4.80166e-19) (0.10903 2.6822 0) (0.0847898 2.68299 2.32418e-19) (0.0285615 2.68968 -2.56595e-19) (0.0220966 1.31972 0) (0.0121122 1.25643 0) (0.0339039 1.33825 0) (0.0385396 1.27864 0) (-0.00338835 1.99567 -5.1171e-20) (-0.0273975 2.61563 5.99748e-20) (-0.0140665 2.68239 8.95665e-20) (-0.0248149 2.69006 0) (-0.0322341 2.62133 -1.63164e-19) (-0.0297579 2.61438 -9.68545e-20) (0.00787971 1.99516 3.93555e-20) (-0.0144509 2.42055 -8.04485e-20) (-0.0184808 2.437 -1.01523e-19) (1.01054 0.0369046 1.32453e-18) (1.00732 0.0171376 -1.65009e-18) (1.00429 0.0419414 -1.3525e-18) (0.979762 0.0289035 1.70107e-18) (1.0629 0.00776848 0) (1.04841 -0.00733131 0) (1.08987 0.0347424 0) (1.07358 0.0131965 0) (1.07195 -0.000695027 0) (1.13547 0.0721697 0) (1.11024 0.042068 0) (1.11182 0.0341358 0) (-0.105436 2.46082 -1.08341e-20) (0.00383849 2.16421 0) (-0.0701241 2.33235 0) (-0.0398407 2.59432 3.59343e-20) (-0.0337562 2.6062 -1.55928e-21) (0.0350459 1.68429 7.33988e-20) (0.0377188 1.60143 -7.46787e-20) (0.0401266 1.41161 0) (0.0430424 1.42043 0) (0.043988 1.4231 0) (0.028265 1.27544 0) (0.00749912 1.16837 0) (0.374848 1.50046 1.54372e-19) (0.417337 1.5094 1.09852e-19) (0.605999 2.463 -2.60069e-19) (0.397121 2.56452 7.65179e-19) (0.355586 2.07358 9.45402e-20) (1.02054 -0.00811461 0) (1.01569 -0.00941736 0) (1.0148 -0.0132775 0) (1.00761 -0.000730533 0) (1.00496 -0.000618353 0) (1.00796 -0.00461489 0) (1.00949 -0.00362807 0) (1.01449 -0.00448176 0) (1.02048 0.0156845 1.28472e-18) (1.01776 0.0148122 -1.62887e-18) (1.02109 0.0177655 -1.29528e-18) (1.01895 0.0162906 1.62117e-18) (0.744564 1.34552 0) (0.677088 1.38697 1.54826e-19) (0.85029 1.2227 2.55184e-20) (0.88039 1.19699 -3.38587e-20) (1.1641 2.62258 4.33641e-19) (0.79701 0.110543 6.53097e-19) (1.161 0.0963278 0) (1.19648 0.186171 -5.74061e-19) (1.17754 0.147499 -2.39287e-20) (1.01341 0.148445 0) (0.0886244 3.02604 4.40863e-19) (0.0895015 2.90561 -1.34391e-18) (0.0380911 2.36443 8.53263e-19) (0.135117 -0.0588251 -4.12346e-19) (0.34751 3.45679 -2.02528e-19) (0.197393 3.34703 0) (0.228041 3.40728 2.63815e-19) (0.230822 3.0841 -1.44313e-18) (0.265079 3.20449 0) (0.00741468 3.12236 5.76337e-20) (0.0182009 3.13111 -6.57889e-19) (0.0169794 3.12701 9.68319e-19) (0.0340006 3.13975 0) (0.031838 3.15001 0) (1.26164 2.58987 0) (0.512234 0.833152 -5.78486e-19) (0.990384 1.03198 5.16983e-20) (0.961609 1.07031 0) (0.824197 0.956617 -1.48944e-19) (1.04708 0.895182 2.83498e-20) (0.406844 0.39374 -1.01861e-18) (0.713885 0.319742 -2.4835e-20) (0.670543 0.24888 4.60175e-19) (0.615775 0.374851 3.3932e-20) (0.527889 0.357936 -1.3687e-18) (0.671544 0.340197 0) (0.697735 0.423793 7.94601e-19) (0.701949 0.427641 0) (0.646503 0.363798 0) (0.610276 0.30882 0) (0.75858 0.643729 4.6641e-19) (1.2268 0.290659 -5.86384e-19) (1.20989 0.43399 0) (1.22279 0.380394 0) (0.761122 0.184081 6.88887e-19) (0.822616 0.542673 -4.34639e-19) (0.742902 0.500563 7.72463e-19) (0.943134 0.426287 -8.38366e-19) (1.019 0.0144362 8.73153e-19) (1.01744 0.0135143 -8.81637e-19) (1.01616 0.0142583 0) (1.03629 -0.00506545 0) (1.02999 -0.00799076 -8.28861e-19) (1.02818 -0.0107904 8.20372e-19) (1.02492 0.0101421 0) (1.02316 0.0141126 0) (1.01246 0.00450649 0) (1.01452 0.00906952 0) (1.01591 0.00380584 0) (1.01515 0.00261984 0) (0.0615654 1.3504 0) (0.0605759 1.31477 0) (0.144383 1.39203 -1.24219e-20) (0.262587 1.47349 4.00722e-20) (0.155946 1.44479 8.43469e-20) (0.177676 1.45117 -1.38888e-19) (0.145996 1.39928 0) (0.123325 1.57591 -1.76438e-19) (0.126043 1.56777 0) (0.352263 2.0334 -1.37593e-19) (0.342269 2.34896 7.27673e-19) (0.178773 1.44682 1.53809e-19) (0.264177 1.37281 -9.52576e-21) (0.193688 1.37303 7.78399e-21) (0.280247 1.30789 -1.77691e-19) (0.255549 1.57521 0) (0.252743 1.62433 1.65957e-19) (0.0246389 2.28128 -4.79833e-20) (0.036619 2.68306 0) (0.0650707 2.42134 1.78875e-19) (0.0579526 2.44128 0) (0.0682336 2.69842 -2.57409e-19) (0.042915 2.71547 0) (0.0238302 1.41971 -3.80627e-20) (0.0367842 1.47486 0) (0.0351589 1.38542 0) (0.0259458 1.38875 4.31604e-20) (-0.00408975 2.66772 -7.8125e-21) (0.0239468 2.707 3.01438e-19) (0.00609683 2.73624 1.98401e-21) (-0.00877662 1.84163 5.65893e-20) (-0.013759 1.68688 2.2979e-20) (0.00202201 1.30586 0) (-0.00549348 1.23164 0) (0.0371691 1.56656 9.10951e-20) (0.0333666 1.44894 7.11182e-20) (0.032581 1.51829 -9.41336e-20) (0.0400855 1.59359 0) (-0.048332 2.28851 -9.16995e-20) (-0.0567428 2.55195 3.88227e-20) (-0.0283571 2.46086 -1.96958e-20) (-0.0258632 1.8594 -6.85543e-20) (-0.0390737 2.51169 -2.29386e-20) (-0.0330319 2.45336 1.15199e-19) (1.01908 0.0205226 -8.7861e-19) (1.01535 0.0262101 8.81036e-19) (1.01435 0.0157817 0) (1.01237 0.0651248 1.20853e-18) (0.993093 0.0524802 -1.38402e-18) (0.956426 0.0478034 1.54557e-18) (1.01283 0.106496 -1.65164e-19) (1.04295 -0.00530744 0) (1.0508 -0.00133344 7.99395e-19) (1.03927 -0.00865185 -7.97492e-19) (1.0711 0.0391436 -4.76813e-20) (1.06345 0.0259322 4.10264e-19) (1.06452 0.0604131 0) (1.05262 0.0507008 -1.47257e-19) (1.03241 0.0411771 0) (1.02561 0.0372645 0) (1.02779 0.0126738 0) (1.0243 0.0153662 0) (1.04048 0.0309942 3.02348e-19) (1.03949 0.0266292 -6.67225e-19) (1.05183 0.0356281 -3.21268e-19) (1.04728 0.0359076 -3.53513e-19) (1.07378 0.0630663 6.85444e-19) (1.09696 0.0503604 0) (1.10252 0.087657 0) (-0.0588244 2.28236 -5.68174e-20) (-0.0162819 2.11883 -1.02249e-20) (-0.0101816 2.08657 0) (-0.0545388 2.45927 5.71632e-20) (-0.0425983 2.43923 2.05949e-20) (-0.0708432 2.45661 -2.20813e-20) (-0.0332376 2.62477 8.52427e-20) (-0.0481438 2.56625 -6.52707e-21) (-0.0367505 2.5265 2.52333e-20) (-0.0316268 2.61473 -4.36982e-20) (-0.0339516 2.61728 5.37706e-20) (0.043971 1.55436 2.61296e-22) (0.0118611 1.70467 7.9349e-20) (0.367802 1.42416 -5.12836e-20) (0.3634 1.35661 1.06148e-19) (0.629541 1.43022 -1.49755e-19) (0.507815 1.4994 -1.05879e-19) (0.552061 1.46526 0) (0.604201 2.43764 2.248e-19) (0.666427 2.43157 3.60412e-19) (0.418175 2.53032 8.29638e-20) (0.400584 2.55258 -7.5432e-19) (0.500712 2.4949 6.45959e-19) (0.557232 2.4815 0) (0.487606 2.53743 -5.97109e-19) (0.26186 2.60206 1.2923e-18) (0.367678 2.5717 -6.03378e-20) (0.287686 2.66237 -1.76611e-18) (0.962619 2.39336 7.99965e-19) (0.845309 2.39383 0) (1.0113 0.00115421 2.87322e-20) (1.01519 -0.00540472 -2.34473e-20) (1.01764 -0.00416577 -4.2895e-19) (1.01543 -0.00129126 4.27602e-19) (1.01288 0.00158185 0) (0.621172 1.29166 0) (0.655267 1.17778 0) (0.762067 1.09806 0) (0.641785 1.1391 0) (1.19541 2.63892 5.08436e-20) (1.08645 2.38548 0) (0.823662 2.20199 4.49824e-21) (0.825517 2.45584 0) (0.917281 2.54339 -5.16108e-19) (0.9491 2.49368 3.44998e-19) (0.812206 0.137064 0) (0.777055 0.131475 1.79016e-19) (0.919794 0.143416 1.03949e-18) (0.843405 0.119658 -3.91336e-19) (0.811747 0.0797379 -1.1875e-18) (1.0802 0.223101 -1.01393e-18) (0.986748 0.282552 -7.39116e-21) (0.925792 0.321488 9.4905e-19) (1.02029 0.233766 8.03462e-19) (0.93704 0.181832 -1.38508e-18) (0.899518 0.194931 1.72374e-19) (0.937699 0.288288 -3.67627e-19) (0.913193 0.19842 0) (1.0021 0.185517 6.80613e-19) (1.05444 0.198668 0) (1.05126 0.20243 0) (1.11753 0.110106 3.18374e-19) (1.06588 0.171766 -1.02397e-20) (1.07286 0.228004 -1.80221e-19) (1.10773 0.193804 0) (1.02355 0.0452671 6.80773e-19) (1.03852 0.0589242 8.51153e-19) (1.03289 0.0431761 -6.75412e-19) (1.04105 0.0638092 -5.70684e-19) (1.01502 0.0692234 -8.5571e-19) (0.990703 0.154385 0) (0.99436 0.0992047 0) (0.965989 0.0620269 -5.47983e-19) (0.915858 0.0909055 2.16648e-19) (1.03652 0.104999 7.91259e-19) (1.07352 0.119983 -9.27929e-19) (1.06667 0.159784 8.31515e-19) (1.03697 0.140049 0) (1.08233 0.10867 0) (1.05799 0.100047 -3.76919e-19) (1.04408 0.0987255 -6.45373e-19) (0.585199 1.10978 1.55022e-19) (0.623293 1.44225 -6.20678e-20) (1.14584 2.73661 -3.00001e-19) (1.19886 3.1174 1.36345e-20) (1.25444 2.74126 -2.54e-19) (1.29632 2.71317 7.45031e-20) (1.27179 2.33366 -3.6816e-20) (1.18652 3.02286 -1.19712e-19) (1.20512 2.97937 2.96082e-19) (1.18126 3.27133 -1.03763e-19) (1.40126 2.98669 1.28381e-19) (1.41338 2.92525 0) (0.544609 0.855843 -5.3607e-20) (0.23804 1.23057 5.26367e-19) (0.493272 0.47035 6.49177e-19) (0.365469 0.232531 7.44621e-19) (0.546457 0.38831 7.71156e-19) (0.553866 0.48157 -1.24092e-18) (0.555181 0.480528 1.01488e-18) (0.51089 0.416942 -3.91911e-19) (0.446288 0.35155 8.86881e-19) (0.770815 0.244272 -3.94607e-19) (0.734254 0.281489 0) (0.708968 0.212397 1.05953e-20) (0.727882 0.517119 4.18207e-19) (0.688463 0.49099 -1.52156e-18) (0.649429 0.472104 2.38301e-20) (0.652173 0.446016 0) (0.681187 0.73962 4.25354e-19) (0.79199 0.786466 4.95566e-19) (0.723897 0.836683 -5.74172e-19) (0.860525 0.803835 -1.87863e-19) (0.901961 0.850896 -5.05491e-20) (0.909355 0.857777 5.18419e-20) (0.850191 0.666431 -7.75169e-19) (0.91922 0.717569 1.74749e-19) (0.97296 0.723081 0) (0.969753 0.700062 -2.32511e-19) (1.02644 0.312505 2.56851e-19) (1.14035 0.315182 3.40748e-19) (1.06278 0.26433 4.15116e-19) (0.985374 0.357756 -5.03013e-19) (1.0208 0.46597 0) (1.10753 0.413964 0) (0.879374 0.394679 8.82332e-21) (0.845716 0.288637 0) (0.869457 0.270049 4.49047e-19) (0.904969 0.318083 1.00769e-20) (0.941183 0.450762 2.36816e-18) (0.867487 0.519052 6.00837e-19) (0.891533 0.467537 -6.4462e-19) (0.812465 0.44842 6.84551e-19) (0.801146 0.433244 4.10096e-19) (0.789225 0.405581 -4.02095e-19) (1.02786 -0.000829731 7.10428e-19) (1.02021 0.000114948 0) (1.0189 0.000977042 4.63302e-19) (1.02256 -0.00118641 -1.04917e-18) (1.02243 0.00411686 5.10593e-19) (1.02024 0.0110337 -1.06843e-18) (1.02112 0.0107688 0) (1.02 0.0116071 -2.22386e-19) (1.01636 0.0074652 5.57284e-19) (1.01675 0.0106173 -2.8023e-19) (1.01745 0.0101876 2.05307e-19) (0.0339307 1.32175 0) (0.0396832 1.35101 0) (0.044458 1.32875 0) (0.0476611 1.28957 0) (0.0737894 1.3548 1.36903e-19) (0.0899288 1.33033 -6.37458e-20) (0.0589541 1.53087 -4.48249e-20) (0.112785 1.35876 -1.27394e-20) (0.036099 1.4555 -8.27628e-20) (0.0386199 1.45047 6.40657e-20) (0.0647152 1.35591 -3.48202e-20) (0.0540001 1.35935 -4.01596e-20) (0.0492028 1.34183 -5.6532e-21) (0.0416119 1.36322 -9.47535e-21) (0.107036 2.39312 -1.97194e-19) (0.0963925 2.43425 0) (0.154442 2.03987 1.30147e-19) (0.117215 1.70633 7.28418e-20) (0.221467 2.03112 -1.07023e-19) (0.219121 2.43996 0) (0.248262 2.39758 -7.45775e-19) (0.298661 2.39312 5.34334e-19) (0.258171 2.00494 -2.8397e-19) (0.14426 2.16868 1.87192e-19) (0.112679 2.27737 0) (0.0129574 1.86846 -1.27966e-19) (-0.0127966 2.40686 -1.78524e-19) (-0.0021886 2.15527 0) (0.000918028 2.46705 -1.43406e-20) (0.0154542 2.3129 7.25975e-20) (0.0166261 1.40502 6.87572e-21) (-0.000972434 1.38875 -1.17146e-19) (-0.00273324 1.39111 2.81305e-20) (0.0142664 1.39378 4.48084e-20) (0.0206113 1.42402 0) (0.00231544 1.37128 0) (0.0112601 1.28384 5.8538e-20) (0.00515111 1.36349 -1.9982e-20) (0.000896225 1.35979 0) (0.0125539 1.28859 3.34507e-20) (-0.0120351 1.19115 -7.38248e-20) (1.04153 0.0136092 0) (1.04821 0.00913198 -7.47262e-20) (1.03872 0.0220485 -5.38281e-19) (1.04857 0.0210419 0) (1.05325 0.0206184 0) (1.03617 0.0116571 -6.55138e-21) (1.03046 0.0118893 8.6175e-19) (1.03199 0.0160103 1.04874e-18) (1.02587 0.0197751 0) (1.02248 0.0204456 0) (1.03544 0.0240932 5.36645e-19) (1.02535 0.0261279 0) (1.02416 0.0261547 0) (-0.0571039 2.0306 0) (0.000297526 1.6974 -2.24094e-21) (-0.0301018 1.79166 8.30369e-21) (0.0164743 1.36109 0) (-0.0138579 1.57141 4.3974e-20) (0.0154072 1.48089 -2.9063e-20) (0.0534948 1.40854 0) (0.407794 1.66954 0) (0.355373 1.29716 -1.70085e-19) (0.284918 1.34387 0) (0.424663 1.30659 1.32434e-19) (0.464158 1.45701 0) (0.4462 1.4007 -3.40446e-20) (1.03828 2.68624 -1.72562e-20) (0.978442 2.41393 -1.00501e-18) (0.936414 2.20207 1.15707e-18) (0.860259 2.38662 2.59932e-19) (0.852425 2.50365 0) (0.919952 2.50135 0) (0.946472 2.38689 0) (0.922791 2.3746 -1.01262e-18) (0.696053 2.47609 -4.48887e-19) (0.803096 2.45987 -1.13553e-19) (0.811276 2.43797 8.58391e-20) (0.702957 2.40554 0) (0.806724 2.39885 0) (0.768862 2.41437 -3.89507e-19) (0.768986 2.48298 0) (0.600705 1.0743 0) (0.512752 0.895836 -6.23687e-19) (0.515137 0.96143 -3.65293e-20) (0.499361 1.09504 0) (0.486306 1.00802 9.54951e-19) (0.758332 0.876245 -1.66761e-19) (0.773652 1.01099 0) (0.749317 0.987646 2.44843e-19) (0.637001 1.02138 0) (0.631686 0.937752 0) (1.16336 2.76948 -2.73188e-19) (1.13823 2.82877 -1.28954e-19) (0.925649 2.35903 1.41432e-19) (0.901852 2.33784 -9.6842e-20) (1.13224 2.74623 0) (1.08409 2.71471 1.16436e-19) (1.09953 2.50482 -3.43727e-19) (0.998737 2.25613 -2.83032e-20) (0.50062 1.35896 0) (0.516687 1.09268 -1.36628e-19) (0.57635 1.17421 0) (0.853882 0.202013 0) (0.796841 0.154007 0) (0.741251 0.139607 0) (0.863175 0.204705 -7.04736e-19) (0.790434 0.204159 4.09106e-19) (0.930037 0.0768251 -4.4847e-19) (0.945493 0.12354 0) (0.921237 0.134172 1.92597e-19) (0.867777 0.0942133 7.70893e-19) (0.835018 0.0674686 -4.82959e-19) (1.10246 3.3648 -6.42465e-19) (1.16729 3.28748 0) (1.12253 3.45012 -1.51876e-18) (0.661936 3.59571 1.26104e-18) (1.03335 3.09089 8.0335e-20) (0.518318 0.834879 6.22578e-19) (0.506745 0.802195 0) (0.383571 0.499698 -1.6185e-19) (0.463105 0.680941 9.41245e-19) (0.51993 0.476969 -2.26346e-19) (0.510008 0.519454 2.55629e-19) (0.684864 0.550427 5.40417e-19) (0.710983 0.577116 0) (0.641171 0.617936 0) (0.609593 0.565464 0) (0.982353 0.616322 1.33995e-19) (0.924176 0.563769 -5.81856e-19) (0.947634 0.59933 4.39265e-19) (1.0021 0.517131 -4.45914e-19) (1.04539 0.494232 0) (1.05606 0.597822 -1.17708e-19) (0.84268 0.390767 -9.25828e-19) (0.838535 0.384803 -1.17673e-18) (0.80685 0.379684 7.27147e-19) (0.807986 0.342453 -7.41928e-19) (0.841341 0.300028 -5.80088e-19) (0.808065 0.301313 7.12613e-19) (1.02655 0.00599958 -5.35251e-19) (1.02622 0.00612257 1.07928e-18) (1.02959 0.000248966 6.89803e-19) (1.03356 0.000824351 -8.28311e-19) (1.03348 0.0105843 0) (1.02983 0.0107064 -1.34765e-18) (0.0811415 1.66268 3.18411e-20) (0.0443322 1.58513 0) (0.0993644 1.71092 2.19036e-19) (0.11082 1.68237 -2.00418e-19) (0.0397867 1.53237 8.41741e-20) (0.0291216 1.5086 0) (-0.00474855 1.69447 0) (-0.00862456 1.49886 -1.93186e-20) (-0.0130476 1.43188 1.73885e-20) (-0.0102444 1.56695 -2.52797e-21) (-0.0211869 1.90237 -3.66062e-20) (-0.042567 1.95414 1.85749e-20) (0.491542 1.38074 -3.85867e-19) (0.494777 1.37848 4.19507e-19) (0.438502 1.2947 -1.02918e-19) (0.42649 1.30207 1.44719e-20) (0.613526 1.29941 0) (0.544584 1.39021 2.99548e-20) (0.545731 1.39372 -2.91347e-20) (0.470948 1.27415 9.81352e-20) (0.509352 1.238 0) (0.5761 1.20666 0) (0.670553 2.43883 6.61441e-19) (0.662969 2.46233 1.43816e-18) (0.720711 2.4776 -9.87767e-19) (0.62256 2.45017 -2.19492e-19) (0.555932 2.54926 3.1128e-19) (0.495995 2.51072 -8.03158e-19) (0.988091 2.39132 -6.5253e-19) (1.02237 2.411 0) (0.943489 2.18782 -7.17717e-19) (1.05433 2.69518 0) (1.05343 2.67709 0) (0.618006 2.31782 -1.47446e-20) (1.12298 3.08387 4.31074e-20) (1.00638 2.98628 -9.86011e-20) (0.338068 0.876645 0) (0.359084 0.786968 -3.27382e-19) (0.544551 0.71138 -3.42741e-19) (0.386345 2.16556 0) (0.413383 2.75315 -5.65124e-20) (0.424256 2.49327 0) (0.687089 0.703384 -9.09018e-19) (0.746786 0.694682 1.28116e-18) (0.759222 0.658145 -1.27969e-18) (0.679201 0.662212 -1.15841e-19) (0.733082 0.618453 -4.8366e-19) (0.978499 2.77198 -3.26524e-20) (1.01565 2.77473 -2.74167e-19) (0.572268 2.24733 4.75281e-19) (0.616884 1.76279 -3.7498e-19) (0.714062 1.8798 -5.70745e-19) (0.982089 2.41392 -1.45013e-19) (0.979898 2.37075 4.31728e-19) (0.662081 1.80503 3.77667e-20) (0.467251 1.32666 2.09433e-19) ) ; boundaryField { wall-4 { type noSlip; } velocity-inlet-5 { type fixedValue; value uniform (1 0 0); } velocity-inlet-6 { type fixedValue; value uniform (0 3 0); } pressure-outlet-7 { type zeroGradient; } wall-8 { type noSlip; } frontAndBackPlanes { type empty; } } // ************************************************************************* //
[ "jfeatherstone123@gmail.com" ]
jfeatherstone123@gmail.com
2b8436297336e00505dd5c70365fed5d8757239e
9423f5a6be717eaf0233cfe5d5dc3a21af1b40d4
/src/classes/AlgorithmConfig.hpp
a46b7cc0f064e869fb76fcdeadf7ea6f7bd8adef
[]
no_license
fboliveira/MDVRPGPU-CD-CUDA-v5-Parallel
9898b8c5d57368f9bce19c1807f5cbfdf765153e
71cd27e3d482cfff2f6c5ee2a6b6b42c4c1716c3
refs/heads/master
2021-01-20T00:57:09.406786
2015-05-09T10:45:18
2015-05-09T10:45:18
35,287,523
0
0
null
null
null
null
UTF-8
C++
false
false
3,378
hpp
/* * File: Config.hpp * Author: fernando * * Created on July 21, 2014, 4:22 PM */ #ifndef CONFIG_HPP #define CONFIG_HPP #include <cmath> #include <climits> #include <string> #include <mutex> #include "MDVRPProblem.hpp" #include "../global.hpp" using namespace std; class AlgorithmConfig { private: // Algoritmo a ser executado Enum_Algorithms algorithm; enum Enum_StopCriteria stopCriteria; // Criterio de parada utilizado enum Enum_Process_Type processType; // Tipo de processamento bool debug; bool display; unsigned long int numGen; float executionTime; // Tempo limite de execucao (s) para criterioParada == TEMPO float maxTimeWithoutUpdate; int totalMoves; bool saveLogRunFile; int numSubIndDepots; // Mu value int numOffspringsPerParent; // Lambda value int numSolutionElem; float mutationRatePM; enum Enum_Local_Search_Type localSearchType; float mutationRatePLS; float capacityPenalty; float routeDurationPenalty; float extraVehiclesPenalty; float incompleteSolutionPenalty; bool writeFactors; int eliteGroupLimit; public: AlgorithmConfig(); Enum_Algorithms getAlgorithm() const; void setAlgorithm(Enum_Algorithms algorithm); float getCapacityPenalty() const; void setCapacityPenalty(float capacityPenalty); bool isDebug() const; void setDebug(bool debug); bool isDisplay() const; void setDisplay(bool display); float getExecutionTime() const; void setExecutionTime(float executionTime); float getMaxTimeWithoutUpdate() const; void setMaxTimeWithoutUpdate(float maxTimeWithoutUpdate); float getExtraVehiclesPenalty() const; void setExtraVehiclesPenalty(float extraVehiclesPenalty); float getIncompleteSolutionPenalty() const; void setIncompleteSolutionPenalty(float incompleteSolutionPenalty); Enum_Local_Search_Type getLocalSearchType() const; void setLocalSearchType(Enum_Local_Search_Type localSearchType); float getMutationRatePLS() const; void setMutationRatePLS(float mutationRatePLS); float getMutationRatePM() const; void setMutationRatePM(float mutationRatePM); unsigned long int getNumGen() const; void setNumGen(unsigned long int numGen); int getNumSolutionElem() const; void setNumSolutionElem(int numSolutionElem); int getNumSubIndDepots() const; void setNumSubIndDepots(int numSubIndDepots); int getNumOffspringsPerParent() const; void setNumOffspringsPerParent(int numOffspringsPerParent); Enum_Process_Type getProcessType() const; void setProcessType(Enum_Process_Type processType); float getRouteDurationPenalty() const; void setRouteDurationPenalty(float routeDurationPenalty); bool isSaveLogRunFile() const; void setSaveLogRunFile(bool saveLogRunFile); Enum_StopCriteria getStopCriteria() const; void setStopCriteria(Enum_StopCriteria stopCriteria); int getTotalMoves() const; void setTotalMoves(int totalMoves); bool isWriteFactors() const; void setWriteFactors(bool writeFactors); int getEliteGroupLimit() const; void setEliteGroupLimit(int eliteGroupLimit); void setParameters(MDVRPProblem *problem); string getLocalSearchTypeStringValue(); }; #endif /* CONFIG_HPP */
[ "fboliveira25@gmail.com" ]
fboliveira25@gmail.com
5a4b7a2b18690a0356de599a2260d648283ea55e
50f7bba2acef9024c3198b3a3cc07e880b142f93
/src/chainparams.cpp
63a7aebcfdeb566cb0f9b5b18de98232c1c5262b
[ "MIT" ]
permissive
Blockade-Project/ADEC
08dd2a07b8257f0a18f0367df92e6871ec788007
53fc2110848a4343f469e16eaae32659626d9081
refs/heads/main
2023-08-18T03:13:00.792644
2021-09-19T14:12:00
2021-09-19T14:12:00
407,564,228
0
0
null
null
null
null
UTF-8
C++
false
false
29,879
cpp
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2020 The PIVX developers // Copyright (c) 2021 The DECENOMY Core Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "chainparams.h" #include "chainparamsseeds.h" #include "consensus/merkle.h" #include "util.h" #include "utilstrencodings.h" #include <boost/assign/list_of.hpp> #include <assert.h> #define DISABLED 0x7FFFFFFE; static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) { CMutableTransaction txNew; txNew.nVersion = 1; txNew.vin.resize(1); txNew.vout.resize(1); txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); txNew.vout[0].nValue = genesisReward; txNew.vout[0].scriptPubKey = genesisOutputScript; CBlock genesis; genesis.vtx.push_back(txNew); genesis.hashPrevBlock.SetNull(); genesis.nVersion = nVersion; genesis.nTime = nTime; genesis.nBits = nBits; genesis.nNonce = nNonce; genesis.hashMerkleRoot = BlockMerkleRoot(genesis); return genesis; } /** * Build the genesis block. Note that the output of the genesis coinbase cannot * be spent as it did not originally exist in the database. * * CBlock(hash=00000ffd590b14, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=e0028e, nTime=1390095618, nBits=1e0ffff0, nNonce=28917698, vtx=1) * CTransaction(hash=e0028e, ver=1, vin.size=1, vout.size=1, nLockTime=0) * CTxIn(COutPoint(000000, -1), coinbase 04ffff001d01044c5957697265642030392f4a616e2f3230313420546865204772616e64204578706572696d656e7420476f6573204c6976653a204f76657273746f636b2e636f6d204973204e6f7720416363657074696e6720426974636f696e73) * CTxOut(nValue=50.00000000, scriptPubKey=0xA9037BAC7050C479B121CF) * vMerkleTree: e0028e */ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) { const char* pszTimestamp = "the cat is on the table"; const CScript genesisOutputScript = CScript() << ParseHex("0478505c5bc438e08c0c8de26a661bc5a4453378d0b149fbf17cb3e1499b1d3e552fe5faaa253673c5349b461bd964a2ee860c114e9d2b9fdb0328f37ed356ed54") << OP_CHECKSIG; return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward); } /** * Main network */ /** * What makes a good checkpoint block? * + Is surrounded by blocks with reasonable timestamps * (no blocks before with a timestamp after, none after with * timestamp before) * + Contains no strange transactions */ static Checkpoints::MapCheckpoints mapCheckpoints = boost::assign::map_list_of (0, uint256S("0x0")); static const Checkpoints::CCheckpointData data = { &mapCheckpoints, 1626853170, // * UNIX timestamp of last checkpoint block 221854, // * total number of transactions between genesis and last checkpoint // (the tx=... number in the UpdateTip debug.log lines) 3076 // * estimated number of transactions per day after checkpoint }; static Checkpoints::MapCheckpoints mapCheckpointsTestnet = boost::assign::map_list_of (0, uint256S("0x0")); static const Checkpoints::CCheckpointData dataTestnet = { &mapCheckpointsTestnet, 1740710, 0, 250}; static Checkpoints::MapCheckpoints mapCheckpointsRegtest = boost::assign::map_list_of(0, uint256S("0x0")); static const Checkpoints::CCheckpointData dataRegtest = { &mapCheckpointsRegtest, 1454124731, 0, 100}; class CMainParams : public CChainParams { public: CMainParams() { networkID = CBaseChainParams::MAIN; strNetworkID = "main"; /* // // This is used inorder to mine the genesis block. Once found, we can use the nonce and block hash found to create a valid genesis block // ///////////////////////////////////////////////////////////////// uint32_t nGenesisTime = 1631025514; // Wed May 05 2021 14:14:51 GMT+0000 arith_uint256 test; bool fNegative; bool fOverflow; test.SetCompact(0x1e0ffff0, &fNegative, &fOverflow); std::cout << "Test threshold: " << test.GetHex() << "\n\n"; int genesisNonce = 0; uint256 TempHashHolding = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000"); uint256 BestBlockHash = uint256S("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); for (int i=0;i<40000000;i++) { genesis = CreateGenesisBlock(nGenesisTime, i, 0x1e0ffff0, 1, 0 * COIN); //genesis.hashPrevBlock = TempHashHolding; consensus.hashGenesisBlock = genesis.GetHash(); arith_uint256 BestBlockHashArith = UintToArith256(BestBlockHash); if (UintToArith256(consensus.hashGenesisBlock) < BestBlockHashArith) { BestBlockHash = consensus.hashGenesisBlock; std::cout << BestBlockHash.GetHex() << " Nonce: " << i << "\n"; std::cout << " PrevBlockHash: " << genesis.hashPrevBlock.GetHex() << "\n"; } TempHashHolding = consensus.hashGenesisBlock; if (BestBlockHashArith < test) { genesisNonce = i - 1; break; } //std::cout << consensus.hashGenesisBlock.GetHex() << "\n"; } std::cout << "\n"; std::cout << "\n"; std::cout << "\n"; std::cout << "hashGenesisBlock to 0x" << BestBlockHash.GetHex() << std::endl; std::cout << "Genesis Nonce to " << genesisNonce << std::endl; std::cout << "Genesis Merkle 0x" << genesis.hashMerkleRoot.GetHex() << std::endl; exit(0); */ // ///////////////////////////////////////////////////////////////// genesis = CreateGenesisBlock(1631025514, 269949, 0x1e0ffff0, 1, 0 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x00000ceb5140e18a08bf66aee9d07fb5982c2c2918175898c25d04fbc1223687")); assert(genesis.hashMerkleRoot == uint256S("0xfac6d0e33fc949953e699770c09a42d659c320ae05076b4d24913f94b2121fb0")); consensus.fPowAllowMinDifficultyBlocks = false; consensus.powLimit = ~UINT256_ZERO >> 20; consensus.posLimitV1 = ~UINT256_ZERO >> 24; consensus.posLimitV2 = ~UINT256_ZERO >> 20; consensus.nBudgetCycleBlocks = 30 * 24 * 60; // approx. 1 every 30 days consensus.nBudgetFeeConfirmations = 6; // Number of confirmations for the finalization fee consensus.nCoinbaseMaturity = 100; consensus.nFutureTimeDriftPoW = 7200; consensus.nFutureTimeDriftPoS = 180; consensus.nMasternodeCountDrift = 20; // num of MN we allow the see-saw payments to be off by consensus.nMaxMoneyOut = 50000000 * COIN; consensus.nPoolMaxTransactions = 3; consensus.nProposalEstablishmentTime = 60 * 60 * 24; // must be at least a day old to make it into a budget consensus.nStakeMinAge = 60 * 60; // 1h consensus.nStakeMinDepth = 100; consensus.nStakeMinDepthV2 = 600; consensus.nTargetTimespan = 40 * 60; consensus.nTargetTimespanV2 = 30 * 60; consensus.nTargetSpacing = 1 * 60; consensus.nTimeSlotLength = 15; // spork keys consensus.strSporkPubKey = "04c80e62aabe7386f91914f69e3edfccb120dfc04218b74747822f01b412899957ebec4b8787aa26a6efc986285a65cde76412b93f9ecd72ad94d90a5ea8559510"; consensus.strSporkPubKeyOld = ""; consensus.nTime_EnforceNewSporkKey = 0; consensus.nTime_RejectOldSporkKey = 0; // height-based activations consensus.height_last_ZC_AccumCheckpoint = DISABLED; consensus.height_last_ZC_WrappedSerials = DISABLED; consensus.height_start_InvalidUTXOsCheck = DISABLED; consensus.height_start_ZC_InvalidSerials = DISABLED; consensus.height_start_ZC_SerialRangeCheck = DISABLED; consensus.height_ZC_RecalcAccumulators = DISABLED; // Zerocoin-related params consensus.ZC_Modulus = "25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784" "4069182906412495150821892985591491761845028084891200728449926873928072877767359714183472702618963750149718246911" "6507761337985909570009733045974880842840179742910064245869181719511874612151517265463228221686998754918242243363" "7259085141865462043576798423387184774447920739934236584823824281198163815010674810451660377306056201619676256133" "8441436038339044149526344321901146575444541784240209246165157233507787077498171257724679629263863563732899121548" "31438167899885040445364023527381951378636564391212010397122822120720357"; consensus.ZC_MaxPublicSpendsPerTx = 637; // Assume about 220 bytes each input consensus.ZC_MaxSpendsPerTx = 7; // Assume about 20kb each input consensus.ZC_MinMintConfirmations = 20; consensus.ZC_MinMintFee = 1 * CENT; consensus.ZC_MinStakeDepth = 200; consensus.ZC_TimeStart = 1893456000; // 01/01/2030 @ 12:00am (UTC) consensus.ZC_WrappedSerialsSupply = 0; //4131563 * COIN; // zerocoin supply at height_last_ZC_WrappedSerials // Network upgrades consensus.vUpgrades[Consensus::BASE_NETWORK].nActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE; consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; consensus.vUpgrades[Consensus::UPGRADE_POS].nActivationHeight = 1001; consensus.vUpgrades[Consensus::UPGRADE_POS_V2].nActivationHeight = 1441; consensus.vUpgrades[Consensus::UPGRADE_ZC].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; consensus.vUpgrades[Consensus::UPGRADE_ZC_V2].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; consensus.vUpgrades[Consensus::UPGRADE_BIP65].nActivationHeight = 1441; consensus.vUpgrades[Consensus::UPGRADE_ZC_PUBLIC].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; consensus.vUpgrades[Consensus::UPGRADE_STAKE_MODIFIER_V2].nActivationHeight = 1541; consensus.vUpgrades[Consensus::UPGRADE_TIME_PROTOCOL_V2].nActivationHeight = 1641; consensus.vUpgrades[Consensus::UPGRADE_P2PKH_BLOCK_SIGNATURES].nActivationHeight = 1741; consensus.vUpgrades[Consensus::UPGRADE_STAKE_MIN_DEPTH_V2].nActivationHeight = 5001; consensus.vUpgrades[Consensus::UPGRADE_MASTERNODE_RANK_V2].nActivationHeight = 115000; consensus.vUpgrades[Consensus::UPGRADE_POS].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_POS_V2].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_BIP65].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_STAKE_MODIFIER_V2].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_TIME_PROTOCOL_V2].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_P2PKH_BLOCK_SIGNATURES].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_STAKE_MIN_DEPTH_V2].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_MASTERNODE_RANK_V2].hashActivationBlock = uint256S("0x0"); /** * The message start string is designed to be unlikely to occur in normal data. * The characters are rarely used upper ASCII, not valid as UTF-8, and produce * a large 4-byte int at any alignment. */ pchMessageStart[0] = 0x6e; pchMessageStart[1] = 0x6f; pchMessageStart[2] = 0x69; pchMessageStart[3] = 0x7a; nDefaultPort = 36880; vSeeds.push_back(CDNSSeedData("tseeder", "144.91.104.80")); vSeeds.push_back(CDNSSeedData("tseed1", "144.91.106.95")); vSeeds.push_back(CDNSSeedData("tseed2", "136.244.78.180")); vSeeds.push_back(CDNSSeedData("seed3", "seed3.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("seed4", "seed4.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("seed5", "seed5.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("seed6", "seed6.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("seed7", "seed7.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("seed8", "seed8.blockadecoin.net")); base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 85); // b base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 25); // B base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, 213); base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x02)(0x2D)(0x25)(0x33).convert_to_container<std::vector<unsigned char> >(); base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x02)(0x21)(0x31)(0x2B).convert_to_container<std::vector<unsigned char> >(); // BIP44 coin type is from https://github.com/satoshilabs/slips/blob/master/slip-0044.md base58Prefixes[EXT_COIN_TYPE] = boost::assign::list_of(0x80)(0x00)(0x03)(0x99).convert_to_container<std::vector<unsigned char> >(); vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); //convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main)); // added } const Checkpoints::CCheckpointData& Checkpoints() const { return data; } }; static CMainParams mainParams; /** * Testnet (v1) */ class CTestNetParams : public CMainParams { public: CTestNetParams() { networkID = CBaseChainParams::TESTNET; strNetworkID = "test"; genesis = CreateGenesisBlock(1454124731, 2402015, 0x1e0ffff0, 1, 250 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); //assert(consensus.hashGenesisBlock == uint256S("0x0000041e482b9b9691d98eefb48473405c0b8ec31b76df3797c74a78680ef818")); //assert(genesis.hashMerkleRoot == uint256S("0x1b2ef6e2f28be914103a277377ae7729dcd125dfeb8bf97bd5964ba72b6dc39b")); consensus.fPowAllowMinDifficultyBlocks = true; consensus.powLimit = ~UINT256_ZERO >> 20; // blockade starting difficulty is 1 / 2^12 consensus.posLimitV1 = ~UINT256_ZERO >> 24; consensus.posLimitV2 = ~UINT256_ZERO >> 20; consensus.nBudgetCycleBlocks = 144; // approx 10 cycles per day consensus.nBudgetFeeConfirmations = 3; // (only 8-blocks window for finalization on testnet) consensus.nCoinbaseMaturity = 15; consensus.nFutureTimeDriftPoW = 7200; consensus.nFutureTimeDriftPoS = 180; consensus.nMasternodeCountDrift = 4; // num of MN we allow the see-saw payments to be off by consensus.nMaxMoneyOut = 43199500 * COIN; consensus.nPoolMaxTransactions = 2; consensus.nProposalEstablishmentTime = 60 * 5; // at least 5 min old to make it into a budget consensus.nStakeMinAge = 60 * 60; consensus.nStakeMinDepth = 100; consensus.nStakeMinDepthV2 = 200; consensus.nTargetTimespan = 40 * 60; consensus.nTargetTimespanV2 = 30 * 60; consensus.nTargetSpacing = 1 * 60; consensus.nTimeSlotLength = 15; // spork keys consensus.strSporkPubKey = "04E88BB455E2A04E65FCC41D88CD367E9CCE1F5A409BE94D8C2B4B35D223DED9C8E2F4E061349BA3A38839282508066B6DC4DB72DD432AC4067991E6BF20176127"; consensus.strSporkPubKeyOld = ""; consensus.nTime_EnforceNewSporkKey = 0; consensus.nTime_RejectOldSporkKey = 0; // height based activations consensus.height_last_ZC_AccumCheckpoint = 999999999; consensus.height_last_ZC_WrappedSerials = 999999999; consensus.height_start_InvalidUTXOsCheck = 999999999; consensus.height_start_ZC_InvalidSerials = 999999999; consensus.height_start_ZC_SerialRangeCheck = 999999999; consensus.height_ZC_RecalcAccumulators = 999999999; // Zerocoin-related params consensus.ZC_Modulus = "25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784" "4069182906412495150821892985591491761845028084891200728449926873928072877767359714183472702618963750149718246911" "6507761337985909570009733045974880842840179742910064245869181719511874612151517265463228221686998754918242243363" "7259085141865462043576798423387184774447920739934236584823824281198163815010674810451660377306056201619676256133" "8441436038339044149526344321901146575444541784240209246165157233507787077498171257724679629263863563732899121548" "31438167899885040445364023527381951378636564391212010397122822120720357"; consensus.ZC_MaxPublicSpendsPerTx = 637; // Assume about 220 bytes each input consensus.ZC_MaxSpendsPerTx = 7; // Assume about 20kb each input consensus.ZC_MinMintConfirmations = 20; consensus.ZC_MinMintFee = 1 * CENT; consensus.ZC_MinStakeDepth = 200; consensus.ZC_TimeStart = 1501776000; consensus.ZC_WrappedSerialsSupply = 0; // WrappedSerials only on main net // Network upgrades consensus.vUpgrades[Consensus::BASE_NETWORK].nActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE; consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; consensus.vUpgrades[Consensus::UPGRADE_POS].nActivationHeight = 1001; consensus.vUpgrades[Consensus::UPGRADE_POS_V2].nActivationHeight = 1441; consensus.vUpgrades[Consensus::UPGRADE_ZC].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; consensus.vUpgrades[Consensus::UPGRADE_ZC_V2].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; consensus.vUpgrades[Consensus::UPGRADE_BIP65].nActivationHeight = 1441; consensus.vUpgrades[Consensus::UPGRADE_ZC_PUBLIC].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; consensus.vUpgrades[Consensus::UPGRADE_STAKE_MODIFIER_V2].nActivationHeight = 1541; consensus.vUpgrades[Consensus::UPGRADE_TIME_PROTOCOL_V2].nActivationHeight = 1641; consensus.vUpgrades[Consensus::UPGRADE_P2PKH_BLOCK_SIGNATURES].nActivationHeight = 1741; consensus.vUpgrades[Consensus::UPGRADE_STAKE_MIN_DEPTH_V2].nActivationHeight = 1841; consensus.vUpgrades[Consensus::UPGRADE_ZC].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_ZC_V2].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_BIP65].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_ZC_PUBLIC].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_STAKE_MODIFIER_V2].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_TIME_PROTOCOL_V2].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_P2PKH_BLOCK_SIGNATURES].hashActivationBlock = uint256S("0x0"); consensus.vUpgrades[Consensus::UPGRADE_STAKE_MIN_DEPTH_V2].hashActivationBlock = uint256S("0x0"); /** * The message start string is designed to be unlikely to occur in normal data. * The characters are rarely used upper ASCII, not valid as UTF-8, and produce * a large 4-byte int at any alignment. */ pchMessageStart[0] = 0x45; pchMessageStart[1] = 0x76; pchMessageStart[2] = 0x65; pchMessageStart[3] = 0xba; nDefaultPort = __PORT_TESTNET__; vFixedSeeds.clear(); vSeeds.clear(); // nodes with support for servicebits filtering should be at the top vSeeds.push_back(CDNSSeedData("tseed3", "tseed3.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("tseed4", "tseed4.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("tseed5", "tseed5.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("tseed6", "tseed6.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("tseed7", "tseed7.blockadecoin.net")); vSeeds.push_back(CDNSSeedData("tseed8", "tseed8.blockadecoin.net")); base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 139); // Testnet blockade addresses start with 'x' or 'y' base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 19); // Testnet blockade script addresses start with '8' or '9' base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, 239); // Testnet private keys start with '9' or 'c' (Bitcoin defaults) // Testnet blockade BIP32 pubkeys start with 'DRKV' base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x3a)(0x80)(0x61)(0xa0).convert_to_container<std::vector<unsigned char> >(); // Testnet blockade BIP32 prvkeys start with 'DRKP' base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x3a)(0x80)(0x58)(0x37).convert_to_container<std::vector<unsigned char> >(); // Testnet blockade BIP44 coin type is '1' (All coin's testnet default) base58Prefixes[EXT_COIN_TYPE] = boost::assign::list_of(0x80)(0x00)(0x00)(0x01).convert_to_container<std::vector<unsigned char> >(); vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test)); } const Checkpoints::CCheckpointData& Checkpoints() const { return dataTestnet; } }; static CTestNetParams testNetParams; /** * Regression test */ class CRegTestParams : public CTestNetParams { public: CRegTestParams() { networkID = CBaseChainParams::REGTEST; strNetworkID = "regtest"; genesis = CreateGenesisBlock(1454124731, 2402015, 0x1e0ffff0, 1, 250 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); //assert(consensus.hashGenesisBlock == uint256S("0x0000041e482b9b9691d98eefb48473405c0b8ec31b76df3797c74a78680ef818")); //assert(genesis.hashMerkleRoot == uint256S("0x1b2ef6e2f28be914103a277377ae7729dcd125dfeb8bf97bd5964ba72b6dc39b")); consensus.fPowAllowMinDifficultyBlocks = true; consensus.powLimit = ~UINT256_ZERO >> 20; // blockade starting difficulty is 1 / 2^12 consensus.posLimitV1 = ~UINT256_ZERO >> 24; consensus.posLimitV2 = ~UINT256_ZERO >> 20; consensus.nBudgetCycleBlocks = 144; // approx 10 cycles per day consensus.nBudgetFeeConfirmations = 3; // (only 8-blocks window for finalization on regtest) consensus.nCoinbaseMaturity = 100; consensus.nFutureTimeDriftPoW = 7200; consensus.nFutureTimeDriftPoS = 180; consensus.nMasternodeCountDrift = 4; // num of MN we allow the see-saw payments to be off by consensus.nMaxMoneyOut = 43199500 * COIN; consensus.nPoolMaxTransactions = 2; consensus.nProposalEstablishmentTime = 60 * 5; // at least 5 min old to make it into a budget consensus.nStakeMinAge = 0; consensus.nStakeMinDepth = 2; consensus.nTargetTimespan = 40 * 60; consensus.nTargetTimespanV2 = 30 * 60; consensus.nTargetSpacing = 1 * 60; consensus.nTimeSlotLength = 15; /* Spork Key for RegTest: WIF private key: 932HEevBSujW2ud7RfB1YF91AFygbBRQj3de3LyaCRqNzKKgWXi private key hex: bd4960dcbd9e7f2223f24e7164ecb6f1fe96fc3a416f5d3a830ba5720c84b8ca Address: yCvUVd72w7xpimf981m114FSFbmAmne7j9 */ consensus.strSporkPubKey = "043969b1b0e6f327de37f297a015d37e2235eaaeeb3933deecd8162c075cee0207b13537618bde640879606001a8136091c62ec272dd0133424a178704e6e75bb7"; consensus.strSporkPubKeyOld = ""; consensus.nTime_EnforceNewSporkKey = 0; consensus.nTime_RejectOldSporkKey = 0; // height based activations consensus.height_last_ZC_AccumCheckpoint = 310; // no checkpoints on regtest consensus.height_last_ZC_WrappedSerials = -1; consensus.height_start_InvalidUTXOsCheck = 999999999; consensus.height_start_ZC_InvalidSerials = 999999999; consensus.height_start_ZC_SerialRangeCheck = 300; consensus.height_ZC_RecalcAccumulators = 999999999; // Zerocoin-related params consensus.ZC_Modulus = "25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784" "4069182906412495150821892985591491761845028084891200728449926873928072877767359714183472702618963750149718246911" "6507761337985909570009733045974880842840179742910064245869181719511874612151517265463228221686998754918242243363" "7259085141865462043576798423387184774447920739934236584823824281198163815010674810451660377306056201619676256133" "8441436038339044149526344321901146575444541784240209246165157233507787077498171257724679629263863563732899121548" "31438167899885040445364023527381951378636564391212010397122822120720357"; consensus.ZC_MaxPublicSpendsPerTx = 637; // Assume about 220 bytes each input consensus.ZC_MaxSpendsPerTx = 7; // Assume about 20kb each input consensus.ZC_MinMintConfirmations = 10; consensus.ZC_MinMintFee = 1 * CENT; consensus.ZC_MinStakeDepth = 10; consensus.ZC_TimeStart = 0; // not implemented on regtest consensus.ZC_WrappedSerialsSupply = 0; // Network upgrades consensus.vUpgrades[Consensus::BASE_NETWORK].nActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE; consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT; consensus.vUpgrades[Consensus::UPGRADE_POS].nActivationHeight = 251; consensus.vUpgrades[Consensus::UPGRADE_POS_V2].nActivationHeight = 251; consensus.vUpgrades[Consensus::UPGRADE_ZC].nActivationHeight = 300; consensus.vUpgrades[Consensus::UPGRADE_ZC_V2].nActivationHeight = 300; consensus.vUpgrades[Consensus::UPGRADE_BIP65].nActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE; consensus.vUpgrades[Consensus::UPGRADE_ZC_PUBLIC].nActivationHeight = 400; consensus.vUpgrades[Consensus::UPGRADE_STAKE_MODIFIER_V2].nActivationHeight = 251; consensus.vUpgrades[Consensus::UPGRADE_TIME_PROTOCOL_V2].nActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE; consensus.vUpgrades[Consensus::UPGRADE_P2PKH_BLOCK_SIGNATURES].nActivationHeight = 300; /** * The message start string is designed to be unlikely to occur in normal data. * The characters are rarely used upper ASCII, not valid as UTF-8, and produce * a large 4-byte int at any alignment. */ pchMessageStart[0] = 0xa1; pchMessageStart[1] = 0xcf; pchMessageStart[2] = 0x7e; pchMessageStart[3] = 0xac; nDefaultPort = __PORT_REGTEST__; vFixedSeeds.clear(); //! Testnet mode doesn't have any fixed seeds. vSeeds.clear(); //! Testnet mode doesn't have any DNS seeds. } const Checkpoints::CCheckpointData& Checkpoints() const { return dataRegtest; } void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight) { assert(idx > Consensus::BASE_NETWORK && idx < Consensus::MAX_NETWORK_UPGRADES); consensus.vUpgrades[idx].nActivationHeight = nActivationHeight; } }; static CRegTestParams regTestParams; static CChainParams* pCurrentParams = 0; const CChainParams& Params() { assert(pCurrentParams); return *pCurrentParams; } CChainParams& Params(CBaseChainParams::Network network) { switch (network) { case CBaseChainParams::MAIN: return mainParams; case CBaseChainParams::TESTNET: return testNetParams; case CBaseChainParams::REGTEST: return regTestParams; default: assert(false && "Unimplemented network"); return mainParams; } } void SelectParams(CBaseChainParams::Network network) { SelectBaseParams(network); pCurrentParams = &Params(network); } bool SelectParamsFromCommandLine() { CBaseChainParams::Network network = NetworkIdFromCommandLine(); if (network == CBaseChainParams::MAX_NETWORK_TYPES) return false; SelectParams(network); return true; } void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight) { regTestParams.UpdateNetworkUpgradeParameters(idx, nActivationHeight); }
[ "root@vmi445682.contaboserver.net" ]
root@vmi445682.contaboserver.net
c13f96186a6e9d98c90204de743b3e4f99660400
ad4356680fb3f55cd45d20f2917e8dbc737ddb92
/src/Gun.h
1bf9de8c9b056073f8406c95ca502a11580b7ce5
[]
no_license
gigaplex/FlyingStringDefence
e395209e4fd7e10949156a7e5514451be3030fc2
94a0e16defd0919864f439faf0c607bc472555c8
refs/heads/master
2021-01-18T07:48:41.335952
2009-07-05T11:56:54
2009-07-05T11:56:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,036
h
/** \file Gun.h * \brief Header file for Gun class * * \author Tim Boundy * \date May 2007 */ #ifndef GUN_H #define GUN_H #include "PlayerItem.h" #include "enum.h" /** \brief The players Gun class. * * The Gun class inherits from PlayerItem and has barrels that aim at a * target. The Window class uses the location of the mouse as the target. * The Guns can only aim in a 180 degree arc, facing upwards. The guns * also allow acces to a list of all the guns and the guns alone. */ class Gun : public PlayerItem { public: Gun(double x, double y, double width); virtual ~Gun(); static const vector<Gun*>& guns(); virtual void target(double x, double y); virtual double target_x(); virtual double target_y(); virtual bool target_valid(); virtual double barrel_width(); virtual void barrel_width(double width); protected: virtual void draw(); private: static vector<Gun*> guns_; virtual void draw_gun(); double target_x_; double target_y_; double theta; double barrel_width_; bool valid_target; }; #endif
[ "gigaplex@gmail.com" ]
gigaplex@gmail.com
aad2cc7b251e8ebefdb62d1076ac2fcf7b3e4e06
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/inetsrv/iis/svcs/wp/admex/proplsts.cpp
b17a2380521e5094443cb85091e49d4dc90d507d
[]
no_license
jjzhang166/WinNT5_src_20201004
712894fcf94fb82c49e5cd09d719da00740e0436
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
refs/heads/Win2K3
2023-08-12T01:31:59.670176
2021-10-14T15:14:37
2021-10-14T15:14:37
586,134,273
1
0
null
2023-01-07T03:47:45
2023-01-07T03:47:44
null
UTF-8
C++
false
false
478
cpp
///////////////////////////////////////////////////////////////////////////// // // Copyright (c) 1996-1997 Microsoft Corporation // // Module Name: // PropLstS.cpp // // Abstract: // Stub for implementation of property list classes. // // Author: // David Potter (davidp) February 24, 1997 // // Revision History: // // Notes: // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "PropList.cpp"
[ "seta7D5@protonmail.com" ]
seta7D5@protonmail.com
6b440dd71fa3be80a6348b24cdf5d28871ca2651
bb47dd255fcb8e504b6277b99d2809314be7292d
/Programming Windows, 6th Edition/CPlusPlus/Chapter13/PointerLog/PointerLog/MainPage.xaml.cpp
e15612f61e09d8fadf5f5e5cc61ab0f23b4139f5
[]
no_license
harshalbetsol/book-examples
154869b228220803bf50cad00fca3024a84195af
4eff9c402a6e2f0ab17dc4a0d345b45cf9c6d25f
refs/heads/master
2021-09-08T02:35:16.590826
2018-03-05T04:59:51
2018-03-06T05:00:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,340
cpp
// // MainPage.xaml.cpp // Implementation of the MainPage class. // #include "pch.h" #include "MainPage.xaml.h" using namespace PointerLog; using namespace Platform; using namespace Windows::Foundation; using namespace Windows::Foundation::Collections; using namespace Windows::UI::Xaml; using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Controls::Primitives; using namespace Windows::UI::Xaml::Data; using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Media; using namespace Windows::UI::Xaml::Navigation; MainPage::MainPage() { InitializeComponent(); timer = ref new DispatcherTimer(); TimeSpan interval = { 50000000 }; timer->Interval = interval; timer->Tick += ref new EventHandler<Object^>(this, &MainPage::OnTimerTick); } void MainPage::OnClearButtonClick(Object^ sender, RoutedEventArgs^ args) { logger->Clear(); } void MainPage::OnCaptureToggleButtonChecked(Object^ sender, RoutedEventArgs^ args) { ToggleButton^ toggle = dynamic_cast<ToggleButton^>(sender); logger->CaptureOnPress = toggle->IsChecked->Value; } void MainPage::OnReleaseCapturesButtonClick(Object^ sender, RoutedEventArgs^ args) { timer->Start(); } void MainPage::OnTimerTick(Object^ sender, Object^ args) { logger->ReleasePointerCaptures(); timer->Stop(); }
[ "sungmann.cho@gmail.com" ]
sungmann.cho@gmail.com
ae9d6cf9c880e39be99854c3f88634f81eb35454
fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd
/chrome/browser/sync/test/integration/performance/extensions_sync_perf_test.cc
00175f3c9f035578d6c724601b584852a02434e6
[ "BSD-3-Clause" ]
permissive
wzyy2/chromium-browser
2644b0daf58f8b3caee8a6c09a2b448b2dfe059c
eb905f00a0f7e141e8d6c89be8fb26192a88c4b7
refs/heads/master
2022-11-23T20:25:08.120045
2018-01-16T06:41:26
2018-01-16T06:41:26
117,618,467
3
2
BSD-3-Clause
2022-11-20T22:03:57
2018-01-16T02:09:10
null
UTF-8
C++
false
false
3,721
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/macros.h" #include "chrome/browser/sync/test/integration/extensions_helper.h" #include "chrome/browser/sync/test/integration/performance/sync_timing_helper.h" #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" #include "chrome/browser/sync/test/integration/sync_test.h" using extensions_helper::AllProfilesHaveSameExtensions; using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier; using extensions_helper::DisableExtension; using extensions_helper::EnableExtension; using extensions_helper::GetInstalledExtensions; using extensions_helper::InstallExtension; using extensions_helper::InstallExtensionsPendingForSync; using extensions_helper::IsExtensionEnabled; using extensions_helper::UninstallExtension; using sync_timing_helper::PrintResult; using sync_timing_helper::TimeMutualSyncCycle; // TODO(braffert): Replicate these tests for apps. static const int kNumExtensions = 150; class ExtensionsSyncPerfTest : public SyncTest { public: ExtensionsSyncPerfTest() : SyncTest(TWO_CLIENT), extension_number_(0) {} // Adds |num_extensions| new unique extensions to |profile|. void AddExtensions(int profile, int num_extensions); // Updates the enabled/disabled state for all extensions in |profile|. void UpdateExtensions(int profile); // Uninstalls all currently installed extensions from |profile|. void RemoveExtensions(int profile); // Returns the number of currently installed extensions for |profile|. int GetExtensionCount(int profile); private: int extension_number_; DISALLOW_COPY_AND_ASSIGN(ExtensionsSyncPerfTest); }; void ExtensionsSyncPerfTest::AddExtensions(int profile, int num_extensions) { for (int i = 0; i < num_extensions; ++i) { InstallExtension(GetProfile(profile), extension_number_++); } } void ExtensionsSyncPerfTest::UpdateExtensions(int profile) { std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile)); for (std::vector<int>::iterator it = extensions.begin(); it != extensions.end(); ++it) { if (IsExtensionEnabled(GetProfile(profile), *it)) { DisableExtension(GetProfile(profile), *it); } else { EnableExtension(GetProfile(profile), *it); } } } int ExtensionsSyncPerfTest::GetExtensionCount(int profile) { return GetInstalledExtensions(GetProfile(profile)).size(); } void ExtensionsSyncPerfTest::RemoveExtensions(int profile) { std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile)); for (std::vector<int>::iterator it = extensions.begin(); it != extensions.end(); ++it) { UninstallExtension(GetProfile(profile), *it); } } IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, P0) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; int num_default_extensions = GetExtensionCount(0); int expected_extension_count = num_default_extensions + kNumExtensions; AddExtensions(0, kNumExtensions); base::TimeDelta dt = TimeMutualSyncCycle(GetClient(0), GetClient(1)); InstallExtensionsPendingForSync(GetProfile(1)); ASSERT_EQ(expected_extension_count, GetExtensionCount(1)); PrintResult("extensions", "add_extensions", dt); UpdateExtensions(0); dt = TimeMutualSyncCycle(GetClient(0), GetClient(1)); ASSERT_EQ(expected_extension_count, GetExtensionCount(1)); PrintResult("extensions", "update_extensions", dt); RemoveExtensions(0); dt = TimeMutualSyncCycle(GetClient(0), GetClient(1)); ASSERT_EQ(num_default_extensions, GetExtensionCount(1)); PrintResult("extensions", "delete_extensions", dt); }
[ "jacob-chen@iotwrt.com" ]
jacob-chen@iotwrt.com
4a7095c150aa6546c1b3283842b10c5af91211ad
bd1fea86d862456a2ec9f56d57f8948456d55ee6
/000/112/849/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_73b.cpp
4aa8f9e7e50f5a9f7df35db97795a4614bf135d0
[]
no_license
CU-0xff/juliet-cpp
d62b8485104d8a9160f29213368324c946f38274
d8586a217bc94cbcfeeec5d39b12d02e9c6045a2
refs/heads/master
2021-03-07T15:44:19.446957
2020-03-10T12:45:40
2020-03-10T12:45:40
246,275,244
0
1
null
null
null
null
UTF-8
C++
false
false
1,854
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_73b.cpp Label Definition File: CWE761_Free_Pointer_Not_at_Start_of_Buffer.label.xml Template File: source-sinks-73b.tmpl.cpp */ /* * @description * CWE: 761 Free Pointer not at Start of Buffer * BadSource: connect_socket Read data using a connect socket (client side) * Sinks: * GoodSink: free() memory correctly at the start of the buffer * BadSink : free() memory not at the start of the buffer * Flow Variant: 73 Data flow: data passed in a list from one function to another in different source files * * */ #include "std_testcase.h" #include <list> #include <wchar.h> #define SEARCH_CHAR L'S' using namespace std; namespace CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_73 { #ifndef OMITBAD void badSink(list<wchar_t *> dataList) { /* copy data out of dataList */ wchar_t * data = dataList.back(); /* FLAW: We are incrementing the pointer in the loop - this will cause us to free the * memory block not at the start of the buffer */ for (; *data != L'\0'; data++) { if (*data == SEARCH_CHAR) { printLine("We have a match!"); break; } } free(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodB2G uses the BadSource with the GoodSink */ void goodB2GSink(list<wchar_t *> dataList) { wchar_t * data = dataList.back(); { size_t i; /* FIX: Use a loop variable to traverse through the string pointed to by data */ for (i=0; i < wcslen(data); i++) { if (data[i] == SEARCH_CHAR) { printLine("We have a match!"); break; } } free(data); } } #endif /* OMITGOOD */ } /* close namespace */
[ "frank@fischer.com.mt" ]
frank@fischer.com.mt
7ea79a9faca99141fdf6f91b2b2d5b738771b623
8aad0674a89e5b5785e3b28acd5c2a0d453bb92a
/EPSILON/core/route_planner/inc/route_planner/route_planner.h
e138141c9e55a11ab0446efc82244c902ef0c821
[ "MIT" ]
permissive
Mesywang/EPSILON_Noted
d047b9434a563d991d66f415bac48e52734cb91a
099ce4e74bd3245e89c50379bb93270b7fba99e0
refs/heads/main
2023-01-09T19:29:18.380687
2020-11-12T08:30:32
2020-11-12T08:30:32
312,210,761
3
2
null
null
null
null
UTF-8
C++
false
false
2,330
h
#ifndef _CORE_ROUTE_PLANNER_INC_ROUTE_PLANNER_H_ #define _CORE_ROUTE_PLANNER_INC_ROUTE_PLANNER_H_ #include <memory> #include <random> #include <set> #include <string> #include "common/basics/basics.h" #include "common/basics/semantics.h" #include "common/interface/planner.h" #include "common/lane/lane.h" #include "common/lane/lane_generator.h" #include "common/state/state.h" namespace planning { class RoutePlanner : public Planner { public: enum NaviMode { kRandomExpansion, kAssignedTarget }; enum NaviStatus { kReadyToGo, kInProgress, kFinished }; std::string Name() override; ErrorType Init(const std::string config) override; ErrorType RunOnce() override; void set_navi_mode(const NaviMode& mode) { navi_mode_ = mode; }; void set_ego_state(const common::State& state) { ego_state_ = state; } void set_nearest_lane_id(const int& id) { nearest_lane_id_ = id; } void set_lane_net(const common::LaneNet& lane_net) { lane_net_ = lane_net; if_get_lane_net_ = true; } std::vector<int> navi_path() const { return navi_path_; } common::Lane navi_lane() const { return navi_lane_; } bool if_get_lane_net() const { return if_get_lane_net_; } decimal_t navi_cur_arc_len() const { return navi_cur_arc_len_; } private: ErrorType GetChildLaneIds(const int lane_id, std::vector<int>* child_ids); ErrorType GetNaviPathByRandomExpansion(); bool CheckIfArriveTargetLane(); ErrorType CheckNaviProgress(); ErrorType NaviLoopRandomExpansion(); ErrorType NaviLoopAssignedTarget(); common::LaneNet lane_net_; common::State ego_state_; int nearest_lane_id_; NaviStatus navi_status_ = kReadyToGo; NaviMode navi_mode_ = kRandomExpansion; bool if_restart_ = true; bool if_get_lane_net_ = false; // decimal_t navi_path_max_length_ = 1500; decimal_t navi_path_max_length_ = 200; decimal_t navi_start_arc_length_{0.0}; // decimal_t navi_tail_remain_ = 200; decimal_t navi_path_length_{0.0}; decimal_t navi_cur_arc_len_{0.0}; std::vector<int> navi_path_; common::Lane navi_lane_; std::random_device rd_gen_; }; } // namespace planning #endif //_CORE_ROUTE_PLANNER_INC_ROUTE_PLANNER_H_
[ "wangshengyue1996@163.com" ]
wangshengyue1996@163.com
2a0871ee0463b3d0714fe9d14e53a3bb074b6fdd
b89810b94f582e87c2df08ec57a0ac7de031ceb4
/template.cpp
56fd9df97f49ca433b3ccd83794fd54fc90c704f
[]
no_license
munzir/template
b4326cb13c9a84b1899df3a43fce475288de3293
7f13fff78c30baf313986d0994490753afb36f0d
refs/heads/master
2020-06-23T02:15:17.818319
2018-11-25T03:49:20
2018-11-25T03:49:20
198,472,986
0
0
null
null
null
null
UTF-8
C++
false
false
1,764
cpp
/* * Copyright (c) 2018, Georgia Tech Research Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of the Georgia Tech Research Corporation nor * the names of its contributors may be used to endorse or * promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY GEORGIA TECH RESEARCH CORPORATION ''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 GEORGIA * TECH RESEARCH CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** * @file .cpp * @author Munzir Zafar * @date Nov 15, 2018 * @brief */ #include ".h"
[ "zafarmunzir@gmail.com" ]
zafarmunzir@gmail.com
a5a1d25a92de26718ae8a6a9fba65c5b3bba4748
6381edf348c69a4edc58b94157737c17f9f468b9
/branches/64x/windows/MVS_2015/CLIPSCLRWrapper/Source/Integration/CLIPSNET_SlotValue.cpp
34b97056797101c896a8da58be1965f6c5dcebc7
[]
no_license
Telefonica/clips
e2d6bbb511c21604538c0457dc94b0c4a282e9ec
bf5eedf91132d82e935c3a061200d2f01bc2b8ce
refs/heads/master
2021-07-20T14:20:00.623087
2020-10-06T09:45:45
2020-10-06T09:45:45
221,422,127
4
0
null
2020-10-06T09:45:47
2019-11-13T09:32:01
C
UTF-8
C++
false
false
1,939
cpp
#include "CLIPSNET_SlotValue.h" using namespace System; using namespace CLIPS; namespace CLIPSNET { /*##########################*/ /* SlotValue class methods */ /*##########################*/ SlotValue::SlotValue( String ^ slotName, String ^ contents, bool isDefault) { this->slotName = slotName; this->contents = contents; this->isDefault = isDefault; } String ^ SlotValue::ToString() { String ^ theString; theString = gcnew String("("); theString = theString->Concat(theString,slotName); theString = theString->Concat(theString," "); theString = theString->Concat(contents); theString = theString->Concat(theString,")"); return theString; } int SlotValue::GetHashCode() { int value = 0; if (slotName != nullptr) { value += slotName->GetHashCode(); } if (contents != nullptr) { value += contents->GetHashCode(); } return value; } bool SlotValue::Equals(Object ^ obj) { if ((obj == nullptr) || (GetType() != obj->GetType())) { return false; } if (! this->isDefault.Equals(((SlotValue ^ ) obj)->IsDefault)) { return false; } if (this->slotName == nullptr) { if (((SlotValue ^) obj)->slotName != nullptr) { return false; } } else { if (! this->slotName->Equals(((SlotValue ^) obj)->SlotName)) { return false; } } if (this->contents == nullptr) { if (((SlotValue ^) obj)->Contents != nullptr) { return false; } } else { if (! this->contents->Equals(((SlotValue ^) obj)->Contents)) { return false; } } return true; } SlotValue::~SlotValue() { this->!SlotValue(); } SlotValue::!SlotValue() { } };
[ "df382ef8615a9b3fdd2d1343267c3f14edce82d8" ]
df382ef8615a9b3fdd2d1343267c3f14edce82d8
1e5a06c78b5d08d93512365b81d19045ae85c9cf
ec68c973b7cd3821dd70ed6787497a0f808e18e1
/Cpp/SDK/BP_PhysicsActor_PaintCan_classes.h
6f432b6c6265ca6868a2665865e9683454fe9880
[]
no_license
Hengle/zRemnant-SDK
05be5801567a8cf67e8b03c50010f590d4e2599d
be2d99fb54f44a09ca52abc5f898e665964a24cb
refs/heads/main
2023-07-16T04:44:43.113226
2021-08-27T14:26:40
2021-08-27T14:26:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
723
h
#pragma once // Name: Remnant, Version: 1.0 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_PhysicsActor_PaintCan.BP_PhysicsActor_PaintCan_C // 0x0000 class ABP_PhysicsActor_PaintCan_C : public ABP_PhysicsActor_C { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_PhysicsActor_PaintCan.BP_PhysicsActor_PaintCan_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "zp2kshield@gmail.com" ]
zp2kshield@gmail.com
03cc745edfc948f18f176c0fd28fbd86a54937d1
e4d0657f13b3b5ef721b1a06ef1f155c015e1c0f
/Vivado/DTOFLS/DTOFLS.gen/sources_1/bd/Subsystem/ip/Subsystem_auto_us_1/sim/Subsystem_auto_us_1_sc.cpp
b909ea451098c4daad245993e90cb216a806870e
[ "MIT" ]
permissive
ndiocson/DTOF-Imaging-System
87a5613f75823928fc7635439d8129b43a5540ff
215f4db1eba6b39f9b137f797a67be904f8e60fc
refs/heads/main
2023-05-31T17:24:00.232223
2021-06-17T17:31:13
2021-06-17T17:31:13
350,418,900
0
0
null
null
null
null
UTF-8
C++
false
false
3,989
cpp
// (c) Copyright 1995-2021 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. // // DO NOT MODIFY THIS FILE. #include "Subsystem_auto_us_1_sc.h" #include "axi_dwidth_converter.h" #include <map> #include <string> Subsystem_auto_us_1_sc::Subsystem_auto_us_1_sc(const sc_core::sc_module_name& nm) : sc_core::sc_module(nm), mp_impl(NULL) { // configure connectivity manager xsc::utils::xsc_sim_manager::addInstance("Subsystem_auto_us_1", this); // initialize module xsc::common_cpp::properties model_param_props; model_param_props.addLong("C_AXI_PROTOCOL", "0"); model_param_props.addLong("C_S_AXI_ID_WIDTH", "1"); model_param_props.addLong("C_SUPPORTS_ID", "0"); model_param_props.addLong("C_AXI_ADDR_WIDTH", "32"); model_param_props.addLong("C_S_AXI_DATA_WIDTH", "32"); model_param_props.addLong("C_M_AXI_DATA_WIDTH", "64"); model_param_props.addLong("C_AXI_SUPPORTS_WRITE", "1"); model_param_props.addLong("C_AXI_SUPPORTS_READ", "0"); model_param_props.addLong("C_FIFO_MODE", "0"); model_param_props.addLong("C_S_AXI_ACLK_RATIO", "1"); model_param_props.addLong("C_M_AXI_ACLK_RATIO", "2"); model_param_props.addLong("C_AXI_IS_ACLK_ASYNC", "0"); model_param_props.addLong("C_MAX_SPLIT_BEATS", "16"); model_param_props.addLong("C_PACKING_LEVEL", "1"); model_param_props.addLong("C_SYNCHRONIZER_STAGE", "3"); model_param_props.addString("C_FAMILY", "zynq"); mp_impl = new axi_dwidth_converter("inst", model_param_props); // initialize AXI sockets target_rd_socket = mp_impl->target_rd_socket; target_wr_socket = mp_impl->target_wr_socket; initiator_rd_socket = mp_impl->initiator_rd_socket; initiator_wr_socket = mp_impl->initiator_wr_socket; } Subsystem_auto_us_1_sc::~Subsystem_auto_us_1_sc() { xsc::utils::xsc_sim_manager::clean(); delete mp_impl; }
[ "ndiocson@outlook.com" ]
ndiocson@outlook.com
02a58f2e5a14ce72009248416928f597dc4dc4e0
4f267de5c3abde3eaf3a7b89d71cd10d3abad87c
/ThirdParty/Libigl/igl/readDMAT.h
e09c492c12e02ce1531f5f0f7ef7e416e11414a4
[ "MIT" ]
permissive
MeshGeometry/IogramSource
5f627ca3102e85cd4f16801f5ee67557605eb506
a82302ccf96177dde3358456c6dc8e597c30509c
refs/heads/master
2022-02-10T19:19:18.984763
2018-01-31T20:09:08
2018-01-31T20:09:08
83,458,576
29
17
MIT
2022-02-01T13:45:33
2017-02-28T17:07:02
C++
UTF-8
C++
false
false
1,481
h
// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com> // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #ifndef IGL_READDMAT_H #define IGL_READDMAT_H #include "igl_inline.h" // .dmat is a simple ascii matrix file type, defined as follows. The first line // is always: // <#columns> <#rows> // Then the coefficients of the matrix are given separated by whitespace with // columns running fastest. // // Example: // The matrix m = [1 2 3; 4 5 6]; // corresponds to a .dmat file containing: // 3 2 // 1 4 2 5 3 6 #include <string> #include <vector> #ifndef IGL_NO_EIGEN # include <Eigen/Core> #endif namespace igl { // Read a matrix from an ascii dmat file // // Inputs: // file_name path to .dmat file // Outputs: // W eigen matrix containing read-in coefficients // Returns true on success, false on error // #ifndef IGL_NO_EIGEN template <typename DerivedW> IGL_INLINE bool readDMAT(const std::string file_name, Eigen::PlainObjectBase<DerivedW> & W); #endif // Wrapper for vector of vectors template <typename Scalar> IGL_INLINE bool readDMAT( const std::string file_name, std::vector<std::vector<Scalar> > & W); } #ifndef IGL_STATIC_LIBRARY # include "readDMAT.cpp" #endif #endif
[ "daniel.hambleton@meshconsultants.ca" ]
daniel.hambleton@meshconsultants.ca
5d56c5906fc09f24e70d29ce23febeeb36135445
106e1d34cf13ff008f59eb0dad7abcbca4deac0f
/C++程序/c++输入输出格式控制.cpp
e66f08e10d6f2f7b4fd96dce1a39d017dee8b319
[]
no_license
bynnebw/C_CPP
4a8312b2699beea2d5fe0685797f64e7f99d1a6a
6e699dd2fa1319a56288e8e682461a8eea9b6b0e
refs/heads/master
2021-05-03T14:38:03.172812
2016-08-11T08:30:08
2016-08-11T08:30:08
null
0
0
null
null
null
null
GB18030
C++
false
false
1,548
cpp
#include <iostream> #include <iomanip> // 操作符头文件 using namespace std; // 自定义 out 操作符 ostream &out(ostream &oc) { oc << setw(20); oc << setiosflags(ios::right | ios::uppercase); oc << setfill('*') << dec; return oc; } // 一般要返回一个引用 &&&&&in istream &in(istream &i) { i >> hex; cout << "请输入一个16进制数"; return i; } int main() { // 使用 ios 成员函数进行格式控制 cout.width(20); cout.setf(ios::right); cout << "wujiaying" << endl; cout.unsetf(ios::right); // 取消右对齐设置 cout.width(30); // 重新修改宽度 cout.fill('*'); // 填充符 cout.setf(ios::left); cout << "wujiaying" << endl; cout.unsetf(ios::left); cout.fill(' '); cout.width(50); cout.setf(ios::right); cout << "test" << endl; cout.unsetf(ios::right); // 正数显示 + 号 cout.width(20); cout.setf(ios::showpos | ios::right); // 分隔符进行多个设置 cout.precision(5); // 显示 n 个数字 double pi = 3.14159265358979; cout << pi << endl; cout.precision(0); cout.unsetf(ios::showpos | ios::right); // 使用操作符进行格式控制 int t = 126; cout << setw(20) << dec << t << endl; cout << setiosflags(ios::uppercase) << hex << t << endl; cout << resetiosflags(ios::uppercase) << hex << t << endl; cout << out << t << endl; // 自定义 oc 格式输出操作符 cin >> in >> t; // 自定义 in 格式输入操作符 cout << "对应的10进制是:" << t << endl; return 0; }
[ "caokun@MacBook-Pro-2.local" ]
caokun@MacBook-Pro-2.local
6fde0a1bf81a5e1bd2268eda393302e7a5b4262c
b045b167d96ad35f52bbb64835f82aa17511aae1
/src/wifi_ops.cpp
726558c8f46b6b51f780c205103de33b8324a8d6
[]
no_license
WaggleNet/WaggleRouter
383f8be4c53dbe61d21b05b524be11fe7531d970
b3d7731e426c01f96a031eecc00c1fdd407652c5
refs/heads/master
2022-12-21T20:52:10.471763
2019-11-18T21:12:44
2019-11-18T21:12:44
135,056,724
1
0
null
2022-12-08T06:15:49
2018-05-27T15:05:11
C++
UTF-8
C++
false
false
8,411
cpp
#include "wifi_ops.h" #include "config.h" ESP8266WebServer server(80); WiFiClient wclient; const String ssid_str = String("WaggleRouter_") + String(getRouterID(), HEX); const char* ssid = ssid_str.c_str(); void mode_ap_begin() { WiFi.mode(WIFI_AP); WiFi.softAP(ssid, param::get_ap_password().c_str()); Serial.println("AP Password:"); Serial.println(param::get_ap_password()); // Finally, print everything out... print_wifi_info(); } void mode_sta_begin() { WiFi.mode(WIFI_STA); auto sta_ssid = param::get_wifi_ssid(); auto sta_pwd = param::get_wifi_password(); if (sta_pwd.length() == 0) WiFi.begin(sta_ssid.c_str()); else WiFi.begin(sta_ssid.c_str(), sta_pwd.c_str()); Serial.print(F("Connecting to WiFi AP: ")); Serial.println(sta_ssid); // Serial.print(F("With password: ")); // Serial.println(sta_pwd); // Finally, print everything out... print_wifi_info(); } void route_root() { if (!(ESPTemplateProcessor(server).send("/index.html", root_processor))) server.send(404, "text/plain", "Page not found."); } void route_advanced() { if (!(ESPTemplateProcessor(server).send("/advanced.html", root_processor))) server.send(404, "text/plain", "Page not found."); } String root_processor(const String& key) { if (key == String("WIFI_STATUS_TEXT")) { if (WiFi.getMode() == WIFI_AP) return "working as AP"; switch (WiFi.status()) { case WL_CONNECTED: return "connected"; case WL_DISCONNECTED: return "disconnected"; case WL_CONNECT_FAILED: return "failed to connect"; case WL_CONNECTION_LOST: return "lost connection to"; default: return "unknown"; } } else if (key == String("WIFI_STATUS_CLASS")) { if (WiFi.getMode() == WIFI_AP) return "success"; if (WiFi.status() == WL_CONNECTED) return "success"; if (WiFi.status() == WL_CONNECT_FAILED) return "danger"; return "unknown"; } else if (key == String("RF_ADDRLIST")) { String message = "<ul class=\"list-group\">"; for (int i = 0; i < mesh.addrListTop; i++) { message += "<li class=\"list-group-item\"><strong>ID: "; message += String(mesh.addrList[i].nodeID) + "</strong>"; message += " Address: "; message += String(mesh.addrList[i].address); message += "</li>"; } message += "</ul>"; return message; } else if (key == String("RF_TRAFFIC")) { return String(trfc_counter); } else if (key == String("MQTT_STATUS_TEXT")) { if (mqtt_on) return "connected"; else return "not connected"; } else if (key == String("MQTT_STATUS_CLASS")) { if (mqtt_on) return "success"; else return "danger"; } else return "N/A"; } void route_enable_mqtt() { if (server.hasArg("address")) { mqtt_broker_address = server.arg("address"); if (server.hasArg("username")) { mqtt_username = server.arg("username"); mqtt_password = server.arg("password"); } else { mqtt_username = ""; mqtt_password = ""; } param::set_mqtt_address(mqtt_broker_address); param::set_mqtt_username(mqtt_username); param::set_mqtt_password(mqtt_password); print_mqtt_info(); server.send(200, "application/json", "{\"status\": \"success\"}"); } else { server.send(200, "application/json", "{\"status\": \"error\"}"); } } void route_addr_broker() { if (!server.hasArg("address")) { server.send(200, "application/json", "{\"status\": \"error\"}"); return; } String addr = server.arg("address"); param::set_mqtt_address(addr); if (server.hasArg("browser")) { server.sendHeader("Location", String("/advanced"), true); server.send (302, "text/plain", ""); } else server.send(200, "application/json", "{\"status\": \"success\"}"); } void route_addr_iam() { if (!server.hasArg("addr")) { server.send(200, "application/json", "{\"status\": \"error\"}"); return; } String addr = server.arg("addr"); param::set_iam_address(addr); server.send(200, "application/json", "{\"status\": \"success\"}"); } void route_mqtt_login_mqi() { String broker_addr = param::get_mqtt_address(); if (!server.hasArg("token")) goto bail; // PRE-CHECK: If custom server is set, refuse mqi auth if (broker_addr.length()) goto bail; // Also clear MQTT username and password param::set_mqtt_mqi_token(server.arg("token")); param::set_mqtt_username(""); param::set_mqtt_password(""); bail: server.send(200, "application/json", "{\"status\": \"error\"}"); return; } void route_mqtt_login() { if (server.hasArg("username")) mqtt_username = server.arg("username"); if (server.hasArg("password")) mqtt_password = server.arg("password"); param::set_mqtt_username(mqtt_username); param::set_mqtt_password(mqtt_password); if (server.hasArg("browser")) { server.sendHeader("Location", String("/advanced"), true); server.send (302, "text/plain", ""); } else server.send(200, "application/json", "{\"status\": \"error\"}"); } void route_switch_sta() { if (server.hasArg("ssid") && server.hasArg("password")) { Serial.print(F("Setting ssid to ")); Serial.println(server.arg("ssid")); param::set_wifi_ssid(server.arg("ssid")); param::set_wifi_password(server.arg("password")); } if (server.hasArg("browser")) { server.sendHeader("Location", String("/"), true); server.send(302, "text/plain", ""); } else server.send(200, "application/json", "{\"status\": \"success\"}"); ESP.restart(); } void route_switch_ap() { param::set_wifi_ssid(""); if (server.hasArg("browser")) { server.sendHeader("Location", String("/"), true); server.send(302, "text/plain", ""); } else server.send(200, "application/json", "{\"status\": \"success\"}"); ESP.restart(); } void route_scan_wifi() { int count = WiFi.scanNetworks(); String result = "{\"networks\": ["; for (int i = 0; i < count; i++) { result += "{\"name\": \""; result += WiFi.SSID(i); result += "\", \"secure\":"; if (WiFi.encryptionType(i) == ENC_TYPE_NONE) result += "false},"; else result += "true},"; } result += "]}"; server.send(200, "application/json", result); } void route_build_ver() { String ver = "{\"major\": "; ver += MAJOR_VER; ver += ", \"minor\": "; ver += MINOR_VER; ver += ", \"build\": "; ver += BUILD_VER; ver += "\"}"; server.send(200, "application/json", ver); } void route_device_info() { String info = "{\"type\": \""; info += DEVTYPE; info += "\", \"device_id\": \""; info += String(getRouterID(), HEX); info += "\"}"; Serial.println(info); server.send(200, "application/json", info); } void setup_routes() { server.on("/", route_root); server.on("/advanced", route_advanced); // TODO: Finish these methods server.on("/api/meta/info", route_device_info); server.on("/api/meta/build", route_build_ver); server.on("/api/addr/iam", route_addr_iam); server.on("/api/addr/broker", route_addr_broker); server.on("/api/wifi/scan", route_scan_wifi); server.on("/api/mqtt/login_mqi", route_mqtt_login_mqi); server.on("/api/mqtt/login", route_mqtt_login); // TODO: End todo server.on("/wifi/sta", route_switch_sta); server.on("/wifi/ap", route_switch_ap); server.onNotFound([]() { if (!handleFileRead(server.uri())) server.send(404, "text/plain", "404: Not Found"); }); } bool handleFileRead(String path) { if (path.endsWith("/")) path += "index.html"; String contentType = getContentType(path); if (SPIFFS.exists(path)) { auto f = SPIFFS.open(path, "r"); server.streamFile(f, contentType); f.close(); return true; } else return false; } void wifi_init() { Serial.println(F("[Wifi] Configuring access point...")); String ssid = param::get_wifi_ssid(); // TLDR: We kick into AP mode if there's no Wifi SSID remembered if (ssid.length()) { mode_sta_begin(); lcd.set_state(UI_GET_APP); } else { mode_ap_begin(); lcd.set_state(UI_CONN_WIFI); } setup_routes(); server.begin(); } void wifi_update() { server.handleClient(); } void print_wifi_info() { Serial.println(F("[Wifi] ********WiFi Information********")); Serial.println(WiFi.macAddress()); Serial.println(WiFi.softAPmacAddress()); if (WiFi.getMode() == WIFI_AP) { // I'm on the welcome screen, do nothing lcd.set_state(UI_GET_APP); } else { if (WiFi.status() == WL_CONNECTED) { Serial.print(F("[Wifi] Status: Connected as ")); Serial.println(WiFi.localIP()); // Connected? MQTT has authority on that screen } else { Serial.println(F("[Wifi] Status: Disconnected")); lcd.set_state(UI_CONN_WIFI); WiFi.reconnect(); } } Serial.println(F("[Wifi] ********************************")); }
[ "jimmy.xrail@me.com" ]
jimmy.xrail@me.com
26a853e4ae6084e61d104ad4601f260b1f48fe06
0988ce5a7709670e10be8f1882de21117e4c54ff
/include/desola/Cache.hpp
4fafb4df4150ee5069da1d8de6871c8f7e7019ec
[ "Artistic-1.0", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-other-permissive", "FSFUL", "MTLL", "Apache-2.0", "Artistic-2.0" ]
permissive
FrancisRussell/desola
d726987bff31d8da2dc8204b29b1ee6672713892
a469428466e4849c7c0e2009a0c50b89184cae01
refs/heads/master
2021-01-23T11:20:26.873081
2014-03-29T13:24:16
2014-03-29T13:24:16
18,237,824
2
0
null
null
null
null
UTF-8
C++
false
false
1,656
hpp
/****************************************************************************/ /* Copyright 2005-2006, Francis Russell */ /* */ /* 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 DESOLA_CACHE_HPP #define DESOLA_CACHE_HPP #include "ConfigurationManager.hpp" namespace desola { namespace detail { class Cache { public: Cache() { ConfigurationManager::getConfigurationManager().registerCache(*this); } virtual void flush() =0; virtual ~Cache() { ConfigurationManager::getConfigurationManager().unregisterCache(*this); } }; } } #endif
[ "fpr02@doc.ic.ac.uk" ]
fpr02@doc.ic.ac.uk
cf97ceff4427ebae632802b315384c45f225643d
777a75e6ed0934c193aece9de4421f8d8db01aac
/src/Providers/UNIXProviders/PackageInConnector/UNIX_PackageInConnector_LINUX.hxx
dd913526b842195019c711e1288c6bebeedc07ed
[ "MIT" ]
permissive
brunolauze/openpegasus-providers-old
20fc13958016e35dc4d87f93d1999db0eae9010a
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
refs/heads/master
2021-01-01T20:05:44.559362
2014-04-30T17:50:06
2014-04-30T17:50:06
19,132,738
1
0
null
null
null
null
UTF-8
C++
false
false
132
hxx
#ifdef PEGASUS_OS_LINUX #ifndef __UNIX_PACKAGEINCONNECTOR_PRIVATE_H #define __UNIX_PACKAGEINCONNECTOR_PRIVATE_H #endif #endif
[ "brunolauze@msn.com" ]
brunolauze@msn.com
efb524a6b0363d7ac4daaab7c2568fb4bab15db7
5ee2876b3eea7bde7669f2a7a7e9b9fe33a8d0aa
/homeworks/1/DNSCache/DNSRecord.cpp
4aa2edf60ef24ea1ea9e206f65360bfa212803b9
[]
no_license
TanyaZheleva/OOP
1c6e396c9d4d10ea1cdfbb935461b35fd96e31b9
f44c67e5df69a91a77d35668f0709954546f210d
refs/heads/master
2022-02-12T03:53:00.074713
2019-08-05T10:16:20
2019-08-05T10:16:20
180,985,027
0
0
null
null
null
null
UTF-8
C++
false
false
2,288
cpp
#include "DNSRecord.h" DNSRecord::DNSRecord() { const int defaultSize = 100; this->domainName = new char[defaultSize]; domainName[0] = '\0'; this->ipAddress = new char[defaultSize]; ipAddress[0] = '\0'; } DNSRecord::DNSRecord(const char* _domainName, const char* _ipAddress) { int domainNameSize = strlen(_domainName); int ipAddressSize = strlen(_ipAddress); this->domainName = new char[domainNameSize+1]; this->ipAddress = new char[ipAddressSize+1]; for (int i = 0; i < domainNameSize; i++) { domainName[i] = _domainName[i]; } domainName[domainNameSize] = '\0'; for (int i = 0; i < ipAddressSize; i++) { ipAddress[i] = _ipAddress[i]; } ipAddress[ipAddressSize] = '\0'; } DNSRecord::~DNSRecord() { delete[] this->domainName; delete[] this->ipAddress; } DNSRecord::DNSRecord(const DNSRecord& old) { int domainNameSize = strlen(old.domainName); domainName = new char[domainNameSize+1]; for (int i = 0; i <= domainNameSize; i++) { domainName[i] = old.domainName[i]; } int ipAddressSize = strlen(old.ipAddress); ipAddress = new char[ipAddressSize+1]; for (int i = 0; i <= ipAddressSize; i++) { ipAddress[i] = old.ipAddress[i]; } } DNSRecord& DNSRecord:: operator= (const DNSRecord& rhs) { if (this != &rhs) { delete[] domainName; int domainNameSize = strlen(rhs.domainName); domainName = new char[domainNameSize+1]; for (int i = 0; i < domainNameSize; i++) { domainName[i] = rhs.domainName[i]; } domainName[domainNameSize] = '\0'; delete[] ipAddress; int ipAddressSize = strlen(rhs.ipAddress); ipAddress = new char[ipAddressSize+1]; for (int i = 0; i < ipAddressSize; i++) { ipAddress[i] = rhs.ipAddress[i]; } ipAddress[ipAddressSize] = '\0'; } return*this; } const char* DNSRecord::getDomainName()const { return this->domainName; } const char* DNSRecord::getIPAddress()const { return this->ipAddress; } std::ostream & operator<<(std::ostream & os, const DNSRecord & records) { return os << records.domainName << " " << records.ipAddress << "\n"; } std::istream& operator>>(std::istream& is, const DNSRecord& rhs) { //rhs.domainName[10]; is.getline(rhs.domainName, 99); rhs.domainName[99] = '\0'; //rhs.ipAddress[10]; is.getline(rhs.ipAddress, 99); rhs.ipAddress[99] = '\0'; return is; }
[ "44448449+TanyaZheleva@users.noreply.github.com" ]
44448449+TanyaZheleva@users.noreply.github.com
5e24e64bd18d3117a2ea330eb0343968dca25626
733d0fc2c854accf7ff5fe4796387f77cefda8c1
/cpp/tests/copying/pack_tests.cpp
11aa505d1637bb639a0cf65f15ea3829b637f055
[ "Apache-2.0" ]
permissive
ajschmidt8/cudf
d6a199b724b8836ebf83a65fac7b564c55fd1510
3ed87f3cf3fc4c5039301c57c28bd64b062b862a
refs/heads/branch-21.08
2023-07-22T16:55:54.199271
2021-07-13T14:06:43
2021-07-13T14:06:43
241,452,538
0
0
Apache-2.0
2021-02-24T15:20:32
2020-02-18T19:47:11
Cuda
UTF-8
C++
false
false
18,909
cpp
/* * Copyright (c) 2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <cudf/copying.hpp> #include <cudf_test/base_fixture.hpp> #include <cudf_test/column_wrapper.hpp> #include <cudf_test/table_utilities.hpp> namespace cudf { namespace test { struct PackUnpackTest : public BaseFixture { void run_test(cudf::table_view const& t) { // verify pack/unpack works auto packed = pack(t); auto unpacked = unpack(packed); cudf::test::expect_tables_equal(t, unpacked); // verify pack_metadata itself works auto metadata = pack_metadata( unpacked, reinterpret_cast<uint8_t const*>(packed.gpu_data->data()), packed.gpu_data->size()); EXPECT_EQ(metadata.size(), packed.metadata_->size()); EXPECT_EQ( std::equal(metadata.data(), metadata.data() + metadata.size(), packed.metadata_->data()), true); } void run_test(std::vector<column_view> const& t) { run_test(cudf::table_view{t}); } }; // clang-format off TEST_F(PackUnpackTest, SingleColumnFixedWidth) { fixed_width_column_wrapper<int64_t> col1 ({ 1, 2, 3, 4, 5, 6, 7}, { 1, 1, 1, 0, 1, 0, 1}); this->run_test({col1}); } TEST_F(PackUnpackTest, SingleColumnFixedWidthNonNullable) { fixed_width_column_wrapper<int64_t> col1 ({ 1, 2, 3, 4, 5, 6, 7}); this->run_test({col1}); } TEST_F(PackUnpackTest, MultiColumnFixedWidth) { fixed_width_column_wrapper<int16_t> col1 ({ 1, 2, 3, 4, 5, 6, 7}, { 1, 1, 1, 0, 1, 0, 1}); fixed_width_column_wrapper<float> col2 ({ 7, 8, 6, 5, 4, 3, 2}, { 1, 0, 1, 1, 1, 1, 1}); fixed_width_column_wrapper<double> col3 ({ 8, 4, 2, 0, 7, 1, 3}, { 0, 1, 1, 1, 1, 1, 1}); this->run_test({col1, col2, col3}); } TEST_F(PackUnpackTest, MultiColumnWithStrings) { fixed_width_column_wrapper<int16_t> col1 ({ 1, 2, 3, 4, 5, 6, 7}, { 1, 1, 1, 0, 1, 0, 1}); strings_column_wrapper col2 ({"Lorem", "ipsum", "dolor", "sit", "amet", "ort", "ral"}, { 1, 0, 1, 1, 1, 0, 1}); strings_column_wrapper col3 ({"", "this", "is", "a", "column", "of", "strings"}); this->run_test({col1, col2, col3}); } // clang-format on TEST_F(PackUnpackTest, EmptyColumns) { { auto empty_string = cudf::make_empty_column(cudf::data_type{cudf::type_id::STRING}); cudf::table_view src_table({static_cast<cudf::column_view>(*empty_string)}); this->run_test(src_table); } { cudf::test::strings_column_wrapper str{"abc"}; auto empty_string = cudf::empty_like(str); cudf::table_view src_table({static_cast<cudf::column_view>(*empty_string)}); this->run_test(src_table); } { cudf::test::fixed_width_column_wrapper<int> col0; cudf::test::dictionary_column_wrapper<int> col1; cudf::test::strings_column_wrapper col2; cudf::test::lists_column_wrapper<int> col3; cudf::test::structs_column_wrapper col4({}); cudf::table_view src_table({col0, col1, col2, col3, col4}); this->run_test(src_table); } } std::vector<std::unique_ptr<column>> generate_lists(bool include_validity) { using LCW = cudf::test::lists_column_wrapper<int>; if (include_validity) { auto valids = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 2 == 0; }); cudf::test::lists_column_wrapper<int> list0{{1, 2, 3}, {4, 5}, {6}, {{7, 8}, valids}, {9, 10, 11}, LCW{}, LCW{}, {{-1, -2, -3, -4, -5}, valids}, {{100, -200}, valids}}; cudf::test::lists_column_wrapper<int> list1{{{{1, 2, 3}, valids}, {4, 5}}, {{LCW{}, LCW{}, {7, 8}, LCW{}}, valids}, {LCW{6}}, {{{7, 8}, {{9, 10, 11}, valids}, LCW{}}, valids}, {{LCW{}, {-1, -2, -3, -4, -5}}, valids}, {LCW{}}, {LCW{-10}, {-100, -200}}, {{-10, -200}, LCW{}, {8, 9}}, {LCW{8}, LCW{}, LCW{9}, {5, 6}}}; std::vector<std::unique_ptr<column>> out; out.push_back(list0.release()); out.push_back(list1.release()); return out; } cudf::test::lists_column_wrapper<int> list0{ {1, 2, 3}, {4, 5}, {6}, {7, 8}, {9, 10, 11}, LCW{}, LCW{}, {-1, -2, -3, -4, -5}, {-100, -200}}; cudf::test::lists_column_wrapper<int> list1{{{1, 2, 3}, {4, 5}}, {LCW{}, LCW{}, {7, 8}, LCW{}}, {LCW{6}}, {{7, 8}, {9, 10, 11}, LCW{}}, {LCW{}, {-1, -2, -3, -4, -5}}, {LCW{}}, {{-10}, {-100, -200}}, {{-10, -200}, LCW{}, {8, 9}}, {LCW{8}, LCW{}, LCW{9}, {5, 6}}}; std::vector<std::unique_ptr<column>> out; out.push_back(list0.release()); out.push_back(list1.release()); return out; } std::vector<std::unique_ptr<column>> generate_structs(bool include_validity) { // 1. String "names" column. std::vector<std::string> names{ "Vimes", "Carrot", "Angua", "Cheery", "Detritus", "Slant", "Fred", "Todd", "Kevin"}; std::vector<bool> names_validity{1, 1, 1, 1, 1, 1, 1, 1, 1}; strings_column_wrapper names_column(names.begin(), names.end()); // 2. Numeric "ages" column. std::vector<int> ages{5, 10, 15, 20, 25, 30, 100, 101, 102}; std::vector<bool> ages_validity = {1, 1, 1, 1, 0, 1, 0, 0, 1}; auto ages_column = include_validity ? fixed_width_column_wrapper<int>( ages.begin(), ages.end(), ages_validity.begin()) : fixed_width_column_wrapper<int>(ages.begin(), ages.end()); // 3. Boolean "is_human" column. std::vector<bool> is_human{true, true, false, false, false, false, true, true, true}; std::vector<bool> is_human_validity{1, 1, 1, 0, 1, 1, 1, 1, 0}; auto is_human_col = include_validity ? fixed_width_column_wrapper<bool>( is_human.begin(), is_human.end(), is_human_validity.begin()) : fixed_width_column_wrapper<bool>(is_human.begin(), is_human.end()); // Assemble struct column. auto const struct_validity = std::vector<bool>{1, 1, 1, 1, 1, 0, 0, 1, 0}; auto struct_column = include_validity ? structs_column_wrapper({names_column, ages_column, is_human_col}, struct_validity.begin()) : structs_column_wrapper({names_column, ages_column, is_human_col}); std::vector<std::unique_ptr<column>> out; out.push_back(struct_column.release()); return out; } std::vector<std::unique_ptr<column>> generate_struct_of_list() { // 1. String "names" column. std::vector<std::string> names{ "Vimes", "Carrot", "Angua", "Cheery", "Detritus", "Slant", "Fred", "Todd", "Kevin"}; std::vector<bool> names_validity{1, 1, 1, 1, 1, 1, 1, 1, 1}; strings_column_wrapper names_column(names.begin(), names.end()); // 2. Numeric "ages" column. std::vector<int> ages{5, 10, 15, 20, 25, 30, 100, 101, 102}; std::vector<bool> ages_validity = {1, 1, 1, 1, 0, 1, 0, 0, 1}; auto ages_column = fixed_width_column_wrapper<int>(ages.begin(), ages.end(), ages_validity.begin()); // 3. List column using LCW = cudf::test::lists_column_wrapper<cudf::string_view>; std::vector<bool> list_validity{1, 1, 1, 1, 1, 0, 1, 0, 1}; lists_column_wrapper<cudf::string_view> list( {{{"abc", "d", "edf"}, {"jjj"}}, {{"dgaer", "-7"}, LCW{}}, {LCW{}}, {{"qwerty"}, {"ral", "ort", "tal"}, {"five", "six"}}, {LCW{}, LCW{}, {"eight", "nine"}}, {LCW{}}, {{"fun"}, {"a", "bc", "def", "ghij", "klmno", "pqrstu"}}, {{"seven", "zz"}, LCW{}, {"xyzzy"}}, {LCW{"negative 3", " ", "cleveland"}}}, list_validity.begin()); // Assemble struct column. auto const struct_validity = std::vector<bool>{1, 1, 1, 1, 1, 0, 0, 1, 0}; auto struct_column = structs_column_wrapper({names_column, ages_column, list}, struct_validity.begin()); std::vector<std::unique_ptr<column>> out; out.push_back(struct_column.release()); return out; } std::vector<std::unique_ptr<column>> generate_list_of_struct() { // 1. String "names" column. std::vector<std::string> names{"Vimes", "Carrot", "Angua", "Cheery", "Detritus", "Slant", "Fred", "Todd", "Kevin", "Abc", "Def", "Xyz", "Five", "Seventeen", "Dol", "Est"}; std::vector<bool> names_validity{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1}; strings_column_wrapper names_column(names.begin(), names.end()); // 2. Numeric "ages" column. std::vector<int> ages{5, 10, 15, 20, 25, 30, 100, 101, 102, -1, -2, -3, -4, -5, -6, -7}; std::vector<bool> ages_validity = {1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1}; auto ages_column = fixed_width_column_wrapper<int>(ages.begin(), ages.end(), ages_validity.begin()); // Assemble struct column. auto const struct_validity = std::vector<bool>{1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1}; auto struct_column = structs_column_wrapper({names_column, ages_column}, struct_validity.begin()); // 3. List column std::vector<bool> list_validity{1, 1, 1, 1, 1, 0, 1, 0, 1}; cudf::test::fixed_width_column_wrapper<int> offsets{0, 1, 4, 5, 7, 7, 10, 13, 14, 16}; auto list = cudf::make_lists_column( 9, offsets.release(), struct_column.release(), 2, cudf::test::detail::make_null_mask(list_validity.begin(), list_validity.begin() + 9)); std::vector<std::unique_ptr<column>> out; out.push_back(std::move(list)); return out; } TEST_F(PackUnpackTest, Lists) { // lists { auto cols = generate_lists(false); std::vector<column_view> col_views; std::transform( cols.begin(), cols.end(), std::back_inserter(col_views), [](std::unique_ptr<column> const& col) { return static_cast<column_view>(*col); }); cudf::table_view src_table(col_views); this->run_test(src_table); } // lists with validity { auto cols = generate_lists(true); std::vector<column_view> col_views; std::transform( cols.begin(), cols.end(), std::back_inserter(col_views), [](std::unique_ptr<column> const& col) { return static_cast<column_view>(*col); }); cudf::table_view src_table(col_views); this->run_test(src_table); } } TEST_F(PackUnpackTest, Structs) { // structs { auto cols = generate_structs(false); std::vector<column_view> col_views; std::transform( cols.begin(), cols.end(), std::back_inserter(col_views), [](std::unique_ptr<column> const& col) { return static_cast<column_view>(*col); }); cudf::table_view src_table(col_views); this->run_test(src_table); } // structs with validity { auto cols = generate_structs(true); std::vector<column_view> col_views; std::transform( cols.begin(), cols.end(), std::back_inserter(col_views), [](std::unique_ptr<column> const& col) { return static_cast<column_view>(*col); }); cudf::table_view src_table(col_views); this->run_test(src_table); } } TEST_F(PackUnpackTest, NestedTypes) { // build one big table containing, lists, structs, structs<list>, list<struct> std::vector<column_view> col_views; auto lists = generate_lists(true); std::transform(lists.begin(), lists.end(), std::back_inserter(col_views), [](std::unique_ptr<column> const& col) { return static_cast<column_view>(*col); }); auto structs = generate_structs(true); std::transform(structs.begin(), structs.end(), std::back_inserter(col_views), [](std::unique_ptr<column> const& col) { return static_cast<column_view>(*col); }); auto struct_of_list = generate_struct_of_list(); std::transform(struct_of_list.begin(), struct_of_list.end(), std::back_inserter(col_views), [](std::unique_ptr<column> const& col) { return static_cast<column_view>(*col); }); auto list_of_struct = generate_list_of_struct(); std::transform(list_of_struct.begin(), list_of_struct.end(), std::back_inserter(col_views), [](std::unique_ptr<column> const& col) { return static_cast<column_view>(*col); }); cudf::table_view src_table(col_views); this->run_test(src_table); } TEST_F(PackUnpackTest, NestedEmpty) { // this produces an empty strings column with no children, // nested inside a list { auto empty_string = cudf::make_empty_column(cudf::data_type{cudf::type_id::STRING}); auto offsets = cudf::test::fixed_width_column_wrapper<int>({0, 0}); auto list = cudf::make_lists_column( 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast<cudf::column_view>(*list)}); this->run_test(src_table); } // this produces an empty strings column with children that have no data, // nested inside a list { cudf::test::strings_column_wrapper str{"abc"}; auto empty_string = cudf::empty_like(str); auto offsets = cudf::test::fixed_width_column_wrapper<int>({0, 0}); auto list = cudf::make_lists_column( 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast<cudf::column_view>(*list)}); this->run_test(src_table); } // this produces an empty lists column with children that have no data, // nested inside a list { cudf::test::lists_column_wrapper<float> listw{{1.0f, 2.0f}, {3.0f, 4.0f}}; auto empty_list = cudf::empty_like(listw); auto offsets = cudf::test::fixed_width_column_wrapper<int>({0, 0}); auto list = cudf::make_lists_column(1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast<cudf::column_view>(*list)}); this->run_test(src_table); } // this produces an empty lists column with children that have no data, // nested inside a list { cudf::test::lists_column_wrapper<float> listw{{1.0f, 2.0f}, {3.0f, 4.0f}}; auto empty_list = cudf::empty_like(listw); auto offsets = cudf::test::fixed_width_column_wrapper<int>({0, 0}); auto list = cudf::make_lists_column(1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast<cudf::column_view>(*list)}); this->run_test(src_table); } // this produces an empty struct column with children that have no data, // nested inside a list { cudf::test::fixed_width_column_wrapper<int> ints{0, 1, 2, 3, 4}; cudf::test::fixed_width_column_wrapper<float> floats{4, 3, 2, 1, 0}; auto struct_column = cudf::test::structs_column_wrapper({ints, floats}); auto empty_struct = cudf::empty_like(struct_column); auto offsets = cudf::test::fixed_width_column_wrapper<int>({0, 0}); auto list = cudf::make_lists_column( 1, offsets.release(), std::move(empty_struct), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast<cudf::column_view>(*list)}); this->run_test(src_table); } } TEST_F(PackUnpackTest, NestedSliced) { auto valids = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 2 == 0; }); using LCW = cudf::test::lists_column_wrapper<int>; cudf::test::lists_column_wrapper<int> col0{{{{1, 2, 3}, valids}, {4, 5}}, {{LCW{}, LCW{}, {7, 8}, LCW{}}, valids}, {{6, 12}}, {{{7, 8}, {{9, 10, 11}, valids}, LCW{}}, valids}, {{LCW{}, {-1, -2, -3, -4, -5}}, valids}, {LCW{}}, {{-10}, {-100, -200}}}; cudf::test::strings_column_wrapper col1{ "Vimes", "Carrot", "Angua", "Cheery", "Detritus", "Slant", "Fred"}; cudf::test::fixed_width_column_wrapper<float> col2{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f}; std::vector<std::unique_ptr<cudf::column>> children; children.push_back(std::make_unique<cudf::column>(col2)); children.push_back(std::make_unique<cudf::column>(col0)); children.push_back(std::make_unique<cudf::column>(col1)); auto col3 = cudf::make_structs_column( static_cast<cudf::column_view>(col0).size(), std::move(children), 0, rmm::device_buffer{}); cudf::table_view t({col0, col1, col2, *col3}); this->run_test(t); } TEST_F(PackUnpackTest, EmptyTable) { // no columns { cudf::table_view t; this->run_test(t); } // no rows { cudf::test::fixed_width_column_wrapper<int> a; cudf::test::strings_column_wrapper b; cudf::test::lists_column_wrapper<float> c; cudf::table_view t({a, b, c}); this->run_test(t); } } // clang-format on } // namespace test } // namespace cudf
[ "noreply@github.com" ]
noreply@github.com
ea69cde130e0843f64e414b1d09576ba296d969b
5d6c3bf3c86ecee29f3860a6b78d2f76930f8e72
/ATK/EQ/SIMD/RIAAFilter.cpp
8cb37e17a21b069a59bd7e1ebc27ce58861b6dbc
[ "BSD-3-Clause" ]
permissive
AudioBucket/AudioTK
83462d2fad4869120f6a9f36015fc0146a8bbf37
781798666685433dded9f538ae2af70372d47925
refs/heads/master
2020-03-27T13:40:08.451953
2018-05-12T13:46:34
2018-05-12T13:46:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,077
cpp
/** * \file RIAAFilter.cpp * For SIMD */ #include <simdpp/simd.h> #include <ATK/EQ/SIMD/RIAAFilter.h> #include <ATK/EQ/IIRFilter.h> #include <ATK/EQ/RIAAFilter.hxx> #include <ATK/EQ/SimpleIIRFilter.h> #include <simdpp/dispatch/dispatcher.h> #include <simdpp/dispatch/get_arch_gcc_builtin_cpu_supports.h> #include <simdpp/dispatch/get_arch_raw_cpuid.h> #include <simdpp/dispatch/get_arch_linux_cpuinfo.h> #if SIMDPP_HAS_GET_ARCH_RAW_CPUID # define SIMDPP_USER_ARCH_INFO ::simdpp::get_arch_raw_cpuid() #elif SIMDPP_HAS_GET_ARCH_GCC_BUILTIN_CPU_SUPPORTS # define SIMDPP_USER_ARCH_INFO ::simdpp::get_arch_gcc_builtin_cpu_supports() #elif SIMDPP_HAS_GET_ARCH_LINUX_CPUINFO # define SIMDPP_USER_ARCH_INFO ::simdpp::get_arch_linux_cpuinfo() #else # error "Unsupported platform" #endif namespace ATK { template class RIAACoefficients<simdpp::float64<2> >; template class InverseRIAACoefficients<simdpp::float64<2> >; template class RIAACoefficients<simdpp::float32<4> >; template class RIAACoefficients<simdpp::float64<4> >; template class InverseRIAACoefficients<simdpp::float32<4> >; template class InverseRIAACoefficients<simdpp::float64<4> >; template class RIAACoefficients<simdpp::float32<8> >; template class RIAACoefficients<simdpp::float64<8> >; template class InverseRIAACoefficients<simdpp::float32<8> >; template class InverseRIAACoefficients<simdpp::float64<8> >; template class SimpleIIRFilter<RIAACoefficients<simdpp::float64<2> > >; template class SimpleIIRFilter<InverseRIAACoefficients<simdpp::float64<2> > >; template class SimpleIIRFilter<RIAACoefficients<simdpp::float32<4> > >; template class SimpleIIRFilter<RIAACoefficients<simdpp::float64<4> > >; template class SimpleIIRFilter<InverseRIAACoefficients<simdpp::float32<4> > >; template class SimpleIIRFilter<InverseRIAACoefficients<simdpp::float64<4> > >; template class SimpleIIRFilter<RIAACoefficients<simdpp::float32<8> > >; template class SimpleIIRFilter<RIAACoefficients<simdpp::float64<8> > >; template class SimpleIIRFilter<InverseRIAACoefficients<simdpp::float32<8> > >; template class SimpleIIRFilter<InverseRIAACoefficients<simdpp::float64<8> > >; template class IIRTDF2Filter<RIAACoefficients<simdpp::float64<2> > >; template class IIRTDF2Filter<InverseRIAACoefficients<simdpp::float64<2> > >; template class IIRTDF2Filter<RIAACoefficients<simdpp::float32<4> > >; template class IIRTDF2Filter<RIAACoefficients<simdpp::float64<4> > >; template class IIRTDF2Filter<InverseRIAACoefficients<simdpp::float32<4> > >; template class IIRTDF2Filter<InverseRIAACoefficients<simdpp::float64<4> > >; template class IIRTDF2Filter<RIAACoefficients<simdpp::float32<8> > >; template class IIRTDF2Filter<RIAACoefficients<simdpp::float64<8> > >; template class IIRTDF2Filter<InverseRIAACoefficients<simdpp::float32<8> > >; template class IIRTDF2Filter<InverseRIAACoefficients<simdpp::float64<8> > >; namespace SIMDPP_ARCH_NAMESPACE { template<typename DataType, std::size_t VL> std::unique_ptr<BaseFilter> createRIAAFilter(std::size_t nb_channels) { return std::unique_ptr<BaseFilter>(new SimpleIIRFilter<RIAACoefficients<typename SIMDTypeTraits<DataType>::template SIMDType<VL> > >(nb_channels)); } template<typename DataType, std::size_t VL> std::unique_ptr<BaseFilter> createInverseRIAAFilter(std::size_t nb_channels) { return std::unique_ptr<BaseFilter>(new SimpleIIRFilter<InverseRIAACoefficients<typename SIMDTypeTraits<DataType>::template SIMDType<VL> > >(nb_channels)); } template<typename DataType, std::size_t VL> std::unique_ptr<BaseFilter> createRIAATDF2Filter(std::size_t nb_channels) { return std::unique_ptr<BaseFilter>(new IIRTDF2Filter<RIAACoefficients<typename SIMDTypeTraits<DataType>::template SIMDType<VL> > >(nb_channels)); } template<typename DataType, std::size_t VL> std::unique_ptr<BaseFilter> createInverseRIAATDF2Filter(std::size_t nb_channels) { return std::unique_ptr<BaseFilter>(new IIRTDF2Filter<InverseRIAACoefficients<typename SIMDTypeTraits<DataType>::template SIMDType<VL> > >(nb_channels)); } } SIMDPP_MAKE_DISPATCHER((template<typename DataType, std::size_t VL>) (<DataType, VL>) (std::unique_ptr<BaseFilter>) (createRIAAFilter) ((std::size_t) nb_channels)) SIMDPP_MAKE_DISPATCHER((template<typename DataType, std::size_t VL>) (<DataType, VL>) (std::unique_ptr<BaseFilter>) (createInverseRIAAFilter) ((std::size_t) nb_channels)) SIMDPP_MAKE_DISPATCHER((template<typename DataType, std::size_t VL>) (<DataType, VL>) (std::unique_ptr<BaseFilter>) (createRIAATDF2Filter) ((std::size_t) nb_channels)) SIMDPP_MAKE_DISPATCHER((template<typename DataType, std::size_t VL>) (<DataType, VL>) (std::unique_ptr<BaseFilter>) (createInverseRIAATDF2Filter) ((std::size_t) nb_channels)) SIMDPP_INSTANTIATE_DISPATCHER( (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAAFilter<double, 2>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAAFilter<double, 2>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAATDF2Filter<double, 2>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAATDF2Filter<double, 2>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAAFilter<float, 4>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAAFilter<double, 4>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAAFilter<float, 4>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAAFilter<double, 4>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAAFilter<float, 8>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAAFilter<double, 8>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAAFilter<float, 8>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAAFilter<double, 8>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAATDF2Filter<float, 4>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAATDF2Filter<double, 4>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAATDF2Filter<float, 4>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAATDF2Filter<double, 4>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAATDF2Filter<float, 8>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createRIAATDF2Filter<double, 8>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAATDF2Filter<float, 8>(std::size_t)), (template ATK_EQSIMD2_EXPORT std::unique_ptr<BaseFilter> createInverseRIAATDF2Filter<double, 8>(std::size_t))); }
[ "matthieu.brucher@gmail.com" ]
matthieu.brucher@gmail.com
6a7c287c347ae50f0478b2ff644d923240a8e4db
19463820a2fa406689cca86913334a5f19569b81
/C++/돌게임.cpp
2fac4d96b8f2254960aade7220c8f0b72dfaff88
[]
no_license
biyotteu/algorithms
de3a1cb0250b0779cc4ba256e64e46d1c642a921
e09b0cd68dd320dd2e91a2476bb4e41418dce25f
refs/heads/main
2023-07-15T15:27:31.134011
2021-09-01T08:51:09
2021-09-01T08:51:09
401,992,826
0
0
null
null
null
null
UTF-8
C++
false
false
165
cpp
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); int n; cin >> n; cout << (n%2 ? "SK" : "CY"); }
[ "32426765+biyotteu@users.noreply.github.com" ]
32426765+biyotteu@users.noreply.github.com
0e496ef012e421798401758be18233254094b6c2
cec1054f9d612e720a622a86567f10d271f1ad29
/lib/gft/src/gft_scene32.cpp
34d42a8de8eb6f4738ff93bfbd494e158997126b
[ "MIT" ]
permissive
ademirtc/bandeirantes
69df2b575c82c62f7bba298db97ec9c24b1f58f6
2dfc2ceadb555c1c40991520f450745bedf88c77
refs/heads/master
2021-01-24T18:46:49.303076
2017-03-09T23:36:33
2017-03-09T23:36:33
84,473,182
1
0
null
null
null
null
UTF-8
C++
false
false
27,681
cpp
#include "gft_scene32.h" extern "C" { #include "gft_bzlib.h" #include "nifti1_io.h" } namespace gft{ namespace Scene32{ Scene32 *Create(int xsize,int ysize,int zsize){ Scene32 *scn=NULL; int **tmp=NULL; int xysize; int i,j,p,N; scn = (Scene32 *) calloc(1,sizeof(Scene32)); if(scn == NULL) gft::Error((char *)MSG1,(char *)"Scene32::Create"); scn->xsize = xsize; scn->ysize = ysize; scn->zsize = zsize; scn->dx = 1.0; scn->dy = 1.0; scn->dz = 1.0; scn->maxval = 0; scn->n = xsize*ysize*zsize; scn->nii_hdr = NULL; //For SSE optimization we allocate a multiple of 4. N = scn->n; if(N%4!=0) N += (4-N%4); scn->data = gft::AllocIntArray(N); if(scn->data==NULL) gft::Error((char *)MSG1,(char *)"Scene32::Create"); scn->array = (int ***) calloc(zsize, sizeof(int **)); if(scn->array==NULL) gft::Error((char *)MSG1,(char *)"Scene32::Create"); tmp = (int **) calloc(zsize*ysize, sizeof(int *)); if(tmp==NULL) gft::Error((char *)MSG1,(char *)"Scene32::Create"); scn->array[0] = tmp; for(i=1; i<zsize; i++) scn->array[i] = scn->array[i-1] + ysize; xysize = xsize*ysize; for(i=0; i<zsize; i++){ for(j=0; j<ysize; j++){ p = j + i*ysize; tmp[p] = scn->data + xysize*i + xsize*j; }} return(scn); } Scene32 *Create(Scene32 *scn){ Scene32 *new_scn=NULL; new_scn = Create(scn->xsize, scn->ysize, scn->zsize); new_scn->dx = scn->dx; new_scn->dy = scn->dy; new_scn->dz = scn->dz; return new_scn; } void Destroy(Scene32 **scn){ Scene32 *aux; aux = *scn; if(aux != NULL){ if(aux->data != NULL) gft::FreeIntArray(&aux->data); if(aux->array[0] != NULL) free(aux->array[0]); if(aux->array != NULL) free(aux->array); free(aux); *scn = NULL; } } Scene32 *Clone(Scene32 *scn){ Scene32 *aux = Create(scn->xsize,scn->ysize,scn->zsize); aux->dx = scn->dx; aux->dy = scn->dy; aux->dz = scn->dz; aux->maxval = scn->maxval; memcpy(aux->data,scn->data,sizeof(int)*aux->n); return aux; } Scene32 *SubScene(Scene32 *scn, Voxel l, Voxel h){ return SubScene(scn, l.c.x, l.c.y, l.c.z, h.c.x, h.c.y, h.c.z); } Scene32 *SubScene(Scene32 *scn, int xl, int yl, int zl, int xh, int yh, int zh){ Scene32 *sub=NULL; Voxel v; int i,j; //v4si *p1,*p2; if(!IsValidVoxel(scn,xl,yl,zl)|| !IsValidVoxel(scn,xh,yh,zh)|| (xl > xh)||(yl>yh)||(zl>zh)) return NULL; sub = Create(xh-xl+1,yh-yl+1,zh-zl+1); sub->dx = scn->dx; sub->dy = scn->dy; sub->dz = scn->dz; j = 0; for(v.c.z=zl; v.c.z<=zh; v.c.z++){ for(v.c.y=yl; v.c.y<=yh; v.c.y++){ /* for(v.c.x=xl; v.c.x<=xh-3; v.c.x+=4){ i = GetVoxelAddress(scn, v); p1 = (v4si *)(&sub->data[j]); p2 = (v4si *)(&scn->data[i]); *p1 = *p2; j+=4; } for(; v.c.x <= xh; v.c.x++){ i = GetVoxelAddress(scn, v); sub->data[j] = scn->data[i]; j++; } */ v.c.x=xl; i = GetVoxelAddress(scn, v); memcpy(&sub->data[j],&scn->data[i],sizeof(int)*sub->xsize); j += sub->xsize; } } return(sub); } void Copy(Scene32 *dest, Scene32 *src){ if(dest->xsize!=src->xsize || dest->ysize!=src->ysize || dest->zsize!=src->zsize) gft::Error((char *)"Incompatible data",(char *)"Scene32::Copy"); dest->dx = src->dx; dest->dy = src->dy; dest->dz = src->dz; dest->maxval = src->maxval; memcpy(dest->data,src->data,sizeof(int)*src->n); } void Copy(Scene32 *dest, Scene32 *src, Voxel v){ int x1,y1,z1,x2,y2,z2,dx; Voxel t,u; int p,q; x1 = MAX(0, -v.c.x); x2 = MIN(src->xsize-1, dest->xsize-1 - v.c.x); dx = x2 - x1 + 1; if(dx<=0) return; y1 = MAX(0, -v.c.y); y2 = MIN(src->ysize-1, dest->ysize-1 - v.c.y); z1 = MAX(0, -v.c.z); z2 = MIN(src->zsize-1, dest->zsize-1 - v.c.z); for(t.c.z=z1; t.c.z<=z2; t.c.z++){ for(t.c.y=y1; t.c.y<=y2; t.c.y++){ t.c.x=x1; p = GetVoxelAddress(src, t); u.v = v.v + t.v; q = GetVoxelAddress(dest, u); memcpy(&dest->data[q],&src->data[p],sizeof(int)*dx); } } } void Fill(Scene32 *scn, int value){ if(value==0) memset((void *)scn->data, 0, sizeof(int)*scn->n); else{ int p; v4si v; v4si *ptr; ((int *)(&v))[0] = value; ((int *)(&v))[1] = value; ((int *)(&v))[2] = value; ((int *)(&v))[3] = value; for(p=0; p<scn->n; p+=4){ ptr = (v4si *)(&scn->data[p]); *ptr = v; } } scn->maxval = value; } Scene32 *Read(char *filename){ Scene32 *scn=NULL; FILE *fp=NULL; uchar *data8=NULL; #if _WIN32 || __BYTE_ORDER==__LITTLE_ENDIAN ushort *data16=NULL; #endif char type[10]; int i,n,v,xsize,ysize,zsize; long pos; int null; // Checking file type int len = strlen(filename); if ( (len>=4) && ((strcasecmp(filename + len - 4, ".hdr")==0) || (strcasecmp(filename + len - 4, ".img")==0))) /*return ReadScene_Analyze(filename); */ return ReadNifti1(filename); if ( (len>=8) && (strcasecmp(filename + len - 8, ".scn.bz2")==0)) return ReadCompressed(filename); if ( (len>=4) && (strcasecmp(filename + len - 4, ".nii")==0)) return ReadNifti1(filename); if ( (len>=7) && (strcasecmp(filename + len - 7, ".nii.gz")==0)) return ReadNifti1(filename); if ( (len<=4) || (strcasecmp(filename + len - 4, ".scn")!=0)) { gft::Error(MSG2,"Scene32::Read: Invalid file name or extension."); return NULL; } // Read the scn file fp = fopen(filename,"rb"); if (fp == NULL){ gft::Error(MSG2,"Scene32::Read"); } null = fscanf(fp,"%s\n",type); if((strcmp(type,"SCN")==0)){ null = fscanf(fp,"%d %d %d\n",&xsize,&ysize,&zsize); scn = Create(xsize,ysize,zsize); n = xsize*ysize*zsize; null = fscanf(fp,"%f %f %f\n",&scn->dx,&scn->dy,&scn->dz); null = fscanf(fp,"%d",&v); pos = ftell(fp); //printf(" current relative position in file: %ld\n",pos);/// fseek(fp,(pos+1)*sizeof(char),SEEK_SET); // +1 for the EOL \n character not included in last fscanf() call if (v==8){ data8 = gft::AllocUCharArray(n); null = fread(data8,sizeof(uchar),n,fp); for (i=0; i < n; i++) scn->data[i] = (int) data8[i]; gft::FreeUCharArray(&data8); } else if (v==16) { // assuming that data was written with LITTLE-ENDIAN Byte ordering, i.e. LSB...MSB #if _WIN32 || __BYTE_ORDER==__LITTLE_ENDIAN // for PCs, Intel microprocessors (LITTLE-ENDIAN too) -> no change data16 = gft::AllocUShortArray(n); null = fread(data16,sizeof(ushort),n,fp); for (i=0; i < n; i++) scn->data[i] = (int) data16[i]; gft::FreeUShortArray(&data16); #else // for Motorola, IBM, SUN (BIG-ENDIAN) -> SWAp Bytes! gft::Warning("Data is converted from LITTLE to BIG-ENDIAN","Scene32::Read"); data8 = gft::AllocUCharArray(2*n); null = fread(data8,sizeof(uchar),2*n,fp); j=0; for (i=0; i < 2*n; i+=2) { scn->data[j] = (int) data8[i] + 256 * (int) data8[i+1]; j++; } gft::FreeUCharArray(&data8); #endif } else { /* n = 32 */ //Warning("32-bit data. Values may be wrong (little/big endian byte ordering)","ReadScene"); n = xsize*ysize*zsize; null = fread(scn->data,sizeof(int),n,fp); } fclose(fp); } else { fprintf(stderr,"Input scene must be SCN\n"); exit(-1); } scn->maxval = GetMaximumValue(scn); return(scn); } Scene32 *ReadCompressed(char *filename) { FILE *f; gft_BZFILE *b; int nBuf; char *buf; int bzerror; Scene32 *scn = NULL; int xsize, ysize, zsize, pos; int nbits, hdr_size, i, p; float dx, dy, dz; char s[ 2000 ]; f = fopen ( filename, "r" ); buf = ( char* ) calloc( 1025, sizeof( char ) ); if ( !f ) { printf("Erro ao abrir arquivos!\n"); return NULL; } b = gft_BZ2_bzReadOpen ( &bzerror, f, 0, 0, NULL, 0 ); if ( bzerror != gft_BZ_OK ) { gft_BZ2_bzReadClose ( &bzerror, b ); fclose(f); printf("Erro ao abrir cena compactada!\n"); return NULL; } nBuf = gft_BZ2_bzRead ( &bzerror, b, buf, 1024 ); hdr_size = 0; if ( ( ( bzerror == gft_BZ_OK ) || ( bzerror == gft_BZ_STREAM_END ) ) && (nBuf > 0) ) { sscanf( buf, "%[^\n]\n%d %d %d\n%f %f %f\n%d\n", s, &xsize, &ysize, &zsize, &dx, &dy, &dz, &nbits ); //printf( "s:%s, xsize:%d, ysize:%d, zsize:%d, dx:%f, dy:%f, dz:%f, bits:%d\n", s, xsize, ysize, zsize, dx, dy, dz, nbits ); if ( strcmp( s, "SCN" ) != 0 ) { printf( "Format must by a compressed scene.\nFound %s\n", s ); return 0; } scn = Create( xsize, ysize, zsize ); scn->dx = dx; scn->dy = dy; scn->dz = dz; hdr_size = strlen( s ) + strlen( "\n" ); for( i = 0; i < 3; i++ ) { sscanf( &buf[ hdr_size ], "%[^\n]\n", s ); hdr_size += strlen( s ) + strlen( "\n" ); } } else { printf("Erro ao ler cena compactada!\n"); return 0; } gft_BZ2_bzReadClose ( &bzerror, b ); rewind( f ); b = gft_BZ2_bzReadOpen ( &bzerror, f, 0, 0, NULL, 0 ); if ( bzerror != gft_BZ_OK ) { gft_BZ2_bzReadClose ( &bzerror, b ); fclose(f); printf("Erro ao abrir cena compactada!\n"); return NULL; } nBuf = gft_BZ2_bzRead ( &bzerror, b, buf, hdr_size ); p = 0; do { nBuf = gft_BZ2_bzRead ( &bzerror, b, buf, 1024 ); if ( ( ( bzerror == gft_BZ_OK ) || ( bzerror == gft_BZ_STREAM_END ) ) && ( nBuf > 0 ) ) { pos = 0; while( pos < nBuf - ( nbits / 8 ) + 1 ) { if( nbits == 8 ) { scn->data[ p ] = ( int ) ( ( uchar ) buf[ pos ] ); pos++; } else if( nbits == 16 ) { scn->data[ p ] = ( int ) ( ( ( uchar ) buf[ pos + 1 ] ) * 256 + ( ( uchar ) buf[ pos ] ) ); if ( scn->data[ p ] < 0 ) printf("dado negativo.\n"); pos += 2; } else { scn->data[ p ] = ( int ) ( ( uchar ) buf[ pos + 3 ] ); for( i = 2; i >= 0; i-- ) { scn->data[ p ] = scn->data[ p ] * 256 + ( ( uchar ) buf[ pos + i ] ); } pos +=4; } p++; } } } while( bzerror == gft_BZ_OK ); //printf( "scn->n:%d, p:%d\n", scn->n, p ); GetMaximumValue( scn ); //printf( "max=%d\n", scn->maxval ); gft_BZ2_bzReadClose ( &bzerror, b ); fclose(f); free(buf); //printf( "fim!\n" ); return( scn ); } Scene32 *ReadNifti1(char *filename){ nifti_image *nii; Scene32 *scn; float max; int p; nii = nifti_image_read( filename , 1 ); scn = Create( nii->nx, nii->ny, nii->nz ); scn->dx = nii->dx; scn->dy = nii->dy; scn->dz = nii->dz; scn->nii_hdr = nii; if( ( nii->datatype == NIFTI_TYPE_COMPLEX64 ) || ( nii->datatype == NIFTI_TYPE_FLOAT64 ) || ( nii->datatype == NIFTI_TYPE_RGB24 ) || ( nii->datatype == NIFTI_TYPE_RGB24 ) || ( nii->datatype >= NIFTI_TYPE_UINT32 ) || ( nii->dim[ 0 ] < 3 ) || ( nii->dim[ 0 ] > 4 ) ) { printf( "Error: Data format not supported, or header is corrupted.\n" ); printf( "Data that is NOT supported: complex, double, RGB, unsigned integer of 32 bits, temporal series and statistical images.\n" ); exit( -1 ); } if( nii->datatype == NIFTI_TYPE_INT32 ) { //printf( "Integer src image.\n" ); memcpy( scn->data, nii->data, nii->nvox * nii->nbyper ); } if( ( nii->datatype == NIFTI_TYPE_INT16 ) || ( nii->datatype == NIFTI_TYPE_UINT16 ) ) { //printf( "Short src image.\n" ); for( p = 0; p < scn->n; p++ ) { scn->data[ p ] = ( ( unsigned short* ) nii->data )[ p ]; } } if( ( nii->datatype == NIFTI_TYPE_INT8 ) || ( nii->datatype == NIFTI_TYPE_UINT8 ) ) { //printf( "Char src image.\n" ); for( p = 0; p < scn->n; p++ ) { scn->data[ p ] = ( ( unsigned char* ) nii->data )[ p ]; } } if( nii->datatype == NIFTI_TYPE_FLOAT32 ) { //printf( "Float src image.\n" ); // max used to set data to integer range without loosing its precision. max = 0.0; for( p = 0; p < scn->n; p++ ) { if( max < ( ( float* ) nii->data )[ p ] ) { max = ( ( float* ) nii->data )[ p ]; } } nii->flt_conv_factor = 10000.0 / max; for( p = 0; p < scn->n; p++ ) { scn->data[ p ] = ROUND( ( ( float* ) nii->data )[ p ] * nii->flt_conv_factor ); } } free( nii->data ); nii->data = NULL; return( scn ); } void Write(Scene32 *scn, char *filename){ FILE *fp=NULL; int Imax; int i,n; uchar *data8 =NULL; ushort *data16=NULL; // Checking file type int len = strlen(filename); if ( (len>=4) && ((strcasecmp(filename + len - 4, ".hdr")==0) || (strcasecmp(filename + len - 4, ".img")==0))) { //WriteScene_Analyze(scn, filename); WriteNifti1(scn, filename); return; } if ( (len>=8) && (strcasecmp(filename + len - 8, ".scn.bz2")==0)) { WriteCompressed(scn, filename); return; } if ( (len>=7) && (strcasecmp(filename + len - 7, ".nii.gz")==0)) { WriteNifti1( scn, filename ); return; } if ( (len>=4) && (strcasecmp(filename + len - 4, ".nii")==0)) { WriteNifti1( scn, filename ); return; } if ( (len<=4) || (strcasecmp(filename + len - 4, ".scn")!=0)) { gft::Error(MSG2,"Scene32::Write: Invalid file name or extension."); } // Writing the scn file fp = fopen(filename,"wb"); if(fp == NULL) gft::Error((char *)MSG2,(char *)"Scene32::Write"); fprintf(fp,"SCN\n"); fprintf(fp,"%d %d %d\n",scn->xsize,scn->ysize,scn->zsize); fprintf(fp,"%f %f %f\n",scn->dx,scn->dy,scn->dz); Imax = GetMaximumValue(scn); n = scn->n; if(Imax < 256) { fprintf(fp,"%d\n",8); data8 = gft::AllocUCharArray(n); for(i=0; i<n; i++) data8[i] = (uchar) scn->data[i]; fwrite(data8,sizeof(uchar),n,fp); gft::FreeUCharArray(&data8); } else if(Imax < 65536) { fprintf(fp,"%d\n",16); data16 = gft::AllocUShortArray(n); for(i=0; i<n; i++) data16[i] = (ushort) scn->data[i]; fwrite(data16,sizeof(ushort),n,fp); gft::FreeUShortArray(&data16); } else { fprintf(fp,"%d\n",32); fwrite(scn->data,sizeof(int),n,fp); } fclose(fp); } void WriteCompressed(Scene32 *scn, char *filename) { FILE *f; //FILE *in; gft_BZFILE *b; //int nBuf = 1024; //char buf[1024]; int Imax, n, i; int bzerror; char *data; uchar *data8; ushort *data16; f = fopen( filename, "wb" ); //if ( ( !f ) || ( !in ) ) { if ( !f ) { printf("Error on opening the compressed file %s\n", filename); return; } b = gft_BZ2_bzWriteOpen( &bzerror, f, 9, 0, 30 ); if (bzerror != gft_BZ_OK) { gft_BZ2_bzWriteClose ( &bzerror, b, 0, 0, 0 ); fclose(f); printf("Error on opening the file %s\n", filename); } //while ( (bzerror == gft_BZ_OK ) && (nBuf > 0) ) { if (bzerror == gft_BZ_OK) { /* get data to write into buf, and set nBuf appropriately */ data = (char*) calloc(200, sizeof(int)); n = scn->xsize*scn->ysize*scn->zsize; sprintf(data,"SCN\n"); sprintf(data,"%s%d %d %d\n",data,scn->xsize,scn->ysize,scn->zsize); sprintf(data,"%s%f %f %f\n",data,scn->dx,scn->dy,scn->dz); Imax = GetMaximumValue(scn); if (Imax < 256) { //printf("8bits\n"); sprintf(data,"%s%d\n",data,8); gft_BZ2_bzWrite ( &bzerror, b, data, strlen( data ) ); data8 = gft::AllocUCharArray(n); for (i=0; i < n; i++) data8[i] = (uchar) scn->data[i]; gft_BZ2_bzWrite ( &bzerror, b, data8, n ); gft::FreeUCharArray(&data8); } else if (Imax < 65536) { //printf("16bits\n"); sprintf(data,"%s%d\n",data,16); gft_BZ2_bzWrite ( &bzerror, b, data, strlen( data ) ); data16 = gft::AllocUShortArray(n); for (i=0; i < n; i++) data16[i] = (ushort) scn->data[i]; gft_BZ2_bzWrite ( &bzerror, b, data16, 2 * n ); gft::FreeUShortArray(&data16); } else { //printf("32bits\n"); sprintf(data,"%s%d\n",data,32); gft_BZ2_bzWrite ( &bzerror, b, data, strlen( data ) ); gft_BZ2_bzWrite ( &bzerror, b, scn->data, 4 * n ); } free(data); /* nBuf = fread(buf, sizeof(char), 1024, in); if (nBuf > 0) gft_BZ2_bzWrite ( &bzerror, b, buf, nBuf ); if (bzerror == gft_BZ_IO_ERROR) { break; } */ } gft_BZ2_bzWriteClose ( &bzerror, b, 0, 0, 0 ); fclose(f); if (bzerror == gft_BZ_IO_ERROR) { printf("Error on writing to %s\n", filename); } } void WriteNifti1(Scene32 *scn, char *filename){ nifti_image *nii; int len; int p; nii = scn->nii_hdr; if( nii == NULL ) gft::Error( MSG4, "Scene32::WriteNifti1" ); if( nii->data != NULL ) free( nii->data ); nii->data = calloc( nii->nbyper, nii->nvox ); if( nii->datatype == NIFTI_TYPE_INT32 ) { //printf( "Integer src image.\n" ); memcpy( nii->data, scn->data, nii->nvox * nii->nbyper ); } else if( ( nii->datatype == NIFTI_TYPE_INT16 ) || ( nii->datatype == NIFTI_TYPE_UINT16 ) ) { //printf( "Short src image.\n" ); for( p = 0; p < scn->n; p++ ) { ( ( unsigned short* ) nii->data )[ p ] = scn->data[ p ]; } } else if( ( nii->datatype == NIFTI_TYPE_INT8 ) || ( nii->datatype == NIFTI_TYPE_INT8 ) || ( nii->datatype == NIFTI_TYPE_UINT8 ) ) { //printf( "Char src image.\n" ); for( p = 0; p < scn->n; p++ ) { ( ( unsigned char* ) nii->data )[ p ] = scn->data[ p ]; } } else if( nii->datatype == NIFTI_TYPE_FLOAT32 ) { //printf( "Float src image.\n" ); // max used to set data to integer range without loosing its precision. for( p = 0; p < scn->n; p++ ) { ( ( float* ) nii->data )[ p ] = scn->data[ p ] / nii->flt_conv_factor; } } else gft::Error( MSG5, "Scene32::WriteNifti1" ); len = strlen( filename ); if( ( strcasecmp( filename + len - 4, ".hdr" ) == 0 ) || ( strcasecmp( filename + len - 4, ".img" ) == 0 ) ) nii->nifti_type = NIFTI_FTYPE_NIFTI1_2; else nii->nifti_type = NIFTI_FTYPE_NIFTI1_1; nifti_set_filenames( nii, filename, 0, nii->byteorder ); nifti_image_write( nii ); free( nii->data ); nii->data = NULL; } float GetValue_trilinear(Scene32 *scn, float x,float y, float z){ int px,py,pz,i1,i2; float dx,dy,dz; int nbx=0,nby=0,nbz=0; float p1,p2,p3,p4,p5,p6,res; if(x>scn->xsize-1||y>scn->ysize-1||z>scn->zsize-1||x<0||y<0||z<0) gft::Error((char *)"Out-of-bounds", (char *)"Scene32::GetValue_trilinear"); px = (int)x; dx=x-px; py = (int)y; dy=y-py; pz = (int)z; dz=z-pz; // If it's not on the border, it has a neighour ahead. if(px<scn->xsize-1) nbx=1; if(py<scn->ysize-1) nby=1; if(pz<scn->zsize-1) nbz=1; // 1st: Interpolate in Z i1 = scn->data[GetVoxelAddress(scn,px,py,pz)]; i2 = scn->data[GetVoxelAddress(scn,px,py,pz+nbz)]; p1 = i1 + dz*(i2-i1); i1 = scn->data[GetVoxelAddress(scn,px+nbx,py,pz)]; i2 = scn->data[GetVoxelAddress(scn,px+nbx,py,pz+nbz)]; p2 = i1 + dz*(i2-i1); i1 = scn->data[GetVoxelAddress(scn,px,py+nby,pz)]; i2 = scn->data[GetVoxelAddress(scn,px,py+nby,pz+nbz)]; p3 = i1 + dz*(i2-i1); i1 = scn->data[GetVoxelAddress(scn,px+nbx,py+nby,pz)]; i2 = scn->data[GetVoxelAddress(scn,px+nbx,py+nby,pz+nbz)]; p4 = i1 + dz*(i2-i1); // 2nd: Interpolate in X p5 = p1 + dx*(p2-p1); p6 = p3 + dx*(p4-p3); // 3rd: Interpolate in Y res = p5 + dy*(p6-p5); return res; } // return the nearest voxel. int GetValue_nn(Scene32 *scn, float x, float y, float z){ Voxel v; if(x>scn->xsize-1||y>scn->ysize-1||z>scn->zsize-1|| x<(float)0||y<(float)0||z<(float)0) gft::Error((char *)"Out-of-bounds", (char *)"Scene32::GetValue_nn"); v.c.x=(int)(x+0.5); v.c.y=(int)(y+0.5); v.c.z=(int)(z+0.5); return scn->array[v.c.z][v.c.y][v.c.x]; } int GetMaximumValue(Scene32 *scn){ int p,Imax; Imax = INT_MIN; for(p=0; p<scn->n; p++) { if(scn->data[p] > Imax) Imax = scn->data[p]; } scn->maxval = Imax; return(Imax); } int GetMinimumValue(Scene32 *scn){ int p,Imin; Imin = INT_MAX; for(p=0; p<scn->n; p++){ if(scn->data[p] < Imin) Imin = scn->data[p]; } return(Imin); } gft::Image32::Image32 *GetSliceX(Scene32 *scn, int x){ gft::Image32::Image32 *img; int z,y; img = gft::Image32::Create(scn->ysize, scn->zsize); for(z = 0; z < scn->zsize; z++){ for(y = 0; y < scn->ysize; y++){ img->array[z][y] = scn->array[z][y][x]; } } return img; } gft::Image32::Image32 *GetSliceY(Scene32 *scn, int y){ gft::Image32::Image32 *img; int z,x; img = gft::Image32::Create(scn->xsize, scn->zsize); for(z = 0; z < scn->zsize; z++){ for(x = 0; x < scn->xsize; x++){ img->array[z][x] = scn->array[z][y][x]; } } return img; } gft::Image32::Image32 *GetSliceZ(Scene32 *scn, int z){ gft::Image32::Image32 *img; int *data; img = gft::Image32::Create(scn->xsize, scn->ysize); data = scn->data + z*img->n; memcpy(img->data, data, sizeof(int)*img->n); return img; } void PutSliceX(Scene32 *scn, Image32::Image32 *img, int x){ int z,y; for(z = 0; z < scn->zsize; z++){ for(y = 0; y < scn->ysize; y++){ scn->array[z][y][x] = img->array[z][y]; } } } void PutSliceY(Scene32 *scn, Image32::Image32 *img, int y){ int z,x; for(z = 0; z < scn->zsize; z++){ for(x = 0; x < scn->xsize; x++){ scn->array[z][y][x] = img->array[z][x]; } } } void PutSliceZ(Scene32 *scn, Image32::Image32 *img, int z){ int *data; data = scn->data + z*img->n; memcpy(data, img->data, sizeof(int)*img->n); } void MBB(Scene32 *scn, Voxel *l, Voxel *h){ Voxel v; l->c.x = scn->xsize-1; l->c.y = scn->ysize-1; l->c.z = scn->zsize-1; h->c.x = 0; h->c.y = 0; h->c.z = 0; for(v.c.z=0; v.c.z<scn->zsize; v.c.z++) for(v.c.y=0; v.c.y<scn->ysize; v.c.y++) for(v.c.x=0; v.c.x<scn->xsize; v.c.x++) if(scn->data[GetVoxelAddress(scn,v)] > 0){ if(v.c.x < l->c.x) l->c.x = v.c.x; if(v.c.y < l->c.y) l->c.y = v.c.y; if(v.c.z < l->c.z) l->c.z = v.c.z; if(v.c.x > h->c.x) h->c.x = v.c.x; if(v.c.y > h->c.y) h->c.y = v.c.y; if(v.c.z > h->c.z) h->c.z = v.c.z; } } Scene32 *MBB(Scene32 *scn){ Voxel lower,higher; Scene32 *mbb=NULL; MBB(scn, &lower, &higher); mbb = SubScene(scn, lower.c.x, lower.c.y, lower.c.z, higher.c.x, higher.c.y, higher.c.z); return(mbb); } Scene32 *AddFrame(Scene32 *scn, int sz, int value){ Scene32 *fscn; int y, z,*dst,*src,nbytes,offset1, offset2; fscn = Create(scn->xsize+(2*sz), scn->ysize+(2*sz), scn->zsize+(2*sz)); fscn->dx = scn->dx; fscn->dy = scn->dy; fscn->dz = scn->dz; Fill(fscn,value); nbytes = sizeof(int)*scn->xsize; offset1 = 0; offset2 = GetVoxelAddress(fscn, sz, sz, sz); for(z=0; z<scn->zsize; z++){ src = scn->data+offset1; dst = fscn->data+offset2; for(y=0; y<scn->ysize; y++){ memcpy(dst,src,nbytes); src += scn->xsize; dst += fscn->xsize; } offset1 += scn->xsize*scn->ysize; offset2 += fscn->xsize*fscn->ysize; } return(fscn); } Scene32 *RemFrame(Scene32 *fscn, int sz){ Scene32 *scn; int y,z,*dst,*src,nbytes,offset; scn = Create(fscn->xsize-(2*sz), fscn->ysize-(2*sz), fscn->zsize-(2*sz)); scn->dx = fscn->dx; scn->dy = fscn->dy; scn->dz = fscn->dz; nbytes = sizeof(int)*scn->xsize; offset = GetVoxelAddress(fscn, sz, sz, sz); src = fscn->data+offset; dst = scn->data; for(z=0; z<scn->zsize; z++,src+=2*sz*fscn->xsize) { for(y=0; y<scn->ysize; y++,src+=fscn->xsize,dst+=scn->xsize){ memcpy(dst,src,nbytes); } } return(scn); } Scene16::Scene16 *ConvertTo16(Scene32 *scn){ Scene16::Scene16 *scn16; int p; scn16 = Scene16::Create(scn->xsize, scn->ysize, scn->zsize); scn16->dx = scn->dx; scn16->dy = scn->dy; scn16->dz = scn->dz; for(p=0; p<scn->n; p++){ scn16->data[p] = (ushort)scn->data[p]; } return scn16; } Scene8::Scene8 *ConvertTo8(Scene32 *scn){ Scene8::Scene8 *scn8; int p; scn8 = Scene8::Create(scn->xsize, scn->ysize, scn->zsize); scn8->dx = scn->dx; scn8->dy = scn->dy; scn8->dz = scn->dz; for(p=0; p<scn->n; p++){ scn8->data[p] = (uchar)scn->data[p]; } return scn8; } Scene64::Scene64 *ComputeIntegralScene(Scene32 *scn){ Scene64::Scene64 *Iscn=NULL; int p,q,i,j,k; int xysize = scn->xsize*scn->ysize; long long sum; //iscn = CreateScene(scn->xsize, scn->ysize, scn->zsize); //SetVoxelSize(iscn, scn->dx, scn->dy, scn->dz); Iscn = Scene64::Create(scn->xsize, scn->ysize, scn->zsize); for(k = 0; k < scn->zsize; k++){ for(i = 0; i < scn->ysize; i++){ for(j = 0; j < scn->xsize; j++){ p = GetVoxelAddress(scn,j,i,k); sum = scn->data[p]; if(k-1>=0){ q = p-xysize; sum += Iscn->data[q]; } if(j-1>=0){ q = p-1; sum += Iscn->data[q]; } if(j-1>=0 && k-1>=0){ q = p-1-xysize; sum -= Iscn->data[q]; } if(i-1>=0){ q = p-scn->xsize; sum += Iscn->data[q]; } if(i-1>=0 && k-1>=0){ q = p-scn->xsize-xysize; sum -= Iscn->data[q]; } if(j-1>=0 && i-1>=0){ q = p-1-scn->xsize; sum -= Iscn->data[q]; } if(j-1>=0 && i-1>=0 && k-1>=0){ q = p-1-scn->xsize-xysize; sum += Iscn->data[q]; } Iscn->data[p] = sum; } } } return Iscn; } //The dimensions of the window (i.e., xsize,ysize,zsize) //should be given in millimeters. void DrawWindow(Scene32 *scn, int val, float xsize, float ysize, float zsize, Voxel u){ Voxel v,lo,hi; int dx,dy,dz; int q; float sum = 0.0; float vol; dx = ROUND(xsize/(scn->dx*2.0)); dy = ROUND(ysize/(scn->dy*2.0)); dz = ROUND(zsize/(scn->dz*2.0)); //--------------------- hi.c.x = MIN(u.c.x+dx, scn->xsize-1); hi.c.y = MIN(u.c.y+dy, scn->ysize-1); hi.c.z = MIN(u.c.z+dz, scn->zsize-1); lo.c.x = MAX(u.c.x-dx-1, 0); lo.c.y = MAX(u.c.y-dy-1, 0); lo.c.z = MAX(u.c.z-dz-1, 0); for(v.c.x = lo.c.x+1; v.c.x <= hi.c.x; v.c.x++){ for(v.c.y = lo.c.y+1; v.c.y <= hi.c.y; v.c.y++){ for(v.c.z = lo.c.z+1; v.c.z <= hi.c.z; v.c.z++){ q = GetVoxelAddress(scn,v.c.x,v.c.y,v.c.z); scn->data[q] = val; } } } } //The dimensions of the window (i.e., xsize,ysize,zsize) //should be given in millimeters. int WindowNvoxels(Scene32 *scn, float xsize, float ysize, float zsize){ int nw,dx,dy,dz; dx = ROUND(xsize/(scn->dx*2.0)); dy = ROUND(ysize/(scn->dy*2.0)); dz = ROUND(zsize/(scn->dz*2.0)); nw = (2*dx + 1)*(2*dy + 1)*(2*dz + 1); return nw; } } //end Scene32 namespace } //end gft namespace
[ "marcostejadac@gmail.com" ]
marcostejadac@gmail.com
425f5e973a3ffdd599b51c402b8ba2ce6f98882b
977d4da2e2deed9b56a2911cc0c761f4b11f7f20
/TPS/Intermediate/Build/Win64/UE4Editor/Inc/TPS/Projectile.gen.cpp
552ad6563c2484de7f00c2730bf202bf5b164cc9
[]
no_license
kingwaykingway/Final-Year-Project
dd5f2e074940ff3c64098b45dcca4d6e075abdd2
62c22570e2d3fe97d9774df3d2765c810c4410c0
refs/heads/main
2023-05-07T17:15:20.876848
2021-05-29T13:08:02
2021-05-29T13:08:02
315,126,322
0
0
null
null
null
null
UTF-8
C++
false
false
22,646
cpp
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. /*=========================================================================== Generated code exported from UnrealHeaderTool. DO NOT modify this manually! Edit the corresponding .h files instead! ===========================================================================*/ #include "UObject/GeneratedCppIncludes.h" #include "TPS/Projectile.h" #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable : 4883) #endif PRAGMA_DISABLE_DEPRECATION_WARNINGS void EmptyLinkFunctionForGeneratedCodeProjectile() {} // Cross Module References TPS_API UClass* Z_Construct_UClass_AProjectile_NoRegister(); TPS_API UClass* Z_Construct_UClass_AProjectile(); ENGINE_API UClass* Z_Construct_UClass_AActor(); UPackage* Z_Construct_UPackage__Script_TPS(); TPS_API UFunction* Z_Construct_UFunction_AProjectile_FireInDirection(); COREUOBJECT_API UScriptStruct* Z_Construct_UScriptStruct_FVector(); ENGINE_API UClass* Z_Construct_UClass_USoundAttenuation_NoRegister(); ENGINE_API UClass* Z_Construct_UClass_USoundBase_NoRegister(); ENGINE_API UClass* Z_Construct_UClass_UParticleSystem_NoRegister(); ENGINE_API UClass* Z_Construct_UClass_UProjectileMovementComponent_NoRegister(); ENGINE_API UClass* Z_Construct_UClass_UArrowComponent_NoRegister(); ENGINE_API UClass* Z_Construct_UClass_USphereComponent_NoRegister(); // End Cross Module References void AProjectile::StaticRegisterNativesAProjectile() { UClass* Class = AProjectile::StaticClass(); static const FNameNativePtrPair Funcs[] = { { "FireInDirection", &AProjectile::execFireInDirection }, }; FNativeFunctionRegistrar::RegisterFunctions(Class, Funcs, ARRAY_COUNT(Funcs)); } struct Z_Construct_UFunction_AProjectile_FireInDirection_Statics { struct Projectile_eventFireInDirection_Parms { FVector ShootDirection; }; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_ShootDirection_MetaData[]; #endif static const UE4CodeGen_Private::FStructPropertyParams NewProp_ShootDirection; static const UE4CodeGen_Private::FPropertyParamsBase* const PropPointers[]; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam Function_MetaDataParams[]; #endif static const UE4CodeGen_Private::FFunctionParams FuncParams; }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UFunction_AProjectile_FireInDirection_Statics::NewProp_ShootDirection_MetaData[] = { { "NativeConst", "" }, }; #endif const UE4CodeGen_Private::FStructPropertyParams Z_Construct_UFunction_AProjectile_FireInDirection_Statics::NewProp_ShootDirection = { "ShootDirection", nullptr, (EPropertyFlags)0x0010000008000182, UE4CodeGen_Private::EPropertyGenFlags::Struct, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(Projectile_eventFireInDirection_Parms, ShootDirection), Z_Construct_UScriptStruct_FVector, METADATA_PARAMS(Z_Construct_UFunction_AProjectile_FireInDirection_Statics::NewProp_ShootDirection_MetaData, ARRAY_COUNT(Z_Construct_UFunction_AProjectile_FireInDirection_Statics::NewProp_ShootDirection_MetaData)) }; const UE4CodeGen_Private::FPropertyParamsBase* const Z_Construct_UFunction_AProjectile_FireInDirection_Statics::PropPointers[] = { (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UFunction_AProjectile_FireInDirection_Statics::NewProp_ShootDirection, }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UFunction_AProjectile_FireInDirection_Statics::Function_MetaDataParams[] = { { "ModuleRelativePath", "Projectile.h" }, { "ToolTip", "Function that initializes the projectile's velocity in the shoot direction." }, }; #endif const UE4CodeGen_Private::FFunctionParams Z_Construct_UFunction_AProjectile_FireInDirection_Statics::FuncParams = { (UObject*(*)())Z_Construct_UClass_AProjectile, nullptr, "FireInDirection", sizeof(Projectile_eventFireInDirection_Parms), Z_Construct_UFunction_AProjectile_FireInDirection_Statics::PropPointers, ARRAY_COUNT(Z_Construct_UFunction_AProjectile_FireInDirection_Statics::PropPointers), RF_Public|RF_Transient|RF_MarkAsNative, (EFunctionFlags)0x04C20401, 0, 0, METADATA_PARAMS(Z_Construct_UFunction_AProjectile_FireInDirection_Statics::Function_MetaDataParams, ARRAY_COUNT(Z_Construct_UFunction_AProjectile_FireInDirection_Statics::Function_MetaDataParams)) }; UFunction* Z_Construct_UFunction_AProjectile_FireInDirection() { static UFunction* ReturnFunction = nullptr; if (!ReturnFunction) { UE4CodeGen_Private::ConstructUFunction(ReturnFunction, Z_Construct_UFunction_AProjectile_FireInDirection_Statics::FuncParams); } return ReturnFunction; } UClass* Z_Construct_UClass_AProjectile_NoRegister() { return AProjectile::StaticClass(); } struct Z_Construct_UClass_AProjectile_Statics { static UObject* (*const DependentSingletons[])(); static const FClassFunctionLinkInfo FuncInfo[]; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam Class_MetaDataParams[]; #endif #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_StartLocation_MetaData[]; #endif static const UE4CodeGen_Private::FStructPropertyParams NewProp_StartLocation; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_PenetrationPower_MetaData[]; #endif static const UE4CodeGen_Private::FFloatPropertyParams NewProp_PenetrationPower; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_MaxPenetrationTolerance_MetaData[]; #endif static const UE4CodeGen_Private::FFloatPropertyParams NewProp_MaxPenetrationTolerance; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_Range_MetaData[]; #endif static const UE4CodeGen_Private::FFloatPropertyParams NewProp_Range; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_Damage_MetaData[]; #endif static const UE4CodeGen_Private::FUnsizedIntPropertyParams NewProp_Damage; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_DealsDamage_MetaData[]; #endif static void NewProp_DealsDamage_SetBit(void* Obj); static const UE4CodeGen_Private::FBoolPropertyParams NewProp_DealsDamage; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_HitSoundAttenuation_MetaData[]; #endif static const UE4CodeGen_Private::FObjectPropertyParams NewProp_HitSoundAttenuation; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_HitSound_MetaData[]; #endif static const UE4CodeGen_Private::FObjectPropertyParams NewProp_HitSound; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_HitEmitter_MetaData[]; #endif static const UE4CodeGen_Private::FObjectPropertyParams NewProp_HitEmitter; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_EmitterScale_MetaData[]; #endif static const UE4CodeGen_Private::FFloatPropertyParams NewProp_EmitterScale; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_BulletHoleSize_MetaData[]; #endif static const UE4CodeGen_Private::FFloatPropertyParams NewProp_BulletHoleSize; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_ProjectileMovementComponent_MetaData[]; #endif static const UE4CodeGen_Private::FObjectPropertyParams NewProp_ProjectileMovementComponent; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_Orientation_MetaData[]; #endif static const UE4CodeGen_Private::FObjectPropertyParams NewProp_Orientation; #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam NewProp_Collider_MetaData[]; #endif static const UE4CodeGen_Private::FObjectPropertyParams NewProp_Collider; static const UE4CodeGen_Private::FPropertyParamsBase* const PropPointers[]; static const FCppClassTypeInfoStatic StaticCppClassTypeInfo; static const UE4CodeGen_Private::FClassParams ClassParams; }; UObject* (*const Z_Construct_UClass_AProjectile_Statics::DependentSingletons[])() = { (UObject* (*)())Z_Construct_UClass_AActor, (UObject* (*)())Z_Construct_UPackage__Script_TPS, }; const FClassFunctionLinkInfo Z_Construct_UClass_AProjectile_Statics::FuncInfo[] = { { &Z_Construct_UFunction_AProjectile_FireInDirection, "FireInDirection" }, // 2520509725 }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::Class_MetaDataParams[] = { { "IncludePath", "Projectile.h" }, { "ModuleRelativePath", "Projectile.h" }, }; #endif #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_StartLocation_MetaData[] = { { "Category", "Projectile" }, { "ModuleRelativePath", "Projectile.h" }, { "ToolTip", "Location where the projectile is launched." }, }; #endif const UE4CodeGen_Private::FStructPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_StartLocation = { "StartLocation", nullptr, (EPropertyFlags)0x0010000000000014, UE4CodeGen_Private::EPropertyGenFlags::Struct, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, StartLocation), Z_Construct_UScriptStruct_FVector, METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_StartLocation_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_StartLocation_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_PenetrationPower_MetaData[] = { { "Category", "Penetration" }, { "ModuleRelativePath", "Projectile.h" }, }; #endif const UE4CodeGen_Private::FFloatPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_PenetrationPower = { "PenetrationPower", nullptr, (EPropertyFlags)0x0010000000000004, UE4CodeGen_Private::EPropertyGenFlags::Float, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, PenetrationPower), METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_PenetrationPower_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_PenetrationPower_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_MaxPenetrationTolerance_MetaData[] = { { "Category", "Penetration" }, { "ModuleRelativePath", "Projectile.h" }, }; #endif const UE4CodeGen_Private::FFloatPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_MaxPenetrationTolerance = { "MaxPenetrationTolerance", nullptr, (EPropertyFlags)0x0010000000000015, UE4CodeGen_Private::EPropertyGenFlags::Float, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, MaxPenetrationTolerance), METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_MaxPenetrationTolerance_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_MaxPenetrationTolerance_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_Range_MetaData[] = { { "Category", "Basic" }, { "ModuleRelativePath", "Projectile.h" }, }; #endif const UE4CodeGen_Private::FFloatPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_Range = { "Range", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Float, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, Range), METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_Range_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_Range_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_Damage_MetaData[] = { { "Category", "Basic" }, { "ModuleRelativePath", "Projectile.h" }, { "ToolTip", "Damage dealt by the projectile." }, }; #endif const UE4CodeGen_Private::FUnsizedIntPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_Damage = { "Damage", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Int, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, Damage), METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_Damage_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_Damage_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_DealsDamage_MetaData[] = { { "Category", "Projectile" }, { "ModuleRelativePath", "Projectile.h" }, { "ToolTip", "True if the projectile deals damage by hitting targets." }, }; #endif void Z_Construct_UClass_AProjectile_Statics::NewProp_DealsDamage_SetBit(void* Obj) { ((AProjectile*)Obj)->DealsDamage = 1; } const UE4CodeGen_Private::FBoolPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_DealsDamage = { "DealsDamage", nullptr, (EPropertyFlags)0x0010000000000004, UE4CodeGen_Private::EPropertyGenFlags::Bool | UE4CodeGen_Private::EPropertyGenFlags::NativeBool, RF_Public|RF_Transient|RF_MarkAsNative, 1, sizeof(bool), sizeof(AProjectile), &Z_Construct_UClass_AProjectile_Statics::NewProp_DealsDamage_SetBit, METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_DealsDamage_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_DealsDamage_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_HitSoundAttenuation_MetaData[] = { { "Category", "Effect" }, { "ModuleRelativePath", "Projectile.h" }, }; #endif const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_HitSoundAttenuation = { "HitSoundAttenuation", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, HitSoundAttenuation), Z_Construct_UClass_USoundAttenuation_NoRegister, METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_HitSoundAttenuation_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_HitSoundAttenuation_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_HitSound_MetaData[] = { { "Category", "Effect" }, { "ModuleRelativePath", "Projectile.h" }, }; #endif const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_HitSound = { "HitSound", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, HitSound), Z_Construct_UClass_USoundBase_NoRegister, METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_HitSound_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_HitSound_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_HitEmitter_MetaData[] = { { "Category", "Effect" }, { "ModuleRelativePath", "Projectile.h" }, }; #endif const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_HitEmitter = { "HitEmitter", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, HitEmitter), Z_Construct_UClass_UParticleSystem_NoRegister, METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_HitEmitter_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_HitEmitter_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_EmitterScale_MetaData[] = { { "Category", "Effect" }, { "ModuleRelativePath", "Projectile.h" }, }; #endif const UE4CodeGen_Private::FFloatPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_EmitterScale = { "EmitterScale", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Float, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, EmitterScale), METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_EmitterScale_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_EmitterScale_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_BulletHoleSize_MetaData[] = { { "Category", "Effect" }, { "ModuleRelativePath", "Projectile.h" }, }; #endif const UE4CodeGen_Private::FFloatPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_BulletHoleSize = { "BulletHoleSize", nullptr, (EPropertyFlags)0x0010000000000005, UE4CodeGen_Private::EPropertyGenFlags::Float, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, BulletHoleSize), METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_BulletHoleSize_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_BulletHoleSize_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_ProjectileMovementComponent_MetaData[] = { { "Category", "Component" }, { "EditInline", "true" }, { "ModuleRelativePath", "Projectile.h" }, { "ToolTip", "Projectile movement component." }, }; #endif const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_ProjectileMovementComponent = { "ProjectileMovementComponent", nullptr, (EPropertyFlags)0x00100000000a001d, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, ProjectileMovementComponent), Z_Construct_UClass_UProjectileMovementComponent_NoRegister, METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_ProjectileMovementComponent_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_ProjectileMovementComponent_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_Orientation_MetaData[] = { { "Category", "Component" }, { "EditInline", "true" }, { "ModuleRelativePath", "Projectile.h" }, { "ToolTip", "xxx" }, }; #endif const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_Orientation = { "Orientation", nullptr, (EPropertyFlags)0x00100000000a001d, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, Orientation), Z_Construct_UClass_UArrowComponent_NoRegister, METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_Orientation_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_Orientation_MetaData)) }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_AProjectile_Statics::NewProp_Collider_MetaData[] = { { "AllowPrivateAccess", "true" }, { "Category", "Component" }, { "EditInline", "true" }, { "ModuleRelativePath", "Projectile.h" }, { "ToolTip", "xxx" }, }; #endif const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UClass_AProjectile_Statics::NewProp_Collider = { "Collider", nullptr, (EPropertyFlags)0x00100000000a001d, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(AProjectile, Collider), Z_Construct_UClass_USphereComponent_NoRegister, METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::NewProp_Collider_MetaData, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::NewProp_Collider_MetaData)) }; const UE4CodeGen_Private::FPropertyParamsBase* const Z_Construct_UClass_AProjectile_Statics::PropPointers[] = { (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_StartLocation, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_PenetrationPower, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_MaxPenetrationTolerance, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_Range, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_Damage, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_DealsDamage, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_HitSoundAttenuation, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_HitSound, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_HitEmitter, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_EmitterScale, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_BulletHoleSize, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_ProjectileMovementComponent, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_Orientation, (const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_AProjectile_Statics::NewProp_Collider, }; const FCppClassTypeInfoStatic Z_Construct_UClass_AProjectile_Statics::StaticCppClassTypeInfo = { TCppClassTypeTraits<AProjectile>::IsAbstract, }; const UE4CodeGen_Private::FClassParams Z_Construct_UClass_AProjectile_Statics::ClassParams = { &AProjectile::StaticClass, nullptr, &StaticCppClassTypeInfo, DependentSingletons, FuncInfo, Z_Construct_UClass_AProjectile_Statics::PropPointers, nullptr, ARRAY_COUNT(DependentSingletons), ARRAY_COUNT(FuncInfo), ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::PropPointers), 0, 0x009000A0u, METADATA_PARAMS(Z_Construct_UClass_AProjectile_Statics::Class_MetaDataParams, ARRAY_COUNT(Z_Construct_UClass_AProjectile_Statics::Class_MetaDataParams)) }; UClass* Z_Construct_UClass_AProjectile() { static UClass* OuterClass = nullptr; if (!OuterClass) { UE4CodeGen_Private::ConstructUClass(OuterClass, Z_Construct_UClass_AProjectile_Statics::ClassParams); } return OuterClass; } IMPLEMENT_CLASS(AProjectile, 3056404978); template<> TPS_API UClass* StaticClass<AProjectile>() { return AProjectile::StaticClass(); } static FCompiledInDefer Z_CompiledInDefer_UClass_AProjectile(Z_Construct_UClass_AProjectile, &AProjectile::StaticClass, TEXT("/Script/TPS"), TEXT("AProjectile"), false, nullptr, nullptr, nullptr); DEFINE_VTABLE_PTR_HELPER_CTOR(AProjectile); PRAGMA_ENABLE_DEPRECATION_WARNINGS #ifdef _MSC_VER #pragma warning (pop) #endif
[ "1040123009@qq.com" ]
1040123009@qq.com
fb4213e07c926c2d1e74b5f15f729da246d673d3
4aaebb67a64e50bb77243fb85abd96dd8d3238d4
/lib/graph/Module.cpp
f993746bbc55f6bc71842cc72482680f647681aa
[]
no_license
viridia/Mint
2c2711a7d9295e0dd4089689f1a101c9c4a795eb
d49cd1c223f766c81417f8ac5dad9a2b754eb804
refs/heads/master
2021-01-25T09:00:39.247366
2012-01-08T21:03:10
2012-01-08T21:03:10
2,691,713
7
1
null
null
null
null
UTF-8
C++
false
false
2,442
cpp
/* ================================================================== * * Module * ================================================================== */ #include "mint/graph/Module.h" #include "mint/graph/Object.h" #include "mint/intrinsic/TypeRegistry.h" #include "mint/project/Project.h" #include "mint/support/OStream.h" namespace mint { /// Default constructor Module::Module(StringRef moduleName, Project * project) : Object(NK_MODULE, Location(), TypeRegistry::moduleType()) , _textBuffer(NULL) , _project(project) { setName(String::create(moduleName)); } void Module::setAttribute(String * name, Node * value) { _attrs[name] = value; _keyOrder.push_back(name); } Node * Module::getAttributeValue(StringRef name) const { Attributes::const_iterator it = _attrs.find_as(name); if (it != _attrs.end()) { return it->second; } for (ImportList::const_iterator m = _importScopes.end(); m != _importScopes.begin(); ) { --m; Node * value = (*m)->getAttributeValue(name); if (value != NULL) { return value; } } return Node::getAttributeValue(name); } bool Module::getAttribute(StringRef name, AttributeLookup & result) const { Attributes::const_iterator it = _attrs.find_as(name); if (it != _attrs.end()) { result.value = it->second; result.foundScope = const_cast<Module *>(this); result.definition = NULL; return true; } for (ImportList::const_iterator m = _importScopes.end(); m != _importScopes.begin(); ) { --m; if ((*m)->getAttribute(name, result)) { return true; } } return Node::getAttribute(name, result); } void Module::dump() const { StringRef moduleName = *name(); if (moduleName.empty()) { moduleName = "<main>"; } console::err() << "module " << moduleName; console::err() << " {\n"; for (Attributes::const_iterator it = _attrs.begin(), itEnd = _attrs.end(); it != itEnd; ++it) { console::err() << " " << it->first << " = " << it->second << "\n"; } console::err() << "}\n"; } void Module::print(OStream & strm) const { StringRef moduleName = *name(); if (moduleName.empty()) { moduleName = "<main>"; } console::err() << "module " << moduleName; } void Module::trace() const { Object::trace(); markArray(ArrayRef<Object *>(_importScopes)); markArray(ArrayRef<Node *>(_actions)); markArray(ArrayRef<String *>(_keyOrder)); safeMark(_textBuffer); safeMark(_project); } }
[ "viridia@gmail.com" ]
viridia@gmail.com
6be12baef17181d3faeeecc1d1b80a819e2f61ae
006f035d65012b7c5af15d54716407a276a096a8
/dependencies/include/cgal/CGAL/RS/polynomial_1_impl.h
ded70d38a92a15f2acb430f214ea84c751b6c4ac
[]
no_license
rosecodym/space-boundary-tool
4ce5b67fd96ec9b66f45aca60e0e69f4f8936e93
300db4084cd19b092bdf2e8432da065daeaa7c55
refs/heads/master
2020-12-24T06:51:32.828579
2016-08-12T16:13:51
2016-08-12T16:13:51
65,566,229
7
0
null
null
null
null
UTF-8
C++
false
false
2,993
h
// Copyright (c) 2006-2008 Inria Lorraine (France). All rights reserved. // // This file is part of CGAL (www.cgal.org); you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 3 of the License, // or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/releases/CGAL-4.1-branch/Algebraic_kernel_d/include/CGAL/RS/polynomial_1_impl.h $ // $Id: polynomial_1_impl.h 67093 2012-01-13 11:22:39Z lrineau $ // // Author: Luis Peñaranda <luis.penaranda@gmx.com> #ifndef CGAL_RS_POLYNOMIAL_1_IMPL_H #define CGAL_RS_POLYNOMIAL_1_IMPL_H namespace CGAL{ // constructor from a container of sorted coefficients template <class InputIterator> RS_polynomial_1::RS_polynomial_1(InputIterator first,InputIterator last){ // count the number of elements in the container int elements=0; InputIterator it; for(it=first;it!=last;++it) ++elements; // now we create the polynomial if(elements){ _degree=elements-1; create_storage(elements); int i=0; for(it=first;it!=last;++it) mpz_init_set(coef(i++),Gmpz(*it).mpz()); }else{ _degree=0; create_storage(1); mpz_init_set_ui(coef(0),0); } } template <class T> RS_polynomial_1 RS_polynomial_1::operator*(const T &n)const{ RS_polynomial_1 r(*this); return (r*=n); } template<class T> RS_polynomial_1& RS_polynomial_1::operator*=(const T &s){ Gmpz z(s); return (*this*=z); } template <class T> RS_polynomial_1 RS_polynomial_1::operator/(const T &d)const{ RS_polynomial_1 r(*this); return (r/=d); } template<class T> RS_polynomial_1& RS_polynomial_1::operator/=(const T &d){ Gmpz z(d); return (*this/=z); } template<class T> Sign RS_polynomial_1::sign_at(const T &x)const{ T y(leading_coefficient()); int d=get_degree_static(); for(int i=1;i<d+1;++i) y=y*x+T(coef(d-i)); if(y>0) return POSITIVE; if(y<0) return NEGATIVE; return ZERO; } template<> inline Sign RS_polynomial_1::sign_at(const Gmpfr &x)const{ return sign_mpfr(x.fr()); } template<class T> T RS_polynomial_1::operator()(const T &x)const{ T y(leading_coefficient()); int d=get_degree_static(); for(int i=1;i<d+1;++i) y=y*x+T(coef(d-i)); return y; } } // namespace CGAL #endif // CGAL_RS_POLYNOMIAL_1_IMPL_H
[ "cmrose@lbl.gov" ]
cmrose@lbl.gov
919b5097633bb8b4501e3bab45ba9c2c5c643899
af0ecafb5428bd556d49575da2a72f6f80d3d14b
/CodeJamCrawler/dataset/12_19299_35.cpp
5029fea38013a945332d76727845500a51e575dd
[]
no_license
gbrlas/AVSP
0a2a08be5661c1b4a2238e875b6cdc88b4ee0997
e259090bf282694676b2568023745f9ffb6d73fd
refs/heads/master
2021-06-16T22:25:41.585830
2017-06-09T06:32:01
2017-06-09T06:32:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,075
cpp
#include <vector> #include <iostream> #include <string> #include <map> #include <fstream> using namespace std; int main() { ifstream infile("B-large.in"); vector<int> res; int input_num; infile>>input_num; int k=0; while(k<input_num) { int googler_num; int surp_num; int req; infile>>googler_num; infile>>surp_num; infile>>req; int result = 0; int used_surp = 0; for(int i = 0; i<googler_num;i++) { int score; infile>>score; if(score == 0) { if(req == 0) result++; else ; } else if( req*3<= score) result++; else if((req-1)*3<score) result++; else if((req-2)*3+2<=score) { if(surp_num>used_surp) { used_surp++; result++; } } else ; } res.push_back(result); k++; } infile.close(); infile.clear(); ofstream outfile; outfile.open("output.txt"); for(int i = 0; i<res.size();i++) { outfile<<"Case #"<<i+1<<": "<<res[i]<<endl; } outfile.close(); outfile.clear(); }
[ "nikola.mrzljak@fer.hr" ]
nikola.mrzljak@fer.hr
efa4a3f313d53617f9a432ba833685d637e44f54
04b1803adb6653ecb7cb827c4f4aa616afacf629
/content/common/input/synthetic_smooth_scroll_gesture_params.h
d590892d409b2e22c7c2a55dacf73ef47d350998
[ "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
1,356
h
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_COMMON_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_PARAMS_H_ #define CONTENT_COMMON_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_PARAMS_H_ #include <vector> #include "content/common/content_export.h" #include "content/common/input/synthetic_gesture_params.h" #include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/vector2d.h" namespace content { struct CONTENT_EXPORT SyntheticSmoothScrollGestureParams : public SyntheticGestureParams { public: SyntheticSmoothScrollGestureParams(); SyntheticSmoothScrollGestureParams( const SyntheticSmoothScrollGestureParams& other); ~SyntheticSmoothScrollGestureParams() override; GestureType GetGestureType() const override; gfx::PointF anchor; std::vector<gfx::Vector2dF> distances; // Positive X/Y to scroll left/up. bool prevent_fling; // Defaults to true. float speed_in_pixels_s; float fling_velocity_x; float fling_velocity_y; bool precise_scrolling_deltas; bool scroll_by_page; static const SyntheticSmoothScrollGestureParams* Cast( const SyntheticGestureParams* gesture_params); }; } // namespace content #endif // CONTENT_COMMON_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_PARAMS_H_
[ "sunny.nam@samsung.com" ]
sunny.nam@samsung.com
1825ef1852fd46862a76b23d928e31c38c6799c4
dfecde4bf7fe18a2f016ef57f76a727b8b482ad4
/modules/stack/src/stack.cpp
1a28c7f2329c56ef50053eaa2e14852bf787671d
[ "CC-BY-4.0" ]
permissive
vla5924-practice/development-tools
04967a92280022e73b612fdc1e0189e3f7dc7940
c7eccc8c41cc770673f1a51b7e82938f3690e052
refs/heads/main
2023-05-14T23:46:58.455672
2021-06-07T12:57:14
2021-06-07T12:57:14
346,111,308
0
0
null
2021-04-20T21:19:32
2021-03-09T18:53:36
C++
UTF-8
C++
false
false
764
cpp
// Copyright 2021 Gruzdeva Diana #include "include/stack.h" Stack::Stack() { top = nullptr; } Stack::~Stack() { while (!isEmpty()) { pop(); } } double Stack::peek() { if (!isEmpty()) { return top->data; } else { throw "Stack is empty"; } } void Stack::pop() { if (!isEmpty()) { NodeStack *tmp; tmp = top; top = top->next; tmp->next = nullptr; tmp = nullptr; } else { throw "Stack is empty"; } } void Stack::push(const double &element) { if (top == nullptr) { top = new NodeStack; top->next = nullptr; top->data = element; } else { NodeStack *tmp = new NodeStack; tmp->data = element; tmp->next = top; top = tmp; } } bool Stack::isEmpty() { return (top == nullptr); }
[ "noreply@github.com" ]
noreply@github.com
0b768a17bd8cae8616438d449845e3d5de6d367f
081c75d11a4a8eb139f1685f087d9cc85a4fa072
/tests/simd/index/simd_index.cpp
0b7743de277610d69546e93db00cf1211d8a4a22
[]
no_license
alifahrri/nmtools
c0a9d63b4101193b484f3e05bce606d58c3b85e2
fa8a45bc3ddb373b7f547dfea3c2c7bea3056e06
refs/heads/master
2023-08-28T19:36:41.814434
2023-08-20T08:28:40
2023-08-20T08:28:40
190,819,342
7
0
null
2023-08-20T08:28:41
2019-06-07T22:43:35
C++
UTF-8
C++
false
false
50,521
cpp
#include "nmtools/array/eval/simd/index.hpp" #include "nmtools/array/index/product.hpp" #include "nmtools/testing/doctest.hpp" namespace nm = nmtools; namespace ix = nm::index; namespace meta = nm::meta; TEST_CASE("binary_2d_simd_shape(case1)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{1ul,8ul}; auto rhs_shape = nmtools_array{2ul,1ul}; auto out_shape = nmtools_array{2ul,8ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{2ul,2ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd_shape(case2)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{1ul,8ul}; auto rhs_shape = nmtools_array{4ul,1ul}; auto out_shape = nmtools_array{4ul,8ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{4ul,2ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd_shape(case3)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{1ul,10ul}; auto rhs_shape = nmtools_array{2ul,1ul}; auto out_shape = nmtools_array{2ul,10ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{2ul,4ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd_shape(case4)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{1ul,3ul}; auto rhs_shape = nmtools_array{4ul,1ul}; auto out_shape = nmtools_array{4ul,3ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{4ul,3ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd_shape(case5)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{1ul,3ul}; auto rhs_shape = nmtools_array{4ul,1ul}; auto out_shape = nmtools_array{4ul,3ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{4ul,3ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd_shape(case6)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{2ul,5ul}; auto rhs_shape = nmtools_array{2ul,5ul}; auto out_shape = nmtools_array{2ul,5ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{2ul,2ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd_shape(case7)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{2ul,5ul}; auto rhs_shape = nmtools_array{1ul,5ul}; auto out_shape = nmtools_array{2ul,5ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{2ul,2ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd_shape(case8)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{1ul,5ul}; auto rhs_shape = nmtools_array{2ul,5ul}; auto out_shape = nmtools_array{2ul,5ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{2ul,2ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd_shape(case9)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{1ul,5ul}; auto rhs_shape = nmtools_array{5ul,1ul}; auto out_shape = nmtools_array{5ul,5ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{5ul,2ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd_shape(case10)" * doctest::test_suite("index::binary_2d_simd_shape")) { auto lhs_shape = nmtools_array{5ul,1ul}; auto rhs_shape = nmtools_array{1ul,5ul}; auto out_shape = nmtools_array{5ul,5ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto shape = ix::binary_2d_simd_shape(n_elem_pack,out_shape,lhs_shape,rhs_shape); auto expect = nmtools_array{5ul,2ul}; NMTOOLS_ASSERT_EQUAL( shape, expect ); } TEST_CASE("binary_2d_simd(case1)" * doctest::test_suite("index::binary_2d_simd")) { auto lhs_shape = nmtools_array{1ul,8ul}; auto rhs_shape = nmtools_array{2ul,1ul}; auto out_shape = nmtools_array{2ul,8ul}; auto simd_shape = nmtools_array{2ul,2ul}; auto n_elem_pack = meta::as_type<4ul>{}; { auto simd_indices = nmtools_array{0ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{1ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 8 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 12 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } } TEST_CASE("binary_2d_simd(case2)" * doctest::test_suite("index::binary_2d_simd")) { auto lhs_shape = nmtools_array{1ul,8ul}; auto rhs_shape = nmtools_array{4ul,1ul}; auto out_shape = nmtools_array{4ul,8ul}; auto simd_shape = nmtools_array{4ul,2ul}; auto n_elem_pack = meta::as_type<4ul>{}; { auto simd_indices = nmtools_array{0ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{1ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 8 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 12 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{2ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 16 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 2 ); } } { auto simd_indices = nmtools_array{2ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 20 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 2 ); } } { auto simd_indices = nmtools_array{3ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 24 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 3 ); } } { auto simd_indices = nmtools_array{3ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 28 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 3 ); } } } TEST_CASE("binary_2d_simd(case3)" * doctest::test_suite("index::binary_2d_simd")) { auto lhs_shape = nmtools_array{1ul,10ul}; auto rhs_shape = nmtools_array{2ul,1ul}; auto out_shape = nmtools_array{2ul,10ul}; auto simd_shape = nmtools_array{2ul,4ul}; auto n_elem_pack = meta::as_type<4ul>{}; { auto simd_indices = nmtools_array{0ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,2ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 8 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 8 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,3ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 9 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 9 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{1ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 10 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 14 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,2ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 18 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 8 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,3ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 19 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 9 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } } TEST_CASE("binary_2d_simd(case4)" * doctest::test_suite("index::binary_2d_simd")) { auto lhs_shape = nmtools_array{1ul,3ul}; auto rhs_shape = nmtools_array{4ul,1ul}; auto out_shape = nmtools_array{4ul,3ul}; auto simd_shape = nmtools_array{4ul,3ul}; auto n_elem_pack = meta::as_type<4ul>{}; { auto simd_indices = nmtools_array{0ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 1 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 1 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,2ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 2 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 2 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{1ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 3 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 1 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,2ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 5 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 2 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } } TEST_CASE("binary_2d_simd(case5)" * doctest::test_suite("index::binary_2d_simd")) { auto lhs_shape = nmtools_array{2ul,5ul}; auto rhs_shape = nmtools_array{2ul,1ul}; auto out_shape = nmtools_array{2ul,5ul}; auto simd_shape = nmtools_array{2ul,2ul}; auto n_elem_pack = meta::as_type<4ul>{}; { auto simd_indices = nmtools_array{0ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{1ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 5 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 5 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 9 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 9 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } } TEST_CASE("binary_2d_simd(case6)" * doctest::test_suite("index::binary_2d_simd")) { auto lhs_shape = nmtools_array{2ul,9ul}; auto rhs_shape = nmtools_array{2ul,1ul}; auto out_shape = nmtools_array{2ul,9ul}; auto simd_shape = nmtools_array{2ul,3ul}; auto n_elem_pack = meta::as_type<4ul>{}; { auto simd_indices = nmtools_array{0ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,2ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 8 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 8 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{1ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 9 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 9 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 13 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 13 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto simd_indices = nmtools_array{1ul,2ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 17 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 17 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } } TEST_CASE("binary_2d_simd(case6)" * doctest::test_suite("index::binary_2d_simd")) { auto lhs_shape = nmtools_array{2ul,5ul}; auto rhs_shape = nmtools_array{1ul,5ul}; auto out_shape = nmtools_array{2ul,5ul}; auto simd_shape = nmtools_array{2ul,2ul}; auto n_elem_pack = meta::as_type<4ul>{}; { auto simd_indices = nmtools_array{0ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 4 ); } } { auto simd_indices = nmtools_array{1ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 5 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 5 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{1ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 9 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 9 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 4 ); } } } TEST_CASE("binary_2d_simd(case6)" * doctest::test_suite("index::binary_2d_simd")) { auto lhs_shape = nmtools_array{1ul,5ul}; auto rhs_shape = nmtools_array{2ul,5ul}; auto out_shape = nmtools_array{2ul,5ul}; auto simd_shape = nmtools_array{2ul,2ul}; auto n_elem_pack = meta::as_type<4ul>{}; { auto simd_indices = nmtools_array{0ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 4 ); } } { auto simd_indices = nmtools_array{1ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 5 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 5 ); } } { auto simd_indices = nmtools_array{1ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 9 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 9 ); } } } TEST_CASE("binary_2d_simd(case7)" * doctest::test_suite("index::binary_2d_simd")) { auto lhs_shape = nmtools_array{5ul,1ul}; auto rhs_shape = nmtools_array{1ul,5ul}; auto out_shape = nmtools_array{5ul,5ul}; auto simd_shape = nmtools_array{5ul,2ul}; auto n_elem_pack = meta::as_type<4ul>{}; { auto simd_indices = nmtools_array{0ul,0ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto simd_indices = nmtools_array{0ul,1ul}; auto result = ix::binary_2d_simd(n_elem_pack,simd_indices,simd_shape,out_shape,lhs_shape,rhs_shape); auto [out_idx,lhs_idx,rhs_idx] = result; { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::SCALAR ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 4 ); } } } TEST_CASE("binary_2d_simd_enumerator(case1)" * doctest::test_suite("index::binary_2d_simd_enumerator")) { auto lhs_shape = nmtools_array{1ul,8ul}; auto rhs_shape = nmtools_array{2ul,1ul}; auto out_shape = nmtools_array{2ul,8ul}; auto n_elem_pack = meta::as_type<4ul>{}; auto enumerator = ix::binary_2d_simd_enumerator(n_elem_pack,out_shape,lhs_shape,rhs_shape); NMTOOLS_ASSERT_EQUAL( enumerator.size(), 4 ); { auto out_idx = nm::get<0>(enumerator[0]); auto lhs_idx = nm::get<1>(enumerator[0]); auto rhs_idx = nm::get<2>(enumerator[0]); { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 0 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto out_idx = nm::get<0>(enumerator[1]); auto lhs_idx = nm::get<1>(enumerator[1]); auto rhs_idx = nm::get<2>(enumerator[1]); { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 4 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 0 ); } } { auto out_idx = nm::get<0>(enumerator[2]); auto lhs_idx = nm::get<1>(enumerator[2]); auto rhs_idx = nm::get<2>(enumerator[2]); { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 8 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 0 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } { auto out_idx = nm::get<0>(enumerator[3]); auto lhs_idx = nm::get<1>(enumerator[3]); auto rhs_idx = nm::get<2>(enumerator[3]); { auto out_tag = nm::get<0>(out_idx); auto out_ptr_idx = nm::get<1>(out_idx); CHECK( out_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( out_ptr_idx, 12 ); } { auto lhs_tag = nm::get<0>(lhs_idx); auto lhs_ptr_idx = nm::get<1>(lhs_idx); CHECK( lhs_tag == ix::SIMD::PACKED ); NMTOOLS_ASSERT_EQUAL( lhs_ptr_idx, 4 ); } { auto rhs_tag = nm::get<0>(rhs_idx); auto rhs_ptr_idx = nm::get<1>(rhs_idx); CHECK( rhs_tag == ix::SIMD::BROADCAST ); NMTOOLS_ASSERT_EQUAL( rhs_ptr_idx, 1 ); } } }
[ "noreply@github.com" ]
noreply@github.com
e3a6395eef81547a1352e3df8ac5bf7379a8a8fe
24f26275ffcd9324998d7570ea9fda82578eeb9e
/chrome/browser/devtools/chrome_devtools_manager_delegate.h
0e7bdc0eb74f198bcd3158dbc2d906f5727d0b7a
[ "BSD-3-Clause" ]
permissive
Vizionnation/chromenohistory
70a51193c8538d7b995000a1b2a654e70603040f
146feeb85985a6835f4b8826ad67be9195455402
refs/heads/master
2022-12-15T07:02:54.461083
2019-10-25T15:07:06
2019-10-25T15:07:06
217,557,501
2
1
BSD-3-Clause
2022-11-19T06:53:07
2019-10-25T14:58:54
null
UTF-8
C++
false
false
3,772
h
// Copyright 2014 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_DEVTOOLS_CHROME_DEVTOOLS_MANAGER_DELEGATE_H_ #define CHROME_BROWSER_DEVTOOLS_CHROME_DEVTOOLS_MANAGER_DELEGATE_H_ #include <map> #include <memory> #include <set> #include <string> #include "base/compiler_specific.h" #include "base/macros.h" #include "chrome/browser/devtools/device/devtools_device_discovery.h" #include "chrome/browser/devtools/protocol/forward.h" #include "chrome/browser/devtools/protocol/protocol.h" #include "content/public/browser/devtools_agent_host_observer.h" #include "content/public/browser/devtools_manager_delegate.h" #include "net/base/host_port_pair.h" class ChromeDevToolsSession; using RemoteLocations = std::set<net::HostPortPair>; namespace extensions { class Extension; } class ChromeDevToolsManagerDelegate : public content::DevToolsManagerDelegate { public: static const char kTypeApp[]; static const char kTypeBackgroundPage[]; ChromeDevToolsManagerDelegate(); ~ChromeDevToolsManagerDelegate() override; static ChromeDevToolsManagerDelegate* GetInstance(); void UpdateDeviceDiscovery(); // |web_contents| may be null, in which case this function just checks // the settings for |profile|. static bool AllowInspection(Profile* profile, content::WebContents* web_contents); // |extension| may be null, in which case this function just checks // the settings for |profile|. static bool AllowInspection(Profile* profile, const extensions::Extension* extension); // Resets |device_manager_|. void ResetAndroidDeviceManagerForTesting(); std::vector<content::BrowserContext*> GetBrowserContexts() override; content::BrowserContext* GetDefaultBrowserContext() override; private: friend class DevToolsManagerDelegateTest; // content::DevToolsManagerDelegate implementation. void Inspect(content::DevToolsAgentHost* agent_host) override; void HandleCommand(content::DevToolsAgentHost* agent_host, content::DevToolsAgentHostClient* client, const std::string& method, const std::string& message, NotHandledCallback callback) override; std::string GetTargetType(content::WebContents* web_contents) override; std::string GetTargetTitle(content::WebContents* web_contents) override; content::BrowserContext* CreateBrowserContext() override; void DisposeBrowserContext(content::BrowserContext*, DisposeCallback callback) override; bool AllowInspectingRenderFrameHost(content::RenderFrameHost* rfh) override; void ClientAttached(content::DevToolsAgentHost* agent_host, content::DevToolsAgentHostClient* client) override; void ClientDetached(content::DevToolsAgentHost* agent_host, content::DevToolsAgentHostClient* client) override; scoped_refptr<content::DevToolsAgentHost> CreateNewTarget( const GURL& url) override; std::string GetDiscoveryPageHTML() override; bool HasBundledFrontendResources() override; void DevicesAvailable( const DevToolsDeviceDiscovery::CompleteDevices& devices); std::map<content::DevToolsAgentHostClient*, std::unique_ptr<ChromeDevToolsSession>> sessions_; std::unique_ptr<AndroidDeviceManager> device_manager_; std::unique_ptr<DevToolsDeviceDiscovery> device_discovery_; content::DevToolsAgentHost::List remote_agent_hosts_; RemoteLocations remote_locations_; DISALLOW_COPY_AND_ASSIGN(ChromeDevToolsManagerDelegate); }; #endif // CHROME_BROWSER_DEVTOOLS_CHROME_DEVTOOLS_MANAGER_DELEGATE_H_
[ "rjkroege@chromium.org" ]
rjkroege@chromium.org
022aea6c048f4f2a60ea20d4689b127816111b59
63c839e756e112a3ae939ae4a80d77c58b851d0a
/Plugins/GameLiftClientSDK/Source/GameLiftClientSDK/Public/aws/gamelift/model/UpdateMatchmakingConfigurationRequest.h
e95fff5b6535a706f2f7e7cbf2feb9e87dbbdea3
[ "Apache-2.0" ]
permissive
ArifZx/GameliftClientPlugin
5ad23b69514662ae8ef7d573298c04e8a9535e13
14f53de4c392e6aea89609b33d0ef4549738be29
refs/heads/master
2020-11-24T13:07:48.006998
2019-12-16T07:08:55
2019-12-16T07:08:55
228,158,770
2
1
null
2019-12-16T01:56:40
2019-12-15T09:23:42
C++
UTF-8
C++
false
false
41,241
h
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/gamelift/GameLift_EXPORTS.h> #include <aws/gamelift/GameLiftRequest.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/gamelift/model/BackfillMode.h> #include <aws/gamelift/model/GameProperty.h> #include <utility> namespace Aws { namespace GameLift { namespace Model { /** * <p>Represents the input for a request action.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/gamelift-2015-10-01/UpdateMatchmakingConfigurationInput">AWS * API Reference</a></p> */ class AWS_GAMELIFT_API UpdateMatchmakingConfigurationRequest : public GameLiftRequest { public: UpdateMatchmakingConfigurationRequest(); // Service request name is the Operation name which will send this request out, // each operation should has unique request name, so that we can get operation's name from this request. // Note: this is not true for response, multiple operations may have the same response name, // so we can not get operation's name from response. inline virtual const char* GetServiceRequestName() const override { return "UpdateMatchmakingConfiguration"; } Aws::String SerializePayload() const override; Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const override; /** * <p>Unique identifier for a matchmaking configuration to update.</p> */ inline const Aws::String& GetName() const{ return m_name; } /** * <p>Unique identifier for a matchmaking configuration to update.</p> */ inline bool NameHasBeenSet() const { return m_nameHasBeenSet; } /** * <p>Unique identifier for a matchmaking configuration to update.</p> */ inline void SetName(const Aws::String& value) { m_nameHasBeenSet = true; m_name = value; } /** * <p>Unique identifier for a matchmaking configuration to update.</p> */ inline void SetName(Aws::String&& value) { m_nameHasBeenSet = true; m_name = std::move(value); } /** * <p>Unique identifier for a matchmaking configuration to update.</p> */ inline void SetName(const char* value) { m_nameHasBeenSet = true; m_name.assign(value); } /** * <p>Unique identifier for a matchmaking configuration to update.</p> */ inline UpdateMatchmakingConfigurationRequest& WithName(const Aws::String& value) { SetName(value); return *this;} /** * <p>Unique identifier for a matchmaking configuration to update.</p> */ inline UpdateMatchmakingConfigurationRequest& WithName(Aws::String&& value) { SetName(std::move(value)); return *this;} /** * <p>Unique identifier for a matchmaking configuration to update.</p> */ inline UpdateMatchmakingConfigurationRequest& WithName(const char* value) { SetName(value); return *this;} /** * <p>Descriptive label that is associated with matchmaking configuration.</p> */ inline const Aws::String& GetDescription() const{ return m_description; } /** * <p>Descriptive label that is associated with matchmaking configuration.</p> */ inline bool DescriptionHasBeenSet() const { return m_descriptionHasBeenSet; } /** * <p>Descriptive label that is associated with matchmaking configuration.</p> */ inline void SetDescription(const Aws::String& value) { m_descriptionHasBeenSet = true; m_description = value; } /** * <p>Descriptive label that is associated with matchmaking configuration.</p> */ inline void SetDescription(Aws::String&& value) { m_descriptionHasBeenSet = true; m_description = std::move(value); } /** * <p>Descriptive label that is associated with matchmaking configuration.</p> */ inline void SetDescription(const char* value) { m_descriptionHasBeenSet = true; m_description.assign(value); } /** * <p>Descriptive label that is associated with matchmaking configuration.</p> */ inline UpdateMatchmakingConfigurationRequest& WithDescription(const Aws::String& value) { SetDescription(value); return *this;} /** * <p>Descriptive label that is associated with matchmaking configuration.</p> */ inline UpdateMatchmakingConfigurationRequest& WithDescription(Aws::String&& value) { SetDescription(std::move(value)); return *this;} /** * <p>Descriptive label that is associated with matchmaking configuration.</p> */ inline UpdateMatchmakingConfigurationRequest& WithDescription(const char* value) { SetDescription(value); return *this;} /** * <p>Amazon Resource Name (<a * href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>) * that is assigned to a game session queue and uniquely identifies it. Format is * <code>arn:aws:gamelift:&lt;region&gt;:&lt;aws * account&gt;:gamesessionqueue/&lt;queue name&gt;</code>. These queues are used * when placing game sessions for matches that are created with this matchmaking * configuration. Queues can be located in any region.</p> */ inline const Aws::Vector<Aws::String>& GetGameSessionQueueArns() const{ return m_gameSessionQueueArns; } /** * <p>Amazon Resource Name (<a * href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>) * that is assigned to a game session queue and uniquely identifies it. Format is * <code>arn:aws:gamelift:&lt;region&gt;:&lt;aws * account&gt;:gamesessionqueue/&lt;queue name&gt;</code>. These queues are used * when placing game sessions for matches that are created with this matchmaking * configuration. Queues can be located in any region.</p> */ inline bool GameSessionQueueArnsHasBeenSet() const { return m_gameSessionQueueArnsHasBeenSet; } /** * <p>Amazon Resource Name (<a * href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>) * that is assigned to a game session queue and uniquely identifies it. Format is * <code>arn:aws:gamelift:&lt;region&gt;:&lt;aws * account&gt;:gamesessionqueue/&lt;queue name&gt;</code>. These queues are used * when placing game sessions for matches that are created with this matchmaking * configuration. Queues can be located in any region.</p> */ inline void SetGameSessionQueueArns(const Aws::Vector<Aws::String>& value) { m_gameSessionQueueArnsHasBeenSet = true; m_gameSessionQueueArns = value; } /** * <p>Amazon Resource Name (<a * href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>) * that is assigned to a game session queue and uniquely identifies it. Format is * <code>arn:aws:gamelift:&lt;region&gt;:&lt;aws * account&gt;:gamesessionqueue/&lt;queue name&gt;</code>. These queues are used * when placing game sessions for matches that are created with this matchmaking * configuration. Queues can be located in any region.</p> */ inline void SetGameSessionQueueArns(Aws::Vector<Aws::String>&& value) { m_gameSessionQueueArnsHasBeenSet = true; m_gameSessionQueueArns = std::move(value); } /** * <p>Amazon Resource Name (<a * href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>) * that is assigned to a game session queue and uniquely identifies it. Format is * <code>arn:aws:gamelift:&lt;region&gt;:&lt;aws * account&gt;:gamesessionqueue/&lt;queue name&gt;</code>. These queues are used * when placing game sessions for matches that are created with this matchmaking * configuration. Queues can be located in any region.</p> */ inline UpdateMatchmakingConfigurationRequest& WithGameSessionQueueArns(const Aws::Vector<Aws::String>& value) { SetGameSessionQueueArns(value); return *this;} /** * <p>Amazon Resource Name (<a * href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>) * that is assigned to a game session queue and uniquely identifies it. Format is * <code>arn:aws:gamelift:&lt;region&gt;:&lt;aws * account&gt;:gamesessionqueue/&lt;queue name&gt;</code>. These queues are used * when placing game sessions for matches that are created with this matchmaking * configuration. Queues can be located in any region.</p> */ inline UpdateMatchmakingConfigurationRequest& WithGameSessionQueueArns(Aws::Vector<Aws::String>&& value) { SetGameSessionQueueArns(std::move(value)); return *this;} /** * <p>Amazon Resource Name (<a * href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>) * that is assigned to a game session queue and uniquely identifies it. Format is * <code>arn:aws:gamelift:&lt;region&gt;:&lt;aws * account&gt;:gamesessionqueue/&lt;queue name&gt;</code>. These queues are used * when placing game sessions for matches that are created with this matchmaking * configuration. Queues can be located in any region.</p> */ inline UpdateMatchmakingConfigurationRequest& AddGameSessionQueueArns(const Aws::String& value) { m_gameSessionQueueArnsHasBeenSet = true; m_gameSessionQueueArns.push_back(value); return *this; } /** * <p>Amazon Resource Name (<a * href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>) * that is assigned to a game session queue and uniquely identifies it. Format is * <code>arn:aws:gamelift:&lt;region&gt;:&lt;aws * account&gt;:gamesessionqueue/&lt;queue name&gt;</code>. These queues are used * when placing game sessions for matches that are created with this matchmaking * configuration. Queues can be located in any region.</p> */ inline UpdateMatchmakingConfigurationRequest& AddGameSessionQueueArns(Aws::String&& value) { m_gameSessionQueueArnsHasBeenSet = true; m_gameSessionQueueArns.push_back(std::move(value)); return *this; } /** * <p>Amazon Resource Name (<a * href="https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html">ARN</a>) * that is assigned to a game session queue and uniquely identifies it. Format is * <code>arn:aws:gamelift:&lt;region&gt;:&lt;aws * account&gt;:gamesessionqueue/&lt;queue name&gt;</code>. These queues are used * when placing game sessions for matches that are created with this matchmaking * configuration. Queues can be located in any region.</p> */ inline UpdateMatchmakingConfigurationRequest& AddGameSessionQueueArns(const char* value) { m_gameSessionQueueArnsHasBeenSet = true; m_gameSessionQueueArns.push_back(value); return *this; } /** * <p>Maximum duration, in seconds, that a matchmaking ticket can remain in process * before timing out. Requests that fail due to timing out can be resubmitted as * needed.</p> */ inline int GetRequestTimeoutSeconds() const{ return m_requestTimeoutSeconds; } /** * <p>Maximum duration, in seconds, that a matchmaking ticket can remain in process * before timing out. Requests that fail due to timing out can be resubmitted as * needed.</p> */ inline bool RequestTimeoutSecondsHasBeenSet() const { return m_requestTimeoutSecondsHasBeenSet; } /** * <p>Maximum duration, in seconds, that a matchmaking ticket can remain in process * before timing out. Requests that fail due to timing out can be resubmitted as * needed.</p> */ inline void SetRequestTimeoutSeconds(int value) { m_requestTimeoutSecondsHasBeenSet = true; m_requestTimeoutSeconds = value; } /** * <p>Maximum duration, in seconds, that a matchmaking ticket can remain in process * before timing out. Requests that fail due to timing out can be resubmitted as * needed.</p> */ inline UpdateMatchmakingConfigurationRequest& WithRequestTimeoutSeconds(int value) { SetRequestTimeoutSeconds(value); return *this;} /** * <p>Length of time (in seconds) to wait for players to accept a proposed match. * If any player rejects the match or fails to accept before the timeout, the * ticket continues to look for an acceptable match.</p> */ inline int GetAcceptanceTimeoutSeconds() const{ return m_acceptanceTimeoutSeconds; } /** * <p>Length of time (in seconds) to wait for players to accept a proposed match. * If any player rejects the match or fails to accept before the timeout, the * ticket continues to look for an acceptable match.</p> */ inline bool AcceptanceTimeoutSecondsHasBeenSet() const { return m_acceptanceTimeoutSecondsHasBeenSet; } /** * <p>Length of time (in seconds) to wait for players to accept a proposed match. * If any player rejects the match or fails to accept before the timeout, the * ticket continues to look for an acceptable match.</p> */ inline void SetAcceptanceTimeoutSeconds(int value) { m_acceptanceTimeoutSecondsHasBeenSet = true; m_acceptanceTimeoutSeconds = value; } /** * <p>Length of time (in seconds) to wait for players to accept a proposed match. * If any player rejects the match or fails to accept before the timeout, the * ticket continues to look for an acceptable match.</p> */ inline UpdateMatchmakingConfigurationRequest& WithAcceptanceTimeoutSeconds(int value) { SetAcceptanceTimeoutSeconds(value); return *this;} /** * <p>Flag that determines whether a match that was created with this configuration * must be accepted by the matched players. To require acceptance, set to TRUE.</p> */ inline bool GetAcceptanceRequired() const{ return m_acceptanceRequired; } /** * <p>Flag that determines whether a match that was created with this configuration * must be accepted by the matched players. To require acceptance, set to TRUE.</p> */ inline bool AcceptanceRequiredHasBeenSet() const { return m_acceptanceRequiredHasBeenSet; } /** * <p>Flag that determines whether a match that was created with this configuration * must be accepted by the matched players. To require acceptance, set to TRUE.</p> */ inline void SetAcceptanceRequired(bool value) { m_acceptanceRequiredHasBeenSet = true; m_acceptanceRequired = value; } /** * <p>Flag that determines whether a match that was created with this configuration * must be accepted by the matched players. To require acceptance, set to TRUE.</p> */ inline UpdateMatchmakingConfigurationRequest& WithAcceptanceRequired(bool value) { SetAcceptanceRequired(value); return *this;} /** * <p>Unique identifier for a matchmaking rule set to use with this configuration. * A matchmaking configuration can only use rule sets that are defined in the same * region.</p> */ inline const Aws::String& GetRuleSetName() const{ return m_ruleSetName; } /** * <p>Unique identifier for a matchmaking rule set to use with this configuration. * A matchmaking configuration can only use rule sets that are defined in the same * region.</p> */ inline bool RuleSetNameHasBeenSet() const { return m_ruleSetNameHasBeenSet; } /** * <p>Unique identifier for a matchmaking rule set to use with this configuration. * A matchmaking configuration can only use rule sets that are defined in the same * region.</p> */ inline void SetRuleSetName(const Aws::String& value) { m_ruleSetNameHasBeenSet = true; m_ruleSetName = value; } /** * <p>Unique identifier for a matchmaking rule set to use with this configuration. * A matchmaking configuration can only use rule sets that are defined in the same * region.</p> */ inline void SetRuleSetName(Aws::String&& value) { m_ruleSetNameHasBeenSet = true; m_ruleSetName = std::move(value); } /** * <p>Unique identifier for a matchmaking rule set to use with this configuration. * A matchmaking configuration can only use rule sets that are defined in the same * region.</p> */ inline void SetRuleSetName(const char* value) { m_ruleSetNameHasBeenSet = true; m_ruleSetName.assign(value); } /** * <p>Unique identifier for a matchmaking rule set to use with this configuration. * A matchmaking configuration can only use rule sets that are defined in the same * region.</p> */ inline UpdateMatchmakingConfigurationRequest& WithRuleSetName(const Aws::String& value) { SetRuleSetName(value); return *this;} /** * <p>Unique identifier for a matchmaking rule set to use with this configuration. * A matchmaking configuration can only use rule sets that are defined in the same * region.</p> */ inline UpdateMatchmakingConfigurationRequest& WithRuleSetName(Aws::String&& value) { SetRuleSetName(std::move(value)); return *this;} /** * <p>Unique identifier for a matchmaking rule set to use with this configuration. * A matchmaking configuration can only use rule sets that are defined in the same * region.</p> */ inline UpdateMatchmakingConfigurationRequest& WithRuleSetName(const char* value) { SetRuleSetName(value); return *this;} /** * <p>SNS topic ARN that is set up to receive matchmaking notifications. See <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-notification.html"> * Setting up Notifications for Matchmaking</a> for more information.</p> */ inline const Aws::String& GetNotificationTarget() const{ return m_notificationTarget; } /** * <p>SNS topic ARN that is set up to receive matchmaking notifications. See <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-notification.html"> * Setting up Notifications for Matchmaking</a> for more information.</p> */ inline bool NotificationTargetHasBeenSet() const { return m_notificationTargetHasBeenSet; } /** * <p>SNS topic ARN that is set up to receive matchmaking notifications. See <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-notification.html"> * Setting up Notifications for Matchmaking</a> for more information.</p> */ inline void SetNotificationTarget(const Aws::String& value) { m_notificationTargetHasBeenSet = true; m_notificationTarget = value; } /** * <p>SNS topic ARN that is set up to receive matchmaking notifications. See <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-notification.html"> * Setting up Notifications for Matchmaking</a> for more information.</p> */ inline void SetNotificationTarget(Aws::String&& value) { m_notificationTargetHasBeenSet = true; m_notificationTarget = std::move(value); } /** * <p>SNS topic ARN that is set up to receive matchmaking notifications. See <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-notification.html"> * Setting up Notifications for Matchmaking</a> for more information.</p> */ inline void SetNotificationTarget(const char* value) { m_notificationTargetHasBeenSet = true; m_notificationTarget.assign(value); } /** * <p>SNS topic ARN that is set up to receive matchmaking notifications. See <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-notification.html"> * Setting up Notifications for Matchmaking</a> for more information.</p> */ inline UpdateMatchmakingConfigurationRequest& WithNotificationTarget(const Aws::String& value) { SetNotificationTarget(value); return *this;} /** * <p>SNS topic ARN that is set up to receive matchmaking notifications. See <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-notification.html"> * Setting up Notifications for Matchmaking</a> for more information.</p> */ inline UpdateMatchmakingConfigurationRequest& WithNotificationTarget(Aws::String&& value) { SetNotificationTarget(std::move(value)); return *this;} /** * <p>SNS topic ARN that is set up to receive matchmaking notifications. See <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-notification.html"> * Setting up Notifications for Matchmaking</a> for more information.</p> */ inline UpdateMatchmakingConfigurationRequest& WithNotificationTarget(const char* value) { SetNotificationTarget(value); return *this;} /** * <p>Number of player slots in a match to keep open for future players. For * example, if the configuration's rule set specifies a match for a single * 12-person team, and the additional player count is set to 2, only 10 players are * selected for the match.</p> */ inline int GetAdditionalPlayerCount() const{ return m_additionalPlayerCount; } /** * <p>Number of player slots in a match to keep open for future players. For * example, if the configuration's rule set specifies a match for a single * 12-person team, and the additional player count is set to 2, only 10 players are * selected for the match.</p> */ inline bool AdditionalPlayerCountHasBeenSet() const { return m_additionalPlayerCountHasBeenSet; } /** * <p>Number of player slots in a match to keep open for future players. For * example, if the configuration's rule set specifies a match for a single * 12-person team, and the additional player count is set to 2, only 10 players are * selected for the match.</p> */ inline void SetAdditionalPlayerCount(int value) { m_additionalPlayerCountHasBeenSet = true; m_additionalPlayerCount = value; } /** * <p>Number of player slots in a match to keep open for future players. For * example, if the configuration's rule set specifies a match for a single * 12-person team, and the additional player count is set to 2, only 10 players are * selected for the match.</p> */ inline UpdateMatchmakingConfigurationRequest& WithAdditionalPlayerCount(int value) { SetAdditionalPlayerCount(value); return *this;} /** * <p>Information to add to all events related to the matchmaking configuration. * </p> */ inline const Aws::String& GetCustomEventData() const{ return m_customEventData; } /** * <p>Information to add to all events related to the matchmaking configuration. * </p> */ inline bool CustomEventDataHasBeenSet() const { return m_customEventDataHasBeenSet; } /** * <p>Information to add to all events related to the matchmaking configuration. * </p> */ inline void SetCustomEventData(const Aws::String& value) { m_customEventDataHasBeenSet = true; m_customEventData = value; } /** * <p>Information to add to all events related to the matchmaking configuration. * </p> */ inline void SetCustomEventData(Aws::String&& value) { m_customEventDataHasBeenSet = true; m_customEventData = std::move(value); } /** * <p>Information to add to all events related to the matchmaking configuration. * </p> */ inline void SetCustomEventData(const char* value) { m_customEventDataHasBeenSet = true; m_customEventData.assign(value); } /** * <p>Information to add to all events related to the matchmaking configuration. * </p> */ inline UpdateMatchmakingConfigurationRequest& WithCustomEventData(const Aws::String& value) { SetCustomEventData(value); return *this;} /** * <p>Information to add to all events related to the matchmaking configuration. * </p> */ inline UpdateMatchmakingConfigurationRequest& WithCustomEventData(Aws::String&& value) { SetCustomEventData(std::move(value)); return *this;} /** * <p>Information to add to all events related to the matchmaking configuration. * </p> */ inline UpdateMatchmakingConfigurationRequest& WithCustomEventData(const char* value) { SetCustomEventData(value); return *this;} /** * <p>Set of custom properties for a game session, formatted as key:value pairs. * These properties are passed to a game server process in the <a>GameSession</a> * object with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline const Aws::Vector<GameProperty>& GetGameProperties() const{ return m_gameProperties; } /** * <p>Set of custom properties for a game session, formatted as key:value pairs. * These properties are passed to a game server process in the <a>GameSession</a> * object with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline bool GamePropertiesHasBeenSet() const { return m_gamePropertiesHasBeenSet; } /** * <p>Set of custom properties for a game session, formatted as key:value pairs. * These properties are passed to a game server process in the <a>GameSession</a> * object with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline void SetGameProperties(const Aws::Vector<GameProperty>& value) { m_gamePropertiesHasBeenSet = true; m_gameProperties = value; } /** * <p>Set of custom properties for a game session, formatted as key:value pairs. * These properties are passed to a game server process in the <a>GameSession</a> * object with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline void SetGameProperties(Aws::Vector<GameProperty>&& value) { m_gamePropertiesHasBeenSet = true; m_gameProperties = std::move(value); } /** * <p>Set of custom properties for a game session, formatted as key:value pairs. * These properties are passed to a game server process in the <a>GameSession</a> * object with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline UpdateMatchmakingConfigurationRequest& WithGameProperties(const Aws::Vector<GameProperty>& value) { SetGameProperties(value); return *this;} /** * <p>Set of custom properties for a game session, formatted as key:value pairs. * These properties are passed to a game server process in the <a>GameSession</a> * object with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline UpdateMatchmakingConfigurationRequest& WithGameProperties(Aws::Vector<GameProperty>&& value) { SetGameProperties(std::move(value)); return *this;} /** * <p>Set of custom properties for a game session, formatted as key:value pairs. * These properties are passed to a game server process in the <a>GameSession</a> * object with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline UpdateMatchmakingConfigurationRequest& AddGameProperties(const GameProperty& value) { m_gamePropertiesHasBeenSet = true; m_gameProperties.push_back(value); return *this; } /** * <p>Set of custom properties for a game session, formatted as key:value pairs. * These properties are passed to a game server process in the <a>GameSession</a> * object with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline UpdateMatchmakingConfigurationRequest& AddGameProperties(GameProperty&& value) { m_gamePropertiesHasBeenSet = true; m_gameProperties.push_back(std::move(value)); return *this; } /** * <p>Set of custom game session properties, formatted as a single string value. * This data is passed to a game server process in the <a>GameSession</a> object * with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline const Aws::String& GetGameSessionData() const{ return m_gameSessionData; } /** * <p>Set of custom game session properties, formatted as a single string value. * This data is passed to a game server process in the <a>GameSession</a> object * with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline bool GameSessionDataHasBeenSet() const { return m_gameSessionDataHasBeenSet; } /** * <p>Set of custom game session properties, formatted as a single string value. * This data is passed to a game server process in the <a>GameSession</a> object * with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline void SetGameSessionData(const Aws::String& value) { m_gameSessionDataHasBeenSet = true; m_gameSessionData = value; } /** * <p>Set of custom game session properties, formatted as a single string value. * This data is passed to a game server process in the <a>GameSession</a> object * with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline void SetGameSessionData(Aws::String&& value) { m_gameSessionDataHasBeenSet = true; m_gameSessionData = std::move(value); } /** * <p>Set of custom game session properties, formatted as a single string value. * This data is passed to a game server process in the <a>GameSession</a> object * with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline void SetGameSessionData(const char* value) { m_gameSessionDataHasBeenSet = true; m_gameSessionData.assign(value); } /** * <p>Set of custom game session properties, formatted as a single string value. * This data is passed to a game server process in the <a>GameSession</a> object * with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline UpdateMatchmakingConfigurationRequest& WithGameSessionData(const Aws::String& value) { SetGameSessionData(value); return *this;} /** * <p>Set of custom game session properties, formatted as a single string value. * This data is passed to a game server process in the <a>GameSession</a> object * with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline UpdateMatchmakingConfigurationRequest& WithGameSessionData(Aws::String&& value) { SetGameSessionData(std::move(value)); return *this;} /** * <p>Set of custom game session properties, formatted as a single string value. * This data is passed to a game server process in the <a>GameSession</a> object * with a request to start a new game session (see <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html#gamelift-sdk-server-startsession">Start * a Game Session</a>). This information is added to the new <a>GameSession</a> * object that is created for a successful match. </p> */ inline UpdateMatchmakingConfigurationRequest& WithGameSessionData(const char* value) { SetGameSessionData(value); return *this;} /** * <p>Method used to backfill game sessions created with this matchmaking * configuration. Specify MANUAL when your game manages backfill requests manually * or does not use the match backfill feature. Specify AUTOMATIC to have GameLift * create a <a>StartMatchBackfill</a> request whenever a game session has one or * more open slots. Learn more about manual and automatic backfill in <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-backfill.html">Backfill * Existing Games with FlexMatch</a>.</p> */ inline const BackfillMode& GetBackfillMode() const{ return m_backfillMode; } /** * <p>Method used to backfill game sessions created with this matchmaking * configuration. Specify MANUAL when your game manages backfill requests manually * or does not use the match backfill feature. Specify AUTOMATIC to have GameLift * create a <a>StartMatchBackfill</a> request whenever a game session has one or * more open slots. Learn more about manual and automatic backfill in <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-backfill.html">Backfill * Existing Games with FlexMatch</a>.</p> */ inline bool BackfillModeHasBeenSet() const { return m_backfillModeHasBeenSet; } /** * <p>Method used to backfill game sessions created with this matchmaking * configuration. Specify MANUAL when your game manages backfill requests manually * or does not use the match backfill feature. Specify AUTOMATIC to have GameLift * create a <a>StartMatchBackfill</a> request whenever a game session has one or * more open slots. Learn more about manual and automatic backfill in <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-backfill.html">Backfill * Existing Games with FlexMatch</a>.</p> */ inline void SetBackfillMode(const BackfillMode& value) { m_backfillModeHasBeenSet = true; m_backfillMode = value; } /** * <p>Method used to backfill game sessions created with this matchmaking * configuration. Specify MANUAL when your game manages backfill requests manually * or does not use the match backfill feature. Specify AUTOMATIC to have GameLift * create a <a>StartMatchBackfill</a> request whenever a game session has one or * more open slots. Learn more about manual and automatic backfill in <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-backfill.html">Backfill * Existing Games with FlexMatch</a>.</p> */ inline void SetBackfillMode(BackfillMode&& value) { m_backfillModeHasBeenSet = true; m_backfillMode = std::move(value); } /** * <p>Method used to backfill game sessions created with this matchmaking * configuration. Specify MANUAL when your game manages backfill requests manually * or does not use the match backfill feature. Specify AUTOMATIC to have GameLift * create a <a>StartMatchBackfill</a> request whenever a game session has one or * more open slots. Learn more about manual and automatic backfill in <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-backfill.html">Backfill * Existing Games with FlexMatch</a>.</p> */ inline UpdateMatchmakingConfigurationRequest& WithBackfillMode(const BackfillMode& value) { SetBackfillMode(value); return *this;} /** * <p>Method used to backfill game sessions created with this matchmaking * configuration. Specify MANUAL when your game manages backfill requests manually * or does not use the match backfill feature. Specify AUTOMATIC to have GameLift * create a <a>StartMatchBackfill</a> request whenever a game session has one or * more open slots. Learn more about manual and automatic backfill in <a * href="https://docs.aws.amazon.com/gamelift/latest/developerguide/match-backfill.html">Backfill * Existing Games with FlexMatch</a>.</p> */ inline UpdateMatchmakingConfigurationRequest& WithBackfillMode(BackfillMode&& value) { SetBackfillMode(std::move(value)); return *this;} private: Aws::String m_name; bool m_nameHasBeenSet; Aws::String m_description; bool m_descriptionHasBeenSet; Aws::Vector<Aws::String> m_gameSessionQueueArns; bool m_gameSessionQueueArnsHasBeenSet; int m_requestTimeoutSeconds; bool m_requestTimeoutSecondsHasBeenSet; int m_acceptanceTimeoutSeconds; bool m_acceptanceTimeoutSecondsHasBeenSet; bool m_acceptanceRequired; bool m_acceptanceRequiredHasBeenSet; Aws::String m_ruleSetName; bool m_ruleSetNameHasBeenSet; Aws::String m_notificationTarget; bool m_notificationTargetHasBeenSet; int m_additionalPlayerCount; bool m_additionalPlayerCountHasBeenSet; Aws::String m_customEventData; bool m_customEventDataHasBeenSet; Aws::Vector<GameProperty> m_gameProperties; bool m_gamePropertiesHasBeenSet; Aws::String m_gameSessionData; bool m_gameSessionDataHasBeenSet; BackfillMode m_backfillMode; bool m_backfillModeHasBeenSet; }; } // namespace Model } // namespace GameLift } // namespace Aws
[ "ArifBudiman19@github.com" ]
ArifBudiman19@github.com
a58620e4efd2edb7f0e8a0912506e5821cd29264
0f94fc227dc298aaad488e468563453f0e312494
/include/pathgen/QuaternionSpline.h
8ea0fdaca1006abf0e0fb52b1c32ebada46e0549
[]
no_license
fernando10/PathGen2
98c594a5ff0e1f68b18e69f3e1480486ad93b1b3
08849b5a507bcdcca77ef2766e2904f6b2462e95
refs/heads/master
2021-03-30T18:03:26.303293
2017-12-07T22:38:42
2017-12-07T22:38:42
113,504,246
0
0
null
null
null
null
UTF-8
C++
false
false
1,829
h
#pragma once #ifndef INCLUDE_PATHGEN_QUATERION_SPLINE_H_ #define INCLUDE_PATHGEN_QUATERION_SPLINE_H_ #include <Eigen/Core> #include <Eigen/Geometry> #include <vector> namespace pathgen { void squad(const Eigen::Quaterniond& q1, const Eigen::Quaterniond& q2, const Eigen::Quaterniond& s1, const Eigen::Quaterniond& s2, double t, Eigen::Quaterniond* dst); void squad_prime(const Eigen::Quaterniond& q1, const Eigen::Quaterniond& q2, const Eigen::Quaterniond& s1, const Eigen::Quaterniond& s2, double t, Eigen::Quaterniond* dst); class QuaternionSpline { public: QuaternionSpline(){} QuaternionSpline(Eigen::Array<Eigen::Quaterniond, 1, Eigen::Dynamic> ctrl, Eigen::Array<Eigen::Quaterniond, 1, Eigen::Dynamic> support); // the spline value at a given locaiton Eigen::Quaterniond operator()(const double& u) const; Eigen::Vector3d derivative(const double& u) const; Eigen::Quaterniond quaternionDerivative(const double& u) const; void SetIntegrateDerivativeForOrientation(bool integrate); protected: Eigen::Array<Eigen::Quaterniond, 1, Eigen::Dynamic> control_pts_; //q_i Eigen::Array<Eigen::Quaterniond, 1, Eigen::Dynamic> support_pts_; //s_i Eigen::VectorXd knots_; std::vector<Eigen::Quaterniond> integrated_quaternions_; bool integrate_derivative_for_orientation_; double eps_ = 1e-3; }; struct QuaterionSplineFitting { static void ChordLengths( const Eigen::Array<Eigen::Quaterniond, 1, Eigen::Dynamic>& pts, Eigen::VectorXd& chord_lengths); static QuaternionSpline Interpolate( const Eigen::Array<Eigen::Quaterniond, 1, Eigen::Dynamic> pts); }; } #endif
[ "fernando.nobre@colorado.edu" ]
fernando.nobre@colorado.edu
053386b06e08ec861420c7b3e2a245b8f5ca5d73
e55766c40f80559a02d4e13f76c8688cec421a15
/src/MWrapper/tests/t_isocat.c
c2c3b628e723936ff34ef55e0981a2f7ad98f07f
[]
no_license
paulbkoch/mlc
be520f8a0bf2e0071ca8220b30305b664880c453
4f6af48c49928072349b928dd52e143a51049ff2
refs/heads/master
2022-04-06T14:44:48.678944
2020-03-01T20:47:21
2020-03-01T20:47:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,416
c
// MLC++ - Machine Learning Library in -*- C++ -*- // See Descrip.txt for terms and conditions relating to use and distribution. // This is a file to test some part of MLC++. It is NOT part of the // MLC++ library, but is designed to test portions of it. /*************************************************************************** Description : Usage : Enhancements : History : Chia-Hsin Li 10/28/94 Initial version ***************************************************************************/ #include <basics.h> #include <ODGInducer.h> #include <EntropyODGInducer.h> #include <CtrInstList.h> #include <CatTestResult.h> #include <GetOption.h> #include <isocat.h> RCSID("MLC++, $RCSfile: t_isocat.c,v $ $Revision: 1.5 $") void check_connection(const CGraph& cg) { int noInDegreeNum = 0; Mcout << "Testing the connectivity..." << endl; NodePtr iterNode; forall_nodes(iterNode, cg) { if (cg.indeg(iterNode) == 0) { noInDegreeNum ++; if (noInDegreeNum > 1) err << "Some part of the graph is unconnnected. " << fatal_error; } } } /*************************************************************************** Description : Get the node whose index is nodeNum. Comments : This function is inefficient. However, it's in the tester. No body cares. ***************************************************************************/ NodePtr get_node(const CGraph& G, int nodeNum) { NodePtr iterNode; forall_nodes(iterNode, G) { if (index(iterNode) == nodeNum) return iterNode; } err << "Can not find the node whose index is " << nodeNum << fatal_error; return NULL; } void check_first_level_subgraphs(const CatGraph& catG) { const CGraph& G = catG.get_graph(); NodePtr redPtr = get_node(G, 1); NodePtr yellowPtr = get_node(G, 2); NodePtr greenPtr = get_node(G, 3); NodePtr bluePtr = get_node(G, 4); LogOptions logOp; logOp.set_log_level(0); Bool changeLabel = FALSE; // Test red and yellow subgraph Mcout << "Testing red and yellow jacket subgraphs" << endl; int conflict = acyclic_graph_merge_conflict(logOp, catG, redPtr, catG, yellowPtr, changeLabel); Mcout << "Conflict Number:" << conflict << endl; // Test red and green subgraph Mcout << "Testing red and green jacket subgraphs" << endl; conflict = acyclic_graph_merge_conflict(logOp, catG, redPtr, catG, greenPtr, changeLabel); Mcout << "Conflict Number:" << conflict << endl; // Test red and blue subgraph Mcout << "Testing red and blue jacket subgraphs" << endl; conflict = acyclic_graph_merge_conflict(logOp, catG, redPtr, catG, bluePtr, changeLabel); Mcout << "Conflict Number:" << conflict << endl; // Test yellow and green jacket subgraph Mcout << "Testing yellow and green jacket subgraphs" << endl; conflict = acyclic_graph_merge_conflict(logOp, catG, yellowPtr, catG, greenPtr, changeLabel); Mcout << "Conflict Number:" << conflict << endl; // Test yellow and blue jacket subgraph Mcout << "Testing yellow and blue jacket subgraphs" << endl; conflict = acyclic_graph_merge_conflict(logOp, catG, yellowPtr, catG, bluePtr, changeLabel); Mcout << "Conflict Number:" << conflict << endl; // Test green and blue jacket subgraph Mcout << "Testing green and blue jacket subgraphs" << endl; conflict = acyclic_graph_merge_conflict(logOp, catG, greenPtr, catG, bluePtr, changeLabel); Mcout << "Conflict Number:" << conflict << endl; } main() { MString datafile = "monk1-full"; EntropyODGInducer inducer("ODG Inducer"); inducer.read_data(datafile); Mcout << "Training ... " << endl; inducer.set_post_proc(set_unknown); inducer.set_debug(TRUE); inducer.set_cv_prune(FALSE); inducer.set_unknown_edges(TRUE); inducer.train(); const CatGraph& catG = inducer.get_cat_graph(); const CGraph& cg = inducer.get_graph(); NodePtr root = inducer.get_root(); Mcout << "Graph has " << inducer.num_nodes() << " nodes, and " << inducer.num_leaves() << " leaves." << endl; /* DotGraphPref pref; MLCOStream out(XStream); inducer.display_struct(out,pref); */ check_first_level_subgraphs(catG); check_connection(cg); return 0; // return success to shell }
[ "jean-marc.lienher@bluewin.ch" ]
jean-marc.lienher@bluewin.ch
4423e5237162ffa3017204efbad2c428a5b3a1a6
3d051b4e7532811456198a58a39c403252d10595
/0817/G.cpp
b8cda9bfeedfca9ce9763a87d8c535920095219e
[]
no_license
ItsLucas/acm
3c1aeee36a96ec33965e7c321bdc76d2c4d0e09f
3659bc82862124146f760923167a15ae1507ed80
refs/heads/master
2021-07-22T11:20:52.094674
2020-07-21T02:56:40
2020-07-21T02:56:40
198,808,058
0
0
null
null
null
null
UTF-8
C++
false
false
1,107
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll fx[21], fy[21]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t; cin >> t; while (t-- > 0) { ll n, m, k; cin >> n >> m >> k; for (ll i = 0; i < k; i++) { cin >> fx[i] >> fy[i]; } ll ans = (n * (n + 1) / 2) * (m * (m + 1) / 2); for (ll i = 1; i < (1 << k); i++) { ll ii = i; ll cnt = 0; while (ii) { cnt += ii & 1; ii /= 2; } ll maxx = 0, maxy = 0, minx = 1e18, miny = 1e18; for (ll j = 0; j < k; j++) { if ((i >> j) & 1) { maxx = max(maxx, fx[j]); minx = min(minx, fx[j]); maxy = max(maxy, fy[j]); miny = min(miny, fy[j]); } } ll sum = minx * miny * (n - maxx + 1) * (m - maxy + 1); ans += (cnt & 1 ? -sum : sum); } cout << ans << endl; } return 0; }
[ "itslucas@itslucas.me" ]
itslucas@itslucas.me
953ef2b7c5780e4aa44f82b3cac147ad6fab9039
a3f704871b974c69fddec501e8d0d5c607f2a898
/E09-ir-ontvanger/ir-ontvanger-deel-2.ino
b9cdf7559537565be4b07dc6e0bbc2478ceb8ec9
[]
no_license
robert190879/Arduino-Beginners-NL
b2f9aa8c9ea2a6aef3ed2e966b2ab3af581aac48
ed370a755e935eaaca122fde3cad181455162961
refs/heads/master
2023-04-05T16:02:58.660585
2021-04-17T05:13:26
2021-04-17T05:13:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,620
ino
/* * Bas on Tech - IR ontvanger * Deze les is onderdeel van de lessen op https://arduino-lessen.nl * * (c) Copyright 2018 - Bas van Dijk / Bas on Tech * Deze code en inhoud van de lessen mag zonder schriftelijke toestemming * niet voor commerciele doeleinden worden gebruikt * * YouTube: https://www.youtube.com/c/BasOnTechNL * Facebook: https://www.facebook.com/BasOnTechChannel * Instagram: https://www.instagram.com/BasOnTech * Twitter: https://twitter.com/BasOnTech * * --------------------------------------------------------------------------- * * Originele code van: * http://arcfn.com door Ken Shirriff * */ // Importeer de IR-remote bibliotheek #include <IRremote.h> int IrReceiverPin = 12; // stel de variable "IrReceiverPin" in op pin 12 IRrecv irrecv(IrReceiverPin); // maak een nieuwe instantie van "irrecv" en sla deze op in de variabele "IRrecv" decode_results results; // definieer de variable "results" om de ontvangen knop-code in op te slaan int speed = 100; void setup() { Serial.begin(9600); // Stel de seriële monitor in pinMode(LED_BUILTIN, OUTPUT); // Initialiseer digitale pin LED_BUILTIN als een uitvoer // In case the interrupt driver crashes on setup, give a clue // to the user what's going on. // Mocht de IR-remote bibliotheek vastlopen dan kunnen we dit aan de getoonde tekst zien Serial.println("IR-ontvanger wordt gestart..."); irrecv.enableIRIn(); // start de IR-ontvanger Serial.println("IR-ontvanger actief"); digitalWrite(LED_BUILTIN, LOW); // Zet de ingebouwde LED uit } void loop() { // Als de IR-ontvanger een signaal heeft ontvangen if (irrecv.decode(&results)) { // Print de ontvangen waarde als hexadecimaal Serial.println(results.value, HEX); // Laat de IR-ontvanger luisteren naar nieuwe signalen irrecv.resume(); // Bepaal welke knop is ingedrukt switch (results.value) { case 0xFF6897: // knop 1 speed = 100; // stel de snelheid in op 100ms break; case 0xFF9867: // knop 2 speed = 500; // stel de snelheid in op 500ms break; case 0xFFB04F: // knop 3 speed = 1000; // stel de snelheid in op 1000ms break; } } // Knipper de ingebouwde LED met de ingestelde snelheid digitalWrite(LED_BUILTIN, HIGH); delay(speed); digitalWrite(LED_BUILTIN, LOW); delay(speed); }
[ "info@basontech.com" ]
info@basontech.com
d51aaaa88324831533c94d7267111641ab0436c2
f91cbe3b643edff7d17a3790a5919d9ca0157d07
/Code/GameSDK/GameDll/ItemAnimation.cpp
891e897dc637bad2088a086a7e50533d17b9beb8
[]
no_license
salilkanetkar/AI-Playing-Games
5b66b166fc6c84853410bf37961b14933fa20509
7dd6965678cbeebb572ab924812acb9ceccabcf3
refs/heads/master
2021-01-21T18:46:11.320518
2016-09-15T16:14:51
2016-09-15T16:14:51
68,309,388
1
1
null
null
null
null
UTF-8
C++
false
false
5,108
cpp
/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. // Description : Helper functionality for item animation control #include "StdAfx.h" #include "ItemAnimation.h" #include "Player.h" #include "Weapon.h" CActionItemIdle::CActionItemIdle(int priority, FragmentID fragmentID, FragmentID idleBreakFragmentID, const TagState fragTags, CPlayer& playerRef) : BaseClass(priority, fragmentID, fragTags, IAction::Interruptable|IAction::NoAutoBlendOut) , m_ownerPlayer(playerRef) , m_fragmentIdle(fragmentID) , m_fragmentIdleBreak(idleBreakFragmentID) , m_lastIdleBreakTime(0.0f) , m_playingIdleBreak(false) { } IAction::EStatus CActionItemIdle::Update(float timePassed) { UpdateFragmentTags(); CWeapon *weapon = m_ownerPlayer.GetWeapon(m_ownerPlayer.GetCurrentItemId()); bool canPlayIdleBreak = !weapon || !(weapon->IsZoomed() || weapon->IsZoomingInOrOut()); if (m_playingIdleBreak) { if (!canPlayIdleBreak) { m_playingIdleBreak = false; } } else if (canPlayIdleBreak) { const float currentTime = gEnv->pTimer->GetAsyncCurTime(); IPlayerInput* pClientInput = m_ownerPlayer.GetPlayerInput(); if (pClientInput) { const float idleBreakDelay = g_pGameCVars->cl_idleBreaksDelayTime; const float lastInputTime = pClientInput->GetLastRegisteredInputTime(); const float referenceTime = (float)fsel((lastInputTime - m_lastIdleBreakTime), lastInputTime, m_lastIdleBreakTime); if ((currentTime - referenceTime) > idleBreakDelay) { m_playingIdleBreak = true; SetFragment(m_fragmentIdleBreak, m_fragTags); m_lastIdleBreakTime = currentTime; } } } if (!m_playingIdleBreak) { if (GetRootScope().IsDifferent(m_fragmentIdle, m_fragTags)) { SetFragment(m_fragmentIdle, m_fragTags); } } return BaseClass::Update(timePassed); } void CActionItemIdle::OnInitialise() { UpdateFragmentTags(); } void CActionItemIdle::OnSequenceFinished(int layer, uint32 scopeID) { if (GetRootScope().GetID() == scopeID && m_playingIdleBreak && (layer == 0)) { m_playingIdleBreak = false; m_lastIdleBreakTime = gEnv->pTimer->GetAsyncCurTime(); } } void CActionItemIdle::UpdateFragmentTags() { CItem* pItem = static_cast<CItem*>(m_ownerPlayer.GetCurrentItem()); CWeapon* pWeapon = pItem ? static_cast<CWeapon*>(pItem->GetIWeapon()) : 0; const CTagDefinition* pTagDefinition = m_context->controllerDef.GetFragmentTagDef(m_fragmentID); if(pItem && pTagDefinition) { CTagState fragTags(*pTagDefinition); fragTags = m_fragTags; pItem->SetFragmentTags(fragTags); m_fragTags = fragTags.GetMask(); } if (pWeapon) { SetParam(CItem::sActionParamCRCs.zoomTransition, pWeapon->GetZoomTransition()); } } //------------------------------------------------------------------------------------- CItemSelectAction::CItemSelectAction(int priority, FragmentID fragmentID, const TagState &fragTags, CItem& _item) : BaseClass(priority, fragmentID, fragTags) , m_ItemID(_item.GetEntityId()) , m_bSelected(false) {} void CItemSelectAction::OnAnimationEvent(ICharacterInstance *pCharacter, const AnimEventInstance &event) { const SActorAnimationEvents& animEventsTable = CActor::GetAnimationEventsTable(); if (animEventsTable.m_stowId == event.m_EventNameLowercaseCRC32) { SelectWeapon(); } } void CItemSelectAction::Enter() { BaseClass::Enter(); if( m_ItemID ) { CItem* pItem = (CItem*)g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem( m_ItemID ); UnhideWeapon(pItem); } } void CItemSelectAction::Exit() { SelectWeapon(); BaseClass::Exit(); } void CItemSelectAction::SelectWeapon() { if(m_bSelected) return; if( m_ItemID ) { CItem* pItem = (CItem*)g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem( m_ItemID ); if( pItem ) { if (pItem->IsSelectGrabbingWeapon()) { pItem->DoSelectWeaponGrab(); m_bSelected = true; } UnhideWeapon(pItem); pItem->OnItemSelectActionComplete(); } else { ForceFinish(); } } } void CItemSelectAction::ItemSelectCancelled() { ForceFinish(); SelectWeapon(); } void CItemSelectAction::UnhideWeapon(CItem* pItem) { if( pItem && pItem->AreAnyItemFlagsSet( CItem::eIF_UseAnimActionUnhide ) ) { pItem->Hide(false); pItem->AttachToBack(false); if (pItem->ShouldAttachWhenSelected()) { pItem->AttachToHand(true); } pItem->ClearItemFlags(CItem::eIF_UseAnimActionUnhide); } }
[ "prawinsg@gmail.com" ]
prawinsg@gmail.com
ba715772c228bdc89f0f5995853b9f618f947428
87a795806ecab3ebaa0b6121f20aaccdf5362559
/test/regress/PortListenerLambda.h
238335eb03523d08e5efed626885b195db6dced0
[]
no_license
ohmtech/flip-public
e2bf0c2d183b3eefa8a5028b0dc2bc12c55f6656
deb775ca7a998cb065667d10be4cb2bba0d3388d
refs/heads/master
2021-01-21T04:53:52.963142
2016-07-22T14:48:26
2016-07-22T14:48:26
53,060,980
32
4
null
2016-07-22T14:48:28
2016-03-03T15:23:58
C++
UTF-8
C++
false
false
3,032
h
/***************************************************************************** PortListenerLambda.h Copyright (c) 2014 Raphael DINGE *Tab=3***********************************************************************/ #pragma once /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ #include "flip/detail/PortListener.h" #include <functional> namespace flip { class PortListenerLambda : public PortListener { /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: PortListenerLambda () = default; virtual ~PortListenerLambda () = default; void bind_greet (std::function <void (PortBase &)> func); void bind_commit (std::function <void (PortBase &, const Transaction &)> func); void bind_squash (std::function <void (PortBase &, const TxIdRange &, const Transaction &)> func); void bind_push (std::function <void (PortBase &, const Transaction &)> func); void bind_signal (std::function <void (PortBase &, const SignalData &)> func); // PortListener virtual void port_greet (PortBase & from) override; virtual void port_commit (PortBase & from, const Transaction & tx) override; virtual void port_squash (PortBase & from, const TxIdRange & range, const Transaction & tx) override; virtual void port_push (PortBase & from, const Transaction & tx) override; virtual void port_signal (PortBase & from, const SignalData & data) override; /*\\\ INTERNAL \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: std::function <void (PortBase &)> _func_greet; std::function <void (PortBase &, const Transaction &)> _func_commit; std::function <void (PortBase &, const TxIdRange &, const Transaction &)> _func_squash; std::function <void (PortBase &, const Transaction &)> _func_push; std::function <void (PortBase &, const SignalData &)> _func_signal; /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: PortListenerLambda (const PortListenerLambda & rhs) = delete; PortListenerLambda & operator = (const PortListenerLambda & rhs) = delete; PortListenerLambda (PortListenerLambda && rhs) = delete; PortListenerLambda & operator = (PortListenerLambda && rhs) = delete; bool operator == (const PortListenerLambda & rhs) const = delete; bool operator != (const PortListenerLambda & rhs) const = delete; }; // class PortListenerLambda } // namespace flip //#include "flip/PortListenerLambda.hpp" /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
[ "raphael.dinge@ohmforce.com" ]
raphael.dinge@ohmforce.com
fd1ebf682cba1d622814920f1fc633ee8581960e
ab5173514a32ba0a2046490d993037e6075f87fd
/Features/include/Features/WorkStationLock/WorkStationLockHook.h
2b651997026d84400cddb0949fe5841d297ae2c3
[ "Apache-2.0" ]
permissive
fcccode/cord.app
64605f878e9eb16b6be5bb09536970730fceb9b3
d365fe8bb362942574811cbeda04c199fc923979
refs/heads/master
2020-08-03T16:58:29.208184
2018-12-18T08:42:58
2018-12-18T08:42:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
767
h
#pragma once #include <GameExecutor/HookInterface.h> #include <QtCore/QObject> #include <QtCore/QRect> namespace P1 { namespace Core { class Service; } } namespace Features { namespace WorkStationLock { class RegisterSessionNotificationFilter; class WorkStationLockHook: public P1::GameExecutor::HookInterface { Q_OBJECT public: explicit WorkStationLockHook(QObject *parent = 0); virtual ~WorkStationLockHook(); static QString id(); virtual void PreExecute(P1::Core::Service &service) override; virtual void CanExecute(P1::Core::Service &service) override; void setFilter(RegisterSessionNotificationFilter * value); private: RegisterSessionNotificationFilter *_filter; }; } }
[ "Clipeus@live.com" ]
Clipeus@live.com
8ee04e2db222732cdb7743d676643ae55e78af8e
92d48a1d733d35304771f4f0362ed273639edc8f
/chapter12/1/12.6/Stack.h
0780a168fd0c67f4ba39142329b219da15fa291b
[]
no_license
deliangyang/Data-Structure
7e33899c99d202a323bb973d4d7c73097b6e2084
1e26544c03cf24543817a96bdb054cd185b6f5c2
refs/heads/master
2021-01-23T12:34:26.756433
2014-09-17T03:51:45
2014-09-17T03:51:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
987
h
#include "StackBase.h" #define LEN 30 template<class T> class Stack:public StackBase<T> { public: Stack(int size=LEN); ~Stack(void); void push(T& item); T& pop(); int length(void)const; int StackFull(void)const; int StackEmpty(void)const; private: int numElements; // start numElements equal -1 int size; T * arr; }; template<class T> Stack<T>::Stack(int size) { arr=new T[size]; numElements=-1; } template<class T> void Stack<T>::push(T& item) { if(numElements>=size-1) { std::cout<<"Stack: push full"<<std::endl; return; } arr[numElements]=item; numElements++; } template<class T> T& Stack<T>::pop(void) { if(numElements<=-1) { std::cout<<"Stack: pop empty"<<std::endl; exit(1); } numElements--; return arr[numElements]; } template<class T> int Stack<T>::length(void)const { return numElements+1; } template<class T> int Stack<T>::StackEmpty(void)const { return numElements==-1; } template<class T> Stack<T>::~Stack(void) { delete[] arr; }
[ "yang623601391@sina.com" ]
yang623601391@sina.com
e75e51877e391ae69b9ce1ae6d759933f4aa18a2
0f7a4119185aff6f48907e8a5b2666d91a47c56b
/sstd_utility/windows_boost/boost/graph/two_bit_color_map.hpp
875c6302cad360d672c4e4dd034be555687d3da2
[]
no_license
jixhua/QQmlQuickBook
6636c77e9553a86f09cd59a2e89a83eaa9f153b6
782799ec3426291be0b0a2e37dc3e209006f0415
refs/heads/master
2021-09-28T13:02:48.880908
2018-11-17T10:43:47
2018-11-17T10:43:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,453
hpp
// Copyright (C) 2005-2006 The Trustees of Indiana University. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Authors: Jeremiah Willcock // Douglas Gregor // Andrew Lumsdaine // Two bit per color property map #ifndef BOOST_TWO_BIT_COLOR_MAP_HPP #define BOOST_TWO_BIT_COLOR_MAP_HPP #include <boost/property_map/property_map.hpp> #include <boost/graph/properties.hpp> #include <boost/shared_array.hpp> #include <boost/config.hpp> #include <boost/assert.hpp> #include <algorithm> #include <limits> namespace boost { enum two_bit_color_type { two_bit_white = 0, two_bit_gray = 1, two_bit_green = 2, two_bit_black = 3 }; template <> struct color_traits<two_bit_color_type> { static two_bit_color_type white() { return two_bit_white; } static two_bit_color_type gray() { return two_bit_gray; } static two_bit_color_type green() { return two_bit_green; } static two_bit_color_type black() { return two_bit_black; } }; template<typename IndexMap = identity_property_map> struct two_bit_color_map { std::size_t n; IndexMap index; shared_array<unsigned char> data; BOOST_STATIC_CONSTANT(int, bits_per_char = std::numeric_limits<unsigned char>::digits); BOOST_STATIC_CONSTANT(int, elements_per_char = bits_per_char / 2); typedef typename property_traits<IndexMap>::key_type key_type; typedef two_bit_color_type value_type; typedef void reference; typedef read_write_property_map_tag category; explicit two_bit_color_map(std::size_t n, const IndexMap& index = IndexMap()) : n(n), index(index), data(new unsigned char[(n + elements_per_char - 1) / elements_per_char]) { // Fill to white std::fill(data.get(), data.get() + (n + elements_per_char - 1) / elements_per_char, 0); } }; template<typename IndexMap> inline two_bit_color_type get(const two_bit_color_map<IndexMap>& pm, typename property_traits<IndexMap>::key_type key) { BOOST_STATIC_CONSTANT(int, elements_per_char = two_bit_color_map<IndexMap>::elements_per_char); typename property_traits<IndexMap>::value_type i = get(pm.index, key); BOOST_ASSERT ((std::size_t)i < pm.n); std::size_t byte_num = i / elements_per_char; std::size_t bit_position = ((i % elements_per_char) * 2); return two_bit_color_type((pm.data.get()[byte_num] >> bit_position) & 3); } template<typename IndexMap> inline void put(const two_bit_color_map<IndexMap>& pm, typename property_traits<IndexMap>::key_type key, two_bit_color_type value) { BOOST_STATIC_CONSTANT(int, elements_per_char = two_bit_color_map<IndexMap>::elements_per_char); typename property_traits<IndexMap>::value_type i = get(pm.index, key); BOOST_ASSERT ((std::size_t)i < pm.n); BOOST_ASSERT (value >= 0 && value < 4); std::size_t byte_num = i / elements_per_char; std::size_t bit_position = ((i % elements_per_char) * 2); pm.data.get()[byte_num] = (unsigned char) ((pm.data.get()[byte_num] & ~(3 << bit_position)) | (value << bit_position)); } template<typename IndexMap> inline two_bit_color_map<IndexMap> make_two_bit_color_map(std::size_t n, const IndexMap& index_map) { return two_bit_color_map<IndexMap>(n, index_map); } } // end namespace boost #endif // BOOST_TWO_BIT_COLOR_MAP_HPP #ifdef BOOST_GRAPH_USE_MPI # include <boost/graph/distributed/two_bit_color_map.hpp> #endif
[ "nanguazhude@vip.qq.com" ]
nanguazhude@vip.qq.com
8e1964dd865cebaa4f3319c72869df2dddbf33c1
cc22045b9def9a6221a8ee4b8e8f5b95dfc8dbef
/DC27/firmware/main/menus/3d/renderer.h
c1703bd61df4fcb440b43f23745c027fb212b5e6
[ "MIT" ]
permissive
thedarknet/darknet8-badge
6ba86f68ab851803c52418f98e7d97ab455e05a7
aff19ab13c8264ab19a47d1e8d4b83d08000ad79
refs/heads/master
2020-04-09T06:59:06.090244
2019-08-11T22:26:10
2019-08-11T22:26:10
160,135,665
3
2
null
null
null
null
UTF-8
C++
false
false
2,895
h
#ifndef RENDERER_H #define RENDERER_H #include "vec_math.h" #include "device/display/color.h" namespace libesp { class BitArray; class DisplayDevice; } extern Matrix ModelView; extern Matrix Viewport; extern Matrix Projection; struct VertexStruct { Vec3f pos; libesp::RGBColor color; Vec3f normal; //VertexStruct(const Vec3f &p, const RGBColor &r) : pos(p), color(r) {} }; class Model { //no model matrix to save space and computation we assume identity public: enum MODEL_FORMAT { VERTS, STRIPS }; Model(); void set(const VertexStruct *v, uint16_t nv, const uint16_t *i, uint16_t ni, MODEL_FORMAT format); const Vec3f &normal(uint16_t face, uint8_t nVert) const; const Vec3f &vert(uint16_t face, uint8_t nVert) const; uint32_t nFaces() const; const Matrix &getModelTransform() const {return ModelTransform;} void setTransformation(float t) {ModelTransform.setRotation(t);} void scale(float t) {ModelTransform.scale(t);} private: const VertexStruct *Verts; uint16_t NumVerts; const uint16_t *Indexes; uint8_t NumIndexes; Matrix ModelTransform; MODEL_FORMAT Format; }; class IShader { public: IShader(); virtual ~IShader() = 0; virtual Vec3i vertex(const Matrix &ModelViewProj, const Model &model, int iface, int nthvert) = 0; virtual bool fragment(Vec3f bar, libesp::RGBColor &color) = 0; void setLightDir(const Vec3f &ld); const Vec3f &getLightDir() const; private: Vec3f LightDir; }; class FlatShader: public IShader { public: FlatShader(); virtual ~FlatShader(); virtual Vec3i vertex(const Matrix &ModelViewProj, const Model &model, int iface, int nthvert); virtual bool fragment(Vec3f bar, libesp::RGBColor &color); private: mat<3, 3, float> varying_tri; }; struct GouraudShader: public IShader { public: GouraudShader(); virtual ~GouraudShader(); virtual Vec3i vertex(const Matrix &ModelViewProj, const Model &model, int iface, int nthvert); virtual bool fragment(Vec3f bar, libesp::RGBColor &color); private: mat<3, 3, float> varying_tri; Vec3f varying_ity; }; class ToonShader: public IShader { public: ToonShader(); virtual ~ToonShader(); virtual Vec3i vertex(const Matrix &ModelViewProj, const Model &model, int iface, int nthvert); virtual bool fragment(Vec3f bar, libesp::RGBColor &color); private: mat<3, 3, float> varying_tri; Vec3f varying_ity; }; void viewport(int x, int y, int w, int h); void projection(float coeff = 0.f); // coeff = -1/c void lookat(const Vec3f &eye, const Vec3f &center, const Vec3f &up); //void triangle(Vec3i *pts, IShader &shader, BitArray &zbuffer, DisplayST7735 *display); void triangle(Vec3i *pts, IShader &shader, libesp::BitArray &zbuffer, libesp::DisplayDevice *display, const Vec2i &bboxmin, const Vec2i &bboxmax, uint16_t canvasWdith); template<typename T> T CLAMP(const T& value, const T& low, const T& high) { return value < low ? low : (value > high ? high : value); } #endif
[ "cmdc0dez@gmail.com" ]
cmdc0dez@gmail.com
42499f10e067b3ded9c68f309467860946d22058
aa9e9fc8044ed7d3e9370ecaa62bf62bfb0e3677
/GoogleDistributedCodeJam/2016R2/D-small.cc
8c6b1dc0faa06ee8462c928c99d7ffa0ea7a2970
[ "MIT" ]
permissive
zearom32/GCJ
d99d92b55a0de01f640a1adb047122107d065dc8
3b44f328cb5da24e7f5029f402b2761985b2e346
refs/heads/master
2021-01-13T13:05:30.595035
2017-01-13T16:00:40
2017-01-13T16:00:40
78,654,569
0
0
null
null
null
null
UTF-8
C++
false
false
2,164
cc
#include <iostream> #include <cstdio> #include <algorithm> #include <set> #include <vector> #include <map> #include <cstdlib> #include <message.h> #include "asteroids.h" using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; const LL master = 0; const LL myid = MyNodeId(); LL nodes = NumberOfNodes(); const LL height = GetHeight(); const LL width = GetWidth(); vector<LL> split_nodes(LL N, LL& nodes) { LL step = (N - 1) / nodes + 1; vector<LL> ans; LL st = 0; for (LL i = 0; i <= nodes; i++) { ans.push_back(st); st = min(N, st + step); } for (LL i = 0; i <= nodes; i++){ if (ans[i] == ans[i+1]) { nodes = i; break; } } return ans; } const LL inf = 1LL << 40; int main() { /* vector<LL> index = split_nodes(height, nodes); for (int i = index[myid]; i < index[myid+1]; i++) { } */ if (myid == master) { vector<LL> row(width); vector<LL> tmp = row; vector<LL> val = row; for (LL i = 0; i < height + 1; i++) { for (LL j = 0; j < width; j++) { LL v; char c; if (i == height) { c = '0'; }else c = GetPosition(i,j); if (c == '#') { tmp[j] = v = -inf; } else { v = c - '0'; if (row[j] == -inf) tmp[j] = -inf; else tmp[j] = row[j] + v; if (j > 0 && row[j-1] != -inf && val[j] != -inf) tmp[j] = max(tmp[j], v + row[j-1] + val[j]); if (j < width-1 && row[j+1] != -inf && val[j] != -inf) tmp[j] = max(tmp[j], v + row[j+1] + val[j]); } val[j] = v; } row = tmp; // for (auto k:row) if (k == -inf) cout << -1; else cout << k; // cout << endl; } LL ans = -inf; for (auto k:row) { ans = max(ans, k); } if (ans > 0) { cout << ans <<endl; } else cout << -1 << endl; } return 0; }
[ "zearom32@gmail.com" ]
zearom32@gmail.com
93ed48d8661bb7a85744bfa07d4eaaaa28a6c44b
bfebd6a2f4e69cbc51224a38875f90d3029dc70f
/Uva/Uva_705.cpp
9a6bb5a1e42892251be2fa51c5ac6277a2c3c55b
[]
no_license
jingfei/CodePractice
d7c301c466a61fe7db28681734bbda206f5aa4d6
30ce730b769c19ba93aba9f210809c7d12bb807d
refs/heads/master
2020-12-24T13:35:19.721294
2018-05-09T16:16:43
2018-05-09T16:16:43
25,290,228
0
0
null
null
null
null
UTF-8
C++
false
false
2,533
cpp
#include <iostream> #include <cstdio> #include <queue> #include <algorithm> #include <cstring> #define Max 80 using namespace std; struct Loc{ int y,x; }; queue <struct Loc> Q; int w,h; bool Maze[Max*3][Max*3]; void Trans(int,int,char); void Fill(int,int); void Print(); int Count(int,int); bool Check(int,int); int main(){ int Case=0; while(scanf("%d%d",&w,&h)!=EOF && !(w==0 && h==0)){ memset(Maze,0,sizeof(Maze)); char c; getchar(); for(int i=0; i<h; i++){ for(int j=0; j<w; j++){ scanf("%c",&c); Trans(i,j,c); } getchar(); } for(int i=0; i<w*3; i++){ if(!Maze[0][i]) Fill(0,i); if(!Maze[h*3-1][i]) Fill(h*3-1,i); } for(int i=0; i<h*3; i++){ if(!Maze[i][0]) Fill(i,0); if(!Maze[i][w*3-1]) Fill(i,w*3-1); } int Cycle=0, Longest=0; for(int i=1; i<h*3-1; i++) for(int j=1; j<w*3-1; j++) if(!Maze[i][j]){ int tmp=Count(i,j)/3; Longest=max(Longest,tmp); Cycle++; } printf("Maze #%d:\n",++Case); if(!Cycle)printf("There are no cycles.\n\n"); else printf("%d Cycles; the longest has length %d.\n\n",Cycle,Longest); } return 0; } void Trans(int y,int x,char c){ if(c=='/') Maze[y*3][x*3+2]=Maze[y*3+1][x*3+1]=Maze[y*3+2][x*3]=1; else if(c=='\\') Maze[y*3][x*3]=Maze[y*3+1][x*3+1]=Maze[y*3+2][x*3+2]=1; } void Fill(int y,int x){ struct Loc F,tmp; tmp.y=y; tmp.x=x; if(!Q.empty())Q.pop(); Q.push(tmp); while(!Q.empty()){ F=Q.front(); int Y=F.y, X=F.x; Maze[Y][X]=1; Q.pop(); if(Check(Y+1,X) && !Maze[Y+1][X]){tmp.y=Y+1; tmp.x=X; Q.push(tmp);} if(Check(Y,X+1) && !Maze[Y][X+1]){tmp.y=Y; tmp.x=X+1; Q.push(tmp);} if(Check(Y-1,X) && !Maze[Y-1][X]){tmp.y=Y-1; tmp.x=X; Q.push(tmp);} if(Check(Y,X-1) && !Maze[Y][X-1]){tmp.y=Y; tmp.x=X-1; Q.push(tmp);} } } int Count(int y,int x){ int ans=0; struct Loc F,tmp; tmp.y=y; tmp.x=x; if(!Q.empty())Q.pop(); Q.push(tmp); while(!Q.empty()){ F=Q.front(); int Y=F.y, X=F.x; if(Maze[Y][X]){Q.pop(); continue;} Maze[Y][X]=1; ans++; Q.pop(); if(Check(Y+1,X) && !Maze[Y+1][X]){tmp.y=Y+1; tmp.x=X; Q.push(tmp);} if(Check(Y,X+1) && !Maze[Y][X+1]){tmp.y=Y; tmp.x=X+1; Q.push(tmp);} if(Check(Y-1,X) && !Maze[Y-1][X]){tmp.y=Y-1; tmp.x=X; Q.push(tmp);} if(Check(Y,X-1) && !Maze[Y][X-1]){tmp.y=Y; tmp.x=X-1; Q.push(tmp);} } return ans; } bool Check(int y,int x){ if(y<0 || x<0 || y>=h*3 || x>=w*3) return false; return true; } void Print(){ for(int i=0; i<h*3; i++){ for(int j=0; j<w*3; j++) printf("%d",Maze[i][j]?1:0); printf("\n"); } printf("\n"); }
[ "jingfei955047@gmail.com" ]
jingfei955047@gmail.com
b5604c35cf6e6149eb084d47c4a86eeb84c449ee
95d980968a2f3f24dd2d83e696ae9eac0c03e9d7
/Chapter6/6.1/GraphIterators/listqueue.h
96dd55c3562e5d95aea80118e0f5e53f01430ba8
[]
no_license
Pavzh1kV/5-94157-506-8
86f7db331214fa2a1450b6646b545d5a1bad1d04
73f9eba12c7b33b3fac0eb8a5ecf35ef089e1065
refs/heads/master
2020-07-13T05:05:46.301636
2019-08-29T10:55:15
2019-08-29T10:55:15
204,997,171
0
0
null
null
null
null
UTF-8
C++
false
false
4,246
h
/*************************************************************** * Структуры и алгоритмы обработки данных: * * объектно-ориентированный подход и реализация на C++ * * Глава 6. Алгоритмы обработки сетевой информации * * 6.1. Обходы и поиск в графах * * * * Автор : А.Кубенский * * Файл : listqueue.h * * Описание : Шаблон классов для реализации очереди в виде * * списка элементов. * ***************************************************************/ #ifndef __LIST_QUEUE_H #define __LIST_QUEUE_H #include "queue.h" #include "queuefactory.h" #include "circularlist.h" //============================================================== // Определение класса основано на представлении очереди в виде // циклического списка элементов очереди. //============================================================== template<class T> class ListQueue : public Queue<T> { CircularList<T> list; // Базовый список public : // Конструктор "по умолчанию" создает пустую очередь ListQueue() : list() {} // Конструктор "копирования" использует операцию присваивания списков ListQueue(const ListQueue & src) { list = src.list; } // Виртуальный деструктор virtual ~ListQueue() {} // Добавление нового элемента происходит в конец кольцевого списка void enqueue(const T & item) { list.insertTail(item); } // Удаление элемента из списка void dequeue(); // Проверка пустоты очереди сводится к проверке пустоты списка bool empty() const { return list.empty(); } // Функции доступа к голове и хвосту очереди T & head(); const T & head() const; T & tail(); const T & tail() const; }; // Функции, не определенные "inline", "переименовывают" // исключительную ситуацию, возникающую при обработке списка, // в ситуацию, естественную для операций с очередью. template <class T> void ListQueue<T>::dequeue() { try { list.removeHead(); } catch (EmptyException) { throw QueueUnderflow(); } } template <class T> T & ListQueue<T>::head() { try { return list.head(); } catch (EmptyException) { throw QueueUnderflow(); } } template <class T> const T & ListQueue<T>::head() const { try { return list.head(); } catch (EmptyException) { throw QueueUnderflow(); } } template <class T> T & ListQueue<T>::tail() { try { return list.tail(); } catch (EmptyException e) { throw QueueUnderflow(); } } template <class T> const T & ListQueue<T>::tail() const { try { return list.tail(); } catch (EmptyException e) { throw QueueUnderflow(); } } //============================================================== // Фабрика порождения очередей типа ListQueue наследует // абстрактной фабрике очередей QueueFactory //============================================================== template <class T> class ListQueueFactory : public QueueFactory<T> { public: // Аргумент игнорируется. Queue<T> *newQueue(int size = 100) { return new ListQueue<T>; } }; #endif
[ "v.pavzhik@gmail.com" ]
v.pavzhik@gmail.com
193755e6867f34b64eedd7b1fac374a4b76ae9be
385cfbb27ee3bcc219ec2ac60fa22c2aa92ed8a0
/Render3D/NodeSpin.h
69cd880426f06d96a7cb004f6b0da972e626e8a5
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
palestar/medusa
edbddf368979be774e99f74124b9c3bc7bebb2a8
7f8dc717425b5cac2315e304982993354f7cb27e
refs/heads/develop
2023-05-09T19:12:42.957288
2023-05-05T12:43:35
2023-05-05T12:43:35
59,434,337
35
18
MIT
2018-01-21T01:34:01
2016-05-22T21:05:17
C++
UTF-8
C++
false
false
956
h
/* NodeSpin.h (c)2005 Palestar, Richard Lyle */ #ifndef NODE_SPIN_H #define NODE_SPIN_H #include "Render3D/NodeTransform.h" #include "Render3D/Render3dDll.h" //------------------------------------------------------------------------------- class DLL NodeSpin : public NodeTransform { public: DECLARE_WIDGET_CLASS(); DECLARE_PROPERTY_LIST(); // Types typedef Reference<NodeSpin> Ref; // Construction NodeSpin(); // NodeTransform Interface void preRender( RenderContext & context, const Matrix33 & frame, const Vector3 & position ); // Accessors float pitch() const; float yaw() const; float roll() const; // Mutators void setSpin( float pitch, float yaw, float roll ); private: // Data float m_Pitch, m_Yaw, m_Roll; }; //------------------------------------------------------------------------------- #endif //------------------------------------------------------------------------------- // EOF
[ "rlyle@palestar.com" ]
rlyle@palestar.com
09b683bc79139c6e3d818e773c2e1d30f6cec05d
8242d218808b8cc5734a27ec50dbf1a7a7a4987a
/Intermediate/Build/Win64/Netshoot/Development/TakeMovieScene/Module.TakeMovieScene.gen.cpp
774967eb6a77978b27073e1183bee3f24cfc8c84
[]
no_license
whyhhr/homework2
a2e75b494a962eab4fb0a740f83dc8dc27f8f6ee
9808107fcc983c998d8601920aba26f96762918c
refs/heads/main
2023-08-29T08:14:39.581638
2021-10-22T16:47:11
2021-10-22T16:47:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
635
cpp
// This file is automatically generated at compile-time to include some subset of the user-created cpp files. #include "F:/UE4Source/myproject/work2/Netshoot/Intermediate/Build/Win64/Netshoot/Inc/TakeMovieScene/MovieSceneTakeSection.gen.cpp" #include "F:/UE4Source/myproject/work2/Netshoot/Intermediate/Build/Win64/Netshoot/Inc/TakeMovieScene/MovieSceneTakeSettings.gen.cpp" #include "F:/UE4Source/myproject/work2/Netshoot/Intermediate/Build/Win64/Netshoot/Inc/TakeMovieScene/MovieSceneTakeTrack.gen.cpp" #include "F:/UE4Source/myproject/work2/Netshoot/Intermediate/Build/Win64/Netshoot/Inc/TakeMovieScene/TakeMovieScene.init.gen.cpp"
[ "49893309+whyhhr@users.noreply.github.com" ]
49893309+whyhhr@users.noreply.github.com
93c0ad8fefc533e9436c847982ae88b45c9f8f6b
47a0a6676349129af4873dc1951531bd76b28228
/device/fido/virtual_fido_device.h
0504281ea265103236a921e4c31965bb664caa6f
[ "BSD-3-Clause" ]
permissive
Kaleb8812/chromium
f61c4a42e211ba4df707a45388a62e70dcae9cd7
4c098731f333f0d38b403af55133182d626be182
refs/heads/master
2022-12-23T01:13:33.470865
2018-04-06T11:44:50
2018-04-06T11:44:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,501
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 DEVICE_FIDO_VIRTUAL_FIDO_DEVICE_H_ #define DEVICE_FIDO_VIRTUAL_FIDO_DEVICE_H_ #include <stdint.h> #include <map> #include <memory> #include <string> #include <utility> #include <vector> #include "base/component_export.h" #include "base/containers/span.h" #include "base/macros.h" #include "base/memory/scoped_refptr.h" #include "device/fido/fido_device.h" namespace crypto { class ECPrivateKey; } // namespace crypto namespace device { class COMPONENT_EXPORT(DEVICE_FIDO) VirtualFidoDevice : public FidoDevice { public: // Encapsulates information corresponding to one registered key on the virtual // authenticator device. struct COMPONENT_EXPORT(DEVICE_FIDO) RegistrationData { RegistrationData(); RegistrationData(std::unique_ptr<crypto::ECPrivateKey> private_key, std::vector<uint8_t> application_parameter, uint32_t counter); RegistrationData(RegistrationData&& data); RegistrationData& operator=(RegistrationData&& other); ~RegistrationData(); std::unique_ptr<crypto::ECPrivateKey> private_key; std::vector<uint8_t> application_parameter; uint32_t counter = 0; DISALLOW_COPY_AND_ASSIGN(RegistrationData); }; // Stores the state of the device. Since |U2fDevice| objects only persist for // the lifetime of a single request, keeping state in an external object is // neccessary in order to provide continuity between requests. class COMPONENT_EXPORT(DEVICE_FIDO) State : public base::RefCounted<State> { public: State(); // The common name in the attestation certificate. std::string attestation_cert_common_name; // The common name in the attestation certificate if individual attestation // is requested. std::string individual_attestation_cert_common_name; // Registered keys. Keyed on key handle (a.k.a. "credential ID"). std::map<std::vector<uint8_t>, RegistrationData> registrations; private: friend class base::RefCounted<State>; ~State(); DISALLOW_COPY_AND_ASSIGN(State); }; // Constructs an object with ephemeral state. In order to have the state of // the device persist between operations, use the constructor that takes a // scoped_refptr<State>. VirtualFidoDevice(); // Constructs an object that will read from, and write to, |state|. explicit VirtualFidoDevice(scoped_refptr<State> state); ~VirtualFidoDevice() override; State* mutable_state() { return state_.get(); } protected: // U2fDevice: void TryWink(WinkCallback cb) override; std::string GetId() const override; void DeviceTransact(std::vector<uint8_t> command, DeviceCallback cb) override; base::WeakPtr<FidoDevice> GetWeakPtr() override; private: base::Optional<std::vector<uint8_t>> DoRegister( uint8_t ins, uint8_t p1, uint8_t p2, base::span<const uint8_t> data); base::Optional<std::vector<uint8_t>> DoSign(uint8_t ins, uint8_t p1, uint8_t p2, base::span<const uint8_t> data); scoped_refptr<State> state_; base::WeakPtrFactory<FidoDevice> weak_factory_; DISALLOW_COPY_AND_ASSIGN(VirtualFidoDevice); }; } // namespace device #endif // DEVICE_FIDO_VIRTUAL_FIDO_DEVICE_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
6ddf8bf8ddc585fc637534884ee1b909dc436eb7
483259d7b2021b4906b640c1846a89aa1ab72549
/src/tp/_testing/test_005.cxx
139745abfadca55fdedff8d18343061548943972
[ "BSD-2-Clause", "BSD-3-Clause", "LicenseRef-scancode-public-domain" ]
permissive
tmothupr/tacitpixel
df7abfa2c753364951ffdbd24d9f206ef9e6677c
c6450d692b59a02a34a3653c6460fca8be1fa89c
refs/heads/master
2021-01-23T06:55:40.021639
2013-04-14T21:25:37
2013-04-14T21:25:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
253
cxx
#include <tp/refptr.h> #include <tp/image.h> #include <tp/library.h> int main(int argc,char* argv[]) { tpLibrary::load("tacit_jpg"); tpLibrary::load("tacit_png"); tpRefPtr<tpImage> img = tpImage::read(argv[1]); img->write(argv[2]); return 0; }
[ "hartmut@technotecture.com" ]
hartmut@technotecture.com
39ee51a891d8e426c3d703efb5583ea3aa71d997
396a9c306e075c6933910f41fead17bb8840d83e
/ofxTouchGUI/src/ofxTouchGUIText.h
11aebf90f17f48c790cc50db23f7719669f73274
[]
no_license
moronlaw/ofxTouchGUI
9905ce8b665386988a54358de889fa21a2b91469
4b878d823ee25d4f34c6cb62e81db747df0839a5
refs/heads/master
2020-07-10T08:24:11.781112
2017-12-15T00:15:15
2017-12-15T00:15:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,318
h
#pragma once #include "ofMain.h" #include "ofxTouchGUIBase.h" // text will autowrap unless value passed in is a pointer // todo: add pointer, check if strngs == then format/wrap? // vars will not autowrap enum TextValueType { // everything excetp TEXT_STRING_VAL is for variables TEXT_INT, TEXT_FLOAT, TEXT_BOOL, TEXT_STRING, TEXT_STRING_VAL }; class ofxTouchGUIText : public ofxTouchGUIBase { public: ofxTouchGUIText(); ~ofxTouchGUIText(); // display virtual void draw(); void formatText(bool isTextTitle); string wrapString(string text, int maxWidth); void setBackgroundVisible(bool vis); void resetDefaultValue(); void setValue(float *val); void setValue(int *val); void setValue(bool *val); void setValue(string *val); // overriden to include 'background visible' void copyStyle(ofxTouchGUIText* source); protected: float baseLineOffset; bool isTextTitle; bool drawTextBg; // for var text only!!! // int, float, bool, string text, string title int textType; float *floatVal; int *intVal; bool *boolVal; string *stringVal; int defaultIntVal; float defaultFloatVal; bool defaultBoolVal; string defaultStringVal; };
[ "trentbrooks@gmail.com" ]
trentbrooks@gmail.com
7943a779841807bf41c4bbbfd9ec6918706b68f2
bd18972f5f6397a5df406fdad3053186e0c7e6c1
/libraries/basics/code/math/headers/basics/internal/Transformation.hpp
1af78d20a5a97b75b733bad8668a51f0b8209403
[ "BSL-1.0" ]
permissive
Sylkha/Skybubbles
287183fe7ad7df6fd85ba5591ea7a23ad71ac1e5
b4277ca165534b1b998e7c8dcfdf9424f8cae88a
refs/heads/main
2023-02-13T19:05:16.180618
2021-01-15T15:07:54
2021-01-15T15:07:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,400
hpp
/* * TRANSFORMATION * Copyright © 2014+ Ángel Rodríguez Ballesteros * * Distributed under the Boost Software License, version 1.0 * See documents/LICENSE.TXT or www.boost.org/LICENSE_1_0.txt * * angel.rodriguez@esne.edu * * C1801080018 */ #ifndef BASICS_TRANSFORMATION_HEADER #define BASICS_TRANSFORMATION_HEADER #include "Matrix.hpp" #include "Vector.hpp" namespace basics { template< unsigned DIMENSION, typename NUMERIC_TYPE > class Transformation { public: typedef NUMERIC_TYPE Numeric_Type; typedef Numeric_Type Number; static constexpr unsigned dimension = DIMENSION; static constexpr unsigned size = dimension + 1; typedef Matrix< size, size, Numeric_Type > Matrix; public: Matrix matrix; public: Transformation() : matrix(Matrix::identity) { } Transformation(const Matrix & matrix) : matrix(matrix) { } public: Transformation operator * (const Transformation & other) const { return this->matrix * other.matrix; } operator const Matrix & () const { return matrix; } }; typedef Transformation< 2, int > Transformation2i; typedef Transformation< 2, float > Transformation2f; typedef Transformation< 2, double > Transformation2d; typedef Transformation< 3, int > Transformation3i; typedef Transformation< 3, float > Transformation3f; typedef Transformation< 3, double > Transformation3d; template< typename NUMERIC_TYPE > Transformation< 2, NUMERIC_TYPE > rotate_then_translate_2d (float angle, const Vector< 2, NUMERIC_TYPE > & displacement) { Transformation< 2, NUMERIC_TYPE > transformation; NUMERIC_TYPE sin = NUMERIC_TYPE(std::sin (angle)); NUMERIC_TYPE cos = NUMERIC_TYPE(std::cos (angle)); transformation.matrix[0][2] = displacement.coordinates.x (); transformation.matrix[1][2] = displacement.coordinates.y (); transformation.matrix[0][0] = cos; transformation.matrix[0][1] = -sin; transformation.matrix[1][0] = sin; transformation.matrix[1][1] = cos; return transformation; } template< typename NUMERIC_TYPE > Transformation< 2, NUMERIC_TYPE > scale_then_translate_2d (NUMERIC_TYPE scale_x, NUMERIC_TYPE scale_y, const Vector< 2, NUMERIC_TYPE > & displacement) { Transformation< 2, NUMERIC_TYPE > transformation; transformation.matrix[0][2] = displacement.coordinates.x (); transformation.matrix[1][2] = displacement.coordinates.y (); transformation.matrix[0][0] = scale_x; transformation.matrix[1][1] = scale_y; return transformation; } template< typename NUMERIC_TYPE > inline Transformation< 2, NUMERIC_TYPE > scale_then_translate_2d (NUMERIC_TYPE scale, const Vector< 2, NUMERIC_TYPE > & displacement) { return scale_then_translate_2d (scale, scale, displacement); } template< typename NUMERIC_TYPE > Transformation< 2, NUMERIC_TYPE > translate_then_scale_2d (const Vector< 2, NUMERIC_TYPE > & displacement, NUMERIC_TYPE scale_x, NUMERIC_TYPE scale_y) { Transformation< 2, NUMERIC_TYPE > transformation; transformation.matrix[0][2] = displacement.coordinates.x () * scale_x; transformation.matrix[1][2] = displacement.coordinates.y () * scale_y; transformation.matrix[0][0] = scale_x; transformation.matrix[1][1] = scale_y; return transformation; } template< typename NUMERIC_TYPE > inline Transformation< 2, NUMERIC_TYPE > translate_then_scale_2d (const Vector< 2, NUMERIC_TYPE > & displacement, NUMERIC_TYPE scale) { return translate_then_scale_2d (displacement, scale, scale); } }; #endif
[ "noreply@github.com" ]
noreply@github.com
5f2454b0ecee060064adf874b7e9c0bee75ce61a
ad0f2de99d16246909d074e86448b285f5304391
/C6.ino
379ceb317a299dcc72f4c50aecea3edbfd421fa6
[]
no_license
sws2019-3/Tele-robotic
7958b80904de1f952a6a2a5970326d498a4af224
495925d2a2e73b9a488ab9afc0d2beeca7df6767
refs/heads/master
2020-06-18T13:48:39.292195
2019-07-14T00:43:58
2019-07-14T00:43:58
196,323,297
2
0
null
null
null
null
UTF-8
C++
false
false
943
ino
#include <AFMotor.h> #include <NewPing.h> #define TRIGGER_PIN 22 // Arduino pin tied to trigger pin on the ultrasonic sensor. #define ECHO_PIN 24 // Arduino pin tied to echo pin on the ultrasonic sensor. #define MAX_DISTANCE 200 NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); int state = -1; // 0 forward; 1 backward; 2 left; 3 right AF_DCMotor motor3(1); AF_DCMotor motor4(2); void setup() { // put your setup code here, to run once: motor3.setSpeed(1000); motor4.setSpeed(1000); // motor4.run( FORWARD ); // // motor3.run( BACKWARD ); state = 0; // motor3.run( RELEASE ); } void TurnLeft() { motor3.run(FORWARD); motor4.run(FORWARD); state = 2; } void GoForward() { motor3.run(FORWARD); motor4.run(BACKWARD); state = 0; } void loop() { // // put your main code here, to run repeatedly if (sonar.ping_cm() < 10 && state != 2) { TurnLeft(); } else if (state != 0){ GoForward(); } }
[ "zhu990729@163.com" ]
zhu990729@163.com
0b6a56149c627e5f1e915c4abb4642730c6e4e91
cbd7f17ec8e983e3f302aa3c9a4c5bd676789bef
/code/steps/source/model/wtg_models/wt_aerodynamic_model/aerd0_test.cpp
1b8bb091370c183e5a62b19ef1216442575b8646
[ "MIT" ]
permissive
yuanzy97/steps
477bce28a11c8e5890f27bb56490f3b80b343048
139193a9c84ad15e342f632ac29afac909802b78
refs/heads/master
2023-04-29T10:00:13.987075
2022-04-13T13:08:17
2022-04-13T13:08:17
256,682,978
0
0
MIT
2020-04-18T06:13:20
2020-04-18T06:13:20
null
UTF-8
C++
false
false
2,865
cpp
#include "header/basic/test_macro.h" #include "header/model/wtg_models/wt_aerodynamic_model/aerd0_test.h" #include "header/basic/utility.h" #include "header/steps_namespace.h" #include <cstdlib> #include <cstring> #include <istream> #include <iostream> #include <cstdio> #include <cmath> #ifdef ENABLE_STEPS_TEST using namespace std; AERD0_TEST::AERD0_TEST() : WT_AERODYNAMIC_MODEL_TEST() { TEST_ADD(AERD0_TEST::test_get_model_name); TEST_ADD(AERD0_TEST::test_set_get_parameters); } void AERD0_TEST::setup() { WT_AERODYNAMIC_MODEL_TEST::setup(); WT_GENERATOR* wt_gen = get_test_wt_generator(); AERD0 model(default_toolkit); DYNAMIC_MODEL_DATABASE& dmdb = default_toolkit.get_dynamic_model_database(); model.set_device_id(wt_gen->get_device_id()); model.set_number_of_pole_pairs(2); model.set_generator_to_turbine_gear_ratio(100.0); model.set_gear_efficiency(1.0); model.set_turbine_blade_radius_in_m(25.0); model.set_nominal_wind_speed_in_mps(13.0); model.set_nominal_air_density_in_kgpm3(1.25); model.set_air_density_in_kgpm3(1.25); model.set_turbine_speed_mode(WT_UNDERSPEED_MODE); model.set_C1(0.22); model.set_C2(116.0); model.set_C3(0.4); model.set_C4(5.0); model.set_C5(12.5); model.set_C6(0.0); model.set_C1(0.5176); model.set_C2(116.0); model.set_C3(0.4); model.set_C4(5.0); model.set_C5(21.0); model.set_C6(0.0068); dmdb.add_model(&model); } void AERD0_TEST::tear_down() { WT_AERODYNAMIC_MODEL_TEST::tear_down(); DYNAMIC_MODEL_DATABASE& dmdb = default_toolkit.get_dynamic_model_database(); dmdb.remove_the_last_model(); show_test_end_information(); } void AERD0_TEST::test_get_model_name() { show_test_information_for_function_of_class(__FUNCTION__,"AERD0_TEST"); WT_AERODYNAMIC_MODEL* model = get_test_wt_aerodynamic_model(); if(model!=NULL) { TEST_ASSERT(model->get_model_name()=="AERD0"); } else TEST_ASSERT(false); } void AERD0_TEST::test_set_get_parameters() { show_test_information_for_function_of_class(__FUNCTION__,"AERD0_TEST"); AERD0* model = (AERD0*) get_test_wt_aerodynamic_model(); model->set_C1(1.1); model->set_C2(2.2); model->set_C3(3.3); model->set_C4(4.4); model->set_C5(5.5); model->set_C6(6.6); model->set_C7(7.7); model->set_C8(8.8); TEST_ASSERT(fabs(model->get_C1()-1.1)<FLOAT_EPSILON); TEST_ASSERT(fabs(model->get_C2()-2.2)<FLOAT_EPSILON); TEST_ASSERT(fabs(model->get_C3()-3.3)<FLOAT_EPSILON); TEST_ASSERT(fabs(model->get_C4()-4.4)<FLOAT_EPSILON); TEST_ASSERT(fabs(model->get_C5()-5.5)<FLOAT_EPSILON); TEST_ASSERT(fabs(model->get_C6()-6.6)<FLOAT_EPSILON); TEST_ASSERT(fabs(model->get_C7()-7.7)<FLOAT_EPSILON); TEST_ASSERT(fabs(model->get_C8()-8.8)<FLOAT_EPSILON); } #endif
[ "lichgang@sdu.edu.cn" ]
lichgang@sdu.edu.cn
e7a6dc84b45bbdd8a99f5806b5203ab6090ff80a
6ea6f31be5d46fec966874227eebbbba8bca72b3
/Assignment5/Assignment5/final1.cpp
e13863a9aa4815fe5051d02950d2fc58d4d7ab61
[]
no_license
dimazhev/CS-20a-Santa-Monica-College
1b6a0369a2f1106934b075966fd04af6484d25ea
c3463bbf5680dbb652708e73a23077d9d41011c7
refs/heads/master
2022-09-09T20:22:23.616780
2020-05-25T23:48:03
2020-05-25T23:48:03
266,902,568
1
0
null
null
null
null
UTF-8
C++
false
false
639
cpp
//#include<iostream> //#include<string> //using namespace std; // //string replace(string input, char from, char to) //{ // string output = ""; // for (int i = 0; i < input.length(); i++) { // if (input[i] == from) { // output = output + to; // } // else { // output = output + input[i]; // } // } // return output; //} // // //int main() //{ // string input; // char from, to; // cout << "Input: "; // getline(cin, input); // cout << "From :"; // cin >> from; // cout << "To: "; // cin >> to; // string output = replace(input, from, to); // cout << output << endl; // // // return 0; // //}
[ "dzhevelev@aol.com" ]
dzhevelev@aol.com
f7326e9b18ff4d6fc8e1180cf105ec023c43e2d0
f576bc38a00e5950e02ea4a2a409844903d9060a
/main.cpp
5e2f571e0a3ba3fd396a390aa28ffe4cb3450b55
[]
no_license
zsotirov/CCDFilter
c102387e724009f66fed40203c87e4bec41e6151
5b6b807590765150664a979504459ade14b923ba
refs/heads/master
2020-07-05T06:09:34.853537
2014-09-08T21:25:13
2014-09-08T21:25:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,870
cpp
/* * File: main.cpp * Author: linuxuser * * Created on August 12, 2014, 9:04 AM * Last Modified September 8, 2014, 2:24 PM */ #include <cstdlib> #include <math.h> #include <time.h> #include <stdio.h> #include <stdlib.h> #include <iostream> #include <fstream> #include <string> using namespace std; /* * */ int ccd[5000]; int ccdv[5000]; int ccdc[5000]; int ccdcc[5000]; int ecpr = 5000; int eps = 500; bool interpolateSegment (int* idx, int ccd[], int ccdc[], int ccdv[]) { int i, j, k, l; double d; i = *idx; if (i == ecpr - 1) return true; while (ccdv[i] != 1 || ccdv[i + 1] != 0) { if ((i == ecpr - 2) && (ccdv[i + 1] == 1)) return true; i++; } int baseIdx = i; k = 1; i = baseIdx + 1; l = i; while (ccdv[l] == 0) { k++; i++; l = i; if (i >= ecpr) { l = i - ecpr; } } d = ((double) (ccd[l] - ccd[i - k])) / k; for (j = 0; j <= k; j++) { int n = baseIdx + j; if (n >= ecpr) { n = n - ecpr; } ccdc[n] = (int)((double) ccd[baseIdx] + j * d); } *idx = i; return false; } // // CCD filter // int validateCCDSample (int ccd[], int i, int ecpr, int eps) { int n = ecpr / 4; int i2, i3, i4; long err, err12, err13, err14; // // Calculate and normalize indexes // i2 = i + n; if (i2 >= ecpr) i2 = i2 - ecpr; i3 = i + 2 * n; if (i3 >= ecpr) i3 = i3 - ecpr; i4 = i + 3 * n; if (i4 >= ecpr) i4 = i4 - ecpr; err12 = labs (ccd[i] - ccd[i2]); err13 = labs (ccd[i] - ccd[i3]); err14 = labs (ccd[i] - ccd[i4]); // // Validate the CCD-sample // err = labs (ccd[i2] - ccd[i3]); if ((err < eps) && (err12 < eps || err13 < eps)) { return 1; } err = labs (ccd[i2] - ccd[i4]); if ((err < eps) && (err12 < eps || err14 < eps)) { return 1; } err = labs (ccd[i3] - ccd[i4]); if ((err < eps) && (err13 < eps || err14 < eps)) { return 1; } return 0; } int validateCCDSampleNew (int ccd[], int i, int ecpr, int eps) { int n = ecpr / 4; int i2, i3, i4; long delta = 500; // // Calculate and normalize indexes // i2 = i + n; if (i2 >= ecpr) i2 = i2 - ecpr; i3 = i + 2 * n; if (i3 >= ecpr) i3 = i3 - ecpr; i4 = i + 3 * n; if (i4 >= ecpr) i4 = i4 - ecpr; // // Validate the CCD-sample // if (ccd[i] < delta || ccd[i] > 3600 - delta) { if ((ccd[i2] > delta && ccd[i2] < 3600 - delta) || (ccd[i3] > delta && ccd[i3] < 3600 - delta) || (ccd[i4] > delta && ccd[i4] < 3600 - delta)) return 0; } return 1; } int main (int argc, char** argv) { int baseIdx; int baseCCD; int i, j, k; double d; FILE* fp; int ccdv_old; string line; double r[3]; int avg; ifstream myfile ("ccd5.txt"); int noCols; char sBuff[20]; i = 0; if (myfile.is_open()) { while (myfile.good()) { getline (myfile, line); double temp = atof (line.c_str()); if (temp == 0.0) temp = 3600.0; ccd[i++] = temp; } } myfile.close (); for (i = 0; i < ecpr; i++) { ccdv[i] = validateCCDSampleNew (ccd, i, ecpr, eps); if (ccdv[i] == 1) ccdc[i] = ccd[i]; } k = 0; i = 0; while (ccdv[i] != 1) { i++; } k = i; bool isEnd = false; while (i < (ecpr + k) && !isEnd) { isEnd = interpolateSegment (&i, ccd, ccdc, ccdv); } //----------------------------------------------------------- for (i = 0; i < 6; i++) { ccdv[i] = 1; ccdcc[i] = ccdc[i]; } for (i = 0; i < ecpr; i++) { avg = 0; for (k = 1; k < 6; k++) { j = i - k; if (j < 0) j = j + ecpr; avg += ccdc[j]; } avg = avg / 5; int err = ccdc[i] - avg; if (err < 0) err = -err; if (err > 100) { ccdv[i] = 0; } else { ccdv[i] = 1; ccdcc[i] = ccdc[i]; } } k = 0; i = 0; while (ccdv[i] != 1) { i++; } k = i; isEnd = false; while (i < (ecpr + k) && !isEnd) { isEnd = interpolateSegment (&i, ccdc, ccdcc, ccdv); } //----------------------------------------------------------- fp = fopen ("ccd5c.txt", "w"); for (i = 0; i < ecpr; i++) { fprintf (fp, "%d %d %d %d\n", ccdv[i], ccd[i], ccdc[i], ccdcc[i]); } fclose (fp); return 0; }
[ "zsotirov.gmail.com" ]
zsotirov.gmail.com
f788683c4398737a9c8d7240a136b3578a5c8842
83bacfbdb7ad17cbc2fc897b3460de1a6726a3b1
/v8_4_5/src/scopeinfo.cc
4ed22b19dcd9a37b60f07aacd92b09c923079ca2
[ "Apache-2.0", "bzip2-1.0.6", "BSD-3-Clause" ]
permissive
cool2528/miniblink49
d909e39012f2c5d8ab658dc2a8b314ad0050d8ea
7f646289d8074f098cf1244adc87b95e34ab87a8
refs/heads/master
2020-06-05T03:18:43.211372
2019-06-01T08:57:37
2019-06-01T08:59:56
192,294,645
2
0
Apache-2.0
2019-06-17T07:16:28
2019-06-17T07:16:27
null
UTF-8
C++
false
false
30,012
cc
// Copyright 2011 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <stdlib.h> #include "src/v8.h" #include "src/bootstrapper.h" #include "src/scopeinfo.h" #include "src/scopes.h" namespace v8 { namespace internal { Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope) { // Collect stack and context locals. ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone); ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone); ZoneList<Variable*> context_globals(scope->ContextGlobalCount(), zone); ZoneList<Variable*> strong_mode_free_variables(0, zone); scope->CollectStackAndContextLocals(&stack_locals, &context_locals, &context_globals, &strong_mode_free_variables); const int stack_local_count = stack_locals.length(); const int context_local_count = context_locals.length(); const int context_global_count = context_globals.length(); const int strong_mode_free_variable_count = strong_mode_free_variables.length(); // Make sure we allocate the correct amount. DCHECK_EQ(scope->ContextLocalCount(), context_local_count); DCHECK_EQ(scope->ContextGlobalCount(), context_global_count); bool simple_parameter_list = scope->is_function_scope() ? scope->is_simple_parameter_list() : true; // Determine use and location of the "this" binding if it is present. VariableAllocationInfo receiver_info; if (scope->has_this_declaration()) { Variable* var = scope->receiver(); if (!var->is_used()) { receiver_info = UNUSED; } else if (var->IsContextSlot()) { receiver_info = CONTEXT; } else { DCHECK(var->IsParameter()); receiver_info = STACK; } } else { receiver_info = NONE; } // Determine use and location of the function variable if it is present. VariableAllocationInfo function_name_info; VariableMode function_variable_mode; if (scope->is_function_scope() && scope->function() != NULL) { Variable* var = scope->function()->proxy()->var(); if (!var->is_used()) { function_name_info = UNUSED; } else if (var->IsContextSlot()) { function_name_info = CONTEXT; } else { DCHECK(var->IsStackLocal()); function_name_info = STACK; } function_variable_mode = var->mode(); } else { function_name_info = NONE; function_variable_mode = VAR; } DCHECK(context_global_count == 0 || scope->scope_type() == SCRIPT_SCOPE); const bool has_function_name = function_name_info != NONE; const bool has_receiver = receiver_info == STACK || receiver_info == CONTEXT; const int parameter_count = scope->num_parameters(); const int length = kVariablePartIndex + parameter_count + (1 + stack_local_count) + 2 * context_local_count + 2 * context_global_count + 3 * strong_mode_free_variable_count + (has_receiver ? 1 : 0) + (has_function_name ? 2 : 0); Factory* factory = isolate->factory(); Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); // Encode the flags. int flags = ScopeTypeField::encode(scope->scope_type()) | CallsEvalField::encode(scope->calls_eval()) | LanguageModeField::encode(scope->language_mode()) | ReceiverVariableField::encode(receiver_info) | FunctionVariableField::encode(function_name_info) | FunctionVariableMode::encode(function_variable_mode) | AsmModuleField::encode(scope->asm_module()) | AsmFunctionField::encode(scope->asm_function()) | IsSimpleParameterListField::encode(simple_parameter_list) | FunctionKindField::encode(scope->function_kind()); scope_info->SetFlags(flags); scope_info->SetParameterCount(parameter_count); scope_info->SetStackLocalCount(stack_local_count); scope_info->SetContextLocalCount(context_local_count); scope_info->SetContextGlobalCount(context_global_count); scope_info->SetStrongModeFreeVariableCount(strong_mode_free_variable_count); int index = kVariablePartIndex; // Add parameters. DCHECK(index == scope_info->ParameterEntriesIndex()); for (int i = 0; i < parameter_count; ++i) { scope_info->set(index++, *scope->parameter(i)->name()); } // Add stack locals' names. We are assuming that the stack locals' // slots are allocated in increasing order, so we can simply add // them to the ScopeInfo object. int first_slot_index; if (stack_local_count > 0) { first_slot_index = stack_locals[0]->index(); } else { first_slot_index = 0; } DCHECK(index == scope_info->StackLocalFirstSlotIndex()); scope_info->set(index++, Smi::FromInt(first_slot_index)); DCHECK(index == scope_info->StackLocalEntriesIndex()); for (int i = 0; i < stack_local_count; ++i) { DCHECK(stack_locals[i]->index() == first_slot_index + i); scope_info->set(index++, *stack_locals[i]->name()); } // Due to usage analysis, context-allocated locals are not necessarily in // increasing order: Some of them may be parameters which are allocated before // the non-parameter locals. When the non-parameter locals are sorted // according to usage, the allocated slot indices may not be in increasing // order with the variable list anymore. Thus, we first need to sort them by // context slot index before adding them to the ScopeInfo object. context_locals.Sort(&Variable::CompareIndex); // Add context locals' names. DCHECK(index == scope_info->ContextLocalNameEntriesIndex()); for (int i = 0; i < context_local_count; ++i) { scope_info->set(index++, *context_locals[i]->name()); } // Add context globals' names. DCHECK(index == scope_info->ContextGlobalNameEntriesIndex()); for (int i = 0; i < context_global_count; ++i) { scope_info->set(index++, *context_globals[i]->name()); } // Add context locals' info. DCHECK(index == scope_info->ContextLocalInfoEntriesIndex()); for (int i = 0; i < context_local_count; ++i) { Variable* var = context_locals[i]; uint32_t value = ContextLocalMode::encode(var->mode()) | ContextLocalInitFlag::encode(var->initialization_flag()) | ContextLocalMaybeAssignedFlag::encode(var->maybe_assigned()); scope_info->set(index++, Smi::FromInt(value)); } // Add context globals' info. DCHECK(index == scope_info->ContextGlobalInfoEntriesIndex()); for (int i = 0; i < context_global_count; ++i) { Variable* var = context_globals[i]; // TODO(ishell): do we need this kind of info for globals here? uint32_t value = ContextLocalMode::encode(var->mode()) | ContextLocalInitFlag::encode(var->initialization_flag()) | ContextLocalMaybeAssignedFlag::encode(var->maybe_assigned()); scope_info->set(index++, Smi::FromInt(value)); } DCHECK(index == scope_info->StrongModeFreeVariableNameEntriesIndex()); for (int i = 0; i < strong_mode_free_variable_count; ++i) { scope_info->set(index++, *strong_mode_free_variables[i]->name()); } DCHECK(index == scope_info->StrongModeFreeVariablePositionEntriesIndex()); for (int i = 0; i < strong_mode_free_variable_count; ++i) { // Unfortunately, the source code positions are stored as int even though // int32_t would be enough (given the maximum source code length). Handle<Object> start_position = factory->NewNumberFromInt( static_cast<int32_t>(strong_mode_free_variables[i] ->strong_mode_reference_start_position())); scope_info->set(index++, *start_position); Handle<Object> end_position = factory->NewNumberFromInt( static_cast<int32_t>(strong_mode_free_variables[i] ->strong_mode_reference_end_position())); scope_info->set(index++, *end_position); } // If the receiver is allocated, add its index. DCHECK(index == scope_info->ReceiverEntryIndex()); if (has_receiver) { int var_index = scope->receiver()->index(); scope_info->set(index++, Smi::FromInt(var_index)); // ?? DCHECK(receiver_info != CONTEXT || var_index == // scope_info->ContextLength() - 1); } // If present, add the function variable name and its index. DCHECK(index == scope_info->FunctionNameEntryIndex()); if (has_function_name) { int var_index = scope->function()->proxy()->var()->index(); scope_info->set(index++, *scope->function()->proxy()->name()); scope_info->set(index++, Smi::FromInt(var_index)); DCHECK(function_name_info != CONTEXT || var_index == scope_info->ContextLength() - 1); } DCHECK(index == scope_info->length()); DCHECK(scope->num_parameters() == scope_info->ParameterCount()); DCHECK(scope->num_heap_slots() == scope_info->ContextLength() || (scope->num_heap_slots() == kVariablePartIndex && scope_info->ContextLength() == 0)); return scope_info; } Handle<ScopeInfo> ScopeInfo::CreateGlobalThisBinding(Isolate* isolate) { DCHECK(isolate->bootstrapper()->IsActive()); const int stack_local_count = 0; const int context_local_count = 1; const int context_global_count = 0; const int strong_mode_free_variable_count = 0; const bool simple_parameter_list = true; const VariableAllocationInfo receiver_info = CONTEXT; const VariableAllocationInfo function_name_info = NONE; const VariableMode function_variable_mode = VAR; const bool has_function_name = false; const bool has_receiver = true; const int parameter_count = 0; const int length = kVariablePartIndex + parameter_count + (1 + stack_local_count) + 2 * context_local_count + 2 * context_global_count + 3 * strong_mode_free_variable_count + (has_receiver ? 1 : 0) + (has_function_name ? 2 : 0); Factory* factory = isolate->factory(); Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); // Encode the flags. int flags = ScopeTypeField::encode(SCRIPT_SCOPE) | CallsEvalField::encode(false) | LanguageModeField::encode(SLOPPY) | ReceiverVariableField::encode(receiver_info) | FunctionVariableField::encode(function_name_info) | FunctionVariableMode::encode(function_variable_mode) | AsmModuleField::encode(false) | AsmFunctionField::encode(false) | IsSimpleParameterListField::encode(simple_parameter_list) | FunctionKindField::encode(FunctionKind::kNormalFunction); scope_info->SetFlags(flags); scope_info->SetParameterCount(parameter_count); scope_info->SetStackLocalCount(stack_local_count); scope_info->SetContextLocalCount(context_local_count); scope_info->SetContextGlobalCount(context_global_count); scope_info->SetStrongModeFreeVariableCount(strong_mode_free_variable_count); int index = kVariablePartIndex; const int first_slot_index = 0; DCHECK(index == scope_info->StackLocalFirstSlotIndex()); scope_info->set(index++, Smi::FromInt(first_slot_index)); DCHECK(index == scope_info->StackLocalEntriesIndex()); // Here we add info for context-allocated "this". DCHECK(index == scope_info->ContextLocalNameEntriesIndex()); scope_info->set(index++, *isolate->factory()->this_string()); DCHECK(index == scope_info->ContextLocalInfoEntriesIndex()); const uint32_t value = ContextLocalMode::encode(CONST) | ContextLocalInitFlag::encode(kCreatedInitialized) | ContextLocalMaybeAssignedFlag::encode(kNotAssigned); scope_info->set(index++, Smi::FromInt(value)); DCHECK(index == scope_info->StrongModeFreeVariableNameEntriesIndex()); DCHECK(index == scope_info->StrongModeFreeVariablePositionEntriesIndex()); // And here we record that this scopeinfo binds a receiver. DCHECK(index == scope_info->ReceiverEntryIndex()); const int receiver_index = Context::MIN_CONTEXT_SLOTS + 0; scope_info->set(index++, Smi::FromInt(receiver_index)); DCHECK(index == scope_info->FunctionNameEntryIndex()); DCHECK_EQ(index, scope_info->length()); DCHECK_EQ(scope_info->ParameterCount(), 0); DCHECK_EQ(scope_info->ContextLength(), Context::MIN_CONTEXT_SLOTS + 1); return scope_info; } ScopeInfo* ScopeInfo::Empty(Isolate* isolate) { return reinterpret_cast<ScopeInfo*>(isolate->heap()->empty_fixed_array()); } ScopeType ScopeInfo::scope_type() { DCHECK(length() > 0); return ScopeTypeField::decode(Flags()); } bool ScopeInfo::CallsEval() { return length() > 0 && CallsEvalField::decode(Flags()); } LanguageMode ScopeInfo::language_mode() { return length() > 0 ? LanguageModeField::decode(Flags()) : SLOPPY; } int ScopeInfo::LocalCount() { return StackLocalCount() + ContextLocalCount(); } int ScopeInfo::StackSlotCount() { if (length() > 0) { bool function_name_stack_slot = FunctionVariableField::decode(Flags()) == STACK; return StackLocalCount() + (function_name_stack_slot ? 1 : 0); } return 0; } int ScopeInfo::ContextLength() { if (length() > 0) { int context_locals = ContextLocalCount(); int context_globals = ContextGlobalCount(); bool function_name_context_slot = FunctionVariableField::decode(Flags()) == CONTEXT; bool has_context = context_locals > 0 || context_globals > 0 || function_name_context_slot || scope_type() == WITH_SCOPE || (scope_type() == ARROW_SCOPE && CallsSloppyEval()) || (scope_type() == FUNCTION_SCOPE && CallsSloppyEval()) || scope_type() == MODULE_SCOPE; if (has_context) { return Context::MIN_CONTEXT_SLOTS + context_locals + 2 * context_globals + (function_name_context_slot ? 1 : 0); } } return 0; } bool ScopeInfo::HasReceiver() { if (length() > 0) { return NONE != ReceiverVariableField::decode(Flags()); } else { return false; } } bool ScopeInfo::HasAllocatedReceiver() { if (length() > 0) { VariableAllocationInfo allocation = ReceiverVariableField::decode(Flags()); return allocation == STACK || allocation == CONTEXT; } else { return false; } } bool ScopeInfo::HasFunctionName() { if (length() > 0) { return NONE != FunctionVariableField::decode(Flags()); } else { return false; } } bool ScopeInfo::HasHeapAllocatedLocals() { if (length() > 0) { return ContextLocalCount() > 0; } else { return false; } } bool ScopeInfo::HasContext() { return ContextLength() > 0; } String* ScopeInfo::FunctionName() { DCHECK(HasFunctionName()); return String::cast(get(FunctionNameEntryIndex())); } String* ScopeInfo::ParameterName(int var) { DCHECK(0 <= var && var < ParameterCount()); int info_index = ParameterEntriesIndex() + var; return String::cast(get(info_index)); } String* ScopeInfo::LocalName(int var) { DCHECK(0 <= var && var < LocalCount()); DCHECK(StackLocalEntriesIndex() + StackLocalCount() == ContextLocalNameEntriesIndex()); int info_index = StackLocalEntriesIndex() + var; return String::cast(get(info_index)); } String* ScopeInfo::StackLocalName(int var) { DCHECK(0 <= var && var < StackLocalCount()); int info_index = StackLocalEntriesIndex() + var; return String::cast(get(info_index)); } int ScopeInfo::StackLocalIndex(int var) { DCHECK(0 <= var && var < StackLocalCount()); int first_slot_index = Smi::cast(get(StackLocalFirstSlotIndex()))->value(); return first_slot_index + var; } String* ScopeInfo::ContextLocalName(int var) { DCHECK(0 <= var && var < ContextLocalCount() + ContextGlobalCount()); int info_index = ContextLocalNameEntriesIndex() + var; return String::cast(get(info_index)); } VariableMode ScopeInfo::ContextLocalMode(int var) { DCHECK(0 <= var && var < ContextLocalCount() + ContextGlobalCount()); int info_index = ContextLocalInfoEntriesIndex() + var; int value = Smi::cast(get(info_index))->value(); return ContextLocalMode::decode(value); } InitializationFlag ScopeInfo::ContextLocalInitFlag(int var) { DCHECK(0 <= var && var < ContextLocalCount() + ContextGlobalCount()); int info_index = ContextLocalInfoEntriesIndex() + var; int value = Smi::cast(get(info_index))->value(); return ContextLocalInitFlag::decode(value); } MaybeAssignedFlag ScopeInfo::ContextLocalMaybeAssignedFlag(int var) { DCHECK(0 <= var && var < ContextLocalCount() + ContextGlobalCount()); int info_index = ContextLocalInfoEntriesIndex() + var; int value = Smi::cast(get(info_index))->value(); return ContextLocalMaybeAssignedFlag::decode(value); } bool ScopeInfo::LocalIsSynthetic(int var) { DCHECK(0 <= var && var < LocalCount()); // There's currently no flag stored on the ScopeInfo to indicate that a // variable is a compiler-introduced temporary. However, to avoid conflict // with user declarations, the current temporaries like .generator_object and // .result start with a dot, so we can use that as a flag. It's a hack! Handle<String> name(LocalName(var)); return (name->length() > 0 && name->Get(0) == '.') || name->Equals(*GetIsolate()->factory()->this_string()); } String* ScopeInfo::StrongModeFreeVariableName(int var) { DCHECK(0 <= var && var < StrongModeFreeVariableCount()); int info_index = StrongModeFreeVariableNameEntriesIndex() + var; return String::cast(get(info_index)); } int ScopeInfo::StrongModeFreeVariableStartPosition(int var) { DCHECK(0 <= var && var < StrongModeFreeVariableCount()); int info_index = StrongModeFreeVariablePositionEntriesIndex() + var * 2; int32_t value = 0; bool ok = get(info_index)->ToInt32(&value); USE(ok); DCHECK(ok); return value; } int ScopeInfo::StrongModeFreeVariableEndPosition(int var) { DCHECK(0 <= var && var < StrongModeFreeVariableCount()); int info_index = StrongModeFreeVariablePositionEntriesIndex() + var * 2 + 1; int32_t value = 0; bool ok = get(info_index)->ToInt32(&value); USE(ok); DCHECK(ok); return value; } int ScopeInfo::StackSlotIndex(String* name) { DCHECK(name->IsInternalizedString()); if (length() > 0) { int first_slot_index = Smi::cast(get(StackLocalFirstSlotIndex()))->value(); int start = StackLocalEntriesIndex(); int end = StackLocalEntriesIndex() + StackLocalCount(); for (int i = start; i < end; ++i) { if (name == get(i)) { return i - start + first_slot_index; } } } return -1; } int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info, Handle<String> name, VariableMode* mode, VariableLocation* location, InitializationFlag* init_flag, MaybeAssignedFlag* maybe_assigned_flag) { DCHECK(name->IsInternalizedString()); DCHECK(mode != NULL); DCHECK(location != NULL); DCHECK(init_flag != NULL); if (scope_info->length() > 0) { ContextSlotCache* context_slot_cache = scope_info->GetIsolate()->context_slot_cache(); int result = context_slot_cache->Lookup(*scope_info, *name, mode, location, init_flag, maybe_assigned_flag); if (result != ContextSlotCache::kNotFound) { DCHECK(result < scope_info->ContextLength()); return result; } DCHECK_EQ(scope_info->ContextGlobalNameEntriesIndex(), scope_info->ContextLocalNameEntriesIndex() + scope_info->ContextLocalCount()); int start = scope_info->ContextLocalNameEntriesIndex(); int end = scope_info->ContextGlobalNameEntriesIndex() + scope_info->ContextGlobalCount(); for (int i = start; i < end; ++i) { if (*name == scope_info->get(i)) { int var = i - start; *mode = scope_info->ContextLocalMode(var); *init_flag = scope_info->ContextLocalInitFlag(var); *maybe_assigned_flag = scope_info->ContextLocalMaybeAssignedFlag(var); if (var < scope_info->ContextLocalCount()) { *location = VariableLocation::CONTEXT; result = Context::MIN_CONTEXT_SLOTS + var; } else { var -= scope_info->ContextLocalCount(); *location = VariableLocation::GLOBAL; result = Context::MIN_CONTEXT_SLOTS + scope_info->ContextLocalCount() + 2 * var; } context_slot_cache->Update(scope_info, name, *mode, *location, *init_flag, *maybe_assigned_flag, result); DCHECK(result < scope_info->ContextLength()); return result; } } // Cache as not found. Mode, location, init flag and maybe assigned flag // don't matter. context_slot_cache->Update(scope_info, name, INTERNAL, VariableLocation::CONTEXT, kNeedsInitialization, kNotAssigned, -1); } return -1; } int ScopeInfo::ParameterIndex(String* name) { DCHECK(name->IsInternalizedString()); if (length() > 0) { // We must read parameters from the end since for // multiply declared parameters the value of the // last declaration of that parameter is used // inside a function (and thus we need to look // at the last index). Was bug# 1110337. int start = ParameterEntriesIndex(); int end = ParameterEntriesIndex() + ParameterCount(); for (int i = end - 1; i >= start; --i) { if (name == get(i)) { return i - start; } } } return -1; } int ScopeInfo::ReceiverContextSlotIndex() { if (length() > 0 && ReceiverVariableField::decode(Flags()) == CONTEXT) return Smi::cast(get(ReceiverEntryIndex()))->value(); return -1; } int ScopeInfo::FunctionContextSlotIndex(String* name, VariableMode* mode) { DCHECK(name->IsInternalizedString()); DCHECK(mode != NULL); if (length() > 0) { if (FunctionVariableField::decode(Flags()) == CONTEXT && FunctionName() == name) { *mode = FunctionVariableMode::decode(Flags()); return Smi::cast(get(FunctionNameEntryIndex() + 1))->value(); } } return -1; } FunctionKind ScopeInfo::function_kind() { return FunctionKindField::decode(Flags()); } void ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, Handle<Context> context, Handle<JSObject> scope_object) { Isolate* isolate = scope_info->GetIsolate(); int local_count = scope_info->ContextLocalCount(); if (local_count == 0) return; // Fill all context locals to the context extension. int first_context_var = scope_info->StackLocalCount(); int start = scope_info->ContextLocalNameEntriesIndex(); for (int i = 0; i < local_count; ++i) { if (scope_info->LocalIsSynthetic(first_context_var + i)) continue; int context_index = Context::MIN_CONTEXT_SLOTS + i; Handle<Object> value = Handle<Object>(context->get(context_index), isolate); // Reflect variables under TDZ as undefined in scope object. if (value->IsTheHole()) continue; // This should always succeed. // TODO(verwaest): Use AddDataProperty instead. JSObject::SetOwnPropertyIgnoreAttributes( scope_object, handle(String::cast(scope_info->get(i + start))), value, ::NONE).Check(); } } int ScopeInfo::ParameterEntriesIndex() { DCHECK(length() > 0); return kVariablePartIndex; } int ScopeInfo::StackLocalFirstSlotIndex() { return ParameterEntriesIndex() + ParameterCount(); } int ScopeInfo::StackLocalEntriesIndex() { return StackLocalFirstSlotIndex() + 1; } int ScopeInfo::ContextLocalNameEntriesIndex() { return StackLocalEntriesIndex() + StackLocalCount(); } int ScopeInfo::ContextGlobalNameEntriesIndex() { return ContextLocalNameEntriesIndex() + ContextLocalCount(); } int ScopeInfo::ContextLocalInfoEntriesIndex() { return ContextGlobalNameEntriesIndex() + ContextGlobalCount(); } int ScopeInfo::ContextGlobalInfoEntriesIndex() { return ContextLocalInfoEntriesIndex() + ContextLocalCount(); } int ScopeInfo::StrongModeFreeVariableNameEntriesIndex() { return ContextGlobalInfoEntriesIndex() + ContextGlobalCount(); } int ScopeInfo::StrongModeFreeVariablePositionEntriesIndex() { return StrongModeFreeVariableNameEntriesIndex() + StrongModeFreeVariableCount(); } int ScopeInfo::ReceiverEntryIndex() { return StrongModeFreeVariablePositionEntriesIndex() + 2 * StrongModeFreeVariableCount(); } int ScopeInfo::FunctionNameEntryIndex() { return ReceiverEntryIndex() + (HasAllocatedReceiver() ? 1 : 0); } int ContextSlotCache::Hash(Object* data, String* name) { // Uses only lower 32 bits if pointers are larger. uintptr_t addr_hash = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(data)) >> 2; return static_cast<int>((addr_hash ^ name->Hash()) % kLength); } int ContextSlotCache::Lookup(Object* data, String* name, VariableMode* mode, VariableLocation* location, InitializationFlag* init_flag, MaybeAssignedFlag* maybe_assigned_flag) { int index = Hash(data, name); Key& key = keys_[index]; if ((key.data == data) && key.name->Equals(name)) { Value result(values_[index]); if (mode != NULL) *mode = result.mode(); if (location != NULL) *location = result.location(); if (init_flag != NULL) *init_flag = result.initialization_flag(); if (maybe_assigned_flag != NULL) *maybe_assigned_flag = result.maybe_assigned_flag(); return result.index() + kNotFound; } return kNotFound; } void ContextSlotCache::Update(Handle<Object> data, Handle<String> name, VariableMode mode, VariableLocation location, InitializationFlag init_flag, MaybeAssignedFlag maybe_assigned_flag, int slot_index) { DisallowHeapAllocation no_gc; Handle<String> internalized_name; DCHECK(slot_index > kNotFound); if (StringTable::InternalizeStringIfExists(name->GetIsolate(), name). ToHandle(&internalized_name)) { int index = Hash(*data, *internalized_name); Key& key = keys_[index]; key.data = *data; key.name = *internalized_name; // Please note value only takes a uint as index. values_[index] = Value(mode, location, init_flag, maybe_assigned_flag, slot_index - kNotFound).raw(); #ifdef DEBUG ValidateEntry(data, name, mode, location, init_flag, maybe_assigned_flag, slot_index); #endif } } void ContextSlotCache::Clear() { for (int index = 0; index < kLength; index++) keys_[index].data = NULL; } #ifdef DEBUG void ContextSlotCache::ValidateEntry(Handle<Object> data, Handle<String> name, VariableMode mode, VariableLocation location, InitializationFlag init_flag, MaybeAssignedFlag maybe_assigned_flag, int slot_index) { DisallowHeapAllocation no_gc; Handle<String> internalized_name; if (StringTable::InternalizeStringIfExists(name->GetIsolate(), name). ToHandle(&internalized_name)) { int index = Hash(*data, *name); Key& key = keys_[index]; DCHECK(key.data == *data); DCHECK(key.name->Equals(*name)); Value result(values_[index]); DCHECK(result.mode() == mode); DCHECK(result.location() == location); DCHECK(result.initialization_flag() == init_flag); DCHECK(result.maybe_assigned_flag() == maybe_assigned_flag); DCHECK(result.index() + kNotFound == slot_index); } } static void PrintList(const char* list_name, int nof_internal_slots, int start, int end, ScopeInfo* scope_info) { if (start < end) { PrintF("\n // %s\n", list_name); if (nof_internal_slots > 0) { PrintF(" %2d - %2d [internal slots]\n", 0 , nof_internal_slots - 1); } for (int i = nof_internal_slots; start < end; ++i, ++start) { PrintF(" %2d ", i); String::cast(scope_info->get(start))->ShortPrint(); PrintF("\n"); } } } void ScopeInfo::Print() { PrintF("ScopeInfo "); if (HasFunctionName()) { FunctionName()->ShortPrint(); } else { PrintF("/* no function name */"); } PrintF("{"); PrintList("parameters", 0, ParameterEntriesIndex(), ParameterEntriesIndex() + ParameterCount(), this); PrintList("stack slots", 0, StackLocalEntriesIndex(), StackLocalEntriesIndex() + StackLocalCount(), this); PrintList("context slots", Context::MIN_CONTEXT_SLOTS, ContextLocalNameEntriesIndex(), ContextLocalNameEntriesIndex() + ContextLocalCount(), this); PrintF("}\n"); } #endif // DEBUG //--------------------------------------------------------------------------- // ModuleInfo. Handle<ModuleInfo> ModuleInfo::Create(Isolate* isolate, ModuleDescriptor* descriptor, Scope* scope) { Handle<ModuleInfo> info = Allocate(isolate, descriptor->Length()); info->set_host_index(descriptor->Index()); int i = 0; for (ModuleDescriptor::Iterator it = descriptor->iterator(); !it.done(); it.Advance(), ++i) { Variable* var = scope->LookupLocal(it.local_name()); info->set_name(i, *(it.export_name()->string())); info->set_mode(i, var->mode()); DCHECK(var->index() >= 0); info->set_index(i, var->index()); } DCHECK(i == info->length()); return info; } } // namespace internal } // namespace v8
[ "22249030@qq.com" ]
22249030@qq.com
8aaf28de7ea73f4d77839c21a6eed7d56d742c3f
7d70b0d051b4d00a94243bffc3cf55e5ca2ce2b2
/ponder.cpp
d94a301f4028b49924a38c8a3484ef59c2eea25b
[]
no_license
RichardEGeorge/PonderThisMay2015
bd260430b32c0c115cc38ed4c62e86b8b23f360f
dec4987c4eaa175b65c82fc3feaa7c2f69196d76
refs/heads/master
2021-01-10T15:27:29.978070
2015-06-02T00:10:17
2015-06-02T00:10:17
36,696,593
0
0
null
null
null
null
UTF-8
C++
false
false
8,316
cpp
// // Ponder This May 2015 Solution by Richard George (rg.george1@gmail.com) // #include <iostream> #include <fstream> #include <set> #include <string> #include <sstream> #include "GameState.h" #include "ponder.h" // Solver driver int explore_game(const GameState &starting) { // If the starting condition is not in the game, abort if (starting.isValid()==false) return 0; std::set<GameState> known; // states already visited std::set<GameState> to_explore; // states to play std::set<GameState> leafs; // novel states reached from states in to_explore to_explore.insert(starting); // add the starting state to the states to explore bool useful = true; int rounds = 0; while (true) { useful = explore_game2(known,to_explore,leafs,rounds); // make one iteration rounds++; if (useful==false) break; known.insert(to_explore.begin(),to_explore.end()); // add explored states to known states std::swap(to_explore,leafs); // swap leafs into to_explore for next round std::set<GameState> empty; std::swap(leafs,empty); // empty the list of leaf states } // the number of iterations before we reached an end-game state return rounds; } bool explore_game2(std::set<GameState> &known,std::set<GameState> &to_explore,std::set<GameState> &leafs,int depth) { // Performs one round of iteration towards the solution // // known - set of visited game states // to_explore - set of input states to play // leafs - set of new game states generated by possible moves on 'to_explore' // iterator over states to_explore std::set<GameState>::iterator it; // Flag to monitor if a move took place bool moved=false; // Iterate over each input state that has not yet been played for (it=to_explore.begin();it!=to_explore.end();it++) { // If the input state has already been played, skip it std::set<GameState>::iterator i0 = known.find(*it); if (i0!=known.end()) continue; // Generate three new game states m1,m2,m3 // which result from playing move 0,1,2 on the input state // If any of the states will end the game, stop iterating and return false GameState m1(*it,0); if (m1.isValid()==false) return false; GameState m2(*it,1); if (m2.isValid()==false) return false; GameState m3(*it,2); if (m3.isValid()==false) return false; // If the resulting state is novel, add it to the output set of leaf states // which will be explored in the next iteration, and flag that a move // has taken place std::set<GameState>::iterator i1=known.find(m1); // if m1 is not in 'known' set if (i1==known.end()) { leafs.insert(m1); moved=true; } std::set<GameState>::iterator i2=known.find(m2); // if m2 is not in 'known' set if (i2==known.end()) { leafs.insert(m2); moved=true; } std::set<GameState>::iterator i3=known.find(m3); // if m3 is not in 'known' set if (i3==known.end()) { leafs.insert(m3); moved=true; } } // returns 'true' if another iteration is justified and 'false' otherwise return moved; } // Main program int main(int argc,char **argv,char **envp) { std::cout << std::endl; std::cout << "IBM Ponder This May 2015 Challenge" << std::endl; std::cout << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" << std::endl << std::endl; std::cout << "by Richard George (rg.george1@gmail.com)" << std::endl << std::endl; if (sanity()==false) { std::cout << "Bug in program" << std::endl; return 1; } switch (argc) { case 1: solve_problem("solution.txt"); break; case 2: solve_problem(argv[1]); break; default: std::cout << argv[0] << " solution.txt" << std::endl; std::cout << std::endl; std::cout << "Solve betting problem and write result to <solution.txt>" << std::endl; break; } return 0; } bool sanity() { GameState g0(5, 7, 7); // Not a valid game state GameState g1(1, 2, 254); // Finish in 1 round GameState g2(2, 3, 254); // ... in 2 rounds GameState g3(3, 4, 254); // ... in 3 rounds GameState g4(4, 5, 254); // GameState g5(4, 9, 254); // These come from a (slower) python implementation GameState g6(8, 11, 254); GameState g7(12, 19, 254); GameState g8(8, 35, 254); GameState g9(1, 4, 6); // From webpage, known to finish in 15 minutes = at round 2 if (explore_game(g0)!=0) return false; // Verify that we get the expected number if (explore_game(g1)!=1) return false; // of rounds for given input states if (explore_game(g2)!=2) return false; // if (explore_game(g3)!=3) return false; // report an error if not if (explore_game(g4)!=4) return false; if (explore_game(g5)!=5) return false; if (explore_game(g6)!=6) return false; if (explore_game(g7)!=7) return false; if (explore_game(g8)!=8) return false; if (explore_game(g9)!=2) return false; return true; } void solve_problem(const char *fname) { int i,j,k; // monies of players 1,2,3 int a=0,s=0; // s counts number of solutions found, a counts number of trials int n=0; // n manages display of progress int l; // l is the minimum length, in rounds, of the game starting at (i,j,k) bool found=false; // A flag to note when a solution is found for display purposes std::set<std::pair<GameState,int> > results; // Outer loop over the money of player one for (i=3;i<256;i++) { // Print a dot whilst searching, but print a star if the last search was successful std::cout << (found ? '*' : '.') << std::flush; found = false; // Scroll the screen nicely to demonstrate activity n++; if (((n % 60)==0) && (n!=0)) { double progress = double(a)/double(255.0*254.0*253.0/6.0); std::cout << " " << i << "/255 (" << float(int(progress*1000.0))/10.0; std::cout << "%)" << std::endl; } // Inner loops over the money of players two and three for (j=2;j<i;j++) { for (k=1;k<j;k++) { // Create a gamestate for the current value of (i,j,k) GameState g(i,j,k); // Measure the number of moves required to complete game (i,j,k) l = explore_game(g); // If the game ends on turn 11 or later (counted from zero) // then the game will take at least 60 minutes if (l>=11) { // Store the result for printing later results.insert(std::pair<GameState,int>(g,l)); // s counts the total number of solutions found s++; // flag that we found a solution found = true; } // 'a' counts the total number of iterations a++; } } // Signal that we've searched all combinations if (i==255) { std::cout << " 255/255 (100%)" << std::endl; } } // Report the results i = 1; // Recycle variable 'i' now to count solutions std::cout << std::endl << "Found " << s << " solution" << ( (s==1) ? ' ' : 's' ); std::cout << std::endl << std::endl; // Write the result to disk also std::ofstream ofs(fname,std::ios::out); std::set<std::pair<GameState,int> >::iterator it; for (it=results.begin();it!=results.end();it++) { std::stringstream ss; ss << "Solution " << i++ << ": Game starting in state "; ss << it->first << " takes " << (it->second + 1) * 5; ss << " minutes to complete"; ofs << ss.str() << std::endl; std::cout << ss.str() << std::endl; } std::cout << std::endl; }
[ "richard@Richards-MacBook-Air.local" ]
richard@Richards-MacBook-Air.local
b1dc3b92c89155e378a6d8ef960bd487cf4bdcf6
a1dd219c114cb52601642659712d2bd2b2ca77d3
/engine/src/hikari/core/game/map/Door.cpp
beb0402cef44e80149cdb37195bf3244c2ba3827
[]
no_license
monsterji/hikari
9e9c2e52ba667a7a8026729eb6eaa3fb524f005d
2bc3a68cde651945ba31536b43bfd8f09e742a4d
refs/heads/master
2020-03-28T16:57:59.241649
2017-04-22T05:08:10
2017-04-22T05:08:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,788
cpp
#include "hikari/core/game/map/Door.hpp" #include "hikari/core/math/Vector2.hpp" #include "hikari/core/util/Log.hpp" #include <SFML/Graphics/RenderTarget.hpp> namespace hikari { const float Door::DOOR_SECTION_DELAY_SECONDS = (1.0f / 60.0f) * 4.0f; // 4 frames const int Door::DOOR_SECTION_COUNT = 4; // 4 sections in a door Door::Door(int x, int y, int width, int height) : timer(0.0f) , bounds(x, y, width, height) , animatedSprite() , doorState(DOOR_CLOSED) { animatedSprite.setPosition(Vector2<float>(x * 16.0f, y * 16.0f)); } Door::~Door() { } int Door::getX() const { return bounds.getPosition().getX(); } int Door::getY() const { return bounds.getPosition().getY(); } int Door::getWidth() const { return bounds.getWidth(); } int Door::getHeight() const { return bounds.getHeight(); } bool Door::isOpen() const { return DOOR_OPEN == doorState; } bool Door::isClosed() const { return DOOR_CLOSED == doorState; } void Door::setAnimationSet(const std::shared_ptr<AnimationSet> & newAnimationSet) { animatedSprite.setAnimationSet(newAnimationSet); changeAnimation("closed"); } void Door::changeAnimation(const std::string& animationName) { animatedSprite.setAnimation(animationName); } void Door::open() { HIKARI_LOG(debug4) << "Door opening!"; changeAnimation("opening"); doorState = DOOR_OPENING; timer = DOOR_SECTION_DELAY_SECONDS * DOOR_SECTION_COUNT; } void Door::close() { HIKARI_LOG(debug4) << "Door closing!"; changeAnimation("closing"); doorState = DOOR_CLOSING; timer = DOOR_SECTION_DELAY_SECONDS * DOOR_SECTION_COUNT; } void Door::setOpen() { HIKARI_LOG(debug4) << "Door opened immediately!"; changeAnimation("open"); doorState = DOOR_OPEN; timer = 0.0f; } void Door::setClosed() { HIKARI_LOG(debug4) << "Door closed immediately!"; changeAnimation("closed"); doorState = DOOR_CLOSED; timer = 0.0f; } void Door::update(float dt) { if(timer > 0.0f) { timer -= dt; } else { switch(doorState) { case DOOR_OPENING: setOpen(); break; case DOOR_CLOSING: setClosed(); break; default: break; } } animatedSprite.update(dt); } void Door::render(sf::RenderTarget & target) const { animatedSprite.render(target); } } // hikari
[ "zack@zackthehuman.com" ]
zack@zackthehuman.com
72c369c06937bfae227d87cc4f867f30bf304932
24d3527ca20f8600d03f4634c8785c88931d73fe
/Chapitre_4/TD_Composition/vanne.cpp
7ab3b916efdfd69631d991ce6f7bf298918ff512
[]
no_license
GeoffreyBeranger/Apprendre_Cpp
803bb847fc17f397dec5afb028a645f4117b6bb7
2321d5b3997af2a6a25ab5637ef592316a794be2
refs/heads/master
2020-07-19T17:34:11.497367
2020-01-09T07:27:17
2020-01-09T07:27:17
206,487,755
0
0
null
null
null
null
UTF-8
C++
false
false
303
cpp
#include "vanne.h" using namespace std; Vanne::Vanne(int _impulsion, int _sensA, int _sensB): impulsion(_impulsion), sensA(_sensA), sensB(_sensB) { cout << "Vanne : " << impulsion << " - " << sensA << " - " << sensB << endl; } void Vanne::Ouvrir() { } void Vanne::Fermer() { }
[ "geoffreyberanger@hotmail.com" ]
geoffreyberanger@hotmail.com
7098ffeb5bd330534cc46eb6e77858cba84c6a6d
e2f226e2c13be0a7aeb982b1c45e2a9cd3af3cd7
/chef/beginner/BOOKCHEF.cpp
6468f31928971e097467e81a0c646302635d015c
[]
no_license
gosour/competitive
7732b47093c4d72ca986c2963cea1141a6e1a8c6
3897365c4109766c8d23ac71a365dd64f090866b
refs/heads/master
2021-01-01T16:44:11.410885
2017-07-27T04:51:19
2017-07-27T04:51:19
97,905,399
0
0
null
null
null
null
UTF-8
C++
false
false
1,493
cpp
#include<cstdio> #include<iostream> #include<cmath> #include<string> #include<cstring> #include<vector> #include<bitset> #include<list> #include<set> #include<map> #include<queue> #include<stack> #include<algorithm> #include<functional> #include<utility> #include<iterator> using namespace std; #define PI acos(-1.0) #define Pi 3.141592653589793 #define SQR(n) ( (n) * (n) ) const int INF = 1<<29; #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define REP(i,n) for(int i=0;i<(n);i++) #define REP2(i,a,b) for(int i=(a);i<=(b);i++) #define REPD(i,a,b) for(int i=(a);i>=(b);i--) inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; } #define pb push_back typedef vector<int> vi; struct Post{ int id; int p; string s; }; Post posts[100001]; Post ans[100001]; bool cmp(Post p1, Post p2){ if(p1.p > p2.p) return true; else return false; } int main(){ int n,m; cin>>n>>m; int specials[100001] = {}; REP(i,n){ int s; cin>>s; specials[s] = 1; } int idx1=0,idx2 = 0; REP(i,m){ int id,p; string s; cin>>id>>p>>s; if(specials[id]){ ans[idx1].id = id; ans[idx1].p = p; ans[idx1].s = s; idx1++; } else{ posts[idx2].id = id; posts[idx2].p = p; posts[idx2].s = s; idx2++; } } sort(posts, posts+idx2,cmp); sort(ans, ans+idx1,cmp); REP(i,idx1) cout<<ans[i].s<<endl; REP(i,idx2) cout<<posts[i].s<<endl; }
[ "sourav.goswami@lexmark.com" ]
sourav.goswami@lexmark.com
a2117fc2c105943a35fc0fb65b6f42fb8cd61d67
49f15e237696d1c166c727fad9c8923d33497494
/codeforces/robotSequence.cpp
228bca356271df5fe493eb307567cc01db9a4c34
[]
no_license
gauravkr123/Codes
280284a3c7cdab2454a8da267c0622b40707e32b
c0295cfbad7794a25c1d4cf85ef8d4d13da8f2c6
refs/heads/master
2020-03-22T17:29:24.819064
2017-12-14T17:59:33
2017-12-14T17:59:33
140,398,111
2
0
null
2018-07-10T08:01:38
2018-07-10T08:01:38
null
UTF-8
C++
false
false
1,154
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; string c; int counter =0; cin>>c; for(int i=0;i<n;i++){ int a=0,b=0; if(c[i]=='U'){ a=a-1; b=b; //cout<<" "<<"u"<<endl; } if(c[i]=='R'){ a=a; b=b+1; //cout<<" "<<"r"<<endl; } if(c[i]=='L'){ a=a; b=b-1; //cout<<" "<<"l"<<endl; } if(c[i]=='D'){ a=a+1; b=b; // cout<<" "<<"d"<<endl; } for(int j=i+1;j<n;j++){ if(c[j]=='U'){ a=a-1; b=b; //cout<<" "<<"u"<<endl; } if(c[j]=='R'){ a=a; b=b+1; //cout<<" "<<"r"<<endl; } if(c[j]=='L'){ a=a; b=b-1; //cout<<" "<<"l"<<endl; } if(c[j]=='D'){ a=a+1; b=b; //cout<<" "<<"d"<<endl; } if(a==0 &&b==0) counter++; } } cout<<counter<<endl; return 0; }
[ "vedicpartap1999@gmail.com" ]
vedicpartap1999@gmail.com
74102d1e533d15724bc816d89085ebb14a483d66
e6ccbfe8824cc6a44ca7440914e17c18c2bd465e
/gtest/test_suit_regex.cpp
a4bcc1e077e7651d8d236e3d747fd595e98ad56e
[ "Apache-2.0" ]
permissive
justchen/myRtspClient
55e314c6b1bcb7e3e9843ba9770c6e4b0537c7e4
95981e651edd0552e76a026b7427cc466b2310a7
refs/heads/master
2021-01-18T07:28:11.051761
2016-01-15T09:18:06
2016-01-15T09:18:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,834
cpp
// Copyright 2015 Ansersion // // 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 <stdio.h> #include <sys/types.h> #include <regex.h> #include <memory.h> #include <stdlib.h> #include <string> #include <list> #include <iostream> #include <gtest/gtest.h> #include "myRegex.h" using namespace std; TEST(myRegex, Regex_InvalidInput) { MyRegex Regex; char str[] = "ansersion"; char pattern[] = "ansersion"; list<string> group; bool IgnoreCase = true; /* int Regex(const char * str, const char * pattern, list<string> * groups, bool ignore_case = false); */ EXPECT_EQ(Regex.Regex(NULL, pattern, &group, IgnoreCase), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(str, NULL, &group, IgnoreCase), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(str, pattern, NULL, IgnoreCase), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(NULL, pattern, &group, !IgnoreCase), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(str, NULL, &group, !IgnoreCase), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(str, pattern, NULL,!IgnoreCase), MyRegex::REGEX_FAILURE); /* int Regex(const char * str, const char * pattern, bool ignore_case = false); */ EXPECT_EQ(Regex.Regex(NULL, pattern, IgnoreCase), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(str, NULL, IgnoreCase), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(NULL, pattern, !IgnoreCase), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(str, NULL, !IgnoreCase), MyRegex::REGEX_FAILURE); } TEST(myRegex, Regex_RegularInput) { char str[] = "ansersion"; char str_with_brackets[] = "an(sersion"; char str_with_new_line[] = "ansersion\nwan_ansersion"; char pattern[] = "anser(sion)"; char pattern_with_brackets[] = "an\\(sersion"; MyRegex Regex; list<string> group; EXPECT_EQ(Regex.Regex(str, pattern, &group), MyRegex::REGEX_SUCCESS); EXPECT_EQ(Regex.Regex(str_with_brackets, pattern_with_brackets, &group), MyRegex::REGEX_SUCCESS); EXPECT_EQ(Regex.Regex(str_with_new_line, pattern, &group), MyRegex::REGEX_SUCCESS); //### Test anchor tag '\b' ###// string AnchorStr1("rtsp://192.168.15.1007/test"); string AnchorStr2("rtsp://192.168.15.100/test"); string AnchorPattern("rtsp://([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})\\b"); EXPECT_EQ(Regex.Regex(AnchorStr1.c_str(), AnchorPattern.c_str(), &group), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(AnchorStr2.c_str(), AnchorPattern.c_str(), &group), MyRegex::REGEX_SUCCESS); //### Test single line ###// string SingleStr1("\r\n"); string SingleStr2("\n"); string SingleStr3("ansersion\r\n"); string SingleStr4("\r\nansersion"); string SingleStr5("\nansersion"); string SingleStr6("ansersion\n"); string SinglePattern("^(\r\n|\n)$"); EXPECT_EQ(Regex.Regex(SingleStr1.c_str(), SinglePattern.c_str()), MyRegex::REGEX_SUCCESS); EXPECT_EQ(Regex.Regex(SingleStr2.c_str(), SinglePattern.c_str()), MyRegex::REGEX_SUCCESS); EXPECT_EQ(Regex.Regex(SingleStr3.c_str(), SinglePattern.c_str()), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(SingleStr4.c_str(), SinglePattern.c_str()), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(SingleStr5.c_str(), SinglePattern.c_str()), MyRegex::REGEX_FAILURE); EXPECT_EQ(Regex.Regex(SingleStr6.c_str(), SinglePattern.c_str()), MyRegex::REGEX_FAILURE); } TEST(myRegex, RegexLine_RegularInput) { string str = "\ Apache License\n\ Version 2.0, January 2004\n\ http://www.apache.org/licenses/\n\ \n\ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\ "; string LineWillBeMatched(" http://www.apache.org/licenses/"); string PartWillBeMatched("http://www.apache"); string GroupWillBeMatched("apache"); string pattern = "http:.*(apache)"; MyRegex Regex; list<string> group; while(Regex.RegexLine(&str, &pattern, &group)) { if(!group.empty()) { EXPECT_EQ(true, LineWillBeMatched == group.front()); group.pop_front(); // pop the line EXPECT_EQ(true, PartWillBeMatched == group.front()); group.pop_front(); // pop the matched part EXPECT_EQ(true, GroupWillBeMatched == group.front()); group.pop_front(); // pop the group } } }
[ "ansersion@gmail.com" ]
ansersion@gmail.com
e593461a2ddc1126ed2fe27a18afa0b4c4f6e4df
39719ced2451b97c266568e2d9364bfe90ab3498
/Source/PluginPhysics_Ode/Wrapper/Prefab/PrefabObject.h
2ebce18db4683cbd69d919f88921d158a0316d72
[ "MIT" ]
permissive
shanefarris/CoreGameEngine
74ae026cdc443242fa80fe9802f5739c1064fb66
5bef275d1cd4e84aa059f2f4f9e97bfa2414d000
refs/heads/master
2020-05-07T12:19:23.055995
2019-04-11T14:10:16
2019-04-11T14:10:16
180,496,793
3
2
null
null
null
null
UTF-8
C++
false
false
724
h
#ifndef _OGREODEPREFABOBJECT_H_ #define _OGREODEPREFABOBJECT_H_ namespace Ode { class World; } namespace Ode { enum ObjectType { ObjectType_Sphere_Wheeled_Vehicle, ObjectType_Ray_Wheeled_Vehicle, ObjectType_Wheel, ObjectType_Ragdoll, ObjectType_CompositeObject, ObjectType_Single_Object }; class Object { public: Object(ObjectType type, Ode::World *world); virtual ~Object(); Ode::ObjectType getObjectType() const; static unsigned int getInstanceNumber(); static unsigned int getInstanceNumberAndIncrement(); protected: ObjectType _type; Ode::World* _world; static unsigned int instanceNumber; }; } #endif
[ "farris.shane@gmail.com" ]
farris.shane@gmail.com
b0e89d9544193ea4cc1a44ec709244e1e938d287
d7626890b0e1fdebd5e19369038e80619528820d
/src/bench/cashaddr.cpp
44e1c1f093572fce851de8a32a3932e0747ea542
[ "MIT" ]
permissive
pyujin78/Fashionking-WonCash
8549bbca518e29ae58bd8392ee0ac7a50323ddae
b3abba221d239cbdb116e9c8518862010cc43c12
refs/heads/main
2023-06-12T10:58:02.979778
2021-07-04T12:32:07
2021-07-04T12:32:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,172
cpp
// Copyright (c) 2018 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "cashaddr.h" #include "bench.h" #include <string> #include <vector> static void CashAddrEncode(benchmark::State &state) { std::vector<uint8_t> buffer = {17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147, 227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90, 200, 24}; while (state.KeepRunning()) { cashaddr::Encode("fashionkingwoncash", buffer); } } static void CashAddrDecode(benchmark::State &state) { const char *addrWithPrefix = "fashionkingwoncash:qprnwmr02d7ky9m693qufj5mgkpf4wvssv0w86tkjd"; const char *addrNoPrefix = "qprnwmr02d7ky9m693qufj5mgkpf4wvssv0w86tkjd"; while (state.KeepRunning()) { cashaddr::Decode(addrWithPrefix, "fashionkingwoncash"); cashaddr::Decode(addrNoPrefix, "fashionkingwoncash"); } } BENCHMARK(CashAddrEncode); BENCHMARK(CashAddrDecode);
[ "hamxa6667@gmail.com" ]
hamxa6667@gmail.com
e4891c511fc2b1c0b22b718a50fc86e11ad52324
01d763843720d1b83ba8f3a897839ce49b2b5fc0
/fourMusic/fourMusic.ino
5ebdcba0e722066e1824546fc8437951d4212454
[]
no_license
paololim/base-zumo
246f409a1f0a00bf3a1cff82b7e0675ad864769d
3de46ad97617eb12654fb4cd3737adcdc98997f6
refs/heads/master
2021-01-25T07:39:36.349905
2014-03-24T13:09:24
2014-03-24T13:09:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,118
ino
#include <ZumoBuzzer.h> #include <Pushbutton.h> /* * This example uses the ZumoBuzzer library to play a series of notes on * the buzzer. It also uses Pushbutton library to allow the user to * stop/reset the melody with the user pushbutton. */ #define MELODY_LENGTH 95 // These arrays take up a total of 285 bytes of RAM (out of a limit of 1k (ATmega168), 2k (ATmega328), or 2.5k(ATmega32U4)) unsigned char note[MELODY_LENGTH] = { NOTE_E(5), NOTE_D(5), NOTE_E(5), NOTE_D(5), NOTE_E(5), NOTE_E(5), NOTE_G(5), SILENT_NOTE, NOTE_A(5), NOTE_D(5), NOTE_D(5), NOTE_C(5), NOTE_D(5), NOTE_C(5), NOTE_E(5), NOTE_C(5), NOTE_D(5), NOTE_E(5), NOTE_C(5), NOTE_C(5), SILENT_NOTE, NOTE_E(5), NOTE_C(5), NOTE_C(5), SILENT_NOTE, SILENT_NOTE }; unsigned int duration[MELODY_LENGTH] = { 250, 250, 250, 250, 250, 500, 750, 250, 250, 500, 250, 250, 250, 500, 500, 500, 750, 500, 250, 250, 3000, 500, 250, 250, 3000 }; ZumoBuzzer buzzer; Pushbutton button(ZUMO_BUTTON); unsigned char currentIdx; void setup() // run once, when the sketch starts { currentIdx = 0; } void loop() // run over and over again { // if we haven't finished playing the song and // the buzzer is ready for the next note, play the next note if (currentIdx < MELODY_LENGTH && !buzzer.isPlaying()) { // play note at max volume buzzer.playNote(note[currentIdx], duration[currentIdx], 15); currentIdx++; } // Insert some other useful code here... // the melody will play normally while the rest of your code executes // as long as it executes quickly enough to keep from inserting delays // between the notes. // For example, let the user pushbutton function as a stop/reset melody button if (button.isPressed()) { buzzer.stopPlaying(); // silence the buzzer if (currentIdx < MELODY_LENGTH) currentIdx = MELODY_LENGTH; // terminate the melody else currentIdx = 0; // restart the melody button.waitForRelease(); // wait here for the button to be released } }
[ "plim@gilt.com" ]
plim@gilt.com
152fa33f94eb50f777dc466e5025399d607b9667
b9a1f258079491bd4c7797893abc3b39763dbe5f
/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h
74b31ae4272b7d9baacbb89ed8dfcd20a7e49846
[ "BSD-3-Clause" ]
permissive
slowfeed/browser-android-tabs
407194c1d61d62df85102b1a31518d3c0f05c8f3
a30495bc0ee14556d514f47744ed12420db85e2e
refs/heads/master
2020-03-17T10:30:25.716344
2018-05-08T07:54:33
2018-05-08T07:54:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,164
h
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_ #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_ #include <memory> #include "ash/public/interfaces/split_view.mojom.h" #include "ash/shell_observer.h" #include "base/gtest_prod_util.h" #include "base/macros.h" #include "chrome/browser/command_observer.h" #include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" #include "chrome/browser/ui/views/tab_icon_view_model.h" #include "mojo/public/cpp/bindings/binding.h" #include "ui/aura/window_observer.h" class HostedAppButtonContainer; class TabIconView; namespace ash { class FrameCaptionButton; class FrameCaptionButtonContainerView; class FrameHeader; } // Provides the BrowserNonClientFrameView for Chrome OS. class BrowserNonClientFrameViewAsh : public BrowserNonClientFrameView, public ash::ShellObserver, public TabletModeClientObserver, public TabIconViewModel, public CommandObserver, public ash::mojom::SplitViewObserver, public aura::WindowObserver { public: BrowserNonClientFrameViewAsh(BrowserFrame* frame, BrowserView* browser_view); ~BrowserNonClientFrameViewAsh() override; void Init(); ash::mojom::SplitViewObserverPtr CreateInterfacePtrForTesting(); // BrowserNonClientFrameView: gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override; int GetTopInset(bool restored) const override; int GetThemeBackgroundXInset() const override; void UpdateThrobber(bool running) override; void UpdateMinimumSize() override; views::View* GetHostedAppMenuView() override; // views::NonClientFrameView: gfx::Rect GetBoundsForClientView() const override; gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const override; int NonClientHitTest(const gfx::Point& point) override; void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override; void ResetWindowControls() override; void UpdateWindowIcon() override; void UpdateWindowTitle() override; void SizeConstraintsChanged() override; // views::View: void OnPaint(gfx::Canvas* canvas) override; void Layout() override; const char* GetClassName() const override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override; gfx::Size GetMinimumSize() const override; void ChildPreferredSizeChanged(views::View* child) override; // ash::ShellObserver: void OnOverviewModeStarting() override; void OnOverviewModeEnded() override; // TabletModeClientObserver: void OnTabletModeToggled(bool enabled) override; // TabIconViewModel: bool ShouldTabIconViewAnimate() const override; gfx::ImageSkia GetFaviconForTabIconView() override; // CommandObserver: void EnabledStateChangedForCommand(int id, bool enabled) override; // ash::mojom::SplitViewObserver: void OnSplitViewStateChanged( ash::mojom::SplitViewState current_state) override; // aura::WindowObserver: void OnWindowDestroying(aura::Window* window) override; void OnWindowPropertyChanged(aura::Window* window, const void* key, intptr_t old) override; protected: // BrowserNonClientFrameView: AvatarButtonStyle GetAvatarButtonStyle() const override; private: FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, NonImmersiveFullscreen); FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, ImmersiveFullscreen); FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, ToggleTabletModeRelayout); FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, AvatarDisplayOnTeleportedWindow); FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, HeaderVisibilityInOverviewAndSplitview); FRIEND_TEST_ALL_PREFIXES(HostedAppNonClientFrameViewAshTest, HostedAppFrame); FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshBackButtonTest, V1BackButton); FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, ToggleTabletModeOnMinimizedWindow); FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, RestoreMinimizedBrowserUpdatesCaption); FRIEND_TEST_ALL_PREFIXES(ImmersiveModeControllerAshHostedAppBrowserTest, FrameLayout); friend class BrowserFrameHeaderAsh; // Distance between the left edge of the NonClientFrameView and the tab strip. int GetTabStripLeftInset() const; // Distance between the right edge of the NonClientFrameView and the tab // strip. int GetTabStripRightInset() const; // Returns true if the header should be painted so that it looks the same as // the header used for packaged apps. Packaged apps use a different color // scheme than browser windows. bool UsePackagedAppHeaderStyle() const; void LayoutProfileIndicatorIcon(); // Returns true if there is anything to paint. Some fullscreen windows do not // need their frames painted. bool ShouldPaint() const; // Helps to hide or show the header as needed when overview mode starts or // ends or when split view state changes. void OnOverviewOrSplitviewModeChanged(); // Creates the frame header for the browser window. std::unique_ptr<ash::FrameHeader> CreateFrameHeader(); // View which contains the window controls. ash::FrameCaptionButtonContainerView* caption_button_container_; ash::FrameCaptionButton* back_button_; // For popups, the window icon. TabIconView* window_icon_; // Helper class for painting the header. std::unique_ptr<ash::FrameHeader> frame_header_; // Container for extra frame buttons shown for hosted app windows. // Owned by views hierarchy. HostedAppButtonContainer* hosted_app_button_container_; // Ash's mojom::SplitViewController. ash::mojom::SplitViewControllerPtr split_view_controller_; // The binding this instance uses to implement mojom::SplitViewObserver. mojo::Binding<ash::mojom::SplitViewObserver> observer_binding_; // Indicates whether overview mode is active. Hide the header for V1 apps in // overview mode because a fake header is added for better UX. If also in // immersive mode before entering overview mode, the flag will be ignored // because the reveal lock will determine the show/hide header. bool in_overview_mode_ = false; // Maintains the current split view state. ash::mojom::SplitViewState split_view_state_ = ash::mojom::SplitViewState::NO_SNAP; DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAsh); }; #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_
[ "artem@brave.com" ]
artem@brave.com
a55933a4fc4edc0effdc1858a6a182e2c56a1d90
536656cd89e4fa3a92b5dcab28657d60d1d244bd
/chrome/browser/chromeos/policy/cloud_external_data_manager_base_unittest.cc
2e2344c8efe879cbe586acd2627c4ab9316ab14b
[ "BSD-3-Clause" ]
permissive
ECS-251-W2020/chromium
79caebf50443f297557d9510620bf8d44a68399a
ac814e85cb870a6b569e184c7a60a70ff3cb19f9
refs/heads/master
2022-08-19T17:42:46.887573
2020-03-18T06:08:44
2020-03-18T06:08:44
248,141,336
7
8
BSD-3-Clause
2022-07-06T20:32:48
2020-03-18T04:52:18
null
UTF-8
C++
false
false
30,403
cc
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h" #include <map> #include <string> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/macros.h" #include "base/optional.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/test/task_environment.h" #include "base/test/test_simple_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/browser/chromeos/policy/cloud_external_data_store.h" #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" #include "components/policy/core/common/cloud/resource_cache.h" #include "components/policy/core/common/external_data_fetcher.h" #include "components/policy/core/common/policy_map.h" #include "components/policy/core/common/policy_test_utils.h" #include "components/policy/core/common/policy_types.h" #include "crypto/sha2.h" #include "net/http/http_status_code.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" namespace policy { namespace { // A string policy. const char kStringPolicy[] = "StringPolicy"; // A policy that may reference up to 10 bytes of external data. const char k10BytePolicy[] = "10BytePolicy"; // A policy that may reference up to 20 bytes of external data. const char k20BytePolicy[] = "20BytePolicy"; // A nonexistent policy. const char kUnknownPolicy[] = "UnknownPolicy"; const char k10BytePolicyURL[] = "http://localhost/10_bytes"; const char k20BytePolicyURL[] = "http://localhost/20_bytes"; const char k10ByteData[] = "10 bytes.."; const char k20ByteData[] = "20 bytes............"; const PolicyDetails kPolicyDetails[] = { // is_deprecated is_device_policy id max_external_data_size { false, false, 1, 0 }, { false, false, 2, 10 }, { false, false, 3, 20 }, }; const char kCacheKey[] = "data"; } // namespace class CloudExternalDataManagerBaseTest : public testing::Test { protected: CloudExternalDataManagerBaseTest(); void SetUp() override; void TearDown() override; void SetUpExternalDataManager(); std::unique_ptr<base::DictionaryValue> ConstructMetadata( const std::string& url, const std::string& hash); void SetExternalDataReference( const std::string& policy, std::unique_ptr<base::DictionaryValue> metadata); ExternalDataFetcher::FetchCallback ConstructFetchCallback(int id); void ResetCallbackData(); void OnFetchDone(int id, std::unique_ptr<std::string> data, const base::FilePath& file_path); void FetchAll(); void SetFakeResponse(const std::string& url, const std::string& repsonse_data, net::HttpStatusCode response_code); base::test::SingleThreadTaskEnvironment task_environment_; base::ScopedTempDir temp_dir_; std::unique_ptr<ResourceCache> resource_cache_; MockCloudPolicyStore cloud_policy_store_; network::TestURLLoaderFactory test_url_loader_factory_; scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_; std::unique_ptr<CloudExternalDataManagerBase> external_data_manager_; std::map<int, std::unique_ptr<std::string>> callback_data_; PolicyDetailsMap policy_details_; private: DISALLOW_COPY_AND_ASSIGN(CloudExternalDataManagerBaseTest); }; CloudExternalDataManagerBaseTest::CloudExternalDataManagerBaseTest() { } void CloudExternalDataManagerBaseTest::SetUp() { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); resource_cache_.reset(new ResourceCache( temp_dir_.GetPath(), task_environment_.GetMainThreadTaskRunner(), /* max_cache_size */ base::nullopt)); SetUpExternalDataManager(); // Set |kStringPolicy| to a string value. cloud_policy_store_.policy_map_.Set( kStringPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, std::make_unique<base::Value>(std::string()), nullptr); // Make |k10BytePolicy| reference 10 bytes of external data. SetExternalDataReference( k10BytePolicy, ConstructMetadata(k10BytePolicyURL, crypto::SHA256HashString(k10ByteData))); // Make |k20BytePolicy| reference 20 bytes of external data. SetExternalDataReference( k20BytePolicy, ConstructMetadata(k20BytePolicyURL, crypto::SHA256HashString(k20ByteData))); cloud_policy_store_.NotifyStoreLoaded(); url_loader_factory_ = base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( &test_url_loader_factory_); policy_details_.SetDetails(kStringPolicy, &kPolicyDetails[0]); policy_details_.SetDetails(k10BytePolicy, &kPolicyDetails[1]); policy_details_.SetDetails(k20BytePolicy, &kPolicyDetails[2]); } void CloudExternalDataManagerBaseTest::TearDown() { external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); ResetCallbackData(); } void CloudExternalDataManagerBaseTest::SetUpExternalDataManager() { external_data_manager_ = std::make_unique<CloudExternalDataManagerBase>( policy_details_.GetCallback(), task_environment_.GetMainThreadTaskRunner()); external_data_manager_->SetExternalDataStore( std::make_unique<CloudExternalDataStore>( kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get())); external_data_manager_->SetPolicyStore(&cloud_policy_store_); } std::unique_ptr<base::DictionaryValue> CloudExternalDataManagerBaseTest::ConstructMetadata(const std::string& url, const std::string& hash) { std::unique_ptr<base::DictionaryValue> metadata(new base::DictionaryValue); metadata->SetKey("url", base::Value(url)); metadata->SetKey("hash", base::Value(base::HexEncode(hash.c_str(), hash.size()))); return metadata; } void CloudExternalDataManagerBaseTest::SetExternalDataReference( const std::string& policy, std::unique_ptr<base::DictionaryValue> metadata) { cloud_policy_store_.policy_map_.Set( policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, std::move(metadata), std::make_unique<ExternalDataFetcher>( external_data_manager_->weak_factory_.GetWeakPtr(), policy)); } ExternalDataFetcher::FetchCallback CloudExternalDataManagerBaseTest::ConstructFetchCallback(int id) { return base::Bind(&CloudExternalDataManagerBaseTest::OnFetchDone, base::Unretained(this), id); } void CloudExternalDataManagerBaseTest::ResetCallbackData() { callback_data_.clear(); } void CloudExternalDataManagerBaseTest::OnFetchDone( int id, std::unique_ptr<std::string> data, const base::FilePath& file_path) { callback_data_[id] = std::move(data); } void CloudExternalDataManagerBaseTest::FetchAll() { external_data_manager_->FetchAll(); } void CloudExternalDataManagerBaseTest::SetFakeResponse( const std::string& url, const std::string& response_data, net::HttpStatusCode response_code) { test_url_loader_factory_.AddResponse(url, response_data, response_code); } // Verifies that when no valid external data reference has been set for a // policy, the attempt to retrieve the external data fails immediately. TEST_F(CloudExternalDataManagerBaseTest, FailToFetchInvalid) { external_data_manager_->Connect(url_loader_factory_); // Attempt to retrieve external data for |kStringPolicy|, which is a string // policy that does not reference any external data. external_data_manager_->Fetch(kStringPolicy, ConstructFetchCallback(0)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); EXPECT_TRUE(callback_data_.find(0) != callback_data_.end()); EXPECT_FALSE(callback_data_[0]); ResetCallbackData(); // Attempt to retrieve external data for |kUnknownPolicy|, which is not a // known policy. external_data_manager_->Fetch(kUnknownPolicy, ConstructFetchCallback(1)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); EXPECT_TRUE(callback_data_.find(1) != callback_data_.end()); EXPECT_FALSE(callback_data_[1]); ResetCallbackData(); // Set an invalid external data reference for |k10BytePolicy|. SetExternalDataReference(k10BytePolicy, ConstructMetadata(std::string(), std::string())); cloud_policy_store_.NotifyStoreLoaded(); // Attempt to retrieve external data for |k10BytePolicy|, which now has an // invalid reference. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(2)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); EXPECT_TRUE(callback_data_.find(2) != callback_data_.end()); EXPECT_FALSE(callback_data_[2]); ResetCallbackData(); } // Verifies that external data referenced by a policy is downloaded and cached // when first requested. Subsequent requests are served from the cache without // further download attempts. TEST_F(CloudExternalDataManagerBaseTest, DownloadAndCache) { // Serve valid external data for |k10BytePolicy|. SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK); external_data_manager_->Connect(url_loader_factory_); // Retrieve external data for |k10BytePolicy|. Verify that a download happens // and the callback is invoked with the downloaded data. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); ASSERT_TRUE(callback_data_[0]); EXPECT_EQ(k10ByteData, *callback_data_[0]); ResetCallbackData(); // Stop serving external data for |k10BytePolicy|. test_url_loader_factory_.ClearResponses(); // Retrieve external data for |k10BytePolicy| again. Verify that no download // is attempted but the callback is still invoked with the expected data, // served from the cache. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(1)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); ASSERT_TRUE(callback_data_[1]); EXPECT_EQ(k10ByteData, *callback_data_[1]); ResetCallbackData(); // Explicitly tell the external_data_manager_ to not make any download // attempts. external_data_manager_->Disconnect(); // Retrieve external data for |k10BytePolicy| again. Verify that even though // downloads are not allowed, the callback is still invoked with the expected // data, served from the cache. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(2)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); ASSERT_TRUE(callback_data_[2]); EXPECT_EQ(k10ByteData, *callback_data_[2]); ResetCallbackData(); // Verify that the downloaded data is present in the cache. external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); std::string data; EXPECT_FALSE( CloudExternalDataStore(kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get()) .Load(k10BytePolicy, crypto::SHA256HashString(k10ByteData), 10, &data) .empty()); EXPECT_EQ(k10ByteData, data); } // Verifies that a request to download and cache all external data referenced by // policies is carried out correctly. Subsequent requests for the data are // served from the cache without further download attempts. TEST_F(CloudExternalDataManagerBaseTest, DownloadAndCacheAll) { // Serve valid external data for |k10BytePolicy| and |k20BytePolicy|. SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK); SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK); external_data_manager_->Connect(url_loader_factory_); // Request that external data referenced by all policies be downloaded. FetchAll(); base::RunLoop().RunUntilIdle(); // Stop serving external data for |k10BytePolicy| and |k20BytePolicy|. test_url_loader_factory_.ClearResponses(); // Retrieve external data for |k10BytePolicy| and |k20BytePolicy|. Verify that // no downloads are attempted but the callbacks are still invoked with the // expected data, served from the cache. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(1)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(2u, callback_data_.size()); ASSERT_TRUE(callback_data_[0]); EXPECT_EQ(k10ByteData, *callback_data_[0]); ASSERT_TRUE(callback_data_[1]); EXPECT_EQ(k20ByteData, *callback_data_[1]); ResetCallbackData(); // Explicitly tell the external_data_manager_ to not make any download // attempts. external_data_manager_->Disconnect(); // Retrieve external data for |k10BytePolicy| and |k20BytePolicy|. Verify that // even though downloads are not allowed, the callbacks are still invoked with // the expected data, served from the cache. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(2)); external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(3)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(2u, callback_data_.size()); ASSERT_TRUE(callback_data_[2]); EXPECT_EQ(k10ByteData, *callback_data_[2]); ASSERT_TRUE(callback_data_[3]); EXPECT_EQ(k20ByteData, *callback_data_[3]); ResetCallbackData(); // Verify that the downloaded data is present in the cache. external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); CloudExternalDataStore cache(kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get()); std::string data; EXPECT_FALSE( cache .Load(k10BytePolicy, crypto::SHA256HashString(k10ByteData), 10, &data) .empty()); EXPECT_EQ(k10ByteData, data); EXPECT_FALSE( cache .Load(k20BytePolicy, crypto::SHA256HashString(k20ByteData), 20, &data) .empty()); EXPECT_EQ(k20ByteData, data); } // Verifies that when the external data referenced by a policy is not present in // the cache and downloads are not allowed, a request to retrieve the data is // enqueued and carried out when downloads become possible. TEST_F(CloudExternalDataManagerBaseTest, DownloadAfterConnect) { // Attempt to retrieve external data for |k10BytePolicy|. Verify that the // callback is not invoked as the request remains pending. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(callback_data_.empty()); ResetCallbackData(); // Serve valid external data for |k10BytePolicy| and allow the // external_data_manager_ to perform downloads. SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK); external_data_manager_->Connect(url_loader_factory_); // Verify that a download happens and the callback is invoked with the // downloaded data. base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); ASSERT_TRUE(callback_data_[0]); EXPECT_EQ(k10ByteData, *callback_data_[0]); ResetCallbackData(); } // Verifies that when the external data referenced by a policy is not present in // the cache and cannot be downloaded at this time, a request to retrieve the // data is enqueued to be retried later. TEST_F(CloudExternalDataManagerBaseTest, DownloadError) { // Make attempts to download the external data for |k20BytePolicy| fail with // an error. SetFakeResponse(k20BytePolicyURL, std::string(), net::HTTP_INTERNAL_SERVER_ERROR); external_data_manager_->Connect(url_loader_factory_); // Attempt to retrieve external data for |k20BytePolicy|. Verify that the // callback is not invoked as the download attempt fails and the request // remains pending. external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(0)); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(callback_data_.empty()); ResetCallbackData(); // Modify the external data reference for |k20BytePolicy|, allowing the // download to be retried immediately. SetExternalDataReference( k20BytePolicy, ConstructMetadata(k20BytePolicyURL, crypto::SHA256HashString(k10ByteData))); cloud_policy_store_.NotifyStoreLoaded(); // Attempt to retrieve external data for |k20BytePolicy| again. Verify that // no callback is invoked still as the download attempt fails again and the // request remains pending. external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(1)); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(callback_data_.empty()); ResetCallbackData(); // Modify the external data reference for |k20BytePolicy|, allowing the // download to be retried immediately. SetExternalDataReference( k20BytePolicy, ConstructMetadata(k20BytePolicyURL, crypto::SHA256HashString(k20ByteData))); cloud_policy_store_.NotifyStoreLoaded(); // Serve external data for |k20BytePolicy| that does not match the hash // specified in its current external data reference. SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK); // Attempt to retrieve external data for |k20BytePolicy| again. Verify that // no callback is invoked still as the downloaded succeeds but returns data // that does not match the external data reference. external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(2)); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(callback_data_.empty()); ResetCallbackData(); // Modify the external data reference for |k20BytePolicy|, allowing the // download to be retried immediately. The external data reference now matches // the data being served. SetExternalDataReference( k20BytePolicy, ConstructMetadata(k20BytePolicyURL, crypto::SHA256HashString(k10ByteData))); cloud_policy_store_.NotifyStoreLoaded(); // Attempt to retrieve external data for |k20BytePolicy| again. Verify that // the current callback and the three previously enqueued callbacks are // invoked with the downloaded data now. external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(3)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(4u, callback_data_.size()); ASSERT_TRUE(callback_data_[0]); EXPECT_EQ(k10ByteData, *callback_data_[0]); ASSERT_TRUE(callback_data_[1]); EXPECT_EQ(k10ByteData, *callback_data_[1]); ASSERT_TRUE(callback_data_[2]); EXPECT_EQ(k10ByteData, *callback_data_[2]); ASSERT_TRUE(callback_data_[3]); EXPECT_EQ(k10ByteData, *callback_data_[3]); ResetCallbackData(); } // Verifies that when the external data referenced by a policy is present in the // cache, a request to retrieve it is served from the cache without any download // attempts. TEST_F(CloudExternalDataManagerBaseTest, LoadFromCache) { // Store valid external data for |k10BytePolicy| in the cache. external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(CloudExternalDataStore( kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get()) .Store(k10BytePolicy, crypto::SHA256HashString(k10ByteData), k10ByteData) .empty()); // Instantiate an external_data_manager_ that uses the primed cache. SetUpExternalDataManager(); external_data_manager_->Connect(url_loader_factory_); // Retrieve external data for |k10BytePolicy|. Verify that no download is // attempted but the callback is still invoked with the expected data, served // from the cache. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); ASSERT_TRUE(callback_data_[0]); EXPECT_EQ(k10ByteData, *callback_data_[0]); ResetCallbackData(); } // Verifies that cache entries which do not correspond to the external data // referenced by any policy are pruned on startup. TEST_F(CloudExternalDataManagerBaseTest, PruneCacheOnStartup) { external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); std::unique_ptr<CloudExternalDataStore> cache(new CloudExternalDataStore( kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get())); // Store valid external data for |k10BytePolicy| in the cache. EXPECT_FALSE(cache ->Store(k10BytePolicy, crypto::SHA256HashString(k10ByteData), k10ByteData) .empty()); // Store external data for |k20BytePolicy| that does not match the hash in its // external data reference. EXPECT_FALSE(cache ->Store(k20BytePolicy, crypto::SHA256HashString(k10ByteData), k10ByteData) .empty()); // Store external data for |kUnknownPolicy|, which is not a known policy and // therefore, cannot be referencing any external data. EXPECT_FALSE(cache ->Store(kUnknownPolicy, crypto::SHA256HashString(k10ByteData), k10ByteData) .empty()); cache.reset(); // Instantiate and destroy an ExternalDataManager that uses the primed cache. SetUpExternalDataManager(); external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); cache.reset(new CloudExternalDataStore( kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get())); std::string data; // Verify that the valid external data for |k10BytePolicy| is still in the // cache. EXPECT_FALSE(cache ->Load(k10BytePolicy, crypto::SHA256HashString(k10ByteData), 10, &data) .empty()); EXPECT_EQ(k10ByteData, data); // Verify that the external data for |k20BytePolicy| and |kUnknownPolicy| has // been pruned from the cache. EXPECT_TRUE(cache ->Load(k20BytePolicy, crypto::SHA256HashString(k10ByteData), 20, &data) .empty()); EXPECT_TRUE(cache ->Load(kUnknownPolicy, crypto::SHA256HashString(k10ByteData), 20, &data) .empty()); } // Verifies that when the external data referenced by a policy is present in the // cache and the reference changes, the old data is pruned from the cache. TEST_F(CloudExternalDataManagerBaseTest, PruneCacheOnChange) { // Store valid external data for |k20BytePolicy| in the cache. external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); std::unique_ptr<CloudExternalDataStore> cache(new CloudExternalDataStore( kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get())); EXPECT_FALSE(cache ->Store(k20BytePolicy, crypto::SHA256HashString(k20ByteData), k20ByteData) .empty()); cache.reset(); // Instantiate an ExternalDataManager that uses the primed cache. SetUpExternalDataManager(); external_data_manager_->Connect(url_loader_factory_); // Modify the external data reference for |k20BytePolicy|. SetExternalDataReference( k20BytePolicy, ConstructMetadata(k20BytePolicyURL, crypto::SHA256HashString(k10ByteData))); cloud_policy_store_.NotifyStoreLoaded(); // Verify that the old external data for |k20BytePolicy| has been pruned from // the cache. external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); cache.reset(new CloudExternalDataStore( kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get())); std::string data; EXPECT_TRUE(cache ->Load(k20BytePolicy, crypto::SHA256HashString(k20ByteData), 20, &data) .empty()); } // Verifies that corrupt cache entries are detected and deleted when accessed. TEST_F(CloudExternalDataManagerBaseTest, CacheCorruption) { external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); std::unique_ptr<CloudExternalDataStore> cache(new CloudExternalDataStore( kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get())); // Store external data for |k10BytePolicy| that exceeds the maximal external // data size allowed for that policy. EXPECT_FALSE(cache ->Store(k10BytePolicy, crypto::SHA256HashString(k20ByteData), k20ByteData) .empty()); // Store external data for |k20BytePolicy| that is corrupted and does not // match the expected hash. EXPECT_FALSE(cache ->Store(k20BytePolicy, crypto::SHA256HashString(k20ByteData), k10ByteData) .empty()); cache.reset(); SetUpExternalDataManager(); // Serve external data for |k10BytePolicy| that exceeds the maximal external // data size allowed for that policy. SetFakeResponse(k10BytePolicyURL, k20ByteData, net::HTTP_OK); external_data_manager_->Connect(url_loader_factory_); // Modify the external data reference for |k10BytePolicy| to match the // external data being served. SetExternalDataReference( k10BytePolicy, ConstructMetadata(k10BytePolicyURL, crypto::SHA256HashString(k20ByteData))); cloud_policy_store_.NotifyStoreLoaded(); // Retrieve external data for |k10BytePolicy|. Verify that the callback is // not invoked as the cached and downloaded external data exceed the maximal // size allowed for this policy and the request remains pending. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(callback_data_.empty()); ResetCallbackData(); // Serve valid external data for |k20BytePolicy|. SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK); // Retrieve external data for |k20BytePolicy|. Verify that the callback is // invoked with the valid downloaded data, not the invalid data in the cache. external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(1)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); ASSERT_TRUE(callback_data_[1]); EXPECT_EQ(k20ByteData, *callback_data_[1]); ResetCallbackData(); external_data_manager_.reset(); base::RunLoop().RunUntilIdle(); cache.reset(new CloudExternalDataStore( kCacheKey, task_environment_.GetMainThreadTaskRunner(), resource_cache_.get())); std::string data; // Verify that the invalid external data for |k10BytePolicy| has been pruned // from the cache. Load() will return |false| in two cases: // 1) The cache entry for |k10BytePolicy| has been pruned. // 2) The cache entry for |k10BytePolicy| still exists but the cached data // does not match the expected hash or exceeds the maximum size allowed. // To test for the former, Load() is called with a maximum data size and hash // that would allow the data originally written to the cache to be loaded. // When this fails, it is certain that the original data is no longer present // in the cache. EXPECT_TRUE(cache ->Load(k10BytePolicy, crypto::SHA256HashString(k20ByteData), 20, &data) .empty()); // Verify that the invalid external data for |k20BytePolicy| has been replaced // with the downloaded valid data in the cache. EXPECT_FALSE(cache ->Load(k20BytePolicy, crypto::SHA256HashString(k20ByteData), 20, &data) .empty()); EXPECT_EQ(k20ByteData, data); } // Verifies that when the external data reference for a policy changes while a // download of the external data for that policy is pending, the download is // immediately retried using the new reference. TEST_F(CloudExternalDataManagerBaseTest, PolicyChangeWhileDownloadPending) { // Make attempts to download the external data for |k10BytePolicy| and // |k20BytePolicy| fail with an error. SetFakeResponse(k10BytePolicyURL, std::string(), net::HTTP_INTERNAL_SERVER_ERROR); SetFakeResponse(k20BytePolicyURL, std::string(), net::HTTP_INTERNAL_SERVER_ERROR); external_data_manager_->Connect(url_loader_factory_); // Attempt to retrieve external data for |k10BytePolicy| and |k20BytePolicy|. // Verify that no callbacks are invoked as the download attempts fail and the // requests remain pending. external_data_manager_->Fetch(k10BytePolicy, ConstructFetchCallback(0)); external_data_manager_->Fetch(k20BytePolicy, ConstructFetchCallback(1)); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(callback_data_.empty()); ResetCallbackData(); // Modify the external data reference for |k10BytePolicy| to be invalid. // Verify that the callback is invoked as the policy no longer has a valid // external data reference. cloud_policy_store_.policy_map_.Erase(k10BytePolicy); cloud_policy_store_.NotifyStoreLoaded(); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); EXPECT_TRUE(callback_data_.find(0) != callback_data_.end()); EXPECT_FALSE(callback_data_[0]); ResetCallbackData(); // Serve valid external data for |k20BytePolicy|. test_url_loader_factory_.ClearResponses(); SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK); // Modify the external data reference for |k20BytePolicy| to match the // external data now being served. Verify that the callback is invoked with // the downloaded data. SetExternalDataReference( k20BytePolicy, ConstructMetadata(k20BytePolicyURL, crypto::SHA256HashString(k10ByteData))); cloud_policy_store_.NotifyStoreLoaded(); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, callback_data_.size()); ASSERT_TRUE(callback_data_[1]); EXPECT_EQ(k10ByteData, *callback_data_[1]); ResetCallbackData(); } } // namespace policy
[ "pcding@ucdavis.edu" ]
pcding@ucdavis.edu