blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
247
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 4
111
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-25 18:16:41
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| github_id
int64 3.89k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 25
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
⌀ | gha_created_at
timestamp[ns]date 2008-03-27 23:40:48
2023-08-24 19:49:39
⌀ | gha_language
stringclasses 159
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
10.5M
| extension
stringclasses 111
values | filename
stringlengths 1
195
| text
stringlengths 7
10.5M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
46d01c4782f29861cadbed1a2c3243749d002b09
|
9f3b36db26d5c8cd14aab82400c6aff282db1ad7
|
/src/Util/Serialization.cpp
|
e53b294910d8fe189bd1d0e3b934c5f2c5659f74
|
[] |
no_license
|
MichaelKirsch/SFML_2D_BLUEPRINT
|
a9f5f7c1d66b25ea640ae3c7e86464f91fced036
|
7aeeae479114a63728dee9c8afda1c2af7c44b01
|
refs/heads/master
| 2020-08-04T22:51:19.597893
| 2020-06-29T16:16:38
| 2020-06-29T16:16:38
| 212,302,460
| 7
| 4
| null | 2019-12-06T17:41:58
| 2019-10-02T09:37:27
|
HTML
|
UTF-8
|
C++
| false
| false
| 71
|
cpp
|
Serialization.cpp
|
//
// Created by micha on 19.12.2019.
//
#include "Serialization.h"
|
958d57c245cbe235372956c3b524bece27ff49c2
|
2b0ff7f7529350a00a34de9050d3404be6d588a0
|
/036_其它/78_JavaScript 呼叫MFC 函數/自己撰寫範例/test00/testDlg.cpp
|
4f00437c06cbe84a65278af19e811728ce8d2b6f
|
[] |
no_license
|
isliulin/jashliao_VC
|
6b234b427469fb191884df2def0b47c4948b3187
|
5310f52b1276379b267acab4b609a9467f43d8cb
|
refs/heads/master
| 2023-05-13T09:28:49.756293
| 2021-06-08T13:40:23
| 2021-06-08T13:40:23
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,282
|
cpp
|
testDlg.cpp
|
// testDlg.cpp : implementation file
//
#include "stdafx.h"
#include "test.h"
#include "testDlg.h"
#include <atlbase.h>//modify by jash
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestDlg dialog
CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pIHTMLDoc = NULL;//modify by jash
}
CTestDlg::~CTestDlg()//modify by jash
{
}
void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestDlg)
DDX_Control(pDX, IDC_EXPLORER1, m_wndWeb);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
//{{AFX_MSG_MAP(CTestDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestDlg message handlers
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CHAR szPath[MAX_PATH];//modify by jash
memset(szPath, 0, sizeof(CHAR)*MAX_PATH);//modify by jash
GetCurrentDirectory(MAX_PATH, szPath);//modify by jash
StrCat(szPath, _T("\\Custom.html"));//modify by jash
m_wndWeb.Navigate(szPath, NULL, NULL, NULL, NULL);//modify by jash
return TRUE; // return TRUE unless you set the focus to a control
}
void CTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CTestDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CTestDlg::InvokeFunc()//modify by jash
{
MessageBox(_T("MFC MessageBox"));
}
void CTestDlg::InvokeFuncWithParams(const CString& strParam1, int iParam2)
{
CString str;
str.Format("MFC String01:%s\nMFC String02:%d", strParam1, iParam2);
MessageBox(str);
}
void CTestDlg::InvokeFuncAdd(int iParam1, int iParam2)
{
CString strResult;
IHTMLWindow2* pIHTMLWindow = NULL;
HRESULT hr = NOERROR;
VARIANT pvarRet;
strResult.Format("fnSetText(\"%d\")", iParam1+iParam2);
if(m_pIHTMLDoc)
{
m_pIHTMLDoc->get_parentWindow(&pIHTMLWindow);
if(pIHTMLWindow)
{
hr = pIHTMLWindow->execScript(CComBSTR(strResult), CComBSTR("JScript"), &pvarRet);
pIHTMLWindow->Release();
pIHTMLWindow = NULL;
}
}
}
void CTestDlg::ShowModalDlg(const CString& strCaption, const CRect& rcPos)
{
MessageBox(strCaption);
CString StrBuf;
StrBuf.Format("Top=%d\nBottom=%d",rcPos.top,rcPos.bottom);
MessageBox(StrBuf);
}
void CTestDlg::ShowModalLessDlg(const CString& strCaption, const CRect& rcPos)
{
MessageBox(strCaption);
CString StrBuf;
StrBuf.Format("right=%d\nleft=%d",rcPos.right,rcPos.left);
MessageBox(StrBuf);
}
BEGIN_EVENTSINK_MAP(CTestDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CTestDlg)
ON_EVENT(CTestDlg, IDC_EXPLORER1, 259 /* DocumentComplete */, OnDocumentCompleteExplorer1, VTS_DISPATCH VTS_PVARIANT)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CTestDlg::OnDocumentCompleteExplorer1(LPDISPATCH pDisp, VARIANT FAR* URL)
{
// TODO: Add your control notification handler code here
IDispatch* pIDisp = NULL;
pIDisp = m_wndWeb.GetDocument();
if(pIDisp)
{
if(m_pIHTMLDoc)
{
m_pIHTMLDoc->Release();
m_pIHTMLDoc = NULL;
}
pIDisp->QueryInterface(IID_IHTMLDocument2, (void**)&m_pIHTMLDoc);
pIDisp->Release();
pIDisp = NULL;
}
}
void CTestDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if(m_pIHTMLDoc)
{
m_pIHTMLDoc->Release();
m_pIHTMLDoc = NULL;
}
CDialog::OnClose();
}
|
4680b426c3dfd0c4c974cba6f0f596e8c4cb9202
|
5d83739af703fb400857cecc69aadaf02e07f8d1
|
/Archive2/40/95fbacaa689b78/main.cpp
|
b14b4f1de96892caa8b95b206459a818d24a45f2
|
[] |
no_license
|
WhiZTiM/coliru
|
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
|
2c72c048846c082f943e6c7f9fa8d94aee76979f
|
refs/heads/master
| 2021-01-01T05:10:33.812560
| 2015-08-24T19:09:22
| 2015-08-24T19:09:22
| 56,789,706
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,577
|
cpp
|
main.cpp
|
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <iostream>
namespace bmi = boost::multi_index;
enum TimePoints { // Lets assume t1 > t2 > t3 > t4
t1 = 100,
t2 = 80,
t3 = 70,
t4 = 20,
};
using IdType = std::string;
using Symbol = std::string;
using TimeT = unsigned int;
struct tickerUpdateInfo {
IdType m_id;
Symbol m_symbol;
TimeT m_last_update_time;
friend std::ostream& operator<<(std::ostream& os, tickerUpdateInfo const& tui) {
return os << "T[" << tui.m_id << ",\t" << tui.m_symbol << ",\t" << tui.m_last_update_time << "]";
}
} static const data[] = {
{ "CBT.151.5.T.FEED", "s1", t1 },
{ "CBT.151.5.T.FEED", "s2", t2 },
{ "CBT.151.5.T.FEED", "s3", t3 },
{ "CBT.151.5.T.FEED", "s4", t4 },
{ "CBT.151.5.T.FEED", "s5", t1 },
{ "CBT.151.8.T.FEED", "s7", t1 },
{ "CBT.151.5.Q.FEED", "s8", t3 },
// added to show freq>1 in histo
{ "CBT.151.5.T.FEED", "s2", t2 },
};
typedef bmi::multi_index_container<tickerUpdateInfo,
bmi::indexed_by<
bmi::ordered_non_unique<bmi::tag<struct most_active_index>,
bmi::composite_key<tickerUpdateInfo,
BOOST_MULTI_INDEX_MEMBER(tickerUpdateInfo, TimeT, m_last_update_time),
BOOST_MULTI_INDEX_MEMBER(tickerUpdateInfo, Symbol, m_symbol),
BOOST_MULTI_INDEX_MEMBER(tickerUpdateInfo, IdType, m_id)
> > >
> ticker_update_info_set;
/*
* Now in the function get_active_ticker_count() I want to specify the key like
*CBT.151.5.T.FEED and it should return:
*
* s1 t1
* s2 t2
* s3 t3
* s4 t4
* s5 t1
*
* Lets assume t1 > t2 > t3 > t4, then I would like to find out such sets where
*times are greater than t3 and also want to find the count of such symbols. How
*do I proceed with the same, I have been able to insert but I am stuck with the
*retrieval part. Please help!
*
*/
#include <map>
#include <boost/range/iterator_range.hpp>
std::map<Symbol, size_t> activity_histo(ticker_update_info_set const& tuis, TimeT since)
{
std::map<Symbol, size_t> histo;
auto const& index = tuis.get<most_active_index>();
auto lb = index.upper_bound(since); // for greater-than-inclusive use lower_bound
for (auto& rec : boost::make_iterator_range(lb, index.end()))
histo[rec.m_symbol]++;
return histo;
}
std::map<Symbol, size_t> activity_histo_ex(ticker_update_info_set const& tuis, TimeT since)
{
std::map<Symbol, size_t> histo;
auto const& index = tuis.get<most_active_index>();
for (auto lb = index.upper_bound(since), end = tuis.end(); lb != end;) // for greater-than-inclusive use lower_bound
{
auto ub = index.upper_bound(boost::make_tuple(lb->m_last_update_time, lb->m_symbol));
histo[lb->m_symbol] += std::distance(lb, ub);
lb = ub;
}
return histo;
}
int main()
{
ticker_update_info_set tuis;
tuis.insert(std::begin(data), std::end(data));
for (auto& r : tuis) std::cout << r << "\n";
std::cout << "\nSince t3 (" << t3 << ") there has been the following activity per symbol:\n";
for (auto const& entry : activity_histo(tuis, t3))
std::cout << "Symbol:" << entry.first << "\tfrequency:" << entry.second << "\n";
std::cout << "\nSince t3 (" << t3 << ") there has been the following activity per symbol:\n";
for (auto const& entry : activity_histo_ex(tuis, t3))
std::cout << "Symbol:" << entry.first << "\tfrequency:" << entry.second << "\n";
}
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <iostream>
namespace bmi = boost::multi_index;
enum TimePoints { // Lets assume t1 > t2 > t3 > t4
t1 = 100,
t2 = 80,
t3 = 70,
t4 = 20,
};
using IdType = std::string;
using Symbol = std::string;
using TimeT = unsigned int;
struct tickerUpdateInfo {
IdType m_id;
Symbol m_symbol;
TimeT m_last_update_time;
friend std::ostream& operator<<(std::ostream& os, tickerUpdateInfo const& tui) {
return os << "T[" << tui.m_id << ",\t" << tui.m_symbol << ",\t" << tui.m_last_update_time << "]";
}
} static const data[] = {
{ "CBT.151.5.T.FEED", "s1", t1 },
{ "CBT.151.5.T.FEED", "s2", t2 },
{ "CBT.151.5.T.FEED", "s3", t3 },
{ "CBT.151.5.T.FEED", "s4", t4 },
{ "CBT.151.5.T.FEED", "s5", t1 },
{ "CBT.151.8.T.FEED", "s7", t1 },
{ "CBT.151.5.Q.FEED", "s8", t3 },
// added to show freq>1 in histo
{ "CBT.151.5.T.FEED", "s2", t2 },
};
typedef bmi::multi_index_container<tickerUpdateInfo,
bmi::indexed_by<
bmi::ordered_non_unique<bmi::tag<struct most_active_index>,
bmi::composite_key<tickerUpdateInfo,
BOOST_MULTI_INDEX_MEMBER(tickerUpdateInfo, TimeT, m_last_update_time),
BOOST_MULTI_INDEX_MEMBER(tickerUpdateInfo, Symbol, m_symbol),
BOOST_MULTI_INDEX_MEMBER(tickerUpdateInfo, IdType, m_id)
> > >
> ticker_update_info_set;
/*
* Now in the function get_active_ticker_count() I want to specify the key like
*CBT.151.5.T.FEED and it should return:
*
* s1 t1
* s2 t2
* s3 t3
* s4 t4
* s5 t1
*
* Lets assume t1 > t2 > t3 > t4, then I would like to find out such sets where
*times are greater than t3 and also want to find the count of such symbols. How
*do I proceed with the same, I have been able to insert but I am stuck with the
*retrieval part. Please help!
*
*/
#include <map>
#include <boost/range/iterator_range.hpp>
std::map<Symbol, size_t> activity_histo(ticker_update_info_set const& tuis, TimeT since)
{
std::map<Symbol, size_t> histo;
auto const& index = tuis.get<most_active_index>();
auto lb = index.upper_bound(since); // for greater-than-inclusive use lower_bound
for (auto& rec : boost::make_iterator_range(lb, index.end()))
histo[rec.m_symbol]++;
return histo;
}
int main()
{
ticker_update_info_set tuis;
tuis.insert(std::begin(data), std::end(data));
for (auto& r : tuis) std::cout << r << "\n";
std::cout << "\nSince t3 (" << t3 << ") there has been the following activity per symbol:\n";
for (auto const& entry : activity_histo(tuis, t3))
std::cout << "Symbol:" << entry.first << "\tfrequency:" << entry.second << "\n";
}
|
8dc8a4e5ae679460a08a073a9c0521d81ef44a01
|
662b9b154faf6fed5a8f4e755c7989890c347d64
|
/src/test_pcd.cpp
|
a54dd6a18a2066bd6b1c170e168ab2b96cd03c9d
|
[] |
no_license
|
aaron-chenjianhui/DepthCam
|
03df41f320f74bcee4c250c265c85d5924625255
|
d7f4caa6378d10dc7946335dcf81e81a96d00700
|
refs/heads/master
| 2022-06-27T11:32:37.326082
| 2018-08-03T03:28:50
| 2018-08-03T03:28:50
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 808
|
cpp
|
test_pcd.cpp
|
#include "DepthDevice.hpp"
#include "CloudView.hpp"
#include "PCDHandler.hpp"
int main(int argc, char *argv[])
{
DepthDevice depth_device({ RGB_VGA, DEPTH_VGA, POINT3D_VGA });
depth_device.InitDevice();
depth_device.OpenDevice();
depth_device.UpdateDevPose("../../config/extrinsic.xml");
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>());
CloudViewer cloud_viewer;
PCDHandler pcd_handler;
// pcd_handler.PCDRead("../../data/2018_4_24_15_15_26.pcd", cloud_ptr);
//
// while(1){
// cloud_viewer.show(cloud_ptr, "cloud_show");
// }
while (1) {
// depth_device.getConPointCloud(cloud_ptr);
depth_device.getPointCloud("207000002571", cloud_ptr);
cloud_viewer.show(cloud_ptr, "test");
// pcd_handler.PCDWrite(cloud_ptr, "test.pcd");
}
return 0;
}
|
17d5c606e1a1ed04cc5409733a9d070e2652d710
|
1a5a1c951d79425a91e0d78980418b031850ba0d
|
/sort on alphatical.cpp
|
f5ffa784b48a8c2f3b0834101cb63e5064579efa
|
[] |
no_license
|
harsh-gulati-14/Competitive-programming-
|
12d718e32a96c22d53da3e6ee6605d7216dd806a
|
a549105680ca952498a18c0861e9c800bd0f454d
|
refs/heads/master
| 2020-11-25T12:08:33.220010
| 2020-10-17T11:51:17
| 2020-10-17T11:51:17
| 228,651,039
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 447
|
cpp
|
sort on alphatical.cpp
|
#include<iostream>
using namespace std;
int check(int n)
{
if(n>10)
{
int d,r=0,k;
k=n;
while(k>0)
{
d=k%10;
r=r*10+d;
k=k/10;
}
if(n==r)
{
return n;
}
else{
return 0;
}
}
}
int main()
{
long i,j,k,l,n,a[10000],r=0,c=0;
cin>>l;
while(l--)
{
cin>>n;
for(i=0;i<=3*n/2;i++)
{
r=check(i);
a[i]=r;
c++;
}
for(i=0;i<c;i++)
{
cout<<a[i];
/*if(a[i]!=0)
{
cout<<a[i];
break;
}*/
}
}
}
|
1fa6db0a6fb15f94775f6d408d2c58b5e10b72f5
|
58039587c1a0d8308e09fb324825a61fbb38d007
|
/source/renderer/actor/mesh/MeshPane.hpp
|
726684a69faa8e7d8ae28fdbc9374952393adf0b
|
[] |
no_license
|
rgnter/moony
|
91037b596cf9b11d01804235c68fd300d74d99d4
|
dee02d72b8d47d5dac3d7c256c145d1a2437ba6e
|
refs/heads/master
| 2022-12-24T13:10:05.175156
| 2020-10-13T10:42:45
| 2020-10-13T10:42:45
| 303,445,256
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 427
|
hpp
|
MeshPane.hpp
|
//
// Created by maros on 10/13/2020.
//
#ifndef MOONY_MESHPANE_HPP
#define MOONY_MESHPANE_HPP
#include "Mesh.hpp"
class MeshPane : Mesh {
public:
MeshPane() {
this->vertices = new float[]{
-0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.0f, 0.5f, 0.0f
};
this->verticesCount = 9;
this->hasIndices = false;
}
};
#endif //MOONY_MESHPANE_HPP
|
b5911584f24cedaad2053e3de97f0bd950e59674
|
4213fd574b08a9bc4c02de4fc5fddec53e99994a
|
/grupcntl/include/MODEL02-IMBNUM.inc
|
995e2eb27c691294b530ae37303b839f3f4082b1
|
[] |
no_license
|
OPM/opm-tests
|
a5a76fa747b7076c65cb05b8a7536939344aaf9f
|
c92774e32de36d5a2309f1fdd8d9251ebe53fc6e
|
refs/heads/master
| 2023-08-28T01:06:21.274269
| 2023-08-23T21:03:02
| 2023-08-23T21:03:02
| 121,263,124
| 21
| 70
| null | 2023-09-14T08:39:55
| 2018-02-12T15:22:07
|
ECL
|
UTF-8
|
C++
| false
| false
| 18,520
|
inc
|
MODEL02-IMBNUM.inc
|
-- This reservoir simulation deck is made available under the Open Database
-- License: http://opendatacommons.org/licenses/odbl/1.0/. Any rights in
-- individual contents of the database are licensed under the Database Contents
-- Copyright (C) 2018-2022 Equinor
--
-- This file is a REGION property file containing the IMBNUM array data for MODEL02.
--
-- SWITCH OFF ECHOING OF INPUT FILES
--
NOECHO
--
-- DEFINE IMBNUM REGIONS FOR ALL CELLS
--
IMBNUM
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 7
7 7 7 7 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 8 8
8 8 8 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
10
/
ECHO
--
-- *********************************************************************************************************************************
-- END OF FILE
-- *********************************************************************************************************************************
|
74f0c6f1fb59519c276dfc6633beae78b0d2c6f1
|
07ac16b79fd00078de5dad36b8af75b701be2227
|
/unit_tests.cpp
|
5c08feddd3cf5374e7d76b0599e48191b9e12b99
|
[] |
no_license
|
samvel1024/JNP5
|
3301da716f21cee407bcb021bde5b518fb70a624
|
e2030815bfbd375e9d175f50cba1ae9e63ba0a4b
|
refs/heads/master
| 2020-04-10T09:21:33.500987
| 2018-12-26T19:59:05
| 2018-12-26T19:59:05
| 160,934,062
| 0
| 0
| null | 2018-12-19T13:02:11
| 2018-12-08T11:50:59
|
C++
|
UTF-8
|
C++
| false
| false
| 9,081
|
cpp
|
unit_tests.cpp
|
#define BOOST_TEST_MODULE CitationGraphTests
//#include <boost/test/excecution_monitor.hpp>
#include <boost/test/included/unit_test.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include "citation_graph.h"
#include "dag.h"
#include "citation_graph.h"
#include "Publication.h"
class PublicationExample {
public:
typedef typename std::string id_type;
PublicationExample(id_type const &_id) : id(_id) {
}
id_type get_id() const noexcept {
return id;
}
private:
id_type id;
};
class Type {
public:
Type() : id(0) {}
Type(const Type& t) : id(t.id) {};
Type(Type&& t) : id(t.id) {};
Type& operator=(const Type& rhs) {
}
private:
int id;
int counter;
};
/*class PublicationThrow {
public:
typedef typename std::string id_type;
PublicationExample(id_type const &_id) : id(_id) {
}
id_type get_id() const noexcept {
return id;
}
private:
id_type id;
};*/
BOOST_AUTO_TEST_SUITE(ProvidedTests);
BOOST_AUTO_TEST_CASE(example) {
CitationGraph<PublicationExample> gen("Goto Considered Harmful");
PublicationExample::id_type const id1 = gen.get_root_id(); // Czy to jest noexcept?
assert(gen.exists(id1));
assert(gen.get_parents(id1).size() == 0);
gen.create("A", id1);
gen.create("B", id1);
assert(gen.get_children(id1).size() == 2);
gen.create("C", "A");
gen.add_citation("C", "B");
assert(gen.get_parents("C").size() == 2);
assert(gen.get_children("A").size() == 1);
std::vector<PublicationExample::id_type> parents;
parents.push_back("A");
parents.push_back("B");
gen.create("D", parents);
assert(gen.get_parents("D").size() == parents.size());
assert(gen.get_children("A").size() == 2);
assert("D" == gen["D"].get_id());
gen.remove("A");
assert(!gen.exists("A"));
assert(gen.exists("B"));
assert(gen.exists("C"));
assert(gen.exists("D"));
assert(gen.get_parents("D").size() == 1);
assert(gen.get_parents("C").size() == 1);
assert(gen.get_children("B").size() == 2);
cout << gen;
gen.remove("B");
/* cout << gen;
assert(!gen.exists("A"));
assert(!gen.exists("B"));
assert(!gen.exists("C"));
assert(!gen.exists("D"));
try {
gen["E"];
}
catch (std::exception &e) {
std::cout << e.what() << std::endl;
}
try {
gen.create("E", "Goto Considered Harmful");
//gen.create("E", "Goto Considered Harmful");
}
catch (std::exception &e) {
std::cout << e.what() << std::endl;
}*/
/* try {
gen.remove("Goto Considered Harmful");
}
catch (std::exception &e) {
std::cout << e.what() << std::endl;
}*/
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(SimpleOperations);
BOOST_AUTO_TEST_CASE(Cycle_removing) {
CitationGraph<PublicationExample> gen("X");
PublicationExample::id_type const id1 = gen.get_root_id();
BOOST_ASSERT(gen.exists(id1));
BOOST_ASSERT(gen.get_parents(id1).size() == 0);
gen.create("A", id1);
gen.create("B", id1);
BOOST_ASSERT(gen.get_children(id1).size() == 2);
gen.create("C", "A");
gen.add_citation("C", "B");
BOOST_ASSERT(gen.get_parents("C").size() == 2);
BOOST_ASSERT(gen.get_children("A").size() == 1);
std::vector<PublicationExample::id_type> parents;
parents.push_back("A");
parents.push_back("B");
gen.create("D", parents);
gen.add_citation("C", "D");
BOOST_ASSERT(gen.get_parents("C").size() == 3);
BOOST_ASSERT(gen.get_parents("D").size() == parents.size());
BOOST_ASSERT(gen.get_children("A").size() == 2);
BOOST_ASSERT("D" == gen["D"].get_id());
gen.remove("A");
std::cout << "size: " << gen.get_parents("C").size() << std::endl;
std::cout << "size: " << gen.get_parents("D").size() << std::endl;
BOOST_ASSERT(gen.get_parents("C").size() == 2);
BOOST_ASSERT(gen.get_parents("D").size() == 1);
BOOST_ASSERT(!gen.exists("A"));
BOOST_ASSERT(gen.exists("B"));
BOOST_ASSERT(gen.exists("C"));
BOOST_ASSERT(gen.exists("D"));
std::cout << gen;
gen.remove("B");
BOOST_ASSERT(!gen.exists("A"));
BOOST_ASSERT(!gen.exists("B"));
BOOST_ASSERT(!gen.exists("C"));
BOOST_ASSERT(!gen.exists("D"));
}
BOOST_AUTO_TEST_CASE(UnconectedGraph) {
CitationGraph<PublicationExample> gen("X");
PublicationExample::id_type const root = gen.get_root_id();
gen.create("A", root);
gen.create("C", "A");
gen.create("D", "C");
gen.create("E", "D");
BOOST_ASSERT(gen.get_parents("A").size() == 1);
BOOST_ASSERT(gen.get_parents("C").size() == 1);
BOOST_ASSERT(gen.get_parents("D").size() == 1);
BOOST_ASSERT(gen.get_parents("E").size() == 1);
BOOST_ASSERT(gen.get_children("A").size() == 1);
BOOST_ASSERT(gen.get_children("C").size() == 1);
BOOST_ASSERT(gen.get_children("D").size() == 1);
BOOST_ASSERT(gen.get_children("E").size() == 0);
gen.remove("C");
BOOST_ASSERT(gen.get_children("A").size() == 0);
BOOST_ASSERT(gen.get_children("X").size() == 1);
try {
gen["C"];
} catch (std::exception& ex) {
std::cout << ex.what() << std::endl;
}
try {
gen["D"];
} catch (std::exception& ex) {
std::cout << ex.what() << std::endl;
}
try {
gen["E"];
} catch (std::exception& ex) {
std::cout << ex.what() << std::endl;
}
}
BOOST_AUTO_TEST_CASE(UnconectedGraph_two_sources) {
CitationGraph<PublicationExample> gen("X");
PublicationExample::id_type const root = gen.get_root_id();
gen.create("A", root);
gen.create("C", "A");
gen.create("D", "C");
gen.create("E", "D");
gen.create("B", root);
gen.add_citation("E", "B");
BOOST_ASSERT(gen.get_parents("A").size() == 1);
BOOST_ASSERT(gen.get_parents("B").size() == 1);
BOOST_ASSERT(gen.get_parents("C").size() == 1);
BOOST_ASSERT(gen.get_parents("D").size() == 1);
BOOST_ASSERT(gen.get_parents("E").size() == 2);
BOOST_ASSERT(gen.get_children("A").size() == 1);
BOOST_ASSERT(gen.get_children("B").size() == 1);
BOOST_ASSERT(gen.get_children("C").size() == 1);
BOOST_ASSERT(gen.get_children("D").size() == 1);
BOOST_ASSERT(gen.get_children("E").size() == 0);
gen.remove("C");
BOOST_ASSERT(gen.get_children("X").size() == 2);
BOOST_ASSERT(gen.get_children("A").size() == 0);
BOOST_ASSERT(gen.get_children("B").size() == 1);
BOOST_ASSERT(gen.get_children("E").size() == 0);
BOOST_ASSERT(gen.get_parents("X").size() == 0);
BOOST_ASSERT(gen.get_parents("A").size() == 1);
BOOST_ASSERT(gen.get_parents("B").size() == 1);
BOOST_ASSERT(gen.get_parents("E").size() == 1);
try {
gen["C"];
} catch (std::exception& ex) {
std::cout << ex.what() << std::endl;
}
try {
gen["D"];
} catch (std::exception& ex) {
std::cout << ex.what() << std::endl;
}
}
BOOST_AUTO_TEST_CASE(create) {
CitationGraph<PublicationExample> gen("X");
PublicationExample::id_type const root = gen.get_root_id();
std::vector<PublicationExample::id_type> parents_F;
std::vector<PublicationExample::id_type> parents_E;
parents_F.emplace_back("B");
parents_F.emplace_back("D");
parents_E.emplace_back("B");
parents_E.emplace_back("C");
gen.create("A", root);
gen.create("B", root);
gen.create("C", root);
gen.create("D", "A");
gen.create("F", parents_F);
gen.create("E", parents_E);
BOOST_ASSERT(gen.get_parents("A").size() == 1);
BOOST_ASSERT(gen.get_parents("B").size() == 1);
BOOST_ASSERT(gen.get_parents("C").size() == 1);
BOOST_ASSERT(gen.get_parents("D").size() == 1);
BOOST_ASSERT(gen.get_parents("E").size() == 2);
BOOST_ASSERT(gen.get_parents("F").size() == 2);
BOOST_ASSERT(gen.get_children("A").size() == 1);
BOOST_ASSERT(gen.get_children("B").size() == 2);
BOOST_ASSERT(gen.get_children("C").size() == 1);
BOOST_ASSERT(gen.get_children("D").size() == 1);
BOOST_ASSERT(gen.get_children("E").size() == 0);
BOOST_ASSERT(gen.get_children("F").size() == 0);
}
BOOST_AUTO_TEST_CASE(simple_cycle) {
CitationGraph<PublicationExample> gen("A");
PublicationExample::id_type const root = gen.get_root_id();
std::vector<PublicationExample::id_type> parents_E;
parents_E.emplace_back("B");
parents_E.emplace_back("C");
gen.create("B", "A");
gen.create("C", "A");
gen.create("D", parents_E);
gen.remove("B");
BOOST_ASSERT(gen.get_parents("A").size() == 0);
BOOST_ASSERT(gen.get_parents("C").size() == 1);
BOOST_ASSERT(gen.get_parents("D").size() == 1);
BOOST_ASSERT(gen.get_children("A").size() == 1);
BOOST_ASSERT(gen.get_children("C").size() == 1);
BOOST_ASSERT(gen.get_children("D").size() == 0);
}
BOOST_AUTO_TEST_CASE(simple_cycle2) {
CitationGraph<PublicationExample> gen("A");
PublicationExample::id_type const root = gen.get_root_id();
std::vector<PublicationExample::id_type> parents_E;
parents_E.emplace_back("B");
parents_E.emplace_back("C");
gen.create("B", "A");
gen.create("C", "A");
gen.create("D", parents_E);
gen.remove("B");
BOOST_ASSERT(gen.get_parents("A").size() == 1);
BOOST_ASSERT(gen.get_parents("C").size() == 1);
BOOST_ASSERT(gen.get_parents("D").size() == 1);
BOOST_ASSERT(gen.get_children("A").size() == 1);
BOOST_ASSERT(gen.get_children("C").size() == 1);
BOOST_ASSERT(gen.get_children("D").size() == 1);
}
BOOST_AUTO_TEST_SUITE_END()
|
79b171dce3b1ba904d08373021936fa149c337f1
|
e9b6e9938ce3bf009be1dbf2c00b1f5aeb79a3a6
|
/trollBox/src/menuStart.h
|
01aff499a6571fe3ea87c4a6d218198cebef8dd1
|
[] |
no_license
|
Galliezb/trollBox
|
f16ffa76ff71a7d65fbd8ba709a1b9d2ac62e836
|
0ead2f5588c666bd30f793d7d58af85e5b9cb4ed
|
refs/heads/master
| 2021-03-24T12:09:33.006137
| 2017-05-16T16:24:22
| 2017-05-16T16:24:22
| 83,933,476
| 0
| 0
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 2,302
|
h
|
menuStart.h
|
#pragma once
#include "SoundManagement.h"
#include "game.h"
#include "TypingLetter.h"
class menuStart {
public:
menuStart();
void afficherMenu();
void changeNameRight();
void changeLetter( bool positif=true );
string createName();
string createText(string str);
void init(SoundManagement* ptrMyPlayerRecieved, ofTrueTypeFont* maFonte, game* instanceDesJeux);
void newModificateur(bool bt1,bool bt2,bool bt3,bool bt4);
// choi menu
void changeChoixMenu( bool goDown = false);
void valideChoixMenu();
~menuStart();
// variable public
/*
0 => INSERT COINS
1 => INSERT MORE COINS
2 => INSERT MORE MORE COINS
3 => SUCCES ! START OF TROLLBOX !
*/
int etatMenu = 0;
bool endWriteUserName = false;
int nameIndexCharacter=0,nameNumberOfLetter=65;
// administration
int indexSequence=7,sequenceHistory[8],optionSelectionAdminsitration=0,decoupeXBomb01=0;
// choix menu jeu
int etatMenuJeu=0;
// les credits
int etatEtapeCredits = 0;
float vitesseDefilementCredit = 0.5f;
float posDefilementY=760.f;
private:
SoundManagement* myPlayer;
ofTrueTypeFont* ptrMaFonte;
game* ptrMesJeux;
bool etatPiece = false, etatBlinkLettrer = false;
int etatPoints=0,posXbarreChargement=-1280;
float tpsBlinkPoint;
// 20 espace, mode bourrin
char name[20] = {'A',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
float tpsLettre = ofRandom( 0.4f, 2.0f);
ofImage img1,img2,troll01,barreIn,barreOut,trollDance,menu;
// les différents timers
int timeBlinkLetter,timeWaitLeavingWelcome,timeLoadBarFPS;
//timer animation + index
int timerTrollDance, decoupeTrollDance=0;
// variable pour l'avancement de la barre
int timeLoadBar,avancement=1,modificateur=0;
string nameSaved,strTimeLoadBar;
// CHOIX MENU
int etatMenuChoix = -1;
// Administration
ofImage gyrophare,bomb01,bomb01Chiffre;
int timeBeforeAutoLeaveAdministration,timeImageGyrophare=1,posXGyrophare=0;
float lastVolume=1.0f;
// les Crédits
ofImage photoCredit[8];
int timerForTypingLetter,toDraw = 0;
vector<string> tabTextToDisplay[8];
TypingLetter displayText[8];
bool youpiPlayed = false;
float timerRebooterAfterCredit=0.0f;
// method private
string invertName();
// aide bouton
ofImage btValider,btInterrogation,btSpam,btGauche,btHaut,btDroite,btBas;
};
|
9d87fe018445d3380a1b5573d3c56f03f2018a7e
|
cb66d2b8f040c9e432eb3df0bb31242d37800fe3
|
/demos/camera_demo/src/remotecameracontroloutput.cpp
|
06c6f49f8b6606315210a9b482cc89c3a6f92425
|
[] |
no_license
|
GaloisInc/pirate
|
a99d3b8527ed533c9f52b4262d628f0755f62a3f
|
07609e8483471c02adcd3efdab9d9b8a23d22d05
|
refs/heads/master
| 2023-03-28T04:25:03.515692
| 2021-03-12T23:44:57
| 2021-03-12T23:44:57
| 218,866,238
| 11
| 4
| null | 2021-03-12T23:44:58
| 2019-10-31T21:40:09
|
C++
|
UTF-8
|
C++
| false
| false
| 9,422
|
cpp
|
remotecameracontroloutput.cpp
|
/*
* This work was authored by Two Six Labs, LLC and is sponsored by a subcontract
* agreement with Galois, Inc. This material is based upon work supported by
* the Defense Advanced Research Projects Agency (DARPA) under Contract No.
* HR0011-19-C-0103.
*
* The Government has unlimited rights to use, modify, reproduce, release,
* perform, display, or disclose computer software or computer software
* documentation marked with this legend. Any reproduction of technical data,
* computer software, or portions thereof marked with this legend must also
* reproduce this marking.
*
* Copyright 2020 Two Six Labs, LLC. All rights reserved.
*/
#include <iostream>
#include <vector>
#include <poll.h>
#include "libpirate.h"
#include "camerademo-serialization.hpp"
#include "remotecameracontroloutput.hpp"
using namespace pirate;
using namespace CameraDemo;
#ifndef MIN
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#endif
RemoteCameraControlOutput::RemoteCameraControlOutput(
std::unique_ptr<CameraControlOutput> delegate,
const Options& options, const RemoteDescriptors& remotes) :
CameraControlOutput(),
mDelegate(std::move(delegate)),
mMessageCounter(0),
mHasOutput(options.mHasOutput),
mGapsRequestWriteGd(remotes.mGapsRequestWriteGd),
mGapsResponseReadGd(remotes.mGapsResponseReadGd),
mGapsRequestReadGds(remotes.mGapsRequestReadGds),
mGapsResponseWriteGds(remotes.mGapsResponseWriteGds),
mClientLock(),
mPollThread(nullptr),
mPoll(false)
{
}
RemoteCameraControlOutput::~RemoteCameraControlOutput() {
term();
}
int RemoteCameraControlOutput::init() {
int rv = 0;
if (mHasOutput) {
mPoll = true;
mPollThread = new std::thread(&RemoteCameraControlOutput::pollThread, this);
rv = mDelegate->init();
}
return rv;
}
void RemoteCameraControlOutput::term() {
if (mPoll) {
mPoll = false;
if (mPollThread != nullptr) {
mPollThread->join();
delete mPollThread;
mPollThread = nullptr;
}
}
}
int RemoteCameraControlOutput::recvRequest(CameraDemo::CameraControlOutputRequest& request, int &clientId) {
int rv;
struct pollfd fds[16];
std::vector<char> readBuf(sizeof(struct CameraControlOutputRequest_wire));
int nfds = MIN(mGapsRequestReadGds.size(), 16);
for (int i = 0; i < nfds; i++) {
fds[i].fd = mGapsRequestReadGds[i];
fds[i].events = POLLIN;
}
rv = poll(fds, nfds, 100);
if (rv == 0) {
return 0;
} else if (rv < 0) {
std::perror("remote camera control output receive request poll error");
return -1;
}
int gd = -1;
for (int i = 0; i < nfds; i++) {
clientId = i;
if (fds[i].revents & POLLIN) {
gd = mGapsRequestReadGds[i];
break;
}
}
rv = pirate_read(gd, readBuf.data(), sizeof(struct CameraControlOutputRequest_wire));
if (rv < 0) {
std::perror("remote camera control output receive request read error");
return -1;
} else if (rv == 0) {
return 0;
}
if (rv != sizeof(struct CameraControlOutputRequest_wire)) {
std::cout << "camera control output request " << ((int) request.reqType)
<< " received " << rv << " out of " << sizeof(struct CameraControlOutputRequest_wire)
<< " bytes" << std::endl;
return -1;
}
request = Serialization<struct CameraControlOutputRequest>::fromBuffer(readBuf);
return rv;
}
bool RemoteCameraControlOutput::recvResponse(CameraDemo::CameraControlOutputResponse& response) {
int rv;
std::vector<char> readBuf(sizeof(struct CameraControlOutputResponse_wire));
rv = pirate_read(mGapsResponseReadGd, readBuf.data(), sizeof(struct CameraControlOutputResponse_wire));
if (rv < 0) {
std::perror("remote camera control output receive response read error");
return false;
}
if (rv != sizeof(struct CameraControlOutputResponse_wire)) {
std::cout << "camera control output response received "
<< rv << " out of " << sizeof(struct CameraControlOutputResponse_wire)
<< " bytes" << std::endl;
return false;
}
response = Serialization<struct CameraControlOutputResponse>::fromBuffer(readBuf);
return true;
}
bool RemoteCameraControlOutput::sendRequest(const CameraControlOutputRequest& request) {
int rv;
std::vector<char> writeBuf(sizeof(struct CameraControlOutputRequest_wire));
Serialization<struct CameraControlOutputRequest>::toBuffer(request, writeBuf);
rv = pirate_write(mGapsRequestWriteGd, writeBuf.data(), sizeof(struct CameraControlOutputRequest_wire));
if (rv < 0) {
std::perror("remote camera control output send request write error");
return false;
}
if (rv != sizeof(struct CameraControlOutputRequest_wire)) {
std::cout << "camera control output request " << ((int) request.reqType)
<< " sent " << rv << " out of " << sizeof(struct CameraControlOutputRequest_wire)
<< " bytes" << std::endl;
return false;
}
return true;
}
bool RemoteCameraControlOutput::sendResponse(uint16_t id,
const CameraControlOutputResponse& response) {
int rv, gd;
if (id >= mGapsResponseWriteGds.size()) {
std::cout << "invalid client id " << id << std::endl;
return false;
}
gd = mGapsResponseWriteGds[id];
std::vector<char> writeBuf(sizeof(struct CameraControlOutputResponse_wire));
Serialization<struct CameraControlOutputResponse>::toBuffer(response, writeBuf);
rv = pirate_write(gd, writeBuf.data(), sizeof(struct CameraControlOutputResponse_wire));
if (rv < 0) {
std::perror("remote camera control output send response write error");
return false;
}
if (rv != sizeof(struct CameraControlOutputResponse_wire)) {
std::cout << "camera control output response to client " << id
<< " sent " << rv << " out of " << sizeof(struct CameraControlOutputResponse_wire)
<< " bytes" << std::endl;
return false;
}
return true;
}
bool RemoteCameraControlOutput::equivalentPosition(PanTilt p1, PanTilt p2) {
return mDelegate->equivalentPosition(p1, p2);
}
void RemoteCameraControlOutput::updateZoom(CameraZoom zoom) {
(void) zoom; // TODO
}
PanTilt RemoteCameraControlOutput::getAngularPosition() {
CameraControlOutputRequest request;
CameraControlOutputResponse response;
mClientLock.lock();
mMessageCounter++;
request.reqType = CameraControlOutputReqType::OutputGet;
request.messageId = mMessageCounter;
request.angularPositionPan = std::numeric_limits<float>::quiet_NaN();
request.angularPositionTilt = std::numeric_limits<float>::quiet_NaN();
bool success = sendRequest(request);
if (success) {
success = recvResponse(response);
}
mClientLock.unlock();
if (success) {
return PanTilt(response.angularPositionPan, response.angularPositionTilt);
} else {
return PanTilt(std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN());
}
}
void RemoteCameraControlOutput::setAngularPosition(PanTilt angularPosition) {
CameraControlOutputRequest request;
mClientLock.lock();
mMessageCounter++;
request.reqType = CameraControlOutputReqType::OutputSet;
request.messageId = mMessageCounter;
request.angularPositionPan = angularPosition.pan;
request.angularPositionTilt = angularPosition.tilt;
sendRequest(request);
mClientLock.unlock();
}
void RemoteCameraControlOutput::updateAngularPosition(PanTilt positionUpdate) {
CameraControlOutputRequest request;
mClientLock.lock();
mMessageCounter++;
request.reqType = CameraControlOutputReqType::OutputUpdate;
request.messageId = mMessageCounter;
request.angularPositionPan = positionUpdate.pan;
request.angularPositionTilt = positionUpdate.tilt;
sendRequest(request);
mClientLock.unlock();
}
void RemoteCameraControlOutput::pollThread() {
CameraControlOutputRequest request;
CameraControlOutputResponse response;
PanTilt angularPosition;
while (mPoll) {
int clientId = -1;
int rv = recvRequest(request, clientId);
if (rv < 0) {
return;
} else if (rv == 0) {
continue;
}
switch (request.reqType) {
case CameraControlOutputReqType::OutputGet:
angularPosition = mDelegate->getAngularPosition();
response.angularPositionPan = angularPosition.pan;
response.angularPositionTilt = angularPosition.tilt;
sendResponse(clientId, response);
break;
case CameraControlOutputReqType::OutputSet:
angularPosition.pan = request.angularPositionPan;
angularPosition.tilt = request.angularPositionTilt;
mDelegate->setAngularPosition(angularPosition);
break;
case CameraControlOutputReqType::OutputUpdate:
angularPosition.pan = request.angularPositionPan;
angularPosition.tilt = request.angularPositionTilt;
mDelegate->updateAngularPosition(angularPosition);
break;
}
}
}
|
86f6de8bee353544793173df638bbeed7b420056
|
607d438d4a0a2a7e7f291f9ab42efc02759f3bee
|
/甲级/A_B_Format.cpp
|
01c868028edb45fc350db71f12d571fbaaa2452f
|
[
"Apache-2.0"
] |
permissive
|
HelloWST2019/PTA_SuanFa
|
167838cddc5121780cab93c71b5e215da51f3cd0
|
c8b7d3781c98d4aeb4657f5363f730f918d1f49c
|
refs/heads/master
| 2020-08-10T20:31:21.165052
| 2019-10-11T16:10:58
| 2019-10-11T16:10:58
| 214,415,086
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 641
|
cpp
|
A_B_Format.cpp
|
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main(){
const int MAX=100000;
long a[MAX]={0},b[MAX]={0},sum[MAX]={0};
long h=0,h1=0,k=0;
//while(scanf("%ld",&a[h++])!=EOF&&scanf("%ld",&b[h1++])!=EOF){
while(cin >> a[h++] >> b[h1++]){
sum[h-1]=a[h-1]+b[h1-1];
};
while(k<h-1)
{
if(sum[k]>1000000||sum[k]<-1000000)
{
printf("%ld,%ld,%ld\n",sum[k]/1000000,abs((sum[k]%1000000)/1000),abs(sum[k]%1000));
}
else if(sum[k]>1000||sum[k]<-1000)
{
printf("%ld,%ld\n",sum[k]/1000,abs(sum[k]%1000));
}
else
{
printf("%ld\n",sum[k]);
}
k++;
}
}
|
eb86e99b4b1e9e2a42a2139736c3126c87387cf7
|
8dc84558f0058d90dfc4955e905dab1b22d12c08
|
/third_party/blink/renderer/platform/graphics/compositor_mutator.h
|
5f5b3cb7c9e5e6b9076d7f32996be59553bd5d34
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] |
permissive
|
meniossin/src
|
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
|
44f73f7e76119e5ab415d4593ac66485e65d700a
|
refs/heads/master
| 2022-12-16T20:17:03.747113
| 2020-09-03T10:43:12
| 2020-09-03T10:43:12
| 263,710,168
| 1
| 0
|
BSD-3-Clause
| 2020-05-13T18:20:09
| 2020-05-13T18:20:08
| null |
UTF-8
|
C++
| false
| false
| 971
|
h
|
compositor_mutator.h
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_COMPOSITOR_MUTATOR_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_COMPOSITOR_MUTATOR_H_
#include "third_party/blink/renderer/platform/graphics/compositor_animators_state.h"
#include "third_party/blink/renderer/platform/platform_export.h"
namespace blink {
class PLATFORM_EXPORT CompositorMutator {
public:
virtual ~CompositorMutator() = default;
// Called from compositor thread to run the animation frame callbacks from all
// connected AnimationWorklets.
virtual void Mutate(std::unique_ptr<CompositorMutatorInputState>) = 0;
// Returns true if Mutate may do something if called 'now'.
virtual bool HasAnimators() = 0;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_COMPOSITOR_MUTATOR_H_
|
b4444b8d71193ba058007a5276601e236b8ec56c
|
b0e5eb57206511d2016c727ed2843845219f8c5b
|
/brendlingerHiggsTestbed/Sample.h
|
898615feca9f2a2b378fd3337a3719f22c83081e
|
[] |
no_license
|
brendlin/brendlingerHiggsTestbed
|
1b54fe0671cce3272ebcb74abac5ab10bb1755f6
|
9368739de0194e936bb4bc27d3e4319481f59e15
|
refs/heads/master
| 2023-08-17T22:53:27.685261
| 2017-05-05T08:54:52
| 2017-05-05T08:54:52
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,167
|
h
|
Sample.h
|
#ifndef brendlingerHiggsTestbed_SAMPLE_H
#define brendlingerHiggsTestbed_SAMPLE_H
/**********************************************************************************
* @Package: MonojetSoftLepton
* @Class : Sample
* @Author : Rustem Ospanov, Doug Schaefer
*
* @Brief :
*
* Enum for dataset keys (samples) and helper class for a set of samples
*
**********************************************************************************/
// C/C++
#include <vector>
#include <string>
#include "brendlingerHiggsTestbed/Variables.h"
/** \brief The KTB namespace */
namespace KTB
{
//* \brief Enums for unique dataset samples. Used for naming and stuff. After a point they are overlapping. */
enum Sample {
knone,
kdata,
kunlabeled,
kggh,
ktth,
ktwh,
kbbh,
kthjb,
kttgamma,
kvbfh,
kwh,
kzh,
kEndOfNonOverlapping, // end of non-overlapping! All samples after this have a special treatment
kall,
khiggs,
};
struct dataset_props{
int runnumber;
std::string generator;
};
class sample_props{
public:
Sample first; // sample
std::string second; // name
std::string human_readable; // human-readable name
std::string tex_label;
std::vector<dataset_props> ds_props;
void addDS(int rn,std::string gen){
dataset_props ds;
ds.runnumber = rn;
ds.generator = gen;
ds_props.push_back(ds);
}
sample_props(){};
sample_props(Sample s,std::string nm,std::string hum_read){
first = s;
second = nm;
human_readable = hum_read;
//tex_label = lab;
};
};
const std::vector<KTB::sample_props> GetSampleProperties();
//const std::vector<std::pair<KTB::Sample,std::string> > GetSampleStringPairs(void);
std::string ConvertSampleToStr(Sample s);
//std::string ConvertSampleToTex(Sample s);
Sample ConvertToSample(const std::string &s);
Sample ConvertToSample(int mc_channel_number);
std::vector<KTB::Sample> GetAllSamples(bool do_overlapping_samples=true);
std::vector<KTB::Sample> GetAllSamplesDetailed();
std::vector<std::string> GetAllSampleStrings(bool do_overlapping_samples=true);
std::vector<std::string> GetAllSampleStringsDetailed();
std::vector<KTB::Sample> PrettyConvert(Sample s1, Sample s2=KTB::knone,
Sample s3=KTB::knone, Sample s4=KTB::knone
,Sample s5=KTB::knone,Sample s6=KTB::knone
,Sample s7=KTB::knone,Sample s8=KTB::knone);
//* \brief To be able to have composite sample sets */
std::vector<KTB::Sample> ConvertSampleToSampleVec(Sample s);
std::vector<std::string> ConvertSampleToSampleVec(std::string s);
/** \brief Match samples to each other */
bool MatchSample(Sample s1, Sample s2);
void PrintSample(Sample s);
void PrintSamples(std::vector<Sample> s);
std::string GetHistogramLocation(std::string classname,std::string instname,Sample s,std::string name);
std::string GetHistogramLocation(std::string classname,std::string instname,Sample s,Variable v);
}
#endif // brendlingerHiggsTestbed_SAMPLE_H
|
f53feb373ba08584aafd521078ec11eb9e641c1d
|
dcd07fb0f11821521b926cf65a1f8e42a3e87afc
|
/Graphics Objects/GraphicsObject_Null.cpp
|
5ce58cf4d72dd405381eb547abf2621a9bed63a9
|
[] |
no_license
|
santoshp1995/Game-Engine
|
9dfce27d9356582fc110460deebb207a7f071298
|
f23e89555dcc8595d7c33840871a3f53dfaa426a
|
refs/heads/main
| 2023-07-05T14:56:09.766539
| 2021-08-25T23:47:53
| 2021-08-25T23:47:53
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 415
|
cpp
|
GraphicsObject_Null.cpp
|
#include "GraphicsObject_Null.h"
namespace Azul
{
GraphicsObject_Null::GraphicsObject_Null(const Model* const _pModel, const ShaderObject* const pShaderObj)
:GraphicsObject(_pModel, pShaderObj)
{
}
void GraphicsObject_Null::SetState()
{
}
void GraphicsObject_Null::SetDataGPU()
{
}
void GraphicsObject_Null::Draw()
{
}
void GraphicsObject_Null::RestoreState()
{
}
}
|
a8bd8e56e91e9e9509ce8693677fb8c38de13484
|
461f81f2432ed373b2a354e3cf141914253c418c
|
/main/3d/inc/Vayo3dLightData.h
|
c844a2c9c60c71b9a518e16382d4184ac8b5cb62
|
[] |
no_license
|
shamozhishu/VayoEngine
|
bb3348e0e2998ff195ef791d65622b32d91ce9e2
|
a28b85776dd7f178a0f9e34eec8ddcf81b765f0a
|
refs/heads/master
| 2021-06-26T04:22:19.416528
| 2019-07-12T09:48:18
| 2019-07-12T09:48:18
| 141,963,573
| 0
| 1
| null | null | null | null |
GB18030
|
C++
| false
| false
| 895
|
h
|
Vayo3dLightData.h
|
/*************************************************************************\
* 望友引擎1.0
* Copyright (c) 2018-2019 authored by 朱加浩
* 灯光数据
\*************************************************************************/
#ifndef __VAYO3D_LIGHT_DATA_H__
#define __VAYO3D_LIGHT_DATA_H__
#include "Vayo3dColour.h"
#include "VayoVector3d.h"
NS_VAYO3D_BEGIN
enum ELightType
{
ELT_DIRECTIONAL_LIGHT = 0, // 方向光
ELT_POINT_LIGHT, // 点光源
ELT_SPOT_LIGHT // 聚光灯
};
class _Vayo3dExport LightData
{
public:
LightData() : _lightType((ELightType)-1) {}
ELightType _lightType;
Colour _ambientColor;
Colour _diffuseColor;
Colour _specularColor;
Vector3df _position;
float _range;
Vector3df _att;
Vector3df _direction;
float _exponent;
float _cutoff;
};
NS_VAYO3D_END
#endif // __VAYO3D_LIGHT_DATA_H__
|
fbc1f0d14b34533da56a620344b577cb6f5424fd
|
0cb85cd0c88a9b9f0cca4472742c2bf9febef2d8
|
/PDM/PDM2/heuristic/heur_psw.cpp
|
7ccb752b829eea17a8e619d9ac1be7103c6aa860
|
[] |
no_license
|
seth1002/antivirus-1
|
9dfbadc68e16e51f141ac8b3bb283c1d25792572
|
3752a3b20e1a8390f0889f6192ee6b851e99e8a4
|
refs/heads/master
| 2020-07-15T00:30:19.131934
| 2016-07-21T13:59:11
| 2016-07-21T13:59:11
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,199
|
cpp
|
heur_psw.cpp
|
#include "heur_psw.h"
// #define USERNAME "ADMINISTRATOR"
//
// #define SYSTEM_DRIVE "C:"
// #define WINDOWS_DIRECTORY SYSTEM_DRIVE"\\WINDOWS"
// #define PROGRAMS_DIRECTORY SYSTEM_DRIVE"\\PROGRAM FILES"
// #define PROFILES_DIRECTORY SYSTEM_DRIVE "\\DOCUMENTS AND SETTINGS"
// #define PROFILE_DIRECTORY PROFILES_DIRECTORY "\\" USERNAME
// #define APPDATA_DIRECTORY PROFILE_DIRECTORY "\\APPLICATION DATA"
#define WINDOWS_DIRECTORY "%WINDIR%"
#define PROGRAMS_DIRECTORY "%PROGRAMFILES%"
#define APPDATA_DIRECTORY "%APPDATA%"
#define PROFILE_DIRECTORY "%USERPROFILE%"
#define USERNAME "%USERNAME%"
#define MAX_FILES 3
#define MAKE_FLAG_BY_NO(no) (1<<(no))
#define INDEX_PROTECTED_STORAGE 31
typedef struct {
uint32_t nFileCreateFailedKnown;
uint32_t nFileCreateFailedUnknown;
uint32_t nFlags;
} PSW_PROCESS_DATA;
struct folder_t {
tcstring path;
tcstring files[MAX_FILES];
};
static const folder_t psw_folders [] = { // UPPERCASE!
{ _T(APPDATA_DIRECTORY) _T("\\THE BAT"), {_T("ACCOUNT.CFG"), _T("ACCOUNT.CFN")}},
{ _T(APPDATA_DIRECTORY) _T("\\IPSWITCH\\WS_FTP\\SITES"), {_T("WS_FTP.INI")} },
{ _T(PROFILE_DIRECTORY), {_T("WCX_FTP.INI")} },
{ _T(APPDATA_DIRECTORY) _T("\\OPERA\\") _T(USERNAME) _T("\\MAIL"), {_T("ACCOUNTS.INI")} },
{ _T(APPDATA_DIRECTORY) _T("\\OPERA\\") _T(USERNAME) _T("\\PROFILE"), {_T("WAND.DAT")} },
{ _T(APPDATA_DIRECTORY) _T("\\THUNDERBIRD"), {_T("PROFILES.INI")} },
{ _T(APPDATA_DIRECTORY) _T("\\MOZILLA\\FIREFOX"), {_T("PROFILES.INI")} },
{ _T(APPDATA_DIRECTORY) _T("\\QUALCOMM\\EUDORA"), {_T("EUDORA.INI")} },
{ _T(APPDATA_DIRECTORY) _T("\\SMARTFTP"), {_T("FAVORITES.DAT"), _T("HISTORY.DAT")} },
{ _T(PROGRAMS_DIRECTORY) _T("\\CUTEFTP"), {_T("SM.DAT"), _T("TREE.DAT"), _T("SMDATA.DAT")} },
{ _T(APPDATA_DIRECTORY) _T("\\GLOBALSCAPE\\CUTEFTP\\7.0"), {_T("SM.DAT"), _T("TREE.DAT"), _T("SMDATA.DAT")} },
{ _T(APPDATA_DIRECTORY) _T("\\.GAIM"), {_T("ACCOUNTS.XML")} },
{ _T(WINDOWS_DIRECTORY) , {_T("VD3USER.DAT"), _T("VD3MAIN.DAT")} },
{ _T(PROGRAMS_DIRECTORY) _T("\\TRILLIAN\\USERS\\GLOBAL"), {_T("PROFILES.INI")} }
};
cEventHandlerHeurPsw::cEventHandlerHeurPsw()
: psw_expanded_folders(0)
{
}
cEventHandlerHeurPsw::~cEventHandlerHeurPsw()
{
if (psw_expanded_folders)
{
for (size_t i=0; i<countof(psw_folders); i++)
tstrfree(psw_expanded_folders[i]);
m_pEnvironmentHelper->Free(psw_expanded_folders);
}
}
bool cEventHandlerHeurPsw::Init()
{
psw_expanded_folders = (tstring*) m_pEnvironmentHelper->Alloc(countof(psw_folders)*sizeof(tstring));
if (!psw_expanded_folders)
return false;
if (!m_pProcessList->AllocSlot(&m_slot_index))
return false;
for (size_t i=0; i<countof(psw_folders); i++)
{
psw_expanded_folders[i] = m_pEnvironmentHelper->ExpandEnvironmentStr(psw_folders[i].path);
if (!psw_expanded_folders[i])
psw_expanded_folders[i] = tstrdup(psw_folders[i].path);
if (!psw_expanded_folders[i])
return false;
psw_expanded_folders[i] = tstrupr(psw_expanded_folders[i]);
if (!psw_expanded_folders[i])
return false;
}
return true;
}
void cEventHandlerHeurPsw::iOnPassAccess(cEvent& event, cFile& file, size_t nFolderIndex)
{
cProcess pProcess = event.GetProcess();
if (!pProcess)
return;
PSW_PROCESS_DATA* pData = (PSW_PROCESS_DATA*)pProcess->GetSlotData(m_slot_index, sizeof(PSW_PROCESS_DATA));
if (!pData)
return;
uint32_t nFlag = MAKE_FLAG_BY_NO(nFolderIndex);
if (pData->nFlags & nFlag) // already marked
return;
pData->nFlags |= nFlag;
pData->nFileCreateFailedKnown++;
uint32_t nKnown = pData->nFileCreateFailedKnown;
pProcess.release();
m_pEventMgr->OnPswAccess(event, file);
if (nKnown >= 3)
m_pEventMgr->OnPswAccessMultiple(event, file);
return;
}
void cEventHandlerHeurPsw::iOnLegitAccess(cEvent& event, cFile& file, size_t nFolderIndex)
{
return;
}
void cEventHandlerHeurPsw::OnFileCreateFail(cEvent& event, cFile& file, uint32_t desired_access, uint32_t share_mode, uint32_t creation_disposition)
{
if (creation_disposition != OPEN_EXISTING || desired_access != GENERIC_READ)
return;
tcstring pFullName = file.getFull();
tcstring pFileName = file.getFilename();
for (size_t nFolderIndex=0; nFolderIndex<countof(psw_folders); nFolderIndex++)
{
tcstring pName = pFullName;
if (!tstrcmpinc(&pName, psw_expanded_folders[nFolderIndex]))
continue;
if (*pName == '\\')
pName++;
if (pName != pFileName)
continue;
for (size_t j=0; j<MAX_FILES; j++)
{
if (psw_folders[nFolderIndex].files[j] == 0)
continue;
if (0 == tstrcmp(pFileName, psw_folders[nFolderIndex].files[j]))
return iOnPassAccess(event, file, nFolderIndex);
}
return iOnLegitAccess(event, file, nFolderIndex);
}
return;
}
void cEventHandlerHeurPsw::OnProtectedStorageAccessPre(cEvent& event)
{
cFile file(m_pEnvironmentHelper, _T("<Protected Storage>"), _T("<Protected Storage>"));
return iOnPassAccess(event, file, INDEX_PROTECTED_STORAGE);
}
|
ef9187724f4922c608723c2f2a68bba0a792dc88
|
2d1716576d0342fe5f6a184046e3ceb5bf474cdd
|
/nauka/nauka1/src/random.cpp
|
97d72568c1b8d111a7253e14df7e1e3a2cf2f743
|
[] |
no_license
|
zuza3012/cpp_nauka
|
580aa438e884b49de1878729081e07c98bdd4ed8
|
feb7a4bb420fcd889551d1e0d4832a0a9f8b0c10
|
refs/heads/master
| 2020-04-12T17:10:26.547603
| 2019-01-09T20:55:55
| 2019-01-09T20:55:55
| 162,636,930
| 0
| 1
| null | 2018-12-20T23:46:21
| 2018-12-20T22:18:01
|
C++
|
UTF-8
|
C++
| false
| false
| 85
|
cpp
|
random.cpp
|
#include "random.h"
Random :: Random(){
srand(time(NULL));
}
Random :: ~Random(){}
|
432fe3b870804332f0a188579f3f26401e282c80
|
0365291d1ea6ddf6ce6979b6d1593d05e66db4f2
|
/Hash.cpp
|
ed4fc030e88bb902f2f2fcb6f0bfb149fbec5034
|
[] |
no_license
|
sumfattytuna/Zim_CSCI2270_FinalProject
|
a625e8d377bc445b6712bce015f04e0ac3d671d0
|
c4dd80a7a4e241ed890115318a537a256a9a49f6
|
refs/heads/master
| 2021-01-25T08:54:03.916957
| 2015-05-03T00:43:01
| 2015-05-03T00:43:01
| 34,361,572
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,055
|
cpp
|
Hash.cpp
|
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <string>
#include "Tree.cpp"
#include "Tree.h"
#include "Hash.h"
using namespace std;
void Hash::hasher()
{/*
for (int j = 0;j <tableSize; j++){
HashTable[j] = new movie;
HashTable[j] -> title = "empty";
HashTable[j] -> year = "empty";
HashTable[j] -> next = NULL;
}
*/
};
//Inserts movie into hashtable
void Hash::insertMovie(int imdb, string title, string year,int quantity){
int index = hashSum(title);
if (HashTable[index] == NULL)
{
HashTable[index]->imdb = imdb;
HashTable[index]->title = title;
HashTable[index]->year = year;
HashTable[index]->quantity = quantity;
HashTable[index]->next = NULL;
}else{
movie* Ptr = HashTable[index];
movie* n = new movie;
n->imdb = imdb;
n->title = title;
n->year = year;
n->quantity = quantity;
n->next = NULL;
while(Ptr->next != NULL)
{
Ptr = Ptr->next;
}
Ptr->next = n;
}
};
//Deletes movie from a hashTable
void Hash::DelMovie(string title)
{
movie* Ptr = HashTable[hashSum(title)];
for (int j = 0; j< numItems(hashSum(title));j++)
{
if(j==0 && Ptr->title == title)
{
if(Ptr->next == NULL){
cout<< "No Movie Found"<< endl;
break;
}
// Ptr->title = "empty";
// Ptr->year = "empty";
delete[Ptr];
break;
}
if(Ptr->title == title){
Ptr->next = Ptr->next->next;
}else{
Ptr = Ptr->next;
}
}
};
//counts numberof items in chain
int Hash::numItems(int index)
{
int count = 0;
if (HashTable[index]->title == "empty")
{
return count;
}else{
count++;
movie* Ptr = HashTable[index];
while(Ptr->next != NULL)
{
count++;
Ptr = Ptr->next;
}
}
return count;
};
//Hash sum algorithm for indexing
int Hash::hashSum(string x/*, int s*/)
{
int sum = 0;
for (unsigned int i = 0; i<x.length(); i++){
sum = sum + x[i];
}
sum = sum % tableSize/*s*/;
return sum;
};
//searches for movie within hash table
void Hash::FindMovie(string title)
{
movie* Ptr = HashTable[hashSum(title)];
for (int j = 0; j< numItems(hashSum(title));j++)
{
if(Ptr->title == title)
{
cout << hashSum(title) << ":" << Ptr->title << ":" << Ptr->year << endl;
}else{
Ptr = Ptr->next;
}
}
};
//Prints table
void Hash::PrintTable(int index)
{
movie* Ptr = HashTable[index];
while(Ptr !=NULL)
{
cout<< Ptr->title << ":" << Ptr->year << endl << "IMDB Rating: "<<Ptr->imdb<<endl<<"stock: "<<Ptr->quantity<<endl<<endl;
Ptr = Ptr->next;
}
};
//Converts table into a bst
void Hash::convertTable(vector<int> *v){
for(int i = 0;i < v.size(); i++){
movie* Ptr = HashTable[v[i]];
while(Ptr !=NULL)
{
movieList.push_back(Ptr);
Ptr = Ptr->next;
}
Tree x;
for (int j = 0; j <movieList.size();j++){
x.addMovieNode(Ptr->imdb, Ptr->title, Ptr->year, Ptr->quantity);
/*movie * x = root;
movie * y = NULL;
if (root == NULL)
root = newMovie;
else
{
while (x != NULL)
{
y = x;
if(newMovie->title.compare(x->title) < 0)
x = x->Lchild;
else
x = x->Rchild;
}
newMovie->parent = y;
if (newMovie->title.compare(y->title) < 0)
y->Lchild = newMovie;
else
y->Rchild = newMovie;
}
}
}*/
};
void Hash::UpdateFiler(int index)
{
ofstream myfile("OrganizedMovies.txt");
movie* Ptr = HashTable[index];
while(Ptr !=NULL)
{
myfile << Ptr->imdb << ","<< Ptr->title << "," << Ptr->year <<","<<Ptr->quantity<<endl;
Ptr = Ptr->next;
}
myfile.close();
};
|
219f1ecf36da0cc377bfd48eee65346b3133b9c9
|
51745485212767c9a3b3e31cb9a13e4a73226327
|
/FinalProject/part1/particleSimulator/src/Random.cpp
|
58f6a00d90525e16790f7a1fc6109c22417c86ca
|
[] |
no_license
|
LukeParkhurst/CS5310_GraphicsCollab
|
67029c30961a6db3aa747f4034b9c6fdf3e2a1fb
|
326a517fe9546feb9b51090f73fb88a3d2b9dd97
|
refs/heads/master
| 2023-06-01T23:44:18.096096
| 2020-08-12T14:15:30
| 2020-08-12T14:15:30
| 377,647,268
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 178
|
cpp
|
Random.cpp
|
//
// Created by Evil Dr Coconut on 8/10/2020.
//
#include <Random.h>
std::mt19937 randomEngine;
std::uniform_int_distribution<std::mt19937::result_type> distribution;
|
8509796d06de90b5b0aeefe690dffe1af46e64db
|
a064312df4c6d7b9f3e386e1a345410ed80b152e
|
/terminal.cpp
|
2098af9bde54a1b4c6d3acf96c26d973caa860b7
|
[] |
no_license
|
AnoushSim/Terminal
|
d86719ecdfe2485fb23286fcf0e67fc931029526
|
eecca29a513438c078594fccea15d3f56980c79f
|
refs/heads/master
| 2020-03-25T00:14:34.410002
| 2018-08-01T15:35:00
| 2018-08-01T15:35:00
| 143,175,550
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,874
|
cpp
|
terminal.cpp
|
#include <iostream>
#include <sstream>
#include <cstring>
#include <string>
#include <fstream>
void make_directory (std::string* , int size);
void change_directory (std::string* , int size );
void cur_directory (std::string* , int size );
void tree_function (std::string* , int size );
void touch_function (std::string* , int size );
void delete_function (std::string* , int size);
int main()
{
bool start = true;
while (start) {
std::string token[3] = {"empty" , "empty", "empty"};
std::string command;
std::getline(std::cin,command);
std::istringstream iss(command);
int ix = 0;
while (!iss.eof())
{
std::string subs;
iss >> subs;
token[ix++] = subs;
}
if ( token[0] == "mkdir") {
make_directory(token, ix );
continue;
}
if ( token[0] == "chdir") {
change_directory(token, ix );
continue;
}
if ( token[0] == "dir") {
cur_directory(token, ix );
continue;
}
if ( token[0] == "rmdir") {
delete_function(token, ix );
continue;
}
if ( token[0] == "tree") {
make_directory(token, ix );
continue;
}
if ( token[0] == "touch") {
touch_function(token, ix );
continue;
}
}
return 0;
}
void make_directory (std::string* token, int size)
{
if (size > 2) {
std::cout << "Unknown command!\n";
return;
}
char * cstr = new char [50];
std::strcpy (cstr, token[0].c_str());
std::strcat (cstr, " ");
std::strcat (cstr, token[1].c_str());
system(cstr);
}
void change_directory (std::string* token, int size)
{
if (size > 2) {
std::cout << "Unknown command!\n";
return;
}
char * cstr = new char [50];
std::strcpy (cstr, token[0].c_str());
std::strcat (cstr, " ");
std::strcat (cstr, token[1].c_str());
system(cstr);
}
void delete_function (std::string* token, int size)
{
if (size > 2) {
std::cout << "Unknown command!\n";
return;
}
char * cstr = new char [50];
std::strcpy (cstr, token[0].c_str());
std::strcat (cstr, " ");
std::strcat (cstr, token[1].c_str());
system(cstr);
}
void touch_function (std::string* token, int size)
{
if (size > 2) {
std::cout << "Unknown command!\n";
return;
}
char * cstr = new char [50];
std::strcpy (cstr, token[0].c_str());
std::ofstream myfile (cstr);
if (myfile.is_open())
{
std::cout << "File is open!\n";
}
else std::cout << "Unable to open file\n";
}
void cur_directory (std::string* token, int size)
{
if (size > 1) {
std::cout << "Unknown command!\n";
return;
}
char * cstr = new char [50];
std::strcpy (cstr, token[0].c_str());
system(cstr);
}
void tree_function (std::string* token, int size)
{
if (size > 1) {
std::cout << "Unknown command!\n";
return;
}
char * cstr = new char [50];
std::strcpy (cstr, token[0].c_str());
system(cstr);
}
|
0fc4e009dfb672de09a76f71e1d8552aa1d12c4d
|
8ff8b4a895bb6cf36de71d65ecb7ca31d7501dc1
|
/src/main.cc
|
b84228deb7edc27a6fb1c55f4187aaf9cd6703cc
|
[] |
no_license
|
Tiarna/prpa
|
1a41eca261ee2184aa7b434a3983ac53324bd35c
|
111348e76164326b6c297dff4766545437c704f4
|
refs/heads/master
| 2016-09-10T20:13:14.473413
| 2014-07-16T14:46:28
| 2014-07-16T14:46:28
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,575
|
cc
|
main.cc
|
#include "main.hh"
/*Uint32 getpixel(SDL_Surface *surface, int x, int y)
{
int bpp = surface->format->BytesPerPixel;
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
switch(bpp) {
case 1:
return *p;
break;
case 2:
return *(Uint16 *)p;
break;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
return p[0] << 16 | p[1] << 8 | p[2];
else
return p[0] | p[1] << 8 | p[2] << 16;
break;
case 4:
return *(Uint32 *)p;
break;
default:
return 0;
}
}*/
unsigned int getpixel(SDL_Surface *s, int x, int y)
{
return ((unsigned int*)s->pixels)[y*(s->pitch/sizeof(unsigned int)) + x];
}
std::vector<Node> init_node(int width, int height)
{
std::vector<Node> ret;
int r, g, b;
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
r = rand() % 256;
g = rand() % 256;
b = rand() % 256;
ret.push_back(Node(r, g, b));
}
}
return ret;
}
void my_pause()
{
int continuer = 1;
SDL_Event event;
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
}
}
}
void display(std::vector<Node> vec, int width, int height)
{
vec = vec;
SDL_Surface *ecran = NULL;
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE);
SDL_Rect position;
position.x = 0;
position.y = 0;
int dim = height * width;
SDL_Surface *pix[dim];
for (int i = 0; i < width * height; i++)
{
//*pix[dim] = {NULL};
pix[i] = SDL_CreateRGBSurface(0, 1, 1, 32, 0, 0, 0, 0);
}
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
for (int i = 0; i < width; i++)
{
for(int j = 0; j < height; j++)
{
position.x = i;
position.y = j;
SDL_FillRect(pix[i * j + j], NULL, SDL_MapRGB(ecran->format, vec[i * j + j].getR(), vec[i * j + j].getG(), vec[i * j + j].getB()));
SDL_BlitSurface(pix[i * j + j], NULL, ecran, &position);
}
}
SDL_Flip(ecran);
my_pause();
for (int i = 0 ; i < width * height; i++)
SDL_FreeSurface(pix[i]);
SDL_Quit();
}
int search_closer(Uint8 r, Uint8 g, Uint8 b, std::vector<Node> vec)
{
int min = 196000;
int tmp;
int pos;
for (unsigned int i = 0; i < vec.size(); i++)
{
tmp = vec[i].dist2(r, g, b);
if (min > tmp)
{
min = tmp;
pos = i;
}
}
return pos;
}
std::vector<Node> calculate_seq(char* file, std::vector<Node> vec, int width,
int height, std::vector<int> vecint)
{
// std::cout << "DEBUG main.cc: calculate: begin of fct" << std::endl;
SDL_Surface *img = NULL;
SDL_Init(SDL_INIT_VIDEO);
img = SDL_LoadBMP(file);
// std::cout << "DEBUG main.cc: calculate: after image loading"
// << ". Img vals " << img << std::endl;
Uint32 current_pix = 0;
Uint8 r = 0;
Uint8 g = 0;
Uint8 b = 0;
int bestfit;
std::vector<Node> ret = vec;
double par_time;
{
timer t(par_time);
for (unsigned int i = 0; i < vecint.size(); i++)
{
current_pix = getpixel(img, vecint[i] / height, vecint[i] % height);
SDL_GetRGB(current_pix, img->format, &r, &g, &b);
bestfit = search_closer(r, g, b, vec);
ret = update(width, height, bestfit, r, g, b, vec);
}
}
std::cout << "Sequential time: \t" << par_time << std::endl;
return ret;
}
class apply_par
{
public:
void operator()(const tbb::blocked_range<size_t>& rank) const
{
Uint32 current_pix = 0;
Uint8 r = 0;
Uint8 g = 0;
Uint8 b = 0;
int bestfit;
for(size_t i = rank.begin(); i != rank.end(); i++)
{
std::vector<Node> t = vec;
current_pix = getpixel(img, vecint[i] / height, vecint[i] % height);
SDL_GetRGB(current_pix, img->format, &r, &g, &b);
bestfit = search_closer(r, g, b, vec);
ret = update(width, height, bestfit, r, g, b, t);
}
}
apply_par(char* file, std::vector<Node>& v, int w, int h, int it, std::vector<int> vt)
:vec(v), width(w), height(h), iteration_nb(it), vecint(vt), ret(v)
{
SDL_Init(SDL_INIT_VIDEO);
img = SDL_LoadBMP(file);
}
std::vector<Node> getvec()
{
return ret;
}
private:
SDL_Surface *img = NULL;
std::vector<int> vecint;
char* file;
std::vector<Node>& vec;
int width;
int height;
int iteration_nb;
std::vector<Node>& ret;
};
std::vector<Node> calculate_par(char* file, std::vector<Node> vec, int width,
int height, int iteration_nb, std::vector<int> vecint)
{
apply_par app = apply_par(file, vec, width, height, iteration_nb, vecint);
double par_time;
{
timer t(par_time);
tbb::parallel_for(tbb::blocked_range<size_t>(0, vecint.size()), app);
}
std::cout << "Parallel time: \t" << par_time << std::endl;
return app.getvec();
}
int main(int argc, char** argv)
{
if (argc != 5)
{
std::cout << "using: Filename dimx dimy nb_iteration" << std::endl;
return 1;
}
int width = atoi(argv[2]);
int height = atoi(argv[3]);
int iteration_nb = atoi(argv[4]);
std::vector<Node> vecNode_seq = init_node(width, height);
std::vector<Node> vecNode_par = vecNode_seq;
std::vector<int> vecint = get_random_suite(width * height, iteration_nb);
vecNode_seq = calculate_seq(argv[1], vecNode_seq, width, height, vecint);
display(vecNode_seq, width, height);
vecNode_par = calculate_par(argv[1], vecNode_par, width, height, iteration_nb, vecint);
display(vecNode_par, width, height);
}
|
140161cdd9bdc645486c71f21fce03fc70392476
|
1ce9442d4977339f042fa404b22a6aba11a5c89d
|
/so lazy to find a name/bai 1.3.cpp
|
edf298c69cff0bfe730751eb167e3d1a137aa701
|
[] |
no_license
|
Phananhkiet0825/Data-Structure-and-Algorithms
|
97f6703dc85b0f3d046a481f9851bc0703b4d710
|
ff565b3ee82ae49e1ab7d82ac932ae99f5580188
|
refs/heads/main
| 2023-01-12T01:17:55.668657
| 2020-11-11T16:59:21
| 2020-11-11T16:59:21
| 309,437,212
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,128
|
cpp
|
bai 1.3.cpp
|
#include<stdio.h>
#define MAX 100
typedef struct NHANVIEN
{
char maNV[11]; //kieu chuoi= mang ky tu
char hoTen[41];
float luong;
}NV ; //ket thuc khai bao co cham phay
//nhap 1 nhan vien
void Nhap(NV &nv)
{
printf("\nMoi nhap ma nhan vien= "); gets(nv.maNV);gets(nv.maNV);
printf("\nMoi nhap ho ten nhan vien= "); gets(nv.hoTen);
printf("\nMoi nhap luong nhan vien= "); scanf("%f", &nv.luong);
}
void XuatTieuDe()
{
printf("\n%-20s","Ma nhan vien");
printf("\t%-30s","Ho ten");
printf("\t%10s","Luong");
}
void Xuat(NV nv)
{
printf("\n%-20s",nv.maNV);
printf("\t%-30s",nv.hoTen);
printf("\t%10.2f", nv.luong);
}
int Nhap()
{
int n;
while(1)
{
printf("\nMoi nhap (n>0) n= " ); scanf("%d",&n);
if(n>0) return n;
printf("\nBan nhap sai, moi nhap lai...");
}
}
void NhapDS(NV a[], int n)
{
for(int i=0; i<n ; i++)
{
printf("\nMoi nhap thong tin nhan vien thu %d", i+1);
Nhap(a[i]);
}
}
void XuatDS(NV a[], int n)
{
XuatTieuDe();
for(int i=0; i<n ; i++)
Xuat(a[i]);
}
void HoanVi(NV &x, NV &y) //[1]
{
NV t=x; x=y; y=t; //[2]
}
void SelectSort(NV a[], int n) //[3]
{
for(int i=0; i<n-1; i++)
{
/* Tim vi tri min*/
int vt=i;
for(int j=i+1; j<n; j++)
if(a[j].luong<a[vt].luong) //[4]
vt=j;
/*Hoan vi giua phan tu a[i] voi a[vt]*/
HoanVi(a[i], a[vt]);
}
}
void InsertSort(NV a[], int n) //[5]
{
for(int i=1;i<n;i++) //duyet mang ben phai chua duoc sap
{
NV x=a[i]; //[6]
int pos=i-1; //duyet nguoc day vang khe ben trai
while(pos>=0 && a[pos].luong>x.luong) //[7]
{
a[pos+1]=a[pos];
//phep gan <- : gan gia tri tu dang sau ra dang truoc
pos--; //duyet nguoc
}
//////////////////////////////////
a[pos+1]=x; //ha bien x xuong
}
}
int main()
{
int n=Nhap();
NV a[MAX]; NhapDS(a,n);
printf("\n*****Danh sach nhan vien*****\n");
XuatDS(a,n);
SelectSort(a,n);
printf("\n*****Danh sach nhan vien tang dan theo luong CHON*****\n");
XuatDS(a,n);
InsertSort(a,n);
printf("\n*****Danh sach nhan vien tang dan theo luong CHEN*****\n");
XuatDS(a,n);
}
|
634489cdfbf0263e3888706effd53fdde95c4e79
|
5acf251ef1b0b3fc7e6da3de4b336c8a5b71a2ee
|
/QuickSort/main2.cpp
|
c380a7dcdb564f1c56cfeea0958c27eef771c5fb
|
[] |
no_license
|
frankyyyt/DataStructure-Algorithm
|
0c023cfffe6a089a15a2f5101a04fad6f02a4db3
|
af4b2e3c3f36f1fcea33ce3f09c11cdbcd1e008c
|
refs/heads/master
| 2021-01-25T09:26:28.490390
| 2016-09-19T13:08:49
| 2016-09-19T13:08:49
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 538
|
cpp
|
main2.cpp
|
#include<iostream>
using namespace std;
int partition1(int* a,int p,int r)
{
int k=a[p];
while(p<r)
{
if(p<r&&k>a[r]) r--;
a[p]=a[r];
if(p<r&&k<a[p]) p++;
a[r]=a[p];
}
a[p]=k;
return p;
}
int qsort(int* a,int p,int r)
{
int k=qsort(a,p,r);
qsort(a,p,k-1);
qsort(a,k+1,r);
}
int main()
{
enum{maxx=10};
int a[maxx]={0,3,2,32,4,22,6,76,0,11};
int p=0,r=maxx-1;
qsort(a,p,r);
for(int i=0;i<maxx;i++)
{
cout<<a[i]<<" ";
}
return 0;
}
|
78e4e36609fce27342c509afd6cc87afe436c5dc
|
ded976908e71b10c82036ea54857176374c7caa0
|
/gameObj.cpp
|
81799aae65ce6f1313a241a9d31d8f6a56458fdb
|
[] |
no_license
|
mattConn/snake-game
|
f1dffccf4cd21d89ec86412cf841f0e903869f49
|
00070f01d7f67a7fd4f99e19c443e1f5c9b76b3b
|
refs/heads/master
| 2020-11-27T14:36:33.737924
| 2020-07-12T23:06:45
| 2020-07-12T23:06:45
| 229,492,199
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,105
|
cpp
|
gameObj.cpp
|
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <cassert>
#include <string>
#include <utility>
#include "SDLw.h"
#include "game.h"
#include "debug.h"
#include "gameObj.h"
// default constructor
gameObj::gameObj()
{
rect = SDLw::rect(0, 0, 1, 1);
};
// detailed constructor
// takes texture string, velocity, width, height, xPos, yPos
gameObj::gameObj(std::string t, const double& vel, const int &width, const int &height, const int &xPos,const int &yPos)
{
textureString = t;
velocity = vel;
rect = SDLw::rect(xPos, yPos, width, height);
initialX = xPos;
initialY = yPos;
};
// copy constructor with rect coords
// takes rhs gameObj, xPos, yPos
gameObj::gameObj(const gameObj& other, const int &xPos, const int &yPos)
{
textureString = other.textureString;
velocity = other.velocity;
rect = SDLw::rect(xPos, yPos, other.rect.w, other.rect.h);
initialX = rect.x;
initialY = rect.y;
};
bool gameObj::isOffscreen() const {
if (rect.getR() < 0 || rect.getL() > game::SCREEN_WIDTH || rect.getTop() > game::SCREEN_HEIGHT || rect.getBottom() < 0)
return true;
return false;
};
|
98542432eaea6ecbfa6ab727b381b8a0622d5046
|
9b8d942f833a0dd081bcec08583d02647178418d
|
/EX07_Joystick/EX07_Joystick.ino
|
6729f6a150b5875f5d8afa8746e461f66350d6e2
|
[
"MIT"
] |
permissive
|
titos-carrasco/Taller-Arduino-Basico
|
4c7ca59bc4ab798a917624d8e1583f6e23fdd238
|
a46689cea1dae573df06a985c2c359e52a6d8220
|
refs/heads/master
| 2021-01-25T04:57:29.705265
| 2015-06-17T23:35:55
| 2015-06-17T23:35:55
| 24,537,173
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,268
|
ino
|
EX07_Joystick.ino
|
/*
Control con Koystick
*/
int pin_vrX = 0; // pin (A0) al cual esta conectada la salida del eje X
int pin_vrY = 1; // pin (A1) al cual esta conectado la salida del eje Y
int pin_sw = 12; // pin al cual esta conectado la salida del boton
// Incluye la libreria del LCD
#include <LiquidCrystal.h>
// Inicializa la libreria con los pines utilizados
// RS, E, D4, D5, D6, D7
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
// la funcion setup() se ejecuta una vez al reiniciarse
void setup() {
lcd.begin(16, 2); // setea el numero de filas y columnas
pinMode(pin_sw, INPUT); // el pin para leer el boton del joystick
digitalWrite(pin_sw, HIGH); // deja en 1 la entrada, ¿Por que?
}
// la funcion loop() es llamada internamente en un ciclo sin fin
void loop() {
int x = analogRead(pin_vrX);
int y = analogRead(pin_vrY);
int b = digitalRead(pin_sw);
lcd.setCursor(0, 0); // cursor en la columna 0, fila 0
lcd.print("X=");
lcd.print(x);
lcd.print(" Y=");
lcd.print(y);
lcd.print(" ");
lcd.setCursor(0, 1); // cursor en la columna 0, fila 1
lcd.print("Boton=");
lcd.print(b);
lcd.print(" ");
}
|
f9175e833fc82c7107b57eac69599302b3829909
|
d35a2833ea92b90b06cb5c6c5374407be1cced41
|
/src/line_block.cpp
|
b87d9cde063ebeb33d4b6d906a4df3b1c68cdcdd
|
[
"BSL-1.0"
] |
permissive
|
qubusproject/carrot
|
51047aabcd3b3eef044eb20973391b9df05bdc9b
|
a56c0fc89190a1b2e026e413052b370584694983
|
refs/heads/master
| 2021-06-24T14:00:02.180938
| 2020-10-11T20:35:52
| 2020-10-11T20:35:52
| 138,066,180
| 0
| 0
|
BSL-1.0
| 2020-10-11T20:35:53
| 2018-06-20T17:41:33
|
C++
|
UTF-8
|
C++
| false
| false
| 1,929
|
cpp
|
line_block.cpp
|
// Copyright (c) 2015-2018 Christopher Hinz
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <carrot/line_block.hpp>
#include <carrot/form_view.hpp>
#include <algorithm>
#include <utility>
namespace carrot
{
line_block::line_block(growth_direction direction_) noexcept : direction_(direction_)
{
}
line_block& line_block::add(block b) noexcept
{
blocks_.push_back(std::move(b));
return *this;
}
void line_block::render(form& output_form, const style& s) const
{
long int offset = 0;
for (const auto& block : blocks_)
{
auto extent = block.extent(output_form.target(), s);
switch (direction_)
{
case growth_direction::right:
{
form_view view(output_form, 0, offset);
block.render(view, s);
offset += extent[1];
break;
}
case growth_direction::down:
{
form_view view(output_form, offset, 0);
block.render(view, s);
offset += extent[0];
break;
}
}
}
}
std::array<long int, 2> line_block::extent(const target_info& output_target, const style& s) const
noexcept
{
std::array<long int, 2> result{0, 0};
for (const auto& block : blocks_)
{
auto extent = block.extent(output_target, s);
switch (direction_)
{
case growth_direction::right:
result[0] = std::max(result[0], extent[0]);
result[1] += extent[1];
break;
case growth_direction::down:
result[0] += extent[0];
result[1] = std::max(result[1], extent[1]);
break;
}
}
return result;
}
line_block make_line(growth_direction direction) noexcept
{
return line_block(direction);
}
} // namespace carrot
|
85382cde18877760aa87c79c853d5135dd8af18e
|
565b0a88c0d6f8a71d42f919613a1d166889c8bb
|
/Code/Easy Problems/CodeForces 100030D Broadcasting (水).cpp
|
0b4d0a54bf2ebfcf924b767fce4c3717a8c5ed27
|
[] |
no_license
|
DaDaMrX/ACM
|
71d7347640e745ea30518762588f6a698722295b
|
603cff542027db7875bfc57d92c9cdaba1f82c80
|
refs/heads/master
| 2020-04-12T06:23:25.442550
| 2017-07-30T11:01:48
| 2017-07-30T11:01:48
| 62,130,184
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 699
|
cpp
|
CodeForces 100030D Broadcasting (水).cpp
|
/************************************************************
CodeForces 100030D Broadcasting (水)
数学上ans=ceil(log(n)/log(k+1)),但计算对数特别容易丢失精度,改用while累乘
************************************************************/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 0x7f7f7f7f;
const int N = 1e3 + 10;
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n, k;
scanf("%d%d", &n, &k);
int ans = 0;
ll s = 1;
while (s < n)
{
s *= k + 1;
ans++;
}
printf("%d\n", ans);
return 0;
}
|
dd997ef0b8e75a7ab16ae54b5f7864be0cfeedbc
|
8c615b3c51c152d95e9e470c5479871f411e3117
|
/src/inputValidation.hpp
|
26c53b090b5d43f9a797ee215e02e70976787412
|
[] |
no_license
|
kelleyneubauer/bigger-or-better
|
9157c6c5d4a7f8d02773db01cb7e608b1a2ed8d4
|
d3c6cfbcbf2d9debbf6182d678f240c8e459d0f1
|
refs/heads/master
| 2023-02-14T17:09:17.883484
| 2021-01-08T23:38:14
| 2021-01-08T23:38:14
| 290,588,654
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 494
|
hpp
|
inputValidation.hpp
|
/*******************************************************************************
*
* File: inputValidation.hpp
* Author: Kelley Neubauer
* Date: 10/1/2019
*
* Description:
* This is the header file for my inputValidation function (CLASS?).
*
******************************************************************************/
#ifndef INPUT_VALIDATION_HPP
#define INPUT_VALIDATION_HPP
int getInt();
int getInt(int min, int max);
int getIntMin(int min);
int getIntMax(int max);
#endif
|
8de044b6a8f61455b8e62e5fa70c0b43028732e6
|
ee948e2bbfa08b79323cb28b99b63f09d5e39682
|
/sources/tests/require-unit-expert-test.cpp
|
82f5006c1eaa2c94eb3ae6cb9fd67d7cd2c86801
|
[] |
no_license
|
LordBlackhawk/bw-karl
|
6c8808cd0472a6fcf6500b03c218fcc01b76908c
|
20ca5958781b856c5861882cddd4c0f8838542fd
|
refs/heads/master
| 2016-09-05T23:57:30.543228
| 2014-11-13T20:17:50
| 2014-11-13T20:17:50
| 35,498,576
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,866
|
cpp
|
require-unit-expert-test.cpp
|
#include "blackboard-fixture.hpp"
#include "plan/broodwar-boundary-items.hpp"
#include "plan/broodwar-plan-items.hpp"
#include "expert/require-unit-expert.hpp"
BOOST_FIXTURE_TEST_SUITE( larva_test, BlackboardFixture )
BOOST_AUTO_TEST_CASE( basic_larva )
{
auto b1 = createOwnUnitBoundaryItem(BWAPI::UnitTypes::Zerg_Larva);
createOwnUnitBoundaryItem(BWAPI::UnitTypes::Zerg_Larva);
createOwnUnitBoundaryItem(BWAPI::UnitTypes::Zerg_Larva);
auto p1 = blackboard->morph(BWAPI::UnitTypes::Zerg_Drone);
auto p2 = blackboard->morph(BWAPI::UnitTypes::Zerg_Drone);
BOOST_CHECK_EQUAL( b1->provideUnit.getUnitType(), BWAPI::UnitTypes::Zerg_Larva );
BOOST_CHECK_EQUAL( p1->requireUnit.getUnitType(), BWAPI::UnitTypes::Zerg_Larva );
BOOST_CHECK( !p1->isActive() );
RequireUnitExpert expert;
expert.tick(blackboard);
BOOST_CHECK( p1->requireUnit.isConnected() );
BOOST_CHECK( p2->requireUnit.isConnected() );
}
BOOST_AUTO_TEST_CASE( active_plan_items )
{
createOwnUnitBoundaryItem(BWAPI::UnitTypes::Zerg_Larva);
auto b1 = createOwnUnitBoundaryItem(BWAPI::UnitTypes::Zerg_Larva);
createOwnUnitBoundaryItem(BWAPI::UnitTypes::Zerg_Larva);
auto p1 = blackboard->morph(BWAPI::UnitTypes::Zerg_Drone);
auto p2 = blackboard->morph(BWAPI::UnitTypes::Zerg_Drone);
BOOST_CHECK( !b1->provideUnit.isActiveConnection() );
BOOST_CHECK( !p1->requireUnit.isActiveConnection() );
p1->requireUnit.connectTo(&b1->provideUnit);
p1->setActive();
BOOST_CHECK( b1->provideUnit.isActiveConnection() );
BOOST_CHECK( p1->requireUnit.isActiveConnection() );
RequireUnitExpert expert;
expert.tick(blackboard);
BOOST_CHECK( b1->provideUnit.isConnected() );
BOOST_CHECK( p1->requireUnit.isConnected() );
BOOST_CHECK( b1->provideUnit.getConnectedPort() == &p1->requireUnit );
BOOST_CHECK( p2->requireUnit.isConnected() );
}
BOOST_AUTO_TEST_CASE( two_provider )
{
auto pool = createOwnUnitBoundaryItem(BWAPI::UnitTypes::Zerg_Spawning_Pool);
blackboard->build(BWAPI::UnitTypes::Zerg_Spawning_Pool);
auto upgrade = blackboard->upgrade(BWAPI::UpgradeTypes::Metabolic_Boost);
RequireUnitExpert expert;
expert.tick(blackboard);
BOOST_REQUIRE( upgrade->requireUnit.isConnected() );
BOOST_CHECK( upgrade->requireUnit.getConnectedPort()->getOwner() == pool );
}
BOOST_AUTO_TEST_CASE( no_provider )
{
auto upgrade = blackboard->upgrade(BWAPI::UpgradeTypes::Metabolic_Boost);
RequireUnitExpert expert;
expert.tick(blackboard);
BOOST_REQUIRE( upgrade->requireUnit.isConnected() );
auto planItem = dynamic_cast<BuildPlanItem*>(upgrade->requireUnit.getConnectedPort()->getOwner());
BOOST_REQUIRE( planItem != NULL );
BOOST_CHECK_EQUAL( planItem->getUnitType(), BWAPI::UnitTypes::Zerg_Spawning_Pool );
}
BOOST_AUTO_TEST_SUITE_END()
|
0bb9df8cf9b6dfd2b2ad9fd97649b11d0b854bea
|
d33b232ae41dcca316c590f35d59209176ab185d
|
/Tools/ResourceEditor/Classes/Qt/DockSceneTree/SceneTreeDelegate.cpp
|
3ca8fb4506b9e86749b11d6b575992d17bf20dbc
|
[] |
no_license
|
dominik111/dava.framework
|
fd10e75cb76090301dd765de3885fe7f62570e75
|
3650cb7541bad8188d0ac043a804f3eea99b972b
|
refs/heads/master
| 2021-01-17T22:59:46.358803
| 2013-10-11T14:20:14
| 2013-10-11T14:20:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,809
|
cpp
|
SceneTreeDelegate.cpp
|
/*==================================================================================
Copyright (c) 2008, DAVA, INC
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the DAVA, INC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE DAVA, INC AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVA, INC BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=====================================================================================*/
#include <QtGui>
#include "DockSceneTree/SceneTreeDelegate.h"
#include "DockSceneTree/SceneTreeItem.h"
SceneTreeDelegate::SceneTreeDelegate(QWidget *parent /* = 0 */)
: QStyledItemDelegate(parent)
{
lockedIcon = QIcon(":/QtIcons/locked.png");
}
void SceneTreeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
customDraw(painter, &opt, index);
QStyledItemDelegate::paint(painter, opt, index);
}
QSize SceneTreeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
return QStyledItemDelegate::sizeHint(option, index);
}
void SceneTreeDelegate::customDraw(QPainter *painter, QStyleOptionViewItem *option, const QModelIndex &index) const
{
DAVA::Entity *entity = index.data(SceneTreeItem::TreeItemEntityRole).value<DAVA::Entity*>();
if(NULL != entity && entity->GetLocked())
{
QRect owRect = option->rect;
owRect.setLeft(owRect.right() - 16);
lockedIcon.paint(painter, owRect);
option->rect.setRight(owRect.left());
}
}
|
c2750ae539e48ee68bccb909ad8ec1ff7c7e8019
|
719ef202149d3ab0864c6a4723b3301f736e0dec
|
/src/甲级/1049.cpp
|
698ca86638e136ab22e158f3d9f33f61d7688401
|
[] |
no_license
|
SuYindu/PAT
|
b74d63b97c9995329bbaf58331a6117514eb3f42
|
e8b4078456f91e97fed57e337ce7f2d39d66ab03
|
refs/heads/master
| 2021-11-29T11:40:17.872722
| 2021-11-23T02:54:24
| 2021-11-23T02:54:24
| 173,454,325
| 21
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 424
|
cpp
|
1049.cpp
|
#include <iostream>
using namespace std;
int main() {
int n, m = 1, ans = 0;
cin >> n;
while (n / m) {
int left = n / m / 10;
int digit = n / m % 10;
int right = n % m;
if (digit == 0) ans += left * m;
else if (digit == 1) ans += left * m + right + 1;
else ans += left * m + m;
m *= 10;
}
cout << ans << endl;
return 0;
}
|
65f88364cd0d67f79d706c8a7f6240545d355bd3
|
26524fec2231290c65a0bf126943101bb8b8300c
|
/LIBCMODELX/MODELX/MODELX/CTransform.h
|
4287256a1e5ead3f17a658b4b4983d813a8b1fbb
|
[] |
no_license
|
programminggp/2DLV1
|
d424a946fe9f92c15c20a76f5986f19a3bf628f5
|
fbe8394189431897312e74caf32e500ea2c8cd13
|
refs/heads/master
| 2023-09-01T13:38:35.309123
| 2023-09-01T11:45:01
| 2023-09-01T11:45:01
| 176,943,495
| 2
| 1
| null | 2022-05-26T09:56:53
| 2019-03-21T12:49:43
|
C
|
SHIFT_JIS
|
C++
| false
| false
| 1,124
|
h
|
CTransform.h
|
#ifndef CTRANSFORM_H
#define CTRANSFORM_H
namespace modelx {
class CVector;
class CMatrix;
/*
トランスフォームクラス
位置、回転、拡縮、変換行列の基本クラス
*/
class CTransform {
public:
//位置の取得
const CVector& Position() const;
//位置の設定
//Position(位置)
void Position(const CVector& v);
//回転値の設定
//Rotation(回転値)
void Rotation(const CVector& v);
//拡大縮小の設定
//Scale(拡大縮小)
void Scale(const CVector& v);
//合成行列の取得
const CMatrix& Matrix() const;
//回転行列の取得
const CMatrix& MatrixRotate() const;
//行列更新処理
void Update();
//Update(位置, 回転, スケール)
void Update(const CVector& pos, const CVector& rot, const CVector& scale);
protected: //子クラスはアクセス可能
CVector mPosition; //位置
CVector mRotation; //回転
CVector mScale; //拡大縮小
CMatrix mMatrixTranslate; //平行移動行列
CMatrix mMatrixRotate; //回転行列
CMatrix mMatrixScale; //拡大縮小行列
CMatrix mMatrix; //合成行列
};
}
#endif
|
65eda10d0d6114ba9ff0ca91c70b06ed38561452
|
4d5fab92b1155ea8b131af3d2af2a48c0b9a7726
|
/game of life.cpp
|
f935206155335cbde3e9df2a9242ff5794a02124
|
[] |
no_license
|
hpp3/GameOfLife
|
98ced012789851e2ecdbf4ffe7ea3e684e127f13
|
a5c9e8a7b2f35420b8df8ea8fc59c8f39a6fd003
|
refs/heads/master
| 2021-01-10T19:59:15.177206
| 2013-01-30T00:26:55
| 2013-01-30T00:26:55
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,106
|
cpp
|
game of life.cpp
|
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <allegro.h>
const int height = 80, width = 120;
int resolution, border;
bool world[width][height];
bool next[width][height];
BITMAP *buffer;
bool quit;
using namespace std;
int neighbours(int x, int y);
void step(int &age);
void display(int age);
void debug(int age);
void close();
void edit();
void redraw();
int main() {
int delay=5, desktoph, desktopw;
allegro_init();
// Set the window title when in a GUI environment
install_keyboard();
install_mouse();
show_mouse(screen);
// Set graphics mode
set_color_depth(desktop_color_depth());
get_desktop_resolution(&desktopw, &desktoph);
if (desktoph*height < desktopw * width) resolution = desktoph/height -4;
else resolution = desktopw/width -4;
border = resolution/10;
if (border == 0) border = 1;
set_gfx_mode(GFX_AUTODETECT_WINDOWED, width*resolution, height*resolution, 0, 0);
set_close_button_callback(close);
buffer = create_bitmap(width*resolution, height*resolution);
int age = 0;
char input[width+1];
ifstream in("world.txt");
if (!in) return 1;
for (int y = 0; y < height; y++) {
in.getline(input, width+1);
for (int x = 0; x < width; x++)
world[x][y] = (input[x]=='1');
}
while (!quit) {
display(age);
if (keypressed()) {
int key = readkey();
switch ((key >> 8) & 0xFF) {
case KEY_E:
edit();
break;
case KEY_1:
delay = 9;
break;
case KEY_2:
delay = 8;
break;
case KEY_3:
delay = 7;
break;
case KEY_4:
delay = 6;
break;
case KEY_5:
delay = 5;
break;
case KEY_6:
delay = 4;
break;
case KEY_7:
delay = 3;
break;
case KEY_8:
delay = 2;
break;
case KEY_9:
delay = 1;
break;
case KEY_0:
delay = 0;
break;
}
}
step(age);
rest(delay*20);
}
in.close();
return 0;
}
END_OF_MAIN()
int neighbours(int x, int y) {
int sum = 0;
for (int dy = -1; dy < 2; dy++) {
for (int dx = -1; dx < 2; dx++) {
if (dx == 0 && dy == 0) continue;
if ((x+dx >= 0) &&
(x+dx < width) &&
(y+dy >= 0) &&
(y+dy < height)) if(world[x+dx][y+dy]) sum++;
}
}
return sum;
}
void step(int &age) {
age++;
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++) {
int myNeighbours = neighbours(x, y);
switch(world[x][y]) {
case 1:
if (myNeighbours == 2 || myNeighbours == 3) next[x][y] = 1;
else next[x][y] = 0;
break;
case 0:
if (myNeighbours == 3) next[x][y] = 1;
else next[x][y] = 0;
break;
}
}
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
world[x][y] = next[x][y];
}
void display(int age) {
char title[32];
sprintf(title, "Life - Time: %d", age);
set_window_title(title);
clear_to_color(buffer, makecol(255, 255, 255));
for (int i = 0; i < width; i++) {
rectfill(buffer, (i+1)*resolution-border, 0, (i+1)*resolution-1, buffer->h, makecol(0,0,0));
rectfill(buffer, i*resolution, 0, i*resolution+border-1, buffer->h, makecol(0,0,0));
}
for (int i = 0; i < height; i++) {
rectfill(buffer, 0, (i+1)*resolution-border, buffer->w, (i+1)*resolution-1, makecol(0,0,0));
rectfill(buffer, 0, i*resolution, buffer->w, i*resolution+border-1, makecol(0,0,0));
}
for (int i = 0; i< height; i++) {
for (int j = 0; j < width; j++) {
if (world[j][i] == 1) rectfill(buffer, j*resolution+border, i*resolution+border, (j+1)*resolution-border-1, (i+1)*resolution-border-1, makecol(255, 0, 0));
}
}
blit(buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h);
}
void redraw(int x, int y) {
rectfill(buffer, x*resolution, y*resolution, (x+1)*resolution-1, (y+1)*resolution-1, makecol(0,0,0));
rectfill(buffer, x*resolution+border, y*resolution+border, (x+1)*resolution-border-1, (y+1)*resolution-border-1, world[x][y] ? makecol(255,0,0) : makecol(255,255,255));
}
void edit() {
int mdx, mdy, x=0, y=0, drawx, drawy, oldz=0, filter=0, released=1;
bool brush=true, draw=false, end=false;
BITMAP *selection;
selection = create_bitmap(resolution,resolution);
clear_to_color(selection, makecol(20,200,10));
set_window_title("Life - Editing");
while (!key[KEY_ESC]&&!quit&&!end) {
get_mouse_mickeys(&mdx, &mdy);
if ((mdx!=0 || mdy!=0) && (mouse_x > 0 && mouse_y > 0 && mouse_x < width*resolution && mouse_y < height*resolution)) {
redraw(x, y);
x = mouse_x/resolution;
y = mouse_y/resolution;
}
if (mouse_b & 1) {
world[x][y] = brush;
}
if (mouse_b & 2) {
if (released) cout << "keydown";
if (released&&!draw) {
drawx = x;
drawy = y;
draw = !draw;
}
/*
if (drawx!=x || drawy!=y) {
if(!draw){
//set initial coordinates
drawx = x;
drawy = y;
}
else
//draw everything from initial coordinates all the way to current coordinates
for (int i = drawy; drawy<y ? i<=y: i>=y; drawy<y ? i++ : i--) {
for (int j = drawx; drawx<x ? j<=x: j>=x; drawx<x ? j++ : j--) {
world[j][i] = brush;
redraw(j, i);
}
}
//toggle drawing
draw=!draw;
drawx = x;
drawy = y;
*/
released = false;
}
else {
if (!released&&(drawx!=x || drawy!=y)) {
for (int i = drawy; drawy<y ? i<=y: i>=y; drawy<y ? i++ : i--) {
for (int j = drawx; drawx<x ? j<=x: j>=x; drawx<x ? j++ : j--) {
world[j][i] = brush;
redraw(j, i);
}
}
}
released=true;
}
if (mouse_z!=oldz) {
brush = !brush;
oldz = mouse_z;
}
if (keypressed()) {
int key = readkey();
switch ((key >> 8) & 0xFF) {
//navigation
case KEY_DOWN:
case KEY_S:
redraw(x, y);
if (y+1<height) y++;
break;
case KEY_UP:
case KEY_W:
redraw(x, y);
if (y-1>=0) y--;
break;
case KEY_RIGHT:
case KEY_D:
redraw(x, y);
if (x+1<width) x++;
break;
case KEY_LEFT:
case KEY_A:
redraw(x, y);
if (x-1>=0) x--;
break;
//change brush
case KEY_Z:
brush = !brush;
break;
//draw
case KEY_SPACE:
world[x][y] = brush;
break;
//draw large blocks
case KEY_X:
if(!draw){
//set initial coordinates
drawx = x;
drawy = y;
}
else
//draw everything from initial coordinates all the way to current coordinates
for (int i = drawy; drawy<y ? i<=y: i>=y; drawy<y ? i++ : i--) {
for (int j = drawx; drawx<x ? j<=x: j>=x; drawx<x ? j++ : j--) {
world[j][i] = brush;
redraw(j, i);
}
}
//toggle drawing
draw=!draw;
break;
case KEY_E:
if (filter > 20) end = true;
else filter = 0;
break;
}
}
filter++;
clear_to_color(selection, !draw ? makecol(200, 10, 200) : makecol(20, 200, 10));
//change selection colour
rectfill(selection, border, border, resolution-border-1, resolution-border-1, brush ? makecol(255,0,0) : makecol(255,255,255));
//draw initial coordinate location
if (draw) {
draw_sprite(buffer, selection, drawx*resolution, drawy*resolution);
}
//change selection outline color once more
clear_to_color(selection, draw ? makecol(200, 10, 200) : makecol(20, 200, 10));
rectfill(selection, border, border, resolution - border-1, resolution - border-1, brush ? makecol(255,0,0) : makecol(255,255,255));
draw_sprite(buffer, selection, x*resolution, y*resolution);
blit(buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h);
}
}
void close() {
quit = true;
}
|
249c3a6167fcbcd785037c7baf14f51fc031f603
|
842416a74cc58a709f28ecb9c7c99d7cb9abbf35
|
/askforleave.cpp
|
cc1fa43b6f3c794493fd1d108626f5e4d39f08b7
|
[] |
no_license
|
Jasmine-Chan/Office_Park
|
6cf187d6fbc27c908d643548c6bdce0800ea8dfe
|
60c6981bf21557383bbd9e8786f10d5a5a778455
|
refs/heads/master
| 2021-01-12T12:15:36.071728
| 2016-11-09T03:39:33
| 2016-11-09T03:39:33
| 72,393,508
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 23,782
|
cpp
|
askforleave.cpp
|
#include "askforleave.h"
#include "ui_askforleave.h"
askforleave::askforleave(QWidget *parent) :
QWidget(parent),
ui(new Ui::askforleave)
{
ui->setupUi(this);
// QTextCharFormat textCharFormat;
// textCharFormat.setAnchorName("周");
// textCharFormat.setAnchor(true);
// ui->LeaveCalendarWidget->setHeaderTextFormat(textCharFormat);
// ui->LeaveCalendarWidget->setObjectName("周");
LeaveAction = new QAction(tr("新建请/休假"),this);
LeavetreeMenu = new QMenu(ui->Leavetree);
ui->Leavetree->setContextMenuPolicy(Qt::CustomContextMenu);
connect(LeaveAction,SIGNAL(triggered()),this,SLOT(SlotShowPseudomonas()));
DeleteAction= new QAction(tr("删除"),this);
DataMenu = new QMenu(ui->leaveData);
DataMenu->setStyleSheet("border:1px solid rgb(180,202,216);background-color:white;selection-background-color:rgb(180,202,216);");
ui->leaveData->setContextMenuPolicy(Qt::CustomContextMenu);
connect(DeleteAction,SIGNAL(triggered()),this,SLOT(SlotDelete()));
QDateTime dateTime = QDateTime::currentDateTime();
ui->QdateETime->setDate(dateTime.date());
ui->QdateSTime->setDate(dateTime.date().addDays(-15));
ui->QdateETime->setCalendarPopup(true); //设置显示日历选择弹出窗口
ui->QdateSTime->setCalendarPopup(true);
ui->QdateETime->setEnabled(false);
ui->QdateSTime->setEnabled(false);
connect(ui->Leavetree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(CheckSelf(QTreeWidgetItem*,int)));
_InitLeaveData(); //初始化函数:请/休假数据窗口
_UpdateLeaveData(); //更新函数:请假数据
_InitLeaveTree(); //初始化函数:请/休假员工树
}
askforleave::~askforleave()
{
delete ui;
}
/********检测“请/休假员工树”中是否有item被选中********/
void askforleave::CheckSelf(QTreeWidgetItem *hItem, int)
{
qDebug()<<"已选中"<<hItem->text(0)<<endl;
//hItem->text(0):获取选中的item中的内容,返回QString类型
//因为leave是MySQL中的关键字,所以需要加 ` 符号,`:切换至英文状态,按Esc正下方的键
QString SQL;
QSqlQuery check_SQL;
QString StrStime = ui->QdateSTime->dateTime().toString("yyyy-MM-dd"); //获取QDateEdit的开始时间
QString StrEtime = ui->QdateETime->dateTime().toString("yyyy-MM-dd"); //获取QDateEdit的结束时间
QString staff_name = hItem->text(0);
QString SQLDepartment = "SELECT * FROM department WHERE Department_Name = '"+ staff_name +"'";
QSqlQuery QueryDepartment;
QString SQLLeaveStaff = "SELECT * FROM leave_staff WHERE Leave_Staff_Name = '"+ staff_name +"'";
QSqlQuery QueryLeaveStaff;
QueryLeaveStaff.exec(SQLLeaveStaff);
if(QueryLeaveStaff.next())
{
QMessageBox::information(this, "提示", staff_name+"职员已离职");
return;
}
QueryDepartment.exec(SQLDepartment);
if(QueryDepartment.next())
{
if(ui->QchkSTime->isChecked() && ui->QchkETime->isChecked()) //选择了开始时间和结束时间
{
if(StrStime > StrEtime) //判断查询的开始日期是否比结束日期大
{
QMessageBox::critical(this, "错误","查询的开始日期比结束日期大,请重新选择日期");
return;
}
else
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime between '"+StrStime+"' and '"+StrEtime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Department_No = '"+ QueryDepartment.value(1).toString() +"') ORDER BY Leave_Staff_No ASC";
}
}
else if(ui->QchkSTime->isChecked()) //只选择了开始时间
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime >= '"+StrStime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Department_No = '"+ QueryDepartment.value(1).toString() +"') ORDER BY Leave_Staff_No ASC";
}
else if(ui->QchkETime->isChecked()) //只选择了结束时间
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime <= '"+StrEtime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Department_No = '"+ QueryDepartment.value(1).toString() +"') ORDER BY Leave_Staff_No ASC";
}
else //1、既没选开始时间,也没选结束时间 2、程序开始执行时,首先执行这个分支
{
SQL = "SELECT * FROM `leave` WHERE Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Department_No = '"+ QueryDepartment.value(1).toString() +"') ORDER BY Leave_Staff_No ASC";
}
}
else
{
if(ui->QchkSTime->isChecked() && ui->QchkETime->isChecked()) //选择了开始时间和结束时间
{
if(StrStime > StrEtime) //判断查询的开始日期是否比结束日期大
{
QMessageBox::critical(this, "错误","查询的开始日期比结束日期大,请重新选择日期");
return;
}
else
{
if("在职" == staff_name)
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime between '"+StrStime+"' and '"+StrEtime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff) ORDER BY Leave_Staff_No ASC";
}
else if("未分配" == staff_name)
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime between '"+StrStime+"' and '"+StrEtime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Department_No = '') ORDER BY Leave_Staff_No ASC";
}
else
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime between '"+StrStime+"' and '"+StrEtime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Name = '"+ staff_name +"') ORDER BY Leave_Staff_No ASC";
}
}
}
else if(ui->QchkSTime->isChecked()) //只选择了开始时间
{
if("在职" == staff_name)
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime >= '"+StrStime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff) ORDER BY Leave_Staff_No ASC";
}
else if("未分配" == staff_name)
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime >= '"+StrStime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Department_No = '') ORDER BY Leave_Staff_No ASC";
}
else
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime >= '"+StrStime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Name = '"+ staff_name +"') ORDER BY Leave_Staff_No ASC";
}
}
else if(ui->QchkETime->isChecked()) //只选择了结束时间
{
if("在职" == staff_name)
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime <= '"+StrEtime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff) ORDER BY Leave_Staff_No ASC";
}
else if("未分配" == staff_name)
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime <= '"+StrEtime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Department_No = '') ORDER BY Leave_Staff_No ASC";
}
else
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime <= '"+StrEtime+"' and Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Name = '"+ staff_name +"') ORDER BY Leave_Staff_No ASC";
}
}
else //1、既没选开始时间,也没选结束时间 2、程序开始执行时,首先执行这个分支
{
if("在职" == staff_name)
{
SQL = "SELECT * FROM `leave` WHERE Leave_Staff_No in (SELECT Staff_No FROM staff) ORDER BY Leave_Staff_No ASC";
}
else if("未分配" == staff_name)
{
SQL = "SELECT * FROM `leave` WHERE Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Department_No = '') ORDER BY Leave_Staff_No ASC";
}
else
{
SQL = "SELECT * FROM `leave` WHERE Leave_Staff_No in (SELECT Staff_No FROM staff WHERE Staff_Name = '"+ staff_name +"') ORDER BY Leave_Staff_No ASC";
}
}
}
qDebug()<<SQL<<SQLDepartment;
//开始执行SQL语句
if(!check_SQL.first())
{
ui->leaveData->clearContents(); //清空TableWidget中所有item数据
}
if(check_SQL.exec(SQL))
{
int ti = 0;
while(check_SQL.next())
{
ui->leaveData->setRowCount(ti+1);
QTableWidgetItem *tableWidget1 = new QTableWidgetItem(QString(check_SQL.value(1).toDate().toString("yyyy-MM-dd")));
tableWidget1->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,0,tableWidget1);
QString StaffSQL = "SELECT a.Staff_Name FROM staff a WHERE a.Staff_No = '"+check_SQL.value(2).toString()+"'";
QSqlQuery Staffquery;
if(Staffquery.exec(StaffSQL))
{
if(Staffquery.next())
{
QTableWidgetItem *tableWidget2 = new QTableWidgetItem(QString(Staffquery.value(0).toString()));
tableWidget2->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,1,tableWidget2);
}
}
QTableWidgetItem *tableWidget3 = new QTableWidgetItem(QString(check_SQL.value(2).toByteArray().data()));
tableWidget3->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,2,tableWidget3);
QTableWidgetItem *tableWidget4 = new QTableWidgetItem(QString(check_SQL.value(3).toDateTime().toString("yyyy-MM-dd hh:mm")));
tableWidget4->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,3,tableWidget4);
QTableWidgetItem *tableWidget5 = new QTableWidgetItem(QString(check_SQL.value(4).toDateTime().toString("yyyy-MM-dd hh:mm")));
tableWidget5->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,4,tableWidget5);
QString str;
int AllType = check_SQL.value(5).toInt();
while(AllType>0)
{
int num = AllType%10;
AllType = AllType/10;
if(num==1)
str=str+"/事假";
if(num==2)
str=str+"/病假";
if(num==3)
str=str+"/年假";
if(num==4)
str=str+"/婚假";
if(num==5)
str=str+"/产假";
if(num==6)
str=str+"/看护假";
}
QTableWidgetItem *tableWidget6 = new QTableWidgetItem(str);
tableWidget6->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,5,tableWidget6);
QTableWidgetItem *tableWidget7 = new QTableWidgetItem(QString(check_SQL.value(6).toByteArray().data()));
tableWidget7->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,6,tableWidget7);
ti++;
}
}
}
/*****初始化函数:请/休假数据窗口*********/
void askforleave::_InitLeaveData()
{
ui->leaveData->setColumnCount(8);
ui->leaveData->setShowGrid(true);
QStringList headers;
headers<<"日期"<<"职员"<<"工号"<<"起始时间"<<"截止时间"<<"请假类型"<<"工时"<<"请假事由";
ui->leaveData->verticalHeader()->hide();
ui->leaveData->horizontalHeader()->setClickable(false);
ui->leaveData->setHorizontalHeaderLabels(headers);
ui->leaveData->horizontalHeader()->setHighlightSections(false);
ui->leaveData->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->leaveData->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->leaveData->setColumnWidth(0,100);
ui->leaveData->setColumnWidth(1,80);
ui->leaveData->setColumnWidth(2,80);
ui->leaveData->setColumnWidth(3,120);
ui->leaveData->setColumnWidth(4,120);
ui->leaveData->setColumnWidth(5,100);
ui->leaveData->setColumnWidth(6,90);
ui->leaveData->setColumnWidth(7,100);
}
/******初始化函数:请/休假员工树*********/
void askforleave::_InitLeaveTree()
{
m_List.clear(); //保存查询配对的数据
ui->Leavetree->clear();
ui->Leavetree->setHeaderHidden(true);
QString SQL = "SELECT * from department ORDER BY Department_No DESC";
QSqlQuery query;
if(query.exec(SQL))
{
int i = 1;
while(query.next())
{
SList data; //“员工ID,编号,姓名信息”结构体
data.Id = query.value(0).toInt();
data.strNo = query.value(1).toString();
data.strName = query.value(2).toString();
m_List.append(data);
i++; //计数作用
}
}
QTreeWidgetItem* B1 = new QTreeWidgetItem(QStringList()<<"在职");
ui->Leavetree->addTopLevelItem(B1);
QTreeWidgetItem* C = new QTreeWidgetItem(QStringList()<<"未分配");
B1->addChild(C);
QString unabsorbedSQL;
QSqlQuery unabsorbedquery;
unabsorbedSQL = "SELECT a.Staff_Name,a.Staff_No FROM `staff` a WHERE a.Staff_No NOT IN (SELECT b.Staff_No FROM staff b,department c WHERE b.Staff_Department_No = c.Department_No) ORDER BY a.Staff_No ASC";
if(unabsorbedquery.exec(unabsorbedSQL))
{
while(unabsorbedquery.next())
{
QTreeWidgetItem *CB = new QTreeWidgetItem(QStringList()<<unabsorbedquery.value(0).toString());
C->addChild(CB);
}
}
QTreeWidgetItem* B[m_List.size()];
for(int i = 0;i < m_List.size();i++)
{
B[i] = new QTreeWidgetItem(QStringList()<<m_List.at(i).strName);
B1->addChild(B[i]); //在“在职”目录下添加所有部门的人员姓名
QString StaffSQL;
QSqlQuery Staffquery;
StaffSQL = "SELECT a.Staff_Name FROM `staff` a where a.Staff_Department_No = '"+m_List.at(i).strNo+"' ORDER BY a.Staff_No ASC";
if(Staffquery.exec(StaffSQL))
{
while(Staffquery.next())
{
QTreeWidgetItem *BiB = new QTreeWidgetItem(QStringList()<<Staffquery.value(0).toString());
B[i]->addChild(BiB); //在各部门的对应目录下添加相应的人员
}
}
}
QTreeWidgetItem* B2 = new QTreeWidgetItem(QStringList()<<"离职");
ui->Leavetree->addTopLevelItem(B2);
QString LeaveSQL;
LeaveSQL = "SELECT a.Leave_Staff_Name FROM `leave_staff` a ORDER BY a.Leave_Staff_Id ASC";
QSqlQuery Leavequery;
if(Leavequery.exec(LeaveSQL))
{
while(Leavequery.next())
{
QTreeWidgetItem *B2B = new QTreeWidgetItem(QStringList()<<Leavequery.value(0).toString());
B2->addChild(B2B); //添加离职人员姓名
}
}
}
/*****更新函数:请假数据*********/
void askforleave::_UpdateLeaveData()
{
QString SQL;
QString StrStime = ui->QdateSTime->dateTime().toString("yyyy-MM-dd"); //获取QDateEdit的开始时间
QString StrEtime = ui->QdateETime->dateTime().toString("yyyy-MM-dd"); //获取QDateEdit的结束时间
if(ui->QchkSTime->isChecked() && ui->QchkETime->isChecked()) //选择了开始时间和结束时间
{
if(StrStime > StrEtime) //判断查询的开始日期是否比结束日期大
{
QMessageBox::critical(this, "错误","查询的开始日期比结束日期大,请重新选择日期");
return;
}
else
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime between '"+StrStime+"' and '"+StrEtime+"' ORDER BY Leave_Staff_No ASC";
}
}
else if(ui->QchkSTime->isChecked()) //只选择了开始时间
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime >= '"+StrStime+"' ORDER BY Leave_Staff_No ASC";
}
else if(ui->QchkETime->isChecked()) //只选择了结束时间
{
SQL = "SELECT * FROM `leave` WHERE Leave_SDateTime <= '"+StrEtime+"' ORDER BY Leave_Staff_No ASC";
}
else //1、既没选开始时间,也没选结束时间 2、程序开始执行时,首先执行这个分支
{
SQL = "SELECT * FROM `leave` ORDER BY Leave_Staff_No ASC";
}
QSqlQuery query;
if(!query.first())
ui->leaveData->clearContents(); //清空TableWidget中所有item数据
if(query.exec(SQL))
{
int ti=0;
while(query.next())
{
ui->leaveData->setRowCount(ti+1);
QTableWidgetItem *tableWidget1 = new QTableWidgetItem(QString(query.value(1).toDate().toString("yyyy-MM-dd")));
tableWidget1->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,0,tableWidget1);
QString StaffSQL = "SELECT a.Staff_Name FROM staff a WHERE a.Staff_No = '"+query.value(2).toString()+"'";
QSqlQuery Staffquery;
if(Staffquery.exec(StaffSQL))
{
if(Staffquery.next())
{
QTableWidgetItem *tableWidget2 = new QTableWidgetItem(QString(Staffquery.value(0).toString()));
tableWidget2->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,1,tableWidget2);
}
}
QTableWidgetItem *tableWidget3 = new QTableWidgetItem(QString(query.value(2).toByteArray().data()));
tableWidget3->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,2,tableWidget3);
QTableWidgetItem *tableWidget4 = new QTableWidgetItem(QString(query.value(3).toDateTime().toString("yyyy-MM-dd hh:mm")));
tableWidget4->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,3,tableWidget4);
QTableWidgetItem *tableWidget5 = new QTableWidgetItem(QString(query.value(4).toDateTime().toString("yyyy-MM-dd hh:mm")));
tableWidget5->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,4,tableWidget5);
QString str;
int AllType = query.value(5).toInt();
while(AllType>0)
{
int num = AllType%10;
AllType = AllType/10;
if(num==1)
str=str+"/事假";
if(num==2)
str=str+"/病假";
if(num==3)
str=str+"/年假";
if(num==4)
str=str+"/婚假";
if(num==5)
str=str+"/产假";
if(num==6)
str=str+"/看护假";
}
QTableWidgetItem *tableWidget6 = new QTableWidgetItem(str);
tableWidget6->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,5,tableWidget6);
QTableWidgetItem *tableWidget7 = new QTableWidgetItem(QString(query.value(6).toByteArray().data()));
tableWidget7->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,6,tableWidget7);
// ti++;
QTableWidgetItem *tableWidget8 = new QTableWidgetItem(QString(query.value(7).toByteArray().data()));
tableWidget8->setTextAlignment(Qt::AlignCenter);
ui->leaveData->setItem(ti,7,tableWidget8);
ti++;
}
}
}
/*****信号槽函数:删除请假条*********/
void askforleave::SlotDelete()
{
int nRow = ui->leaveData->currentRow();
if(nRow >= 0){
QString str1 = ui->leaveData->item(nRow,2)->text();
QString leavedate = ui->leaveData->item(nRow,0)->text();
QMessageBox::StandardButton standard = QMessageBox::question(this,tr("提示"),tr("确认删除此记录?"),QMessageBox::Yes|QMessageBox::No);
if(standard == QMessageBox::Yes)
{
QString SQL = "delete from `leave` where Leave_Staff_No = '"+str1+"' AND Leave_Date = '"+leavedate+"'";
QSqlQuery query;
if(query.exec(SQL))
{
QMessageBox::information(this,"提示","删除成功!",QMessageBox::Yes);
if(ui->leaveData->rowCount()==1)
ui->leaveData->setRowCount(0);
_UpdateLeaveData();
}
else
QMessageBox::information(this,"提示","删除失败!",QMessageBox::Yes);
}
} else{
QMessageBox::information(this,tr("提示"),tr("请选择要删除的记录"));
}
}
/*****信号槽函数:添加请假条*********/
void askforleave::SlotShowPseudomonas()
{
SStaff staff;
QString No, post;
int department;
QString Name = ui->Leavetree->currentItem()->text(0);
QString NameSQL = "SELECT * FROM staff WHERE Staff_Name = '"+ Name +"'";
QSqlQuery NameQuery;
if(NameQuery.exec(NameSQL))
{
if(NameQuery.next())
{
No = NameQuery.value(1).toString();
department = NameQuery.value(5).toInt();
post = NameQuery.value(6).toString();
}
else
{
QMessageBox::information(this, "提示", "请选择员工!");
return;
}
}
switch(department)
{
case 1:
staff.strDepartment = "技术部";
break;
case 2:
staff.strDepartment = "财务部";
break;
case 3:
staff.strDepartment = "董事会";
break;
case 4:
staff.strDepartment = "商务部";
break;
case 5:
staff.strDepartment = "硬件部";
break;
case 6:
staff.strDepartment = "软件部";
break;
case 7:
staff.strDepartment = "平台部";
break;
default:
staff.strDepartment = "未分组";
}
staff.strName = Name;
staff.strNo = No;
staff.strPost = post;
m_Pseudomonas = new Pseudomonas();
m_Pseudomonas->setAttribute(Qt::WA_DeleteOnClose);
connect(m_Pseudomonas,SIGNAL(SigAddSuccess()),this,SLOT(SlotAddSuccess()));
connect(this,SIGNAL(SigLeaveDate(QDate,SStaff)),m_Pseudomonas,SLOT(SlotLeaveDate(QDate,SStaff)));
emit SigLeaveDate(ui->LeaveCalendarWidget->selectedDate(), staff);
m_Pseudomonas->show();
}
/*****信号槽函数:添加成功*********/
void askforleave::SlotAddSuccess()
{
_UpdateLeaveData();
}
void askforleave::on_leaveData_customContextMenuRequested(const QPoint &pos)
{
DataMenu->addAction(DeleteAction);
DataMenu->exec(QCursor::pos());
}
void askforleave::on_Leavetree_customContextMenuRequested(const QPoint &pos)
{
LeavetreeMenu->addAction(LeaveAction);
LeavetreeMenu->exec(QCursor::pos());
}
/*****控件焦点重置函数函数:鼠标点击离开此页面时*********/
void askforleave::SlotFocusOut()
{
ui->leaveData->setCurrentItem(ui->leaveData->item(-1,-1));
ui->LeaveCalendarWidget->setSelectedDate(QDate::currentDate());
}
void askforleave::on_QchkSTime_clicked() //查询时段的开始时间
{
if(!ui->QchkSTime->checkState())
{
ui->QdateSTime->setEnabled(false);
}
else
{
ui->QdateSTime->setEnabled(true);
}
}
void askforleave::on_QchkETime_clicked() //查询时段的结束时间
{
if(!ui->QchkETime->checkState())
{
ui->QdateETime->setEnabled(false);
}
else
{
ui->QdateETime->setEnabled(true);
}
}
|
2eae106d3c415fab574a7ab3965202b0865e1997
|
694174d01d8b8c61f056b2299f88564e081a4844
|
/2017校招编程/网易/暗黑的字符串.cpp
|
25049f82c2d4b03f40b97c73a8f8b6c0a24b0287
|
[] |
no_license
|
BaldrLector/Personal-Practice-for-job
|
c32122c3d4e76acc14d9911e5a5d0787574ac348
|
7e377d823f65ed151cbe4085727f2a94862eacc8
|
refs/heads/master
| 2021-09-10T21:25:49.850921
| 2018-04-02T05:27:24
| 2018-04-02T05:27:24
| 124,490,630
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,089
|
cpp
|
暗黑的字符串.cpp
|
/*
题目描述
一个只包含'A'、'B'和'C'的字符串,如果存在某一段长度为3的连续子串中恰好'A'、'B'和'C'各有一个,那么这个字符串就是纯净的,否则这个字符串就是暗黑的。例如:
BAACAACCBAAA 连续子串"CBA"中包含了'A','B','C'各一个,所以是纯净的字符串
AABBCCAABB 不存在一个长度为3的连续子串包含'A','B','C',所以是暗黑的字符串
你的任务就是计算出长度为n的字符串(只包含'A'、'B'和'C'),有多少个是暗黑的字符串。
输入描述:
输入一个整数n,表示字符串长度(1 ≤ n ≤ 30)
输出描述:
输出一个整数表示有多少个暗黑字符串
示例1
输入
2 3
输出
9 21*/
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<limits.h>
#include <math.h>
using namespace std;
int main(void){
int n;
cin >> n;
vector <long int> dp(n);
dp[0]=3;
dp[1]=9;
for(int i=2;i<n;i++){
dp[i]=2*dp[i-1]+dp[i-2];
}
cout << dp[n-1] << endl;
}
|
a9d78971d76635d921b006f91ae3ad1428fc43e9
|
74019a333068870756afc7ef6d7d55e6f0447fe1
|
/sawOpenIGTLink-dev/code/mtsOpenIGTLink.cpp
|
255411c77069b05018c74c15144cd7acde98f416
|
[] |
no_license
|
lixiao89/usoverlay_final
|
0d48ee262546aa704680420e973fd759b8d3baca
|
9b88d154d305d2e1404a2a17b83eb3f3810775b7
|
refs/heads/master
| 2016-09-06T08:18:19.214470
| 2015-07-11T21:29:09
| 2015-07-11T21:29:09
| 38,940,927
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,121
|
cpp
|
mtsOpenIGTLink.cpp
|
/* *- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
/*
Author(s): Ali Uneri
Created on: 2009-08-10
(C) Copyright 2009-2012 Johns Hopkins University (JHU), All Rights Reserved.
--- begin cisst license - do not edit ---
This software is provided "as is" under an open source license, with
no warranty. The complete license can be found in license.txt and
http://www.cisst.org/cisst/license.txt.
--- end cisst license ---
*/
#include <cisstOSAbstraction/osaSleep.h>
#include <cisstMultiTask/mtsInterfaceProvided.h>
#include <cisstMultiTask/mtsInterfaceRequired.h>
#include <sawOpenIGTLink-dev/mtsOpenIGTLink.h>
CMN_IMPLEMENT_SERVICES_DERIVED_ONEARG(mtsOpenIGTLink, mtsTaskPeriodic, mtsTaskPeriodicConstructorArg);
void mtsOpenIGTLink::Cleanup(void)
{
CMN_LOG_CLASS_INIT_VERBOSE << "~mtsOpenIGTLink: closing hanging connections" << std::endl;
if (serverSocket) serverSocket->CloseSocket();
}
void mtsOpenIGTLink::Configure(const std::string & hostAndPort)
{
// // parse port and [if any] host information
std::string host;
unsigned int port;
size_t colonPosition = hostAndPort.find(':');
if (colonPosition == std::string::npos) {
host = "";
port = atoi(hostAndPort.c_str());
} else {
host = hostAndPort.substr(0, colonPosition);
port = atoi(hostAndPort.substr(colonPosition + 1).c_str());
}
// if a target host is not provided, configure as server, otherwise client
if (host.empty()) {
//CMN_LOG_CLASS_INIT_VERBOSE << "mtsOpenIGTLink: setting up as server" << std::endl;
std::cout << "mtsOpenIGTLink: setting up as server in port: " << port << std::endl;
ConnectionType = SERVER;
serverSocket = igtl::ServerSocket::New();
ServerPort = port;
} else {
CMN_LOG_CLASS_INIT_VERBOSE << "mtsOpenIGTLink: setting up as client" << std::endl;
// ConnectionType = CLIENT;
// Host = host;
// Port = port;
// SocketServer = 0;
// Socket = new osaSocket();
// IGTLData = new sawOpenIGTLinkData;
}
IsConnected = false;
/* The required interface that:
1. grabs data from a provided interface (sawNDITracker for example)
2. publishes data in form of openigtlink */
mtsInterfaceRequired * requiresPositionCartesion = AddInterfaceRequired("RobotBase");
if (requiresPositionCartesion){
// get tool cartesian pose from mtsNDITracker
requiresPositionCartesion->AddFunction("GetPositionCartesian", NDI.GetPositionCartesian);
}
}
void mtsOpenIGTLink::Startup(void)
{
if (ConnectionType == SERVER) {
int r = serverSocket->CreateServer(ServerPort);
if (r<0){
CMN_LOG_CLASS_INIT_VERBOSE << "Cannot create a server socket" << std::endl;
exit(0);
}
}
}
void mtsOpenIGTLink::Run(void)
{
ProcessQueuedCommands();
if (!IsConnected) {
if (ConnectionType == SERVER) {
do {
socket = serverSocket->WaitForConnection(1000);
} while (!socket.IsNotNull());
IsConnected = true;
}// else if (ConnectionType == CLIENT) {
// IsConnected = Socket->Connect(Host.c_str(), Port);
// }
}
NDI.GetPositionCartesian(NDI.PositionCartesian);
std::cout<<NDI.PositionCartesian.Position().Rotation().Element(0,0)<<std::endl;
if (IsConnected) {
igtl::TransformMessage::Pointer transMsg;
transMsg = igtl::TransformMessage::New();
transMsg->SetDeviceName("OpenIGTLink_USProbe");
igtl::Matrix4x4 dataMatrix;
prmPositionCartesianToOIGTL(NDI.PositionCartesian, dataMatrix);
transMsg->SetMatrix(dataMatrix);
transMsg->Pack();
socket->Send(transMsg->GetPackPointer(), transMsg->GetPackSize());
igtl::PrintMatrix(dataMatrix);
}
}
void mtsOpenIGTLink::prmPositionCartesianToOIGTL(const prmPositionCartesianGet& frameCISST,
igtl::Matrix4x4& frameIGTL){
frameIGTL[0][0] = frameCISST.Position().Rotation().Element(0,0);
frameIGTL[1][0] = frameCISST.Position().Rotation().Element(1,0);
frameIGTL[2][0] = frameCISST.Position().Rotation().Element(2,0);
frameIGTL[3][0] = 0;
frameIGTL[0][1] = frameCISST.Position().Rotation().Element(0,1);
frameIGTL[1][1] = frameCISST.Position().Rotation().Element(1,1);
frameIGTL[2][1] = frameCISST.Position().Rotation().Element(2,1);
frameIGTL[3][1] = 0;
frameIGTL[0][2] = frameCISST.Position().Rotation().Element(0,2);
frameIGTL[1][2] = frameCISST.Position().Rotation().Element(1,2);
frameIGTL[2][2] = frameCISST.Position().Rotation().Element(2,2);
frameIGTL[3][2] = 0;
frameIGTL[0][3] = frameCISST.Position().Translation().Element(0) - 250;
frameIGTL[1][3] = frameCISST.Position().Translation().Element(1) - 42.3;
frameIGTL[2][3] = frameCISST.Position().Translation().Element(2) + 1592;
frameIGTL[3][3] = 1;
}
|
ca3ee2c1d9d607560f30077b0a34948a389b6034
|
2f2c142d7aa568411a2e9a6c70f882910501e648
|
/WavFile.cpp
|
817d341960820b3180c834faa80a90e31276fb4d
|
[] |
no_license
|
pipmix/AudioEngine
|
df26062497f988e427938c63d466d2772be4afb1
|
222f63fb850270a51e7c433c261437baf5f9141d
|
refs/heads/master
| 2021-01-12T11:55:31.387321
| 2016-09-28T06:32:59
| 2016-09-28T06:32:59
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,097
|
cpp
|
WavFile.cpp
|
#include "stdafx.h"
#include "WavFile.h"
WavFile::WavFile(){
m_waveFormat = { 0 };
m_buffer = { 0 };
m_wavData = nullptr;
m_voiceDetails = { 0 };
m_voiceState = { 0 };
m_wfx = { 0 };
}
WavFile::~WavFile() {
delete[] m_wavData;
m_wavData = nullptr;
}
void WavFile::Create()
{
}
void WavFile::Load(std::wstring fileName) {
HANDLE hFile = CreateFile(fileName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
DWORD dwChunkSize;
DWORD dwChunkPosition;
FindChunk(hFile, fourccRIFF, dwChunkSize, dwChunkPosition);
DWORD filetype;
ReadChunkData(hFile, &filetype, sizeof(DWORD), dwChunkPosition);
FindChunk(hFile, fourccFMT, dwChunkSize, dwChunkPosition);
ReadChunkData(hFile, &m_waveFormat, dwChunkSize, dwChunkPosition);
FindChunk(hFile, fourccDATA, dwChunkSize, dwChunkPosition);
m_wavData = new BYTE[dwChunkSize];
//BYTE * pDataBuffer = new BYTE[dwChunkSize];
ReadChunkData(hFile, m_wavData, dwChunkSize, dwChunkPosition);
m_buffer.AudioBytes = dwChunkSize;
m_buffer.pAudioData = m_wavData;
m_buffer.Flags = XAUDIO2_END_OF_STREAM;
}
|
7406bce6ab7f9844da3dc05d504da142038b016b
|
3fd26a7cd44d214f2aefe2a07063a2665ace93b4
|
/digit_dp.cpp
|
4d0e22344eabfe7e4421139de4139abb573dec6e
|
[] |
no_license
|
octopus0110/MyLibrary
|
de0e0e34d91ed482ccf4d8c1d5324e4a91aff3c3
|
c0bf91a28958f7167676e4aa41196b4f32576d09
|
refs/heads/master
| 2023-03-20T12:15:02.052894
| 2021-03-11T17:46:03
| 2021-03-11T17:46:03
| 277,846,249
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,231
|
cpp
|
digit_dp.cpp
|
#include <iostream>
#include <vector>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
using LL = long long;
using VLL = V<LL>;
using VVLL = V<VLL>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define SIZE(a, type) ((type)(a).size())
const LL MOD = 1e9 + 7;
// N以下の整数を数える(0~NまでのN+1通り)
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
string N;
cin >> N;
int digit = SIZE(N, int); // Nの桁数
VVLL dp(digit, VLL(2, 0));
dp[0][1] = N[0] - '0'; // 0~N[0]-1 までのN[0]個は未満フラグが1
dp[0][0] = 1; // 0桁目がN[0]なら未満フラグは0
REP(int, i, digit-1){
const int D = N[i+1] - '0'; // i+1桁目の数字
REP(int, j, 2){
REP(int, d, (j ? 10 : D+1)){ // 未満フラグが立っているときは0~9まですべてが可能で、そうでないときは0~Dまでのみ可能
dp[i+1][j || d < D] += dp[i][j]; // 遷移先の未満フラグは遷移前と同じで、d < Dのときは未満フラグを立てる
}
}
}
cout << dp[digit-1][0] + dp[digit-1][1] << endl;
return 0;
}
/*
string N として、 N[i] はNのi桁目の数字を表す文字
dp[i][j] : 上位からi桁目までの数字の総数
jは構成される数字がN未満であるかどうかを示すフラグ(未満フラグ)
・ j = 0 のとき構成される数字がi桁目まで完全に一致していることを示す
・ j = 1 のとき構成される数字がN未満となることを示す(0≦k≦iについてNのk桁目より小さくなるものが存在する)
(遷移)
int D = N[i+1]-'0';
dp[i][j]が確定しているものとして状態の遷移を考える
・ dp[i][1] のとき、すでにN未満の数字であることが確定しているので、i+1桁目の数字として考えられるのは、0~9までの数字すべてである
・ dp[i][0] のとき、i桁目の数字まですべて一致しているので、i+1桁目の数字として考えられるのは、0~Dまでの数字のみである(D以上の数字だとNを超えてしまう)
これらをまとめて考えると、その遷移の仕方は、d = (i+1桁目として選ぶ数字) として
・ dp[i][1] -> dp[i+1][1]
・ dp[i][0] -> dp[i+1][0] (if (d==D)) or dp[i+1][1] (if (d < D))
となる
これらを場合分けで実装してもいいが、よく見ると遷移前の未満フラグが立っているときはときは遷移先のフラグも立っていて、立っていないときは d < D のときに遷移先のフラグが立つことから実装を工夫している
(初期条件)
dp[0][0] = 1 (0桁目の数字まで一致している)
dp[0][1] = N[0]-'0' (Nの0桁目より小さい数字の数)
(最終状態)
int digit = SIZE(N);
dp[digit-1][0] : digit-1 桁目まででN未満の数字の個数(0以上N未満の整数の個数)
dp[digit-1][1] : digit-1 桁目まですべての数字がNと一致している数字の個数(Nの1つのみ)
(参照)
https://torus711.hatenablog.com/entry/20150423/1429794075
https://qiita.com/murai_mart/items/1a7a4d10abc0c3b5b53f
*/
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// N以下の整数でいずれかの桁に3を含むものの総数を数える
int Main()
{
cin.tie(0);
ios::sync_with_stdio(false);
string N;
cin >> N;
int digit = SIZE(N, int);
VVV<LL> dp(digit, VVLL(2, VLL(2, 0)));
REP(int, d, N[0]-'0'+1) dp[0][d < N[0]-'0'][d == 3]++;
REP(int, i, digit-1)
{
int D = N[i+1] - '0';
REP(int, j, 2) REP(int, k, 2) REP(int, d, j ? 10 : D+1) dp[i+1][j || d < D][k || d == 3] += dp[i][j][k];
}
cout << dp[digit-1][0][1] + dp[digit-1][1][1] << endl;
return 0;
}
/*
dp[i][j][k] : 上位からi桁目までの数字で3を含むものの総数
jは未満フラグ
kは構成される数字に3が含まれているかどうかを示すフラグ
・ k = 0 のとき構成される数字に3が含まれないことを示す
・ k = 1 のとき構成される数字に3が含まれることを示す(0≦k≦iについてNのk桁目より小さくなるものが存在する)
(遷移)
int D = N[i+1] - '0';
・ dp[i][0][0] -> dp[i+1][0][0] (d == D != 3)
dp[i+1][0][1] (d == D == 3)
dp[i+1][1][0] (d != 3)
dp[i+1][1][1] (d == 3)
・ dp[i][0][1] -> dp[i+1][0][1] (d == D)
dp[i+1][1][1] (d < D)
・ dp[i][1][0] -> dp[i+1][1][0] (d != 3)
dp[i+1][1][1] (d == 3)
・ dp[i][1][1] -> dp[i+1][1][1] (for all d)
*/
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// N以下の正整数であって、十進法表記したときの各桁の数の和がDの倍数であるものの個数を mod 1e9+7 で求める
LL f(string X, int s)
{
int digit = SIZE(X, int);
VVV<LL> dp(digit+1, VVLL(2, VLL(s, 0)));
dp[0][0][0] = 1;
REP(int, i, digit)
{
int D = X[i] - '0';
REP(int, j, 2) REP(int, k, s) REP(int, d, j ? 10 : D+1)
{
dp[i+1][j || d < D][(k + d) % s] += dp[i][j][k];
dp[i+1][j || d < D][(k + d) % s] %= MOD;
}
}
return (dp[digit][0][0] + dp[digit][1][0] - 1) % MOD;
}
/*
dp[i][j][k] : 上位からi桁目までの数字で各桁の和の mod s がkになるものの総数
jは未満フラグ
これまでと違って0桁はどの数字も選んでいない状態を示す(これまでと同様のやり方で実装してもいいが0桁から始めることで、dp[0][0][0] = 1 とし、以降の桁についてはdpテーブルを回すだけでよくなる)
(遷移)
int D = N[i+1] - '0';
・ dp[i][0][k] -> dp[i+1][0][(k+d)%s] (d == D)
dp[i+1][1][(k+d)%s] (d < D)
・ dp[i][1][k] -> dp[i+1][1][(k+d)%s] (for all d)
*/
|
6266524d87deb5d090510284b6a6282ac54dee4c
|
575099783e3ac92a4bbf5a755e767f7041f12c5f
|
/header/parser/HighOp.hpp
|
a3d8a14cd6198161b42a7b8964348b4b5826c971
|
[] |
no_license
|
Kevin-Costa/cpp_bomberman
|
a70f22ccb270d6463e008e2e1eddbf3e455632cc
|
eb2c377a2a7da752333d998af6d561259246bf3b
|
refs/heads/master
| 2021-01-10T16:48:58.732111
| 2016-02-29T09:06:22
| 2016-02-29T09:06:22
| 52,778,074
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 896
|
hpp
|
HighOp.hpp
|
//
// HighOp.hpp for bomberman in /home/rousse_3/rendu/cpp_bomberman
//
// Made by rousse_3
// Login <rousse_3@epitech.net>
//
// Started on Wed May 27 03:27:41 2015 rousse_3
// Last update Sat Jun 6 17:06:50 2015 rousse_3
//
#ifndef HIGHOP_HPP_
# define HIGHOP_HPP_
# include "Parser.hpp"
class HighOp : public IParserItem
{
public:
static int isHighOp(const std::string &str, int index);
HighOp(const std::string &str, int &index, VarTable &table);
~HighOp(void) throw();
type getType(const VarTable &table) const;
bool checkType(const VarTable &table) const;
double getDoubleValue(VarTable &table) const;
std::string getStringValue(VarTable &table) const;
bool getBoolValue(VarTable &table) const;
private:
enum operate
{
MUL,
DIV,
NONE
};
IParserItem *_right;
operate _op;
IParserItem *_left;
};
#endif /* !HIGHOP_HPP_ */
|
b1803a1f844f9f6d7f9fcf89befe29abb538787d
|
87c12524efba5a739caa1f8b31b503f4bf1e2979
|
/dquery.cpp
|
beda9ecc4415f1934320a97623dc291e81e5bf71
|
[] |
no_license
|
Ironman0505/Spoj-1
|
fe234ab5f70f239090caece9ca888df3de61c22a
|
d4e6db21ee1ce6cc5bc65a61ae1aeb0d30d0278d
|
refs/heads/master
| 2022-01-18T22:17:03.575047
| 2014-09-01T18:42:56
| 2014-09-01T18:42:56
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,165
|
cpp
|
dquery.cpp
|
//Author : Piyush Agarwal
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define mod 1000000007
#define inp1(a) scanf("%lld",&a);
#define outl(a) printf("%lld\n",a);
#define out(a) printf("%lld ",a);
#define line printf("\n");
#define FOR(i,b,e) for(i=b;i<=e;i++)
#define mp make_pair
#define pb push_back
#define inp2(a,b) scanf("%lld %lld",&a,&b)
#define getcx getchar_unlocked
ll size=1000000;
inline void finp(ll *a )
{
ll n=0; int ch = getcx(); int sign = 1;
while(ch < '0' || ch > '9')
{
if(ch == '-') sign=-1; ch = getcx();
}
while(ch >= '0' && ch <= '9')
{
n = (n << 3) + (n << 1) + ch - '0', ch = getcx();
}
*a = n * sign;
}
ll power(ll b,ll e)
{
ll x=1;
while(e>0)
{
if(e&1)
x=x*b;
b=b*b;
e=e/2;
}
return x;
}
ll gcd(ll a,ll b)
{
if(b==0)
return a;
return gcd(b,a%b);
}
struct node
{
ll count;
}m[1000005];
ll i,j,k,l,n,d[1000000];
vector< pair<ll,ll> > a;
vector< pair< pair<ll,ll>,pair<ll,ll> > > q;
bool cmp(pair< pair<ll,ll> ,pair<ll,ll> > a,pair< pair<ll,ll>,pair<ll,ll> > b)
{
if(a.first.second!=b.first.second)
return a.first.second<b.first.second;
return a.first.first<b.first.first;
}
ll ans[1000000],mark[1000005];
void update(ll node,ll b,ll e,ll pos,ll opt)
{
// if(opt==1&&pos==1)
// printf("co or %lld %lld\n",b,e);
if(b==e&&b==pos)
{
// if(b==1)
// printf("oh yes opt %lld\n",opt);
if(opt==0)
m[node].count=1;
else
{
// printf("count set to zero %lld\n",node);
m[node].count=0;
}
return;
}
if(b==e&&b!=pos) return;
if(pos<b||pos>e) return;
update(2*node,b,(e+b)/2,pos,opt);
update(2*node+1,(e+b)/2+1,e,pos,opt);
m[node].count=m[2*node].count+m[2*node+1].count;
}
ll query(ll node,ll b,ll e,ll i,ll j)
{
if(b>=i&&e<=j)
return m[node].count;
if(b>j||i>e)
return 0;
return query(2*node,b,(e+b)/2,i,j)+query(2*node+1,(e+b)/2+1,e,i,j);
}
int main()
{
finp(&n);
//printf("%d\n",n);
for(i=0;i<=1000000;i++)
{
m[i].count=0;
mark[i]=-1;
}
for(i=0;i<n;i++)
{
finp(&j);
// printf("%d\n",j);
a.pb(mp(j,i));
}
finp(&l);
//printf("%d\n",l);
for(i=0;i<l;i++)
{
finp(&j);
// printf("%d\n",j);
finp(&k);
//printf("%d\n",k);
q.pb(mp(mp(j-1,k-1),mp(i,0)));
}
sort(q.begin(),q.end(),cmp);
//for(i=0;i<l;i++)
// printf("%lld %lld\n",q[i].first.first,q[i].first.second);
ll c=0;
i=0;j=0;
// printf("done\n");
while(c<n+l)
{
if(a[i].second<=q[j].first.second&&i<n)
{
// printf("%lld %lld\n",a[i].first,a[i].second);
if(mark[a[i].first]==-1)
{
// printf("new\n");
update(1,0,n,a[i].second,0);
mark[a[i].first]=a[i].second;
}
else
{
update(1,0,n,mark[a[i].first],1);
/// printf("removed %lld\n",mark[a[i].first]);
/* for(int y=1;y<=9;y++)
printf("%lld ",m[y].count);
printf("\nupdatin\n");
*/ update(1,0,n,a[i].second,0);
mark[a[i].first]=a[i].second;
}
// printf("%lld %lld\n",a[i].first,a[i].second);
i++;
}
else
{
//printf("query %lld %lld\n",q[j].first.first,q[j].first.second);
ans[q[j].second.first]=query(1,0,n,q[j].first.first,q[j].first.second);
j++;
}
c++;
// for(int y=1;y<=9;y++)
// printf("%lld ",m[y].count);
// printf("\n");
}
for(i=0;i<l;i++)
printf("%d\n",ans[i]);
/*
printf("queries\n");
for(i=0;i<l;i++)
printf("%lld %lld\n",q[i].first.first,q[i].first.second);*/
return 0;
}
|
5a83d66ea7bc536159d43525b70cfab2959f5044
|
f6a5b7480f5f977c229cf29b1742499e12624090
|
/Code/RubDivSolverV1.cpp
|
384b7c743fc0fb6f65fcd44fd575537f8790bfe2
|
[
"MIT"
] |
permissive
|
spencerparkin/RubiksDivide
|
a812308b8bc1c91f191f5eeccd77d44189dd8bf6
|
816219594da38aef594f700034789d7d093280a7
|
refs/heads/master
| 2021-01-01T18:17:01.127111
| 2015-06-27T00:20:01
| 2015-06-27T00:20:01
| 37,741,005
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,636
|
cpp
|
RubDivSolverV1.cpp
|
// RubDivSolverV1.cpp
#include "RubDivSolverV1.h"
RubDivSolverV1::RubDivSolverV1( void )
{
puzzleClone = 0;
}
/*virtual*/ RubDivSolverV1::~RubDivSolverV1( void )
{
wxASSERT( puzzleClone == 0 );
}
/*virtual*/ bool RubDivSolverV1::Solve( const RubDivPuzzle* puzzle, RubDivPuzzle::MoveList& moveList )
{
wxASSERT( puzzleClone == 0 );
// We only deal with the vertical case, which is really no different than the horizontal case.
if( puzzle->GetOrientation() != RubDivPuzzle::VERTICAL )
return false;
moveList.clear();
puzzleClone = puzzle->Clone();
while( !puzzleClone->IsSolved() )
{
RubDivPuzzle::MoveList algorithm;
if( FindAlgorithm( algorithm ) )
{
bool manipulated = puzzleClone->ManipulatePuzzle( algorithm );
wxASSERT( manipulated );
ConcatinateMoveList( moveList, algorithm );
}
else
{
RubDivPuzzle::Move rotateMove;
rotateMove.squareOffset = 2;
rotateMove.rotateCCWCount = 1;
rotateMove.rowOrColumn = -1;
rotateMove.shiftDir = RubDivPuzzle::SHIFT_NONE;
bool manipulated = puzzleClone->ManipulatePuzzle( rotateMove );
wxASSERT( manipulated );
moveList.push_back( rotateMove );
}
}
delete puzzleClone;
puzzleClone = 0;
CompressMoveList( moveList );
return true;
}
// Note that this could generalize even further by solving multiple rows at the same time and using multiple preservation columns.
// As long as there's no collision between the columns we solve in the rows and the preservation columns, it works out.
bool RubDivSolverV1::FindAlgorithm( RubDivPuzzle::MoveList& algorithm )
{
int size = puzzleClone->GetSize();
for( int i = 0; i < size; i++ )
{
RubDivPuzzle::MoveList algorithmCCW, algorithmCW;
RubDivPuzzle::Move rotationMove;
rotationMove.squareOffset = 1;
rotationMove.rowOrColumn = -1;
rotationMove.shiftDir = RubDivPuzzle::SHIFT_NONE;
rotationMove.rotateCCWCount = 1;
bool foundCCW = FindAlgorithmForRow( i, rotationMove, algorithmCCW );
rotationMove.rotateCCWCount = 3;
bool foundCW = FindAlgorithmForRow( i, rotationMove, algorithmCW );
if( foundCCW && foundCW )
{
if( algorithmCCW.size() > algorithmCW.size() )
ConcatinateMoveList( algorithm, algorithmCCW );
else
ConcatinateMoveList( algorithm, algorithmCW );
}
else if( foundCCW )
ConcatinateMoveList( algorithm, algorithmCCW );
else if( foundCW )
ConcatinateMoveList( algorithm, algorithmCW );
if( algorithm.size() > 0 )
return true;
}
return false;
}
// Notice that for puzzles with an odd size, the centers cannot move.
// So to avoid this special case, we always restore color A to the top
// square, and color B to the bottom square.
bool RubDivSolverV1::FindAlgorithmForRow( int row, const RubDivPuzzle::Move& rotationMove, RubDivPuzzle::MoveList& algorithm )
{
int size = puzzleClone->GetSize();
int preservationColumn;
if( rotationMove.rotateCCWCount == 1 )
preservationColumn = row;
else if( rotationMove.rotateCCWCount == 3 )
preservationColumn = size - 1 - row;
else
return false;
RubDivPuzzle::MoveList shiftMoveList;
RubDivPuzzle::MoveList inverseShiftMoveList;
for( int j = 0; j < size; j++ )
{
if( j == preservationColumn )
continue;
if( puzzleClone->GetColor( 1, row, j ) == RubDivPuzzle::Element::COLOR_B && puzzleClone->GetColor( 2, row, j ) == RubDivPuzzle::Element::COLOR_A )
{
RubDivPuzzle::Move shiftMove;
shiftMove.squareOffset = -1;
shiftMove.rotateCCWCount = 0;
shiftMove.rowOrColumn = j;
shiftMove.shiftDir = RubDivPuzzle::SHIFT_BACKWARD;
shiftMoveList.push_back( shiftMove );
RubDivPuzzle::Move inverseShiftMove;
shiftMove.Invert( inverseShiftMove );
inverseShiftMoveList.push_back( inverseShiftMove );
}
}
if( shiftMoveList.size() == 0 )
return false;
ConcatinateMoveList( algorithm, shiftMoveList );
algorithm.push_back( rotationMove );
RubDivPuzzle::Move preservationShiftMove;
preservationShiftMove.squareOffset = -1;
preservationShiftMove.rotateCCWCount = 0;
preservationShiftMove.rowOrColumn = preservationColumn;
preservationShiftMove.shiftDir = RubDivPuzzle::SHIFT_BACKWARD;
algorithm.push_back( preservationShiftMove );
RubDivPuzzle::Move inverseRotationMove;
rotationMove.Invert( inverseRotationMove );
algorithm.push_back( inverseRotationMove );
ConcatinateMoveList( algorithm, inverseShiftMoveList );
algorithm.push_back( rotationMove );
RubDivPuzzle::Move inversePreservationShiftMove;
preservationShiftMove.Invert( inversePreservationShiftMove );
algorithm.push_back( inversePreservationShiftMove );
algorithm.push_back( inverseRotationMove );
return true;
}
// RubDivSolverV1.cpp
|
2f87389a1e16c50c83b437b03406b71917863c3f
|
140b21b8faa8182ac4c96ef1b177702396b1b632
|
/x10.runtime/x10rt/common/x10rt_front.cc
|
a4b206c9cba816ca8ce3003f18bbc7603f66bcfd
|
[] |
no_license
|
manuelmohr/x10i
|
fac437a9ba3c29a20f743dd6c1ea37bcc053660e
|
a2b4761691dfd05b0d8c77c40a0b586e46b8508d
|
refs/heads/master
| 2021-08-18T19:34:11.681152
| 2017-09-25T11:21:30
| 2017-09-25T11:21:39
| 111,830,404
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,487
|
cc
|
x10rt_front.cc
|
#if defined(__CYGWIN__) || defined(__FreeBSD__)
#undef __STRICT_ANSI__ // Strict ANSI mode is too strict in Cygwin and FreeBSD
#endif
#include <cstdlib>
#include <cstdio>
#include <x10rt_front.h>
#include <x10rt_logical.h>
#include <x10rt_net.h>
static x10rt_msg_type counter = 0;
static bool run_as_library = false;
char* x10rt_preinit() {
run_as_library = true;
// Because we don't want to break the old PGAS-BG/P implementation of x10rt_net.h, we
// can't add methods to lower API layers. So instead, we set environment variables
// to pass & return values needed inside the regular x10rt_init method call of sockets.
// Yuck.
setenv("X10_LIBRARY_MODE", "preinit", 1);
x10rt_net_init(NULL, NULL, &counter);
char* connInfo = getenv("X10_LIBRARY_MODE");
return connInfo;
}
bool x10rt_run_as_library (void)
{ return run_as_library; }
void x10rt_init (int *argc, char ***argv)
{ x10rt_lgl_init(argc, argv, &counter); }
x10rt_msg_type x10rt_register_msg_receiver (x10rt_handler *cb,
x10rt_cuda_pre *pre, x10rt_cuda_post *post,
const char *cubin, const char *kernel_name)
{
x10rt_lgl_register_msg_receiver(counter, cb);
if (pre!=NULL)
x10rt_lgl_register_msg_receiver_cuda(counter, pre, post, cubin, kernel_name);
return counter++;
}
x10rt_msg_type x10rt_register_get_receiver (x10rt_finder *cb1, x10rt_notifier *cb2,
x10rt_finder *cuda_cb1, x10rt_notifier *cuda_cb2)
{
x10rt_lgl_register_get_receiver(counter, cb1, cb2);
if (cuda_cb1!=NULL)
x10rt_lgl_register_get_receiver_cuda(counter, cuda_cb1, cuda_cb2);
return counter++;
}
x10rt_msg_type x10rt_register_put_receiver (x10rt_finder *cb1, x10rt_notifier *cb2,
x10rt_finder *cuda_cb1, x10rt_notifier *cuda_cb2)
{
x10rt_lgl_register_put_receiver(counter, cb1, cb2);
if (cuda_cb1!=NULL)
x10rt_lgl_register_put_receiver_cuda(counter, cuda_cb1, cuda_cb2);
return counter++;
}
void x10rt_registration_complete (void)
{ x10rt_lgl_registration_complete(); }
x10rt_place x10rt_nplaces (void)
{ return x10rt_lgl_nplaces(); }
x10rt_place x10rt_nhosts (void)
{ return x10rt_lgl_nhosts(); }
x10rt_place x10rt_here (void)
{ return x10rt_lgl_here(); }
bool x10rt_is_host (x10rt_place place)
{ return x10rt_lgl_type(place) == X10RT_LGL_HOST; }
bool x10rt_is_cuda (x10rt_place place)
{ return x10rt_lgl_type(place) == X10RT_LGL_CUDA; }
bool x10rt_is_spe (x10rt_place place)
{ return x10rt_lgl_type(place) == X10RT_LGL_SPE; }
x10rt_place x10rt_parent (x10rt_place place)
{ return x10rt_lgl_parent(place); }
x10rt_place x10rt_nchildren (x10rt_place place)
{ return x10rt_lgl_nchildren(place); }
x10rt_place x10rt_child (x10rt_place host, x10rt_place index)
{ return x10rt_lgl_child(host, index); }
x10rt_place x10rt_child_index (x10rt_place child)
{ return x10rt_lgl_child_index(child); }
static uint32_t print_headers = getenv("X10RT_PRINT_MSG_HEADERS") != NULL
? (uint32_t)strtoull(getenv("X10RT_PRINT_MSG_HEADERS"),NULL,10)
: 0xFFFFFFFF;
void x10rt_send_msg (x10rt_msg_params *p)
{
if (p->len > print_headers) {
::fprintf(stderr,"p%llu --%llu--> p%llu (%llu bytes)\n",
(unsigned long long)x10rt_lgl_here(),
(unsigned long long)p->type,
(unsigned long long)p->dest_place,
(unsigned long long)p->len);
}
return x10rt_lgl_send_msg(p);
}
void x10rt_send_get (x10rt_msg_params *p, void *buf, x10rt_copy_sz len)
{ return x10rt_lgl_send_get(p, buf, len); }
void x10rt_send_put (x10rt_msg_params *p, void *buf, x10rt_copy_sz len)
{ return x10rt_lgl_send_put(p, buf, len); }
void x10rt_remote_alloc (x10rt_place place, x10rt_remote_ptr sz,
x10rt_completion_handler3 *ch, void *arg)
{ x10rt_lgl_remote_alloc(place, sz, ch, arg); }
void x10rt_remote_free (x10rt_place place, x10rt_remote_ptr ptr)
{ x10rt_lgl_remote_free(place, ptr); }
void x10rt_remote_op (x10rt_place place, x10rt_remote_ptr remote_addr,
x10rt_op_type type, unsigned long long value)
{ x10rt_lgl_remote_op(place, remote_addr, type, value); }
void x10rt_remote_ops (x10rt_remote_op_params *opv, size_t opc)
{ x10rt_lgl_remote_ops(opv, opc); }
x10rt_remote_ptr x10rt_register_mem (void *ptr, size_t len)
{ return x10rt_lgl_register_mem(ptr, len); }
void x10rt_blocks_threads (x10rt_place d, x10rt_msg_type type, int dyn_shm,
int *blocks, int *threads, const int *cfg)
{ x10rt_lgl_blocks_threads (d, type, dyn_shm, blocks, threads, cfg); }
void x10rt_probe (void)
{ x10rt_lgl_probe(); }
void x10rt_blocking_probe (void)
{ x10rt_lgl_blocking_probe(); }
void x10rt_finalize (void)
{ x10rt_lgl_finalize(); }
void x10rt_team_new (x10rt_place placec, x10rt_place *placev,
x10rt_completion_handler2 *ch, void *arg)
{
x10rt_lgl_team_new(placec, placev, ch, arg);
}
void x10rt_team_del (x10rt_team team, x10rt_place role,
x10rt_completion_handler *ch, void *arg)
{
x10rt_lgl_team_del(team, role, ch, arg);
}
x10rt_place x10rt_team_sz (x10rt_team team)
{
return x10rt_lgl_team_sz(team);
}
void x10rt_team_split (x10rt_team parent, x10rt_place parent_role,
x10rt_place color, x10rt_place new_role,
x10rt_completion_handler2 *ch, void *arg)
{
x10rt_lgl_team_split(parent, parent_role, color, new_role, ch, arg);
}
void x10rt_barrier (x10rt_team team, x10rt_place role,
x10rt_completion_handler *ch, void *arg)
{
x10rt_lgl_barrier(team, role, ch, arg);
}
void x10rt_bcast (x10rt_team team, x10rt_place role,
x10rt_place root, const void *sbuf, void *dbuf,
size_t el, size_t count,
x10rt_completion_handler *ch, void *arg)
{
x10rt_lgl_bcast(team, role, root, sbuf, dbuf, el, count, ch, arg);
}
void x10rt_scatter (x10rt_team team, x10rt_place role,
x10rt_place root, const void *sbuf, void *dbuf,
size_t el, size_t count,
x10rt_completion_handler *ch, void *arg)
{
x10rt_lgl_scatter(team, role, root, sbuf, dbuf, el, count, ch, arg);
}
void x10rt_alltoall (x10rt_team team, x10rt_place role,
const void *sbuf, void *dbuf,
size_t el, size_t count,
x10rt_completion_handler *ch, void *arg)
{
x10rt_lgl_alltoall(team, role, sbuf, dbuf, el, count, ch, arg);
}
void x10rt_allreduce (x10rt_team team, x10rt_place role,
const void *sbuf, void *dbuf,
x10rt_red_op_type op,
x10rt_red_type dtype,
size_t count,
x10rt_completion_handler *ch, void *arg)
{
x10rt_lgl_allreduce(team, role, sbuf, dbuf, op, dtype, count, ch, arg);
}
void x10rt_one_setter (void *arg)
{ *((int*)arg) = 1; }
void x10rt_team_setter (x10rt_team v, void *arg)
{ *((x10rt_team*)arg) = v; }
void x10rt_remote_ptr_setter (x10rt_remote_ptr v, void *arg)
{ *((x10rt_remote_ptr*)arg) = v; }
void x10rt_get_stats (x10rt_stats *s)
{ x10rt_lgl_get_stats(s); }
void x10rt_set_stats (x10rt_stats *s)
{ x10rt_lgl_set_stats(s); }
void x10rt_zero_stats (x10rt_stats *s)
{ x10rt_lgl_zero_stats(s); }
|
a8b56a99483a42a31b964ba8e174801f614a3f94
|
b005e76d8f20308335dadc9fd0a5a64e3813d777
|
/Recursion/Recursion_JosephusProblem.cpp
|
3c7c3e669bab4ab3abe5c97448c8746d294cee0b
|
[] |
no_license
|
saa27/Data-Structures
|
7951ab0e2cfdb4ff9afb8386f25dcd26570fb49f
|
8823680b3654917ca637700dd060715815567819
|
refs/heads/master
| 2023-06-22T13:30:03.479668
| 2021-07-10T05:07:48
| 2021-07-10T05:07:48
| 280,473,117
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 676
|
cpp
|
Recursion_JosephusProblem.cpp
|
#include <cmath>
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
void solve(vector<int>v, int k, int index, int &ans){
if(v.size() == 1){
ans = v[0];
return;
}
index = (index + k)% v.size();
v.erase(v.begin()+index);
solve(v,k,index,ans);
}
int main(){
int n,k;
cin>>n>>k;
vector<int> v;
for(int i=1;i<=n;i++){
v.push_back(i);
}
int index =0;
k = k-1;
int ans =0;
solve(v,k,index,ans);
cout<<ans;
}
|
0b955ccfd67d634aa82ca70de32217113749f4d7
|
3f114af0f20d20b10548edf19f821afba0799d10
|
/main_app/main_app.ino
|
702c3857ac83dec41a3d5259fc5bf1e4687f05da
|
[] |
no_license
|
JAICHANGPARK/esp32_ble_ota
|
9c5538eb86227c4bcaf57c707339ae0f9f8d695b
|
a04312ce1cb29ca6778c6059083a0272653dfbfc
|
refs/heads/main
| 2023-04-19T07:49:28.481098
| 2021-05-02T10:06:36
| 2021-05-02T10:06:36
| 353,535,413
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,480
|
ino
|
main_app.ino
|
#include "FS.h"
#include "SD.h"
#include "SPI.h"
#include <Update.h>
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
BLEServer *pServer = NULL;
BLECharacteristic * pTxCharacteristic;
BLECharacteristic * pOtaControlCharacteristic;
bool deviceConnected = false;
bool oldDeviceConnected = false;
uint8_t txValue = 0;
#define SERVICE_UUID "0000FF00-0000-1000-8000-00805f9b34fb" // UART service UUID
#define CHARACTERISTIC_UUID_RX "0000FF01-0000-1000-8000-00805f9b34fb" // 데이터 쓰는것
#define CHARACTERISTIC_UUID_TX "0000FF02-0000-1000-8000-00805f9b34fb"
#define CHARACTERISTIC_UUID_OTA_CONTROL "0000FF03-0000-1000-8000-00805f9b34fb" // 총 버퍼 컨트롤용
uint8_t bleFileBuff[1024] = {0x00,};
bool isReceived = false;
int received_counter = 0;
bool receivedIndicator = false;
bool isPsramSetting = false;
int n_elements = 0;
int n_chunk_length = 0;
uint8_t *int_array ;
int buff_counter = 0;
int chunk_counter = 0;
// perform the actual update from a given stream
void performUpdateV2(uint8_t * datas, size_t updateSize) {
Serial.print(">>> performUpdate updateSize: ");
Serial.println(updateSize);
if (Update.begin(updateSize)) {
size_t written = Update.write(datas, updateSize );
Serial.print(">>> performUpdate written: ");
Serial.println(written);
if (written == updateSize) {
Serial.println("Written : " + String(written) + " successfully");
}
else {
Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
}
if (Update.end()) {
Serial.println("OTA done!");
if (Update.isFinished()) {
Serial.println("Update successfully completed. Rebooting.");
}
else {
Serial.println("Update not finished? Something went wrong!");
}
}
else {
Serial.println("Error Occurred. Error #: " + String(Update.getError()));
}
}
else
{
Serial.println("Not enough space to begin OTA");
}
}
void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
Serial.printf("Listing directory: %s\n", dirname);
File root = fs.open(dirname);
if (!root) {
Serial.println("Failed to open directory");
return;
}
if (!root.isDirectory()) {
Serial.println("Not a directory");
return;
}
File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
Serial.print(" DIR : ");
Serial.println(file.name());
if (levels) {
listDir(fs, file.path(), levels - 1);
}
} else {
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print(" SIZE: ");
Serial.println(file.size());
}
file = root.openNextFile();
}
}
void deleteFile(fs::FS &fs, const char * path) {
Serial.printf("Deleting file: %s\n", path);
if (fs.exists(path)) {
Serial.printf("Deleting exists file: %s\n", path);
if (fs.remove(path)) {
Serial.println("File deleted");
} else {
Serial.println("Delete failed");
}
}
}
void appendFile(fs::FS &fs, const char * path, const char * message) {
Serial.printf("Appending to file: %s\n", path);
File file = fs.open(path, FILE_APPEND);
if (!file) {
Serial.println("Failed to open file for appending");
return;
}
if (file.print(message)) {
Serial.println("Message appended");
} else {
Serial.println("Append failed");
}
file.close();
}
void appendFileV2(fs::FS &fs, const char * path) {
Serial.printf("Appending to file: %s\n", path);
File file = fs.open(path, FILE_APPEND);
if (!file) {
Serial.println("Failed to open file for appending");
return;
}
file.write(int_array, n_elements);
Serial.printf("Done Append to file: %s\n", path);
// for (int i = 0; i < n_elements; i++) {
// Serial.print("index: ");
// Serial.print(i);
// Serial.print("->");
// Serial.print(int_array[i]);
// Serial.print(" ");
// // Serial.println(file.write(int_array[i]));
//
// }
file.close();
}
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
};
void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
}
};
class MyCallbacks: public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
std::string rxValue = pCharacteristic->getValue();
if (rxValue.length() > 0) {
Serial.println(rxValue.length());
// Serial.println("*********");
// Serial.print("Received Value: ");
for (int i = 0; i < rxValue.length(); i++)
{
bleFileBuff[i] = (uint8_t)rxValue[i];
// Serial.print(rxValue[i]);
received_counter = received_counter + 1;
}
Serial.print(">>> received_counter: ");
Serial.println(received_counter);
if (received_counter == 512) {
Serial.println("received_counter is 512");
isReceived = true;
} else {
Serial.print(">>> chunk_counter: ");
Serial.println(chunk_counter);
if (chunk_counter == n_chunk_length - 1) {
isReceived = true;
}
}
// Serial.println();
// Serial.println("*********");
}
}
};
class OtaControlCallbacks: public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
std::string rxValue = pCharacteristic->getValue();
if (rxValue.length() > 0) {
Serial.println("OtaControlCallbacks *********");
for (int i = 0; i < rxValue.length(); i++)
{
Serial.print(rxValue[i]);
}
n_elements = ((uint8_t)rxValue[0] << 24) & 0xFF000000
| ((uint8_t)rxValue[1] << 16) & 0x00FF0000
| ((uint8_t)rxValue[2] << 8) & 0x0000FF00
| ((uint8_t)rxValue[3]) & 0x000000FF;
n_chunk_length = ((uint8_t)rxValue[4] << 24) & 0xFF000000
| ((uint8_t)rxValue[5] << 16) & 0x00FF0000
| ((uint8_t)rxValue[6] << 8) & 0x0000FF00
| ((uint8_t)rxValue[7]) & 0x000000FF;
Serial.print(">>> n_chunk_length:: ");
Serial.println(n_chunk_length);
Serial.println();
isPsramSetting = true;
}
}
};
void setup() {
Serial.begin(115200);
pinMode(5, OUTPUT);
if (!SD.begin(4)) {
Serial.println("Card Mount Failed");
return;
}
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
Serial.println("No SD card attached");
return;
}
Serial.print("SD Card Type: ");
if (cardType == CARD_MMC) {
Serial.println("MMC");
} else if (cardType == CARD_SD) {
Serial.println("SDSC");
} else if (cardType == CARD_SDHC) {
Serial.println("SDHC");
} else {
Serial.println("UNKNOWN");
}
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
Serial.printf("SD Card Size: %lluMB\n", cardSize);
listDir(SD, "/", 0);
deleteFile(SD, "/update.bin");
// Create the BLE Device
BLEDevice::init("UART Service");
// Create the BLE Server
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
// Create the BLE Service
BLEService *pService = pServer->createService(SERVICE_UUID);
// Create a BLE Characteristic
pTxCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_TX,
BLECharacteristic::PROPERTY_NOTIFY
);
pTxCharacteristic->addDescriptor(new BLE2902());
BLECharacteristic * pRxCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_RX,
BLECharacteristic::PROPERTY_WRITE
);
pRxCharacteristic->setCallbacks(new MyCallbacks());
pOtaControlCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_OTA_CONTROL,
BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_READ
);
pOtaControlCharacteristic->setCallbacks(new OtaControlCallbacks());
// Start the service
pService->start();
// Start advertising
pServer->getAdvertising()->start();
Serial.println("Waiting a client connection to notify...");
}
void loop() {
if (deviceConnected) {
// pTxCharacteristic->setValue(&txValue, 1);
// pTxCharacteristic->notify();
// txValue++;
if (isReceived) {
Serial.println("*********");
Serial.print("Received Value: ");
if (received_counter == 512) {
for (int i = 0; i < 512; i++) {
Serial.print(bleFileBuff[i], HEX);
Serial.print(" ");
int_array[buff_counter] = bleFileBuff[i];
buff_counter++;
}
Serial.println();
Serial.print("buff_counter: ");
Serial.print(buff_counter);
Serial.println(" *********");
receivedIndicator = !receivedIndicator;
digitalWrite(5, receivedIndicator);
chunk_counter++;
pTxCharacteristic->setValue(chunk_counter);
pTxCharacteristic->notify();
if (buff_counter == n_elements) {
Serial.println(">>>>>>>>>>>>> Same? >>>>>>>>>>>>>>>>>>>>");
}
received_counter = 0;
} else {
if (chunk_counter == n_chunk_length - 1) {
Serial.println(">>>>>>>>>>>>>>> is Last Packet");
for (int i = 0; i < received_counter; i++) {
Serial.print(bleFileBuff[i], HEX);
Serial.print(" ");
int_array[buff_counter] = bleFileBuff[i];
buff_counter++;
}
Serial.println();
Serial.print("buff_counter: ");
Serial.print(buff_counter);
chunk_counter++;
pTxCharacteristic->setValue(chunk_counter);
pTxCharacteristic->notify();
appendFileV2(SD, "/update.bin");
performUpdateV2(int_array, n_elements);
free(int_array);
delay(1000);
ESP.restart();
}
}
isReceived = false;
}
if (isPsramSetting) {
Serial.print("n_elements: ");
Serial.println(n_elements);
int temp = n_elements + 1024;
if (n_elements != 0) {
//psram setting
int_array = (uint8_t *) ps_malloc(temp * sizeof(uint8_t));
Serial.println("Set PSRAM ps_malloc");
} else {
//psram free
free(int_array);
Serial.println("free PSRAM ");
}
isPsramSetting = false;
}
delay(10); // bluetooth stack will go into congestion, if too many packets are sent
}
// disconnecting
if (!deviceConnected && oldDeviceConnected) {
delay(500); // give the bluetooth stack the chance to get things ready
pServer->startAdvertising(); // restart advertising
Serial.println("start advertising");
oldDeviceConnected = deviceConnected;
free(int_array);
n_elements = 0;
for (int i = 0; i < 1024; i++) {
bleFileBuff[i] = 0x00;
}
isReceived = false;
receivedIndicator = false;
isPsramSetting = false;
n_elements = 0;
n_chunk_length = 0;
buff_counter = 0;
chunk_counter = 0;
}
// connecting
if (deviceConnected && !oldDeviceConnected) {
// do stuff here on connecting
oldDeviceConnected = deviceConnected;
}
}
|
e305aa117e446910f42902c0022722f5e2529e8d
|
11a3307520cdf33c49f2e63f77a8da4526459a25
|
/LongestCommonSubsequence.cpp
|
33f114e4c582646f5ed5722196a3bcad18fbd48a
|
[] |
no_license
|
anup-k1/DP_practice
|
444b5928f867e636c5171f64f543ddd97a08116f
|
f1c8e7797060b40f88cc603a697f8f067f1943ef
|
refs/heads/main
| 2023-02-18T01:51:25.364076
| 2021-01-09T14:31:04
| 2021-01-09T14:31:04
| 327,966,141
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,250
|
cpp
|
LongestCommonSubsequence.cpp
|
//LCS - longest comimon susequence.
#include <iostream>
#include < string>
#include <vector>
using namespace std;
int LCMDynamic(const string &s1, const string &s2)
{
int strSize1 = s1.size();
int strSize2 = s2.size();
vector<vector<int>> K (strSize1+1, vector<int> (strSize2+1));
int maxm = 0;
for( int i = 1; i <= strSize1; ++i )
for (int j = 1; j <= strSize2; ++j)
{
if(s1[i-1] == s2[j-1] )
K[i][j] = 1 + K[i-1][j-1];
else
K[i][j] = max(K[i-1][j], K[i][j-1]); // checking diagonally
}//end for
return K[strSize1][strSize2];
}//end LCMDynamic
int LCMRecursive(const string &s1, const string &s2, int i , int j )
{
if(s1[i] == '\0' || s2[j] == '\0')
return 0;
else if(s1[i] == s2[j])
return 1 + (LCMRecursive(s1, s2, i+1 , j+1 ));
else
return max(LCMRecursive(s1, s2, i+1 , j),LCMRecursive(s1, s2, i , j+1));
// we can improve the recusion by adding cache i.e memorization
// storing the results for already calculate subseqs.
}
int main(void)
{
string s1 = "abcdaf";
string s2 = "acbcf";
cout<<"Longest common sub seq :- "<<LCMDynamic(s1,s2)<<endl;
cout<<"Longest common sub seq recursive solution "<<LCMRecursive(s1,s2, 0, 0)<<endl;
}
|
01a533d5f6362ad2b477a6471336acf8d4fac757
|
aff7c365be316e90540afdd3afbd690a38a1565c
|
/RTP_HLS/RTP_HLS/libmov/source/mov-mfhd.cpp
|
4eb63888990cdc393e7a610b2907f671a8ca54f8
|
[] |
no_license
|
chxj1980/rtp_hikvision_test
|
c7887a50768dcd3b9a9e9b417a04358b2a97c44d
|
fb3effe57f1b70b04964d5ec6d54d528b8ec6596
|
refs/heads/master
| 2022-04-09T03:13:43.097407
| 2020-03-05T08:06:00
| 2020-03-05T08:06:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 657
|
cpp
|
mov-mfhd.cpp
|
#include "../include/mov-internal.h"
#include <errno.h>
#include <stdlib.h>
#include <assert.h>
// 8.8.5 Movie Fragment Header Box (p70)
int mov_read_mfhd(struct mov_t* mov, const struct mov_box_t* box)
{
(void)box;
mov_buffer_r32(&mov->io); /* version & flags */
mov_buffer_r32(&mov->io); /* sequence_number */
return mov_buffer_error(&mov->io);
}
size_t mov_write_mfhd(const struct mov_t* mov, uint32_t fragment)
{
mov_buffer_w32(&mov->io, 16); /* size */
mov_buffer_write(&mov->io, "mfhd", 4);
mov_buffer_w32(&mov->io, 0); /* version & flags */
mov_buffer_w32(&mov->io, fragment); /* sequence_number */
return 16;
}
|
a718ba04b925c11360ce8dd3be4b4e7280b37bcc
|
3f05b45ba295e7d388689b05d309b704425386df
|
/correctbalance.cpp
|
9a7cf7391443ac26730b18095a0f442c5fcba6a3
|
[] |
no_license
|
sergey196510/mycash
|
9d5e42d968b729f8739e9b9913b0eaec0e07d27b
|
d91e851b1a3a19c0d3a3a3c8e8975f177409d791
|
refs/heads/master
| 2023-03-02T12:34:21.061386
| 2021-01-24T12:39:32
| 2021-01-24T12:39:32
| 332,447,640
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,454
|
cpp
|
correctbalance.cpp
|
#include "correctbalance.h"
#include "ui_correctbalance.h"
CorrectBalance::CorrectBalance(QWidget *parent) :
QDialog(parent),
ui(new Ui::CorrectBalance)
{
ui->setupUi(this);
ui->lineEdit->setValue(var.CorrectAccount());
// ui->okButton->setIcon(QPixmap(":icons/accept.png"));
// ui->cancelButton->setIcon(QPixmap(":icons/block_32.png"));
ui->okButton->setEnabled(false);
// ui->doubleSpinBox->setRange(-1000000, 1000000);
connect(ui->lineEdit, SIGNAL(changed_value()), SLOT(check_ok()));
connect(ui->summEdit, SIGNAL(textChanged(QString)), SLOT(check_ok()));
connect(ui->okButton, SIGNAL(clicked()), SLOT(accept()));
connect(ui->cancelButton, SIGNAL(clicked()), SLOT(reject()));
}
CorrectBalance::~CorrectBalance()
{
delete ui;
}
void CorrectBalance::check_ok()
{
if (ui->summEdit == 0 || ui->lineEdit->value() == 0)
ui->okButton->setEnabled(false);
else
ui->okButton->setEnabled(true);
}
void CorrectBalance::setAccount(int value)
{
ui->lineEdit->setValue(value);
}
void CorrectBalance::setBalance(double value)
{
ui->summEdit->setValue(value);
}
double CorrectBalance::balance()
{
// return ui->summEdit->text().toDouble();
// return default_locale->toDouble(ui->summEdit->text());
return ui->summEdit->value();
}
int CorrectBalance::account()
{
return ui->lineEdit->value();
}
QDate CorrectBalance::date()
{
return ui->dateEdit->value();
}
|
956f8fb72b294fdd951868d8a21a8105d245b1ff
|
9b718a0002e5a6cd0a8fbb0e532968195630a291
|
/grasp_ros2/src/ros_params.cpp
|
5406281507e28990b2e93af08df0f69d00bdb350
|
[
"Apache-2.0"
] |
permissive
|
intel/ros2_grasp_library
|
25368e47f7983e67f658e989d3efd21fea3e8aa8
|
505fa7353622b01334e950e50a0a027ff92788cf
|
refs/heads/master
| 2023-05-27T14:27:05.363057
| 2023-01-31T00:22:13
| 2023-01-31T00:22:13
| 148,516,381
| 165
| 48
|
Apache-2.0
| 2023-04-07T10:09:16
| 2018-09-12T17:25:24
|
C++
|
UTF-8
|
C++
| false
| false
| 6,701
|
cpp
|
ros_params.cpp
|
// Copyright (c) 2018 Intel Corporation. All Rights Reserved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string>
#include <vector>
#include "grasp_library/ros2/ros_params.hpp"
namespace grasp_ros2
{
void ROSParameters::getDetectionParams(
rclcpp::Node * node,
GraspDetector::GraspDetectionParameters & param)
{
// Read hand geometry parameters.
node->get_parameter_or("finger_width", param.hand_search_params.finger_width_, 0.005);
node->get_parameter_or("hand_outer_diameter", param.hand_search_params.hand_outer_diameter_,
0.12);
node->get_parameter_or("hand_depth", param.hand_search_params.hand_depth_, 0.06);
node->get_parameter_or("hand_height", param.hand_search_params.hand_height_, 0.02);
node->get_parameter_or("init_bite", param.hand_search_params.init_bite_, 0.01);
// Read local hand search parameters.
node->get_parameter_or("nn_radius", param.hand_search_params.nn_radius_frames_, 0.01);
node->get_parameter_or("num_orientations", param.hand_search_params.num_orientations_, 8);
node->get_parameter_or("num_samples", param.hand_search_params.num_samples_, 100);
node->get_parameter_or("num_threads", param.hand_search_params.num_threads_, 4);
node->get_parameter_or("rotation_axis", param.hand_search_params.rotation_axis_, 2);
// Read plotting parameters.
node->get_parameter_or("plot_samples", param.plot_samples_, false);
node->get_parameter_or("plot_normals", param.plot_normals_, false);
param.generator_params.plot_normals_ = param.plot_normals_;
node->get_parameter_or("plot_filtered_grasps", param.plot_filtered_grasps_, false);
node->get_parameter_or("plot_valid_grasps", param.plot_valid_grasps_, false);
node->get_parameter_or("plot_clusters", param.plot_clusters_, false);
node->get_parameter_or("plot_selected_grasps", param.plot_selected_grasps_, false);
// Read general parameters.
param.generator_params.num_samples_ = param.hand_search_params.num_samples_;
param.generator_params.num_threads_ = param.hand_search_params.num_threads_;
node->get_parameter_or("plot_candidates", param.generator_params.plot_grasps_, false);
// Read preprocessing parameters.
node->get_parameter_or("remove_outliers", param.generator_params.remove_statistical_outliers_,
false);
node->get_parameter_or("voxelize", param.generator_params.voxelize_, true);
node->get_parameter_or("workspace", param.generator_params.workspace_,
std::vector<double>(std::initializer_list<double>({-1.0, 1.0, -1.0, 1.0, -1.0, 1.0})));
param.workspace_ = param.generator_params.workspace_;
// Read classification parameters and create classifier.
node->get_parameter_or("model_file", param.model_file_, std::string(""));
node->get_parameter_or("trained_file", param.weights_file_, std::string(""));
node->get_parameter_or("min_score_diff", param.min_score_diff_, 500.0);
node->get_parameter_or("create_image_batches", param.create_image_batches_, false);
node->get_parameter_or("device", param.device_, 0);
// Read grasp image parameters.
node->get_parameter_or("image_outer_diameter", param.image_params.outer_diameter_,
param.hand_search_params.hand_outer_diameter_);
node->get_parameter_or("image_depth", param.image_params.depth_,
param.hand_search_params.hand_depth_);
node->get_parameter_or("image_height", param.image_params.height_,
param.hand_search_params.hand_height_);
node->get_parameter_or("image_size", param.image_params.size_, 60);
node->get_parameter_or("image_num_channels", param.image_params.num_channels_, 15);
// Read learning parameters.
node->get_parameter_or("remove_plane_before_image_calculation", param.remove_plane_, false);
// Read grasp filtering parameters
node->get_parameter_or("filter_grasps", param.filter_grasps_, false);
node->get_parameter_or("filter_half_antipodal", param.filter_half_antipodal_, false);
param.gripper_width_range_.push_back(0.03);
param.gripper_width_range_.push_back(0.10);
// node->get_parameter("gripper_width_range", param.gripper_width_range_);
// Read clustering parameters
node->get_parameter_or("min_inliers", param.min_inliers_, 1);
// Read grasp selection parameters
node->get_parameter_or("num_selected", param.num_selected_, 5);
}
void ROSParameters::getPlanningParams(
rclcpp::Node * node,
GraspPlanner::GraspPlanningParameters & param)
{
node->get_parameter_or("grasp_service_timeout", param.grasp_service_timeout_, 0);
node->get_parameter_or("grasp_score_threshold", param.grasp_score_threshold_, 200);
node->get_parameter_or("grasp_frame_id", param.grasp_frame_id_, std::string("base"));
std::vector<double> approach;
node->get_parameter_or("grasp_approach", approach,
std::vector<double>(std::initializer_list<double>({0.0, 0.0, -1.0})));
param.grasp_approach_ = tf2::Vector3(approach[0], approach[1], approach[2]);
node->get_parameter_or("grasp_approach_angle", param.grasp_approach_angle_, M_PI);
node->get_parameter_or("grasp_offset", param.grasp_offset_,
std::vector<double>(std::initializer_list<double>({0.0, 0.0, 0.0})));
node->get_parameter_or("grasp_boundry", param.grasp_boundry_,
std::vector<double>(std::initializer_list<double>({-1.0, 1.0, -1.0, 1.0, -1.0, 1.0})));
node->get_parameter_or("eef_offset", param.eef_offset, 0.154);
node->get_parameter_or("eef_yaw_offset", param.eef_yaw_offset, 0.0);
node->get_parameter_or("grasp_min_distance", param.grasp_min_distance_, 0.06);
node->get_parameter_or("grasp_desired_distance", param.grasp_desired_distance_, 0.1);
// gripper parameters
std::vector<double> finger_opens, finger_closes;
node->get_parameter_or("finger_joint_names", param.finger_joint_names_,
std::vector<std::string>(std::initializer_list<std::string>({std::string("panda_finger_joint1"),
std::string("panda_finger_joint2")})));
node->get_parameter_or("finger_positions_open", param.finger_points_open_.positions,
std::vector<double>(std::initializer_list<double>({-0.01, 0.01})));
node->get_parameter_or("finger_positions_close", param.finger_points_close_.positions,
std::vector<double>(std::initializer_list<double>({-0.0, 0.0})));
}
} // namespace grasp_ros2
|
6dc9ab6485f0dbe8c0e162a04b9fe1e7e17c374e
|
ad8271700e52ec93bc62a6fa3ee52ef080e320f2
|
/CatalystRichPresence/CatalystSDK/DestructionEntityFactory.h
|
6c29f66dc8b4418fcb6f4d0612d84fd6a4fd4c65
|
[] |
no_license
|
RubberDuckShobe/CatalystRPC
|
6b0cd4482d514a8be3b992b55ec143273b3ada7b
|
92d0e2723e600d03c33f9f027c3980d0f087c6bf
|
refs/heads/master
| 2022-07-29T20:50:50.640653
| 2021-03-25T06:21:35
| 2021-03-25T06:21:35
| 351,097,185
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 456
|
h
|
DestructionEntityFactory.h
|
//
// Generated with FrostbiteGen by Chod
// File: SDK\DestructionEntityFactory.h
// Created: Wed Mar 10 19:07:14 2021
//
#ifndef FBGEN_DestructionEntityFactory_H
#define FBGEN_DestructionEntityFactory_H
#include "IglooEntityFactory.h"
class DestructionEntityFactory :
public IglooEntityFactory // size = 0x28
{
public:
static void* GetTypeInfo()
{
return (void*)0x0000000142831A70;
}
}; // size = 0x28
#endif // FBGEN_DestructionEntityFactory_H
|
2a4d89078f25fc4e2f13ab98f28875df7ade2ea4
|
58e23b4e45ece5d297a3a270f5051228788c42c9
|
/IO/src/ImageLoaderPVR.h
|
901827b64a99d537a3ff095d743c6684b411e9ed
|
[
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-public-domain"
] |
permissive
|
playcanvas/FasTC
|
7cd34ed7f971e9a62a9f3048327fd2257ae81c3d
|
b5d602116dd34cdb9bad5d4c11f05c2aaedc2fe9
|
refs/heads/master
| 2023-02-21T04:07:23.985122
| 2021-01-25T13:20:41
| 2021-01-25T13:20:41
| 329,951,542
| 0
| 0
|
Apache-2.0
| 2021-01-25T13:20:42
| 2021-01-15T15:34:23
| null |
UTF-8
|
C++
| false
| false
| 1,001
|
h
|
ImageLoaderPVR.h
|
// Copyright 2016 The University of North Carolina at Chapel Hill
//
// 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.
//
// Please send all BUG REPORTS to <pavel@cs.unc.edu>.
// <http://gamma.cs.unc.edu/FasTC/>
#ifndef _IMAGE_LOADER_PVR_H_
#define _IMAGE_LOADER_PVR_H_
#include "FasTC/ImageLoader.h"
class ImageLoaderPVR : public ImageLoader {
public:
ImageLoaderPVR(const unsigned char *rawData);
virtual ~ImageLoaderPVR();
virtual bool ReadData();
};
#endif // _IMAGE_LOADER_PVR_H_
|
a83a7db9930e32814156c018ab2e3dbecfe9814d
|
4cfc6c4425786ac3128af32ed6a7c4d97b154a8f
|
/libraries/CustomHeaderLibs/ustd/shared_ptr.hpp
|
13c888f4edbf0d8044f5a9bb08ce759dd16ed82d
|
[
"WTFPL"
] |
permissive
|
mskoenz/arduino_crash_course
|
9aa1417daa84442c20de27df11646bd40525d039
|
cc7031e827dd13211cb9ce84f6d758f6e635e6a8
|
refs/heads/master
| 2020-05-16T23:58:43.635800
| 2019-11-18T09:00:33
| 2019-11-18T09:00:33
| 13,575,894
| 0
| 0
| null | 2013-10-24T14:39:30
| 2013-10-14T23:23:07
|
C
|
UTF-8
|
C++
| false
| false
| 2,748
|
hpp
|
shared_ptr.hpp
|
// Author: Mario S. Könz <mskoenz@gmx.net>
// Date: 14.11.2013 00:38:16 CET
// File: shared_ptr.hpp
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ or COPYING for more details. */
#ifndef __SHARED_PTR_HEADER
#define __SHARED_PTR_HEADER
namespace ustd {
template<typename T>
class shared_ptr {
void incr() {
++(*count_);
}
void decr() {
--(*count_);
}
public:
typedef T element_type;
//------------------- ctor -------------------
explicit shared_ptr(T * ptr = NULL): ptr_(ptr) {
count_ = new uint8_t(0);
ASSERT(count_ != NULL)
incr();
}
shared_ptr(shared_ptr const & rhs): ptr_(rhs.ptr_), count_(rhs.count_) {
incr();
}
//------------------- dtor -------------------
~shared_ptr() {
if(ptr_ == NULL) {
decr();
return;
}
if(*count_ == 1) {
delete ptr_;
delete count_;
} else {
ptr_ = NULL;
decr();
}
}
//------------------- assign -------------------
shared_ptr & operator=(shared_ptr const & rhs) {
if(ptr_ != rhs.ptr_) {
if(ptr_ != NULL) {
if(*count_ == 1) {
delete ptr_;
delete count_;
}
else
decr();
}
ptr_ = rhs.ptr_;
count_ = rhs.count_;
incr();
}
return (*this);
}
//------------------- deref -------------------
element_type * operator->() const {
return ptr_;
}
element_type & operator*() const {
return *ptr_;
}
//------------------- compare -------------------
//~ bool operator==(T * ptr) const {
//~ return ptr == ptr_;
//~ }
//~ bool operator==(shared_ptr const & arg) const {
//~ return arg.prt_ == ptr_;
//~ }
bool operator!=(T * ptr) const {
return ptr != ptr_;
}
bool operator!=(shared_ptr const & arg) const {
return arg.prt_ != ptr_;
}
private:
element_type * ptr_;
uint8_t * count_;
};
}//end namespace ustd
#endif //__SHARED_PTR_HEADER
|
8b33259ba8eb7aa55ee0977634d490e78a69b97d
|
72a7b27678d75782ed5f5228d39138e6af4eb448
|
/Milestone/Milestone/TeacherEditDlg.h
|
261d2c86b8358511f381503b7dd1ecb372824631
|
[
"MIT"
] |
permissive
|
aclisp/large-scale
|
9403167b903179ee6b47a253e826ae5cf9420ebe
|
6ab382c919f75da5b562b1879122fe0086339915
|
refs/heads/master
| 2020-03-29T18:50:23.528563
| 2014-11-04T02:55:16
| 2014-11-04T02:55:16
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 625
|
h
|
TeacherEditDlg.h
|
#ifndef __TeacherEditDlg__
#define __TeacherEditDlg__
/**
@file
Subclass of TeacherEditDlgGui, which is generated by wxFormBuilder.
*/
#include "TeacherDlgGui.h"
//// end generated include
/** Implementing TeacherEditDlgGui */
class TeacherEditDlg : public TeacherEditDlgGui
{
protected:
// Handlers for TeacherEditDlgGui events.
void OnClass( wxGridEvent& event );
const wxString _teacherName;
public:
/** Constructor */
TeacherEditDlg( wxWindow* parent, const wxString& teacherName );
//// end generated class members
void showClass();
};
#endif // __TeacherEditDlg__
|
30ae6c05e19e4c643bbb501d1deb1e94c86aa78f
|
f4b1142dce92f10f93d1531c151ed0df2ae0fb5e
|
/platform.cpp
|
f36627ee792ac1f96b746120fde6d04788a0ac43
|
[] |
no_license
|
rowanlovejoy/bounding-box
|
91026112bba8bdf13548a34766af444e72c39cc9
|
329c99e8fb4e3667f575bc4b9c4c51f53bc8908b
|
refs/heads/main
| 2023-04-25T08:02:28.536831
| 2021-05-03T09:47:18
| 2021-05-03T09:47:18
| 352,142,492
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 781
|
cpp
|
platform.cpp
|
#include "platform.h"
#include <GLFW/glfw3.h>
#include "effolkronium/random.hpp"
Platform::Platform(const Model& model, const Shader& shader, const glm::vec3& position, const glm::vec3& size, bool oscillate, const glm::vec3& offset, const glm::vec3& scale)
: VisibleObject{model, shader, position, size, offset, scale},
offset_{effolkronium::random_thread_local::get<float>(1, 10)},
oscillate_{oscillate}
{
}
void Platform::init()
{
}
void Platform::tick(float deltaTime)
{
if (oscillate_)
{
const auto y{sin(static_cast<float>(glfwGetTime())) * 0.0025f * offset_ * deltaTime};
addVelocity(glm::vec3{0.0f, y, 0.0f});
move();
}
}
void Platform::setOscillate(bool oscillate)
{
oscillate_ = oscillate;
}
bool Platform::getOscillate() const
{
return oscillate_;
}
|
be95e440e7349e9806a4aeea859eea060e57b061
|
cd060892280983a64d1d463fcea7b3edbf843cf8
|
/includes/Internal/Graphics/bk/RenderTargetImp.h
|
11ad29559173fd914d32de754401d7af67af37e3
|
[] |
no_license
|
zhvirus/zhangtina
|
c8741d3cab4cc0929db6776dde3ce5a4733fabe1
|
88a6f85992861862e22cd9edbe852f45b8a62775
|
refs/heads/master
| 2021-01-21T04:31:30.673821
| 2016-06-29T03:14:16
| 2016-06-29T03:14:16
| 14,973,156
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 568
|
h
|
RenderTargetImp.h
|
#ifndef RENDERTARGET_IMP_H
#define RENDERTARGET_IMP_H
#include "Common/ZHSTD.h"
#include "Internal/Graphics/Internal_common_graphics.h"
namespace ZH{
namespace Graphics{
class RenderTargetImp{
public:
RenderTargetImp( ID3D11RenderTargetView* );
~RenderTargetImp();
bool isValid();
ID3D11RenderTargetView* getRenderTargetView_d3d() { return m_pRenderTargetView_d3d; }
private:
ID3D11RenderTargetView* m_pRenderTargetView_d3d;
};
} // Graphics
} // ZH
#endif
|
64a53e96f514255b17bbf84e1b2dc7a3a4a51f25
|
25cfeb9c97b05fbb024007efa16775a215a7f5d1
|
/80-89/088/B/B.cpp
|
856079af91e1903c4487d19bdf1401d2c55b674a
|
[] |
no_license
|
edamame8888/edamame-s_ABC
|
626dde1b8f1ac61071cfe166cd6c08cc31371e72
|
41ce3164f20069f1e3a659a673350c76e36da04f
|
refs/heads/master
| 2020-03-24T03:49:04.644221
| 2019-06-28T04:53:53
| 2019-06-28T04:53:53
| 142,433,980
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 353
|
cpp
|
B.cpp
|
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main(){
int a,b,c,x,cnt = 0;
cin >> a >> b >> c >> x;
for(int i = 0; i <= a; i++){
for(int j = 0; j <= b; j++){
for(int k = 0; k <= c; k++){
if(500*i + 100 * j + 50 * k == x) cnt ++;
}
}
}
cout << cnt << endl;
}
|
00e38ecd914ce24b39344aa9b0480e7e1803f81d
|
01e8e12a077ba1dc3df79a7294bf95f950f2a2cf
|
/Estimation/KalmanFilter.h
|
6c555fac748dd58a620cfe2376f732e0a929c976
|
[
"MIT"
] |
permissive
|
TrevorDecker/RobotPlayGround
|
a75cab058a674eb541cc3e363e8ac5b6da400897
|
b03551f7e481b400a390386e3a0528487bc13f2b
|
refs/heads/master
| 2021-05-15T10:05:38.875385
| 2017-11-01T00:57:40
| 2017-11-01T00:57:40
| 108,233,501
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 557
|
h
|
KalmanFilter.h
|
// KalmanFilter.h
// Written by Trevor Decker
// TODO think about makeing this a templated class, and removing pointers
#ifndef _KALMAN_FILTER_H_
#define _KALMAN_FILTER_H_
#include "State.h"
class KalmanFilter {
private:
// State Estimation
State* s;
// Covariance
public:
//constructor
KalmanFilter() {
// TODO
}
//destructor
~KalmanFilter() {
// TODO
}
// predictTo()
// observe()
// getStateEstimate
State* getStateEstimate() {
return s;
}
// getConfidence
};
#endif // _KALMAN_FILTER_H_
|
6a58d68b90909cde27402f29032835fdf139efc9
|
939ed533e9b1ba919b89da6d63d4e9cdaa9ae040
|
/2016_Algorithm/algo_hw4.cpp
|
73d7f54d3f9745c4a53e8795e733d8615bd28167
|
[] |
no_license
|
digression99/SchoolProject
|
5e8d4e1b030e1a4234aeffa73f2705ceb81a3b3a
|
f722841140dc101b077da62ec183814fe72e2cef
|
refs/heads/master
| 2021-01-19T10:54:32.536380
| 2017-04-11T10:27:41
| 2017-04-11T10:27:41
| 87,915,187
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 3,152
|
cpp
|
algo_hw4.cpp
|
#include <stdio.h>
#include <math.h>
typedef struct _Point {
int x, y;
}Point;
// 따로 기억해 놓아야 할 게 있을까?
// 가까운 두 점 -> 값을 굳이 리턴할 필요는 없다.
// 인덱스만 저장해 놓아도 된다.
// 가까운 두 점의 인덱스와 거리를 리턴한다?
// maximumSubarray 로직을 이용.
double getDistance(int x1, int y1, int x2, int y2);
double dacPointDistance(Point * A, int p, int r, int * p1, int * p2);
double dacCrossingDistance(Point * A, int p, int r, int q, int * idx1, int * idx2);
int tripleCompare(double d1, double d2, double d3);
int main()
{
Point pArr[8];
double dist = 0;
int p1 = 0, p2 = 0;
pArr[0].x = 0, pArr[0].y = 0;
pArr[1].x = 5, pArr[1].y = 5;
pArr[2].x = 10, pArr[2].y = 10;
pArr[3].x = 15, pArr[3].y = 15;
pArr[4].x = 16, pArr[4].y = 16;
pArr[5].x = 25, pArr[5].y = 25;
pArr[6].x = 30, pArr[6].y = 30;
pArr[7].x = 35, pArr[7].y = 35;
dist = dacPointDistance(pArr, 1, 8, &p1, &p2);
printf("point 1 : %d, point 2 : %d, distance: %lf\n", p1, p2, dist);
return 0;
}
double getDistance(int x1, int y1, int x2, int y2)
{
return sqrt((double)((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
}
double dacPointDistance(Point * A, int p, int r, int * p1, int * p2)
{
double d1 = 999, d2 = 999, d3 = 999;
int q = 0;
int idx1 = 0, idx2 = 0,
idx3 = 0, idx4 = 0,
idx5 = 0, idx6 = 0;
if (p == r)
{
*p1 = p;
*p2 = p;
return 999;
}
else
{
q = (p + r) / 2;
d1 = dacPointDistance(A, p, q, &idx1, &idx2);
d2 = dacPointDistance(A, q + 1, r, &idx3, &idx4);
d3 = dacCrossingDistance(A, p, r, q, &idx5, &idx6);
if (idx1 != idx2) // 처음이 아니라면
{
int n = tripleCompare(d1, d2, d3);
switch (n)
{
case 1:
*p1 = idx1;
*p2 = idx2;
printf("point 1 : %d, point 2 : %d, distance: %lf\n", *p1, *p2, d1);
return d1;
case 2:
*p1 = idx3;
*p2 = idx4;
printf("point 1 : %d, point 2 : %d, distance: %lf\n", *p1, *p2, d2);
return d2;
case 3:
*p1 = idx5;
*p2 = idx6;
printf("point 1 : %d, point 2 : %d, distance: %lf\n", *p1, *p2, d3);
return d3;
}
}
else
{ // 점이 두개만 있는 배열일 때.
d1 = getDistance(
A[p - 1].x, A[p - 1].y,
A[r - 1].x, A[r - 1].y);
*p1 = p;
*p2 = r;
printf("point 1 : %d, point 2 : %d, distance: %lf\n", p, r, d1);
return d1;
}
}
}
double dacCrossingDistance(Point * A, int p, int r, int q, int * idx1, int * idx2)
{
int i, j;
double minDist = 999, dist = 0;
for (i = q; i >= p; i--)
{
for (j = q + 1; j <= r; j++)
{
dist = getDistance(A[i - 1].x, A[i - 1].y, A[j - 1].x, A[j - 1].y);
if (minDist > dist)
{
*idx1 = i;
*idx2 = j;
minDist = dist;
}
}
}
printf("point 1 : %d, point 2 : %d, MinDistance: %lf\n", *idx1, *idx2, minDist);
return minDist;
}
int tripleCompare(double d1, double d2, double d3)
{
if (d1 < d2)
{
if (d1 < d3)
{
return 1;
}
}
else
{
if (d2 < d3)
{
return 2;
}
}
return 3;
}
|
f79dad93e4cb217dd551af0430314e15c50e552f
|
378bfafdfe7b39bed8e316445092109bf6a19a67
|
/lib/lab03/src/fifo.cpp
|
90e19f2fa50a0bafd40e19e169ec9bbcc0163c60
|
[] |
no_license
|
alexnorell/CMPE126-Labs
|
5db9d417766538b49549bec0ffa6d5c52efd30c9
|
60a371982deb2bf48bdd24daa386500190409e7a
|
refs/heads/master
| 2020-04-03T08:37:00.096469
| 2018-05-07T18:39:19
| 2018-05-07T18:39:19
| 155,139,004
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 587
|
cpp
|
fifo.cpp
|
#include "fifo.h"
namespace lab3{
fifo::fifo() {
//Reserve 100 spaces in fifo_storage
}
fifo::fifo(std::string input_string) {
}
fifo::fifo(const fifo &original) {
}
fifo::~fifo() {
}
fifo &fifo::operator=(const fifo &right) {
//return <#initializer#>;
}
bool fifo::is_empty(){
//return false;
}
int fifo::size(){
//return 0;
}
std::string fifo::top(){
//return std::__cxx11::string();
}
void fifo::enqueue(std::string input) {
}
void fifo::dequeue() {
}
}
|
61dcd4a36e627c9dad153b9e87d20481b908995a
|
a5a99f646e371b45974a6fb6ccc06b0a674818f2
|
/DataFormats/CastorReco/interface/CastorCell.h
|
fbd8e9cb40248ff69797b99f649030b2c3621b94
|
[
"Apache-2.0"
] |
permissive
|
cms-sw/cmssw
|
4ecd2c1105d59c66d385551230542c6615b9ab58
|
19c178740257eb48367778593da55dcad08b7a4f
|
refs/heads/master
| 2023-08-23T21:57:42.491143
| 2023-08-22T20:22:40
| 2023-08-22T20:22:40
| 10,969,551
| 1,006
| 3,696
|
Apache-2.0
| 2023-09-14T19:14:28
| 2013-06-26T14:09:07
|
C++
|
UTF-8
|
C++
| false
| false
| 2,666
|
h
|
CastorCell.h
|
#ifndef CastorReco_CastorCell_h
#define CastorReco_CastorCell_h
/** \class reco::CastorCell CastorCell.h DataFormats/CastorReco/CastorCell.h
*
* Class for CastorCells made of full simulation/data
*
* \author Hans Van Haevermaet, University of Antwerp
*
*
*/
#include <vector>
#include <memory>
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/Common/interface/RefProd.h"
#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/Common/interface/RefVector.h"
namespace reco {
class CastorCell {
public:
/// default constructor. Sets energy and position to zero
CastorCell() : energy_(0.), position_(ROOT::Math::XYZPoint(0., 0., 0.)) {}
/// constructor from values
CastorCell(const double energy, const ROOT::Math::XYZPoint& position);
/// destructor
virtual ~CastorCell();
/// cell energy
double energy() const { return energy_; }
/// cell centroid position
ROOT::Math::XYZPoint position() const { return position_; }
/// comparison >= operator
bool operator>=(const CastorCell& rhs) const { return (energy_ >= rhs.energy_); }
/// comparison > operator
bool operator>(const CastorCell& rhs) const { return (energy_ > rhs.energy_); }
/// comparison <= operator
bool operator<=(const CastorCell& rhs) const { return (energy_ <= rhs.energy_); }
/// comparison <= operator
bool operator<(const CastorCell& rhs) const { return (energy_ < rhs.energy_); }
/// z coordinate of cell centroid
double z() const { return position_.z(); }
/// azimuthal angle of cell centroid
double phi() const { return position_.phi(); }
/// x coordinate of cell centroid
double x() const { return position_.x(); }
/// y coordinate of cell centroid
double y() const { return position_.y(); }
/// rho coordinate of cell centroid
double rho() const { return position_.rho(); }
/// eta coordinate of cell centroid
double eta() const { return position_.eta(); }
private:
/// cell energy
double energy_;
/// cell centroid position
ROOT::Math::XYZPoint position_;
};
/// collection of CastorCell objects
typedef std::vector<CastorCell> CastorCellCollection;
// persistent reference to CastorCell objects
typedef edm::Ref<CastorCellCollection> CastorCellRef;
/// vector of references to CastorCell objects all in the same collection
typedef edm::RefVector<CastorCellCollection> CastorCellRefVector;
/// iterator over a vector of references to CastorCell objects all in the same collection
typedef CastorCellRefVector::iterator CastorCell_iterator;
} // namespace reco
#endif
|
8db0a2a1728a6e3fa1d728c2a22b99c55c8a0f31
|
e346655ea759bb64459b6345c7be8089f06db263
|
/Maximum_function_overloading.cpp
|
69e786c2dd366cf6458328457cd01c0b5e9b578f
|
[] |
no_license
|
knight-furry/Function-overloading
|
bc9b65dce8c8d769a78ed6112d002f22ba7c4939
|
952cf1d16c89e527fff2945640fd977671e92b31
|
refs/heads/master
| 2022-12-29T05:48:48.867068
| 2020-10-14T11:00:45
| 2020-10-14T11:00:45
| 298,488,332
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,353
|
cpp
|
Maximum_function_overloading.cpp
|
#include<iostream>
using namespace std;
class Data
{
public:
int maximum(int , int);
int maximum(int *, int);
void maximum(int *, int, int);
int minimum( int , int);
int minimum( int *, int);
void minimum(int *, int, int);
};
int Data :: maximum(int m, int n)
{
if(m > n)
return m;
return n;
}
int Data :: maximum(int *a, int arraylength)
{
int i, max = a[0];
for(i = 0; i < arraylength; i++)
{
if(a[i] > max)
max = a[i];
}
return max;
}
void Data :: maximum(int *a, int arrarylength, int n)
{
int i;
cout<< "\nThe Result is:\n";
for(i = 0; i < arrarylength; i++)
{
if(a[i] > n)
{
cout<< a[i]<< "\t";
}
}
cout<< "\nThank you...!\n\n";
}
int Data :: minimum(int m, int n)
{
if(m < n)
return m;
return n;
}
int Data :: minimum(int *a, int arraylength)
{
int i, min = a[0];
for(i = 0; i < arraylength; i++)
{
if(a[i] < min)
{
min = a[i];
}
}
return min;
}
void Data :: minimum(int *a, int arrarylength, int n)
{
int i;
cout<< "\nThe Result is:\n";
for(i = 0; i < arrarylength; i++)
{
if(a[i] < n)
{
cout<< a[i]<< "\t";
}
}
cout<< "\nThank you...!\n\n";
}
int main()
{
int choice, m, n, min, max;
int arr[20];
Data d;
do
{
cout<< "\n========================Welcome to Overloading concept ===============================\n";
cout<< "\n1. Get maximum number between two numbers\n2. Get maximum number from an array\n3. Get maximum numbers from a limit number\n";
cout<< "\n4. Get minimum number between two numbers\n5. Get minimum number from an array\n6. Get minimum numbers from a limit number\n";
cout<< "0. For Exit....!\n";
cout<< "Please enter your choice: ";
cin>> choice;
switch(choice)
{
case 1:
cout<< "Enter two numbers :\n";
cin>> m>> n;
max = d.maximum(m, n);
cout<< "The maximum number is: "<< max<< "\n";
break;
case 2:
cout<< "Enter the size of array :";
cin>> n;
for(int i = 0;i < n; i++)
{
cout<< "Enter data: ";
cin>> arr[i];
}
max = d.maximum(arr, n);
cout<< "The maximum number from array is: "<< max<< "\n";
break;
case 3:
cout<< "Enter the size of array :";
cin>> n;
for(int i = 0;i < n; i++)
{
cout<< "Enter data: ";
cin>> arr[i];
}
cout<< "\nNow enter the limit value: ";
cin>> m;
d.maximum(arr, n, m);
break;
case 4:
cout<< "Enter two numbers :\n";
cin>> m>> n;
min = d.minimum(m, n);
cout<< "The minimum number is: "<< min<< "\n";
break;
case 5:
cout<< "Enter the size of array :";
cin>> n;
for(int i = 0;i < n; i++)
{
cout<< "Enter data: ";
cin>> arr[i];
}
min = d.minimum(arr, n);
cout<< "The minimum number from array is: "<< min<< "\n";
break;
case 6:
cout<< "Enter the size of array :";
cin>> n;
for(int i = 0;i < n; i++)
{
cout<< "Enter data: ";
cin>> arr[i];
}
cout<< "\nNow enter the limit value: ";
cin>> m;
d.minimum(arr, n, m);
break;
}
}while(choice != 0);
}
|
c523a3977fa4c46d464d4079b235aa4cdbdfda15
|
093b6813b0e7da9b768131dbc60732b3b9712179
|
/include/LiveProfiler/Models/Shared/SymbolName.hpp
|
97796e589cf9348097cf55b473b314428e5fd816
|
[
"MIT"
] |
permissive
|
Tifancy/live-profiler
|
d390a6c1b6a38c47b1c49f23949a15c3e0a15cee
|
f2908d1b26589d2624ccf029106fb623639c9720
|
refs/heads/master
| 2021-08-29T01:28:12.226890
| 2017-12-13T09:09:51
| 2017-12-13T09:09:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,441
|
hpp
|
SymbolName.hpp
|
#pragma once
#include <string>
#include <memory>
namespace LiveProfiler {
/**
* Represent a symbol name in the executable file.
* The originalName and path should not be empty, the demangleName can be empty.
*/
class SymbolName {
public:
/** Getters and Setters **/
const std::string& getOriginalName() const& { return originalName_; }
const std::string& getDemangleName() const& { return demangleName_; }
const std::shared_ptr<std::string>& getPath() const& { return path_; }
std::size_t getFileOffset() const { return fileOffset_; }
std::size_t getSymbolSize() const { return symbolSize_; }
void setOriginalName(const std::string& name) { originalName_ = name; }
void setDemangleName(const std::string& name) { demangleName_ = name; }
void setPath(const std::shared_ptr<std::string>& path) { path_ = path; }
void setFileOffset(std::size_t offset) { fileOffset_ = offset; }
void setSymbolSize(std::size_t size) { symbolSize_ = size; }
/** Return either the demangle name or the orignal name */
const std::string& getName() const& {
return demangleName_.empty() ? originalName_ : demangleName_;
}
/** Constructor */
SymbolName() :
originalName_(),
demangleName_(),
path_(),
fileOffset_(0),
symbolSize_(0) { }
protected:
std::string originalName_;
std::string demangleName_;
std::shared_ptr<std::string> path_;
std::size_t fileOffset_;
std::size_t symbolSize_;
};
}
|
cd4d4e1dff4628c29ffac223224d9b3967b81753
|
7f2405ecb5a66ed6e5ce5cc0c969dd0a611becfe
|
/chatroomsDlg.cpp
|
62d04e1a71896e44c8ee4bbe47b2f6075f8d569b
|
[] |
no_license
|
kxf3199/chatrooms
|
7d095f6aa0bb3065b0854f674daef812d0a5030d
|
99e01b4e3ca4b5514421c0de78d410534f770473
|
refs/heads/master
| 2021-01-20T20:15:46.046401
| 2016-07-05T15:31:40
| 2016-07-05T15:31:40
| 62,648,596
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 13,146
|
cpp
|
chatroomsDlg.cpp
|
// chatroomsDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "chatrooms.h"
#include "chatroomsDlg.h"
#include "inc.h"
#include <afxtempl.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChatroomsDlg dialog
CChatroomsDlg::CChatroomsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CChatroomsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CChatroomsDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
bShowAll=false;
m_ListenSock=INVALID_SOCKET;
m_ConnectSock=INVALID_SOCKET;
m_hListenThread=NULL;
m_hConnectThread=NULL;
m_bIsServer=-1;
bShutDown=FALSE;
}
void CChatroomsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChatroomsDlg)
DDX_Control(pDX, IDC_SHOW_MSG, m_MsgEdit);
DDX_Control(pDX, IDC_START_CLIENT, m_startclient);
DDX_Control(pDX, IDC_STOP_SEVER, m_stopsever);
DDX_Control(pDX, IDC_START_SEVER, m_startsever);
DDX_Control(pDX, IDC_STOP_CLIENT, m_stopclient);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChatroomsDlg, CDialog)
//{{AFX_MSG_MAP(CChatroomsDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_RADIO_SEVER, OnRadioSever)
ON_BN_CLICKED(IDC_NETSET, OnNetset)
ON_BN_CLICKED(IDC_START_SEVER, OnStartSever)
ON_BN_CLICKED(IDC_RADIO_CLIENT, OnRadioClient)
ON_BN_CLICKED(IDC_SENDMSG, OnSendmsg)
ON_BN_CLICKED(IDC_START_CLIENT, OnStartClient)
ON_EN_CHANGE(IDC_INPUT_MSG, OnChangeInputMsg)
ON_BN_CLICKED(IDC_STOP_CLIENT, OnStopClient)
ON_BN_CLICKED(IDC_STOP_SEVER, OnStopSever)
ON_BN_CLICKED(IDC_SHUTDOWN, OnShutdown)
ON_BN_CLICKED(IDC_OTHER, OnOther)
ON_COMMAND(ID_MENU_TRAYINCO, OnMenuTrayinco)
ON_MESSAGE(WM_TRAYICON_MSG, OnTrayCallBackMsg)
//}}AFX_MSG_MAP
ON_COMMAND(ID_MENU_EXIT, &CChatroomsDlg::OnMenuExit)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChatroomsDlg message handlers
BOOL CChatroomsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
DlgAllInit();
ExtendDlg(false);
return TRUE; // return TRUE unless you set the focus to a control
}
void CChatroomsDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CChatroomsDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CChatroomsDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CChatroomsDlg::DlgAllInit()
{
CheckRadioButton(IDC_RADIO_CLIENT,IDC_RADIO_SEVER,IDC_RADIO_CLIENT);
SetDlgItemText(IDC_IP_ADDR,"127.0.0.1");
SetDlgItemText(IDC_CONNECT_PORT,"5566");
SetDlgItemText(IDC_LISTEN_PORT,"5566");
m_stopclient.EnableWindow(false);
m_stopsever.EnableWindow(false);
m_startsever.EnableWindow(false);
//GetDlgItem(IDC_SLISTENPORT)->EnableWindow(false);
GetDlgItem(IDC_LISTEN_PORT)->EnableWindow(false);
EnableWindow(IDC_SLISTENPORT,false);
ShowMsg(_T("程序运行成功!"));
EnableWindow(IDC_SENDMSG,FALSE);
}
BOOL CChatroomsDlg::EnableWindow(UINT uID,BOOL benable)
{
return GetDlgItem(uID)->EnableWindow(benable);
}
void CChatroomsDlg::DlgClientInit()
{//点服务端选项后
((CButton *)GetDlgItem(IDC_RADIO_CLIENT))->SetCheck(true);
((CButton *)GetDlgItem(IDC_RADIO_SEVER))->SetCheck(false);
m_stopclient.EnableWindow(false);
m_stopsever.EnableWindow(false);
m_startsever.EnableWindow(false);
m_startclient.EnableWindow(true);
//GetDlgItem(IDC_SLISTENPORT)->EnableWindow(false);
GetDlgItem(IDC_LISTEN_PORT)->EnableWindow(false);
EnableWindow(IDC_SLISTENPORT,false);
EnableWindow(IDC_SLISTENPORT,true);
EnableWindow(IDC_CLISTENPORT,true);
EnableWindow(IDC_CONNECT_PORT,true);
EnableWindow(IDC_SEVERIP,true);
EnableWindow(IDC_IP_ADDR,true);
}
void CChatroomsDlg::DlgSeverInit()
{
((CButton *)GetDlgItem(IDC_RADIO_CLIENT))->SetCheck(false);
((CButton *)GetDlgItem(IDC_RADIO_SEVER))->SetCheck(true);
m_stopsever.EnableWindow(true);
m_startsever.EnableWindow(true);
//GetDlgItem(IDC_SLISTENPORT)->EnableWindow(false);
GetDlgItem(IDC_LISTEN_PORT)->EnableWindow(true);
EnableWindow(IDC_SLISTENPORT,true);
m_startclient.EnableWindow(false);
EnableWindow(IDC_CLISTENPORT,false);
EnableWindow(IDC_CONNECT_PORT,false);
EnableWindow(IDC_SEVERIP,false);
EnableWindow(IDC_IP_ADDR,false);
EnableWindow(IDC_START_SEVER, true);
EnableWindow(IDC_STOP_SEVER, false);
SetWindowText(_T("chatrooms-sever"));
}
void CChatroomsDlg::OnRadioSever()
{
// TODO: Add your control notification handler code here
DlgSeverInit();
}
void CChatroomsDlg::ExtendDlg(BOOL bShow)
{
static CRect m_DlgRectLarge(0,0,0,0);
static CRect m_DlgRectSmall(0,0,0,0);
if(m_DlgRectLarge.IsRectNull()){
//CRect rectP;
GetWindowRect(&m_DlgRectLarge);
m_DlgRectSmall=m_DlgRectLarge;
//GetDlgItem(IDC_STATIC_CHAT)->GetWindowRect(&rectP);
//ScreenToClient(&rectP);
m_DlgRectSmall.right = m_DlgRectSmall.right*0.63;
//m_DlgRectSmall.right= rectP.right+18;
}
if(bShow){
bShowAll=true;
SetWindowPos(NULL,m_DlgRectLarge.left,m_DlgRectLarge.right,m_DlgRectLarge.Width(),m_DlgRectLarge.Height(),SWP_NOZORDER|SWP_NOMOVE);
}else{
bShowAll=false;
SetWindowPos(NULL,m_DlgRectSmall.left,m_DlgRectSmall.right,m_DlgRectSmall.Width(),m_DlgRectSmall.Height(),SWP_NOZORDER|SWP_NOMOVE);
}
}
void CChatroomsDlg::OnNetset()
{
if(bShowAll){
ExtendDlg(false);
}else{
ExtendDlg(true);
}
}
void CChatroomsDlg::OnStartSever()
{
CreateThread(NULL,0,ListenThreadFunc,this,0,NULL);
}
void CChatroomsDlg::OnRadioClient()
{
DlgClientInit();
}
void CChatroomsDlg::ShowMsg(CString strMsg)
{
m_MsgEdit.SetSel(-1, -1);
m_MsgEdit.ReplaceSel(strMsg+_T("\r\n"));
}
void CChatroomsDlg::RemoveClientFromArray(CClientItem in_Item)
{
for( int idx = 0; idx <m_ClientArray.GetSize(); idx++ ) {
CClientItem tItem = m_ClientArray.GetAt(idx);
if ( tItem.m_Socket == in_Item.m_Socket &&
tItem.hThread == in_Item.hThread &&
tItem.m_strIp == in_Item.m_strIp ) {
m_ClientArray.RemoveAt(idx);
}
}
}
void CChatroomsDlg::OnSendmsg()
{
CString strMsg;
GetDlgItemText(IDC_INPUT_MSG, strMsg);
if ( m_bIsServer == TRUE ) {
strMsg = _T("服务器:>") + strMsg;
ShowMsg(strMsg);
SendClientsMsg(strMsg);
}else if (m_bIsServer == FALSE) {
CString strTmp = _T("本地客户端:>") + strMsg;
ShowMsg(strTmp);
int iSend = send(m_ConnectSock, (char *)strMsg.GetBuffer(0), strMsg.GetLength()*sizeof(TCHAR), 0);
strMsg.ReleaseBuffer();
}else {
AfxMessageBox(_T("请您先进入聊天室"));
}
SetDlgItemText(IDC_INPUT_MSG, _T(""));
}
void CChatroomsDlg::OnStartClient()
{
m_hConnectThread=CreateThread(NULL,0,ConnectThreadFunc,this,0,NULL);
EnableWindow(IDC_STOP_CLIENT,TRUE);
}
void CChatroomsDlg::SendClientsMsg(CString strMsg, CClientItem *pNotSend)
{
TCHAR szBuf[MAX_BUF_SIZE] = {0};
strncpy(szBuf, strMsg,MAX_BUF_SIZE);
for( INT_PTR idx = 0; idx < m_ClientArray.GetSize(); idx++ ) {
if ( !pNotSend || pNotSend->m_Socket != m_ClientArray.GetAt(idx).m_Socket ||pNotSend->hThread != m_ClientArray.GetAt(idx).hThread ||
pNotSend->m_strIp != m_ClientArray.GetAt(idx).m_strIp) {
send(m_ClientArray.GetAt(idx).m_Socket, (char *)szBuf, _tcslen(szBuf)*sizeof(TCHAR), 0);
}
}
}
/*
void CChatroomDlg::OnBnClickedSendmsg()
{
}
*/
void CChatroomsDlg::OnChangeInputMsg()
{
CString StrMsg;
GetDlgItemText(IDC_INPUT_MSG,StrMsg);
if (StrMsg.IsEmpty())
{EnableWindow(IDC_SENDMSG,FALSE);
}
else
{EnableWindow(IDC_SENDMSG,TRUE);
}
}
void CChatroomsDlg::StopClient()
{
bShutDown = TRUE;
EnableWindow(IDC_START_CLIENT, true);
EnableWindow(IDC_STOP_CLIENT, false);
DWORD dwRet = WaitForSingleObject(m_hConnectThread, 1000);
if ( dwRet != WAIT_OBJECT_0 ) {
TerminateThread(m_hConnectThread, -1);
closesocket(m_ConnectSock);
}
m_hConnectThread = NULL;
m_ConnectSock = INVALID_SOCKET;
m_bIsServer = -1;
bShutDown = FALSE;
}
void CChatroomsDlg::StopSever()
{
UINT nCount = m_ClientArray.GetSize();
HANDLE *m_pHandles = new HANDLE[nCount+1];
m_pHandles[0] = m_hListenThread;
for( int idx = 0; idx < nCount; idx++ ) {
m_pHandles[idx+1] = m_ClientArray.GetAt(idx).hThread;
}
bShutDown = TRUE;
EnableWindow(IDC_START_SEVER, true);
EnableWindow(IDC_STOP_SEVER, false);
DWORD dwRet = WaitForMultipleObjects(nCount+1, m_pHandles, TRUE, 1000);
if ( dwRet != WAIT_OBJECT_0 ) {
for( INT_PTR i = 0; i < m_ClientArray.GetSize(); i++ ) {
TerminateThread(m_ClientArray.GetAt(i).hThread, -1);
closesocket(m_ClientArray.GetAt(i).m_Socket);
}
TerminateThread(m_hListenThread, -1);
closesocket(m_ListenSock);
}
delete [] m_pHandles;
m_hListenThread = NULL;
m_ListenSock = INVALID_SOCKET;
m_bIsServer = -1;
bShutDown = FALSE;
}
void CChatroomsDlg::OnStopClient()
{StopClient();
ShowMsg(_T("停止客户端"));
}
void CChatroomsDlg::OnStopSever()
{
StopSever();
}
void CChatroomsDlg::OnShutdown()
{
if(m_bIsServer==TRUE)
{
StopSever();
}else if (m_bIsServer==FALSE)
{StopClient();
}else
{
OnCancel();
}
// TODO: Add your control notification handler code here
}
void CChatroomsDlg::OnOther()
{
CPoint pt;
CRect mRect;
CMenu mMenu, *pMenu = NULL;
GetDlgItem(IDC_OTHER)->GetWindowRect(&mRect);
pt = mRect.BottomRight();
pt.y = mRect.top+10;
mMenu.LoadMenu(IDR_MENU1);
pMenu = mMenu.GetSubMenu(0);
pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this);
}
BOOL CChatroomsDlg::TrayMyIcon(BOOL bAdd)
{
BOOL bRet = FALSE;
NOTIFYICONDATA tnd;
tnd.cbSize = sizeof(NOTIFYICONDATA);
tnd.hWnd = GetSafeHwnd();
tnd.uID = IDR_MAINFRAME;
if ( bAdd == TRUE ) {
tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
tnd.uCallbackMessage = WM_TRAYICON_MSG;
tnd.hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));
strncpy(tnd.szTip, _T("聊天室v1.0"), sizeof(tnd.szTip));
ShowWindow(SW_MINIMIZE);
ShowWindow(SW_HIDE);
bRet = Shell_NotifyIcon(NIM_ADD, &tnd);
}else{
ShowWindow(SW_SHOWNA);
SetForegroundWindow();
bRet = Shell_NotifyIcon(NIM_DELETE, &tnd);
}
return bRet;
}
void CChatroomsDlg::OnMenuTrayinco()
{
TrayMyIcon();
}
LRESULT CChatroomsDlg::OnTrayCallBackMsg(WPARAM wparam, LPARAM lparam)
{
switch(lparam)
{
case WM_RBUTTONUP:
{
CMenu mMenu, *pMenu = NULL;
CPoint pt;
mMenu.LoadMenu(IDR_MENU2);
pMenu = mMenu.GetSubMenu(0);
GetCursorPos(&pt);
SetForegroundWindow();
pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this);
break;
}
case WM_LBUTTONDBLCLK:
ShowWindow(SW_RESTORE);
SetForegroundWindow();
break;
default:break;
}
return NULL;
}
void CChatroomsDlg::OnMenuExit()
{
// TODO: 在此添加命令处理程序代码
OnShutdown();
}
|
e27e8300152ff95a0fa096c4d4adf0004941652a
|
7e2930716b8d87c9758d918b2474536a923a9d3f
|
/SDLut/src/Font/TTF/SDLFontExtend.cc
|
1b82c63f6f54bb5a047ecc1bfaa6420e622f2c3b
|
[
"BSD-2-Clause",
"BSD-3-Clause"
] |
permissive
|
asmodehn/sdlut
|
85749ae4463a0875e6783eaeb901c3dd2a3c1653
|
c59b9f539dccb17781bb131050adbb38e6f854ed
|
refs/heads/master
| 2023-07-09T15:54:06.740218
| 2013-10-17T14:23:14
| 2013-10-17T14:23:14
| 13,437,128
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,509
|
cc
|
SDLFontExtend.cc
|
#include "SDLFontExtend.hh"
#include "Video/internal/OpenGL/SDLGLSurface.hh"
#include "SDLConfig.hh"
using namespace Core;
namespace SDLut
{
namespace font
{
//if SDL_TTF used, provide a class to be used as a bridge.
//this way the client doesnt have to take care of which function is available
#ifdef WK_SDLut_FOUND_SDLTTF
#pragma message ("SDL_TTf Found. Compiling FontExtend.")
FontExtend::FontExtend(std::string filename, int ptsize, long index) throw (std::logic_error)
try :
FontImpl(), ptsize(ptsize), index(index),pvm_OriginalData(new system::RWOps(filename.c_str(), "rb")),pvm_ttfstruct(TTF_OpenFontIndexRW(pvm_OriginalData->get_pSDL(),0,ptsize,index))
{
if (pvm_ttfstruct == NULL)
{
throw std::logic_error("TTF_OpenFont Error : " + Optional::GetError(Optional::TTF));
}
pvm_OriginalData->seek(0,system::RWOps::Set);
}
catch (std::exception& e)
{
Log << nl << "Exception catched in internal FontExtent Constructor :" << nl <<
e.what() << std::endl;
//TODO : much more explicit error message...
}
FontExtend::FontExtend(const FontExtend & font) throw (std::logic_error)
try :
FontImpl(font), ptsize(font.ptsize), index(font.index), pvm_OriginalData(font.pvm_OriginalData.get() !=0 ? new system::RWOps(*font.pvm_OriginalData) : 0),pvm_ttfstruct(0)
{
pvm_ttfstruct = TTF_OpenFontIndexRW(pvm_OriginalData->get_pSDL(),0,ptsize,index);
if (pvm_ttfstruct == 0)
{
Log << nl << pvm_OriginalData->get_pSDL();
throw std::logic_error("TTF_OpenFont Error : " + Optional::GetError(Optional::TTF));
}
pvm_OriginalData->seek(0,system::RWOps::Set);
}
catch (std::exception& e)
{
Log << nl << "Exception catched in internal FontExtent Copy Constructor :" << nl <<
e.what() << std::endl;
//TODO : much more explicit error message...
}
FontExtend & FontExtend::operator=(const FontExtend & font) throw (std::logic_error)
{
FontImpl::operator=(font);
ptsize = font.ptsize;
index = font.index;
pvm_OriginalData.reset(font.pvm_OriginalData.get() !=0 ? new system::RWOps(*font.pvm_OriginalData) : 0 );
pvm_ttfstruct = TTF_OpenFontIndexRW(pvm_OriginalData->get_pSDL(),0,ptsize,index);
pvm_OriginalData->seek(0,system::RWOps::Set);
if (pvm_ttfstruct == 0)
{
throw std::logic_error("TTF_OpenFont Error : " + Optional::GetError(Optional::TTF));
}
return *this;
}
FontExtend::~FontExtend()
{
TTF_CloseFont(pvm_ttfstruct);
}
std::auto_ptr<video::internal::RGBSurface> FontExtend::render(const std::string& text, video::Color c, video::Color bgc, Font::RenderMode mode) const
{
std::auto_ptr<SDL_Surface> surf;
switch ( mode )
{
case Font::Blended :
surf.reset(TTF_RenderText_Blended(pvm_ttfstruct,text.c_str(), c.get_SDL()));
break;
case Font::Shaded :
surf.reset(TTF_RenderText_Shaded(pvm_ttfstruct,text.c_str(),c.get_SDL(), bgc.get_SDL()));
break;
case Font::Solid :
default:
surf.reset(TTF_RenderText_Solid(pvm_ttfstruct,text.c_str(), c.get_SDL()));
break;
}
video::internal::OGL::GLSurface * glsurf = new video::internal::OGL::GLSurface (surf);
//glsurf->saveBMP( text + "_fext.bmp" );
//beware : auto_ptr ownership transferred ;)
std::auto_ptr<video::internal::RGBSurface> result(glsurf );
//result->saveBMP ( text + "_fextres.bmp");
return result;
}
//Attributes Access
void FontExtend::byteSwapUNICODE(bool swapped)
{
TTF_ByteSwappedUNICODE(swapped);
}
Font::Style FontExtend::getStyle()
{
switch (TTF_GetFontStyle(pvm_ttfstruct))
{
case TTF_STYLE_NORMAL :
return Font::Normal;
break;
case TTF_STYLE_BOLD :
return Font::Bold;
break;
case TTF_STYLE_ITALIC :
return Font::Italic;
break;
case TTF_STYLE_UNDERLINE :
return Font::Underline;
break;
}
return Font::Default;
}
void FontExtend::setStyle(Font::Style s)
{
switch (s)
{
case Font::Normal :
TTF_SetFontStyle(pvm_ttfstruct,TTF_STYLE_NORMAL);
break;
case Font::Bold :
TTF_SetFontStyle(pvm_ttfstruct,TTF_STYLE_BOLD);
break;
case Font::Italic :
TTF_SetFontStyle(pvm_ttfstruct,TTF_STYLE_ITALIC);
break;
case Font::Underline :
TTF_SetFontStyle(pvm_ttfstruct,TTF_STYLE_UNDERLINE);
break;
case Font::Default : //TODO : Implement using parent class
default :
break;
}
}
int FontExtend::height()
{
return TTF_FontHeight(pvm_ttfstruct);
}
int FontExtend::ascent()
{
return TTF_FontAscent(pvm_ttfstruct);
}
int FontExtend::descent()
{
return TTF_FontDescent(pvm_ttfstruct);
}
int FontExtend::lineskip()
{
return TTF_FontLineSkip(pvm_ttfstruct);
}
long FontExtend::faces()
{
return TTF_FontFaces(pvm_ttfstruct);
}
bool FontExtend::faceIsFixedWidth()
{
return TTF_FontFaceIsFixedWidth(pvm_ttfstruct) != 0 ;
}
std::string FontExtend::faceFamilyName()
{
return std::string( TTF_FontFaceFamilyName(pvm_ttfstruct) );
}
std::string FontExtend::faceStyleName()
{
return std::string( TTF_FontFaceStyleName(pvm_ttfstruct) );
}
video::Rect FontExtend::getSize(const std::string & text) const
{
int w,h;
int test = TTF_SizeText(pvm_ttfstruct,text.c_str(),&w,&h);
if (!test) //success
return video::Rect(0,0,w,h);
//failure
Log << nl << Optional::GetError(Optional::TTF);
return video::Rect(0,0,0,0);
}
#endif //WK_SDLut_FOUND_SDLTTF
}
}
|
eb030b0ec00d4bb24197e0c04db01da05429d30d
|
d3ec57c11fe40b4c9c4949f56917fe768c370c31
|
/SpriteSheet.cpp
|
df251a0897d644a5777261c4aadeff2215bea39c
|
[] |
no_license
|
zjleblanc/PirateGame
|
88ba0d8b873aabe9730e395c440b5e69d9f07c49
|
7eea696abb9a3d29ce6aab7a00389b53b868ca3f
|
refs/heads/master
| 2016-09-15T19:05:27.581581
| 2014-05-01T01:24:28
| 2014-05-01T01:24:28
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,225
|
cpp
|
SpriteSheet.cpp
|
#include "SpriteSheet.h"
#include "SDL_image.h"
#include "SDL.h"
// CONSTRUCTOR
SpriteSheet::SpriteSheet(string fileName) {
path = fileName;
sheet = loadSheet();
}
// DECONSTRUCTOR
SpriteSheet::~SpriteSheet() {
SDL_FreeSurface(sheet);
}
// PUBLIC METHODS
bool SpriteSheet::operator==(const SpriteSheet& testSheet) const { // used for sprite equivalence checking
if(!path.compare(testSheet.path)) {
return true;
}
return false;
}
// GETTERS AND SETTERS
SDL_Surface* SpriteSheet::getSurface() { // returns the sheet's surface, used to render sprites individually
return sheet;
}
string SpriteSheet::getPath() {
return path;
}
// PRIVATE METHODS
SDL_Surface* SpriteSheet::loadSheet() { // loads images of any format and returns a pointer to it, run upon instantiation
SDL_Surface* loadedImage = NULL;
SDL_Surface* optImage = NULL;
loadedImage = IMG_Load(path.c_str());
if(loadedImage != NULL) {
optImage = SDL_DisplayFormat(loadedImage);
SDL_FreeSurface(loadedImage);
}
if(optImage) { // colorkeying of FF00FF is run upon loading
colorkey = SDL_MapRGB(optImage->format, 0xFF, 0x00, 0xFF);
SDL_SetColorKey(optImage, SDL_SRCCOLORKEY, colorkey);
}
return optImage;
}
|
53212b3d12119a0d9ef801b91b008af55a9d5a6b
|
8067bf4fdd3d9dcbaee2fd4fe98ca3c26132c2a3
|
/libsolidity/inlineasm/AsmData.h
|
0361a4c2c18aa1367cab371f2acca646166bb1c7
|
[
"MIT"
] |
permissive
|
AlwaysBCoding/solidity
|
d7ab5c4eff022f90825e5b6205937c36f074eb42
|
c492d9be00c843b8390959bd9f203c4047cb9f69
|
refs/heads/develop
| 2021-01-13T06:10:37.159465
| 2016-03-31T23:31:15
| 2016-03-31T23:31:15
| 55,323,559
| 2
| 1
| null | 2016-04-03T01:05:48
| 2016-04-03T01:05:47
| null |
UTF-8
|
C++
| false
| false
| 2,385
|
h
|
AsmData.h
|
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @author Christian <c@ethdev.com>
* @date 2016
* Parsed inline assembly to be used by the AST
*/
#pragma once
#include <boost/variant.hpp>
#include <libevmcore/Instruction.h>
namespace dev
{
namespace solidity
{
namespace assembly
{
/// What follows are the AST nodes for assembly.
/// Direct EVM instruction (except PUSHi and JUMPDEST)
struct Instruction { eth::Instruction instruction; };
/// Literal number or string (up to 32 bytes)
struct Literal { bool isNumber; std::string value; };
/// External / internal identifier or label reference
struct Identifier { std::string name; };
struct FunctionalInstruction;
/// Jump label ("name:")
struct Label { std::string name; };
/// Assignemnt (":= x", moves stack top into x, potentially multiple slots)
struct Assignment { Identifier variableName; };
struct FunctionalAssignment;
struct VariableDeclaration;
struct Block;
using Statement = boost::variant<Instruction, Literal, Label, Assignment, Identifier, FunctionalAssignment, FunctionalInstruction, VariableDeclaration, Block>;
/// Functional assignment ("x := mload(20)", expects push-1-expression on the right hand
/// side and requires x to occupy exactly one stack slot.
struct FunctionalAssignment { Identifier variableName; std::shared_ptr<Statement> value; };
/// Functional instruction, e.g. "mul(mload(20), add(2, x))"
struct FunctionalInstruction { Instruction instruction; std::vector<Statement> arguments; };
/// Block-scope variable declaration ("let x := mload(20)"), non-hoisted
struct VariableDeclaration { std::string name; std::shared_ptr<Statement> value; };
/// Block that creates a scope (frees declared stack variables)
struct Block { std::vector<Statement> statements; };
}
}
}
|
87351c87efa02c4ab7493d9b1d1e4a583c134f6f
|
d142829a061b5418d582c2dc39326ceffad3734e
|
/reverselist/reverselist.cpp
|
ccfcfbb400e8d7e8894c79ad26cc77da84f782fd
|
[] |
no_license
|
Cauahu/hihoCoder-training
|
662f3ac531916e1b4613ea5645a7fca130559156
|
252f327c3f8ec803721f35b1d65204dde93c4b31
|
refs/heads/master
| 2021-01-15T15:32:30.308033
| 2016-08-08T02:48:28
| 2016-08-08T02:48:28
| 54,168,241
| 0
| 1
| null | 2020-10-02T05:30:02
| 2016-03-18T02:44:41
|
C++
|
UTF-8
|
C++
| false
| false
| 858
|
cpp
|
reverselist.cpp
|
#include <iostream>
#include <vector>
using namespace std;
struct ListNode{
int val;
struct ListNode *next;
};
vector<int> printListFromTaillToHead(struct ListNode* head){
struct ListNode *p = head->next, *p_next = p->next;
head->next = NULL;
while(p_next != NULL)
{
p->next = head->next;
head->next = p;
p = p_next;
p_next = p->next;
}
p->next = head->next;
head->next = p;
vector<int > vp;
p = head->next;
while(p != NULL)
{
vp.push_back(p->val);
p = p->next;
}
return vp;
}
int main(){
struct ListNode * head = new ListNode;
head->next = NULL;
int i = 0;
while(i < 10){
struct ListNode *tmp = new ListNode;
tmp->val = i;
tmp->next = head->next;
head->next = tmp;
i++;
}
vector<int> vp = printListFromTaillToHead(head);
while(!vp.empty()){
cout << vp.back() << " ";
vp.pop_back();
}
return 0;
}
|
add712693c0ab8440363ed36e921f000cb224faa
|
9f51d7ba7e5455dbb3cc39cc114d0d2f1796a133
|
/src/storage_pool.h
|
526c68ba270e8446d0d8350e6360fd90818e1c21
|
[
"MIT"
] |
permissive
|
GaikwadPratik/node-libvirt
|
c2eee7bb37f8be0e9641adbc83798e8a71a182a1
|
6d0d6a08851e33ba02629bbfa601358180095c7c
|
refs/heads/master
| 2020-03-24T11:22:28.016141
| 2019-01-09T16:59:16
| 2019-01-09T16:59:16
| 142,683,585
| 0
| 1
| null | 2018-12-19T23:54:01
| 2018-07-28T14:26:29
|
C++
|
UTF-8
|
C++
| false
| false
| 3,543
|
h
|
storage_pool.h
|
// Copyright 2010, Camilo Aguilar. Cloudescape, LLC.
#ifndef STORAGE_POOL_H
#define STORAGE_POOL_H
#include "nlv_object.h"
#include "nlv_async_worker.h"
#include "worker_macros.h"
#include "hypervisor.h"
namespace NLV {
struct StoragePoolCleanupHandler {
static int cleanup(virStoragePoolPtr handle) {
return virStoragePoolFree(handle);
}
};
class StoragePool : public NLVObject<StoragePool, virStoragePoolPtr, StoragePoolCleanupHandler>
{
public:
static void Initialize(Handle<Object> exports);
NLV_OBJECT_STATIC_HELPERS(StoragePool);
private:
explicit StoragePool(virStoragePoolPtr handle);
static Nan::Persistent<FunctionTemplate> constructor_template;
static Nan::Persistent<Function> constructor;
friend class StorageVolume;
friend class Hypervisor;
private:
// HYPERVISOR METHODS
static NAN_METHOD(LookupByName);
static NAN_METHOD(LookupByUUID);
static NAN_METHOD(LookupByVolume);
static NAN_METHOD(Define);
static NAN_METHOD(Create);
// ACTIONS
static NAN_METHOD(Build);
static NAN_METHOD(Undefine);
static NAN_METHOD(Start);
static NAN_METHOD(Stop);
static NAN_METHOD(Erase);
static NAN_METHOD(Refresh);
// ACCESSORS/MUTATORS
static NAN_METHOD(GetAutostart);
static NAN_METHOD(SetAutostart);
static NAN_METHOD(GetInfo);
static NAN_METHOD(GetName);
static NAN_METHOD(GetUUID);
static NAN_METHOD(ToXml);
static NAN_METHOD(IsActive);
static NAN_METHOD(IsPersistent);
static NAN_METHOD(GetVolumes);
private:
// HYPERVISOR METHOD WORKERS
NLV_LOOKUP_BY_VALUE_WORKER(LookupByName, StoragePool, Hypervisor, virStoragePoolPtr);
NLV_LOOKUP_BY_VALUE_WORKER(LookupByUUID, StoragePool, Hypervisor, virStoragePoolPtr);
NLV_LOOKUP_BY_VALUE_WORKER(Define, StoragePool, Hypervisor, virStoragePoolPtr);
NLV_LOOKUP_BY_VALUE_WORKER(Create, StoragePool, Hypervisor, virStoragePoolPtr);
// METHOD WORKERS
NLV_PRIMITIVE_RETURN_WORKER(Build, virStoragePoolPtr, bool);
NLV_PRIMITIVE_RETURN_WORKER(Undefine, virStoragePoolPtr, bool);
NLV_PRIMITIVE_RETURN_WORKER(Start, virStoragePoolPtr, bool);
NLV_PRIMITIVE_RETURN_WORKER(Stop, virStoragePoolPtr, bool);
NLV_PRIMITIVE_RETURN_WORKER(Refresh, virStoragePoolPtr, bool);
class EraseWorker : public NLVPrimitiveReturnWorker<virStoragePoolPtr, bool> {
public:
EraseWorker(Nan::Callback *callback, virStoragePoolPtr handle, unsigned int flags)
: NLVPrimitiveReturnWorker<virStoragePoolPtr, bool>(callback, handle), flags_(flags) {}
void Execute();
private:
unsigned int flags_;
};
// ACCESSORS/MUTATORS WORKERS
NLV_PRIMITIVE_RETURN_WORKER(GetAutostart, virStoragePoolPtr, bool);
NLV_STRING_RETURN_WORKER(GetName, virStoragePoolPtr, std::string);
NLV_STRING_RETURN_WORKER(GetUUID, virStoragePoolPtr, std::string);
NLV_STRING_RETURN_WORKER(ToXml, virStoragePoolPtr, std::string);
NLV_PRIMITIVE_RETURN_WORKER(IsActive, virStoragePoolPtr, bool);
NLV_PRIMITIVE_RETURN_WORKER(IsPersistent, virStoragePoolPtr, bool);
NLV_OBJECT_RETURN_WORKER(GetInfo, virStoragePoolPtr, virStoragePoolInfo);
NLV_STRING_LIST_RETURN_WORKER(GetVolumes, virStoragePoolPtr, std::string, v8::String);
class SetAutostartWorker : public NLVPrimitiveReturnWorker<virStoragePoolPtr, bool> {
public:
SetAutostartWorker(Nan::Callback *callback, virStoragePoolPtr handle, bool autoStart)
: NLVPrimitiveReturnWorker<virStoragePoolPtr, bool>(callback, handle), autoStart_(autoStart) {}
void Execute();
private:
bool autoStart_;
};
};
} //namespace NLV
#endif // STORAGE_POOL_H
|
9a74682349cc1473bbfd0d0ad651dcb52bd8dd6e
|
d61d05748a59a1a73bbf3c39dd2c1a52d649d6e3
|
/chromium/third_party/blink/renderer/core/css/properties/longhands/zoom_custom.cc
|
269a6107887bb579ab301c893164abdce676701b
|
[
"LGPL-2.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"BSD-3-Clause",
"MIT",
"Apache-2.0"
] |
permissive
|
Csineneo/Vivaldi
|
4eaad20fc0ff306ca60b400cd5fad930a9082087
|
d92465f71fb8e4345e27bd889532339204b26f1e
|
refs/heads/master
| 2022-11-23T17:11:50.714160
| 2019-05-25T11:45:11
| 2019-05-25T11:45:11
| 144,489,531
| 5
| 4
|
BSD-3-Clause
| 2022-11-04T05:55:33
| 2018-08-12T18:04:37
| null |
UTF-8
|
C++
| false
| false
| 3,146
|
cc
|
zoom_custom.cc
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/css/properties/longhands/zoom.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
#include "third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h"
#include "third_party/blink/renderer/core/frame/use_counter.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
namespace blink {
namespace css_longhand {
const CSSValue* Zoom::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
const CSSParserToken& token = range.Peek();
CSSValue* zoom = nullptr;
if (token.GetType() == kIdentToken) {
zoom = css_property_parser_helpers::ConsumeIdent<CSSValueNormal>(range);
} else {
zoom = css_property_parser_helpers::ConsumePercent(range,
kValueRangeNonNegative);
if (!zoom) {
zoom = css_property_parser_helpers::ConsumeNumber(range,
kValueRangeNonNegative);
}
}
if (zoom) {
if (!(token.Id() == CSSValueNormal ||
(token.GetType() == kNumberToken &&
ToCSSPrimitiveValue(zoom)->GetDoubleValue() == 1) ||
(token.GetType() == kPercentageToken &&
ToCSSPrimitiveValue(zoom)->GetDoubleValue() == 100)))
context.Count(WebFeature::kCSSZoomNotEqualToOne);
}
return zoom;
}
const CSSValue* Zoom::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const SVGComputedStyle&,
const LayoutObject*,
Node*,
bool allow_visited_style) const {
return CSSPrimitiveValue::Create(style.Zoom(),
CSSPrimitiveValue::UnitType::kNumber);
}
void Zoom::ApplyInitial(StyleResolverState& state) const {
state.SetZoom(ComputedStyleInitialValues::InitialZoom());
}
void Zoom::ApplyInherit(StyleResolverState& state) const {
state.SetZoom(state.ParentStyle()->Zoom());
}
void Zoom::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
SECURITY_DCHECK(value.IsPrimitiveValue() || value.IsIdentifierValue());
if (value.IsIdentifierValue()) {
const CSSIdentifierValue& identifier_value = ToCSSIdentifierValue(value);
if (identifier_value.GetValueID() == CSSValueNormal) {
state.SetZoom(ComputedStyleInitialValues::InitialZoom());
}
} else if (value.IsPrimitiveValue()) {
const CSSPrimitiveValue& primitive_value = ToCSSPrimitiveValue(value);
if (primitive_value.IsPercentage()) {
if (float percent = primitive_value.GetFloatValue())
state.SetZoom(percent / 100.0f);
else
state.SetZoom(1.0f);
} else if (primitive_value.IsNumber()) {
if (float number = primitive_value.GetFloatValue())
state.SetZoom(number);
else
state.SetZoom(1.0f);
}
}
}
} // namespace css_longhand
} // namespace blink
|
2bf5df14d427258880f3d44ed3768b992ad8dcce
|
2be6caa86d197fc36328d9bd8575dd4bdd399bbc
|
/vugc2_control/src/steering.ino
|
9ccbee8a83a9d8a23b9ece9afb70c33fab71c7ef
|
[] |
no_license
|
vugolfcart/vugc2
|
c214673de668e3d0e8dc4ccba45db4b95ffdec6d
|
5a04dcdf176aba028cf7573e2914b66959fc8464
|
refs/heads/master
| 2020-05-18T16:42:35.354492
| 2020-02-29T16:39:31
| 2020-02-29T16:39:31
| 184,533,391
| 0
| 0
| null | 2020-02-29T16:39:33
| 2019-05-02T06:40:57
|
Python
|
UTF-8
|
C++
| false
| false
| 1,330
|
ino
|
steering.ino
|
#include <ArduinoHardware.h>
#include <Wire.h>
#include <Adafruit_MCP4725.h>
#include <ros.h>
#include <vugc2_control/Steering.h>
#include <std_msgs/String.h>
// 12 bit DAC
Adafruit_MCP4725 T1;
Adafruit_MCP4725 T2;
int TRQ_CENTER = 2048; // 2.5V
int TRQ_LOWER = 0; // 0V
int TRQ_HIGHER = 4095; // 12 bits 5V
vugc2_control::Steering prev;
void messageSteer(const vugc2_control::Steering &trq);
// ROS
ros::NodeHandle nh;
ros::Subscriber<vugc2_control::Steering> vugc1_control_torque_parameters("vugc2_control_torque_parameters", &messageSteer);
void messageSteer(const vugc2_control::Steering &trq) {
vugc2_control::Steering safe;
safe.torque1 = min(TRQ_HIGHER, max(TRQ_LOWER, trq.torque1));
safe.torque2 = min(TRQ_HIGHER, max(TRQ_LOWER, trq.torque2));
T1.setVoltage(safe.torque1, false);
T2.setVoltage(safe.torque2, false);
delay(50);
// reset to center
T1.setVoltage(TRQ_CENTER, false);
T2.setVoltage(TRQ_CENTER, false);
prev.torque1 = safe.torque1;
prev.torque2 = safe.torque2;
}
void setup() {
Serial.begin(9600);
T1.begin(0x62);
T2.begin(0x63);
T1.setVoltage(TRQ_CENTER, false);
T2.setVoltage(TRQ_CENTER, false);
nh.initNode();
nh.subscribe(vugc1_control_torque_parameters);
prev.torque1 = TRQ_CENTER;
prev.torque2 = TRQ_CENTER;
}
void loop() {
nh.spinOnce();
}
|
536eac7fa74566331829d55d3f0aa9b7d2152962
|
0be22da878ab8b5f6f3608b4d5296bf9759421ea
|
/CIS 350/CIS350P1/Source.cpp
|
387e797a79f563b902eeb9f48f9102f558e23b85
|
[] |
no_license
|
holajason/SchoolProjects
|
342f0741c32bbe44939a4bd73b57b13188b2476f
|
f55a46ea8955ee7c2705e0148387a8637f78d899
|
refs/heads/master
| 2020-06-23T07:36:46.437680
| 2019-08-21T22:14:23
| 2019-08-21T22:14:23
| 198,558,265
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,657
|
cpp
|
Source.cpp
|
//
// nagagram.cpp
// nagagram
//
// Created by Jason Lu on 1/30/18.
// Copyright ?2018 Jason Lu. All rights reserved.
//
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
class EquiClassess
{
private:
vector<vector<string>>classes;
vector<string>temp;
public:
// The function will sort the list by its size
// If the class size is less than the next class, swap the classes
//Precondition
//PostCondition : classes will be sorted by the size
static bool sortList(const vector<string>& list1, const vector<string>& list2)
{
return list1.size() > list2.size();
}
//The function will sort the classes in alphabetical order
//PreCondition:
//PostCondition: Every classes/row will be sorted in alphabetical order
static bool sortWord(const vector<string>& word1, const vector<string>& word2)
{
return word1 < word2;
}
// The function will determine if the word entered are ananagram to any exitence word
//PreCondition: Determine if both word are anagram by the length of each word by their
// length and characters in the word
//PostCondition: Check if both word are equally match to each other after sorting
bool isAnagram(string word1, string word2)
{
//Check if both word have the same length
if (word1.length() != word2.length())
{
return false;
}
// If both word have the same length
if (word1.length() == word2.length())
{
// Using the build in sort function to sort both word
// into alphabetical order
sort(word1.begin(), word1.end());
sort(word2.begin(), word2.end());
//If both word have the same characters, return true
if (word1 == word2)
{
return true;
}
}
return false;
}
// The function is pass by reference and accept the word from the user
//PreCondition: The word will push into the same class if the length and the word
//are equally match after sorted
//PostCondition: Once both word are anagram, push the word into the same class
void add(string word)
{
//This is used to clear the list after the user enter a word
temp.clear();
//Push_back is used to add the word in the back of the list
temp.push_back(word);
//This for loop is used to check if the word enter are
//anagram to any other word in the classes
for (unsigned int i = 0; i < classes.size(); i++)
{
//Set the first word in the class as an comparison word
string word2 = classes[i][0];
if (isAnagram(word, word2))
{
//If the word enter match the word in the list
//push the entered word into the class
classes[i].push_back(word);
return;
}
}
// If no match of the word is found inside any of those
//classes, create a new class to store the word
classes.push_back(temp);
}
//The function is pass by reference, it will dipslay
//the number of classes of the anagram that the user enter
//PreCondition: The classes not empty, num2Print >= 0 and num2Print <= classes size
//PostCondition: The function will print the number of classes that
//the user enter or the maximum size of the classes
void print(unsigned long num2Print)
{
//If the user enter the number to print is greater the class size,
//set num2Print equal to the class size
if (num2Print > classes.size())
{
num2Print = classes.size();
}
// Using a nested for loop to print the number of classes
// and and the word inside of the classes;
for (unsigned int i = 0; i < num2Print; i++) {
{
cout << "Class of size " << classes[i].size() << ": ";
// sort the word inside the classes
sort(classes[i].begin(), classes[i].end());
//Another for loop is used to print the word inside the class
for (unsigned int j = 0; j < classes[i].size(); j++) {
//print the in the classes will print in 2d vector
cout << classes[i][j] << " ";
}
cout << "." << endl;
}
}
}
// This function is used to sort the classes, by its size or
//equivalence classes size, sort the member words in lexicographically
//PreCondition
//PostCondition: The list will be sort by the size of the class and the row
// will be sort in alphabtical order
void sortClasses()
{
//check for duplicate word by using build in algorithm "unique"
unique(classes.begin(), classes.end());
for (unsigned int i = 0; i < classes.size(); i++)
{
//Resize the list of the class, from the beginning of the class
//to the unqiue/dupicate word, and from the duplicate to the end
//the duplicate word will only print out once
classes[i].resize(distance(classes[i].begin(), unique(classes[i].begin(), classes[i].end())));
}
//This function will sort the classes in alphabetical order
sort(classes.begin(), classes.end(), sortWord);
//This function will sort the size of the classes
sort(classes.begin(), classes.end(), sortList);
}
};
//PreCondition: The program will determines if the word anagram, and then it will
//print out the class of the anagram by the size of the classes, the class will also be
//sorted into alphabetical order
//PostCodition: The program will accept input and display the output by the size
//of the class in sorted order
int main()
{
EquiClassess anagram;
string word;
int numString, num2Print;
//ask the user for the number of word to consider
// and the number of classes to print
cin >> numString;
cin >> num2Print;
//number of word to consider
for (int i = 0; i < numString; i++)
{
cin >> word;
//calls the add function, push the word into the temporary vector
anagram.add(word);
}
//call the sort function class
anagram.sortClasses();
//display the word from the classes vector
anagram.print(num2Print);
return 0;
}
|
23231d296cb7536aa2ff1271f3132e26378f96eb
|
e7aeb9c49f0d35caa1cea7f416ee1d238c8a2426
|
/HDUOJ/HDU2010-水仙花数.cpp
|
a1296e406801980851384539515544ff91211d6a
|
[] |
no_license
|
protectors/ACM
|
1ee0c2ade796c5bda80fc0551647661c2b40c65a
|
a9b33912d8763c6af37fbbae4135b2761a69a2a8
|
refs/heads/master
| 2022-07-26T13:57:40.590234
| 2022-06-21T03:41:13
| 2022-06-21T03:41:13
| 85,793,349
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 841
|
cpp
|
HDU2010-水仙花数.cpp
|
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int m,n,t,flag,i,a[1010],b,c,d,first;
memset(a,0,sizeof(a));
for(i=100;i<=999;i++)
{
b=i/100;
c=i/10%10;
d=i%10;
if(i==b*b*b+c*c*c+d*d*d)
a[i]=1;
}
while(cin>>m>>n)
{
flag=0;
first=1;
if(m>n)
{
t=m;
m=n;
n=t;
}
for(i=m;i<=n;i++)
{
if(a[i]==1)
{
if(first)
first=0;
else
cout<<" ";
flag=1;
cout<<i;
}
}
if(flag)
cout<<endl;
else
cout<<"no\n";
}
return 0;
}
|
0042223ce6ccfaf9ebc4a6871f7e3656401988cf
|
45b286742deac8638ec06e00c888e9554f5637d4
|
/libraries/libym_mincov/ym_mincov/MincovSolver.h
|
ba7a47de02a8b3c36b9a518d689833c510cb9099
|
[] |
no_license
|
yusuke-matsunaga/minimaleda
|
0800200f42474a2dbe08d94d977678d67ee085d1
|
e0619bfd34baf3ca27c23d2f705067297209104a
|
refs/heads/master
| 2021-01-20T20:03:15.199896
| 2016-08-02T03:43:11
| 2016-08-02T03:43:11
| 64,721,871
| 5
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,943
|
h
|
MincovSolver.h
|
#ifndef YM_MINCOV_MINCOVSOLVER_H
#define YM_MINCOV_MINCOVSOLVER_H
/// @file ym_mincov/MincovSolver.h
/// @brief MincovSolver のヘッダファイル
/// @author Yusuke Matsunaga (松永 裕介)
///
/// $Id: MincovSolver.h 2507 2009-10-17 16:24:02Z matsunaga $
///
/// Copyright (C) 2005-2010 Yusuke Matsunaga
/// All rights reserved.
#include "ym_mincov/mincov_nsdef.h"
BEGIN_NAMESPACE_YM_MINCOV
class MincovCost;
//////////////////////////////////////////////////////////////////////
/// @class MincovSolver MincovSolver.h <ym_mincov/MincovSolver.h>
/// @brief 最小被覆問題を解くクラス
//////////////////////////////////////////////////////////////////////
class MincovSolver
{
public:
/// @brief コンストラクタ
MincovSolver();
/// @brief デストラクタ
~MincovSolver();
public:
/// @brief 最小被覆問題を解く.
/// @param[in] matrix 対象の行列
/// @param[out] solution 選ばれた列集合
/// @return 最良解
MincovCost
operator()(const MincovMatrix& matrix,
vector<ymuint32>& solution);
private:
/// @brief 解を求める再帰関数
/// @param[in] matrix 対象の行列
/// @param[in] best_sofar 現時点の最良解
/// @param[out] solution 選ばれた列集合
/// @return 最良解
MincovCost
solve(MincovMatrix& matrix,
const MincovCost& best_sofar,
vector<ymuint32>& solution);
/// @brief 下限を求める.
/// @param[in] matrix 対象の行列
/// @return 下限値
MincovCost
lower_bound(MincovMatrix& matrix);
/// @brief 簡単化を行う.
/// @param[in] matrix 対象の行列
/// @param[out] selected_cols 簡単化中で選択された列の集合
void
reduce(MincovMatrix& matrix,
vector<ymuint32>& selected_cols);
/// @brief 行支配を探し,行を削除する.
/// @param[in] matrix 対象の行列
/// @return 削除された行があったら true を返す.
bool
row_dominance(MincovMatrix& matrix);
/// @brief 列支配を探し,列を削除する.
/// @param[in] matrix 対象の行列
/// @return 削除された列があったら true を返す.
bool
col_dominance(MincovMatrix& matrix);
/// @brief 必須列を探し,列を選択する.
/// @param[in] matrix 対象の行列
/// @param[out] selected_cols 選択された列を追加する列集合
/// @return 選択された列があったら true を返す.
bool
essential_col(MincovMatrix& matrix,
vector<ymuint32>& selected_cols);
private:
//////////////////////////////////////////////////////////////////////
// データメンバ
//////////////////////////////////////////////////////////////////////
};
//////////////////////////////////////////////////////////////////////
// インライン関数の定義
//////////////////////////////////////////////////////////////////////
END_NAMESPACE_YM_MINCOV
#endif // YM_MINCOV_MINCOVMATRIX_H
|
d345f75061f0f8e1ab59fec1629acd7a680a744f
|
5c13d48ab1ca025820bb1fad7c07011cfc407bff
|
/mySqrt.cpp
|
d923e7b64a447a54a32cde39cc4f1f8a7390861a
|
[] |
no_license
|
Saki-Zhang/LeetCode
|
1d628c8712a0207ea713f232ba8fc39169ccee12
|
3688760ca116a5e639070793bd55039e15628b8d
|
refs/heads/master
| 2023-04-18T03:18:07.590182
| 2021-05-08T19:38:19
| 2021-05-08T19:38:19
| 283,374,988
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 541
|
cpp
|
mySqrt.cpp
|
// 69. Sqrt(x)
// https://leetcode.com/problems/sqrtx/
class Solution {
public:
int mySqrt(int x) {
if(x <= 1) {
return x;
}
int l = 2;
int h = x / 2;
while(l <= h) {
long m = l + (h - l) / 2;
if(m * m == x) {
return m;
}
else if(m * m < x) {
l = m + 1;
}
else {
h = m - 1;
}
}
return h;
}
};
|
d11d993ef7ab462d7f939459525b09daf0ebab90
|
18f686a3f56c1fc8e93a4bf42f7696252a494282
|
/Pascal_sTriangle.cpp
|
af5bb2cb7a12403dd0b82a03045bacff417a672e
|
[] |
no_license
|
husscc/leetcode
|
7086ce9556f1504a28116b8bffb1f884b266d8cf
|
447fd969e35da7f691cc6a900021954d24945d23
|
refs/heads/master
| 2021-01-10T21:08:33.264124
| 2013-01-28T15:58:40
| 2013-01-28T15:58:40
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 696
|
cpp
|
Pascal_sTriangle.cpp
|
/*
Given numRows, generate the first numRows of Pascal's triangle.
For example, given numRows = 5,
Return
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]
*/
class Solution {
public:
vector<vector<int> > generate(int numRows) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector<vector<int> > res;
if(numRows<1)
return res;
res.push_back(vector<int>(1,1));
vector<int> currow;
for(int i=1;i<numRows;i++){
currow.clear();
currow.push_back(1);
for(int j=1;j<i;j++)
currow.push_back(res[i-1][j-1]+res[i-1][j]);
currow.push_back(1);
res.push_back(currow);
}
return res;
}
};
|
d6805c5bb6ad2c98f0f035bc2a612a72c77967f4
|
9fd0b6465570129c86f4892e54da27d0e9842f9b
|
/src/runtime/libc++/test/iterators/stream.iterators/ostream.iterator/types.pass.cpp
|
460da642bc6ed4912cf317fec92ca8fa7017433e
|
[
"BSL-1.0"
] |
permissive
|
metta-systems/metta
|
cdbdcda872c5b13ae4047a7ceec6c34fc6184cbf
|
170dd91b5653626fb3b9bfab01547612efe531c5
|
refs/heads/develop
| 2022-04-06T07:25:16.069905
| 2020-02-17T08:22:10
| 2020-02-17T08:22:10
| 6,562,050
| 39
| 11
|
BSL-1.0
| 2019-02-22T08:53:20
| 2012-11-06T12:54:03
|
C++
|
UTF-8
|
C++
| false
| false
| 1,635
|
cpp
|
types.pass.cpp
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <iterator>
// template <class T, class charT = char, class traits = char_traits<charT>,
// class Distance = ptrdiff_t>
// class ostream_iterator
// : public iterator<output_iterator_tag, void, void, void, void>
// {
// public:
// typedef charT char_type;
// typedef traits traits_type;
// typedef basic_istream<charT,traits> istream_type;
// ...
#include <iterator>
#include <type_traits>
int main()
{
typedef std::ostream_iterator<double> I1;
static_assert((std::is_convertible<I1,
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
static_assert((std::is_same<I1::char_type, char>::value), "");
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
typedef std::ostream_iterator<unsigned, wchar_t> I2;
static_assert((std::is_convertible<I2,
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
}
|
ac28ed4405956a4818e6742c5d9fd4a9db0b7b86
|
6605d954d4aecb59d07aa48129f0751035efade5
|
/src/Score.cpp
|
1c1f350507c635a218883a1831c9aa383b126847
|
[] |
no_license
|
sylvaing19/sudoku
|
a3ec9d36f1d93dafa3aee7b0b201d413e9eeb98a
|
37fa6c1a4de67e0f5ccfd16f9fa8c1817fb4a160
|
refs/heads/master
| 2016-09-06T02:06:54.293686
| 2015-05-26T19:41:45
| 2015-05-26T19:41:45
| 27,779,347
| 0
| 0
| null | 2015-08-27T09:16:31
| 2014-12-09T17:58:31
|
HTML
|
UTF-8
|
C++
| false
| false
| 3,426
|
cpp
|
Score.cpp
|
#include "Score.h"
using namespace std;
Score::Score()
{
initialScore = 0;
gamePaused = true;
nbIndices = 0;
nbOfHighscore = 3;
saveFile = "highscore/highscore.txt";
pausedTime = 0;
}
void Score::initScore(Difficulte difficulte)
{
switch (difficulte)
{
case FACILE:
initialScore = 3000;
break;
case MOYEN:
initialScore = 5000;
break;
case DIFFICILE:
initialScore = 8000;
break;
default:
break;
}
gamePaused = false;
nbIndices = 0;
beginTime = time(NULL);
pausedTime = 0;
}
time_t Score::getTimer()
{
time_t currentTime = time(NULL);
time_t playTime;
if (gamePaused)
playTime = pauseStartTime - beginTime - pausedTime;
else
playTime = currentTime - beginTime - pausedTime;
return playTime;
}
void Score::removeScore(int pointsToRemove)
{
initialScore-=pointsToRemove;
}
void Score::stopTimer()
{
gamePaused = true;
pauseStartTime = time(NULL);
}
void Score::restartTimer()
{
gamePaused = false;
time_t currentTime = time(NULL);
pausedTime += currentTime - pauseStartTime;
}
void Score::indiceUtilise()
{
nbIndices++;
}
int Score::getScore()
{
time_t currentTime = time(NULL);
time_t playTime;
if (gamePaused)
playTime = pauseStartTime - beginTime - pausedTime;
else
playTime = currentTime - beginTime - pausedTime;
return initialScore - 200 * nbIndices - 100 * playTime / 60;
}
unsigned int Score::getRank()
{
ifstream fichier(saveFile.c_str(), ios::in);
if (fichier)
{
unsigned int realNbOfHighscore = 0;
bool fichierNonConforme = false;
string rangCourant, nomCourant;
int scoreCourant;
vector<string> rang, nom;
vector<int> score;
for (unsigned int i = 0; i < nbOfHighscore; i++)
{
if (fichier >> rangCourant >> nomCourant >> scoreCourant)
{
realNbOfHighscore++;
rang.push_back(rangCourant);
nom.push_back(nomCourant);
score.push_back(scoreCourant);
if (rang[i].size() < 2 || rang[i][0] != '#' || atoi(rang[i].substr(1).c_str()) != i + 1)
{
fichierNonConforme = true;
}
}
}
realNbOfHighscore = min(realNbOfHighscore, nbOfHighscore);
int scoreAClasser = getScore();
unsigned int rangDuScore = realNbOfHighscore + 1;
if (score[0] < scoreAClasser)
rangDuScore = 1;
for (unsigned int i = 1; i < realNbOfHighscore; i++)
{
if (score[i - 1] > scoreAClasser && score[i] <= scoreAClasser)
rangDuScore = i + 1;
if (score[i - 1] < score[i])
fichierNonConforme = true;
}
fichier.close();
if (fichierNonConforme)
{
remove(saveFile.c_str());
return 1;
}
else
return rangDuScore;
}
else
return 1;
}
void Score::save(string name, unsigned int rank)
{
fstream fichier(saveFile.c_str(), ios::in | ios::out | ios::ate);
fichier.seekp(0, ios::beg);
string rang, nom, score, rangS, nomS, scoreS;
do
{
fichier >> rang >> nom >> score;
} while (atoi(rang.substr(1).c_str()) != rank - 1);
fichier << '#' << rank << ' ' << name << ' ' << getScore() << endl;
int curseur;
bool endOfFile = false;
do
{
curseur = fichier.tellp();
if (!(fichier >> rangS >> nomS >> scoreS))
{
endOfFile = true;
}
fichier.seekp(curseur, ios::beg);
fichier << rang << ' ' << nom << ' ' << score << endl;
rang = rangS;
nom = nomS;
score = scoreS;
} while (!endOfFile);
}
unsigned int Score::getNbOfHighscore()
{
return nbOfHighscore;
}
void Score::setNbOfHighscore(unsigned int nbOfHighscore)
{
this->nbOfHighscore = nbOfHighscore;
}
|
5dffb901ec92304f33b3256eec56adedc573a138
|
35596c34d80d1378091090e6183cb0e1c27fdc4d
|
/src/pcl_tutorial/src/filter/extract_plane.cpp
|
adb0724807ca7928c80d98e1962931ea0616a253
|
[] |
no_license
|
YeeKal/grasp_ws
|
bdb22a04a52919621fd69d15a5ba274322f61102
|
7e40ddb871c4975f39f677ada035aac56d79e511
|
refs/heads/master
| 2020-09-02T04:12:41.745818
| 2019-12-31T05:26:35
| 2019-12-31T05:26:35
| 219,128,067
| 4
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,130
|
cpp
|
extract_plane.cpp
|
#include <iostream>
#include <pcl/ModelCoefficients.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/sample_consensus/method_types.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/visualization/pcl_visualizer.h>
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>),cloud_blob(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>), cloud_p (new pcl::PointCloud<pcl::PointXYZ>), cloud_f (new pcl::PointCloud<pcl::PointXYZ>);
// Create the filtering object: downsample the dataset using a leaf size of 1cm
if(pcl::io::loadPCDFile<pcl::PointXYZ>("block/saved_pcd0/inputCloud10.pcd",*cloud)==-1){
PCL_ERROR("could not read file\n");
return (-1);
}
pcl::VoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud (cloud);
sor.setLeafSize (0.01f, 0.01f, 0.01f);
sor.filter (*cloud_filtered);
std::cerr << "PointCloud after filtering: " << cloud_filtered->width * cloud_filtered->height << " data points." << std::endl;
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
pcl::PointIndices::Ptr inliers (new pcl::PointIndices ());
// Create the segmentation object
pcl::SACSegmentation<pcl::PointXYZ> seg;
// Optional
seg.setOptimizeCoefficients (true);
// Mandatory
seg.setModelType (pcl::SACMODEL_PLANE);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setMaxIterations (1000);
seg.setDistanceThreshold (0.01);
// Create the filtering object
pcl::ExtractIndices<pcl::PointXYZ> extract;
int i = 0, nr_points = (int) cloud_filtered->points.size ();
// While 30% of the original cloud is still there
while (cloud_filtered->points.size () > 0.3 * nr_points)
{
// Segment the largest planar component from the remaining cloud
seg.setInputCloud (cloud_filtered);
seg.segment (*inliers, *coefficients);
if (inliers->indices.size () == 0)
{
std::cerr << "Could not estimate a planar model for the given dataset." << std::endl;
break;
}
// Extract the inliers
extract.setInputCloud (cloud_filtered);
extract.setIndices (inliers);
extract.setNegative (false);
extract.filter (*cloud_p);
std::cerr << "PointCloud representing the planar component: " << cloud_p->width * cloud_p->height << " data points." << std::endl;
// Create the filtering object
extract.setNegative (true);
extract.filter (*cloud_f);
cloud_filtered.swap (cloud_f);
i++;
break;
}
pcl::visualization::PCLVisualizer viewer("pointcloud viewer");
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> sig(cloud_filtered, 0, 234, 0);
viewer.addPointCloud(cloud_filtered, sig, "cloud");
while (!viewer.wasStopped())
{
viewer.spinOnce();
}
return (0);
}
|
7220c0d10de5637176c34ce08a94cb6e2b1890c3
|
63623bd1d0fb38cabfba9f02976f989d1a7cfd08
|
/CCP5.CPP
|
2ff82200e68de93f5847d45cae489859aeee40ce
|
[] |
no_license
|
toshinCS173/NEWPROJECT
|
8ab3fd0c6f2bd16282cbc0b043e97999f45a0fd4
|
b73c49540e926fe1e96bc812ef1bec589642f6ab
|
refs/heads/main
| 2023-07-07T13:11:26.021451
| 2021-07-21T05:05:09
| 2021-07-21T05:05:09
| 366,692,226
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 967
|
cpp
|
CCP5.CPP
|
//WAP TO FIND ALL POSSIBLE ROOTS OF A QUADRATIC EQUATIONS//
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,c;
float d,root1,root2;
double real_root;
double img_root;
printf("\n Enter the value for 1->co-efficient of x^2,\n 2->co-efficient of x,\n 3->constant: \n");
scanf("%d%d%d",&a,&b,&c);
d=(b*b)-(4*a*c);
if (d==0)
{
printf("\n The roots are equal and real");
root1=(-b-sqrt(d))/(2*a);
root2=root1;
printf("\n The roots are %f and %f",root1,root2);
}
else if (d>0)
{
printf("\n The root are real and distinct");
root1=(-b+sqrt(d))/(2*a);
root2=(-b-sqrt(d))/(2*a);
printf("\n The root are %f and %f",root1,root2);
}
else
{
printf("\n The root are imaginary");
real_root= - b/(2*a);
img_root =sqrt(-d)/(2*a);
printf("\n The real part of roots are %2lf\n",real_root);
printf("\n The imaginary part of the root are %2lfi \n",img_root);
}
getch();
}
|
a0fd7c5df350590b5ecea96ee5d09552ea5c0129
|
fca173faac354549b6b30d48ce8efef59b3a3357
|
/admin/src/get-edges.cpp
|
cb1b2dceb18d28d5cf79022218a4462c6789c317
|
[] |
no_license
|
protein-bioinformatics/STAMPS
|
4bf6a8210a05ce61263c51cd11cdb8720d7e8144
|
9270bac3b1f72d245950a91f85e8449239296a75
|
refs/heads/master
| 2023-05-02T04:27:01.726679
| 2021-01-29T11:19:27
| 2021-01-29T11:19:27
| 361,710,740
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,866
|
cpp
|
get-edges.cpp
|
#include "bio-classes.h"
using namespace std;
void print_out(string response, bool compress){
if (compress){
cout << compress_string(response);
}
else {
cout << response;
}
}
class reagent {
public:
string id;
string reaction_id;
string node_id;
string type;
string anchor;
string head;
string to_string(){
string data = "{\"i\":" + id;
data += ",\"r\":" + reaction_id;
data += ",\"n\":" + node_id;
data += ",\"t\":\"" + type + "\"";
data += ",\"h\":" + head;
data += ",\"a\":\"" + anchor + "\"}";
return data;
}
};
class direct {
public:
string id;
string node_id_start;
string node_id_end;
string anchor_start;
string anchor_end;
string head;
string to_string(){
string data = "{\"i\":" + id;
data += ",\"ns\":" + node_id_start;
data += ",\"ne\":" + node_id_end;
data += ",\"as\":\"" + anchor_start + "\"";
data += ",\"ae\":\"" + anchor_end + "\"";
data += ",\"h\":" + head + "}";
return data;
}
};
class reaction {
public:
string id;
string node_id;
string anchor_in;
string anchor_out;
vector<reagent*> reagents;
string to_string(){
string data = "{\"i\":" + id;
data += ",\"n\":" + node_id;
data += ",\"in\":\"" + anchor_in + "\"";
data += ",\"out\":\"" + anchor_out + "\"";
data += ",\"r\":{";
for (int i = 0; i < reagents.size(); ++i){
if (i) data += ",";
data += "\"" + reagents[i]->id + "\":" + reagents[i]->to_string();
}
data += "}}";
return data;
}
};
static int sqlite_select_reactions(sqlite3_stmt* select_stmt, void *data){
map<string, string> row;
map<string, reaction* >* all_reactions = (map<string, reaction* >*)data;
for(int col = 0; col < sqlite3_column_count(select_stmt); col++) {
row.insert({string(sqlite3_column_name(select_stmt, col)), string((const char*)sqlite3_column_text(select_stmt, col))});
}
reaction* r = new reaction();
r->id = row["id"];
r->node_id = row["node_id"];
r->anchor_in = row["anchor_in"];
r->anchor_out = row["anchor_out"];
all_reactions->insert({r->id, r});
return SQLITE_OK;
}
static int sqlite_select_reagents(sqlite3_stmt* select_stmt, void *data){
map<string, string> row;
map<string, reaction* >* all_reactions = (map<string, reaction* >*)data;
for(int col = 0; col < sqlite3_column_count(select_stmt); col++) {
row.insert({string(sqlite3_column_name(select_stmt, col)), string((const char*)sqlite3_column_text(select_stmt, col))});
}
reagent* r = new reagent();
r->id = row["rg_id"];
r->reaction_id = row["reaction_id"];
r->node_id = row["rg_node_id"];
r->type = row["type"];
r->anchor = row["anchor"];
r->head = row["head"];
all_reactions->at(row["id"])->reagents.push_back(r);
return SQLITE_OK;
}
static int sqlite_select_reagents_direct(sqlite3_stmt* select_stmt, void *data){
map<string, string> row;
map<string, direct* >* all_directs = (map<string, direct* >*)data;
for(int col = 0; col < sqlite3_column_count(select_stmt); col++) {
row.insert({string(sqlite3_column_name(select_stmt, col)), string((const char*)sqlite3_column_text(select_stmt, col))});
}
direct* r = new direct();
r->id = row["id"];
r->node_id_start = row["node_id_start"];
r->node_id_end = row["node_id_end"];
r->anchor_start = row["anchor_start"];
r->anchor_end = row["anchor_end"];
r->head = row["head"];
all_directs->insert({r->id, r});
return SQLITE_OK;
}
int main(int argc, char** argv) {
bool compress = false;
string response = "";
if (compress){
cout << "Content-Type: text/html" << endl;
cout << "Content-Encoding: deflate" << endl << endl;
}
else {
cout << "Content-Type: text/html" << endl << endl;
}
// load get values
char* get_string_chr = getenv("QUERY_STRING");
if (!get_string_chr){
response += "-1";
print_out(response, compress);
return -1;
}
string get_string = get_string_chr;
if (!get_string.length()){
response += "-2";
print_out(response, compress);
return -2;
}
vector<string> get_entries = split(get_string, '&');
map< string, string > form;
for (uint i = 0; i < get_entries.size(); ++i){
vector<string> get_value = split(get_entries.at(i), '=');
string value = (get_value.size() > 1) ? get_value.at(1) : "";
form.insert(pair< string, string >(get_value.at(0), value));
}
// load parameters from config file
string line;
map< string, string > parameters;
ifstream myfile ("../admin/qsdb.conf");
if (myfile.is_open()){
while ( getline (myfile,line) ){
strip(line);
if (line[0] == '#') continue;
vector< string > tokens = split(line, '=');
if (tokens.size() < 2) continue;
strip(tokens.at(0));
strip(tokens.at(1));
parameters.insert(pair< string, string >(tokens.at(0), tokens.at(1)));
}
myfile.close();
}
/*
char* get_remote_addr = getenv("REMOTE_ADDR");
if (get_remote_addr == NULL || (string(get_remote_addr) != "localhost" && string(get_remote_addr) != "127.0.0.1" && parameters.at("public") != "1")){
print_out("{}", compress);
exit(-3);
}
*/
string pathway_id = (form.find("pathway") != form.end()) ? form["pathway"] : "";
string host = (form.find("host") != form.end()) ? form["host"] : "";
if (!pathway_id.length() || !is_integer_number(pathway_id)){
response += "-3";
print_out(response, compress);
return -3;
}
int pathway_id_int = atoi(pathway_id.c_str());
// if it is a remote request
if (host.length() > 0 && (host != "localhost" || host != "127.0.0.1")){
string get_vars = "";
for (uint i = 0; i < get_entries.size(); ++i){
vector<string> get_values = split(get_entries.at(i), '=');
if (get_values.size() && get_values.at(0) != "host"){
if (get_vars.length() > 0) get_vars += "&";
get_vars += get_entries.at(i);
}
}
string remote_request = host + "/scripts/get-edges.bin?" + get_vars;
string response = web_request(remote_request);
if (response.length() == 0) response = "{}";
print_out(response, compress);
return 0;
}
// retrieve id and peptide sequence from spectral library
sqlite3 *db;
char *zErrMsg = 0;
int rc, chr;
string database = parameters["root_path"] + "/data/database.sqlite";
rc = sqlite3_open((char*)database.c_str(), &db);
if( rc ){
print_out("[]", compress);
exit(-3);
}
sqlite3_stmt *select_stmt_reactions = NULL;
string sql_query = "SELECT r.* FROM reactions r INNER JOIN nodes n ON r.node_id = n.id WHERE n.pathway_id = ? ORDER BY r.id;";
map<string, reaction* > all_reactions;
rc = sqlite3_prepare_v2(db, sql_query.c_str(), -1, &select_stmt_reactions, NULL);
if(SQLITE_OK != rc) {
print_out("{}", compress);
sqlite3_close(db);
exit(-13);
}
sqlite3_bind_int(select_stmt_reactions, 1, pathway_id_int);
while(SQLITE_ROW == (rc = sqlite3_step(select_stmt_reactions))) {
sqlite_select_reactions(select_stmt_reactions, (void*)&all_reactions);
}
if(SQLITE_DONE != rc) {
print_out("{}", compress);
sqlite3_finalize(select_stmt_reactions);
exit(-4);
}
sqlite3_finalize(select_stmt_reactions);
sqlite3_stmt *select_stmt_reagents = NULL;
sql_query = "SELECT r.id, rg.id rg_id, rg.reaction_id, rg.node_id rg_node_id, rg.type, rg.anchor, rg.head FROM reactions r INNER JOIN nodes n ON r.node_id = n.id INNER JOIN reagents rg on r.id = rg.reaction_id WHERE n.pathway_id = ? ORDER BY r.id;";
rc = sqlite3_prepare_v2(db, sql_query.c_str(), -1, &select_stmt_reagents, NULL);
if(SQLITE_OK != rc) {
print_out("{}", compress);
sqlite3_close(db);
exit(-13);
}
sqlite3_bind_int(select_stmt_reagents, 1, pathway_id_int);
while(SQLITE_ROW == (rc = sqlite3_step(select_stmt_reagents))) {
sqlite_select_reagents(select_stmt_reagents, (void*)&all_reactions);
}
if(SQLITE_DONE != rc) {
print_out("{}", compress);
sqlite3_finalize(select_stmt_reagents);
exit(-4);
}
sqlite3_finalize(select_stmt_reagents);
sqlite3_stmt *select_stmt_reagents_direct = NULL;
map<string, direct* > all_directs;
sql_query = "SELECT r.* FROM reactions_direct r INNER JOIN nodes n ON r.node_id_start = n.id INNER JOIN nodes nn ON r.node_id_end = nn.id WHERE n.pathway_id = ? AND nn.pathway_id = ? ORDER BY r.id;";
rc = sqlite3_prepare_v2(db, sql_query.c_str(), -1, &select_stmt_reagents_direct, NULL);
if(SQLITE_OK != rc) {
print_out("{}", compress);
sqlite3_close(db);
exit(-13);
}
sqlite3_bind_int(select_stmt_reagents_direct, 1, pathway_id_int);
sqlite3_bind_int(select_stmt_reagents_direct, 2, pathway_id_int);
while(SQLITE_ROW == (rc = sqlite3_step(select_stmt_reagents_direct))) {
sqlite_select_reagents_direct(select_stmt_reagents_direct, (void*)&all_directs);
}
if(SQLITE_DONE != rc) {
print_out("{}", compress);
sqlite3_finalize(select_stmt_reagents_direct);
exit(-4);
}
sqlite3_finalize(select_stmt_reagents_direct);
string data = "{\"reactions\":{";
int i = 0;
for (auto entry : all_reactions){
if (i++) data += ",";
data += "\"" + entry.first + "\":" + entry.second->to_string();
}
data += "}, \"direct\":{";
i = 0;
for (auto entry : all_directs){
if (i++) data += ",";
data += "\"" + entry.first + "\":" + entry.second->to_string();
}
data += "}}";
response += data;
print_out(response, compress);
sqlite3_close(db);
return 0;
}
|
772bf2902a69932fddedf26b6c0cef9380d3866d
|
371c4ebdf1b207ca7e05f76be95cddbcfc978e14
|
/source/Network/CMA_Optimizer.h
|
3f52dfb9fdeb92adf09c2ec7ca340c0663e161e7
|
[
"MIT"
] |
permissive
|
bmewang/smarties
|
d7f93ad9bfdd4bf903a98f16f155f64c9e942420
|
1ed5f1a56e9e5012b5db582b4c5fca14af11fd20
|
refs/heads/master
| 2022-09-19T02:15:13.414697
| 2020-06-02T15:47:37
| 2020-06-02T15:47:37
| 270,935,413
| 1
| 0
|
MIT
| 2020-06-09T07:39:39
| 2020-06-09T07:39:38
| null |
UTF-8
|
C++
| false
| false
| 3,957
|
h
|
CMA_Optimizer.h
|
//
// smarties
// Copyright (c) 2018 CSE-Lab, ETH Zurich, Switzerland. All rights reserved.
// Distributed under the terms of the MIT license.
//
// Created by Guido Novati (novatig@ethz.ch).
//
#ifndef smarties_CMA_Optimizer_h
#define smarties_CMA_Optimizer_h
#include "Optimizer.h"
class Saru;
namespace smarties
{
class CMA_Optimizer : public Optimizer
{
protected:
const std::vector<nnReal> popWeights = initializePopWeights(populationSize);
const nnReal mu_eff = initializeMuEff(popWeights, populationSize);
const nnReal sumW = initializeSumW(popWeights, populationSize);
const Uint mpiDistribOpsStride = Utilities::roundUpSimd( std::ceil( weights->nParams/(Real)learn_size ) );
const std::vector<std::shared_ptr<Parameters>> popNoiseVectors =
allocManyParams(weights, populationSize);
const std::shared_ptr<Parameters> momNois = weights->allocateEmptyAlike();
const std::shared_ptr<Parameters> avgNois = weights->allocateEmptyAlike();
const std::shared_ptr<Parameters> negNois = weights->allocateEmptyAlike();
const std::shared_ptr<Parameters> pathCov = weights->allocateEmptyAlike();
const std::shared_ptr<Parameters> pathDif = weights->allocateEmptyAlike();
const std::shared_ptr<Parameters> diagCov = weights->allocateEmptyAlike();
const std::vector<Uint> pStarts, pCounts;
const Uint pStart, pCount;
std::vector<std::shared_ptr<Saru>> generators;
std::vector<std::shared_ptr<std::mt19937>> stdgens;
MPI_Request paramRequest = MPI_REQUEST_NULL;
std::vector<Real> losses = std::vector<Real>(populationSize, 0);
//Uint Nswap = 0;
nnReal computeStdDevScale() const
{
return bAnnealLearnRate? Utilities::annealRate(eta, nStep, epsAnneal) : eta;
}
public:
CMA_Optimizer(const Settings& S, const DistributionInfo& D,
const std::shared_ptr<Parameters>& W);
void prepare_update(const Rvec& L) override;
void apply_update() override;
void save(const NetSaveF_t& F,
const std::string fname,
const bool bBackup) override;
int restart(const NetLoadF_t& F, const std::string fname) override;
protected:
static inline std::vector<nnReal> initializePopWeights(const Uint popSize)
{
std::vector<nnReal> ret(popSize);
nnReal sum = 0;
for(Uint i=0; i<popSize; ++i)
{
ret[i] = std::log(0.5*(popSize+1)) - std::log(i+1.0);
sum += std::max( ret[i], (nnReal) 0 );
}
for(Uint i=0; i<popSize; ++i) ret[i] /= sum;
return ret;
}
static inline Real initializeMuEff(const std::vector<nnReal>popW,
const Uint popSize)
{
Real sum = 0, sumsq = 0;
for(Uint i=0; i<popSize; ++i) {
const nnReal W = std::max( popW[i], (nnReal) 0 );
sumsq += W * W; sum += W;
}
return sum * sum / sumsq;
}
static inline Real initializeSumW(const std::vector<nnReal>popW, const Uint popsz)
{
Real sum = 0;
for(Uint i=0; i<popsz; ++i) sum += popW[i];
return sum;
}
void getMetrics(std::ostringstream& buff) override;
void getHeaders(std::ostringstream& buff, const std::string nnName) override;
std::vector<Uint> computePstarts() const
{
std::vector<Uint> ret (learn_size, 0);
for (Uint i=0; i < learn_size; ++i)
ret[i] = mpiDistribOpsStride * i;
return ret;
}
std::vector<Uint> computePcounts() const
{
std::vector<Uint> ret (learn_size, 0);
for (Uint i=0; i < learn_size; ++i) {
const Uint end = std::min(mpiDistribOpsStride*(i+1), weights->nParams);
const Uint beg = mpiDistribOpsStride * i;
ret[i] = end - beg;
}
return ret;
}
bool ready2UpdateWeights() override
{
if(paramRequest == MPI_REQUEST_NULL) return true;
int completed = 0;
MPI(Test, ¶mRequest, &completed, MPI_STATUS_IGNORE);
return completed;
}
void startAllGather(const Uint ID);
};
} // end namespace smarties
#endif // smarties_Quadratic_term_h
|
61d39c6762669e10f2de819507b459922ad13a64
|
06f7797201b33b684df77cf704d41f5d51af8c5b
|
/源码/Client/signin.h
|
66b6b63a1dad3e35d013ad7b4cd64a5c1b9afeeb
|
[] |
no_license
|
kyon1920/KoalaNotes
|
ebb807040f35fcd9a1893823d780fe23b98c92ae
|
e05cdd4f90436038e29a0f7af7ba1d8f71e59110
|
refs/heads/master
| 2022-08-06T06:59:41.147905
| 2020-05-16T07:19:38
| 2020-05-16T07:19:38
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 906
|
h
|
signin.h
|
#ifndef SIGNIN_H
#define SIGNIN_H
#include "head.h"
#include "register.h"
namespace Ui {
class Signin;
}
class Signin : public QWidget
{
Q_OBJECT
public:
explicit Signin(QWidget *parent = nullptr);
~Signin();
void setWindow();
// void paintEvent(QPaintEvent *event);
void TikTok();
void mousePressEvent(QMouseEvent* mEvent);
void mouseMoveEvent(QMouseEvent* mEvent);
void initRFile();
void signinWFile();
void netLink();
signals:
//定义子窗口向主窗口发送数据的信号
void send_to_main(QString send_msg);
private slots:
void on_close_clicked();
void on_min_clicked();
void on_signin_clicked();
void on_signup_clicked();
private:
Ui::Signin *ui;
QPoint dragPosition;
QTcpSocket *tSocket;
bool insuccess = false;
bool netlink;
QString username;
Register _register;
};
#endif // SIGNIN_H
|
bf5569ec1246e71c194082b3c8334a9f3201edd9
|
e5ac23961f52bb8e7de6907833378493fcb8318a
|
/lexerGenerator/DFA/DFABuilder.h
|
e0232107233e04b4c84eb849726419fb061d9ee6
|
[] |
no_license
|
syedmuhammadhasan/Compiler-Generator
|
80da6e813e170b9b4f05befa397ae67f0d919300
|
8f08a80c098f713c1cdb97a2e763bbc47bf0b682
|
refs/heads/master
| 2020-09-04T06:53:30.087052
| 2019-04-25T20:55:50
| 2019-04-25T20:55:50
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 471
|
h
|
DFABuilder.h
|
//
// Created by Shazly on 3/24/2019.
//
#ifndef COMPILERS_DFABUILDER_H
#define COMPILERS_DFABUILDER_H
#include <DFAState.h>
#include "NFA/NFAState.h"
#include "DFAGraph.h"
class DFABuilder {
public:
DFABuilder(NFAState s){
startState = s;
}
DFAGraph buildDFA();
private:
NFAState startState;
map<DFAState, vector< pair<DFAState, char> > > graph;
DFAState convertInputToGraph(NFAState state);
};
#endif //COMPILERS_DFABUILDER_H
|
a718947693a2c584baa32065531e261276d51990
|
23819413de400fa78bb813e62950682e57bb4dc0
|
/Rounds/Round-837/C/backup.cpp
|
f5da6a4cb8a89a19ba4c938c318a16f4164df5e2
|
[] |
no_license
|
Manzood/CodeForces
|
56144f36d73cd35d2f8644235a1f1958b735f224
|
578ed25ac51921465062e4bbff168359093d6ab6
|
refs/heads/master
| 2023-08-31T16:09:55.279615
| 2023-08-20T13:42:49
| 2023-08-20T13:42:49
| 242,544,327
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 880
|
cpp
|
backup.cpp
|
#include "bits/stdc++.h"
#ifdef local
#include "custom/debugger.h"
#else
#define debug(...) 42;
#endif
using namespace std;
#define int long long
constexpr int mod = (int)1e9 + 7;
void solve([[maybe_unused]] int test) {
int n;
scanf("%lld", &n);
vector<int> a(n);
int prod = 1;
bool ans = false;
int x = 0;
int cnt = 0;
for (int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
int v = (cnt * (mod % a[i])) % a[i];
int val =
(((((v + x) % a[i]) * (mod % a[i])) % a[i]) + (prod % a[i])) % a[i];
if (__gcd(val, a[i]) > 1) ans = true;
prod *= a[i];
x += prod / mod;
cnt += x / mod;
x %= mod;
prod %= mod;
}
ans ? printf("YES\n") : printf("NO\n");
}
int32_t main() {
int t = 1;
cin >> t;
for (int tt = 1; tt <= t; tt++) {
solve(tt);
}
}
|
0a081f91063708693e77928c62851edc7c8d5669
|
446a749d41af0008ba557dca6a62c0fbf8fed3ad
|
/codeforces/Ladders/1500-1600/absurdity.cpp
|
d884732cb285c65bc0647a59dfe88715f1370dcd
|
[] |
no_license
|
Sirivasv/ProgrammingChallenges
|
b8910f869548491a81e5352f72295a6886cc150e
|
5d9039725b2947f392a179f75896b8a57b4537cb
|
refs/heads/master
| 2021-01-12T09:08:15.814557
| 2020-05-15T21:40:14
| 2020-05-15T21:40:14
| 76,768,160
| 0
| 0
| null | 2018-10-13T17:18:12
| 2016-12-18T07:02:21
|
C++
|
UTF-8
|
C++
| false
| false
| 821
|
cpp
|
absurdity.cpp
|
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
const int MAXN = 200009;
int N, K;
lli arr[MAXN], barr[MAXN];
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> N >> K;
for (int i = 0; i < N; ++i)
cin >> arr[i];
lli sum = 0;
for (int i = 0; i < K; ++i)
sum += arr[i];
barr[0] = sum;
int le = 0;
for (int i = K; i < N; ++i) {
sum -= arr[le];
sum += arr[i];
le++;
barr[le] = sum;
}
lli mats = -1LL, ansq = -1LL;
int matsa, matsb, matsq;
int lim = N - (2 * K);
for (int i = lim; i >= 0; --i) {
lli posa = barr[i];
if (barr[i + K] >= ansq) {
ansq = barr[i + K];
matsq = i + K + 1;
}
posa += ansq;
if (posa >= mats) {
mats = posa;
matsa = i + 1;
matsb = matsq;
}
}
cout << matsa << ' ' << matsb << '\n';
return 0;
}
|
4144342fd6deaec359d9497f718c98cb34219a03
|
f50f5850d5be7f2c0e8061cb9b8197fc6e6bd99b
|
/Scanner.h
|
46040faad191072028854ca39c8d9295753c4272
|
[] |
no_license
|
Bartholomew-m134/CoreInterpreter
|
6431c50783a76c15a14be0d271c80ad4822b8977
|
19de7a4ee56c26f878d5227337a310343e328f36
|
refs/heads/master
| 2021-01-19T02:19:45.037497
| 2016-11-11T14:00:52
| 2016-11-11T14:00:52
| 73,479,749
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 812
|
h
|
Scanner.h
|
#include <fstream>
#include <string>
#include "Tokenizer.h"
class Scanner {
public:
Scanner(char* fileName);
Token* getCurrentToken();
void getNextToken();
int getVariableValue(Token* token);
int setVariableValue(Token* token, int value);
std::ifstream* fileStream;
private:
void declareVariable(Token* token);
void handleIfNotDeclared(Token* token);
void removeWhiteSpace(char& c);
void getUnaryChar(std::string& token, char& c);
void getBinaryChar(std::string& token, char& c);
void getConst(std::string& token, char& c);
void getAlnumString(std::string& token, char& c);
void handleIfNotInitialized(Token* token);
Token* currentToken;
std::map<std::string, std::pair<bool, int>> variables;
bool isDeclPhase;
};
extern Scanner* scanner;
|
1cebf3e8eec29a380ca7c4f97928be80f4136b2c
|
e14d3bb8862ac353e46f5dd174d467b63bd24318
|
/colorED/colorED/matrix.h
|
b2015ba0713cbd9fd18458a80aa179e41fd8c12f
|
[] |
no_license
|
dcsuju13/flowermodelling
|
d1f07e5d99a9864030ded93ef0c056beaed56526
|
b61d3dda3aa2185d20575c82ade7cabc81963e59
|
refs/heads/master
| 2021-01-22T17:33:59.683383
| 2016-08-07T05:05:50
| 2016-08-07T05:05:50
| 60,755,873
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 774
|
h
|
matrix.h
|
#pragma once
#include<iostream>
#include "math.h"
#include<vector>
using namespace std;
class matrix
{
public:
matrix();
void init(vector<float> a,vector<float> p,int m,int n);//初始化A和b
void transpose(vector<float> a, int m, int n, vector<float> &b);//求矩阵a转置
void trmul(vector<float> a, vector<float> b, int m, int n, int k, vector<float> &c);//矩阵相乘
int chlk(vector<float> a, int n, int m, vector<float> &d);//平方根法(Cholesky法)求实正定对称方程组的解
void fun(vector<float> r, vector<float> p, int m, int n);//求超定方程的最小二乘解
vector<float> &getX();
~matrix();
private:
vector<float> A;//系数矩阵A
int A_row;//A行数
int A_col;//A列数
vector<float> b;
vector<float> x;//结果矩阵
};
|
6ae66fad8e8d55113fb950edcc299a23e99eb0ee
|
4bea57e631734f8cb1c230f521fd523a63c1ff23
|
/projects/openfoam/rarefied-flows/impingment/sims/test/nozzle1/4.74/grad(rho)
|
8ac11749774d169ba6e058d984c06cee679561a8
|
[] |
no_license
|
andytorrestb/cfal
|
76217f77dd43474f6b0a7eb430887e8775b78d7f
|
730fb66a3070ccb3e0c52c03417e3b09140f3605
|
refs/heads/master
| 2023-07-04T01:22:01.990628
| 2021-08-01T15:36:17
| 2021-08-01T15:36:17
| 294,183,829
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 46,153
|
grad(rho)
|
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1912 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "4.74";
object grad(rho);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -4 0 0 0 0 0];
internalField nonuniform List<vector>
1900
(
(159735 -0.799053 0)
(-135235 -0.11746 0)
(-17290.6 0.990883 0)
(-3854.2 0.363067 0)
(-2298.05 1.55781 0)
(-1640.25 6.47255 0)
(-1523.84 19.438 0)
(-1388.17 38.746 0)
(-1444.96 -118.77 0)
(-695.423 -171.323 0)
(159734 -1.33221 0)
(-135234 0.0114529 0)
(-17290.2 1.76065 0)
(-3853.64 1.36194 0)
(-2291.94 2.72319 0)
(-1622.37 7.6968 0)
(-1491.56 19.0298 0)
(-1526.38 28.6856 0)
(-1655.03 -161.656 0)
(-1550.53 -218.63 0)
(159733 1.53477e-08 0)
(-135232 8.88178e-10 0)
(-17289.3 -1.22569e-09 0)
(-3853.24 -4.44089e-10 0)
(-2291.71 -7.31859e-09 0)
(-1623.94 -5.24025e-09 0)
(-1502.85 1.68754e-09 0)
(-1568.86 3.19744e-09 0)
(-1692.28 5.82645e-09 0)
(-1583.89 2.80664e-09 0)
(159734 1.33221 0)
(-135234 -0.0114529 0)
(-17290.2 -1.76065 0)
(-3853.64 -1.36194 0)
(-2291.94 -2.72319 0)
(-1622.37 -7.6968 0)
(-1491.56 -19.0298 0)
(-1526.38 -28.6856 0)
(-1655.03 161.656 0)
(-1550.53 218.63 0)
(159735 0.799053 0)
(-135235 0.11746 0)
(-17290.6 -0.990883 0)
(-3854.2 -0.363067 0)
(-2298.05 -1.55781 0)
(-1640.25 -6.47255 0)
(-1523.84 -19.438 0)
(-1388.17 -38.746 0)
(-1444.96 118.77 0)
(-695.423 171.323 0)
(-612.758 -876.506 1.32821e-11)
(-1138.67 -917.71 -1.57329e-11)
(-1041.19 -1443.13 -1.98533e-11)
(-863.129 -1575.37 0)
(-11409 -8325.29 -8.46343e-11)
(-1278.55 -952.819 1.31238e-11)
(-1189.47 -1039.04 1.57329e-11)
(-1068.08 -1561.91 1.98533e-11)
(-2951.45 -1576.32 0)
(-10417.2 -6743.61 0)
(-1684.08 9.33231e-10 0)
(-1547.13 5.45373e-10 0)
(-1483.76 -1.35694e-09 0)
(-2796.89 -1.04294e-09 0)
(-13217.9 -1.37456e-09 0)
(-1278.55 952.819 1.31238e-11)
(-1189.47 1039.04 1.57329e-11)
(-1068.08 1561.91 1.98533e-11)
(-2951.45 1576.32 0)
(-10417.2 6743.61 0)
(-612.758 876.506 -3.95296e-11)
(-1138.67 917.71 -1.57329e-11)
(-1041.19 1443.13 -1.98533e-11)
(-863.129 1575.37 -5.37885e-11)
(-11409 8325.29 8.46343e-11)
(-19162.4 9814.61 2.79353e-11)
(-3857.41 2702.73 -2.26943e-11)
(-5279.46 1401.92 0)
(-7411.07 1029.34 1.5624e-11)
(-11915.3 1480.98 -6.36639e-12)
(-15538.4 11209.6 -1.41154e-11)
(-5743.16 1779.72 1.13878e-11)
(-5679.45 570.854 0)
(-7253.8 442.282 -9.78773e-12)
(-10968.9 661.877 1.60773e-12)
(-16966.8 -1.61487e-09 0)
(-6531.39 -9.86865e-10 0)
(-5743.6 1.25003e-09 0)
(-7411.31 -2.55424e-09 3.92042e-12)
(-10171.1 2.12955e-09 -3.21546e-12)
(-15538.4 -11209.6 -1.41154e-11)
(-5743.16 -1779.72 1.13878e-11)
(-5679.45 -570.854 0)
(-7253.8 -442.282 -9.78773e-12)
(-10968.9 -661.877 1.60773e-12)
(-19162.4 -9814.61 1.41154e-11)
(-3857.41 -2702.73 -8.13973e-14)
(-5279.46 -1401.92 0)
(-7411.07 -1029.34 3.10004e-14)
(-11915.3 -1480.98 6.36639e-12)
(-14549.3 5653.55 0)
(-5863.9 4058.67 0)
(1708.63 3221.39 0)
(-163.841 2620.36 0)
(-1911.89 1418.85 0)
(-1961.99 570.311 0)
(-1599.76 224.496 0)
(-1484.14 145.625 0)
(-1472.76 102.205 0)
(-1358.62 117.843 0)
(-1053.47 37.0266 0)
(-658.647 8.82121 0)
(-402.212 1.86496 0)
(-284.584 1.92457 0)
(-233.555 1.89447 0)
(-199.493 1.23731 0)
(-168.737 0.312579 0)
(-140.252 -0.43146 0)
(-116.054 -0.96338 0)
(-95.1843 -1.32292 0)
(-75.9375 -1.57969 0)
(-59.5877 -1.7553 0)
(-44.6817 -1.85483 0)
(-30.4768 -1.89423 0)
(-18.1136 -1.8647 0)
(-8.33869 -1.80076 0)
(-1.26228 -1.72302 0)
(4.1235 -1.75804 0)
(12.3963 -1.69189 0)
(22.8369 -1.92745 0)
(49.38 -1.81326 0)
(79.837 -1.06393 0)
(123.6 -0.408275 0)
(157.771 2.37631 0)
(198.549 2.11419 0)
(222.543 7.65368 0)
(272.488 -0.54522 0)
(2852.43 14.3957 0)
(46379.8 -80.0091 0)
(-47438 -3325.78 0)
(-14214.6 5464.57 0)
(-6531.16 5806.27 0)
(1373.06 4734.12 0)
(-314.348 2462.33 0)
(-2124.92 1087.61 0)
(-2116.58 331.433 0)
(-1656.41 105.939 0)
(-1498.87 59.2319 0)
(-1471.76 32.3054 0)
(-1363.74 58.8308 0)
(-1065.82 9.95062 0)
(-660.905 1.53872 0)
(-402.511 -0.623885 0)
(-284.474 -0.233874 0)
(-233.552 -0.0586956 0)
(-199.579 -0.161315 0)
(-168.843 -0.438356 0)
(-140.337 -0.649417 0)
(-116.125 -0.791983 0)
(-95.2452 -0.93575 0)
(-75.9856 -1.07318 0)
(-59.6224 -1.1868 0)
(-44.7066 -1.27054 0)
(-30.4942 -1.33604 0)
(-18.1243 -1.37732 0)
(-8.34458 -1.39583 0)
(-1.2827 -1.3986 0)
(4.09976 -1.47079 0)
(12.3496 -1.46783 0)
(22.7883 -1.61271 0)
(49.4434 -1.55201 0)
(79.9844 -0.999885 0)
(123.906 -0.197737 0)
(158.003 1.63416 0)
(199.274 3.32148 0)
(222.667 9.62045 0)
(272.832 12.1431 0)
(2840.98 24.16 0)
(46303.3 -39.2747 0)
(-47397.8 1262.93 0)
(-12737.5 -9.30165e-09 0)
(-6076.39 4.01941e-08 0)
(735.845 5.08523e-08 0)
(-1224.64 2.8131e-08 0)
(-2531.79 -1.14494e-08 0)
(-2247.57 1.28705e-08 0)
(-1678.94 -6.28184e-09 0)
(-1505.56 -2.54342e-08 0)
(-1472.87 -3.00366e-08 0)
(-1365.13 -1.09327e-08 0)
(-1070.14 -2.48367e-08 0)
(-661.724 -1.03675e-08 0)
(-402.728 -2.4223e-09 0)
(-284.419 5.49056e-09 0)
(-233.534 3.40738e-09 0)
(-199.603 -3.58501e-09 0)
(-168.879 -1.16271e-09 0)
(-140.355 -1.195e-08 0)
(-116.137 -2.6823e-08 0)
(-95.2661 -8.0582e-09 0)
(-76.0105 4.82846e-09 0)
(-59.6451 1.46307e-08 0)
(-44.7251 1.92815e-08 0)
(-30.5078 1.85549e-08 0)
(-18.131 2.61932e-08 0)
(-8.34487 4.04686e-08 0)
(-1.28408 5.11591e-08 0)
(4.10336 4.70089e-08 0)
(12.3551 3.52203e-08 0)
(22.8124 1.71984e-08 0)
(49.5583 9.64077e-09 0)
(80.2309 4.70089e-08 0)
(124.367 9.47767e-08 0)
(158.795 1.42819e-07 0)
(200.872 1.3812e-07 0)
(225.109 1.94963e-07 0)
(276.717 1.39525e-07 0)
(2837.47 7.68517e-08 0)
(46740.2 -1.84693e-07 0)
(-47943.3 -2.2718e-07 0)
(-14214.6 -5464.57 0)
(-6531.16 -5806.27 0)
(1373.06 -4734.12 0)
(-314.348 -2462.33 0)
(-2124.92 -1087.61 0)
(-2116.58 -331.433 0)
(-1656.41 -105.939 0)
(-1498.87 -59.2319 0)
(-1471.76 -32.3054 0)
(-1363.74 -58.8308 0)
(-1065.82 -9.95062 0)
(-660.905 -1.53872 0)
(-402.511 0.623885 0)
(-284.474 0.233874 0)
(-233.552 0.0586956 0)
(-199.579 0.161315 0)
(-168.843 0.438356 0)
(-140.337 0.649417 0)
(-116.125 0.791983 0)
(-95.2452 0.93575 0)
(-75.9856 1.07318 0)
(-59.6224 1.1868 0)
(-44.7066 1.27054 0)
(-30.4942 1.33604 0)
(-18.1243 1.37732 0)
(-8.34458 1.39583 0)
(-1.2827 1.3986 0)
(4.09976 1.47079 0)
(12.3496 1.46783 0)
(22.7883 1.61271 0)
(49.4434 1.55201 0)
(79.9844 0.999884 0)
(123.906 0.197737 0)
(158.003 -1.63416 0)
(199.274 -3.32148 0)
(222.667 -9.62045 0)
(272.832 -12.1431 0)
(2840.98 -24.16 0)
(46303.3 39.2747 0)
(-47397.8 -1262.93 0)
(-14549.3 -5653.55 0)
(-5863.9 -4058.67 0)
(1708.63 -3221.39 0)
(-163.841 -2620.36 0)
(-1911.89 -1418.85 0)
(-1961.99 -570.311 0)
(-1599.76 -224.496 0)
(-1484.14 -145.625 0)
(-1472.76 -102.205 0)
(-1358.62 -117.843 0)
(-1053.47 -37.0266 0)
(-658.647 -8.82121 0)
(-402.212 -1.86496 0)
(-284.584 -1.92457 0)
(-233.555 -1.89447 0)
(-199.493 -1.23731 0)
(-168.737 -0.312579 0)
(-140.252 0.431461 0)
(-116.054 0.96338 0)
(-95.1843 1.32292 0)
(-75.9375 1.57969 0)
(-59.5877 1.7553 0)
(-44.6817 1.85483 0)
(-30.4768 1.89423 0)
(-18.1136 1.8647 0)
(-8.33869 1.80075 0)
(-1.26228 1.72302 0)
(4.1235 1.75804 0)
(12.3963 1.69189 0)
(22.8369 1.92745 0)
(49.38 1.81326 0)
(79.837 1.06393 0)
(123.6 0.408275 0)
(157.771 -2.37631 0)
(198.549 -2.11419 0)
(222.543 -7.65368 0)
(272.488 0.54522 0)
(2852.43 -14.3957 0)
(46379.8 80.0091 0)
(-47438 3325.78 0)
(18860.4 2595.5 0)
(-5777.06 -3525.16 0)
(1887.27 -3786.16 0)
(642.314 -3073.82 0)
(-1085.3 -1823.32 0)
(-1546.14 -894.463 0)
(-1455.53 -450.125 0)
(-1439.19 -295.984 0)
(-1453.18 -208.441 0)
(-1328.77 -171.956 0)
(-1011.72 -76.3535 0)
(-641.459 -22.6659 0)
(-398.531 -7.24233 0)
(-284.365 -5.87985 0)
(-233.117 -5.37586 0)
(-198.686 -3.8858 0)
(-167.919 -2.07589 0)
(-139.634 -0.617807 0)
(-115.649 0.364885 0)
(-94.929 0.967914 0)
(-75.7701 1.38306 0)
(-59.4899 1.66663 0)
(-44.6482 1.82149 0)
(-30.5082 1.86654 0)
(-18.1953 1.78197 0)
(-8.44026 1.64139 0)
(-1.33311 1.48997 0)
(4.05277 1.48186 0)
(12.4018 1.38091 0)
(22.8082 1.69239 0)
(48.975 1.46291 0)
(79.2736 0.377654 0)
(122.101 -0.651046 0)
(156.689 -5.17052 0)
(196.803 -5.27892 0)
(224.479 -11.5124 0)
(269.001 -1.22514 0)
(2877.59 -25.8806 0)
(48310.1 -40.1407 0)
(-49646.4 510.296 0)
(18483 9252.15 0)
(-12060.1 -2512.68 0)
(2047.76 -2449.13 0)
(1295.33 -2414.45 0)
(-255.035 -1790.67 0)
(-861.724 -1109.61 0)
(-1100.38 -680.77 0)
(-1275.34 -441.539 0)
(-1363.73 -322.357 0)
(-1247.35 -224.015 0)
(-931.993 -110.054 0)
(-601.266 -39.2864 0)
(-388.011 -14.7806 0)
(-282.903 -10.1993 0)
(-231.868 -8.34144 0)
(-196.746 -5.7622 0)
(-166.026 -2.99772 0)
(-138.231 -0.819551 0)
(-114.742 0.64349 0)
(-94.34 1.55491 0)
(-75.3539 2.20746 0)
(-59.2177 2.66554 0)
(-44.5071 2.92701 0)
(-30.498 3.02749 0)
(-18.2867 2.9402 0)
(-8.56559 2.78387 0)
(-1.37802 2.61966 0)
(4.05634 2.69864 0)
(12.5963 2.67045 0)
(22.9313 3.26923 0)
(48.3303 3.10705 0)
(78.1019 1.65091 0)
(119.058 0.116243 0)
(153.891 -5.92905 0)
(193.373 -7.07968 0)
(225.411 -14.6224 0)
(260.512 -7.87143 0)
(2801.44 -34.7416 0)
(45861.4 -179.419 0)
(-46850.4 -3519.06 0)
(19933 7543.39 0)
(-17052.8 -1250.53 0)
(1981.93 -1238.85 0)
(1276.83 -1713.4 0)
(172.09 -1372.35 0)
(-476.604 -1028.39 0)
(-811.748 -746.002 0)
(-1093.81 -536.56 0)
(-1243.57 -415.208 0)
(-1124.19 -267.24 0)
(-833.713 -138.07 0)
(-549.65 -56.2561 0)
(-370.502 -24.7983 0)
(-278.16 -15.7741 0)
(-228.841 -11.4566 0)
(-193.537 -7.30946 0)
(-163.156 -3.43813 0)
(-136.126 -0.472416 0)
(-113.361 1.51002 0)
(-93.4219 2.78971 0)
(-74.6999 3.72324 0)
(-58.7965 4.37851 0)
(-44.2994 4.7405 0)
(-30.4955 4.86363 0)
(-18.43 4.72594 0)
(-8.74915 4.51811 0)
(-1.41524 4.31174 0)
(4.10171 4.50057 0)
(12.9517 4.5209 0)
(23.229 5.45858 0)
(47.4155 5.36749 0)
(76.3916 3.43835 0)
(114.797 1.44059 0)
(149.755 -5.64733 0)
(188.426 -7.42731 0)
(223.716 -15.9454 0)
(249.614 -13.7755 0)
(2712.28 -33.0116 0)
(44952.5 -123.33 0)
(-45906.8 -1872.75 0)
(22324.7 5634.6 0)
(-20522.9 -386.383 0)
(1601.72 -706.877 0)
(1166.69 -1189.73 0)
(405.071 -1019.07 0)
(-258.151 -892.773 0)
(-626.435 -720.855 0)
(-956.576 -591.548 0)
(-1104.21 -457.445 0)
(-980.285 -289.308 0)
(-728.681 -150.155 0)
(-492.113 -67.9705 0)
(-349.001 -33.5267 0)
(-270.046 -20.8696 0)
(-223.711 -13.9077 0)
(-189.019 -8.13531 0)
(-159.438 -3.30472 0)
(-133.463 0.268811 0)
(-111.599 2.67787 0)
(-92.2073 4.30438 0)
(-73.8229 5.52845 0)
(-58.2374 6.39477 0)
(-44.0396 6.86618 0)
(-30.5121 7.02064 0)
(-18.6197 6.85581 0)
(-8.96473 6.64595 0)
(-1.39492 6.44503 0)
(4.25789 6.82778 0)
(13.5194 6.97487 0)
(23.7471 8.24085 0)
(46.3835 8.21546 0)
(74.3178 5.86871 0)
(110.303 3.38501 0)
(145.346 -3.92485 0)
(183.45 -6.43621 0)
(219.294 -14.9318 0)
(244.066 -18.816 0)
(2695.87 -24.3305 0)
(44088.5 -79.7105 0)
(-45025 -1843.6 0)
(24689 4573.01 0)
(-23163.7 -68.2363 0)
(1207.79 -416.069 0)
(975.989 -762.81 0)
(458.253 -745.897 0)
(-189.233 -765.953 0)
(-521.477 -684.336 0)
(-839.983 -600.173 0)
(-952.32 -450.426 0)
(-828.074 -285.723 0)
(-620.424 -146.937 0)
(-437.263 -72.8316 0)
(-325.113 -38.8574 0)
(-259.254 -24.1557 0)
(-216.57 -15.228 0)
(-183.319 -8.28755 0)
(-155.057 -2.86673 0)
(-130.361 1.07631 0)
(-109.472 3.84396 0)
(-90.675 5.79094 0)
(-72.6855 7.31613 0)
(-57.5074 8.42769 0)
(-43.6963 9.06554 0)
(-30.5055 9.34485 0)
(-18.7911 9.3114 0)
(-9.14499 9.3228 0)
(-1.24003 9.32851 0)
(4.61229 10.1888 0)
(14.3133 10.7942 0)
(24.4244 12.68 0)
(45.1296 13.1097 0)
(71.7368 10.8244 0)
(105.359 8.40849 0)
(140.291 1.55336 0)
(177.819 -0.77677 0)
(211.786 -7.87285 0)
(240.557 -14.0633 0)
(2653.6 -9.0898 0)
(43199.4 -64.886 0)
(-44090.8 -2060.61 0)
(26576.1 5020.11 0)
(-25330.6 -3.98198 0)
(932.405 -335.462 0)
(848.851 -506.4 0)
(402.042 -602.814 0)
(-198.828 -671.581 0)
(-466.684 -649.88 0)
(-731.172 -573.343 0)
(-801.19 -418.763 0)
(-687.832 -262.257 0)
(-523.531 -140.187 0)
(-387.964 -74.54 0)
(-302.095 -42.7722 0)
(-247.276 -26.8087 0)
(-208.42 -16.5313 0)
(-177.107 -8.83746 0)
(-150.414 -3.05428 0)
(-126.996 1.18131 0)
(-107.056 4.25537 0)
(-88.8614 6.46639 0)
(-71.2821 8.27513 0)
(-56.5516 9.65518 0)
(-43.1558 10.509 0)
(-30.2752 10.987 0)
(-18.6409 11.1942 0)
(-8.94824 11.5694 0)
(-0.560428 11.8586 0)
(5.6703 13.2095 0)
(15.92 14.25 0)
(25.9783 16.5077 0)
(44.5954 17.0633 0)
(69.7876 14.4417 0)
(101.369 11.3221 0)
(136.495 3.79015 0)
(174.366 0.837994 0)
(206.49 -4.92699 0)
(242.893 -12.0425 0)
(2646.9 -0.131232 0)
(42111.6 -66.1705 0)
(-42984.7 -2269.67 0)
(29513.3 2739.78 0)
(-28324.5 -35.8844 0)
(723.642 -286.858 0)
(718.359 -414.736 0)
(299.078 -549.428 0)
(-234.587 -611.989 0)
(-426.812 -607.788 0)
(-617.27 -518.689 0)
(-652.546 -368.9 0)
(-559.628 -225.927 0)
(-439.533 -124.776 0)
(-343.39 -69.6196 0)
(-279.118 -41.3316 0)
(-233.967 -25.6843 0)
(-199.252 -15.4103 0)
(-170.332 -7.8642 0)
(-145.403 -2.38206 0)
(-123.317 1.60179 0)
(-104.38 4.52996 0)
(-86.8014 6.80948 0)
(-69.6126 8.88698 0)
(-55.3548 10.6342 0)
(-42.4129 11.8926 0)
(-29.8451 12.8717 0)
(-18.2298 13.7571 0)
(-8.50479 14.991 0)
(0.34041 16.0473 0)
(6.91673 18.5082 0)
(17.4916 20.5177 0)
(27.1355 23.6517 0)
(43.1388 25.0007 0)
(66.2043 22.7285 0)
(95.0949 19.7418 0)
(130.188 11.9059 0)
(169.419 7.72115 0)
(199.374 1.49542 0)
(245.178 -6.32011 0)
(2601.44 5.30188 0)
(41012.4 -94.5603 0)
(-41850 -2514.05 0)
(29130.7 -103.324 0)
(-28247.2 -103.955 0)
(567.33 -255.206 0)
(595.829 -375.174 0)
(211.962 -521.942 0)
(-255.066 -554.774 0)
(-376.777 -541.539 0)
(-500.97 -445.472 0)
(-519.074 -312.831 0)
(-452.585 -192.267 0)
(-372.908 -111.501 0)
(-307.554 -65.7178 0)
(-259.757 -40.2792 0)
(-222.297 -24.6207 0)
(-191.248 -14.1391 0)
(-164.552 -7.03731 0)
(-141.293 -2.18509 0)
(-120.335 1.32355 0)
(-102.037 4.20268 0)
(-84.6628 6.72084 0)
(-67.5964 9.12814 0)
(-53.6553 11.2224 0)
(-40.9996 12.8178 0)
(-28.4784 14.2042 0)
(-16.5988 15.6108 0)
(-6.74132 17.4039 0)
(2.82888 18.8055 0)
(9.97819 21.8113 0)
(20.8765 23.9606 0)
(30.2983 26.9908 0)
(43.7058 28.335 0)
(64.7199 25.852 0)
(90.9396 22.0574 0)
(124.911 14.4626 0)
(164.334 9.51668 0)
(192.96 4.57201 0)
(246.561 -2.44035 0)
(2561.86 9.16252 0)
(39683.9 -108.294 0)
(-40508 -2682.63 0)
(29237.5 -329.112 0)
(-28470.9 -123.193 0)
(462.286 -238.613 0)
(461.322 -356.879 0)
(126.009 -507.941 0)
(-253.472 -506.454 0)
(-321.485 -473.458 0)
(-396.878 -377.315 0)
(-408.548 -263.942 0)
(-365.62 -164.771 0)
(-317.586 -99.117 0)
(-274.758 -58.876 0)
(-239.515 -34.1229 0)
(-208.778 -17.7084 0)
(-182.308 -7.13763 0)
(-158.813 -0.763676 0)
(-137.346 3.41619 0)
(-117.161 6.57782 0)
(-99.1785 9.45736 0)
(-82.0551 12.0801 0)
(-65.2748 14.6854 0)
(-51.7993 17.07 0)
(-39.5396 19.0247 0)
(-27.1537 20.87 0)
(-15.1465 22.7381 0)
(-5.4262 24.8724 0)
(4.58762 26.2936 0)
(11.8843 29.2414 0)
(22.4827 30.4562 0)
(31.3508 31.8715 0)
(42.0414 31.5302 0)
(60.155 27.3014 0)
(84.1196 20.4343 0)
(118.104 10.8519 0)
(159.888 3.99652 0)
(187.852 0.769525 0)
(249.602 -3.87825 0)
(2499.44 9.77247 0)
(38418.5 -154.031 0)
(-39237.7 -2939.88 0)
(28742.2 -1086.8 0)
(-28160 -121.143 0)
(342.142 -235.585 0)
(336.295 -348.25 0)
(67.8262 -479.779 0)
(-221.837 -447.516 0)
(-252.334 -397.84 0)
(-299.073 -309.439 0)
(-314.258 -215.773 0)
(-293.754 -135.979 0)
(-270.863 -82.3693 0)
(-244.923 -46.1382 0)
(-220.087 -22.4559 0)
(-196.293 -7.64808 0)
(-174.92 1.55671 0)
(-154.382 7.62032 0)
(-134.218 11.8161 0)
(-114.514 15.2127 0)
(-96.735 18.2538 0)
(-79.6249 21.0247 0)
(-62.7879 23.8841 0)
(-49.4738 26.557 0)
(-37.3378 28.7316 0)
(-24.9001 30.7545 0)
(-12.742 32.6162 0)
(-3.31504 34.5598 0)
(7.0391 35.6955 0)
(13.9893 38.6054 0)
(23.411 38.9342 0)
(31.3333 38.9934 0)
(39.3018 37.0463 0)
(54.0274 31.2941 0)
(75.0883 21.7532 0)
(109.071 9.33972 0)
(154.619 -1.90344 0)
(185.371 -7.90182 0)
(255.237 -13.4088 0)
(2417.17 -0.242157 0)
(36841.5 -216.178 0)
(-37647 -3229.38 0)
(28089.5 -1642.28 0)
(-27650.6 -138.711 0)
(243.437 -231.609 0)
(226.008 -326.632 0)
(30.3528 -433.101 0)
(-174.512 -379.451 0)
(-188.429 -321.286 0)
(-221.431 -248.284 0)
(-241.396 -173.313 0)
(-237.068 -109.324 0)
(-231.012 -64.4828 0)
(-217.023 -30.9271 0)
(-202.425 -8.8355 0)
(-185.639 7.16697 0)
(-167.595 18.2925 0)
(-148.927 26.9411 0)
(-130.03 33.6508 0)
(-110.958 39.2261 0)
(-93.5779 43.8856 0)
(-76.6295 47.6141 0)
(-59.9437 50.8494 0)
(-47.1281 53.2917 0)
(-35.4948 54.6 0)
(-23.4104 55.2313 0)
(-11.4796 55.1107 0)
(-2.45891 54.8528 0)
(8.4861 53.7404 0)
(15.0054 54.5098 0)
(22.8566 52.384 0)
(29.5315 49.8202 0)
(34.6221 44.9655 0)
(45.418 37.1614 0)
(62.9636 24.6196 0)
(95.3072 9.50758 0)
(143.273 -5.13574 0)
(176.765 -11.8933 0)
(256.983 -18.0954 0)
(2304.04 -11.9063 0)
(35306.8 -322.246 0)
(-36089.5 -3593.93 0)
(27046.9 -2279.28 0)
(-26800.6 -147.856 0)
(161.055 -223.085 0)
(142.13 -295.262 0)
(16.9282 -369.751 0)
(-114.088 -310.885 0)
(-125.938 -252.275 0)
(-156.481 -192.652 0)
(-180.351 -129.866 0)
(-188.882 -75.405 0)
(-195.317 -36.8442 0)
(-191.299 -6.23151 0)
(-183.378 15.2721 0)
(-170.152 31.958 0)
(-155.865 43.6553 0)
(-139.583 53.0733 0)
(-122.38 60.9764 0)
(-104.651 67.831 0)
(-88.6521 73.6211 0)
(-72.9142 78.025 0)
(-57.3168 81.5695 0)
(-45.8596 83.996 0)
(-35.4687 84.8942 0)
(-24.408 84.7633 0)
(-13.1066 83.4768 0)
(-4.63549 82.1168 0)
(6.70854 79.56 0)
(12.6823 78.6254 0)
(18.8919 74.3942 0)
(24.1845 69.2767 0)
(27.1034 61.3846 0)
(34.4214 50.3693 0)
(48.4401 33.2379 0)
(80.3977 13.5328 0)
(133.996 -6.36682 0)
(172.883 -14.3534 0)
(255.224 -21.3595 0)
(2124.08 -25.2682 0)
(33389.7 -455.318 0)
(-34079.1 -4059.63 0)
(25748.2 -2708.28 0)
(-25669.2 -159.745 0)
(101.392 -214.581 0)
(84.6756 -259.422 0)
(15.2978 -296.232 0)
(-61.3086 -240.245 0)
(-74.4952 -181.655 0)
(-103.473 -134.065 0)
(-128.412 -82.3804 0)
(-147.429 -39.7543 0)
(-164.354 -5.88968 0)
(-166.802 25.8576 0)
(-165.624 47.7188 0)
(-158.287 64.722 0)
(-147.247 76.8126 0)
(-132.235 87.3027 0)
(-115.809 96.8673 0)
(-98.7726 105.708 0)
(-83.7545 113.376 0)
(-68.9701 118.949 0)
(-54.1898 122.634 0)
(-43.9243 124.204 0)
(-34.7553 123.501 0)
(-24.7762 121.395 0)
(-14.0298 117.876 0)
(-6.23332 114.846 0)
(5.12168 110.496 0)
(10.0274 107.42 0)
(13.8479 101.323 0)
(16.995 93.1069 0)
(16.4021 82.0948 0)
(18.2948 67.8945 0)
(27.4667 46.8197 0)
(57.1427 25.0316 0)
(116.401 -0.35073 0)
(162.318 -8.81327 0)
(246.465 -16.4752 0)
(1885.86 -32.3995 0)
(31419.1 -587.508 0)
(-31961.3 -4472.01 0)
(24317.7 -3055.62 0)
(-24397.6 -138.081 0)
(65.0021 -170.036 0)
(63.448 -193.109 0)
(35.4077 -193.97 0)
(-3.67721 -154.529 0)
(-23.6189 -98.6508 0)
(-60.816 -67.9344 0)
(-89.4698 -24.3193 0)
(-115.172 11.1239 0)
(-132.091 40.5616 0)
(-139.64 68.9662 0)
(-145.927 86.6107 0)
(-142.116 101.586 0)
(-134.105 112.02 0)
(-120.257 121.671 0)
(-104.644 130.714 0)
(-88.7427 139.29 0)
(-75.8926 146.911 0)
(-63.9931 152.622 0)
(-52.253 156.774 0)
(-45.0245 158.972 0)
(-38.1751 158.723 0)
(-29.8283 156.885 0)
(-19.4175 153.434 0)
(-11.7472 150.903 0)
(-0.447049 146.787 0)
(3.84338 143.94 0)
(5.09895 138.97 0)
(5.65537 131.065 0)
(2.80774 119.611 0)
(0.429 107.549 0)
(7.13584 86.2823 0)
(34.9425 65.7461 0)
(101.382 35.4726 0)
(157.345 22.8368 0)
(232.496 20.8094 0)
(1573.81 -2.70853 0)
(29111.5 -625.792 0)
(-29448.7 -4775.62 0)
(22772.6 -3615.02 0)
(-22888.5 -35.1849 0)
(48.3656 -57.1673 0)
(61.6113 -72.6137 0)
(52.4741 -53.1878 0)
(30.5447 -42.3868 0)
(8.95089 4.58973 0)
(-31.8447 28.1507 0)
(-52.229 55.4827 0)
(-84.9069 80.6543 0)
(-108.615 100.52 0)
(-122.427 122.416 0)
(-134.19 134.017 0)
(-133.802 145.565 0)
(-127.892 154.432 0)
(-114.222 164.24 0)
(-98.8311 173.781 0)
(-83.1648 183.058 0)
(-70.907 191.37 0)
(-59.4651 197.237 0)
(-48.071 200.673 0)
(-42.0462 201.488 0)
(-36.7662 199.833 0)
(-29.8735 197.149 0)
(-19.7939 193.094 0)
(-12.6388 190.262 0)
(-1.58893 186.109 0)
(2.49536 183.835 0)
(1.44101 181.165 0)
(-1.66066 176.497 0)
(-6.25815 167.41 0)
(-13.8217 162.372 0)
(-12.8162 146.29 0)
(8.18055 132.377 0)
(75.0522 110.662 0)
(148.188 98.9856 0)
(221.849 111.26 0)
(1262.77 89.2307 0)
(26819.7 -512.583 0)
(-27041.6 -4972.54 0)
(20981 -2970.03 0)
(-20969.1 138.457 0)
(28.9344 90.0025 0)
(67.2828 64.6102 0)
(64.5355 70.2361 0)
(51.9993 63.3489 0)
(44.3536 102.25 0)
(-11.7738 120.51 0)
(-38.8754 133.911 0)
(-71.7729 150.92 0)
(-91.8484 162.919 0)
(-107.361 176.369 0)
(-123.62 181.871 0)
(-122.443 191.683 0)
(-116.109 199.884 0)
(-101.612 209.58 0)
(-86.5099 218.061 0)
(-71.7932 224.41 0)
(-62.2293 228.779 0)
(-55.0285 232.043 0)
(-48.1568 236.59 0)
(-45.8336 241.315 0)
(-42.3566 242.931 0)
(-36.3224 241.056 0)
(-26.0534 234.899 0)
(-18.4783 229.12 0)
(-6.64061 220.693 0)
(-0.920588 215.67 0)
(-1.97261 210.529 0)
(-7.59973 206.409 0)
(-10.8034 197.056 0)
(-19.9234 195.997 0)
(-21.7688 183.884 0)
(0.610456 174.728 0)
(69.2049 165.165 0)
(157.921 164.878 0)
(223.096 196.942 0)
(972.656 204.563 0)
(24233.8 -213.505 0)
(-24548.5 -4212.9 0)
(20436.6 -2502.03 0)
(-19939.8 362.212 0)
(-22.7958 297.283 0)
(42.5636 260.391 0)
(51.2587 217.104 0)
(61.395 214.143 0)
(64.0335 234.798 0)
(-1.33533 233.904 0)
(-22.9248 256.943 0)
(-56.9541 259.918 0)
(-84.0913 264.175 0)
(-104.164 255.969 0)
(-119.434 248.971 0)
(-116.444 246.87 0)
(-110.646 244.835 0)
(-96.7058 248.823 0)
(-84.5396 257.013 0)
(-72.8362 267.99 0)
(-63.5522 279.494 0)
(-51.9383 285.229 0)
(-39.1356 287.673 0)
(-35.9358 288.216 0)
(-37.016 284.63 0)
(-37.6135 282.659 0)
(-31.2964 279.464 0)
(-26.3285 281.458 0)
(-14.5491 282.531 0)
(-7.29821 285.33 0)
(-7.48369 288.268 0)
(-14.6445 292.341 0)
(-16.2911 292.019 0)
(-26.5144 294.141 0)
(-33.3119 288.427 0)
(-9.85751 274.121 0)
(65.5605 263.873 0)
(178.809 258.927 0)
(260.091 287.969 0)
(867.253 317.156 0)
(22562.9 84.3891 0)
(-23347.1 -4280.59 0)
(19722.8 35912.6 0)
(-18271.6 3208.08 0)
(-69.1837 1531.69 0)
(-9.98012 1508.99 0)
(19.9684 1654.89 0)
(69.0498 1975.02 0)
(63.3965 2272.19 0)
(9.56594 2527.47 0)
(-13.8076 2754.88 0)
(-64.8037 2884.7 0)
(-95.6542 2978.23 0)
(-122.012 3020.6 0)
(-132.387 3051.65 0)
(-126.429 3062.27 0)
(-114.227 3067.64 0)
(-89.8766 3061.94 0)
(-68.0399 3057.02 0)
(-50.1294 3019.16 0)
(-45.6175 3014.36 0)
(-47.1473 2959.55 0)
(-45.2782 2963.46 0)
(-48.7659 3028.56 0)
(-47.7113 3030.19 0)
(-41.3005 3083.12 0)
(-27.2109 3062.35 0)
(-15.5226 3080.09 0)
(-2.90983 3044.38 0)
(4.60821 3015.35 0)
(4.78337 2959.08 0)
(-3.98602 2884.88 0)
(-9.06795 2785.79 0)
(-23.3843 2626.75 0)
(-41.0613 2430.15 0)
(-23.0506 2136.11 0)
(54.564 1810.44 0)
(181.141 1447.12 0)
(279.207 1249.76 0)
(776.479 1095.71 0)
(19803.3 2613.75 0)
(-21437.1 31040.7 0)
(56411.2 668026 0)
(-53070.5 59253 0)
(-1660.1 25585.9 0)
(161.29 28370.6 0)
(500.34 30114.7 0)
(656.244 32795.4 0)
(596.395 34885.9 0)
(463.797 37180.4 0)
(321.314 39107.2 0)
(158.278 40660 0)
(46.8634 42108.6 0)
(-33.4086 43282.2 0)
(-79.2697 44365.7 0)
(-101.041 45316.6 0)
(-110.97 46215.4 0)
(-106.934 46965.7 0)
(-125.762 47627.7 0)
(-113.95 48121.7 0)
(-120.99 48310.4 0)
(-100.99 48324.1 0)
(27.359 48285.4 0)
(28.3741 48096.3 0)
(15.5649 47906 0)
(-6.63056 47003.9 0)
(-34.2238 46159.8 0)
(-43.638 44957.5 0)
(-76.9298 43771.1 0)
(-89.4975 42287.2 0)
(-133.211 40870.8 0)
(-181.636 39070.7 0)
(-265.03 37341.1 0)
(-369.218 35138.7 0)
(-506.111 32956.4 0)
(-607.033 30362.2 0)
(-598.38 27839.8 0)
(-361.482 24984.5 0)
(-78.5351 23194.9 0)
(2181.64 20304.7 0)
(51419 51772.3 0)
(-54294.9 605069 0)
(714599 -738658 0)
(-637351 -61979.3 0)
(-29828.7 -28836.2 0)
(4354.11 -31063.5 0)
(4283.94 -32695.8 0)
(4666.78 -35531.4 0)
(4288.87 -37841.8 0)
(4077.37 -40260.5 0)
(3339.27 -42260.8 0)
(2827.47 -43735.5 0)
(2431.18 -45041.8 0)
(2052.95 -46021.3 0)
(1828.05 -46882.6 0)
(1656.05 -47624.9 0)
(1474.97 -48328.2 0)
(1271.08 -48902.2 0)
(1045.93 -49431.4 0)
(607.73 -49807.3 0)
(149.417 -49916.5 0)
(-71.2598 -49825.5 0)
(-264.792 -49735.9 0)
(-414.335 -49539.7 0)
(-1100.4 -49329 0)
(-1724.06 -48386.7 0)
(-1999.26 -47517.3 0)
(-2317.33 -46306.1 0)
(-2576.06 -45098.6 0)
(-2790.22 -43615.4 0)
(-3094.73 -42203.1 0)
(-3405.35 -40389.7 0)
(-3798.1 -38647.8 0)
(-4248.65 -36367.7 0)
(-4643.95 -34070.9 0)
(-4953.6 -31259.8 0)
(-5127.5 -28568 0)
(-4294.8 -25688.9 0)
(-4230.43 -24317.7 0)
(28314.7 -22198.8 0)
(583303 -54436.7 0)
(-648181 -674488 0)
(714599 738658 0)
(-637351 61979.3 0)
(-29828.7 28836.2 0)
(4354.11 31063.5 0)
(4283.94 32695.8 0)
(4666.78 35531.4 0)
(4288.87 37841.8 0)
(4077.37 40260.5 0)
(3339.27 42260.8 0)
(2827.47 43735.5 0)
(2431.18 45041.8 0)
(2052.95 46021.3 0)
(1828.05 46882.6 0)
(1656.05 47624.9 0)
(1474.97 48328.2 0)
(1271.08 48902.2 0)
(1045.93 49431.4 0)
(607.73 49807.3 0)
(149.417 49916.5 0)
(-71.2597 49825.5 0)
(-264.792 49735.9 0)
(-414.335 49539.7 0)
(-1100.4 49329 0)
(-1724.06 48386.7 0)
(-1999.26 47517.3 0)
(-2317.33 46306.1 0)
(-2576.06 45098.6 0)
(-2790.22 43615.4 0)
(-3094.73 42203.1 0)
(-3405.35 40389.7 0)
(-3798.1 38647.8 0)
(-4248.65 36367.7 0)
(-4643.95 34070.9 0)
(-4953.6 31259.8 0)
(-5127.5 28568 0)
(-4294.8 25688.9 0)
(-4230.43 24317.7 0)
(28314.7 22198.8 0)
(583303 54436.7 0)
(-648181 674488 0)
(56411.2 -668026 0)
(-53070.5 -59253 0)
(-1660.1 -25585.9 0)
(161.29 -28370.6 0)
(500.34 -30114.7 0)
(656.244 -32795.4 0)
(596.395 -34885.9 0)
(463.797 -37180.4 0)
(321.314 -39107.2 0)
(158.278 -40660 0)
(46.8634 -42108.6 0)
(-33.4086 -43282.2 0)
(-79.2697 -44365.7 0)
(-101.041 -45316.6 0)
(-110.97 -46215.4 0)
(-106.934 -46965.7 0)
(-125.762 -47627.7 0)
(-113.95 -48121.7 0)
(-120.99 -48310.4 0)
(-100.99 -48324.1 0)
(27.359 -48285.4 0)
(28.3741 -48096.3 0)
(15.5649 -47906 0)
(-6.63056 -47003.9 0)
(-34.2238 -46159.8 0)
(-43.638 -44957.5 0)
(-76.9298 -43771.1 0)
(-89.4975 -42287.2 0)
(-133.211 -40870.8 0)
(-181.636 -39070.7 0)
(-265.03 -37341.1 0)
(-369.218 -35138.7 0)
(-506.111 -32956.4 0)
(-607.033 -30362.2 0)
(-598.38 -27839.8 0)
(-361.482 -24984.5 0)
(-78.5351 -23194.9 0)
(2181.64 -20304.7 0)
(51419 -51772.3 0)
(-54294.9 -605069 0)
(19722.8 -35912.6 0)
(-18271.6 -3208.08 0)
(-69.1837 -1531.69 0)
(-9.98012 -1508.99 0)
(19.9684 -1654.89 0)
(69.0498 -1975.02 0)
(63.3965 -2272.19 0)
(9.56594 -2527.47 0)
(-13.8076 -2754.88 0)
(-64.8037 -2884.7 0)
(-95.6542 -2978.23 0)
(-122.012 -3020.6 0)
(-132.387 -3051.65 0)
(-126.429 -3062.27 0)
(-114.227 -3067.64 0)
(-89.8766 -3061.94 0)
(-68.0399 -3057.02 0)
(-50.1294 -3019.16 0)
(-45.6175 -3014.36 0)
(-47.1473 -2959.55 0)
(-45.2782 -2963.46 0)
(-48.7659 -3028.56 0)
(-47.7113 -3030.19 0)
(-41.3005 -3083.12 0)
(-27.2109 -3062.35 0)
(-15.5226 -3080.09 0)
(-2.90983 -3044.38 0)
(4.60821 -3015.35 0)
(4.78337 -2959.08 0)
(-3.98602 -2884.88 0)
(-9.06795 -2785.79 0)
(-23.3843 -2626.75 0)
(-41.0613 -2430.15 0)
(-23.0506 -2136.11 0)
(54.564 -1810.44 0)
(181.141 -1447.12 0)
(279.207 -1249.76 0)
(776.479 -1095.71 0)
(19803.3 -2613.75 0)
(-21437.1 -31040.7 0)
(20436.6 2502.03 0)
(-19939.8 -362.212 0)
(-22.7958 -297.283 0)
(42.5636 -260.391 0)
(51.2587 -217.104 0)
(61.395 -214.143 0)
(64.0335 -234.798 0)
(-1.33533 -233.904 0)
(-22.9248 -256.943 0)
(-56.9541 -259.918 0)
(-84.0913 -264.175 0)
(-104.164 -255.969 0)
(-119.434 -248.971 0)
(-116.444 -246.87 0)
(-110.646 -244.835 0)
(-96.7058 -248.823 0)
(-84.5396 -257.013 0)
(-72.8362 -267.99 0)
(-63.5522 -279.494 0)
(-51.9383 -285.229 0)
(-39.1356 -287.673 0)
(-35.9358 -288.216 0)
(-37.016 -284.63 0)
(-37.6135 -282.659 0)
(-31.2964 -279.464 0)
(-26.3285 -281.458 0)
(-14.5491 -282.531 0)
(-7.29822 -285.33 0)
(-7.48369 -288.268 0)
(-14.6445 -292.341 0)
(-16.2911 -292.019 0)
(-26.5144 -294.141 0)
(-33.3119 -288.427 0)
(-9.85751 -274.121 0)
(65.5605 -263.873 0)
(178.809 -258.927 0)
(260.091 -287.969 0)
(867.253 -317.156 0)
(22562.9 -84.3891 0)
(-23347.1 4280.59 0)
(20981 2970.03 0)
(-20969.1 -138.457 0)
(28.9344 -90.0025 0)
(67.2828 -64.6102 0)
(64.5355 -70.2361 0)
(51.9993 -63.3489 0)
(44.3536 -102.25 0)
(-11.7738 -120.51 0)
(-38.8754 -133.911 0)
(-71.7729 -150.92 0)
(-91.8484 -162.919 0)
(-107.361 -176.369 0)
(-123.62 -181.871 0)
(-122.443 -191.683 0)
(-116.109 -199.884 0)
(-101.612 -209.58 0)
(-86.5099 -218.061 0)
(-71.7932 -224.41 0)
(-62.2293 -228.779 0)
(-55.0285 -232.043 0)
(-48.1568 -236.59 0)
(-45.8336 -241.315 0)
(-42.3566 -242.931 0)
(-36.3224 -241.056 0)
(-26.0534 -234.899 0)
(-18.4783 -229.12 0)
(-6.64061 -220.693 0)
(-0.920588 -215.67 0)
(-1.97261 -210.529 0)
(-7.59973 -206.409 0)
(-10.8034 -197.056 0)
(-19.9234 -195.997 0)
(-21.7688 -183.884 0)
(0.610456 -174.728 0)
(69.2049 -165.165 0)
(157.921 -164.878 0)
(223.096 -196.942 0)
(972.656 -204.563 0)
(24233.8 213.505 0)
(-24548.5 4212.9 0)
(22772.6 3615.02 0)
(-22888.5 35.1849 0)
(48.3656 57.1673 0)
(61.6113 72.6137 0)
(52.4741 53.1878 0)
(30.5447 42.3868 0)
(8.95089 -4.58973 0)
(-31.8447 -28.1507 0)
(-52.229 -55.4827 0)
(-84.9069 -80.6543 0)
(-108.615 -100.52 0)
(-122.427 -122.416 0)
(-134.19 -134.017 0)
(-133.802 -145.565 0)
(-127.892 -154.432 0)
(-114.222 -164.24 0)
(-98.8311 -173.781 0)
(-83.1648 -183.058 0)
(-70.907 -191.37 0)
(-59.4651 -197.237 0)
(-48.071 -200.673 0)
(-42.0462 -201.488 0)
(-36.7662 -199.833 0)
(-29.8735 -197.149 0)
(-19.7939 -193.094 0)
(-12.6388 -190.262 0)
(-1.58893 -186.109 0)
(2.49536 -183.835 0)
(1.44101 -181.165 0)
(-1.66066 -176.497 0)
(-6.25815 -167.41 0)
(-13.8217 -162.372 0)
(-12.8162 -146.29 0)
(8.18055 -132.377 0)
(75.0522 -110.662 0)
(148.188 -98.9856 0)
(221.849 -111.26 0)
(1262.77 -89.2307 0)
(26819.7 512.583 0)
(-27041.6 4972.54 0)
(24317.7 3055.62 0)
(-24397.6 138.081 0)
(65.0021 170.036 0)
(63.448 193.109 0)
(35.4077 193.97 0)
(-3.67721 154.529 0)
(-23.6189 98.6508 0)
(-60.816 67.9344 0)
(-89.4698 24.3193 0)
(-115.172 -11.1239 0)
(-132.091 -40.5616 0)
(-139.64 -68.9662 0)
(-145.927 -86.6107 0)
(-142.116 -101.586 0)
(-134.105 -112.02 0)
(-120.257 -121.671 0)
(-104.644 -130.714 0)
(-88.7427 -139.29 0)
(-75.8926 -146.911 0)
(-63.9931 -152.622 0)
(-52.253 -156.774 0)
(-45.0245 -158.972 0)
(-38.1751 -158.723 0)
(-29.8283 -156.885 0)
(-19.4175 -153.434 0)
(-11.7472 -150.903 0)
(-0.447049 -146.787 0)
(3.84338 -143.94 0)
(5.09895 -138.97 0)
(5.65537 -131.065 0)
(2.80774 -119.611 0)
(0.429 -107.549 0)
(7.13584 -86.2823 0)
(34.9425 -65.7461 0)
(101.382 -35.4726 0)
(157.345 -22.8368 0)
(232.496 -20.8094 0)
(1573.81 2.70853 0)
(29111.5 625.792 0)
(-29448.7 4775.62 0)
(25748.2 2708.28 0)
(-25669.2 159.745 0)
(101.392 214.581 0)
(84.6756 259.422 0)
(15.2978 296.232 0)
(-61.3086 240.245 0)
(-74.4952 181.655 0)
(-103.473 134.065 0)
(-128.412 82.3804 0)
(-147.429 39.7543 0)
(-164.354 5.88968 0)
(-166.802 -25.8576 0)
(-165.624 -47.7188 0)
(-158.287 -64.722 0)
(-147.247 -76.8126 0)
(-132.235 -87.3027 0)
(-115.809 -96.8673 0)
(-98.7726 -105.708 0)
(-83.7545 -113.376 0)
(-68.9701 -118.949 0)
(-54.1898 -122.634 0)
(-43.9243 -124.204 0)
(-34.7553 -123.501 0)
(-24.7762 -121.395 0)
(-14.0298 -117.876 0)
(-6.23332 -114.846 0)
(5.12168 -110.496 0)
(10.0274 -107.42 0)
(13.8479 -101.323 0)
(16.995 -93.1069 0)
(16.4021 -82.0948 0)
(18.2948 -67.8945 0)
(27.4667 -46.8197 0)
(57.1427 -25.0316 0)
(116.401 0.35073 0)
(162.318 8.81327 0)
(246.465 16.4752 0)
(1885.86 32.3995 0)
(31419.1 587.508 0)
(-31961.3 4472.01 0)
(27046.9 2279.28 0)
(-26800.6 147.856 0)
(161.055 223.085 0)
(142.13 295.262 0)
(16.9282 369.751 0)
(-114.088 310.885 0)
(-125.938 252.275 0)
(-156.481 192.652 0)
(-180.351 129.866 0)
(-188.882 75.405 0)
(-195.317 36.8442 0)
(-191.299 6.23151 0)
(-183.378 -15.2721 0)
(-170.152 -31.958 0)
(-155.865 -43.6553 0)
(-139.583 -53.0733 0)
(-122.38 -60.9764 0)
(-104.651 -67.831 0)
(-88.6521 -73.6211 0)
(-72.9142 -78.025 0)
(-57.3168 -81.5695 0)
(-45.8596 -83.996 0)
(-35.4687 -84.8942 0)
(-24.408 -84.7633 0)
(-13.1066 -83.4768 0)
(-4.63549 -82.1168 0)
(6.70854 -79.56 0)
(12.6823 -78.6254 0)
(18.8919 -74.3942 0)
(24.1845 -69.2767 0)
(27.1034 -61.3846 0)
(34.4214 -50.3693 0)
(48.4401 -33.2379 0)
(80.3977 -13.5328 0)
(133.996 6.36682 0)
(172.883 14.3534 0)
(255.224 21.3595 0)
(2124.08 25.2682 0)
(33389.7 455.318 0)
(-34079.1 4059.63 0)
(28089.5 1642.28 0)
(-27650.6 138.711 0)
(243.437 231.609 0)
(226.008 326.632 0)
(30.3528 433.101 0)
(-174.512 379.451 0)
(-188.429 321.286 0)
(-221.431 248.284 0)
(-241.396 173.313 0)
(-237.068 109.324 0)
(-231.012 64.4828 0)
(-217.023 30.9271 0)
(-202.425 8.8355 0)
(-185.639 -7.16697 0)
(-167.595 -18.2925 0)
(-148.927 -26.9411 0)
(-130.03 -33.6508 0)
(-110.958 -39.2261 0)
(-93.5779 -43.8856 0)
(-76.6295 -47.6141 0)
(-59.9437 -50.8494 0)
(-47.1281 -53.2917 0)
(-35.4948 -54.6 0)
(-23.4104 -55.2313 0)
(-11.4796 -55.1107 0)
(-2.45891 -54.8528 0)
(8.4861 -53.7404 0)
(15.0054 -54.5098 0)
(22.8566 -52.384 0)
(29.5315 -49.8202 0)
(34.6221 -44.9655 0)
(45.418 -37.1614 0)
(62.9636 -24.6196 0)
(95.3072 -9.50758 0)
(143.273 5.13574 0)
(176.765 11.8933 0)
(256.983 18.0954 0)
(2304.04 11.9063 0)
(35306.8 322.246 0)
(-36089.5 3593.93 0)
(28742.2 1086.8 0)
(-28160 121.143 0)
(342.142 235.585 0)
(336.295 348.25 0)
(67.8262 479.779 0)
(-221.837 447.516 0)
(-252.334 397.84 0)
(-299.073 309.439 0)
(-314.258 215.773 0)
(-293.754 135.979 0)
(-270.863 82.3693 0)
(-244.923 46.1382 0)
(-220.087 22.4559 0)
(-196.293 7.64808 0)
(-174.92 -1.55671 0)
(-154.382 -7.62032 0)
(-134.218 -11.8161 0)
(-114.514 -15.2127 0)
(-96.735 -18.2538 0)
(-79.6249 -21.0247 0)
(-62.7879 -23.8841 0)
(-49.4738 -26.557 0)
(-37.3378 -28.7316 0)
(-24.9001 -30.7545 0)
(-12.742 -32.6162 0)
(-3.31504 -34.5598 0)
(7.0391 -35.6955 0)
(13.9893 -38.6054 0)
(23.411 -38.9342 0)
(31.3333 -38.9934 0)
(39.3018 -37.0463 0)
(54.0274 -31.2941 0)
(75.0883 -21.7532 0)
(109.071 -9.33972 0)
(154.619 1.90344 0)
(185.371 7.90182 0)
(255.237 13.4088 0)
(2417.17 0.242157 0)
(36841.5 216.178 0)
(-37647 3229.38 0)
(29237.5 329.112 0)
(-28470.9 123.193 0)
(462.286 238.613 0)
(461.322 356.879 0)
(126.009 507.941 0)
(-253.472 506.454 0)
(-321.485 473.458 0)
(-396.878 377.315 0)
(-408.548 263.942 0)
(-365.62 164.771 0)
(-317.586 99.117 0)
(-274.758 58.876 0)
(-239.515 34.1229 0)
(-208.778 17.7084 0)
(-182.308 7.13763 0)
(-158.813 0.763676 0)
(-137.346 -3.41619 0)
(-117.161 -6.57782 0)
(-99.1785 -9.45736 0)
(-82.0551 -12.0801 0)
(-65.2748 -14.6854 0)
(-51.7993 -17.07 0)
(-39.5396 -19.0247 0)
(-27.1537 -20.87 0)
(-15.1465 -22.7381 0)
(-5.4262 -24.8724 0)
(4.58762 -26.2936 0)
(11.8843 -29.2414 0)
(22.4827 -30.4562 0)
(31.3508 -31.8715 0)
(42.0414 -31.5302 0)
(60.155 -27.3014 0)
(84.1196 -20.4343 0)
(118.104 -10.8519 0)
(159.888 -3.99652 0)
(187.852 -0.769525 0)
(249.602 3.87825 0)
(2499.44 -9.77247 0)
(38418.5 154.031 0)
(-39237.7 2939.88 0)
(29130.7 103.324 0)
(-28247.2 103.955 0)
(567.33 255.206 0)
(595.829 375.174 0)
(211.962 521.942 0)
(-255.066 554.774 0)
(-376.777 541.539 0)
(-500.97 445.472 0)
(-519.074 312.831 0)
(-452.585 192.267 0)
(-372.908 111.501 0)
(-307.554 65.7178 0)
(-259.757 40.2792 0)
(-222.297 24.6207 0)
(-191.248 14.1391 0)
(-164.552 7.03731 0)
(-141.293 2.18509 0)
(-120.335 -1.32355 0)
(-102.037 -4.20268 0)
(-84.6628 -6.72084 0)
(-67.5964 -9.12814 0)
(-53.6553 -11.2224 0)
(-40.9996 -12.8178 0)
(-28.4784 -14.2042 0)
(-16.5988 -15.6108 0)
(-6.74132 -17.4039 0)
(2.82888 -18.8055 0)
(9.97819 -21.8113 0)
(20.8765 -23.9606 0)
(30.2983 -26.9908 0)
(43.7058 -28.335 0)
(64.7199 -25.852 0)
(90.9396 -22.0574 0)
(124.911 -14.4626 0)
(164.334 -9.51668 0)
(192.96 -4.57201 0)
(246.561 2.44035 0)
(2561.86 -9.16252 0)
(39683.9 108.294 0)
(-40508 2682.63 0)
(29513.3 -2739.78 0)
(-28324.5 35.8844 0)
(723.642 286.858 0)
(718.359 414.736 0)
(299.078 549.428 0)
(-234.587 611.989 0)
(-426.812 607.788 0)
(-617.27 518.689 0)
(-652.546 368.9 0)
(-559.628 225.927 0)
(-439.533 124.776 0)
(-343.39 69.6196 0)
(-279.118 41.3316 0)
(-233.967 25.6843 0)
(-199.252 15.4103 0)
(-170.332 7.8642 0)
(-145.403 2.38206 0)
(-123.317 -1.60179 0)
(-104.38 -4.52996 0)
(-86.8014 -6.80948 0)
(-69.6126 -8.88698 0)
(-55.3548 -10.6342 0)
(-42.4129 -11.8926 0)
(-29.8451 -12.8717 0)
(-18.2298 -13.7571 0)
(-8.50479 -14.991 0)
(0.34041 -16.0473 0)
(6.91673 -18.5082 0)
(17.4916 -20.5177 0)
(27.1355 -23.6517 0)
(43.1388 -25.0007 0)
(66.2043 -22.7285 0)
(95.0949 -19.7418 0)
(130.188 -11.9059 0)
(169.419 -7.72115 0)
(199.374 -1.49542 0)
(245.178 6.32011 0)
(2601.44 -5.30188 0)
(41012.4 94.5603 0)
(-41850 2514.05 0)
(26576.1 -5020.11 0)
(-25330.6 3.98198 0)
(932.405 335.462 0)
(848.851 506.4 0)
(402.042 602.814 0)
(-198.828 671.581 0)
(-466.684 649.88 0)
(-731.172 573.343 0)
(-801.19 418.763 0)
(-687.832 262.257 0)
(-523.531 140.187 0)
(-387.964 74.54 0)
(-302.095 42.7722 0)
(-247.276 26.8087 0)
(-208.42 16.5313 0)
(-177.107 8.83746 0)
(-150.414 3.05428 0)
(-126.996 -1.18131 0)
(-107.056 -4.25537 0)
(-88.8614 -6.46639 0)
(-71.2821 -8.27513 0)
(-56.5516 -9.65518 0)
(-43.1558 -10.509 0)
(-30.2752 -10.987 0)
(-18.6409 -11.1942 0)
(-8.94824 -11.5694 0)
(-0.560428 -11.8586 0)
(5.6703 -13.2095 0)
(15.92 -14.25 0)
(25.9783 -16.5077 0)
(44.5954 -17.0633 0)
(69.7876 -14.4417 0)
(101.369 -11.3221 0)
(136.495 -3.79015 0)
(174.366 -0.837994 0)
(206.49 4.92699 0)
(242.893 12.0425 0)
(2646.9 0.131232 0)
(42111.6 66.1705 0)
(-42984.7 2269.67 0)
(24689 -4573.01 0)
(-23163.7 68.2363 0)
(1207.79 416.069 0)
(975.989 762.81 0)
(458.253 745.897 0)
(-189.233 765.953 0)
(-521.477 684.336 0)
(-839.983 600.173 0)
(-952.32 450.426 0)
(-828.074 285.723 0)
(-620.424 146.937 0)
(-437.263 72.8316 0)
(-325.113 38.8574 0)
(-259.254 24.1557 0)
(-216.57 15.228 0)
(-183.319 8.28755 0)
(-155.057 2.86673 0)
(-130.361 -1.07631 0)
(-109.472 -3.84396 0)
(-90.675 -5.79094 0)
(-72.6855 -7.31613 0)
(-57.5074 -8.42769 0)
(-43.6963 -9.06554 0)
(-30.5055 -9.34485 0)
(-18.7911 -9.3114 0)
(-9.14499 -9.3228 0)
(-1.24003 -9.32851 0)
(4.61229 -10.1888 0)
(14.3133 -10.7942 0)
(24.4244 -12.68 0)
(45.1296 -13.1097 0)
(71.7368 -10.8244 0)
(105.359 -8.40849 0)
(140.291 -1.55336 0)
(177.819 0.77677 0)
(211.786 7.87286 0)
(240.557 14.0633 0)
(2653.6 9.0898 0)
(43199.4 64.886 0)
(-44090.8 2060.61 0)
(22324.7 -5634.6 0)
(-20522.9 386.383 0)
(1601.72 706.877 0)
(1166.69 1189.73 0)
(405.071 1019.07 0)
(-258.151 892.773 0)
(-626.435 720.855 0)
(-956.576 591.548 0)
(-1104.21 457.445 0)
(-980.285 289.308 0)
(-728.681 150.155 0)
(-492.113 67.9705 0)
(-349.001 33.5267 0)
(-270.046 20.8696 0)
(-223.711 13.9077 0)
(-189.019 8.13531 0)
(-159.438 3.30472 0)
(-133.463 -0.268811 0)
(-111.599 -2.67787 0)
(-92.2073 -4.30438 0)
(-73.8229 -5.52845 0)
(-58.2374 -6.39477 0)
(-44.0396 -6.86618 0)
(-30.5121 -7.02064 0)
(-18.6197 -6.85581 0)
(-8.96473 -6.64595 0)
(-1.39492 -6.44503 0)
(4.25789 -6.82778 0)
(13.5194 -6.97487 0)
(23.7471 -8.24085 0)
(46.3835 -8.21546 0)
(74.3178 -5.86871 0)
(110.303 -3.38501 0)
(145.346 3.92485 0)
(183.45 6.43621 0)
(219.294 14.9318 0)
(244.066 18.816 0)
(2695.87 24.3305 0)
(44088.5 79.7105 0)
(-45025 1843.6 0)
(19933 -7543.39 0)
(-17052.8 1250.53 0)
(1981.93 1238.85 0)
(1276.83 1713.4 0)
(172.09 1372.35 0)
(-476.604 1028.39 0)
(-811.748 746.002 0)
(-1093.81 536.56 0)
(-1243.57 415.208 0)
(-1124.19 267.24 0)
(-833.713 138.07 0)
(-549.65 56.2561 0)
(-370.502 24.7983 0)
(-278.16 15.7741 0)
(-228.841 11.4566 0)
(-193.537 7.30946 0)
(-163.156 3.43813 0)
(-136.126 0.472416 0)
(-113.361 -1.51002 0)
(-93.4219 -2.78971 0)
(-74.6999 -3.72324 0)
(-58.7965 -4.37851 0)
(-44.2994 -4.7405 0)
(-30.4955 -4.86363 0)
(-18.43 -4.72594 0)
(-8.74915 -4.51811 0)
(-1.41524 -4.31174 0)
(4.10171 -4.50057 0)
(12.9517 -4.5209 0)
(23.229 -5.45858 0)
(47.4155 -5.36749 0)
(76.3916 -3.43835 0)
(114.797 -1.44059 0)
(149.755 5.64733 0)
(188.426 7.42731 0)
(223.716 15.9454 0)
(249.614 13.7755 0)
(2712.28 33.0116 0)
(44952.5 123.33 0)
(-45906.8 1872.75 0)
(18483 -9252.15 0)
(-12060.1 2512.68 0)
(2047.76 2449.13 0)
(1295.33 2414.45 0)
(-255.035 1790.67 0)
(-861.724 1109.61 0)
(-1100.38 680.77 0)
(-1275.34 441.539 0)
(-1363.73 322.357 0)
(-1247.35 224.015 0)
(-931.993 110.054 0)
(-601.266 39.2864 0)
(-388.011 14.7806 0)
(-282.903 10.1993 0)
(-231.868 8.34144 0)
(-196.746 5.7622 0)
(-166.026 2.99772 0)
(-138.231 0.819551 0)
(-114.742 -0.64349 0)
(-94.34 -1.55491 0)
(-75.3539 -2.20746 0)
(-59.2177 -2.66554 0)
(-44.5071 -2.92701 0)
(-30.498 -3.02749 0)
(-18.2867 -2.9402 0)
(-8.56559 -2.78387 0)
(-1.37802 -2.61966 0)
(4.05634 -2.69864 0)
(12.5963 -2.67045 0)
(22.9313 -3.26923 0)
(48.3303 -3.10705 0)
(78.1019 -1.65091 0)
(119.058 -0.116243 0)
(153.891 5.92905 0)
(193.373 7.07968 0)
(225.411 14.6224 0)
(260.512 7.87143 0)
(2801.44 34.7416 0)
(45861.4 179.419 0)
(-46850.4 3519.06 0)
(18860.4 -2595.5 0)
(-5777.06 3525.16 0)
(1887.27 3786.16 0)
(642.314 3073.82 0)
(-1085.3 1823.32 0)
(-1546.14 894.463 0)
(-1455.53 450.125 0)
(-1439.19 295.984 0)
(-1453.18 208.441 0)
(-1328.77 171.956 0)
(-1011.72 76.3535 0)
(-641.459 22.6659 0)
(-398.531 7.24233 0)
(-284.365 5.87985 0)
(-233.117 5.37586 0)
(-198.686 3.8858 0)
(-167.919 2.07589 0)
(-139.634 0.617807 0)
(-115.649 -0.364885 0)
(-94.929 -0.967914 0)
(-75.7701 -1.38306 0)
(-59.4899 -1.66663 0)
(-44.6482 -1.82149 0)
(-30.5082 -1.86654 0)
(-18.1953 -1.78197 0)
(-8.44026 -1.64139 0)
(-1.33311 -1.48997 0)
(4.05277 -1.48186 0)
(12.4018 -1.38091 0)
(22.8082 -1.69239 0)
(48.975 -1.46291 0)
(79.2736 -0.377654 0)
(122.101 0.651046 0)
(156.689 5.17052 0)
(196.803 5.27892 0)
(224.479 11.5124 0)
(269.001 1.22514 0)
(2877.59 25.8806 0)
(48310.1 40.1407 0)
(-49646.4 -510.296 0)
)
;
boundaryField
{
inlet
{
type extrapolatedCalculated;
value nonuniform List<vector> 5((560243 -0.799053 0) (560239 -1.33221 0) (560237 1.53477e-08 0) (560239 1.33221 0) (560243 0.799053 0));
}
outlet
{
type extrapolatedCalculated;
value nonuniform List<vector>
165
(
(51184.6 2595.5 0)
(62798.9 9252.15 0)
(76003.8 7543.39 0)
(87430.6 5634.6 0)
(97119.9 4573.01 0)
(104878 5020.11 0)
(116451 2739.78 0)
(115337 -103.324 0)
(115901 -329.112 0)
(114163 -1086.8 0)
(111744 -1642.28 0)
(107875 -2279.28 0)
(102953 -2708.28 0)
(97504.6 -3055.62 0)
(91379.3 -3615.02 0)
(83932 -2970.03 0)
(80716.3 -2502.03 0)
(75895.4 35912.6 0)
(215696 668026 0)
(2.63892e+06 -738658 0)
(714599 -2.7385e+06 0)
(-637351 -236527 0)
(-29828.7 -106201 0)
(4354.11 -116233 0)
(4283.94 -122622 0)
(4666.78 -133021 0)
(4288.87 -141238 0)
(4077.37 -150143 0)
(3339.27 -157575 0)
(2827.47 -163357 0)
(2431.18 -168677 0)
(2052.95 -172877 0)
(1828.05 -176689 0)
(1656.05 -180043 0)
(1474.97 -183227 0)
(1271.08 -185889 0)
(1045.93 -188294 0)
(607.73 -190131 0)
(149.417 -190762 0)
(-71.2598 -190729 0)
(-264.792 -190462 0)
(-414.335 -189551 0)
(-1100.4 -188730 0)
(-1724.06 -184929 0)
(-1999.26 -181542 0)
(-2317.33 -176689 0)
(-2576.06 -171985 0)
(-2790.22 -166121 0)
(-3094.73 -160589 0)
(-3405.35 -153523 0)
(-3798.1 -146788 0)
(-4248.65 -138146 0)
(-4643.95 -129582 0)
(-4953.6 -119342 0)
(-5127.5 -109555 0)
(-4294.8 -98800.3 0)
(-4230.43 -92891.1 0)
(28314.7 -83203.1 0)
(583303 -207367 0)
(-648181 -2.49169e+06 0)
(-190484 510.296 0)
(-180121 -3519.06 0)
(-176568 -1872.75 0)
(-173099 -1843.6 0)
(-169536 -2060.61 0)
(-165172 -2269.67 0)
(-160808 -2514.05 0)
(-155556 -2682.63 0)
(-150622 -2939.88 0)
(-144465 -3229.38 0)
(-138518 -3593.93 0)
(-131023 -4059.63 0)
(-123316 -4472.01 0)
(-114276 -4775.62 0)
(-105478 -4972.54 0)
(-95880 -4212.9 0)
(-90381.3 -4280.59 0)
(-81244.8 31040.7 0)
(-207064 605069 0)
(-2.40109e+06 -674488 0)
(-182271 -3325.78 0)
(-182062 1262.93 0)
(-184039 -2.2718e-07 0)
(-182062 -1262.93 0)
(-182271 3325.78 0)
(-2.40109e+06 674488 0)
(-207064 -605069 0)
(-81244.8 -31040.7 0)
(-90381.3 4280.59 0)
(-95880 4212.9 0)
(-105478 4972.54 0)
(-114276 4775.62 0)
(-123316 4472.01 0)
(-131023 4059.63 0)
(-138518 3593.93 0)
(-144465 3229.38 0)
(-150622 2939.88 0)
(-155556 2682.63 0)
(-160808 2514.05 0)
(-165172 2269.67 0)
(-169536 2060.61 0)
(-173099 1843.6 0)
(-176568 1872.75 0)
(-180121 3519.06 0)
(-190484 -510.296 0)
(714599 2.7385e+06 0)
(-637351 236527 0)
(-29828.7 106201 0)
(4354.11 116233 0)
(4283.94 122622 0)
(4666.78 133021 0)
(4288.87 141238 0)
(4077.37 150143 0)
(3339.27 157575 0)
(2827.47 163357 0)
(2431.18 168677 0)
(2052.95 172877 0)
(1828.05 176689 0)
(1656.05 180043 0)
(1474.97 183227 0)
(1271.08 185889 0)
(1045.93 188294 0)
(607.73 190131 0)
(149.417 190762 0)
(-71.2597 190729 0)
(-264.792 190462 0)
(-414.335 189551 0)
(-1100.4 188730 0)
(-1724.06 184929 0)
(-1999.26 181542 0)
(-2317.33 176689 0)
(-2576.06 171985 0)
(-2790.22 166121 0)
(-3094.73 160589 0)
(-3405.35 153523 0)
(-3798.1 146788 0)
(-4248.65 138146 0)
(-4643.95 129582 0)
(-4953.6 119342 0)
(-5127.5 109555 0)
(-4294.8 98800.3 0)
(-4230.43 92891.1 0)
(28314.7 83203.1 0)
(583303 207367 0)
(-648181 2.49169e+06 0)
(2.63892e+06 738658 0)
(215696 -668026 0)
(75895.4 -35912.6 0)
(80716.3 2502.03 0)
(83932 2970.03 0)
(91379.3 3615.02 0)
(97504.6 3055.62 0)
(102953 2708.28 0)
(107875 2279.28 0)
(111744 1642.28 0)
(114163 1086.8 0)
(115901 329.112 0)
(115337 103.324 0)
(116451 -2739.78 0)
(104878 -5020.11 0)
(97119.9 -4573.01 0)
(87430.6 -5634.6 0)
(76003.8 -7543.39 0)
(62798.9 -9252.15 0)
(51184.6 -2595.5 0)
)
;
}
obstacle
{
type extrapolatedCalculated;
value nonuniform List<vector>
40
(
(159735 -1.45519e-10 0)
(-135235 0 0)
(-17290.6 0 0)
(-3854.2 0 0)
(-2298.05 0 0)
(-1640.25 -3.63798e-11 0)
(-1523.84 0 0)
(-1388.17 0 0)
(-1444.96 3.63798e-11 0)
(-695.423 0 0)
(159735 -1.45519e-10 0)
(-135235 0 0)
(-17290.6 0 0)
(-3854.2 0 0)
(-2298.05 0 0)
(-1640.25 3.63798e-11 0)
(-1523.84 -3.63798e-11 0)
(-1388.17 -3.63798e-11 0)
(-1444.96 3.63798e-11 0)
(-695.423 0 0)
(-828.758 -552.506 1.32236e-11)
(-1211.87 -807.91 -1.57329e-11)
(-1386.88 -924.59 -1.98533e-11)
(-1324.64 -883.097 0)
(-11741 -7827.33 -8.45443e-11)
(-828.758 552.506 -3.94711e-11)
(-1211.87 807.91 -1.57329e-11)
(-1386.88 924.59 -1.98533e-11)
(-1324.64 883.097 -5.36634e-11)
(-11741 7827.33 8.45443e-11)
(-20005.9 -2222.88 1.41154e-11)
(-4107.01 -456.334 -1.37433e-14)
(-5368.95 -596.55 0)
(-7433.67 -825.963 2.48753e-14)
(-11932.6 -1325.84 6.37106e-12)
(-20005.9 2222.88 2.81639e-11)
(-4107.01 456.334 -2.27619e-11)
(-5368.95 596.55 0)
(-7433.67 825.963 1.56302e-11)
(-11932.6 1325.84 -6.37106e-12)
)
;
}
empty
{
type empty;
}
}
// ************************************************************************* //
|
|
d467fc8f7b163dfd1f7b02ac40e06391bdf385f2
|
92035a680e5e89e5afbdbb66778d6406cbe705ba
|
/TriangleTemplate/Animation.h
|
700af196e680dd10cd702a9e9648b8cee1a8cf61
|
[] |
no_license
|
ngkaizhe/DigitalMeshProcessingP2
|
27ca511ced515510a1966da9dfb2fb7c6845b8e6
|
3438e02cf3099e1eb01a00d20099e882274c0353
|
refs/heads/master
| 2023-06-08T09:33:57.844304
| 2021-01-12T14:09:53
| 2021-01-12T14:09:53
| 321,357,926
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,768
|
h
|
Animation.h
|
#pragma once
#include "Common.h"
#include "Shader.h"
#include "ARAPTool.h"
#include <vector>
#include <map>
using namespace std;
extern float imageScale;
extern int ScreenWidth;
extern int ScreenHeight;
enum btnType{ RECORD, START, STOP, SAVE, CLEAR, TIMELINE};
enum AnimState {NONE, RECORDING, PLAYING};
class Button {
//model info
typedef struct
{
GLuint vao;
GLuint vbo;
GLuint vboTex;
GLuint ebo;
GLuint p_normal;
// texture
unsigned int texture;
unsigned int texture1;
glm::mat4 model;
} Shape;
public:
Button();
Button(float w, float h, btnType t);
Button(glm::vec2 c, float w, float h, btnType t);
void InitVAOandVBO();
void InitFinish();
bool Collider(int x, int y);
virtual void Render(Shader shader);
virtual bool Click(int x, int y);
Shape m_shape;
btnType type;
glm::vec2 center;
float width;
float height;
bool keep = false;
bool clickf = false;
bool initf = false;
int total_cd = 8;
int cd = 8;
};
class AnimControlPoint {
public:
AnimControlPoint();
AnimControlPoint(vector<CtrlPoint> cps);
vector<CtrlPoint> keyPoints;
};
class AnimationData {
public:
AnimationData();
AnimationData(map<float, AnimControlPoint*> frames, vector<float> indexs);
map<float, AnimControlPoint*> keyframes;
vector<float> framesIndex;
};
class TimeLine :public Button {
public:
TimeLine();
TimeLine(float w, float h, float sp);
TimeLine(glm::vec2 c, float w, float h, float sp);
void SetKeyTime();
void BindKey();
void CheckIndex();
bool Click(int x, int y);
void SetKeyFrame(vector<CtrlPoint> cps, bool init);
void SetAnimation(map<float, AnimControlPoint*> frames, vector<float> indexs);
void Clear();
//void AnimationParser(string path);
AnimationData* SaveAnimation(int index);
void Render(Shader shader, Shader textureShader, ARAPTool* a);
void Play(bool f);
void SetSpeed(float sp);
private:
GLuint line_vao;
GLuint key_vao;
map<float, AnimControlPoint*> keyframes;
vector<float> framesIndex;
float key_time;
float speed;
bool isplay = false;
int key_index = 0;
};
class Animation
{
public:
Animation();
Animation(TimeLine* tl, Button* rec, Button* star, Button* stop, Button* save_btn, Button* clear_btn);
void InitFinish();
void Render(Shader normalShader, Shader textureShader, ARAPTool* a);
int Click(int state, int x, int y);
void SetKeyFrame(vector<CtrlPoint> cps, bool init = false);
void AnimationParser();
void OnAnimationListChange(int index);
void SetSpeed(float speed);
vector<int> GetCpsPos();
TimeLine* timeLine;
Button* record_btn;
Button* start_btn;
Button* stop_btn;
Button* save_btn;
Button* clear_btn;
int animIndex = -1;
vector<AnimationData*> animationList;
AnimState animState = AnimState::NONE;
std::vector<CtrlPoint> lastCPs;
};
|
145b119a291be4a51e709b1be5ab48d82a0e514f
|
a3d6556180e74af7b555f8d47d3fea55b94bcbda
|
/storage/browser/blob/blob_memory_controller.cc
|
714f8b53102c678085f05d910cb6fb6f3b604972
|
[
"BSD-3-Clause"
] |
permissive
|
chromium/chromium
|
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
|
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
|
refs/heads/main
| 2023-08-24T00:35:12.585945
| 2023-08-23T22:01:11
| 2023-08-23T22:01:11
| 120,360,765
| 17,408
| 7,102
|
BSD-3-Clause
| 2023-09-10T23:44:27
| 2018-02-05T20:55:32
| null |
UTF-8
|
C++
| false
| false
| 42,714
|
cc
|
blob_memory_controller.cc
|
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "storage/browser/blob/blob_memory_controller.h"
#include <algorithm>
#include <memory>
#include <numeric>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/small_map.h"
#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/numerics/safe_math.h"
#include "base/strings/string_number_conversions.h"
#include "base/system/sys_info.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_runner.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "storage/browser/blob/blob_data_builder.h"
#include "storage/browser/blob/blob_data_item.h"
#include "storage/browser/blob/shareable_blob_data_item.h"
#include "storage/browser/blob/shareable_file_reference.h"
using base::File;
using base::FilePath;
namespace storage {
namespace {
constexpr int64_t kUnknownDiskAvailability = -1ll;
const int64_t kMinSecondsForPressureEvictions = 30;
using FileCreationInfo = BlobMemoryController::FileCreationInfo;
using MemoryAllocation = BlobMemoryController::MemoryAllocation;
using QuotaAllocationTask = BlobMemoryController::QuotaAllocationTask;
using DiskSpaceFuncPtr = BlobMemoryController::DiskSpaceFuncPtr;
File::Error CreateBlobDirectory(const FilePath& blob_storage_dir) {
File::Error error = File::FILE_OK;
base::CreateDirectoryAndGetError(blob_storage_dir, &error);
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.CreateDirectoryResult", -error,
-File::FILE_ERROR_MAX);
DLOG_IF(ERROR, error != File::FILE_OK)
<< "Error creating blob storage directory '"
<< blob_storage_dir.LossyDisplayName() << "': " << error;
return error;
}
// CrOS:
// * Ram - 20%
// * Disk - 50%
// Note: The disk is the user partition, so the operating system can still
// function if this is full.
// Android:
// * RAM - 1%
// * Disk - 6%
// Desktop:
// * Ram - 20%, or 2 GB if x64.
// * Disk - 10%
BlobStorageLimits CalculateBlobStorageLimitsImpl(
const FilePath& storage_dir,
bool disk_enabled,
absl::optional<uint64_t> optional_memory_size_for_testing) {
int64_t disk_size = 0ull;
uint64_t memory_size = optional_memory_size_for_testing
? optional_memory_size_for_testing.value()
: base::SysInfo::AmountOfPhysicalMemory();
if (disk_enabled && CreateBlobDirectory(storage_dir) == base::File::FILE_OK)
disk_size = base::SysInfo::AmountOfTotalDiskSpace(storage_dir);
BlobStorageLimits limits;
// Don't do specialty configuration for error size (-1).
if (memory_size > 0) {
#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID) && \
defined(ARCH_CPU_64_BITS)
constexpr size_t kTwoGigabytes = 2ull * 1024 * 1024 * 1024;
limits.max_blob_in_memory_space = kTwoGigabytes;
#elif BUILDFLAG(IS_ANDROID)
limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 100);
#else
limits.max_blob_in_memory_space = static_cast<size_t>(memory_size / 5);
#endif
}
// Devices just on the edge (RAM == 256MB) should not fail because
// max_blob_in_memory_space turns out smaller than min_page_file_size
// causing the CHECK below to fail.
if (limits.max_blob_in_memory_space < limits.min_page_file_size)
limits.max_blob_in_memory_space = limits.min_page_file_size;
// Don't do specialty configuration for error size (-1). Allow no disk.
if (disk_size >= 0) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 2ll);
#elif BUILDFLAG(IS_ANDROID)
limits.desired_max_disk_space = static_cast<uint64_t>(3ll * disk_size / 50);
#else
limits.desired_max_disk_space = static_cast<uint64_t>(disk_size / 10ll);
#endif
}
limits.effective_max_disk_space = limits.desired_max_disk_space;
CHECK(limits.IsValid());
return limits;
}
void DestructFile(File infos_without_references) {}
void DeleteFiles(std::vector<FileCreationInfo> files) {
for (FileCreationInfo& file_info : files) {
file_info.file.Close();
base::DeleteFile(file_info.path);
}
}
struct EmptyFilesResult {
EmptyFilesResult() = default;
EmptyFilesResult(std::vector<FileCreationInfo> files,
File::Error file_error,
int64_t disk_availability)
: files(std::move(files)),
file_error(file_error),
disk_availability(disk_availability) {}
~EmptyFilesResult() = default;
EmptyFilesResult(EmptyFilesResult&& o) = default;
EmptyFilesResult& operator=(EmptyFilesResult&& other) = default;
std::vector<FileCreationInfo> files;
File::Error file_error = File::FILE_ERROR_FAILED;
int64_t disk_availability = 0;
};
// Used for new unpopulated file items. Caller must populate file reference in
// returned FileCreationInfos. Also returns the currently available disk space
// (without the future size of these files).
EmptyFilesResult CreateEmptyFiles(
const FilePath& blob_storage_dir,
DiskSpaceFuncPtr disk_space_function,
scoped_refptr<base::TaskRunner> file_task_runner,
std::vector<base::FilePath> file_paths) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
File::Error dir_create_status = CreateBlobDirectory(blob_storage_dir);
if (dir_create_status != File::FILE_OK) {
return EmptyFilesResult(std::vector<FileCreationInfo>(), dir_create_status,
kUnknownDiskAvailability);
}
int64_t free_disk_space = disk_space_function(blob_storage_dir);
std::vector<FileCreationInfo> result;
for (const base::FilePath& file_path : file_paths) {
FileCreationInfo creation_info;
// Try to open our file.
uint32_t flags = File::FLAG_CREATE_ALWAYS | File::FLAG_WRITE;
// This File may be passed to an untrusted process.
flags = base::File::AddFlagsForPassingToUntrustedProcess(flags);
File file(file_path, flags);
creation_info.path = std::move(file_path);
creation_info.file_deletion_runner = file_task_runner;
creation_info.error = file.error_details();
if (creation_info.error != File::FILE_OK) {
return EmptyFilesResult(std::vector<FileCreationInfo>(),
creation_info.error, free_disk_space);
}
creation_info.file = std::move(file);
result.push_back(std::move(creation_info));
}
return EmptyFilesResult(std::move(result), File::FILE_OK, free_disk_space);
}
// Used to evict multiple memory items out to a single file. Caller must
// populate file reference in returned FileCreationInfo. Also returns the free
// disk space AFTER creating this file.
std::pair<FileCreationInfo, int64_t> CreateFileAndWriteItems(
const FilePath& blob_storage_dir,
DiskSpaceFuncPtr disk_space_function,
const FilePath& file_path,
scoped_refptr<base::TaskRunner> file_task_runner,
std::vector<base::span<const uint8_t>> data,
size_t total_size_bytes) {
DCHECK_NE(0u, total_size_bytes);
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
FileCreationInfo creation_info;
creation_info.file_deletion_runner = std::move(file_task_runner);
creation_info.error = CreateBlobDirectory(blob_storage_dir);
if (creation_info.error != File::FILE_OK)
return std::make_pair(std::move(creation_info), kUnknownDiskAvailability);
int64_t free_disk_space = disk_space_function(blob_storage_dir);
// Fail early instead of creating the files if we fill the disk.
if (free_disk_space != kUnknownDiskAvailability &&
free_disk_space < static_cast<int64_t>(total_size_bytes)) {
creation_info.error = File::FILE_ERROR_NO_SPACE;
return std::make_pair(std::move(creation_info), free_disk_space);
}
int64_t disk_availability =
free_disk_space == kUnknownDiskAvailability
? kUnknownDiskAvailability
: free_disk_space - static_cast<int64_t>(total_size_bytes);
// Create the page file.
uint32_t flags = File::FLAG_CREATE_ALWAYS | File::FLAG_WRITE;
// This File may be passed to an untrusted process.
flags = base::File::AddFlagsForPassingToUntrustedProcess(flags);
File file(file_path, flags);
creation_info.path = file_path;
creation_info.error = file.error_details();
if (creation_info.error != File::FILE_OK)
return std::make_pair(std::move(creation_info), free_disk_space);
// Write data.
file.SetLength(total_size_bytes);
int bytes_written = 0;
for (const auto& item : data) {
size_t length = item.size();
size_t bytes_left = length;
while (bytes_left > 0) {
bytes_written = file.WriteAtCurrentPos(
reinterpret_cast<const char*>(item.data() + (length - bytes_left)),
base::saturated_cast<int>(bytes_left));
if (bytes_written < 0)
break;
DCHECK_LE(static_cast<size_t>(bytes_written), bytes_left);
bytes_left -= bytes_written;
}
if (bytes_written < 0)
break;
}
if (!file.Flush()) {
file.Close();
base::DeleteFile(file_path);
creation_info.error = File::FILE_ERROR_FAILED;
return std::make_pair(std::move(creation_info), free_disk_space);
}
File::Info info;
bool success = file.GetInfo(&info);
creation_info.error =
bytes_written < 0 || !success ? File::FILE_ERROR_FAILED : File::FILE_OK;
creation_info.last_modified = info.last_modified;
return std::make_pair(std::move(creation_info), disk_availability);
}
uint64_t GetTotalSizeAndFileSizes(
const std::vector<scoped_refptr<ShareableBlobDataItem>>&
unreserved_file_items,
std::vector<uint64_t>* file_sizes_output) {
uint64_t total_size_output = 0;
base::small_map<std::map<uint64_t, uint64_t>> file_id_to_sizes;
for (const auto& item : unreserved_file_items) {
uint64_t file_id = item->item()->GetFutureFileID();
auto it = file_id_to_sizes.find(file_id);
if (it != file_id_to_sizes.end())
it->second =
std::max(it->second, item->item()->offset() + item->item()->length());
else
file_id_to_sizes[file_id] =
item->item()->offset() + item->item()->length();
total_size_output += item->item()->length();
}
for (const auto& size_pair : file_id_to_sizes) {
file_sizes_output->push_back(size_pair.second);
}
DCHECK_EQ(std::accumulate(file_sizes_output->begin(),
file_sizes_output->end(), 0ull),
total_size_output)
<< "Illegal builder configuration, temporary files must be totally used.";
return total_size_output;
}
} // namespace
FileCreationInfo::FileCreationInfo() = default;
FileCreationInfo::~FileCreationInfo() {
if (file.IsValid()) {
DCHECK(file_deletion_runner);
file_deletion_runner->PostTask(
FROM_HERE, base::BindOnce(&DestructFile, std::move(file)));
}
}
FileCreationInfo::FileCreationInfo(FileCreationInfo&&) = default;
FileCreationInfo& FileCreationInfo::operator=(FileCreationInfo&&) = default;
MemoryAllocation::MemoryAllocation(
base::WeakPtr<BlobMemoryController> controller,
uint64_t item_id,
size_t length)
: controller_(std::move(controller)), item_id_(item_id), length_(length) {}
MemoryAllocation::~MemoryAllocation() {
if (controller_)
controller_->RevokeMemoryAllocation(item_id_, length_);
}
BlobMemoryController::QuotaAllocationTask::~QuotaAllocationTask() = default;
class BlobMemoryController::MemoryQuotaAllocationTask
: public BlobMemoryController::QuotaAllocationTask {
public:
MemoryQuotaAllocationTask(
BlobMemoryController* controller,
size_t quota_request_size,
std::vector<scoped_refptr<ShareableBlobDataItem>> pending_items,
MemoryQuotaRequestCallback done_callback)
: controller_(controller),
pending_items_(std::move(pending_items)),
done_callback_(std::move(done_callback)),
allocation_size_(quota_request_size) {}
MemoryQuotaAllocationTask(const MemoryQuotaAllocationTask&) = delete;
MemoryQuotaAllocationTask& operator=(const MemoryQuotaAllocationTask&) =
delete;
~MemoryQuotaAllocationTask() override = default;
void RunDoneCallback(bool success) {
// Make sure we clear the weak pointers we gave to the caller beforehand.
weak_factory_.InvalidateWeakPtrs();
if (success)
controller_->GrantMemoryAllocations(&pending_items_, allocation_size_);
std::move(done_callback_).Run(success);
}
base::WeakPtr<QuotaAllocationTask> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
void Cancel() override {
DCHECK_GE(controller_->pending_memory_quota_total_size_, allocation_size_);
controller_->pending_memory_quota_total_size_ -= allocation_size_;
// This call destroys this object.
controller_->pending_memory_quota_tasks_.erase(my_list_position_);
}
// The my_list_position_ iterator is stored so that we can remove ourself
// from the task list when we are cancelled.
void set_my_list_position(
PendingMemoryQuotaTaskList::iterator my_list_position) {
my_list_position_ = my_list_position;
}
size_t allocation_size() const { return allocation_size_; }
private:
raw_ptr<BlobMemoryController> controller_;
std::vector<scoped_refptr<ShareableBlobDataItem>> pending_items_;
MemoryQuotaRequestCallback done_callback_;
size_t allocation_size_;
PendingMemoryQuotaTaskList::iterator my_list_position_;
base::WeakPtrFactory<MemoryQuotaAllocationTask> weak_factory_{this};
};
class BlobMemoryController::FileQuotaAllocationTask
: public BlobMemoryController::QuotaAllocationTask {
public:
// We post a task to create the file for the items right away.
FileQuotaAllocationTask(
BlobMemoryController* memory_controller,
DiskSpaceFuncPtr disk_space_function,
std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_file_items,
FileQuotaRequestCallback done_callback)
: controller_(memory_controller),
done_callback_(std::move(done_callback)) {
// Get the file sizes and total size.
uint64_t total_size =
GetTotalSizeAndFileSizes(unreserved_file_items, &file_sizes_);
// When we do perf tests that force the file strategy, these often run
// before |CalculateBlobStorageLimitsImpl| is complete. The disk isn't
// enabled until after this call returns (|file_paging_enabled_| is false)
// and |GetAvailableFileSpaceForBlobs()| will thus return 0. So skip this
// check when we have a custom file transportation trigger.
#if DCHECK_IS_ON()
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (LIKELY(
!command_line->HasSwitch(kBlobFileTransportByFileTriggerSwitch))) {
DCHECK_LE(total_size, controller_->GetAvailableFileSpaceForBlobs());
}
#endif
allocation_size_ = total_size;
// Check & set our item states.
for (auto& shareable_item : unreserved_file_items) {
DCHECK_EQ(ShareableBlobDataItem::QUOTA_NEEDED, shareable_item->state());
DCHECK_EQ(BlobDataItem::Type::kFile, shareable_item->item()->type());
shareable_item->set_state(ShareableBlobDataItem::QUOTA_REQUESTED);
}
pending_items_ = std::move(unreserved_file_items);
// Increment disk usage and create our file references.
controller_->disk_used_ += allocation_size_;
std::vector<base::FilePath> file_paths;
std::vector<scoped_refptr<ShareableFileReference>> references;
for (size_t i = 0; i < file_sizes_.size(); i++) {
file_paths.push_back(controller_->GenerateNextPageFileName());
references.push_back(ShareableFileReference::GetOrCreate(
file_paths.back(), ShareableFileReference::DELETE_ON_FINAL_RELEASE,
controller_->file_runner_.get()));
}
// Send file creation task to file thread.
controller_->file_runner_->PostTaskAndReplyWithResult(
FROM_HERE,
base::BindOnce(&CreateEmptyFiles, controller_->blob_storage_dir_,
disk_space_function, controller_->file_runner_,
std::move(file_paths)),
base::BindOnce(&FileQuotaAllocationTask::OnCreateEmptyFiles,
weak_factory_.GetWeakPtr(), std::move(references),
allocation_size_));
controller_->RecordTracingCounters();
}
FileQuotaAllocationTask(const FileQuotaAllocationTask&) = delete;
FileQuotaAllocationTask& operator=(const FileQuotaAllocationTask&) = delete;
~FileQuotaAllocationTask() override = default;
void RunDoneCallback(std::vector<FileCreationInfo> file_info, bool success) {
// Make sure we clear the weak pointers we gave to the caller beforehand.
weak_factory_.InvalidateWeakPtrs();
// We want to destroy this object on the exit of this method if we were
// successful.
std::unique_ptr<FileQuotaAllocationTask> this_object;
if (success) {
// Register the disk space accounting callback.
DCHECK_EQ(file_info.size(), file_sizes_.size());
for (size_t i = 0; i < file_sizes_.size(); i++) {
file_info[i].file_reference->AddFinalReleaseCallback(base::BindOnce(
&BlobMemoryController::OnBlobFileDelete,
controller_->weak_factory_.GetWeakPtr(), file_sizes_[i]));
}
for (auto& item : pending_items_) {
item->set_state(ShareableBlobDataItem::QUOTA_GRANTED);
}
this_object = std::move(*my_list_position_);
controller_->pending_file_quota_tasks_.erase(my_list_position_);
}
std::move(done_callback_).Run(std::move(file_info), success);
}
base::WeakPtr<QuotaAllocationTask> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
void Cancel() override {
DCHECK_GE(controller_->disk_used_, allocation_size_);
controller_->disk_used_ -= allocation_size_;
// This call destroys this object.
controller_->pending_file_quota_tasks_.erase(my_list_position_);
}
void OnCreateEmptyFiles(
std::vector<scoped_refptr<ShareableFileReference>> references,
uint64_t new_files_total_size,
EmptyFilesResult result) {
int64_t avail_disk_space = result.disk_availability;
if (result.files.empty()) {
DCHECK_NE(result.file_error, File::FILE_OK);
DCHECK_GE(controller_->disk_used_, allocation_size_);
controller_->disk_used_ -= allocation_size_;
// This will call our callback and delete the object correctly.
controller_->DisableFilePaging(result.file_error);
return;
}
// The allocation won't fit at all. Cancel this request. The disk will be
// decremented when the file is deleted through AddFinalReleaseCallback.
if (avail_disk_space != kUnknownDiskAvailability &&
base::checked_cast<uint64_t>(avail_disk_space) < new_files_total_size) {
DCHECK_GE(controller_->disk_used_, allocation_size_);
controller_->disk_used_ -= allocation_size_;
controller_->AdjustDiskUsage(static_cast<uint64_t>(avail_disk_space));
controller_->file_runner_->PostTask(
FROM_HERE, base::BindOnce(&DeleteFiles, std::move(result.files)));
std::unique_ptr<FileQuotaAllocationTask> this_object =
std::move(*my_list_position_);
controller_->pending_file_quota_tasks_.erase(my_list_position_);
RunDoneCallback(std::vector<FileCreationInfo>(), false);
return;
}
if (avail_disk_space != kUnknownDiskAvailability) {
controller_->AdjustDiskUsage(base::checked_cast<uint64_t>(
avail_disk_space - new_files_total_size));
}
DCHECK_EQ(result.files.size(), references.size());
for (size_t i = 0; i < result.files.size(); i++) {
result.files[i].file_reference = std::move(references[i]);
}
RunDoneCallback(std::move(result.files), true);
}
// The my_list_position_ iterator is stored so that we can remove ourself
// from the task list when we are cancelled.
void set_my_list_position(
PendingFileQuotaTaskList::iterator my_list_position) {
my_list_position_ = my_list_position;
}
size_t allocation_size() const { return allocation_size_; }
private:
raw_ptr<BlobMemoryController> controller_;
std::vector<uint64_t> file_sizes_;
std::vector<scoped_refptr<ShareableBlobDataItem>> pending_items_;
FileQuotaRequestCallback done_callback_;
uint64_t allocation_size_;
PendingFileQuotaTaskList::iterator my_list_position_;
base::WeakPtrFactory<FileQuotaAllocationTask> weak_factory_{this};
};
BlobMemoryController::BlobMemoryController(
const base::FilePath& storage_directory,
scoped_refptr<base::TaskRunner> file_runner)
: file_paging_enabled_(file_runner.get() != nullptr),
blob_storage_dir_(storage_directory),
file_runner_(std::move(file_runner)),
disk_space_function_(&base::SysInfo::AmountOfFreeDiskSpace),
populated_memory_items_(
base::LRUCache<uint64_t, ShareableBlobDataItem*>::NO_AUTO_EVICT),
memory_pressure_listener_(
FROM_HERE,
base::BindRepeating(&BlobMemoryController::OnMemoryPressure,
base::Unretained(this))) {}
BlobMemoryController::~BlobMemoryController() = default;
void BlobMemoryController::DisableFilePaging(base::File::Error reason) {
DLOG(ERROR) << "Blob storage paging disabled, reason: " << reason;
file_paging_enabled_ = false;
in_flight_memory_used_ = 0;
items_paging_to_file_.clear();
pending_evictions_ = 0;
pending_memory_quota_total_size_ = 0;
populated_memory_items_.Clear();
populated_memory_items_bytes_ = 0;
file_runner_ = nullptr;
PendingMemoryQuotaTaskList old_memory_tasks;
PendingFileQuotaTaskList old_file_tasks;
std::swap(old_memory_tasks, pending_memory_quota_tasks_);
std::swap(old_file_tasks, pending_file_quota_tasks_);
// Don't call the callbacks until we have a consistent state.
for (auto& memory_request : old_memory_tasks) {
memory_request->RunDoneCallback(false);
}
for (auto& file_request : old_file_tasks) {
// OnBlobFileDelete is registered when RunDoneCallback is called with
// |true|, so manually do disk accounting.
disk_used_ -= file_request->allocation_size();
file_request->RunDoneCallback(std::vector<FileCreationInfo>(), false);
}
}
BlobMemoryController::Strategy BlobMemoryController::DetermineStrategy(
size_t preemptive_transported_bytes,
uint64_t total_transportation_bytes) const {
if (total_transportation_bytes == 0)
return Strategy::NONE_NEEDED;
if (!CanReserveQuota(total_transportation_bytes))
return Strategy::TOO_LARGE;
// Handle the case where we have all the bytes preemptively transported, and
// we can also fit them.
if (preemptive_transported_bytes == total_transportation_bytes &&
pending_memory_quota_tasks_.empty() &&
preemptive_transported_bytes <= GetAvailableMemoryForBlobs()) {
return Strategy::NONE_NEEDED;
}
if (UNLIKELY(limits_.override_file_transport_min_size > 0) &&
file_paging_enabled_ &&
total_transportation_bytes >= limits_.override_file_transport_min_size) {
return Strategy::FILE;
}
if (total_transportation_bytes <= limits_.max_ipc_memory_size)
return Strategy::IPC;
if (file_paging_enabled_ &&
total_transportation_bytes <= GetAvailableFileSpaceForBlobs() &&
total_transportation_bytes > limits_.memory_limit_before_paging()) {
return Strategy::FILE;
}
return Strategy::SHARED_MEMORY;
}
bool BlobMemoryController::CanReserveQuota(uint64_t size) const {
// We check each size independently as a blob can't be constructed in both
// disk and memory.
return size <= GetAvailableMemoryForBlobs() ||
size <= GetAvailableFileSpaceForBlobs();
}
base::WeakPtr<QuotaAllocationTask> BlobMemoryController::ReserveMemoryQuota(
std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_memory_items,
MemoryQuotaRequestCallback done_callback) {
if (unreserved_memory_items.empty()) {
std::move(done_callback).Run(true);
return base::WeakPtr<QuotaAllocationTask>();
}
base::CheckedNumeric<uint64_t> unsafe_total_bytes_needed = 0;
for (auto& item : unreserved_memory_items) {
DCHECK_EQ(ShareableBlobDataItem::QUOTA_NEEDED, item->state());
DCHECK(item->item()->type() == BlobDataItem::Type::kBytesDescription ||
item->item()->type() == BlobDataItem::Type::kBytes);
DCHECK(item->item()->length() > 0);
unsafe_total_bytes_needed += item->item()->length();
item->set_state(ShareableBlobDataItem::QUOTA_REQUESTED);
}
uint64_t total_bytes_needed = unsafe_total_bytes_needed.ValueOrDie();
DCHECK_GT(total_bytes_needed, 0ull);
// If we're currently waiting for blobs to page already, then we add
// ourselves to the end of the queue. Once paging is complete, we'll schedule
// more paging for any more pending blobs.
if (!pending_memory_quota_tasks_.empty()) {
return AppendMemoryTask(total_bytes_needed,
std::move(unreserved_memory_items),
std::move(done_callback));
}
// Store right away if we can.
if (total_bytes_needed <= GetAvailableMemoryForBlobs()) {
GrantMemoryAllocations(&unreserved_memory_items,
static_cast<size_t>(total_bytes_needed));
MaybeScheduleEvictionUntilSystemHealthy(
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE);
std::move(done_callback).Run(true);
return base::WeakPtr<QuotaAllocationTask>();
}
// Size is larger than available memory.
DCHECK(pending_memory_quota_tasks_.empty());
DCHECK_EQ(0u, pending_memory_quota_total_size_);
auto weak_ptr =
AppendMemoryTask(total_bytes_needed, std::move(unreserved_memory_items),
std::move(done_callback));
MaybeScheduleEvictionUntilSystemHealthy(
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE);
return weak_ptr;
}
base::WeakPtr<QuotaAllocationTask> BlobMemoryController::ReserveFileQuota(
std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_file_items,
FileQuotaRequestCallback done_callback) {
pending_file_quota_tasks_.push_back(std::make_unique<FileQuotaAllocationTask>(
this, disk_space_function_, std::move(unreserved_file_items),
std::move(done_callback)));
pending_file_quota_tasks_.back()->set_my_list_position(
--pending_file_quota_tasks_.end());
return pending_file_quota_tasks_.back()->GetWeakPtr();
}
void BlobMemoryController::ShrinkMemoryAllocation(ShareableBlobDataItem* item) {
DCHECK(item->HasGrantedQuota());
DCHECK_EQ(item->item()->type(), BlobDataItem::Type::kBytes);
DCHECK_GE(item->memory_allocation_->length(), item->item()->length());
DCHECK_EQ(item->memory_allocation_->controller_.get(), this);
// Setting a new MemoryAllocation will delete and free the existing memory
// allocation, so here we only have to account for the new allocation.
blob_memory_used_ += item->item()->length();
item->set_memory_allocation(std::make_unique<MemoryAllocation>(
weak_factory_.GetWeakPtr(), item->item_id(),
base::checked_cast<size_t>(item->item()->length())));
MaybeGrantPendingMemoryRequests();
}
void BlobMemoryController::ShrinkFileAllocation(
ShareableFileReference* file_reference,
uint64_t old_length,
uint64_t new_length) {
DCHECK_GE(old_length, new_length);
DCHECK_GE(disk_used_, old_length - new_length);
disk_used_ -= old_length - new_length;
file_reference->AddFinalReleaseCallback(
base::BindOnce(&BlobMemoryController::OnShrunkenBlobFileDelete,
weak_factory_.GetWeakPtr(), old_length - new_length));
}
void BlobMemoryController::GrowFileAllocation(
ShareableFileReference* file_reference,
uint64_t delta) {
DCHECK_LE(delta, GetAvailableFileSpaceForBlobs());
disk_used_ += delta;
file_reference->AddFinalReleaseCallback(
base::BindOnce(&BlobMemoryController::OnBlobFileDelete,
weak_factory_.GetWeakPtr(), delta));
}
void BlobMemoryController::NotifyMemoryItemsUsed(
const std::vector<scoped_refptr<ShareableBlobDataItem>>& items) {
for (const auto& item : items) {
if (item->item()->type() != BlobDataItem::Type::kBytes ||
item->state() != ShareableBlobDataItem::POPULATED_WITH_QUOTA) {
continue;
}
// We don't want to re-add the item if we're currently paging it to disk.
if (base::Contains(items_paging_to_file_, item->item_id())) {
return;
}
auto iterator = populated_memory_items_.Get(item->item_id());
if (iterator == populated_memory_items_.end()) {
populated_memory_items_bytes_ +=
static_cast<size_t>(item->item()->length());
populated_memory_items_.Put(item->item_id(), item.get());
}
}
MaybeScheduleEvictionUntilSystemHealthy(
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE);
}
void BlobMemoryController::CallWhenStorageLimitsAreKnown(
base::OnceClosure callback) {
if (did_calculate_storage_limits_) {
std::move(callback).Run();
return;
}
on_calculate_limits_callbacks_.push_back(std::move(callback));
CalculateBlobStorageLimits();
}
void BlobMemoryController::CalculateBlobStorageLimits() {
if (did_schedule_limit_calculation_)
return;
did_schedule_limit_calculation_ = true;
if (file_runner_) {
file_runner_->PostTaskAndReplyWithResult(
FROM_HERE,
base::BindOnce(&CalculateBlobStorageLimitsImpl, blob_storage_dir_, true,
amount_of_memory_for_testing_),
base::BindOnce(&BlobMemoryController::OnStorageLimitsCalculated,
weak_factory_.GetWeakPtr()));
} else {
OnStorageLimitsCalculated(CalculateBlobStorageLimitsImpl(
blob_storage_dir_, false, amount_of_memory_for_testing_));
}
}
base::WeakPtr<BlobMemoryController> BlobMemoryController::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
void BlobMemoryController::OnStorageLimitsCalculated(BlobStorageLimits limits) {
DCHECK(limits.IsValid());
if (manual_limits_set_)
return;
limits_ = limits;
did_calculate_storage_limits_ = true;
for (auto& callback : on_calculate_limits_callbacks_)
std::move(callback).Run();
on_calculate_limits_callbacks_.clear();
}
void BlobMemoryController::AdjustDiskUsage(uint64_t avail_disk) {
DCHECK_LE(disk_used_, limits_.desired_max_disk_space +
limits_.min_available_external_disk_space());
uint64_t avail_disk_without_blobs = avail_disk + disk_used_;
// Note: The UMA metrics here intended to record state change between frozen,
// adjusted, and normal states.
if (avail_disk <= limits_.min_available_external_disk_space()) {
limits_.effective_max_disk_space = disk_used_;
} else if (avail_disk_without_blobs <
limits_.min_available_external_disk_space() +
limits_.desired_max_disk_space) {
// |effective_max_disk_space| is guaranteed to be less than
// |desired_max_disk_space| by the if statement.
limits_.effective_max_disk_space =
avail_disk_without_blobs - limits_.min_available_external_disk_space();
} else {
limits_.effective_max_disk_space = limits_.desired_max_disk_space;
}
}
base::WeakPtr<QuotaAllocationTask> BlobMemoryController::AppendMemoryTask(
uint64_t total_bytes_needed,
std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_memory_items,
MemoryQuotaRequestCallback done_callback) {
DCHECK(file_paging_enabled_)
<< "Caller tried to reserve memory when CanReserveQuota("
<< total_bytes_needed << ") would have returned false.";
pending_memory_quota_total_size_ += total_bytes_needed;
pending_memory_quota_tasks_.push_back(
std::make_unique<MemoryQuotaAllocationTask>(
this, total_bytes_needed, std::move(unreserved_memory_items),
std::move(done_callback)));
pending_memory_quota_tasks_.back()->set_my_list_position(
--pending_memory_quota_tasks_.end());
return pending_memory_quota_tasks_.back()->GetWeakPtr();
}
void BlobMemoryController::MaybeGrantPendingMemoryRequests() {
while (!pending_memory_quota_tasks_.empty() &&
limits_.max_blob_in_memory_space - blob_memory_used_ >=
pending_memory_quota_tasks_.front()->allocation_size()) {
std::unique_ptr<MemoryQuotaAllocationTask> memory_task =
std::move(pending_memory_quota_tasks_.front());
pending_memory_quota_tasks_.pop_front();
pending_memory_quota_total_size_ -= memory_task->allocation_size();
memory_task->RunDoneCallback(true);
}
RecordTracingCounters();
}
size_t BlobMemoryController::CollectItemsForEviction(
std::vector<scoped_refptr<ShareableBlobDataItem>>* output,
uint64_t min_page_file_size) {
base::CheckedNumeric<size_t> total_items_size = 0;
// Process the recent item list and remove items until we have at least a
// minimum file size or we're at the end of our items to page to disk.
while (total_items_size.ValueOrDie() < min_page_file_size &&
!populated_memory_items_.empty()) {
auto iterator = --populated_memory_items_.end();
ShareableBlobDataItem* item = iterator->second;
DCHECK_EQ(item->item()->type(), BlobDataItem::Type::kBytes);
populated_memory_items_.Erase(iterator);
size_t size = base::checked_cast<size_t>(item->item()->length());
populated_memory_items_bytes_ -= size;
total_items_size += size;
output->push_back(base::WrapRefCounted(item));
}
return total_items_size.ValueOrDie();
}
void BlobMemoryController::MaybeScheduleEvictionUntilSystemHealthy(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
// Don't do eviction when others are happening, as we don't change our
// pending_memory_quota_total_size_ value until after the paging files have
// been written.
if (pending_evictions_ != 0 || !file_paging_enabled_)
return;
uint64_t total_memory_usage =
static_cast<uint64_t>(pending_memory_quota_total_size_) +
blob_memory_used_;
size_t in_memory_limit = limits_.memory_limit_before_paging();
uint64_t min_page_file_size = limits_.min_page_file_size;
if (memory_pressure_level !=
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) {
in_memory_limit = 0;
// Use lower page file size to reduce using more memory for writing under
// pressure.
min_page_file_size = limits_.max_blob_in_memory_space *
limits_.max_blob_in_memory_space_under_pressure_ratio;
}
// We try to page items to disk until our current system size + requested
// memory is below our size limit.
// Size limit is a lower |memory_limit_before_paging()| if we have disk space.
while (disk_used_ < limits_.effective_max_disk_space &&
total_memory_usage > in_memory_limit) {
// We only page when we have enough items to fill a whole page file.
if (populated_memory_items_bytes_ < min_page_file_size)
break;
DCHECK_LE(min_page_file_size, static_cast<uint64_t>(blob_memory_used_));
std::vector<scoped_refptr<ShareableBlobDataItem>> items_to_swap;
size_t total_items_size =
CollectItemsForEviction(&items_to_swap, min_page_file_size);
if (total_items_size == 0)
break;
std::vector<base::span<const uint8_t>> data_for_paging;
for (auto& shared_blob_item : items_to_swap) {
items_paging_to_file_.insert(shared_blob_item->item_id());
data_for_paging.push_back(shared_blob_item->item()->bytes());
}
// Update our bookkeeping.
pending_evictions_++;
disk_used_ += total_items_size;
in_flight_memory_used_ += total_items_size;
// Create our file reference.
FilePath page_file_path = GenerateNextPageFileName();
scoped_refptr<ShareableFileReference> file_reference =
ShareableFileReference::GetOrCreate(
page_file_path,
ShareableFileReference::DELETE_ON_FINAL_RELEASE,
file_runner_.get());
// Add the release callback so we decrement our disk usage on file deletion.
file_reference->AddFinalReleaseCallback(
base::BindOnce(&BlobMemoryController::OnBlobFileDelete,
weak_factory_.GetWeakPtr(), total_items_size));
// Post the file writing task.
file_runner_->PostTaskAndReplyWithResult(
FROM_HERE,
base::BindOnce(&CreateFileAndWriteItems, blob_storage_dir_,
disk_space_function_, std::move(page_file_path),
file_runner_, std::move(data_for_paging),
total_items_size),
base::BindOnce(&BlobMemoryController::OnEvictionComplete,
weak_factory_.GetWeakPtr(), std::move(file_reference),
std::move(items_to_swap), total_items_size));
last_eviction_time_ = base::TimeTicks::Now();
}
RecordTracingCounters();
}
void BlobMemoryController::OnEvictionComplete(
scoped_refptr<ShareableFileReference> file_reference,
std::vector<scoped_refptr<ShareableBlobDataItem>> items,
size_t total_items_size,
std::pair<FileCreationInfo, int64_t /* avail_disk */> result) {
if (!file_paging_enabled_)
return;
FileCreationInfo& file_info = std::get<0>(result);
int64_t avail_disk_space = std::get<1>(result);
if (file_info.error != File::FILE_OK) {
DisableFilePaging(file_info.error);
return;
}
if (avail_disk_space != kUnknownDiskAvailability) {
AdjustDiskUsage(static_cast<uint64_t>(avail_disk_space));
}
DCHECK_LT(0, pending_evictions_);
pending_evictions_--;
// Switch item from memory to the new file.
uint64_t offset = 0;
for (const scoped_refptr<ShareableBlobDataItem>& shareable_item : items) {
scoped_refptr<BlobDataItem> new_item = BlobDataItem::CreateFile(
file_reference->path(), offset, shareable_item->item()->length(),
file_info.last_modified, file_reference);
DCHECK(shareable_item->memory_allocation_);
shareable_item->set_memory_allocation(nullptr);
shareable_item->set_item(new_item);
items_paging_to_file_.erase(shareable_item->item_id());
offset += shareable_item->item()->length();
}
in_flight_memory_used_ -= total_items_size;
// We want callback on blobs up to the amount we've freed.
MaybeGrantPendingMemoryRequests();
// If we still have more blobs waiting and we're not waiting on more paging
// operations, schedule more.
MaybeScheduleEvictionUntilSystemHealthy(
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE);
}
void BlobMemoryController::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
// Under critical memory pressure the system is probably already swapping out
// memory and making heavy use of IO. Adding to that is not desirable.
// Furthermore, scheduling a task to write files to disk risks paging-in
// memory that was already committed to disk which compounds the problem. Do
// not take any action on critical memory pressure.
if (memory_pressure_level ==
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
return;
}
auto time_from_last_evicion = base::TimeTicks::Now() - last_eviction_time_;
if (last_eviction_time_ != base::TimeTicks() &&
time_from_last_evicion.InSeconds() < kMinSecondsForPressureEvictions) {
return;
}
MaybeScheduleEvictionUntilSystemHealthy(memory_pressure_level);
}
FilePath BlobMemoryController::GenerateNextPageFileName() {
std::string file_name = base::NumberToString(current_file_num_++);
return blob_storage_dir_.Append(FilePath::FromUTF8Unsafe(file_name));
}
void BlobMemoryController::RecordTracingCounters() const {
TRACE_COUNTER2("Blob", "MemoryUsage", "TotalStorage", blob_memory_used_,
"InFlightToDisk", in_flight_memory_used_);
TRACE_COUNTER1("Blob", "DiskUsage", disk_used_);
TRACE_COUNTER1("Blob", "TransfersPendingOnDisk",
pending_memory_quota_tasks_.size());
TRACE_COUNTER1("Blob", "TransfersBytesPendingOnDisk",
pending_memory_quota_total_size_);
}
size_t BlobMemoryController::GetAvailableMemoryForBlobs() const {
if (limits_.max_blob_in_memory_space < memory_usage())
return 0;
return limits_.max_blob_in_memory_space - memory_usage();
}
uint64_t BlobMemoryController::GetAvailableFileSpaceForBlobs() const {
if (!file_paging_enabled_)
return 0;
// Sometimes we're only paging part of what we need for the new blob, so add
// the rest of the size we need into our disk usage if this is the case.
uint64_t total_disk_used = disk_used_;
if (in_flight_memory_used_ < pending_memory_quota_total_size_) {
total_disk_used +=
pending_memory_quota_total_size_ - in_flight_memory_used_;
}
if (limits_.effective_max_disk_space < total_disk_used)
return 0;
return limits_.effective_max_disk_space - total_disk_used;
}
void BlobMemoryController::GrantMemoryAllocations(
std::vector<scoped_refptr<ShareableBlobDataItem>>* items,
size_t total_bytes) {
blob_memory_used_ += total_bytes;
for (auto& item : *items) {
item->set_state(ShareableBlobDataItem::QUOTA_GRANTED);
item->set_memory_allocation(std::make_unique<MemoryAllocation>(
weak_factory_.GetWeakPtr(), item->item_id(),
base::checked_cast<size_t>(item->item()->length())));
}
}
void BlobMemoryController::RevokeMemoryAllocation(uint64_t item_id,
size_t length) {
DCHECK_LE(length, blob_memory_used_);
blob_memory_used_ -= length;
auto iterator = populated_memory_items_.Get(item_id);
if (iterator != populated_memory_items_.end()) {
DCHECK_GE(populated_memory_items_bytes_, length);
populated_memory_items_bytes_ -= length;
populated_memory_items_.Erase(iterator);
}
MaybeGrantPendingMemoryRequests();
}
void BlobMemoryController::OnBlobFileDelete(uint64_t size,
const FilePath& path) {
DCHECK_LE(size, disk_used_);
disk_used_ -= size;
}
void BlobMemoryController::OnShrunkenBlobFileDelete(uint64_t shrink_delta,
const FilePath& path) {
disk_used_ += shrink_delta;
}
} // namespace storage
|
67e2e0c9f9c14a404edb0664b26add26bacd2601
|
886f10ff80a5826f0578cce15a4d8a264d22ea16
|
/TankWar/Timer.h
|
fd3026813bba42048d0400c9e85a8a01d9a3bfd4
|
[] |
no_license
|
StarTrekCenter/Hello-Tank
|
ec0c46c4dacc2a83c7ea1602487b0b544c2e4bf4
|
e2235e711cc70621142e88efcf056d9a98c3cc7f
|
refs/heads/master
| 2016-08-07T22:24:47.640818
| 2015-01-08T09:42:17
| 2015-01-08T09:42:17
| 12,504,574
| 0
| 1
| null | 2015-01-08T09:42:17
| 2013-08-31T11:26:16
|
C++
|
UTF-8
|
C++
| false
| false
| 507
|
h
|
Timer.h
|
#pragma once
#include "SDL.h"
#include "SDL_thread.h"
#define TIME_CODE 0x0001
class Timer
{
public:
Timer(void);
~Timer(void);
void StartTimer(Uint32 ms,SDL_EventType(*onTimer)(SDL_Event),void* userData = nullptr);
void StopTimer();
void FlushTimeEvent();
private:
//SDL_ThreadFunction TimerThread;
static int TimerThread(void *data);
private:
int mTimeDelay;
bool mTimeStarted;
SDL_EventType mTimeEventType;
SDL_Thread *mThreadTimer;
void* mUserDate;
};
|
eb1ba97e335ee767408ed581fa6c3aaec062a0a0
|
925f50bef2089477801fe170b1811bbbd2e5493c
|
/Ch12/Ex12.23.cpp
|
63bf11f8fd62a20ea9bec9e0ed48e81194948042
|
[] |
no_license
|
DxnteSC/CppPrimer
|
e22b39b5df105c7e410038080cb1cae87e32801f
|
d1026974459bed7e622ffc6602f562070ed97fff
|
refs/heads/master
| 2021-07-10T07:06:22.326501
| 2020-07-10T07:33:46
| 2020-07-10T07:33:46
| 163,541,475
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 412
|
cpp
|
Ex12.23.cpp
|
#include <iostream>
#include <string>
int main()
{
const char* c1 = "Hello, ";
const char* c2 = "World!";
char* cA = new char[std::strlen(c1) + std::strlen(c2) + 1];
std::strcpy(cA,c1);
std::strcat(cA,c2);
std::cout << cA << std::endl;
delete[] cA;
std::string s1 = "Hello, ";
std::string s2 = "World!";
std::string s3 = s1 + s2;
std::cout << s3 << std::endl;
}
|
e57b674c95b942309f0e13141c939668a0e29e2d
|
e9a835541c88e68f24af6c079e0e5743e56571c9
|
/src/pc_emulator/core/kronos_api.cc
|
38eb03437340915faaa5cca89d6e41b858e9f3b4
|
[] |
no_license
|
ITI/OpenSCADA
|
60b25f3fda6f2475f2daa0029b1fcc629c2aa2d8
|
6396b80a3c6b3769b34f74c0f79129ac1f77b435
|
refs/heads/master
| 2021-06-25T07:06:45.979335
| 2021-01-07T21:53:58
| 2021-01-07T21:53:58
| 193,534,183
| 6
| 2
| null | 2021-01-07T21:53:59
| 2019-06-24T15:44:22
|
C++
|
UTF-8
|
C++
| false
| false
| 232
|
cc
|
kronos_api.cc
|
#include <sys/types.h>
#include "src/pc_emulator/include/kronos_api.h"
string GetNxtCommand(int assignedTracerID) {
int ret = writeTracerResults(assignedTracerID, NULL, 0);
if (ret < 0) return "STOP";
return "CONT";
}
|
c92996001ae1a997b7137014dff2637bf4778753
|
0d3a90b771a2a825526219c9d56746b24a426be3
|
/include/node.h
|
a75e48d84b111fa16bc15c5a12ca8c32c00ce4b4
|
[
"MIT"
] |
permissive
|
ynamiki/btree
|
7362a50d9fd5c0347929f41caa7015b894ca1a3d
|
aa74a6cdf8ebd21e230767fa9106dc567aafc525
|
refs/heads/master
| 2022-12-20T00:14:22.299058
| 2020-09-22T02:49:45
| 2020-09-22T02:49:45
| 251,499,584
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,718
|
h
|
node.h
|
#ifndef BTREE_NODE_H_
#define BTREE_NODE_H_
#include <cstddef>
#include <vector>
#include "btree.h"
namespace btree {
class Node {
public:
explicit Node(const std::vector<key_t> keys, const std::vector<Node*> sons);
~Node();
/**
* Get the i-th key.
*
* @return The i-th key.
*/
key_t key_at(std::size_t i) const;
/**
* Get the i-th son.
*
* @return The i-th son.
*/
Node* son_at(std::size_t i) const;
/**
* Get the number of the keys in this node.
*
* @return The number of the keys.
*/
std::size_t size() const noexcept;
/**
* Return whether this node is a leaf.
*
* @return Whether this node is a leaf.
*/
bool leaf() const;
/**
* Find the key.
*
* @param[in] key A key to find.
* @param[out] i An index of the key if the key exists. Otherwise, An index of
* the key should be inserted.
* @param[out] node A son node to go next if the key does not exist.
* @return Whether the key exists.
*/
bool find(key_t key, std::size_t* i = nullptr, Node** son = nullptr) const;
/**
* Return an index of the given son. The son must be in this node.
*
* @param[in] son A son to find.
*/
std::size_t find(const Node* son) const;
/**
* Insert the entry into this node. The key must not be in this node.
*
* @param[in] key The key to be inserted.
* @param[in] son The son to be inserted with the key.
*/
void insert(key_t key, Node* son);
/**
* Split the i-th son. The i-th key will be newly inserted to this node.
*
* @param[in] i An index of a node in the son to be moved to this node.
* @param[out] key A key to be inserted to the father node.
* @return A new brother node to be inserted to the father node.
*/
Node* split(std::size_t i, key_t* key);
/**
* Delete the key from this node. The key must be in this node.
*
* @param[in] key The key to be deleted.
* @param[in] leaf A leaf node which is next to this key, if this node is not
* a leaf. nullptr if this node is a leaf.
*/
void delete_(key_t key, Node* leaf = nullptr);
/**
* Catenate i-th and (i+1)-th sons.
*
* @param[in] i An index of a son.
*/
void catenate(std::size_t i);
/**
* Underflow i-th and (i+1)-th sons.
*
* @param[in] i An index of a son.
*/
void underflow(std::size_t i);
/**
* Add keys in the sub-tree to the given vector.
*
* @param[out] v The vector to insert keys.
*/
void get_all_keys(std::vector<key_t>& v) const;
/**
* Clear contents.
*/
void clear();
private:
void catenate(key_t key, Node* brother);
std::vector<key_t> keys;
std::vector<Node*> sons;
};
} // namespace btree
#endif
|
e4fb23e6c1b8af99c5e7bebfdf83b825cfdcf201
|
d8d5b8c8bf1f5b15d6701367d09fa093ec60d0f2
|
/src/Kernels.hpp
|
71e788d5a21a70483531422f9234138700965315
|
[
"MIT"
] |
permissive
|
asterycs/cuWave
|
5afc6c7e754d615a392972ff9f3e8eecdfdf6f29
|
e1630950aaac50e789745ad0f1af19e67168ad22
|
refs/heads/master
| 2021-03-27T16:04:58.164291
| 2018-11-16T09:34:13
| 2018-11-16T09:34:13
| 122,977,371
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 24,449
|
hpp
|
Kernels.hpp
|
#ifndef KERNELS_HPP
#define KERNELS_HPP
#define BLOCKWIDTH 8
#define INTERSECT_EPSILON 0.0000001f
#define OFFSET_EPSILON 0.00001f
#define BIGT 99999.f
#define AIR_INDEX 1.f
#define MIN_PATHS 3
#define RUSSIAN_PROB 0.8f
#define PREGEN_RANDOM_DIMENSIONS 32
// Helper enum for random dimension. Dimensions for extension rays are computed using ray index and EXT
enum RandDim
{
SHADING = 0,
AAX,
AAY,
RUSSIAN,
LIGHT,
DIFF0,
DIFF1,
DIFF2,
DIFF3,
EXT
};
#define LEFT_HIT_BIT 0x80000000
#define RIGHT_HIT_BIT 0x40000000
__device__ inline float fresnelReflectioncoefficient(const float sin2t, const float cosi, const float idx1, const float idx2)
{
const float cost = sqrt(1 - sin2t);
const float Rs = (idx1 * cosi - idx2 * cost) / (idx1 * cosi + idx2 * cost);
const float Rp = (idx1 * cost - idx2 * cosi) / (idx1 * cost + idx2 * cosi);
return (Rs * Rs + Rp * Rp) * 0.5f;
}
__device__ float3 createDirection(const float r0, const float r1)
{
const float sinTheta = sqrtf(r0);
const float cosTheta = sqrtf(1-sinTheta*sinTheta);
const float psi = r1*2*CUDART_PI_F;
return make_float3(sinTheta*cosf(psi), sinTheta*sinf(psi), cosTheta);
}
// Veach
__device__ inline float powerHeuristic(const float f, const float g)
{
return (f*f)/(f*f + g*g);
}
// https://devblogs.nvidia.com/cuda-pro-tip-optimized-filtering-warp-aggregated-atomics/
__device__ int atomicAggInc(uint32_t *ctr) {
auto g = cooperative_groups::coalesced_threads();
uint32_t warp_res;
if(g.thread_rank() == 0)
warp_res = atomicAdd(ctr, g.size());
return g.shfl(warp_res, 0) + g.thread_rank();
}
__device__ inline float scramble(const uint32_t scrambleConstant, const float f)
{
const uint32_t i = static_cast<uint32_t>(f * 0xFFFFFFFF) ^ scrambleConstant;
const float r = i * 2.3283064365386963e-10f;
return r;
}
__device__ float bboxIntersect(const AABB box, const float3 origin, const float3 inverseDirection)
{
float3 tmin = make_float3(-BIGT, -BIGT, -BIGT), tmax = make_float3(BIGT, BIGT, BIGT);
const float3 tdmin = (box.min - origin) * inverseDirection;
const float3 tdmax = (box.max - origin) * inverseDirection;
tmin = fminf(tdmin, tdmax);
tmax = fmaxf(tdmin, tdmax);
const float tmind = fmin_compf(tmin);
const float tmaxd = fmin_compf(tmax);
return (tmaxd >= tmind && !(tmaxd < 0.f && tmind < 0.f)) ? fminf(tmind, tmaxd) : -1.f;
}
__device__ bool rayTriangleIntersection(const Ray ray, const Triangle& triangle,
float& t, float2& uv)
{
/* Möller-Trumbore algorithm
* https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
*/
// TODO: Experiment with __ldg
const float3 vertex0 = triangle.vertices[0].p;
const float3 edge1 = triangle.vertices[1].p - vertex0;
const float3 edge2 = triangle.vertices[2].p - vertex0;
const float3 h = cross(ray.direction, edge2);
const float a = dot(edge1, h);
if (a > -INTERSECT_EPSILON && a < INTERSECT_EPSILON)
return false;
const float f = __fdividef(1.f, a);
const float3 s = ray.origin - vertex0;
const float u = f * dot(s, h);
if (u < 0.f || u > 1.0f)
return false;
const float3 q = cross(s, edge1);
const float v = f * dot(ray.direction, q);
if (v < 0.0 || u + v > 1.0)
return false;
t = f * dot(edge2, q);
if (t > INTERSECT_EPSILON)
{
uv = make_float2(u, v);
return true;
}
else
return false;
}
enum HitType
{
ANY, CLOSEST
};
template<const HitType hitType>
__device__ RaycastResult rayCast(const Ray ray, const Node* bvh,
const Triangle* triangles, const float maxT)
{
float tMin = maxT;
int32_t minTriIdx = -1;
float2 minUV;
RaycastResult result;
const float3 inverseDirection = make_float3(1.f, 1.f, 1.f) / ray.direction;
int32_t ptr = 0;
uint32_t stack[16] { 0 };
int32_t i = -1;
float t = 0;
float2 uv;
bool getNextNode = true;
while (ptr >= 0)
{
uint32_t currentNodeIdx = stack[ptr];
Node currentNode = bvh[currentNodeIdx];
if (currentNode.rightIndex == -1)
{
getNextNode = false;
if (i >= currentNode.startTri && i < currentNode.startTri + currentNode.nTri)
{
if (rayTriangleIntersection(ray, triangles[i], t, uv))
{
if (t < tMin)
{
tMin = t;
minTriIdx = i;
minUV = uv;
if (hitType == HitType::ANY)
break;
}
}
++i;
if (i >= currentNode.startTri + currentNode.nTri)
getNextNode = true;
}
else
{
i = currentNode.startTri;
}
}
else
{
const AABB leftBox = bvh[stack[ptr] + 1].bbox;
const AABB rightBox = bvh[currentNode.rightIndex].bbox;
float leftt = bboxIntersect(leftBox, ray.origin, inverseDirection);
float rightt = bboxIntersect(rightBox, ray.origin, inverseDirection);
uint32_t hitMask = leftt != -1.f ? LEFT_HIT_BIT : 0x00;
hitMask = rightt != -1.f ? hitMask | RIGHT_HIT_BIT : hitMask;
// TODO: Push closer one last, don't intersect if closest hit is closer than box
if ((hitMask & LEFT_HIT_BIT) != 0x00 && leftt < tMin)
{
stack[ptr] = currentNodeIdx + 1;
++ptr;
}
if ((hitMask & RIGHT_HIT_BIT) != 0x00 && rightt < tMin)
{
stack[ptr] = currentNode.rightIndex;
++ptr;
}
}
if (getNextNode)
{
--ptr;
i = -1;
}
}
if (minTriIdx == -1)
return result;
result.t = tMin;
result.triangleIdx = minTriIdx;
result.uv = minUV;
return result;
}
__device__ void writeToCanvas(const uint32_t x, const uint32_t y,
const cudaSurfaceObject_t& surfaceObj, const glm::ivec2 canvasSize,
const float3 data)
{
const float4 out = make_float4(__saturatef(data.x), __saturatef(data.y), __saturatef(data.z), 1.f);
surf2Dwrite(out, surfaceObj, (canvasSize.x - 1 - x) * sizeof(out), y);
return;
}
__device__ float3 readFromCanvas(const uint32_t x, const uint32_t y,
const cudaSurfaceObject_t& surfaceObj, const glm::ivec2 canvasSize)
{
float4 in;
surf2Dread(&in, surfaceObj, (canvasSize.x - 1 - x) * sizeof(in), y);
const float3 ret = make_float3(in.x, in.y, in.z);
return ret;
}
__global__ void logicKernel(const glm::ivec2 canvasSize, Queues queues,
Paths paths, const Material* materials,
const uint32_t* triangleMaterialIds,
const Triangle* triangles
)
{
const uint32_t x = threadIdx.x + blockIdx.x * blockDim.x;
const uint32_t y = threadIdx.y + blockIdx.y * blockDim.y;
const uint32_t pathIdx = x + y * canvasSize.x;
const float3 float3_zero = make_float3(0.f, 0.f, 0.f);
if (x >= canvasSize.x || y >= canvasSize.y)
return;
const uint32_t scrambleConstant = paths.scrambleConstants[pathIdx];
const float rf = scramble(scrambleConstant, paths.floats[RandDim::SHADING]);
const RaycastResult result = paths.result[pathIdx];
const uint32_t rayNr = paths.rayNr[pathIdx];
if (!result)
{
const uint32_t new_idx = atomicAggInc(queues.newPathQueueSize);
queues.newPathQueue[new_idx] = pathIdx;
if (rayNr == 1)
paths.color[pathIdx] = make_float3(0.3f, 0.3f, 0.3f);
return;
}else if (rayNr >= MIN_PATHS)
{
const float rr = scramble(scrambleConstant, paths.floats[RandDim::RUSSIAN]);
if (rr > RUSSIAN_PROB) // terminated by Russian roulette
{
const uint32_t new_idx = atomicAggInc(queues.newPathQueueSize);
queues.newPathQueue[new_idx] = pathIdx;
return;
}
paths.p[pathIdx] *= RUSSIAN_PROB;
}
const Ray ray = paths.ray[pathIdx];
const float3 normal = triangles[result.triangleIdx].normal(result.uv);
const Material material = materials[triangleMaterialIds[result.triangleIdx]];
uint32_t new_idx;
switch (material.mode)
{
case (Material::TRANSPARENCY_REFLECTION_FRESNEL):
{
const float idx1 = AIR_INDEX;
const float idx2 = material.refractionIndex;
float refractionRatio;
const bool outside = dot(ray.direction, normal) < 0.f;
float3 flippedNormal = normal;
if (outside)
refractionRatio = idx2 / idx1;
else
{
refractionRatio = idx1 / idx2;
flippedNormal = -normal;
}
const float cosi = dot(ray.direction, -flippedNormal);
if (sinf(acosf(cosi)) <= refractionRatio) // Refraction allowed
{
const float sin2t = abs((idx1 / idx2) * (idx1 / idx2) * (1 - cosi * cosi));
const float twoR = outside ? 2.f*fresnelReflectioncoefficient(sin2t, cosi, idx1, idx2): 1.f;
const float total = length(material.colorDiffuse) + twoR * length(material.colorSpecular) + (2.f-twoR) * length(material.colorTransparent);
const float diffuseTreshold = length(material.colorDiffuse) / total;
const float specularTreshold = diffuseTreshold + twoR * length(material.colorSpecular) / total;
//const float transparentTreshold = diffuseTreshold + specularTreshold + ((1-R) / 0.5f) * length(material.colorTransparent) / total;
if (rf < diffuseTreshold)
{
new_idx = atomicAggInc(queues.diffuseQueueSize);
queues.diffuseQueue[new_idx] = pathIdx;
}else if (rf > diffuseTreshold && rf < specularTreshold)
{
new_idx = atomicAggInc(queues.specularQueueSize);
queues.specularQueue[new_idx] = pathIdx;
paths.throughput[pathIdx] *= material.colorSpecular / fmax_compf(material.colorSpecular); // Rather this that precompute and increase memory pressure by storing a ratio between specular and transparent
}else
{
new_idx = atomicAggInc(queues.transparentQueueSize);
queues.transparentQueue[new_idx] = pathIdx;
paths.throughput[pathIdx] *= material.colorTransparent / fmax_compf(material.colorTransparent);
}
break;
}
}
case (Material::REFLECTION_FRESNEL):
{
const float idx1 = AIR_INDEX;
const float idx2 = material.refractionIndex;
const bool outside = dot(ray.direction, normal) < 0.f;
float3 flippedNormal = normal;
if (!outside)
flippedNormal = -normal;
const float cosi = dot(ray.direction, -flippedNormal);
const float sin2t = abs((idx1 / idx2) * (idx1 / idx2) * (1 - cosi * cosi));
const float twoR = outside ? 2.f*fresnelReflectioncoefficient(sin2t, cosi, idx1, idx2): 1.f;
const float total = length(material.colorDiffuse) + twoR * length(material.colorSpecular) + (2.f-twoR) * length(material.colorTransparent);
const float diffuseTreshold = length(material.colorDiffuse) / total;
if (rf < diffuseTreshold)
{
new_idx = atomicAggInc(queues.diffuseQueueSize);
queues.diffuseQueue[new_idx] = pathIdx;
}else
{
new_idx = atomicAggInc(queues.specularQueueSize);
queues.specularQueue[new_idx] = pathIdx;
paths.throughput[pathIdx] *= material.colorSpecular / fmax_compf(material.colorSpecular);
}
}
break;
default:
new_idx = atomicAggInc(queues.diffuseQueueSize);
queues.diffuseQueue[new_idx] = pathIdx;
break;
}
return;
}
__global__ void writeToCanvas(const glm::ivec2 canvasSize,
cudaSurfaceObject_t canvas, Paths paths)
{
const uint32_t x = threadIdx.x + blockIdx.x * blockDim.x;
const uint32_t y = threadIdx.y + blockIdx.y * blockDim.y;
const int idx = x + y * canvasSize.x;
if (x >= canvasSize.x || y >= canvasSize.y)
return;
const uint32_t currentPath = paths.pathNr[idx];
const float3 newColor = paths.color[idx];
float3 oldColor = readFromCanvas(x, y, canvas, canvasSize);
float3 blend = static_cast<float>(currentPath - 1) / currentPath * oldColor
+ 1.f / currentPath * newColor;
writeToCanvas(x, y, canvas, canvasSize, blend);
}
typedef struct
{
float3 col[3];
} float33;
__device__
inline void setZero(float33& m)
{
m.col[0] = make_float3(0.0f, 0.0f, 0.0f);
m.col[1] = make_float3(0.0f, 0.0f, 0.0f);
m.col[2] = make_float3(0.0f, 0.0f, 0.0f);
}
__device__
inline float3 operator*(const float33 m, const float3 v)
{
float3 res;
res.x = m.col[0].x * v.x + m.col[1].x * v.y + m.col[2].x * v.z;
res.y = m.col[0].y * v.x + m.col[1].y * v.y + m.col[2].y * v.z;
res.z = m.col[0].z * v.x + m.col[1].z * v.y + m.col[2].z * v.z;
return res;
}
__device__ float33 getBasis(const float3 n)
{
float33 R;
float3 Q = n;
const float3 absq = abs(Q);
float absqmin = fmin(absq);
if (absq.x == absqmin)
Q.x = 1;
else if (absq.y == absqmin)
Q.y = 1;
else
Q.z = 1;
float3 T = normalize(cross(Q, n));
float3 B = normalize(cross(n, T));
R.col[0] = T;
R.col[1] = B;
R.col[2] = n;
return R;
}
__global__ void diffuseKernel(const glm::ivec2 canvasSize, const Queues queues,
Paths paths, const Triangle* triangles,
const uint32_t* lightTriangleIds, const uint32_t lightTriangles,
const uint32_t* triangleMaterialIds, const Material* materials,
const Node* bvh)
{
const uint32_t x = threadIdx.x + blockIdx.x * blockDim.x;
const uint32_t y = threadIdx.y + blockIdx.y * blockDim.y;
const uint32_t idx = x + y * canvasSize.x;
if (idx >= *queues.diffuseQueueSize)
return;
const uint32_t pathIdx = queues.diffuseQueue[idx];
const uint32_t scrambleConstant = paths.scrambleConstants[pathIdx];
const RaycastResult result = paths.result[pathIdx];
const Material material = materials[triangleMaterialIds[result.triangleIdx]];
const Ray ray = paths.ray[pathIdx];
const float3 hitNormal = triangles[result.triangleIdx].normal();
const bool outside = dot(ray.direction, hitNormal) < 0.f;
float3 flippedNormal = hitNormal;
if (!outside)
flippedNormal = -hitNormal;
const float3 shadowRayOrigin = ray.origin + ray.direction*result.t + flippedNormal * OFFSET_EPSILON;
float3 directLightning = make_float3(0.f, 0.f, 0.f);
if (lightTriangles > 0) // TODO: Make check reduntant
{
// Choose light by uniform sampling
const float p = paths.p[pathIdx];
const float lightProb = 1.f / lightTriangles;
const float lightRF = paths.floats[RandDim::LIGHT];
const uint32_t lightIdx = lightRF / lightProb;
float r0 = paths.floats[RandDim::DIFF0];
float r1 = paths.floats[RandDim::DIFF1];
r0 = scramble(scrambleConstant, r0);
r1 = scramble(scrambleConstant, r1);
const float4 pointPdf = triangles[lightTriangleIds[lightIdx]].sample(r0, r1);
const float3 shadowPoint = make_float3(pointPdf.x, pointPdf.y, pointPdf.z);
const float3 shadowRayDirection = shadowPoint - shadowRayOrigin;
const Ray shadowRay(shadowRayOrigin, normalize(shadowRayDirection));
const float shadowRayLength = length(shadowRayDirection);
const Triangle lightTriangle = triangles[lightTriangleIds[lightIdx]];
const Material lightTriangleMaterial = materials[triangleMaterialIds[lightTriangleIds[lightIdx]]];
const float3 lightEmission = lightTriangleMaterial.colorEmission;
const RaycastResult shadowResult = rayCast<HitType::ANY>(shadowRay, bvh, triangles, shadowRayLength);
if ((shadowResult && shadowResult.t >= shadowRayLength + OFFSET_EPSILON) || !shadowResult)
{
const float misWeight = powerHeuristic(lightProb*pointPdf.w, 2*CUDART_PI_F);
const float cosOmega = __saturatef(dot(normalize(shadowRayDirection), hitNormal));
const float cosL = __saturatef(dot(-normalize(shadowRayDirection), lightTriangle.normal()));
directLightning += misWeight * 1.f / (shadowRayLength * shadowRayLength * lightProb*pointPdf.w * p) * lightEmission * cosL * cosOmega;
}
const float33 B = getBasis(hitNormal);
float r2 = scramble(scrambleConstant, paths.floats[RandDim::DIFF2]);
float r3 = scramble(scrambleConstant, paths.floats[RandDim::DIFF3]);
float3 brdfDir = createDirection(r2, r3);
brdfDir = B * brdfDir;
const Ray brdfRay(shadowRayOrigin, brdfDir);
const RaycastResult brdfResult = rayCast<HitType::CLOSEST>(brdfRay, bvh, triangles, BIGT);
bool hitEmitter = false;
for (int i = 0; i < lightTriangles; ++i) // TODO: ...
{
if (lightTriangleIds[i] == brdfResult.triangleIdx)
hitEmitter = true;
}
if (hitEmitter)
{
const float3 brdfHitEmission = materials[triangleMaterialIds[brdfResult.triangleIdx]].colorEmission;
const float misWeight = powerHeuristic(2*CUDART_PI_F, lightProb*pointPdf.w);
const float cosOmega = __saturatef(dot(normalize(brdfDir), hitNormal));
const float cosL = __saturatef(dot(-normalize(brdfDir), lightTriangle.normal()));
const float toLightLength = length(brdfDir*brdfResult.t);
directLightning += misWeight * 1.f / (toLightLength * toLightLength * 2 * CUDART_PI_F * p) * brdfHitEmission * cosL * cosOmega;
}
}
const float3 currentTroughput = paths.throughput[pathIdx];
//const float3 filteredAmbient = currentTroughput * material.colorAmbient * 0.25f;
const float3 filteredDiffuse = currentTroughput * material.colorDiffuse;
const float3 fiteredEmission = paths.rayNr[pathIdx] == 1 ? currentTroughput * material.colorEmission : make_float3(0.f, 0.f, 0.f);
paths.color[pathIdx] += fiteredEmission /*+ filteredAmbient*/ + directLightning * filteredDiffuse / CUDART_PI_F;
}
__global__ void newPathsKernel(const glm::ivec2 canvasSize, const Queues queues,
const Paths paths, const Camera camera)
{
const uint32_t x = threadIdx.x + blockIdx.x * blockDim.x;
const uint32_t y = threadIdx.y + blockIdx.y * blockDim.y;
const int idx = x + y * canvasSize.x;
if (idx >= *queues.newPathQueueSize)
return;
const uint32_t pathIdx = queues.newPathQueue[idx];
const uint32_t xCoordinate = pathIdx % canvasSize.x;
const uint32_t yCoordinate = pathIdx / canvasSize.x;
const uint32_t scrambleConstant = paths.scrambleConstants[idx];
const float rfx = scramble(scrambleConstant, paths.floats[RandDim::AAX]);
const float rfy = scramble(scrambleConstant, paths.floats[RandDim::AAY]);
const glm::fvec2 nic = camera.normalizedImageCoordinateFromPixelCoordinate(xCoordinate, yCoordinate, canvasSize);
const float xOffset = 0.5f / static_cast<float>(canvasSize.x) * (rfx * 2.0f - 1.f);
const float yOffset = 0.5f / static_cast<float>(canvasSize.y) * (rfy * 2.0f - 1.f);
const Ray ray = camera.generateRay(nic + glm::fvec2(xOffset, yOffset), static_cast<float>(canvasSize.x) / canvasSize.y);
paths.ray[pathIdx] = ray;
paths.color[pathIdx] = make_float3(0.f, 0.f, 0.f);
paths.throughput[pathIdx] = make_float3(1.f, 1.f, 1.f);
paths.p[pathIdx] = 1.f;
paths.rayNr[pathIdx] = 1;
paths.pathNr[pathIdx] += 1;
}
inline __device__ float3 reflectionDirection(const float3 normal,
const float3 incomingDirection)
{
const float cosT = dot(incomingDirection, normal);
return incomingDirection - 2 * cosT * normal;
}
inline __device__ float3 refractionDirection(const float cosInAng, const float sin2t, const float3 normal, const float3 incoming, const float index1, const float index2)
{
return index1 / index2 * incoming + (index1 / index2 * cosInAng - sqrt(1 - sin2t)) * normal;
}
__global__ void diffuseExtensionKernel(const glm::ivec2 canvasSize,
const Queues queues, const Paths paths, const Triangle* triangles,
const uint32_t* triangleMaterialIds, const Material* materials, const uint32_t lightTriangles)
{
const uint32_t x = threadIdx.x + blockIdx.x * blockDim.x;
const uint32_t y = threadIdx.y + blockIdx.y * blockDim.y;
const uint32_t idx = x + y * canvasSize.x;
if (idx >= *queues.diffuseQueueSize)
return;
const uint32_t pathIdx = queues.diffuseQueue[idx];
const uint32_t scrambleConstant = paths.scrambleConstants[idx];
const uint32_t rayNumber = paths.rayNr[pathIdx];
const Ray ray = paths.ray[pathIdx];
const RaycastResult result = paths.result[pathIdx];
const Triangle triangle = triangles[result.triangleIdx];
const Material& material = materials[triangleMaterialIds[result.triangleIdx]];
float3 hitNormal = triangle.normal();
float33 B = getBasis(hitNormal);
// Every bounce should have their unique random dimension. This one goes around after enough bounces. Not correct, to be fixed.
const uint32_t randomDimensionIndex0 = RandDim::EXT + (2*(rayNumber-1) % (PREGEN_RANDOM_DIMENSIONS - RandDim::EXT));
const uint32_t randomDimensionIndex1 = RandDim::EXT + (2*(rayNumber-1) % (PREGEN_RANDOM_DIMENSIONS - RandDim::EXT)) + 1;
float r0 = scramble(scrambleConstant, paths.floats[randomDimensionIndex0]);
float r1 = scramble(scrambleConstant, paths.floats[randomDimensionIndex1]);
float3 extensionDir = createDirection(r0, r1);
extensionDir = B * extensionDir;
extensionDir = normalize(extensionDir); // Unnecessary
const float3 extensionOrig = ray.origin + ray.direction*result.t + OFFSET_EPSILON * hitNormal;
const Ray extensionRay(extensionOrig, extensionDir);
const float cosO = dot(extensionDir, hitNormal);
const float p = cosO * dot(extensionDir, hitNormal) * (1.f / CUDART_PI_F);
float3 throughput = material.colorDiffuse / CUDART_PI_F * dot(extensionDir, hitNormal);
paths.ray[pathIdx] = extensionRay;
paths.throughput[pathIdx] = paths.throughput[pathIdx] * throughput;
paths.p[pathIdx] *= p;
paths.rayNr[pathIdx] += 1;
}
__global__ void
specularExtensionKernel(
const glm::ivec2 canvasSize,
const Queues queues,
const Paths paths,
const Triangle* triangles
)
{
const uint32_t x = threadIdx.x + blockIdx.x * blockDim.x;
const uint32_t y = threadIdx.y + blockIdx.y * blockDim.y;
const uint32_t idx = x + y * canvasSize.x;
if (idx >= *queues.specularQueueSize)
return;
const float3 float3_zero = make_float3(0.f, 0.f, 0.f);
const uint32_t pathIdx = queues.specularQueue[idx];
const Ray hitRay = paths.ray[pathIdx];
const RaycastResult hitResult = paths.result[pathIdx];
const Triangle triangle = triangles[hitResult.triangleIdx];
const float3 hitNormal = triangle.normal(hitResult.uv);
const float3 reflectionRayOrigin = hitRay.origin + hitRay.direction*hitResult.t + hitNormal * OFFSET_EPSILON;
const float3 reflectionRayDir = reflectionDirection(hitNormal, hitRay.direction);
const Ray reflectionRay(reflectionRayOrigin, reflectionRayDir);
paths.ray[pathIdx] = reflectionRay;
//paths.throughput[pathIdx] = paths.throughput[pathIdx] * material.colorSpecular; // Handled in logicKernel
paths.rayNr[pathIdx] += 1;
}
__global__ void
transparentExtensionKernel(
const glm::ivec2 canvasSize,
const Queues queues,
const Paths paths,
const Triangle* triangles,
const uint32_t* triangleMaterialIds,
const Material* materials
)
{
const uint32_t x = threadIdx.x + blockIdx.x * blockDim.x;
const uint32_t y = threadIdx.y + blockIdx.y * blockDim.y;
const uint32_t idx = x + y * canvasSize.x;
if (idx >= *queues.transparentQueueSize)
return;
const float3 float3_zero = make_float3(0.f, 0.f, 0.f);
const uint32_t pathIdx = queues.transparentQueue[idx];
const Ray hitRay = paths.ray[pathIdx];
const RaycastResult hitResult = paths.result[pathIdx];
const Triangle triangle = triangles[hitResult.triangleIdx];
float3 hitNormal = triangle.normal(hitResult.uv);
const Material material = materials[triangleMaterialIds[hitResult.triangleIdx]];
const float idx1 = AIR_INDEX;
const float idx2 = material.refractionIndex;
const bool outside = dot(hitRay.direction, hitNormal) < 0.f;
if (!outside)
hitNormal = -hitNormal;
const float cosi = __saturatef(dot(hitRay.direction, hitNormal));
const float sin2t = abs((idx1 / idx2) * (idx1 / idx2) * (1 - cosi * cosi));
const float3 transOrig = hitRay.origin + hitRay.direction*hitResult.t - hitNormal * OFFSET_EPSILON;
const float3 transDir = refractionDirection(cosi, sin2t, hitNormal, hitRay.direction, idx1, idx2);
paths.ray[pathIdx] = Ray(transOrig, transDir);
//paths.throughput[pathIdx] = paths.throughput[pathIdx] * material.colorTransparent; // Handled in logicKernel
paths.rayNr[pathIdx] += 1;
}
__global__ void resetAllPaths(Paths paths, Camera camera,
const glm::fvec2 canvasSize)
{
const uint32_t x = threadIdx.x + blockIdx.x * blockDim.x;
const uint32_t y = threadIdx.y + blockIdx.y * blockDim.y;
const int idx = x + y * canvasSize.x;
if (x >= canvasSize.x || y >= canvasSize.y)
return;
const glm::fvec2 nic = camera.normalizedImageCoordinateFromPixelCoordinate(x, y, canvasSize);
const Ray ray = camera.generateRay(nic,static_cast<float>(canvasSize.x) / canvasSize.y);
paths.ray[idx] = ray;
paths.color[idx] = make_float3(0.f, 0.f, 0.f);
paths.throughput[idx] = make_float3(1.f, 1.f, 1.f);
paths.p[idx] = 1.f;
paths.rayNr[idx] = 1;
paths.pathNr[idx] = 1;
}
__global__ void castRays(Paths paths, const glm::ivec2 canvasSize,
const Triangle* triangles, const Node* bvh, const Material* materials,
const unsigned int* traingelMaterialIds)
{
const int x = threadIdx.x + blockIdx.x * blockDim.x;
const int y = threadIdx.y + blockIdx.y * blockDim.y;
const int idx = x + y * canvasSize.x;
if (x >= canvasSize.x || y >= canvasSize.y)
return;
const Ray ray = paths.ray[idx];
RaycastResult result = rayCast<HitType::CLOSEST>(ray, bvh, triangles, BIGT);
paths.result[idx] = result;
}
#endif /* KERNELS_HPP_ */
|
33e1779b51881b168f8cfcad1c76202fc3a254c4
|
221d667f76a556828c3e30ac6325411b1b723d65
|
/Visual Studio 2015 Project/output.h
|
456eacd6f2280ffe0b2957b8c494415d92a3d50e
|
[] |
no_license
|
basecq/DarkSoulsScriptHook
|
086d668ac4afb7c8b96f29d0b5b548672a79ac1a
|
2d284858bb6fbea95991e268d07cf436df2e65e9
|
refs/heads/master
| 2020-12-28T23:04:42.877374
| 2015-12-29T13:35:13
| 2015-12-29T13:35:13
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 519
|
h
|
output.h
|
#pragma once
#include <iostream>
#ifdef _DEBUG
#define D_ERR(x) std::cerr << "ERROR in " << __FILE__ << " at line " << __LINE__ << ": " << x << "\n";
#define D_WAR(x) std::cerr << "WARNING: " << x << "\n";
#define D_OUT(x) std::cout << x << "\n";
#else
#define D_ERR(x)
#define D_WAR(x)
#define D_OUT(x)
#endif
#define R_ERR(x) std::cerr << "ERROR in " << __FILE__ << " at line " << __LINE__ << ": " << x << "\n";
#define R_WAR(x) std::cerr << "WARNING: " << x << "\n";
#define R_OUT(x) std::cout << x << "\n";
|
df371f4d6253b5bc9db309630bba4e8994f22adf
|
d2650b73a3d64ec4c0614b08a4b0ba7370b7327a
|
/cpp/graph/bipartite-graph.cpp
|
9f673b1636e1e1df6a7766a7f9576457a73dc8f3
|
[] |
no_license
|
jodnddus/nojam
|
1fdf90805be8ea8bdfad5030f5ac39bc5b08d89f
|
a2e646ab06bc81f89bd451faea1da6231547de05
|
refs/heads/master
| 2020-05-18T07:57:21.808166
| 2019-08-15T10:05:53
| 2019-08-15T10:05:53
| 184,280,261
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 873
|
cpp
|
bipartite-graph.cpp
|
// https://www.acmicpc.net/problem/1707
#include <iostream>
#include <vector>
#define RED 1
#define BULE -1
using namespace std;
int K,V,E,visited[200001] = { 0, };
vector<int> graph[200001];
bool checkBipartite;
void dfs(int now, int color)
{
visited[now] = color;
for (int next : graph[now])
{
if (visited[next] == color)
{
checkBipartite = false;
return;
}
if (!visited[next]) dfs(next, -color);
}
}
int main()
{
cin >> K;
while (K-- > 0)
{
cin >> V >> E;
checkBipartite = true;
for (int i=1; i<=V; i++)
{
graph[i].clear();
visited[i] = 0;
}
for (int i=0,u,v; i<E; i++)
{
cin >> u >> v;
graph[u].push_back(v), graph[v].push_back(u);
}
for (int i=1; i<=V; i++)
{
if (!checkBipartite) break;
if (!visited[i]) dfs(i, RED);
}
printf("%s\n",checkBipartite ? "YES" : "NO");
}
return 0;
}
|
77ecff26186a7a6e9e7a0b25bf67bd241cd87208
|
97b50234b5aa6382932fea461835b5dd3ba9c473
|
/Games/StarShot/SST_Game.cpp
|
02d7fb0dcced0608cfd8b723b33d4406666d6f76
|
[] |
no_license
|
vectorstorm/vectorstorm-testbeds
|
d71d34c8a1be002081fb18224aba2b23f33ce89a
|
ad12a08fdaf95e0231a1693520a8aa2ca893016f
|
refs/heads/master
| 2021-05-16T02:32:07.725258
| 2014-01-24T01:01:05
| 2014-01-24T01:01:05
| 4,004,016
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 810
|
cpp
|
SST_Game.cpp
|
/*
* BNG_Game.cpp
* VectorStorm
*
* Created by Trevor Powell on 28/04/07.
* Copyright 2007 Trevor Powell. All rights reserved.
*
*/
#include "SST_Game.h"
#include "SST_Fireworks.h"
#include "SST_Hud.h"
#include "SST_ModeInGame.h"
#include "SST_Rocket.h"
#include "SST_Sequence.h"
//#define RECORDING_ALLOWED // disabled in most builds, so people don't accidentally tromp over the initial data when they're trying to figure out how to play.
REGISTER_GAME("StarShot", sstGame);
sstGame::sstGame()
{
m_sceneCount = 2;
}
void
sstGame::Init()
{
Parent::Init();
m_modeInGame = new sstModeInGame(this);
SetGameMode( m_modeInGame );
}
void
sstGame::Deinit()
{
SetGameMode( NULL );
vsDelete( m_modeInGame );
Parent::Deinit();
}
void
sstGame::Update(float timeStep)
{
UNUSED(timeStep);
}
|
9bdc812096bb823639c125adc980d34f7f384190
|
e8face9d41375f7ed4e6cfa960fac6ba7ed6c152
|
/src/parser.h
|
a1747a65ddd3bc8874a0ffb133b118fe31a24e93
|
[
"MIT"
] |
permissive
|
iguyong/cppmark
|
264f1ef90b333abc830a375a46886fdbb1ccf9e4
|
e26cc85f276d06decd52be25be9d87d40e0bde99
|
refs/heads/master
| 2021-09-14T07:23:24.748539
| 2018-05-09T16:43:19
| 2018-05-09T16:43:19
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,519
|
h
|
parser.h
|
//
// Created by yong gu on 5/3/18.
//
#ifndef CPPMARK_BLOCK_H
#define CPPMARK_BLOCK_H
#include <regex>
#include <string>
#include <unordered_map>
#include "token.h"
#include "rules.h"
#include "options.h"
#include "renderer.h"
class Link{
public:
string href;
string title;
};
class Parser {
public:
Parser(){};
Parser(Options& options):options(options),renderer(options){}
Renderer renderer;
Rules rules;
void tokenBlock(std::string &src, bool top = true, bool bq = false); // get block tokens
void parse(); // generate out from block tokens, it calls parseToken() for each token.
std::string parseToken(); // parse current token
std::string parseText(); // parse pure text
std::string parseInline(const std::string& text); //parse inline paragraph
std::string out; //output html
Options options;
std::vector<Token> tokens;
std::unordered_map<std::string,Link> links;
private:
//tokens access
int tokenIndex = -1;
Token token; //current token
bool next(){
if (tokenIndex + 1 < (int)tokens.size()){
tokenIndex ++;
token = tokens[tokenIndex];
return true;
}else{
return false;
}
}
bool peek(Token& nToken){
if (tokenIndex + 1 < (int)tokens.size()){
nToken = tokens[tokenIndex+1]; // preview next token
return true;
}else{
return false;
}
}
};
#endif //CPPMARK_BLOCK_H
|
4e1e0db1ead15b1a1bbf1f1fb413716ea9acbf2c
|
60639ff35d95b9644de078144abcc0b2be65ca09
|
/win32_api.cpp
|
f279741f20ef42578e120596d7ba9027df8e2074
|
[] |
no_license
|
y0zhyk/cpp_helpers
|
933295364f07f669e9c0dff6fc3f1b25e61e38a1
|
d78591ed4cc005d6b39dae745b6f2a16ba4c5720
|
refs/heads/master
| 2020-05-17T02:32:30.755497
| 2019-01-29T16:49:19
| 2019-01-29T16:49:19
| 31,330,751
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,179
|
cpp
|
win32_api.cpp
|
// Created by Taras Lushney on 6/8/14.
// Copyright (c) 2014 Taras Lushney. All rights reserved.
#include <functional>
#include <memory>
#include "./win32_api.h"
#include "./win32_exception.h"
namespace win32_api {
void CloseHandle(HANDLE handle) {
auto result = ::CloseHandle(handle);
ThrowLastErrorIf(FALSE == result, "::CloseHandle() == FALSE");
}
static void LocalFree(HLOCAL memory) {
auto result = ::LocalFree(memory);
ThrowLastErrorIf(NULL != result, "::LocalFree() != NULL");
}
std::string GetErrorString(DWORD error) {
if (error == 0)
return "No error";
char *raw_buffer = nullptr;
const size_t size = ::FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
nullptr, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPSTR>(&raw_buffer), 0, nullptr);
ThrowLastErrorIf(size == 0, "::FormatMessage() == 0");
std::unique_ptr<char, std::function<void(HLOCAL)>> buffer(raw_buffer, LocalFree);
return std::string(buffer.get(), size);
}
}; // namespace win32_api
|
68fa21d9b5c0e4f671841d02c6d41fb708448cf9
|
873002d555745752657e3e25839f6653e73966a2
|
/model/MessageResource.h
|
22bea2e8d267ee8be8b7b6264d77da5017e3ebbc
|
[] |
no_license
|
knetikmedia/knetikcloud-cpprest-client
|
e7e739e382c02479b0a9aed8160d857414bd2fbf
|
14afb57d62de064fb8b7a68823043cc0150465d6
|
refs/heads/master
| 2021-01-23T06:35:44.076177
| 2018-03-14T16:02:35
| 2018-03-14T16:02:35
| 86,382,044
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,160
|
h
|
MessageResource.h
|
/**
* Knetik Platform API Documentation latest
* This is the spec for the Knetik API. Use this in conjunction with the documentation found at https://knetikcloud.com.
*
* OpenAPI spec version: latest
* Contact: support@knetik.com
*
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/*
* MessageResource.h
*
*
*/
#ifndef MessageResource_H_
#define MessageResource_H_
#include "ModelBase.h"
#include "MessageContentResource.h"
#include <cpprest/details/basic_types.h>
namespace com {
namespace knetikcloud {
namespace client {
namespace model {
/// <summary>
///
/// </summary>
class MessageResource
: public ModelBase
{
public:
MessageResource();
virtual ~MessageResource();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
void fromJson(web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// MessageResource members
/// <summary>
/// The content of the message in various formats
/// </summary>
std::shared_ptr<MessageContentResource> getContent() const;
void setContent(std::shared_ptr<MessageContentResource> value);
/// <summary>
/// The id of the recipient, dependent on the recipient_type. The user's id or the topic's id. Required if sending directly to messaging service
/// </summary>
utility::string_t getRecipient() const;
bool recipientIsSet() const;
void unsetRecipient();
void setRecipient(utility::string_t value);
/// <summary>
/// The type of recipient for the message. Either a user, or all users in a topic. Required if sending directly to messaging service
/// </summary>
utility::string_t getRecipientType() const;
bool recipientTypeIsSet() const;
void unsetRecipient_type();
void setRecipientType(utility::string_t value);
/// <summary>
/// The subject of the message. Required for email messages
/// </summary>
utility::string_t getSubject() const;
bool subjectIsSet() const;
void unsetSubject();
void setSubject(utility::string_t value);
/// <summary>
/// The type of message for websocket type hinting. will be added to the payload with the key _type
/// </summary>
utility::string_t getType() const;
bool typeIsSet() const;
void unsetType();
void setType(utility::string_t value);
protected:
std::shared_ptr<MessageContentResource> m_Content;
utility::string_t m_Recipient;
bool m_RecipientIsSet;
utility::string_t m_Recipient_type;
bool m_Recipient_typeIsSet;
utility::string_t m_Subject;
bool m_SubjectIsSet;
utility::string_t m_Type;
bool m_TypeIsSet;
};
}
}
}
}
#endif /* MessageResource_H_ */
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.