blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 905
values | visit_date
timestamp[us]date 2015-08-09 11:21:18
2023-09-06 10:45:07
| revision_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-17 19:19:19
| committer_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-06 06:22:19
| github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us]date 2012-06-07 00:51:45
2023-09-14 21:58:39
⌀ | gha_created_at
timestamp[us]date 2008-03-27 23:40:48
2023-08-21 23:17:38
⌀ | gha_language
stringclasses 141
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 115
values | content
stringlengths 3
10.4M
| authors
listlengths 1
1
| author_id
stringlengths 0
158
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
960ec938ce0b8ab52754a558aba1e1b7c25d26aa
|
93758fe8a5d9860873c87e25392b5f4c23ada8d6
|
/branches/trunk/Kernel/spot-on-neighbor-b.cc
|
6ef6fccf467099d7057fd746e202207fe16485a1
|
[] |
no_license
|
Lucas-Developer/spot-on
|
c534fa55f2d19eb8735126b08b4c21912c015925
|
c6a64b006b4b9825ec93e7378e0e16969c889d3c
|
refs/heads/master
| 2021-05-15T06:24:49.868043
| 2017-12-12T23:17:54
| 2017-12-12T23:17:54
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 17,172
|
cc
|
/*
** Copyright (c) 2011 - 10^10^10, Alexis Megas.
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from Spot-On without specific prior written permission.
**
** SPOT-ON IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR 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
** SPOT-ON, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "spot-on-kernel.h"
#include "spot-on-neighbor.h"
QAbstractSocket::SocketState spoton_neighbor::state(void) const
{
if(m_bluetoothSocket)
{
#if QT_VERSION >= 0x050200 && defined(SPOTON_BLUETOOTH_ENABLED)
return QAbstractSocket::SocketState(m_bluetoothSocket->state());
#endif
return QAbstractSocket::UnconnectedState;
}
else if(m_sctpSocket)
return QAbstractSocket::SocketState(m_sctpSocket->state());
else if(m_tcpSocket)
return m_tcpSocket->state();
else if(m_udpSocket)
return m_udpSocket->state();
else
return QAbstractSocket::UnconnectedState;
}
QString spoton_neighbor::localAddress(void) const
{
if(m_bluetoothSocket)
{
#if QT_VERSION >= 0x050200 && defined(SPOTON_BLUETOOTH_ENABLED)
return m_bluetoothSocket->localAddress().toString();
#else
return "";
#endif
}
else if(m_sctpSocket)
return m_sctpSocket->localAddress().toString();
else if(m_tcpSocket)
return m_tcpSocket->localAddress().toString();
else if(m_udpSocket)
return m_udpSocket->localAddress().toString();
else
return "";
}
QString spoton_neighbor::peerAddress(void) const
{
if(m_bluetoothSocket)
{
#if QT_VERSION >= 0x050200 && defined(SPOTON_BLUETOOTH_ENABLED)
return m_bluetoothSocket->peerAddress().toString();
#else
return "";
#endif
}
else if(m_sctpSocket)
return m_sctpSocket->peerAddress().toString();
else if(m_tcpSocket)
return m_tcpSocket->peerAddress().toString();
else if(m_udpSocket)
return m_udpSocket->peerAddress().toString();
else
return "";
}
quint16 spoton_neighbor::peerPort(void) const
{
if(m_sctpSocket)
return m_sctpSocket->peerPort();
else if(m_tcpSocket)
return m_tcpSocket->peerPort();
else if(m_udpSocket)
return m_udpSocket->peerPort();
else
return 0;
}
bool spoton_neighbor::isEncrypted(void) const
{
if(m_tcpSocket)
return m_tcpSocket->isEncrypted();
else
return false;
}
QString spoton_neighbor::transport(void) const
{
return m_transport;
}
void spoton_neighbor::slotAuthenticationTimerTimeout(void)
{
spoton_misc::logError
(QString("spoton_neighbor::slotAuthenticationTimerTimeout(): "
"authentication timer expired for %1:%2. Aborting!").
arg(m_address).
arg(m_port));
deleteLater();
}
void spoton_neighbor::abort(void)
{
if(m_bluetoothSocket)
{
#if QT_VERSION >= 0x050200 && defined(SPOTON_BLUETOOTH_ENABLED)
m_bluetoothSocket->abort();
#endif
}
else if(m_sctpSocket)
m_sctpSocket->abort();
else if(m_tcpSocket)
m_tcpSocket->abort();
else if(m_udpSocket)
m_udpSocket->abort();
}
void spoton_neighbor::close(void)
{
if(m_bluetoothSocket)
{
#if QT_VERSION >= 0x050200 && defined(SPOTON_BLUETOOTH_ENABLED)
m_bluetoothSocket->disconnectFromService();
#endif
}
else if(m_sctpSocket)
m_sctpSocket->close();
else if(m_tcpSocket)
{
if(!m_isUserDefined)
{
int socketDescriptor = static_cast<int>
(m_tcpSocket->socketDescriptor());
#ifdef Q_OS_WIN32
shutdown(socketDescriptor, SD_BOTH);
#else
shutdown(socketDescriptor, SHUT_RDWR);
#endif
}
m_tcpSocket->close();
}
else if(m_udpSocket)
m_udpSocket->close();
}
void spoton_neighbor::slotStopTimer(QTimer *timer)
{
if(timer)
timer->stop();
}
void spoton_neighbor::slotNewDatagram(const QByteArray &datagram)
{
if(datagram.isEmpty())
return;
m_bytesRead += static_cast<quint64> (datagram.length());
if(m_passthrough)
{
/*
** A private application may not be able to authenticate.
*/
if(!m_privateApplicationCredentials.isEmpty())
{
if(m_isUserDefined)
{
QMutexLocker locker(&m_privateApplicationMutex);
quint64 sequence = m_privateApplicationSequences.first;
m_privateApplicationSequences.first += 1;
locker.unlock();
m_privateApplicationFutures << QtConcurrent::run
(this,
&spoton_neighbor::bundlePrivateApplicationData,
datagram,
m_privateApplicationCredentials,
m_id,
sequence);
}
else
{
QMutexLocker locker(&m_privateApplicationMutex);
quint64 sequence = m_privateApplicationSequences.second;
m_privateApplicationSequences.second += 1;
locker.unlock();
m_privateApplicationFutures << QtConcurrent::run
(this,
&spoton_neighbor::bundlePrivateApplicationData,
datagram,
m_privateApplicationCredentials,
m_id,
sequence);
}
return;
}
bool ok = true;
if(m_useAccounts.fetchAndAddOrdered(0))
if(!m_accountAuthenticated.fetchAndAddOrdered(0))
ok = false;
if(ok)
{
if(!spoton_kernel::messagingCacheContains(datagram))
{
emit receivedMessage
(datagram, m_id, QPair<QByteArray, QByteArray> ());
spoton_kernel::messagingCacheAdd(datagram);
}
emit resetKeepAlive();
return;
}
}
QReadLocker locker1(&m_maximumBufferSizeMutex);
qint64 maximumBufferSize = m_maximumBufferSize;
locker1.unlock();
QWriteLocker locker2(&m_dataMutex);
int length = static_cast<int> (maximumBufferSize) - m_data.length();
if(length > 0)
m_data.append(datagram.mid(0, length));
if(!m_data.isEmpty())
{
locker2.unlock();
emit newData();
}
}
void spoton_neighbor::saveUrlsToShared(const QList<QByteArray> &urls)
{
if(urls.isEmpty())
return;
if(spoton_kernel::instance())
spoton_kernel::instance()->saveUrls(urls);
}
void spoton_neighbor::slotEchoKeyShare(const QByteArrayList &list)
{
if(m_passthrough && !m_privateApplicationCredentials.isEmpty())
return;
QByteArray message;
QPair<QByteArray, QByteArray> ae
(spoton_misc::decryptedAdaptiveEchoPair(m_adaptiveEchoPair,
spoton_kernel::s_crypts.
value("chat", 0)));
message = spoton_send::message0090
(list.value(0) + "\n" + list.value(1), ae);
if(readyToWrite())
{
if(write(message.constData(), message.length()) != message.length())
spoton_misc::logError
(QString("spoton_neighbor::slotEchoKeyShare(): write() error "
"for %1:%2.").
arg(m_address).
arg(m_port));
else
spoton_kernel::messagingCacheAdd(message);
}
}
void spoton_neighbor::deleteLater(void)
{
#if QT_VERSION >= 0x050200 && defined(Q_OS_MAC) && \
defined(SPOTON_BLUETOOTH_ENABLED)
if(m_transport == "bluetooth")
{
/*
** Deferred deletion does not function correctly on
** OS X.
*/
m_abort.fetchAndStoreOrdered(1);
disconnect(m_bluetoothSocket,
SIGNAL(connected(void)),
this,
SLOT(slotConnected(void)));
disconnect(m_bluetoothSocket,
SIGNAL(disconnected(void)),
this,
SIGNAL(disconnected(void)));
disconnect(m_bluetoothSocket,
SIGNAL(disconnected(void)),
this,
SLOT(slotDisconnected(void)));
disconnect(m_bluetoothSocket,
SIGNAL(error(QBluetoothSocket::SocketError)),
this,
SLOT(slotError(QBluetoothSocket::SocketError)));
disconnect(m_bluetoothSocket,
SIGNAL(readyRead(void)),
this,
SLOT(slotReadyRead(void)));
disconnect(this,
SIGNAL(accountAuthenticated(const QByteArray &,
const QByteArray &,
const QByteArray &)),
this,
SLOT(slotAccountAuthenticated(const QByteArray &,
const QByteArray &,
const QByteArray &)));
disconnect(this,
SIGNAL(resetKeepAlive(void)),
this,
SLOT(slotResetKeepAlive(void)));
disconnect(this,
SIGNAL(sharePublicKey(const QByteArray &,
const QByteArray &,
const QByteArray &,
const QByteArray &,
const QByteArray &,
const QByteArray &)),
this,
SLOT(slotSharePublicKey(const QByteArray &,
const QByteArray &,
const QByteArray &,
const QByteArray &,
const QByteArray &,
const QByteArray &)));
disconnect(this,
SIGNAL(stopTimer(QTimer *)),
this,
SLOT(slotStopTimer(QTimer *)));
disconnect(this,
SIGNAL(writeParsedApplicationData(const QByteArray &)),
this,
SLOT(slotWriteParsedApplicationData(const QByteArray &)));
close();
m_accountTimer.stop();
m_authenticationTimer.stop();
m_externalAddressDiscovererTimer.stop();
m_keepAliveTimer.stop();
m_lifetime.stop();
m_timer.stop();
delete this;
}
else
QThread::deleteLater();
#else
QThread::deleteLater();
#endif
}
void spoton_neighbor::slotSendForwardSecrecyPublicKey(const QByteArray &data)
{
if(m_passthrough && !m_privateApplicationCredentials.isEmpty())
return;
QByteArray message;
QPair<QByteArray, QByteArray> ae
(spoton_misc::decryptedAdaptiveEchoPair(m_adaptiveEchoPair,
spoton_kernel::s_crypts.
value("chat", 0)));
message = spoton_send::message0091a(data, ae);
if(readyToWrite())
{
if(write(message.constData(), message.length()) != message.length())
spoton_misc::logError
(QString("spoton_neighbor::slotSendForwardSecrecyPublicKey(): "
"write() error for %1:%2.").
arg(m_address).
arg(m_port));
else
spoton_kernel::messagingCacheAdd(message);
}
}
void spoton_neighbor::slotSendForwardSecrecySessionKeys
(const QByteArray &data)
{
if(m_passthrough && !m_privateApplicationCredentials.isEmpty())
return;
QByteArray message;
QPair<QByteArray, QByteArray> ae
(spoton_misc::decryptedAdaptiveEchoPair(m_adaptiveEchoPair,
spoton_kernel::s_crypts.
value("chat", 0)));
message = spoton_send::message0091b(data, ae);
if(readyToWrite())
{
if(write(message.constData(), message.length()) != message.length())
spoton_misc::logError
(QString("spoton_neighbor::slotSendForwardSecrecySessionKeys(): "
"write() error for %1:%2.").
arg(m_address).
arg(m_port));
else
spoton_kernel::messagingCacheAdd(message);
}
}
void spoton_neighbor::parsePrivateApplicationData
(const QByteArray &data,
const QByteArray &privateApplicationCredentials,
const qint64 maximumContentLength)
{
/*
** The container data contains Spot-On data, that is, data does
** not contain raw application data.
*/
if(privateApplicationCredentials.isEmpty())
return;
int a = data.indexOf("Content-Length: ");
if(a >= 0)
{
QByteArray contentLength;
int b = data.indexOf("\r\n", a);
int length = 0;
if(b > 0)
{
a += static_cast<int> (qstrlen("Content-Length: "));
if(a < b)
contentLength = data.mid(a, b - a);
}
/*
** toInt() returns zero on failure.
*/
length = contentLength.toInt();
if(length > 0 && length <= maximumContentLength)
if((a = data.indexOf("content=", a)) > 0)
{
QByteArray bytes(data.mid(a));
if(bytes.length() == length)
{
bytes = bytes.mid
(static_cast<int> (qstrlen("content="))).trimmed();
if((a = bytes.lastIndexOf('\n')) > 0)
{
spoton_crypt *crypt = spoton_misc::
parsePrivateApplicationMagnet
(privateApplicationCredentials);
if(crypt)
{
bool ok = true;
bytes = crypt->decryptedAfterAuthenticated
(QByteArray::fromBase64(bytes.mid(0, a)), &ok);
delete crypt;
if(ok)
{
/*
** In-order:
** 1
** 2
** 3
** 4
** 5
** Out-of-order:
** 2
** 5
** 3
** 1
** 4
*/
QByteArray sequencer(bytes.mid(0, 20));
quint64 sequence = sequencer.toULongLong();
if(m_isUserDefined)
{
QMutexLocker locker(&m_privateApplicationMutex);
if(m_privateApplicationSequences.first ==
sequence)
{
emit writeParsedApplicationData
(bytes.mid(20));
m_privateApplicationSequences.first += 1;
}
else if(m_privateApplicationSequences.first <
sequence)
/*
** The received sequence number
** should always increase, yes? Our
** initial value is one. It is increased
** if the received sequence equals the
** initial value.
*/
m_privateApplicationMap[sequence] =
bytes.mid(20);
/*
** Determine if we can distribute more data.
*/
while(true)
if(m_privateApplicationMap.
contains(m_privateApplicationSequences.
first))
{
emit writeParsedApplicationData
(m_privateApplicationMap.
take(m_privateApplicationSequences.
first));
m_privateApplicationSequences.first += 1;
}
else
break;
}
else
{
QMutexLocker locker(&m_privateApplicationMutex);
if(m_privateApplicationSequences.second ==
sequence)
{
emit writeParsedApplicationData
(bytes.mid(20));
m_privateApplicationSequences.second += 1;
}
else if(m_privateApplicationSequences.second <
sequence)
/*
** The received sequence number
** should always increase, yes? Our
** initial value is one. It is increased
** if the received sequence equals the
** initial value.
*/
m_privateApplicationMap[sequence] =
bytes.mid(20);
/*
** Determine if we can distribute more data.
*/
while(true)
if(m_privateApplicationMap.
contains(m_privateApplicationSequences.
second))
{
emit writeParsedApplicationData
(m_privateApplicationMap.
take(m_privateApplicationSequences.
second));
m_privateApplicationSequences.second += 1;
}
else
break;
}
}
}
}
}
}
}
}
void spoton_neighbor::slotWriteParsedApplicationData(const QByteArray &data)
{
/*
** Let's write the raw data to the private application.
*/
if(data.length() > m_laneWidth)
return;
if(readyToWrite())
if(write(data.constData(), data.length()) != data.length())
spoton_misc::logError
(QString("spoton_neighbor::slotWriteParsedApplicationData(): "
"write() error for %1:%2.").
arg(m_address).
arg(m_port));
}
void spoton_neighbor::bundlePrivateApplicationData
(const QByteArray &data,
const QByteArray &privateApplicationCredentials,
const qint64 id,
const quint64 sequence)
{
/*
** The container data contains raw application data. We will not insert
** an entry into the congestion-control mechanism here.
*/
spoton_crypt *crypt = spoton_misc::parsePrivateApplicationMagnet
(privateApplicationCredentials);
if(!crypt)
return;
QByteArray bytes;
bool ok = true;
bytes = crypt->encryptedThenHashed // Twelve bytes could be conserved.
(QByteArray::number(sequence).rightJustified(20, '0') + data, &ok);
delete crypt;
if(ok)
emit receivedMessage
(spoton_send::messageXYZ(bytes.toBase64(),
QPair<QByteArray, QByteArray> ()),
id,
QPair<QByteArray, QByteArray> ());
emit resetKeepAlive();
}
void spoton_neighbor::slotSMPMessageReceivedFromUI(const QByteArrayList &list)
{
if(m_passthrough && !m_privateApplicationCredentials.isEmpty())
return;
QByteArray message;
QPair<QByteArray, QByteArray> ae
(spoton_misc::decryptedAdaptiveEchoPair(m_adaptiveEchoPair,
spoton_kernel::s_crypts.
value("chat", 0)));
message = spoton_send::messageXYZ
(list.value(2) + "\n" +
list.value(3) + "\n" +
list.value(4), ae);
if(readyToWrite())
{
if(write(message.constData(), message.length()) != message.length())
spoton_misc::logError
(QString("spoton_neighbor::slotSMPMessageReceivedFromUI(): "
"write() error for %1:%2.").
arg(m_address).
arg(m_port));
else
spoton_kernel::messagingCacheAdd(message);
}
}
|
[
"textbrowser@gmail.com"
] |
textbrowser@gmail.com
|
dcd84093269a4ae05cea2dd31645bd2d5ba60631
|
81361fbb260f3a43f2dfd05474c1bb06c5160d9c
|
/USACO/transform.cpp
|
c323a7645ca3bd524b8c564022f2bf8848f1db22
|
[] |
no_license
|
enamcse/ACM-Programming-Codes
|
9307a22aafb0be6d8f64920e46144f2f813c493a
|
70b57c35ec551eae6322959857b3ac37bcf615fa
|
refs/heads/master
| 2022-10-09T19:35:54.894241
| 2022-09-30T01:26:24
| 2022-09-30T01:26:24
| 33,211,745
| 3
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,309
|
cpp
|
/*
ID: manetsus
PROG: transform
LANG: C++
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <vector>
#include <algorithm>
#include <cctype>
#include <fstream>
#include <map>
#define sz 11
#define input_file "transform.in"
#define output_file "transform.out"
#define pb(a) push_back(a)
#define pp pop_back()
#define all(a) a.begin(),a.end()
#define ll long long
#define fread freopen(input_file,"r",stdin)
#define fwrite freopen(output_file,"w",stdout)
#define inf (1<<30-1)
#define clr(abc,z) memset(abc,z,sizeof(abc))
#define chng(a,b) a^=b^=a^=b;
#define PI acos(-1)
#define mod 1000000007
using namespace std;
char pre[sz][sz], post[sz][sz], original[sz][sz];
char temp[sz][sz];
void make_mirrored(int n)
{
for (int i = 0; i<n; i++)
for (int j = 0; j<n; j++)
temp[i][j] = pre[i][n-1-j];
for (int i = 0; i<n; i++)
for (int j = 0; j<n; j++)
{
original[i][j] = pre[i][j];
pre[i][j]=temp[i][j];
}
return;
}
void get_original(int n)
{
for (int i = 0; i<n; i++)
for (int j = 0; j<n; j++)
pre[i][j]=original[i][j];
return;
}
void rotat(int n)
{
for (int i = 0; i<n; i++)
for (int j = 0; j<n; j++)
temp[i][j] = pre[n-j-1][i];
for (int i = 0; i<n; i++)
for (int j = 0; j<n; j++)
pre[i][j] = temp[i][j];
return;
}
bool check(int n)
{
int i;
for (i = 0; i<n; i++)
{
int j;
for (j=0; j<n; j++)
if(pre[i][j]!=post[i][j]) break;
if(j!=n) break;
}
if(i==n) return true;
return false;
}
int main()
{
#if !defined ENAM
fread;
fwrite;
#endif // ENAM
// ofstream fout (input_file);
// ifstream fin (output_file);
int ans = 0, i,n;
scanf("%d", &n);
for (i = 0; i<n; i++)
scanf("%s", pre[i]);
for (i = 0; i<n; i++)
scanf("%s", post[i]);
switch (1)
{
case 1:
//rotate 90-degree
rotat(n);
if(check(n))
{
ans = 1;
break;
}
//rotate 180-degree
rotat(n);
if(check(n))
{
ans = 2;
break;
}
//rotate 270-degree
rotat(n);
if(check(n))
{
ans = 3;
break;
}
//back to original
rotat(n);
make_mirrored(n);
// for (int i = 0; i<n; i++)
// cout<<pre[i]<<endl;
//check mirrored
if(check(n))
{
ans = 4;
break;
}
//rotate 90,180,270-degree
for (i=0; i<3; i++)
{
rotat(n);
if(check(n))
{
ans = 5;
break;
}
}
if(i!=3) break;
get_original(n);
if(check(n))
{
ans = 6;
break;
}
ans = 7;
break;
}
printf("%d\n", ans);
return 0;
}
/*
4
@@@@
@@@@
-@@@
@@@@
@@@@
@@@@
@@@-
@@@@
*/
|
[
"enamsustcse@gmail.com"
] |
enamsustcse@gmail.com
|
176f28b36e9bdc71c53052eb3ce17aaff8e839f3
|
94c8827ab404881fa15c44fbd0cd684eee515e8a
|
/GameEngine/w_main.cpp
|
3dbd8c894c98d6112a8224c3b05aabfa13616b45
|
[] |
no_license
|
KarteekKumarM/FrozenArk
|
b7cb3c04891b95d77c214cec7fe0982ae9f4a756
|
06f444ff549cf4e9602db2f26fa2324f56d9950a
|
refs/heads/master
| 2021-01-02T22:29:49.098984
| 2015-01-12T06:22:06
| 2015-01-12T06:22:06
| 24,086,989
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,812
|
cpp
|
#include "w_main.h"
#include "r_main.h"
#include "g_main.h"
#include "console.h"
#include "c_time.h"
HWND s_hWnd;
// forward declarations
void W_Shutdown();
LRESULT CALLBACK W_WindowProc( HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
switch ( message )
{
case WM_DESTROY:
W_Shutdown();
PostQuitMessage( 0 );
return 0;
default:
break;
}
return DefWindowProc( hWnd, message, wParam, lParam );
}
static void W_CommonInit()
{
C_InitTime();
}
static void W_CommonFrame()
{
C_UpdateTime();
}
void W_InitalizeWindow( HINSTANCE hInstance, int nCmdShow )
{
WNDCLASSEX wc;
ZeroMemory( &wc, sizeof( WNDCLASSEX ) );
wc.cbSize = sizeof( WNDCLASSEX );
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // TODO: optional cursor
wc.lpszClassName = WIN_CLASSNAME; // TODO: config string file
wc.lpfnWndProc = W_WindowProc;
RegisterClassEx( &wc );
s_hWnd = CreateWindowEx( NULL,
wc.lpszClassName,
WIN_TITLE,
WIN_STYLE,
WIN_POS_X,
WIN_POS_Y,
WIN_WIDTH,
WIN_HEIGHT,
NULL,
NULL,
hInstance,
NULL
);
W_CommonInit();
Con_Init();
R_Init( s_hWnd, 640, 480 );
ShowWindow( s_hWnd, nCmdShow );
G_Init( hInstance, s_hWnd );
Con_PrintLn( CON_CHANNEL_SYSTEM, "W_InitalizeWindow() complete" );
}
void W_EnterMessageLoop()
{
MSG msg;
while ( true )
{
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
// translate keystroke message to right format
TranslateMessage( &msg );
// send message to WindowsProc callback
DispatchMessage( &msg );
// check if its time to quit
if ( msg.message == WM_QUIT )
{
break;
}
}
W_CommonFrame();
G_Frame();
R_Frame();
}
}
void W_Shutdown()
{
Con_Shutdown();
Con_PrintLn( CON_CHANNEL_SYSTEM, "R_Shutdown() complete" );
}
|
[
"Karteek.Kumar.M@gmail.com"
] |
Karteek.Kumar.M@gmail.com
|
69a6aafe52e7cf58d6ae41ada5a6ab89d3f164cc
|
a4d65b6552c160933d8e19e0477004126f43e980
|
/2nd/euler25.cpp
|
91ea227ddc6c0a72e70373c3990a1015305b181b
|
[] |
no_license
|
chunag24/project_euler
|
d4224f2d4f01b12867e462a233d54bcdd1d4bb6a
|
d930ad519fca71803f483178f9b15702748bec21
|
refs/heads/main
| 2023-03-31T03:06:38.220626
| 2021-04-05T03:52:59
| 2021-04-05T03:52:59
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 867
|
cpp
|
/*************************************************************************
> File Name: euler25.cpp
> Author:
> Mail:
> Created Time: Sun 4 Apr 15:53:51 2021
************************************************************************/
#include<iostream>
using namespace std;
void func(int *n1, int *n2){
cout << n2[0] << " " << n1[0] << endl;
n2[0] = n1[0];
for (int i = 1; i <= n2[0]; i++){
n2[i] += n1[i];
if (n2[i] > 9){
n2[i + 1] += n2[i] / 10;
n2[i] %= 10;
if (i == n2[0]){
n2[0]++;
}
}
}
}
int main(){
int num[2][1111] = {{1, 1}, {1, 1}}, a = 0, b = 1;
for (int i = 3; i; i++){
func(num[a], num[b]);
if (num[b][0] >= 10){
cout << i << endl;
break;
}
swap(a, b);
}
return 0;
}
|
[
"hzh94kobe24@hotmail.com"
] |
hzh94kobe24@hotmail.com
|
c5d2bdb1d8baaf1993ff68223127f393ceea379e
|
baebe8a00a7b3aa662b8078bd000c424bb214cc6
|
/src/bxdf/specular_reflection_brdf.cpp
|
0aad2e7b4e729cc30752fa41c6215ba26693f131
|
[
"MIT"
] |
permissive
|
jonike/lumen
|
8ffd85f64018eba0d5adea401c44f740b6ea0032
|
c35259f45a265d470afccb8b6282c8520eabdc95
|
refs/heads/master
| 2021-04-25T04:03:36.864204
| 2017-06-02T17:49:11
| 2017-07-15T00:10:37
| 115,495,859
| 2
| 0
| null | 2017-12-27T07:45:31
| 2017-12-27T07:45:31
| null |
UTF-8
|
C++
| false
| false
| 805
|
cpp
|
#include <cmath>
#include <geometry.h>
#include <specular_reflection_brdf.h>
namespace lumen {
specular_reflection_brdf::specular_reflection_brdf(const nex::color& reflectance) :
bxdf(),
reflectance(reflectance)
{
}
nex::color specular_reflection_brdf::sample(const lumen::sample& sample, const surface& surface,
const nex::vector& wo, nex::vector* wi, float* pdf) const
{
*wi = reflect(wo, surface.normal);
*pdf = 1.0f;
return reflectance / std::abs(nex::dot(surface.normal, *wi));
}
nex::color specular_reflection_brdf::evaluate(const surface& surface,
const nex::vector& wo, const nex::vector& wi) const
{
return nex::color::black();
}
int specular_reflection_brdf::type() const
{
return BXDF_REFLECTION | BXDF_SPECULAR;
}
}
|
[
"jeremy.adam.lukacs@gmail.com"
] |
jeremy.adam.lukacs@gmail.com
|
91d8be0d5eb8a2a5b0a299c100110601b7879229
|
98fd8f675fa336090e433fc9889d0471f77417e4
|
/ArduinoDoorbell.ino
|
7e462aa72ff349aa90f6916c7382c32f38c0872f
|
[] |
no_license
|
thisptr-hub/ArduinoDoorbell
|
8a0eed9d3523222dcc6e583ab236aef1b6a096d6
|
88f63ad8dfe45fc16a70794b35d8921ef5171e70
|
refs/heads/master
| 2022-10-23T19:10:31.867471
| 2020-06-18T13:41:48
| 2020-06-18T13:41:48
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,524
|
ino
|
#include <stdint.h>
#include "BellFilePlayer.h"
#include "BellButton.h"
BellFilePlayer *player;
BellButton *bellButton;
const uint32_t SHORT_PLAY_DURATION_MS = 5000;
const uint16_t BUTTON_PRESSES_FOR_LONG_PLAY = 3;
const uint32_t BUTTON_PRESS_CHECKS_BEFORE_TIMEOUT = 20;
const char *audioFileName = "bell.wav";
void setup() {
bellButton = new BellButton();
player = new BellFilePlayer();
}
uint16_t recentButtonPresses = 0;
uint32_t lastPlayedPosition = 0;
uint16_t buttonNotPressedCount;
void ResetRepeatedPressData() {
recentButtonPresses = 0;
lastPlayedPosition = 0;
buttonNotPressedCount = 0;
}
void ResetRepeatedPressDataOnTimeout() {
if (buttonNotPressedCount >= BUTTON_PRESS_CHECKS_BEFORE_TIMEOUT) {
ResetRepeatedPressData();
}
}
uint32_t DeterminePlayDuration() {
if (recentButtonPresses >= (BUTTON_PRESSES_FOR_LONG_PLAY - 1)) {
return (UINT32_MAX / player->FILE_SAMPLES_PER_MSEC);
}
else {
return SHORT_PLAY_DURATION_MS;
}
}
void loop() {
if (bellButton->IsButtonPressed()) {
uint32_t playDuration = DeterminePlayDuration();
player->PlayFile(audioFileName, lastPlayedPosition, playDuration);
if (player->IsFileFinished()) {
ResetRepeatedPressData();
}
else {
lastPlayedPosition += playDuration;
recentButtonPresses++;
}
}
else if (recentButtonPresses > 0) {
buttonNotPressedCount++;
ResetRepeatedPressDataOnTimeout();
}
}
|
[
""
] | |
5412d21d6d28e1e9b3bec3be073eb02548bbfbd4
|
322db0227e38a60db6541f94c305f4460b5f9573
|
/51Nod/2455.cpp
|
26f42c78893d7d08c789f7b65cde3946746d2493
|
[] |
no_license
|
miluplay/AlgorithmProblemList
|
74eb29ff4810be1f3807d3ca37fe53bd38852b4e
|
36327009afe863ad6a25ac80e2ebfddc11ef5cd9
|
refs/heads/master
| 2022-12-22T06:48:59.098857
| 2020-08-26T09:47:29
| 2020-08-26T09:47:29
| 269,381,987
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 214
|
cpp
|
// Link:https://www.51nod.com/Challenge/Problem.html#problemId=2455
#include <iostream>
#define BT ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
using namespace std;
int main() { BT
return 0; }
|
[
"miluplay1013@outlook.com"
] |
miluplay1013@outlook.com
|
32f3aabd5f1cc3adeb0047ca0a7e47347a2b49ae
|
a5103b7d5066138ac1a9aabc273361491a5031cd
|
/c++/computerGraph/two/ModelerView.h
|
837fdfa1c2144f51863c61864d8b050f5854b849
|
[] |
no_license
|
mckjzhangxk/deepAI
|
0fa2f261c7899b850a4ec432b5a387e8c5f13e83
|
24e60f24b6e442db22507adddd6bf3e2c343c013
|
refs/heads/master
| 2022-12-13T18:00:12.839041
| 2021-06-18T03:01:10
| 2021-06-18T03:01:10
| 144,862,423
| 1
| 1
| null | 2022-12-07T23:31:01
| 2018-08-15T14:19:10
|
Jupyter Notebook
|
UTF-8
|
C++
| false
| false
| 942
|
h
|
// modelerview.h
// This is the base class for your view window. It contains
// a camera control for your use. The draw() function will
// set up default lighting and apply the projection.
#ifndef MODELERVIEW_H
#define MODELERVIEW_H
#ifdef WIN32
#include <windows.h>
#endif
#include <FL/Fl_Gl_Window.H>
#include <GL/gl.h>
class Camera;
class ModelerView;
#include "SkeletalModel.h"
using namespace std;
class ModelerView : public Fl_Gl_Window
{
public:
ModelerView(int x, int y, int w, int h, const char *label = 0);
void loadModel(int argc, char* argv[]);
virtual ~ModelerView ();
virtual int handle(int event);
virtual void update();
virtual void draw();
void updateJoints();
void drawAxes();
Camera *m_camera;
SkeletalModel model;
bool m_drawAxes;
bool m_drawSkeleton; // if false, the mesh is drawn instead.
};
#endif /* */
|
[
"mckj_zhangxk@163.com"
] |
mckj_zhangxk@163.com
|
b90be6d0301e2b15cd3d865bcdea8474fe467751
|
8d224a6d10be43849294fa686e5b7c1d8c7b12f2
|
/13ArrayPointersAndReference/ptr2ClassMember.cpp
|
8c5f75c0aec94661c9c7bb2ae2ac50f7aee5b9ce
|
[] |
no_license
|
linuxmint17/TheCompleteRefercnce
|
60e22c8a7192def6aba4811ba28bc18113ec8b51
|
7c2c6db0a6533c282562f05a64d93c33c255470b
|
refs/heads/master
| 2021-10-29T19:38:58.181982
| 2019-04-25T14:27:47
| 2019-04-25T14:27:47
| 104,641,157
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,433
|
cpp
|
#include<iostream>
#include<cstdio>
#include<new>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<iomanip>
using namespace std;
class cl{
public:
cl(int i){val=i;}
int val;
int double_val(){return val+val;}
};
int main(void)
{
int cl::*data;//data member pointer
int (cl::*func)();//function member pointer
cl ob1(1),ob2(2);//create objects
data=&cl::val;//get offset of val
func=&cl::double_val;//get offset of double_val()
cout<<"here are values: ";
cout<<ob1.*data<<" " <<ob2.*data<<endl;
cout<<"here they are doubled :";
cout<<(ob1.*func)()<<" ";
cout<<(ob2.*func)()<<endl;
return 0;
}
//C++ allows you to generate a special type of pointer that "points"
//genericall to a member of a class , not to a specific instance of
//that memember in an object.Thsi soft of pointer is called a pointer
//to a class member or a pointer-to-member ,for short.A pointer to
// a member is not the same as a normal C++ pointer .Instead , a pointer
//to member provide only an offset into an object of the member's class
// at which that member can be found .Since member pointers are not true
//pointers ,the . and -> can not be applied to them. To access a member
//of a class given a pointer to it, you must use the special pointer-to-member
//opterators .* and ->* .Their job is to allow you to access a member of a
//class given a pointer to that ember.
|
[
"opensuselinux13.2@gmail.com"
] |
opensuselinux13.2@gmail.com
|
2321c2cf11e5f13198c3801bfee97819c565c1a3
|
357e30063ffc703a194ebd1a13871be1ac4866c6
|
/src/MoriorGames/Entity/Neuron.cpp
|
6c82248c263d1228edd953896ebeb6deab970689
|
[] |
no_license
|
moriorgames/machine-learning
|
74de19024aad4107d2c1c46bb278a075d747df84
|
ea4c7a8b7faef388af91201ccd43d51f5e730c34
|
refs/heads/master
| 2021-09-06T16:54:11.243364
| 2018-02-08T19:11:03
| 2018-02-08T19:11:03
| 114,208,898
| 1
| 0
| null | 2018-02-08T19:11:04
| 2017-12-14T05:59:17
|
C++
|
UTF-8
|
C++
| false
| false
| 2,519
|
cpp
|
#include "Neuron.h"
using MoriorGames::Neuron;
Neuron::Neuron(unsigned index, unsigned nextLayer)
: index{index}
{
for (unsigned i = 0; i < nextLayer; ++i) {
connections.push_back(new Connection);
}
}
void Neuron::feedForward(Layer *layer)
{
double sum = 0.0;
// Sum the previous layer outputs and add the Bias Neuron output
for (unsigned i = 0; i < layer->size(); ++i) {
sum += layer->at(i)->getOutput() * layer->at(i)->getOutputWeights()[index]->weight;
}
output = activationFunction(sum);
}
void Neuron::calculateOutputGradient(double output)
{
double delta = output - this->output;
gradient = delta * activationFunctionDerivative(output);
}
double Neuron::getOutput() const
{
return output;
}
const vector<MoriorGames::Connection *> &Neuron::getOutputWeights() const
{
return connections;
}
void Neuron::setOutput(double output)
{
this->output = output;
}
void Neuron::print()
{
cout << "Connection Weights" << endl;
for (auto connection:connections) {
cout << connection->weight << endl;
}
}
/**
* We Compute hyperbolic tangent function as an Activation function
*
* @param x
*
* @return double
*/
double Neuron::activationFunction(double x)
{
return 1.0 / (1.0 + exp(-x));
}
double Neuron::activationFunctionDerivative(double x)
{
auto f = activationFunction(x);
return f * (1 - f);
}
void Neuron::calculateHiddenGradient(const Layer *nextLayer)
{
double dow = sumDow(nextLayer);
gradient = dow * activationFunctionDerivative(output);
}
double Neuron::sumDow(const Layer *nextLayer) const
{
double sum = 0.0;
// Sum our contributions of the errors at the nodes we feed.
for (unsigned i = 0; i < nextLayer->size() - 1; ++i) {
sum += connections[i]->weight * nextLayer->at(i)->gradient;
}
return sum;
}
void Neuron::updateInputWeights(Layer *previousLayer)
{
// The weights to be updated are in the Connection container
// in the neurons in the preceding layer
for (auto &neuron:*previousLayer) {
double oldDeltaWeight = neuron->connections[index]->deltaWeight;
double newDeltaWeight = calculateDeltaWeight(oldDeltaWeight, neuron);
neuron->connections[index]->deltaWeight = newDeltaWeight;
neuron->connections[index]->weight += newDeltaWeight;
}
}
double Neuron::calculateDeltaWeight(double delta, Neuron *neuron) const
{
return LEARNING_RATE * neuron->getOutput() * gradient + MOMENTUM * delta;
}
|
[
"moriorgames@gmail.com"
] |
moriorgames@gmail.com
|
9be85d5dfe83baa9a5eea8a0c156a22c4ae3bde8
|
93c1a49b80edea6ccf3f2054d30a7c7a8d0d3909
|
/Algorithms Techniques/1. Sorting and Selection/randomize-selection/randomSelect.cpp
|
afe8f69de18b65e692fbb237b5101f765a67abfb
|
[] |
no_license
|
KangboLu/Data-Structure-and-Algorithms
|
801cad87f4ccee7b8fa9ba84733b61e5aeba8228
|
1b8d7d943c6eddad417b831a3b038b950c62ed77
|
refs/heads/master
| 2020-03-21T14:28:33.565035
| 2018-11-12T23:09:19
| 2018-11-12T23:09:19
| 138,659,254
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,521
|
cpp
|
// c library
#include <ctime>
#include <cstdlib>
// c++ library
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// function to return random pivot
int randomPivot(vector<int>& array) {
return array[rand() % array.size()];
}
// function to return k-th smallest element
int randomSelect(vector<int>& S, int k) {
if (S.size() == 1)
return S[0];
// creating L, E, and G set
int pivot = randomPivot(S); // pick random pivot element from S
vector<int> L; // set of element < pivot
vector<int> E; // set of element == pivot
vector<int> G; // set of element > pivot
for (int i = 0; i < S.size(); i++) {
if (S[i] < pivot)
L.push_back(S[i]);
else if (S[i] == pivot)
E.push_back(S[i]);
else
G.push_back(S[i]);
}
// finding which set to recurvse on
if (k <= L.size()) // k-th smallest is in smaller set
return randomSelect(L, k);
else if (k <= L.size() + E.size()) // k-th smallest equal to the pivot set
return pivot;
else // k-th smallest is j-th in bigger set
return randomSelect(G, k - L.size() - E.size());
}
int main(void) {
// create input array and k value for selection
vector<int> S{1,2,3,4,5};
int k = 2;
// output input content
cout << "\nGiven Set S: ";
for (int i = 0; i < S.size(); i++)
cout << S[i] << " ";
cout << endl;
cout << "k = " << k << endl;
// run randomized selection algorithm
srand(time(0));
cout << "\nThe " << k << "-th smallest element is: " << randomSelect(S, k);
}
|
[
"redstonegranola@gmail.com"
] |
redstonegranola@gmail.com
|
38645fc901f07cba7add0fd0404909919c91e039
|
37596f223cf5115178a5a218fecf422bc545de78
|
/wrong code.c
|
740aac4c222b4be2d32f7b3df2c4edb1a3d9d2e0
|
[] |
no_license
|
fahim-ahmed-7861/competitive-programming
|
85cc4a61ce643d07446c36848b1f55789ee978f3
|
7c3e649756a426cceb588b5b119d40a5a94c80b4
|
refs/heads/master
| 2022-12-31T10:45:15.798645
| 2020-10-21T14:37:38
| 2020-10-21T14:37:38
| 306,051,853
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 119
|
c
|
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d %d",&a,&b);
c=a+b;
printf("%d",c);
return 0;
}
|
[
"fahimahmedshojib109@gmail.com"
] |
fahimahmedshojib109@gmail.com
|
882eafecde42835a87f9a78e1d4560b9e9679a17
|
702ae9de838718ac88c6a99461c8ffb668b9a9c3
|
/raytrace/Triangle.h
|
7eff35a763ed68f6e277dee55dc6be0d420ed260
|
[] |
no_license
|
wuhaozhe/ray_trace
|
9dbf66fc2adcd12f5bdb89fbc5c5b18e50ad3fb4
|
3a47ed81e8bfc787d456046022bbbd18de86ec58
|
refs/heads/master
| 2021-01-04T02:39:21.266958
| 2017-06-21T00:18:28
| 2017-06-21T00:18:28
| 87,383,443
| 1
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,177
|
h
|
#pragma once
#include "Object.h"
#include "Point.h"
class Triangle: public Object
{
private:
void init();
double det(vector3<double> a, vector3<double> b, vector3<double> c) //返回a, b, c为列的三阶行列式
{
double a1 = a.x * b.y * c.z;
double a2 = b.x * c.y * a.z;
double a3 = c.x * a.y * b.z;
double b1 = c.x * b.y * a.z;
double b2 = b.x * a.y * c.z;
double b3 = a.x * c.y * b.z;
return a1 + a2 + a3 - b1 - b2 - b3;
}
vector3<double> solve_equation(vector3<double> a, vector3<double> b, vector3<double> c, vector3<double> d); //求解非齐次三元一次方程组
vector3<double> normal_vector, E1, E2;
public:
vector3<double> vertex[3]; //三角形的三个顶点
Triangle();
Triangle(vector3<double> vertex1, vector3<double> vertex2, vector3<double> vertex3);
bool intersect(Ray input_ray, vector3<double> &intersect_point);
Color get_color_normalvec(vector3<double> target_pos, vector3<double> view_direction, Single_Light light, vector3<double> &in);
vector3<double> get_normalvec(vector3<double> target_pos, vector3<double> view_direction); //获取该点的法向量
~Triangle();
};
|
[
"506903514@qq.com"
] |
506903514@qq.com
|
4c3259ed61b5c8a6227add12b8cf7403a0b40cbc
|
a44f1eb99f0aad7eba90253c63240ec00407bc2e
|
/2D-Breakout/Health.cpp
|
0ee76ec12773d373454c91eea71d940395886d1e
|
[] |
no_license
|
GabrielJadderson/2D-Breakout
|
08d925c0c1bf8be7daff8926af883a3ae21cdbc1
|
de76fb27bf6278c0bbb9dfaebd7398ef15972b3e
|
refs/heads/master
| 2020-04-02T11:34:24.164924
| 2018-12-05T23:48:37
| 2018-12-05T23:48:37
| 154,396,070
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 88
|
cpp
|
#include "pch.h"
Health::Health(sf::Sprite s)
{
Sprite = s;
}
Health::~Health()
{
}
|
[
"mullie34@hotmail.com"
] |
mullie34@hotmail.com
|
c31716f7a97940160b867105cd3c1de478d5ed44
|
ba4db75b9d1f08c6334bf7b621783759cd3209c7
|
/src_main/materialsystem/stdshaders/fxctmp9_tmp/fillrate_ps11.inc
|
dfa2fa49fe90825396169b0edebf1285baff9c4a
|
[] |
no_license
|
equalent/source-2007
|
a27326c6eb1e63899e3b77da57f23b79637060c0
|
d07be8d02519ff5c902e1eb6430e028e1b302c8b
|
refs/heads/master
| 2020-03-28T22:46:44.606988
| 2017-03-27T18:05:57
| 2017-03-27T18:05:57
| 149,257,460
| 2
| 0
| null | 2018-09-18T08:52:10
| 2018-09-18T08:52:09
| null |
UTF-8
|
C++
| false
| false
| 740
|
inc
|
#include "shaderlib/cshader.h"
class fillrate_ps11_Static_Index
{
public:
fillrate_ps11_Static_Index( )
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderStaticTest_fillrate_ps11 0
class fillrate_ps11_Dynamic_Index
{
public:
fillrate_ps11_Dynamic_Index()
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderDynamicTest_fillrate_ps11 0
|
[
"sean@csnxs.uk"
] |
sean@csnxs.uk
|
16abad2d295cdb65ae4420ba69e8a8ac68765fca
|
4dad7078c907135214b38706fcfc555c485d6a25
|
/Estruturas de Dados e Agoritmos I - Lab/Arvores/Arvore.cpp
|
76edbac9e1e0f6c8f862e1eadb76b6f22ce11458
|
[
"MIT"
] |
permissive
|
GabrielNogueiraBR/Linguagem-C
|
5c679e9bf3d5ec497e4776f32bfcad30c27f5ee3
|
e12b405113b703b710ac96ae925ff919cab068f9
|
refs/heads/master
| 2023-01-04T14:55:17.460002
| 2020-10-28T02:56:37
| 2020-10-28T02:56:37
| 287,816,616
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,573
|
cpp
|
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define espaco 5
typedef struct no{
int info;
no *right;
no *left;
}no;
no* make_no(int num);
void aloca_no(no **p);
void insert_tree(no **p, int num);
bool find_number_tree(int num, no *p);
int profundidade_tree(no *p);
int soma_folhas(no *p);
void desenha_arvore_horiz(no *arvore, int depth, char *path, int direita);
void draw_arvore_hor(no *arvore);
main(){
//declarando a variavel que vai ser a cabeca da arvore
no *tree = NULL;
int num, op;
bool find_number;
do{
system("cls");
printf("\n[1] Adicionar um numero positivo na arvore");
printf("\n[2] Buscar um numero na arvore");
printf("\n[3] Mostar arvore");
printf("\n[4] Profundidade da arvore");
printf("\n[5] Total de folhas da arvore");
printf("\n[6] Sair");
printf("\nDigite a opcao desejada: ");
scanf("%i", &op);
switch(op){
case 1:
do{
system("cls");
printf("\nDigite um numero a ser inserido na arvore: ");
scanf("%i", &num);
fflush(stdin);
}while(num < 0);
if(num != -1){
insert_tree(&tree, num);
printf("\nO numero %i foi inserido com sucesso.\n", num);
system("pause");
}
break;
case 2:
do{
system("cls");
printf("\nDigite um numero a ser buscado na arvore: ");
scanf("%i", &num);
fflush(stdin);
}while(num < 0);
find_number = find_number_tree(num, tree);
if(find_number == true)
printf("\nO numero %i foi encontrado na arvore.\n", num);
else
printf("\nO numero %i nao foi encontrado na arvore.\n", num);
system("pause");
break;
case 3:
system("cls");
draw_arvore_hor(tree);
printf("\n\n");
system("pause");
break;
case 4:
system("cls");
printf("\nA profundidade da arvore e %i.\n", profundidade_tree(tree));
system("pause");
break;
case 5:
system("cls");
printf("\nA quantidade de folhas da arvore e %i.\n", soma_folhas(tree));
system("pause");
break;
break;
case 6:
exit(1);
default:
break;
}
}while(num > -1);
system("cls");
}
no* make_no(int num){
no *p;
aloca_no(&p);
p->info = num;
p->left = NULL;
p->right = NULL;
return (p);
}
void aloca_no(no **p){
if( (*p = (no*) malloc(sizeof(no))) == NULL )
exit(1);
}
//recursividade
void insert_tree(no **p, int num){
if( (*p) == NULL )
(*p) = make_no(num);
else if(num > (*p)->info)
insert_tree(&(*p)->right, num);
else
insert_tree(&(*p)->left, num);
}
bool find_number_tree(int num, no *p){
if( p == NULL)
return false;
else if ( p->info == num )
return true;
else if( num > p->info )
find_number_tree(num, p->right);
else
find_number_tree(num, p->left);
}
//recursividade
int profundidade_tree(no *p){
//profundidade da esquerda
int prof_left;
//profundidade da direita
int prof_right;
if( p == NULL){
return (0);
}
else{
//calcular a profundidade da esquerda
prof_left = profundidade_tree(p->left);
//calcular a profundidade da direita
prof_right = profundidade_tree(p->right);
if(prof_left > prof_right){
return (1 + prof_left);
}
else
return (1 + prof_right);
}
}
//recursividade
int soma_folhas(no *p){
int folhas_direita;
int folhas_esquerda;
if( p == NULL){
return (0);
}
else if( p->left == NULL && p->right == NULL )
return (1);
else{
folhas_direita = soma_folhas(p->right);
folhas_esquerda = soma_folhas(p->left);
return (folhas_direita + folhas_esquerda);
}
}
//funcao montada pelo professor para exibir uma arvore
void desenha_arvore_horiz(no *arvore, int depth, char *path, int direita)
{
if (arvore== NULL)
return;
depth++;
desenha_arvore_horiz(arvore->right, depth, path, 1);
path[depth-2] = 0;
if(direita)
path[depth-2] = 1;
if(arvore->left)
path[depth-1] = 1;
printf("\n");
for(int i=0; i<depth-1; i++)
{
if(i == depth-2)
printf("+");
else if(path[i])
printf("|");
else
printf(" ");
for(int j=1; j< espaco; j++)
if(i < depth-2)
printf(" ");
else
printf("-");
}
printf("%d\n", arvore->info);
for(int i=0; i<depth; i++)
{
if(path[i])
printf("|");
else
printf(" ");
for(int j=1; j< espaco; j++)
printf(" ");
}
desenha_arvore_horiz(arvore->left, depth, path, 0);
}
void draw_arvore_hor(no *arvore)
{
char path[255] = {};
desenha_arvore_horiz(arvore, 0, path, 0);
}
|
[
"gabrielnoog7@gmail.com"
] |
gabrielnoog7@gmail.com
|
443bdc86579704f41a2e46f239021a7ec9714ead
|
8eb79b6ec28abbf8c6570bb4f2f2568cfae6432c
|
/tensorflow/compiler/xla/service/gpu/gpu_executable.cc
|
e50da6f728d4fd6829691022ce55ec3fcf5627df
|
[
"Apache-2.0"
] |
permissive
|
FullStackHan/tensorflow
|
7d094049a614e317b5a4b46ae0d3b2c001532166
|
8ec93550847eaf9289ff33403bb19fa78c097334
|
refs/heads/master
| 2020-06-06T08:57:05.737140
| 2019-06-19T08:30:29
| 2019-06-19T08:35:06
| 192,692,426
| 1
| 0
| null | 2019-06-19T08:35:29
| 2019-06-19T08:35:28
| null |
UTF-8
|
C++
| false
| false
| 16,500
|
cc
|
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/gpu/gpu_executable.h"
#include <set>
#include <utility>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/memory/memory.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/gpu/buffer_allocations.h"
#include "tensorflow/compiler/xla/service/gpu/gpu_debug_info_manager.h"
#include "tensorflow/compiler/xla/service/gpu/hlo_execution_profiler.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
#include "tensorflow/compiler/xla/service/llvm_ir/buffer_assignment_util.h"
#include "tensorflow/compiler/xla/service/logical_buffer.h"
#include "tensorflow/compiler/xla/service/shaped_buffer.h"
#include "tensorflow/compiler/xla/service/transfer_manager.h"
#include "tensorflow/compiler/xla/shape_tree.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/tracing.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/profiler/lib/traceme.h"
namespace xla {
namespace gpu {
namespace {
using tensorflow::tracing::ScopedAnnotation;
} // namespace
// Implementation note: HLO profiling is always enabled for GPU executables,
// since we can use timers around thunks.
GpuExecutable::GpuExecutable(
const string& ptx, const std::vector<uint8>& cubin,
std::pair<int, int> compute_capability,
std::unique_ptr<const ThunkSchedule> thunk_schedule,
std::shared_ptr<HloModule> hlo_module,
std::shared_ptr<const BufferAssignment> assignment,
std::unique_ptr<HloProfilePrinterData> hlo_profile_printer_data,
std::unique_ptr<HloProfileIndexMap> hlo_profile_index_map)
: Executable(std::move(hlo_module), std::move(hlo_profile_printer_data),
std::move(hlo_profile_index_map)),
ptx_(ptx),
cubin_(cubin),
compute_capability_(compute_capability),
thunk_schedule_(std::move(thunk_schedule)),
assignment_(std::move(assignment)) {
CHECK(has_module() && assignment_);
GpuDebugInfoManager::Get()->RegisterModule(module().name(), shared_module(),
assignment_);
ComputeThunkAnnotations();
}
GpuExecutable::~GpuExecutable() {
CHECK(has_module() && assignment_);
GpuDebugInfoManager::Get()->UnregisterModule(module().name(), shared_module(),
assignment_);
}
void GpuExecutable::ComputeThunkAnnotations() {
CanonicalNameMap canonical_name_map;
for (Thunk* thunk : thunk_schedule_->TotalOrder()) {
const HloInstruction* hlo = thunk->hlo_instruction();
CHECK(hlo);
thunk_annotations_[thunk] = absl::StrFormat(
"%s:#tf_op=%s,hlo_op=%s,hlo_module=%s#",
hlo->ToStringWithCanonicalNameMap(HloPrintOptions::Canonical(),
&canonical_name_map),
hlo->metadata().op_name(), hlo->name(), hlo->GetModule()->name());
}
}
Status GpuExecutable::ExecuteThunks(
const ServiceExecutableRunOptions* run_options,
const BufferAllocations& buffer_allocations, bool block_host_until_done,
HloExecutionProfile* hlo_execution_profile) {
GpuDebugInfoManager::Get()->OnModuleStart(module().name());
auto cleanup = MakeCleanup(
[&]() { GpuDebugInfoManager::Get()->OnModuleStop(module().name()); });
se::Stream* main_stream = run_options->stream();
se::StreamExecutor* executor = main_stream->parent();
std::pair<int, int> stream_compute_compatibility;
executor->GetDeviceDescription().cuda_compute_capability(
&stream_compute_compatibility.first,
&stream_compute_compatibility.second);
TF_RET_CHECK(stream_compute_compatibility == compute_capability_)
<< "Compute capability mismatch; expected {" << compute_capability_.first
<< ", " << compute_capability_.second << "}, but was {"
<< stream_compute_compatibility.first << ", "
<< stream_compute_compatibility.second << "}";
bool do_profile = hlo_execution_profile != nullptr;
if (do_profile) {
LOG(WARNING) << "PROFILING: profiling is enabled";
}
// Stream 0 indicates `main_stream` and substreams start from stream 1.
std::vector<StreamPool::Ptr> sub_streams;
sub_streams.reserve(thunk_schedule_->StreamCount() - 1);
while (sub_streams.size() + 1 < thunk_schedule_->StreamCount()) {
sub_streams.emplace_back();
TF_ASSIGN_OR_RETURN(sub_streams.back(),
run_options->BorrowStream(executor->device_ordinal()));
}
HloExecutionProfiler profiler(do_profile, hlo_execution_profile, main_stream,
sub_streams, hlo_module_->entry_computation());
uint64 start_micros = tensorflow::Env::Default()->NowMicros();
tensorflow::profiler::TraceMe hlo_module_activity(
[&] { return absl::StrCat(hlo_module_->name(), ":XLA GPU module"); },
tensorflow::profiler::TraceMeLevel::kInfo);
std::map<const Thunk*, std::unique_ptr<se::Event>> thunk_to_finish_event;
bool scoped_annotation_enabled = ScopedAnnotation::IsEnabled();
for (Thunk* thunk : thunk_schedule_->TotalOrder()) {
// Annotate execution of this op if tracing was enabled when we started
// running this module. If tracing is enabled *while* we're running the
// module, we won't get any data, but that's probably an OK trade-off.
absl::optional<ScopedAnnotation> op_annotation;
CHECK(thunk->hlo_instruction());
if (scoped_annotation_enabled) {
op_annotation.emplace(FindOrDie(thunk_annotations_, thunk));
}
TF_RETURN_IF_ERROR(thunk->Initialize(*this, executor));
int32 stream_no =
thunk_schedule_->StreamNumberForHlo(*thunk->hlo_instruction());
se::Stream* stream =
(stream_no == 0 ? main_stream : sub_streams[stream_no - 1].get());
for (const Thunk* dependency : thunk_schedule_->DependsOn(thunk)) {
stream->ThenWaitFor(FindOrDie(thunk_to_finish_event, dependency).get());
}
VLOG(2) << "Executing the thunk for "
<< thunk->hlo_instruction()->ToString() << " on stream "
<< stream_no;
Thunk::ExecuteParams thunk_params{
&buffer_allocations, stream, run_options->run_options().run_id(),
&profiler, run_options->run_options().device_assignment()};
TF_RETURN_IF_ERROR(thunk->ExecuteOnStream(thunk_params));
if (thunk_schedule_->Depended(thunk)) {
auto finish_event = absl::make_unique<se::Event>(main_stream->parent());
finish_event->Init();
stream->ThenRecordEvent(finish_event.get());
thunk_to_finish_event[thunk] = std::move(finish_event);
}
}
main_stream->ThenWaitFor(&sub_streams);
// Make sure kernels are completed before deallocating temporary buffers.
// TODO(b/30100571): we could potentially postpone deallocating the temp
// buffers until a different computation is executed.
if (block_host_until_done) {
Status block_status = main_stream->BlockHostUntilDone();
if (!block_status.ok()) {
return InternalError(
"Failed to complete all kernels launched on stream %p: %s",
main_stream, block_status.error_message());
}
}
profiler.FinishExecution();
uint64 end_micros = tensorflow::Env::Default()->NowMicros();
{
tensorflow::mutex_lock lock(mutex_);
const double nanoseconds = (end_micros - start_micros) * 1000.0;
execution_profile_.set_compute_time_ns(std::max(nanoseconds, 1.0));
// If hlo profiling was disabled then the cycle count is left empty.
if (do_profile) {
execution_profile_.set_compute_cycle_count(
hlo_execution_profile->total_cycles_executed(
*module().entry_computation()));
}
}
return Status::OK();
}
StatusOr<const GpuExecutable::BufferAllocToDeviceMemoryMap*>
GpuExecutable::ResolveConstantGlobals(se::StreamExecutor* executor) {
tensorflow::mutex_lock lock(module_handle_mutex_);
auto it = module_globals_.find(executor);
if (it != module_globals_.end()) {
return &it->second;
}
se::MultiModuleLoaderSpec module_spec;
if (!cubin().empty()) {
module_spec.AddCudaCubinInMemory(cubin());
}
module_spec.AddCudaPtxInMemory(ptx().c_str());
absl::flat_hash_map<int64, se::DeviceMemoryBase> globals;
se::ModuleHandle module_handle;
executor->LoadModule(module_spec, &module_handle);
for (BufferAllocation::Index i = 0; i < assignment_->Allocations().size();
++i) {
const BufferAllocation& allocation = assignment_->GetAllocation(i);
if (allocation.is_constant()) {
TF_ASSIGN_OR_RETURN(
se::DeviceMemoryBase global,
executor->GetUntypedSymbol(
llvm_ir::ConstantBufferAllocationToGlobalName(allocation),
module_handle));
VLOG(3) << "Resolved global "
<< llvm_ir::ConstantBufferAllocationToGlobalName(allocation)
<< " to " << global.opaque();
InsertOrDie(&globals, i, global);
const Literal& literal =
llvm_ir::LiteralForConstantAllocation(allocation);
CHECK(literal.shape().IsArray());
if (!ShouldEmitLiteralInLlvmIr(literal)) {
VLOG(3) << "H2D memcpy for constant with shape "
<< ShapeUtil::HumanString(literal.shape());
TF_RETURN_IF_ERROR(executor->SynchronousMemcpyH2D(
literal.untyped_data(), allocation.size(), &global));
}
}
}
module_handles_.emplace(executor,
se::ScopedModuleHandle(executor, module_handle));
return &module_globals_.emplace(executor, std::move(globals)).first->second;
}
StatusOr<ScopedShapedBuffer> GpuExecutable::Execute(
const ServiceExecutableRunOptions* run_options,
absl::Span<const ShapedBuffer* const> arguments,
HloExecutionProfile* hlo_execution_profile, bool block_host_until_done) {
se::DeviceMemoryAllocator* memory_allocator = run_options->allocator();
if (GetRootPointsToSet().IsAmbiguous()) {
return Unimplemented("Points-to set of root instruction is ambiguous");
}
BufferAllocations::Builder buffer_allocations_builder;
se::StreamExecutor* executor = run_options->stream()->parent();
TF_ASSIGN_OR_RETURN(auto* const globals, ResolveConstantGlobals(executor));
for (BufferAllocation::Index i = 0; i < assignment_->Allocations().size();
++i) {
const BufferAllocation& allocation = assignment_->GetAllocation(i);
if (allocation.is_entry_computation_parameter()) {
auto param_no = allocation.parameter_number();
se::DeviceMemoryBase buffer =
arguments[param_no]->buffer(allocation.param_shape_index());
// All top-level buffers and sub-buffers must have an explicit, non-null
// pointer, except for zero-sized buffers, which may be null.
if (buffer.is_null() && buffer.size() > 0) {
return FailedPrecondition(
"Cannot run XLA computation because pointer to (sub-)buffer at "
"index %s of parameter %d was null. All pointers to (sub-)buffers "
"must not be null, unless the (sub-)buffer has zero elements.",
allocation.param_shape_index().ToString(), param_no);
}
buffer_allocations_builder.RegisterBuffer(i, buffer);
}
if (allocation.is_constant()) {
buffer_allocations_builder.RegisterBuffer(i, FindOrDie(*globals, i));
}
}
TF_ASSIGN_OR_RETURN(
auto buffer_allocations,
buffer_allocations_builder.Build(
assignment_.get(), executor->device_ordinal(), memory_allocator));
TF_RETURN_IF_ERROR(ExecuteThunks(run_options, *buffer_allocations,
block_host_until_done,
hlo_execution_profile));
HloInstruction* root = hlo_module_->entry_computation()->root_instruction();
auto device_ordinal = executor->device_ordinal();
ScopedShapedBuffer shaped_buffer(root->shape(), root->shape(),
memory_allocator, device_ordinal);
// Copy DeviceMemoryBase values which contain the array(s) of the result into
// the respective location in ShapedBuffer.
std::set<se::DeviceMemoryBase> buffers_in_result;
TF_RETURN_IF_ERROR(shaped_buffer.buffers().ForEachMutableElementWithStatus(
[&buffer_allocations, &buffers_in_result, this](
const ShapeIndex& index, se::DeviceMemoryBase* device_memory) {
const auto& sources = this->GetRootPointsToSet().element(index);
// The points-to set is unambiguous so the set should be a
// singleton. That is, we know exactly which instruction
// produced the array at this element.
CHECK_EQ(1, sources.size());
auto src_hlo = sources[0]->instruction();
VLOG(4) << "Looking at: " << sources[0];
// The source instruction should have a non-parameter buffer
// assigned.
TF_ASSIGN_OR_RETURN(
const BufferAllocation::Slice slice,
this->assignment_->GetUniqueSlice(src_hlo, sources[0]->index()));
se::DeviceMemoryBase src_base =
buffer_allocations->GetDeviceAddress(slice.index());
CHECK(!src_base.is_null() || src_base.size() == 0);
if (!slice.allocation()->is_entry_computation_parameter()) {
// If the buffer coming out of the result is from a parameter, it
// means the caller aliased some parameter buffer to an output one
// (via the HloInputOutputAliasConfig API). If that is the case, the
// caller will receive a partially complete scoped shaped buffer,
// which they will have to fill up on return.
// Unfortunately the interface to the execute APIs are ShapedBuffer
// pointer based, which assumes caller ownership, and hence a buffer
// coming from there cannot be part of the new ScopedShapedBuffer we
// create for the result (which assumes ownership).
*device_memory = src_base;
} else {
const HloInputOutputAliasConfig& input_output_alias =
module().input_output_alias_config();
auto output_alias = input_output_alias.GetAliasedOutput(
slice.allocation()->parameter_number(),
slice.allocation()->param_shape_index());
CHECK(output_alias)
<< "Ouput buffer is coming from parameter "
<< slice.allocation()->parameter_number() << " at index "
<< slice.allocation()->param_shape_index()
<< ", but no alias exists";
CHECK_EQ(*output_alias, index);
}
buffers_in_result.insert(src_base);
return Status::OK();
}));
TF_RETURN_IF_ERROR(buffer_allocations->TearDown(buffers_in_result));
return std::move(shaped_buffer);
}
StatusOr<ScopedShapedBuffer> GpuExecutable::ExecuteOnStream(
const ServiceExecutableRunOptions* run_options,
absl::Span<const ShapedBuffer* const> arguments,
HloExecutionProfile* hlo_execution_profile) {
return Execute(run_options, arguments, hlo_execution_profile,
/*block_host_until_done=*/true);
}
StatusOr<ScopedShapedBuffer> GpuExecutable::ExecuteAsyncOnStream(
const ServiceExecutableRunOptions* run_options,
absl::Span<const ShapedBuffer* const> arguments) {
se::DeviceMemoryAllocator* memory_allocator = run_options->allocator();
// Force synchronous execution if the allocator requires it.
bool block_host_until_done =
!memory_allocator->AllowsAsynchronousDeallocation();
return Execute(run_options, arguments, nullptr, block_host_until_done);
}
const PointsToSet& GpuExecutable::GetRootPointsToSet() const {
return assignment_->points_to_analysis().GetPointsToSet(
module().entry_computation()->root_instruction());
}
} // namespace gpu
} // namespace xla
|
[
"gardener@tensorflow.org"
] |
gardener@tensorflow.org
|
847c6895d0f8dad6873b4270cf495a2ca4d6f0b0
|
6a9c422f963e1fd79f6ceda23a6e147565b43624
|
/LEETCODE-766.Toeplitz Matrix.cpp
|
34f35cde69cef2119ce41a0f3f31e9952caa75aa
|
[] |
no_license
|
sidhantchadha/LEETCODE
|
6605d07b30c06d47d81b0d6d84673c31ea0cc9e1
|
d67e210d396a015b2dd6980ffd2a82b9e0cf2d73
|
refs/heads/master
| 2020-03-07T01:37:28.592703
| 2018-06-22T20:32:11
| 2018-06-22T20:32:11
| 127,188,143
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 641
|
cpp
|
//============================================================================
// Name : Toeplitz.cpp
// Author : Sidhant Chadha
// Version :
// Copyright :
// Description : Toeplitz Matrix in C++, Ansi-style
//============================================================================
class Solution {
public:
bool isToeplitzMatrix(vector<vector<int>>& matrix) {
int m = matrix.size(), n = matrix[0].size();
for (int i = 1; i < m; i++)
for (int j = 1; j < n; j++)
if (matrix[i][j] != matrix[i - 1][j - 1])
return false;
return true;
}
};
|
[
"sidhantchadha@live.com"
] |
sidhantchadha@live.com
|
e33d887b1e1f163374b7edcacf20eeba59033ded
|
573b7f2b79b6fb8b21b40985f7639bc003b60f7e
|
/SDK/BP_Vehiclewheel_BRDM2_rear_classes.h
|
2e2da6ea02a1e8648c3978b4881cecf55320ad3b
|
[] |
no_license
|
AlexzDK/SquadSDK2021
|
8d4c29486922fed3ba8451680d823a04a7b7fc44
|
cdce732ad4713b6d7f668f8b9c39e160035efb34
|
refs/heads/main
| 2023-02-21T02:52:15.634663
| 2021-01-23T23:28:57
| 2021-01-23T23:28:57
| 332,328,796
| 4
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 761
|
h
|
#pragma once
// Name: Squad, Version: 13-01-2021
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
/*!!HELPER_DEF!!*/
/*!!DEFINE!!*/
namespace UFT
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass BP_Vehiclewheel_BRDM2_rear.BP_Vehiclewheel_BRDM2_rear_C
// 0x0000 (FullSize[0x00F8] - InheritedSize[0x00F8])
class UBP_Vehiclewheel_BRDM2_rear_C : public USQVehicleWheel_Rear
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_Vehiclewheel_BRDM2_rear.BP_Vehiclewheel_BRDM2_rear_C");
return ptr;
}
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
[
"39485681+AlexzDK@users.noreply.github.com"
] |
39485681+AlexzDK@users.noreply.github.com
|
fd2e0813c784a5c9d4609310c511cfe04d9d8bea
|
0c260a8689d62a273c155d2a7e895eb26d8a0a30
|
/Pathfinder.h
|
7c247cd51796e37edc41390b7c9ad200ba854b94
|
[] |
no_license
|
IgnacioAlmeida/Recursion---3D-Maze
|
0e319010865c750a88e7d720b3e3bac08691b797
|
4c90af651dc2f4f0f460cb4217f573613f0609dc
|
refs/heads/master
| 2023-03-03T21:11:03.847670
| 2021-02-11T02:51:43
| 2021-02-11T02:51:43
| 336,704,552
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 761
|
h
|
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <fstream>
#include <time.h>
#include <algorithm>
#include "PathfinderInterface.h"
using namespace std;
const int ROW_SIZE = 5;
const int COL_SIZE = 5;
const int FLOOR_SIZE = 5;
const int BACKGROUND = 1;
const int PATH = 3;
const int TEMPORARY = 2;
class Pathfinder : public PathfinderInterface {
public:
Pathfinder();
// ~Pathfinder() {};
string toString() const;
void createRandomMaze();
bool importMaze(string file_name);
vector<string> solveMaze();
protected:
bool find_maze_path(int grid[ROW_SIZE][COL_SIZE][FLOOR_SIZE], int row, int col, int floor);
vector<string> solution;
int maze_grid[ROW_SIZE][COL_SIZE][FLOOR_SIZE]; // Holds values
};
|
[
"ignacio.rdea@gmail.com"
] |
ignacio.rdea@gmail.com
|
55b914965ce3eada080d86475d8224ecb1765427
|
5629bfeac0508fc0a33be5e5ccc7ae1946e87abd
|
/src/qt/paymentserver.cpp
|
bf9700a51b6b9fd32ef466686a58f651fc5fb154
|
[
"MIT"
] |
permissive
|
btcrcoin/btcrcoin
|
ce6bbcbe8836d3d0817def7602b489b9aa8b8538
|
e49a490165fb1e45113b5527d0f1a1f8f0001eb6
|
refs/heads/master
| 2021-05-13T19:53:57.619320
| 2018-01-31T13:23:29
| 2018-01-31T13:23:29
| 116,625,632
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,505
|
cpp
|
// Copyright (c) 2011-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <QApplication>
#include "paymentserver.h"
#include "guiconstants.h"
#include "ui_interface.h"
#include "util.h"
#include <QByteArray>
#include <QDataStream>
#include <QDebug>
#include <QFileOpenEvent>
#include <QHash>
#include <QLocalServer>
#include <QLocalSocket>
#include <QStringList>
#if QT_VERSION < 0x050000
#include <QUrl>
#endif
using namespace boost;
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds
const QString BITCOIN_IPC_PREFIX("btcrcoin:");
//
// Create a name that is unique for:
// testnet / non-testnet
// data directory
//
static QString ipcServerName()
{
QString name("BitcoinQt");
// Append a simple hash of the datadir
// Note that GetDataDir(true) returns a different path
// for -testnet versus main net
QString ddir(GetDataDir(true).string().c_str());
name.append(QString::number(qHash(ddir)));
return name;
}
//
// This stores payment requests received before
// the main GUI window is up and ready to ask the user
// to send payment.
//
static QStringList savedPaymentRequests;
//
// Sending to the server is done synchronously, at startup.
// If the server isn't already running, startup continues,
// and the items in savedPaymentRequest will be handled
// when uiReady() is called.
//
bool PaymentServer::ipcSendCommandLine()
{
bool fResult = false;
const QStringList& args = qApp->arguments();
for (int i = 1; i < args.size(); i++)
{
if (!args[i].startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive))
continue;
savedPaymentRequests.append(args[i]);
}
foreach (const QString& arg, savedPaymentRequests)
{
QLocalSocket* socket = new QLocalSocket();
socket->connectToServer(ipcServerName(), QIODevice::WriteOnly);
if (!socket->waitForConnected(BITCOIN_IPC_CONNECT_TIMEOUT))
return false;
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_0);
out << arg;
out.device()->seek(0);
socket->write(block);
socket->flush();
socket->waitForBytesWritten(BITCOIN_IPC_CONNECT_TIMEOUT);
socket->disconnectFromServer();
delete socket;
fResult = true;
}
return fResult;
}
PaymentServer::PaymentServer(QApplication* parent) : QObject(parent), saveURIs(true)
{
// Install global event filter to catch QFileOpenEvents on the mac (sent when you click bitcoin: links)
parent->installEventFilter(this);
QString name = ipcServerName();
// Clean up old socket leftover from a crash:
QLocalServer::removeServer(name);
uriServer = new QLocalServer(this);
if (!uriServer->listen(name))
qDebug() << tr("Cannot start btcrcoin: click-to-pay handler");
else
connect(uriServer, SIGNAL(newConnection()), this, SLOT(handleURIConnection()));
}
bool PaymentServer::eventFilter(QObject *object, QEvent *event)
{
// clicking on bitcoin: URLs creates FileOpen events on the Mac:
if (event->type() == QEvent::FileOpen)
{
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
if (!fileEvent->url().isEmpty())
{
if (saveURIs) // Before main window is ready:
savedPaymentRequests.append(fileEvent->url().toString());
else
emit receivedURI(fileEvent->url().toString());
return true;
}
}
return false;
}
void PaymentServer::uiReady()
{
saveURIs = false;
foreach (const QString& s, savedPaymentRequests)
emit receivedURI(s);
savedPaymentRequests.clear();
}
void PaymentServer::handleURIConnection()
{
QLocalSocket *clientConnection = uriServer->nextPendingConnection();
while (clientConnection->bytesAvailable() < (int)sizeof(quint32))
clientConnection->waitForReadyRead();
connect(clientConnection, SIGNAL(disconnected()),
clientConnection, SLOT(deleteLater()));
QDataStream in(clientConnection);
in.setVersion(QDataStream::Qt_4_0);
if (clientConnection->bytesAvailable() < (int)sizeof(quint16)) {
return;
}
QString message;
in >> message;
if (saveURIs)
savedPaymentRequests.append(message);
else
emit receivedURI(message);
}
|
[
"crcashfc@gmail.com"
] |
crcashfc@gmail.com
|
b8b23f55bfcecaab5709d5c5037832c275259165
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/ui/display/test/display_manager_test_api.cc
|
733201595b3a2b2ed9f5ece4bcf1b14f8523d3d6
|
[
"BSD-3-Clause"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C++
| false
| false
| 8,255
|
cc
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/display/test/display_manager_test_api.h"
#include <cstdarg>
#include <vector>
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_split.h"
#include "build/chromeos_buildflags.h"
#include "ui/display/display_layout_builder.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/manager/managed_display_info.h"
#include "ui/display/manager/util/display_manager_util.h"
#include "ui/display/screen.h"
#include "ui/display/util/display_util.h"
namespace display {
namespace test {
namespace {
// Indicates the default maximum of displays that chrome device can support.
constexpr size_t kDefaultMaxSupportDisplayTest = 10;
DisplayInfoList CreateDisplayInfoListFromString(
const std::string specs,
DisplayManager* display_manager) {
DisplayInfoList display_info_list;
std::vector<std::string> parts = base::SplitString(
specs, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
size_t index = 0;
Displays list = display_manager->IsInUnifiedMode()
? display_manager->software_mirroring_display_list()
: display_manager->active_display_list();
for (std::vector<std::string>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter, ++index) {
int64_t id = (index < list.size()) ? list[index].id() : kInvalidDisplayId;
display_info_list.push_back(
ManagedDisplayInfo::CreateFromSpecWithID(*iter, id));
}
return display_info_list;
}
// Gets the display |mode| for |resolution|. Returns false if no display
// mode matches the resolution, or the display is an internal display.
bool GetDisplayModeForResolution(const ManagedDisplayInfo& info,
const gfx::Size& resolution,
ManagedDisplayMode* mode) {
if (IsInternalDisplayId(info.id()))
return false;
const ManagedDisplayInfo::ManagedDisplayModeList& modes =
info.display_modes();
DCHECK_NE(0u, modes.size());
auto iter = base::ranges::find(modes, resolution, &ManagedDisplayMode::size);
if (iter == modes.end()) {
DLOG(WARNING) << "Unsupported resolution was requested:"
<< resolution.ToString();
return false;
}
*mode = *iter;
return true;
}
} // namespace
size_t DisplayManagerTestApi::maximum_support_display_ =
kDefaultMaxSupportDisplayTest;
DisplayManagerTestApi::DisplayManagerTestApi(DisplayManager* display_manager)
: display_manager_(display_manager) {
DCHECK(display_manager);
}
DisplayManagerTestApi::~DisplayManagerTestApi() {}
void DisplayManagerTestApi::ResetMaximumDisplay() {
maximum_support_display_ = kDefaultMaxSupportDisplayTest;
}
void DisplayManagerTestApi::UpdateDisplay(const std::string& display_specs) {
DisplayInfoList display_info_list =
CreateDisplayInfoListFromString(display_specs, display_manager_);
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (display_info_list.size() > maximum_support_display_) {
display_manager_->configurator()->has_unassociated_display_ = true;
while (display_info_list.size() > maximum_support_display_)
display_info_list.pop_back();
} else {
display_manager_->configurator()->has_unassociated_display_ = false;
}
#endif
bool is_host_origin_set = false;
for (const ManagedDisplayInfo& display_info : display_info_list) {
if (display_info.bounds_in_native().origin() != gfx::Point(0, 0)) {
is_host_origin_set = true;
break;
}
}
// Start from (1,1) so that windows won't overlap with native mouse cursor.
// See |AshTestBase::SetUp()|.
int next_y = 1;
for (auto& info : display_info_list) {
// On non-testing environment, when a secondary display is connected, a new
// native (i.e. X) window for the display is always created below the
// previous one for GPU performance reasons. Try to emulate the behavior
// unless host origins are explicitly set.
if (!is_host_origin_set) {
gfx::Rect bounds(info.bounds_in_native().size());
bounds.set_x(1);
bounds.set_y(next_y);
next_y += bounds.height();
info.SetBounds(bounds);
}
// Overscan and native resolution are excluded for now as they require
// special handing (has_overscan flag. resolution change makes sense
// only on external).
display_manager_->RegisterDisplayProperty(
info.id(), info.GetRotation(Display::RotationSource::USER),
/*overscan_insets=*/nullptr,
/*resolution_in_pixels=*/gfx::Size(), info.device_scale_factor(),
info.zoom_factor(), info.refresh_rate(), info.is_interlaced(),
info.variable_refresh_rate_state(), info.vsync_rate_min());
}
display_manager_->OnNativeDisplaysChanged(display_info_list);
display_manager_->UpdateInternalManagedDisplayModeListForTest();
display_manager_->RunPendingTasksForTest();
}
int64_t DisplayManagerTestApi::SetFirstDisplayAsInternalDisplay() {
const Display& internal = display_manager_->active_display_list_[0];
SetInternalDisplayIds({internal.id()});
return Display::InternalDisplayId();
}
void DisplayManagerTestApi::SetInternalDisplayId(int64_t id) {
SetInternalDisplayIds({id});
display_manager_->UpdateInternalManagedDisplayModeListForTest();
}
void DisplayManagerTestApi::DisableChangeDisplayUponHostResize() {
display_manager_->set_change_display_upon_host_resize(false);
}
const ManagedDisplayInfo& DisplayManagerTestApi::GetInternalManagedDisplayInfo(
int64_t display_id) {
return display_manager_->display_info_[display_id];
}
void DisplayManagerTestApi::SetTouchSupport(
int64_t display_id,
Display::TouchSupport touch_support) {
display_manager_->FindDisplayForId(display_id)
->set_touch_support(touch_support);
}
const Display& DisplayManagerTestApi::GetSecondaryDisplay() const {
CHECK_GE(display_manager_->GetNumDisplays(), 2U);
const int64_t primary_display_id =
Screen::GetScreen()->GetPrimaryDisplay().id();
auto primary_display_iter = base::ranges::find(
display_manager_->active_display_list_, primary_display_id, &Display::id);
DCHECK(primary_display_iter != display_manager_->active_display_list_.end());
++primary_display_iter;
// If we've reach the end of |active_display_list_|, wrap back around to the
// front.
if (primary_display_iter == display_manager_->active_display_list_.end())
return *display_manager_->active_display_list_.begin();
return *primary_display_iter;
}
ScopedSetInternalDisplayId::ScopedSetInternalDisplayId(
DisplayManager* display_manager,
int64_t id) {
DisplayManagerTestApi(display_manager).SetInternalDisplayId(id);
}
ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() {
SetInternalDisplayIds({});
}
bool SetDisplayResolution(DisplayManager* display_manager,
int64_t display_id,
const gfx::Size& resolution) {
const ManagedDisplayInfo& info = display_manager->GetDisplayInfo(display_id);
ManagedDisplayMode mode;
if (!GetDisplayModeForResolution(info, resolution, &mode))
return false;
return display_manager->SetDisplayMode(display_id, mode);
}
std::unique_ptr<DisplayLayout> CreateDisplayLayout(
DisplayManager* display_manager,
DisplayPlacement::Position position,
int offset) {
DisplayLayoutBuilder builder(Screen::GetScreen()->GetPrimaryDisplay().id());
builder.SetSecondaryPlacement(
DisplayManagerTestApi(display_manager).GetSecondaryDisplay().id(),
position, offset);
return builder.Build();
}
DisplayIdList CreateDisplayIdList2(int64_t id1, int64_t id2) {
DisplayIdList list;
list.push_back(id1);
list.push_back(id2);
SortDisplayIdList(&list);
return list;
}
DisplayIdList CreateDisplayIdListN(int64_t start_id, size_t count) {
DisplayIdList list;
list.push_back(start_id);
int64_t id = start_id;
size_t N = count;
while (count-- > 1) {
id = display::GetNextSynthesizedDisplayId(id);
list.push_back(id);
}
SortDisplayIdList(&list);
DCHECK_EQ(N, list.size());
return list;
}
} // namespace test
} // namespace display
|
[
"jengelh@inai.de"
] |
jengelh@inai.de
|
1e2a079abe4b6a3a3445056a8006cebfa448599e
|
2a7e77565c33e6b5d92ce6702b4a5fd96f80d7d0
|
/fuzzedpackages/roben/src/BVCUtilities.cpp
|
5b57a9cafcf7258045f98c38fbdb2f283a21b34d
|
[] |
no_license
|
akhikolla/testpackages
|
62ccaeed866e2194652b65e7360987b3b20df7e7
|
01259c3543febc89955ea5b79f3a08d3afe57e95
|
refs/heads/master
| 2023-02-18T03:50:28.288006
| 2021-01-18T13:23:32
| 2021-01-18T13:23:32
| 329,981,898
| 7
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,050
|
cpp
|
#include<RcppArmadillo.h>
#include<Rmath.h>
// #include<stdio.h>
#include"BVCUtilities.h"
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
using namespace arma;
using namespace R;
double rtnorm(double mu, double sigma){
double lower = -mu/sigma, ret, a, z;
if(lower <0){ //naive
while((ret = R::rnorm(0, 1)) < lower)
;
}
else{ // accept-reject method based on an exponential distribution
a = (lower + pow((lower*lower + 4),0.5))/2;
do{
ret = R::rexp(a) + lower;
z = exp(-(ret - a)*(ret - a)/2);
}while(z < R::runif(0,1));
}
return (ret * sigma + mu);
}
double rtnorm0(double mu, double sigma){
double ret;
while((ret = R::rnorm(mu, sigma)) <= 0);
return (ret);
}
double rinvgaussian(double mu, double lambda){
if(mu>1000){
mu = 1000;
}
double random_sample;
double z,y,x,u;
z=R::rnorm(0,1);
y=z*z;
x=mu+0.5*mu*mu*y/lambda - 0.5*(mu/lambda)*sqrt(4*mu*lambda*y+mu*mu*y*y);
u=R::runif(0,1);
if(u <= mu/(mu+x)){
random_sample = x;
}else{
random_sample = mu*mu/x;
};
return(random_sample);
}
double rinvGauss(double mu, double lambda)
{
double b=0.5*mu/lambda;
double a=mu*b;
double c=4.0*mu*lambda;
double d=mu*mu;
double z=R::rnorm(0,1);
double random_sample;
double u=R::runif(0,1);
double v=z*z; // Chi-square with 1 df
double x=mu+a*v-b*sqrt(c*v+d*v*v); // Smallest root
if(u <= mu/(mu+x)){ // Pick x with prob mu/(mu+x), else d/x;
random_sample = x;
}else{
random_sample = d/x;
};
return(random_sample);
}
arma::vec mvrnormCpp(const arma::vec& mu, const arma::mat& sigma, double tol){
unsigned int p = mu.n_elem;
arma::vec eigval;
arma::mat eigvec;
// double tol = std::pow(10, -6);
arma::eig_sym(eigval, eigvec, sigma);
// arma::eig_gen(eigval, eigvec, sigma);
if(arma::any(eigval < (-1*tol*std::abs(eigval(eigval.n_elem -1))))){
std::string error = std::string("covariance matrix is not positive definite");
throw std::runtime_error(error);
}
arma::vec z = arma::randn(p);
arma::vec rs = mu + eigvec * diagmat(sqrt(arma::clamp(eigval, 0, eigval.max()))) * z;
return rs;
}
// arma::vec mvrnormCpp(const arma::vec& mu, const arma::mat& sigma){
// unsigned int p = mu.n_elem;
// arma::vec eigval;
// arma::mat eigvec;
// arma::eig_sym(eigval, eigvec, sigma);
// double scale = std::pow(10,5);
// if(arma::any((arma::round(eigval * scale)/scale) <= 0)){
// std::string error = std::string("covariance matrix is not positive definite");
// throw std::runtime_error(error);
// }
// arma::vec z = arma::randn(p);
// arma::vec rs = mu + eigvec * diagmat(sqrt(eigval)) * z;
// return rs;
// }
arma::vec mvrnormCpp(const arma::vec& mu, const arma::mat& sigma){
unsigned int p = mu.n_elem;
arma::vec eigval;
arma::mat eigvec;
arma::eig_sym(eigval, eigvec, sigma);
if(arma::any(eigval <= 0)){
std::string error = std::string("covariance matrix is not positive definite");
throw std::runtime_error(error);
}
arma::vec z = arma::randn(p);
arma::vec rs = mu + eigvec * arma::diagmat(arma::sqrt(eigval)) * z;
return rs;
}
|
[
"akhilakollasrinu424jf@gmail.com"
] |
akhilakollasrinu424jf@gmail.com
|
36027a40682824e63a18358e58bf0207e7eae609
|
e41e78cc4b8d010ebdc38bc50328e7bba2d5a3fd
|
/SDK/Mordhau_BP_Crest02_classes.hpp
|
f90441a7548e0905336cc8163cb61be31b7f7acc
|
[] |
no_license
|
Mentos-/Mordhau_SDK
|
a5e4119d60988dca9063e75e2563d1169a2924b8
|
aacf020e6d4823a76787177eac2f8f633f558ec2
|
refs/heads/master
| 2020-12-13T10:36:47.589320
| 2020-01-03T18:06:38
| 2020-01-03T18:06:38
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 634
|
hpp
|
#pragma once
// Mordhau (Dumped by Hinnie) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass BP_Crest02.BP_Crest02_C
// 0x0000 (0x0060 - 0x0060)
class UBP_Crest02_C : public UEmblem
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_Crest02.BP_Crest02_C");
return ptr;
}
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
[
"hsibma02@gmail.com"
] |
hsibma02@gmail.com
|
b764e39ff68551aff101ac9393eb8f13dd0a1738
|
51222a640bdfaf394af67601dc4e128f678743d3
|
/c++/matrix/main.cpp
|
06b8a6f70ec27ffa7ac65ac3d30bbbb78e74e1f1
|
[] |
no_license
|
pvelesko/testing
|
8294f5cd9af5634460f3b597c582ce7ff22238d0
|
5bdc53da65f67596858825d023852f7457937211
|
refs/heads/master
| 2023-06-29T00:42:37.744462
| 2021-08-04T04:24:08
| 2021-08-04T04:30:37
| 392,545,407
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,640
|
cpp
|
#include <iostream>
#include <CL/sycl.hpp>
using namespace cl::sycl;
template<class T>
class MatrixUSM2D {
public:
T* data;
int dim0;
int dim1;
context* ctx;
device* dev;
MatrixUSM2D(int dim0_in, int dim1_in, device &dev_in, context &ctx_in) {
ctx = &ctx_in;
dev = &dev_in;
dim0 = dim0_in;
dim1 = dim1_in;
data = static_cast<T*>(malloc_shared(dim0 * dim1 * sizeof(T), *dev, *ctx));
int dim;
if (!std::is_pointer<T>::value) dim = 0;
typedef typename std::remove_pointer<T>::type T1;
typedef typename std::remove_pointer<T1>::type T2;
typedef typename std::remove_pointer<T2>::type T3;
typedef typename std::remove_pointer<T3>::type T4;
if (std::is_pointer<T >::value) dim++;
if (std::is_pointer<T1>::value) dim++;
if (std::is_pointer<T2>::value) dim++;
if (std::is_pointer<T3>::value) dim++;
if (std::is_pointer<T4>::value) dim++;
}
~MatrixUSM2D() {
cl::sycl::free(data, *ctx);
};
T& operator()(int x, int y) {
return data[x *dim0 + y];
};
};
int main() {
queue q(gpu_selector{});
device dev = q.get_device();
context ctx = q.get_context();
std::cout << "Running on "
<< dev.get_info<info::device::name>()
<< std::endl;
MatrixUSM2D<float> m(3, 3, dev, ctx);
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
m(i, j) = 0;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
std::cout << m(i, j) << std::endl;
std::cout << std::endl;
m(2, 1) = 1;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
std::cout << m(i, j) << std::endl;
return 0;
}
|
[
"paulius.velesko@intel.com"
] |
paulius.velesko@intel.com
|
07de991178a1dd9ed81c261877de4e39d80e6c11
|
9e65dd575555c5aa754e120c2e4b10e927415887
|
/inc/ui/genfileprogress.h
|
b20d9e847e49cd3780bfae1529331f3a9ec48fa1
|
[] |
no_license
|
heretique/cuteboxLegacy
|
2e20727344cdda290af397c9a149af1e99e3fcf1
|
7d0f1436da485d4da3cf33afbb192e4329efd3d1
|
refs/heads/master
| 2021-06-19T12:32:03.768669
| 2021-06-15T18:55:58
| 2021-06-15T18:55:58
| 138,695,873
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 712
|
h
|
#ifndef GENFILEPROGRESS_H
#define GENFILEPROGRESS_H
#include "geninterfaces.h"
#include <QTime>
#include "gentypes.h"
namespace Ui {
class GenFileProgress;
}
class GenFileProgress : public GenCachedWidget
{
Q_OBJECT
public:
explicit GenFileProgress(QWidget *parent = 0);
~GenFileProgress();
void setText(const QString& text);
void setItemProgress(qint64 bytes, qint64 bytesTotal);
void setTotalProgress(int current, int total);
void showTotalProgress(bool show);
void start();
void reset();
signals:
void fileActionCanceled();
private:
Ui::GenFileProgress *ui;
QTime _fileProgressTime;
};
#endif // GENFILEPROGRESS_H
|
[
"139596+heretique@users.noreply.github.com"
] |
139596+heretique@users.noreply.github.com
|
a8b570309e5a6598289eaa9119417dba52f05909
|
92eead7872140b0ba00e54629ef19d4432f3be4e
|
/Chapter-12/12.22/StrBlob.h
|
84e612fa74722305c206af6b14304bff99596bcf
|
[] |
no_license
|
shengchiliu/Cpp-Primer-Answer
|
acd8a3b3f0ce80fd759055d7d79788c2b5456b13
|
9a932c349b5cd272c47a7c793c3cee8c84f9edbc
|
refs/heads/master
| 2023-03-22T10:35:00.824761
| 2019-08-30T04:57:29
| 2019-08-30T04:57:29
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,767
|
h
|
#ifndef STRBLOB_H
#define STRBLOB_H
#include<vector>
#include<string>
#include<initializer_list>
#include<memory>
class StrBlobPtr;
class ConstStrBlobPtr;
class StrBlob
{
friend class StrBlobPtr;
friend class ConstStrBlobPtr;
public:
typedef std::vector<std::string>::size_type size_type;
StrBlob();
StrBlob(std::initializer_list<std::string> li);
inline size_type size() const { return data->size(); }
bool empty() const { return data->empty(); }
void push_back(const std::string &t) { data->push_back(t); }
void pop_back();
const std::string & front() const;
std::string & front();
const std::string & back() const;
std::string & back();
StrBlobPtr begin();
StrBlobPtr end();
ConstStrBlobPtr cbegin();
ConstStrBlobPtr cend();
private:
std::shared_ptr<std::vector<std::string>> data;
void check(size_type i, const std::string & msg) const;
};
class StrBlobPtr
{
friend bool compare(const StrBlobPtr &p1, const StrBlobPtr &p2);
public:
StrBlobPtr() : curr(0) { }
StrBlobPtr(StrBlob &a, std::size_t sz = 0) : wptr(a.data), curr(sz) { }
std::string & deref() const;
StrBlobPtr & incr();
private:
std::shared_ptr<std::vector<std::string>> check(std::size_t , const std::string &) const;
std::weak_ptr<std::vector<std::string>> wptr;
std::size_t curr;
};
class ConstStrBlobPtr
{
friend bool compare(const ConstStrBlobPtr &p1, const ConstStrBlobPtr &p2);
public:
ConstStrBlobPtr() : curr(0) { }
ConstStrBlobPtr(const StrBlob &a, std::size_t sz = 0) : wptr(a.data), curr(sz) { }
std::string & deref() const;
ConstStrBlobPtr & incr();
private:
std::shared_ptr<std::vector<std::string>> check(std::size_t , const std::string &) const;
std::weak_ptr<std::vector<std::string>> wptr;
std::size_t curr;
};
#endif
|
[
"jzplp@qq.com"
] |
jzplp@qq.com
|
96c1fe78474c7acc20344ba70aa6f714500b1d8d
|
c3805708c63d3dd3a7a85e02fc2535b39fc0a7fa
|
/src/placement/constraint_updater.cpp
|
1cedfe557dbb969baf76539611c85dd145f14c7b
|
[
"MIT"
] |
permissive
|
Christof/voly-labeller
|
68c49424bfd56cb3190c003b00d3dc52d83b9eb0
|
68ddb4681b200aac7f7cf6a328ac42e3562257ec
|
refs/heads/master
| 2021-01-19T18:38:46.504357
| 2017-05-28T15:36:41
| 2017-05-28T20:07:43
| 31,907,641
| 3
| 0
| null | 2017-05-28T20:07:44
| 2015-03-09T15:51:50
|
C++
|
UTF-8
|
C++
| false
| false
| 5,965
|
cpp
|
#include "./constraint_updater.h"
#include <Eigen/Geometry>
#include <vector>
#include <string>
#include <memory>
#include "./placement.h"
#include "./shadow_constraint_drawer.h"
#include "./anchor_constraint_drawer.h"
ConstraintUpdater::ConstraintUpdater(
int bufferWidth, int bufferHeight,
std::shared_ptr<AnchorConstraintDrawer> anchorConstraintDrawer,
std::shared_ptr<ShadowConstraintDrawer> connectorShadowDrawer,
std::shared_ptr<ShadowConstraintDrawer> shadowConstraintDrawer,
float scaleFactor)
: width(bufferWidth), height(bufferHeight),
anchorConstraintDrawer(anchorConstraintDrawer),
connectorShadowDrawer(connectorShadowDrawer),
shadowConstraintDrawer(shadowConstraintDrawer), scaleFactor(scaleFactor)
{
labelShadowColor = Placement::labelShadowValue / 255.0f;
connectorShadowColor = Placement::connectorShadowValue / 255.0f;
anchorConstraintColor = Placement::anchorConstraintValue / 255.0f;
borderPixel = scaleFactor * Eigen::Vector2f(4, 4);
}
ConstraintUpdater::~ConstraintUpdater()
{
}
void ConstraintUpdater::drawConstraintRegionFor(
Eigen::Vector2i anchorPosition, Eigen::Vector2i labelSize,
Eigen::Vector2i lastAnchorPosition, Eigen::Vector2i lastLabelPosition,
Eigen::Vector2i lastLabelSize)
{
this->labelSize = labelSize.cast<float>();
if (isConnectorShadowEnabled)
addConnectorShadow(anchorPosition, lastAnchorPosition, lastLabelPosition);
Eigen::Vector2f anchor = anchorPosition.cast<float>();
Eigen::Vector2f lastHalfSize = 0.5f * lastLabelSize.cast<float>();
addLabelShadow(anchor, lastLabelPosition, lastHalfSize);
}
void ConstraintUpdater::drawRegionsForAnchors(
std::vector<Eigen::Vector2f> anchorPositions, Eigen::Vector2i labelSize)
{
std::vector<float> positions(anchorPositions.size() * 2);
size_t index = 0;
for (auto &anchorPosition : anchorPositions)
{
positions[index++] = anchorPosition.x();
positions[index++] = anchorPosition.y();
}
assert(positions.size() == index);
anchorConstraintDrawer->update(positions);
Eigen::Vector2f constraintSize = borderPixel + labelSize.cast<float>();
Eigen::Vector2f halfSize =
constraintSize.cwiseQuotient(Eigen::Vector2f(width, height));
anchorConstraintDrawer->draw(anchorConstraintColor, halfSize);
}
void ConstraintUpdater::clear()
{
shadowConstraintDrawer->clear();
sources.clear();
starts.clear();
ends.clear();
anchors.clear();
connectorStart.clear();
connectorEnd.clear();
}
void ConstraintUpdater::finish()
{
shadowConstraintDrawer->update(sources, starts, ends);
connectorShadowDrawer->update(anchors, connectorStart, connectorEnd);
Eigen::Vector2f sizeWithBorder = labelSize.cast<float>() + borderPixel;
Eigen::Vector2f halfSize =
sizeWithBorder.cwiseQuotient(Eigen::Vector2f(width, height));
shadowConstraintDrawer->draw(labelShadowColor, halfSize);
connectorShadowDrawer->draw(connectorShadowColor, halfSize);
}
void ConstraintUpdater::setIsConnectorShadowEnabled(bool enabled)
{
isConnectorShadowEnabled = enabled;
}
void ConstraintUpdater::addConnectorShadow(Eigen::Vector2i anchor,
Eigen::Vector2i start,
Eigen::Vector2i end)
{
anchors.push_back(anchor.x());
anchors.push_back(anchor.y());
connectorStart.push_back(start.x());
connectorStart.push_back(start.y());
connectorEnd.push_back(end.x());
connectorEnd.push_back(end.y());
}
void ConstraintUpdater::addLineShadow(Eigen::Vector2f source,
Eigen::Vector2f start,
Eigen::Vector2f end)
{
sources.push_back(source.x());
sources.push_back(source.y());
starts.push_back(start.x());
starts.push_back(start.y());
ends.push_back(end.x());
ends.push_back(end.y());
}
void ConstraintUpdater::addLabelShadow(Eigen::Vector2f anchor,
Eigen::Vector2i lastLabelPosition,
Eigen::Vector2f lastHalfSize)
{
std::vector<Eigen::Vector2f> corners =
getCornersFor(lastLabelPosition, lastHalfSize);
std::vector<float> cornerAnchorDistances;
for (auto corner : corners)
cornerAnchorDistances.push_back((corner - anchor).squaredNorm());
int maxIndex = std::distance(cornerAnchorDistances.begin(),
std::max_element(cornerAnchorDistances.begin(),
cornerAnchorDistances.end()));
// Just add a line shadow for two edges of the label.
// The other two, which are connected to the farthest corner
// would produce an area which is included in the first one.
// The following table illustrates which lines must be drawn,
// between which corners (given by index)
//
// maxIndex line 1 line 2
// 0 1 to 2 2 to 3
// 1 2 to 3 3 to 0
// 2 0 to 1 3 to 0
// 3 0 to 1 1 to 2
if (maxIndex == 2 || maxIndex == 3)
addLineShadow(anchor, corners[0], corners[1]);
if (maxIndex == 0 || maxIndex == 3)
addLineShadow(anchor, corners[1], corners[2]);
if (maxIndex == 0 || maxIndex == 1)
addLineShadow(anchor, corners[2], corners[3]);
if (maxIndex == 1 || maxIndex == 2)
addLineShadow(anchor, corners[3], corners[0]);
}
std::vector<Eigen::Vector2f>
ConstraintUpdater::getCornersFor(Eigen::Vector2i position,
Eigen::Vector2f halfSize)
{
std::vector<Eigen::Vector2f> corners = {
Eigen::Vector2f(position.x() + halfSize.x(), position.y() + halfSize.y()),
Eigen::Vector2f(position.x() - halfSize.x(), position.y() + halfSize.y()),
Eigen::Vector2f(position.x() - halfSize.x(), position.y() - halfSize.y()),
Eigen::Vector2f(position.x() + halfSize.x(), position.y() - halfSize.y()),
};
return corners;
}
void ConstraintUpdater::save(std::string filename)
{
anchorConstraintDrawer->saveBufferTo(filename);
}
|
[
"christof.sirk@gmail.com"
] |
christof.sirk@gmail.com
|
fe1f78625df6c5e5871f786d1f027ad67d443e83
|
78aa6efa0418e1778d9a026ab030fb8d02177140
|
/include/burst/container/k_ary_search_set.hpp
|
048f5d3ddc842e093b2afc52cc0136ceb954447d
|
[
"BSL-1.0"
] |
permissive
|
izvolov/burst
|
8a5b1e106891b1caf3434157a5646df955ceb2a5
|
ea38c4a59c8f98f857dafbc468b6e8a1f8bed6ca
|
refs/heads/master
| 2022-09-07T13:48:07.094878
| 2022-08-07T15:52:06
| 2022-08-07T16:14:48
| 26,827,690
| 88
| 6
|
BSL-1.0
| 2022-08-08T03:19:57
| 2014-11-18T20:07:42
|
C++
|
UTF-8
|
C++
| false
| false
| 19,738
|
hpp
|
#ifndef BURST__CONTAINER__K_ARY_SEARCH_SET_HPP
#define BURST__CONTAINER__K_ARY_SEARCH_SET_HPP
#include <burst/container/unique_ordered_tag.hpp>
#include <burst/functional/not_fn.hpp>
#include <burst/integer/intlog.hpp>
#include <burst/integer/intpow.hpp>
#include <boost/assert.hpp>
#include <boost/container/container_fwd.hpp>
#include <boost/range/iterator_range.hpp>
#include <algorithm>
#include <cstddef>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <stack>
#include <utility>
#include <vector>
namespace burst
{
struct k_ary_search_set_branch
{
std::size_t index;
std::size_t size;
std::size_t height;
std::size_t preceding_elements;
};
//! Множество, основанное на k-местном дереве поиска.
/*!
k-местное дерево поиска — это дерево поиска, у которого в каждом узле находится не
более (k - 1) элементов и не более k переходов в поддеревья.
В данном случае используется правильное k-местное дерево, то есть такое, в котором
обязательно заполнены все уровни дерева, кроме последнего, причём в последнем уровне
элементы прибиты к левому краю уровня.
При этом, естественно, соблюдается, условие дерева поиска, то есть все элементы,
находящиеся в i-м поддереве узла, строго меньше i-го элемента узла и не меньше (i - 1)-го
элемента узла, а i-й элемент узла не больше (i + 1)-го элемента узла.
Повторяющихся элементов в дереве нет, это не мультимножество.
Само дерево представлено в виде массива, элементы в котором размещены по принципу,
схожему с пирамидой.
\tparam Value
Тип данных, хранящихся в множестве.
\tparam Compare
Отношение порядка, по которому элементы выстроены в дереве.
Должно быть двухместной операцией на элементах типа Value, возвращающей булевское
значение.
bool Compare (Value [const &], Value [const &])
*/
template<typename Value, typename Compare = std::less<>>
class k_ary_search_set
{
public:
using value_type = Value;
using value_compare = Compare;
private:
using value_container_type = std::vector<value_type>;
public:
using iterator = typename value_container_type::iterator;
using const_iterator = typename value_container_type::const_iterator;
using size_type = typename value_container_type::size_type;
using difference_type = typename value_container_type::difference_type;
public:
//! Создание множества из упорядоченного набора, представленного итераторами.
/*!
Принимает два итератора, которые задают набор элементов, которые должны быть в
результирующем множестве, местность дерева, отношение порядка на элементах, а также
фиктивный элемент — метку, обозначающую, что входной набор элементов уже упорядочен и
элементы в нём уникальны, то есть проводить дополнительную предобработку не нужно.
Асимптотика.
Время: O(N), N = |[first, last)| — размер дерева.
Память: O(log_k(N) + k).
Учитывается только собственная память конструктора. Созданное дерево, естественно,
содержит ровно N элементов.
*/
template <typename RandomAccessIterator>
k_ary_search_set
(
container::unique_ordered_tag_t,
RandomAccessIterator first,
RandomAccessIterator last,
std::size_t arity = default_arity,
const value_compare & compare = value_compare()
):
m_values(static_cast<size_type>(std::distance(first, last))),
m_arity(arity),
m_compare(compare)
{
initialize_trusted(boost::make_iterator_range(first, last));
}
//! Создание множества из набора, заданного итераторами.
/*!
Принимает два итератора, которые задают набор элементов, которые должны быть в
результирующем множестве, местность дерева и отношение порядка на элементах.
Асимптотика.
Время:
1. O(N), если набор упорядочен.
2. O(N logN), если набор неупорядочен,
где N = |[first, last)|.
Память: O(log_k(N) + k).
*/
template <typename RandomAccessIterator>
k_ary_search_set
(
RandomAccessIterator first,
RandomAccessIterator last,
std::size_t arity = default_arity,
const value_compare & compare = value_compare()
):
m_arity(arity),
m_compare(compare)
{
initialize(boost::make_iterator_range(first, last));
}
//! Создание множества из упорядоченного набора, представленного списком инициализации.
/*!
Принимает std::initializer_list, заполненный элементами которые должны быть в
результирующем множестве, местность дерева, отношение порядка на элементах, а также
фиктивный элемент — метку, обозначающую, что входной набор элементов уже упорядочен и
элементы в нём уникальны, то есть проводить дополнительную предобработку не нужно.
Асимптотика.
Время: O(N), где N = |values|.
Память: O(log_k(N) + k).
*/
k_ary_search_set
(
container::unique_ordered_tag_t,
std::initializer_list<value_type> values,
std::size_t arity = default_arity,
const value_compare & compare = value_compare()
):
m_values(values.size()),
m_arity(arity),
m_compare(compare)
{
initialize_trusted(boost::make_iterator_range(values));
}
//! Создание множества из набора, представленного списком инициализации.
/*!
Принимает std::initializer_list, заполненный элементами которые должны быть в
результирующем множестве, местность дерева и отношение порядка на элементах.
Асимптотика.
Время:
1. O(N), если набор упорядочен.
2. O(N logN), если набор неупорядочен,
где N = |values|.
Память: O(log_k(N) + k).
*/
explicit k_ary_search_set
(
std::initializer_list<value_type> values,
std::size_t arity = default_arity,
const value_compare & compare = value_compare()
):
m_arity(arity),
m_compare(compare)
{
initialize(boost::make_iterator_range(values));
}
k_ary_search_set ():
m_arity(0)
{
}
public:
//! Поиск элемента в множестве.
/*!
Если искомый элемент существует в множестве, то возвращается итератор на него. Если
не существует, то возвращается end().
Асимптотика.
Время: O(log_k(N)),
k — местность дерева.
N — количество элементов в дереве.
Память: O(1).
*/
iterator find (const value_type & value)
{
return begin() + std::distance(cbegin(), find_impl(value));
}
const_iterator find (const value_type & value) const
{
return find_impl(value);
}
size_type size () const
{
return m_values.size();
}
bool empty () const
{
return m_values.empty();
}
//! Начало множества.
/*!
Важно, что последовательность [begin(), end()) неупорядочена.
*/
iterator begin ()
{
return m_values.begin();
}
iterator end ()
{
return m_values.end();
}
const_iterator begin () const
{
return m_values.begin();
}
const_iterator end () const
{
return m_values.end();
}
const_iterator cbegin () const
{
return m_values.cbegin();
}
const_iterator cend () const
{
return m_values.cend();
}
private:
const_iterator find_impl (const value_type & value) const
{
std::size_t node_index = 0;
while (node_index < m_values.size())
{
const_iterator node_begin = begin() + static_cast<difference_type>(node_index);
const_iterator node_end =
node_begin +
std::min
(
static_cast<difference_type>(m_arity - 1),
std::distance(node_begin, end())
);
const_iterator search_result =
std::lower_bound(node_begin, node_end, value, m_compare);
if (search_result != node_end && not m_compare(value, *search_result))
{
return search_result;
}
else
{
node_index = perfect_tree_child_index
(
m_arity,
node_index,
static_cast<std::size_t>(std::distance(node_begin, search_result))
);
}
}
return end();
}
template <typename RandomAccessRange>
void initialize (const RandomAccessRange & range)
{
const auto is_sorted_and_unique =
std::adjacent_find(range.begin(), range.end(), burst::not_fn(m_compare)) == range.end();
if (is_sorted_and_unique)
{
initialize_trusted(range);
}
else
{
value_container_type buffer(range.begin(), range.end());
std::sort(buffer.begin(), buffer.end(), m_compare);
buffer.erase
(
std::unique(buffer.begin(), buffer.end(), burst::not_fn(m_compare)),
buffer.end()
);
initialize_trusted(boost::make_iterator_range(buffer));
}
}
//! Расстановка элементов по своим местам.
/*!
Обходит дерево по уровням и расставляет по местам в дереве элементы исходной
последовательности.
Асимптотика.
Время: O(N), N — количество элементов в дереве.
Память: O(log_k(N) + k),
O(log_k(N)) памяти требуется для хранения стека при обходе узлов дерева.
O(k) памяти требуется для хранения счётчиков при заполнении одного узла.
*/
template <typename RandomAccessRange>
void initialize_trusted (const RandomAccessRange & range)
{
BOOST_ASSERT
(
std::adjacent_find(range.begin(), range.end(), burst::not_fn(m_compare)) == range.end()
);
if (not range.empty())
{
m_values.resize(range.size());
std::stack<k_ary_search_set_branch> branches;
branches.push({0, size(), perfect_tree_height(m_arity, size()), 0});
while (not branches.empty())
{
const auto branch = branches.top();
branches.pop();
// Количество меньших элементов ветки для каждого элемента текущего узла.
std::vector<std::size_t> counters;
fill_counters(branch, counters);
fill_node(branch, counters, range);
if (counters[0] > 0)
{
branches.push
({
perfect_tree_child_index(m_arity, branch.index, 0),
counters[0],
branch.height - 1,
branch.preceding_elements
});
}
for
(
std::size_t i = 1;
i < counters.size() && (counters[i] - counters[i - 1] - 1) > 0;
++i
)
{
branches.push
({
perfect_tree_child_index(m_arity, branch.index, i),
counters[i] - counters[i - 1] - 1,
branch.height - 1,
branch.preceding_elements + counters[i - 1] + 1
});
}
}
}
}
//! Подсчёт счётчиков для элементов узла.
/*!
Для каждого элемента узла подсчитывает количество элементов в ветке (ветка включает
рассматриваемый узел), которые строго меньше этого элемента.
*/
void
fill_counters
(
const k_ary_search_set_branch & branch,
std::vector<std::size_t> & counters
)
{
const std::size_t max_subtree_height = branch.height - 1;
const std::size_t min_subtree_elements =
perfect_tree_size(m_arity, max_subtree_height - 1);
const std::size_t max_subtree_elements =
perfect_tree_size(m_arity, max_subtree_height);
const std::size_t elements_in_last_row =
branch.size - perfect_tree_size(m_arity, branch.height - 1);
counters.resize(std::min(m_arity, branch.size + 1));
for (std::size_t i = 0; i < counters.size(); ++i)
{
counters[i] = i + std::min
(
(i + 1) * min_subtree_elements + elements_in_last_row,
(i + 1) * max_subtree_elements
);
}
BOOST_ASSERT(counters.back() == branch.size);
}
//! Заполнение узла нужными элементами исходного диапазона.
/*!
Для каждого элемента узла известен индекс в исходном диапазоне, по которому лежит
нужное значение. Осталось только скопировать его.
*/
template <typename RandomAccessRange>
void
fill_node
(
const k_ary_search_set_branch & branch,
const std::vector<std::size_t> & counters,
const RandomAccessRange & range
)
{
for
(
std::size_t element_index = 0;
element_index < counters.size() - 1;
++element_index
)
{
using difference_type = typename RandomAccessRange::difference_type;
const auto index_in_initial_range =
static_cast<difference_type>
(
branch.preceding_elements + counters[element_index]
);
m_values[branch.index + element_index] = range[index_in_initial_range];
}
BOOST_ASSERT(std::is_sorted
(
m_values.begin() + static_cast<difference_type>(branch.index),
m_values.begin() + static_cast<difference_type>(branch.index + counters.size() - 1),
m_compare
));
}
private:
static std::size_t perfect_tree_size (std::size_t arity, std::size_t height)
{
return intpow(arity, height) - 1;
}
static std::size_t perfect_tree_height (std::size_t arity, std::size_t size)
{
return intlog(size, arity) + 1;
}
static std::size_t
perfect_tree_child_index
(
std::size_t arity,
std::size_t parent_index,
std::size_t child_number
)
{
return parent_index * arity + (child_number + 1) * (arity - 1);
}
private:
static const std::size_t default_arity = 33;
private:
value_container_type m_values;
const std::size_t m_arity;
value_compare m_compare;
};
}
#endif // BURST__CONTAINER__K_ARY_SEARCH_SET_HPP
|
[
"dmitriy@izvolov.ru"
] |
dmitriy@izvolov.ru
|
30b8fe8e8da076dfc0bf6d736a2f74d2291c09cc
|
65f9576021285bc1f9e52cc21e2d49547ba77376
|
/LINUX/android/vendor/qcom/proprietary/fastmmi/module/bluetooth/bluetooth.cpp
|
4fe01840362aec351919853c32c0b100343a2bd4
|
[] |
no_license
|
AVCHD/qcs605_root_qcom
|
183d7a16e2f9fddc9df94df9532cbce661fbf6eb
|
44af08aa9a60c6ca724c8d7abf04af54d4136ccb
|
refs/heads/main
| 2023-03-18T21:54:11.234776
| 2021-02-26T11:03:59
| 2021-02-26T11:03:59
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,101
|
cpp
|
/*
* Copyright (c) 2014-2017, Qualcomm Technologies, Inc.
* All Rights Reserved.
* Confidential and Proprietary - Qualcomm Technologies, Inc.
*/
#include "mmi_module.h"
/**
* Defined case run in mmi mode,this mode support UI.
*
*/
static const mmi_module_t *g_module = NULL;
static int g_pid;
static pthread_mutex_t g_mutex;
#define KEY_WORD_DEVICE "Device name is :"
#define KEY_WORD_RSSI "Device RSSI VALUE is"
#define KEY_WORD_ADDRESS "Device address is :"
typedef struct {
char ap_device[64];
char rssi[64];
} bt_info;
static void cb_function(char *str, int size) {
if(g_module != NULL)
g_module->cb_print(NULL, SUBCMD_MMI, str, size, PRINT);
}
static int start_test(char *buf, uint32_t size, unordered_map < string, string > ¶ms) {
char result[SIZE_1K * 4];
char tmp[256];
int ret = FAILED;
bool found = false;
bt_info bt_result;
const char *args[3];
int i = 0;
exec_cmd_t execmd;
//initial the local variable
memset(&bt_result, 0, sizeof(bt_info));
if(buf == NULL) {
MMI_ALOGE("Invalid parameter");
return FAILED;
}
if(!check_file_exist(get_value("bdt"))) {
MMI_ALOGE("file(%s) not exist", get_value("bdt"));
return FAILED;
}
args[i++] = (char *) get_value("bdt");
if(!params["method"].empty()) {
args[i++] = params["method"].c_str();
args[i] = NULL;
} else {
args[i++] = "get_a_device";
args[i] = NULL;
}
execmd.cmd = (char *) get_value("bdt");
execmd.params = (char **) args;
execmd.pid = &g_pid;
execmd.exit_str = NULL;
execmd.result = result;
execmd.size = sizeof(result);
{
char temp_agrs[512] = { 0 };
for(int j = 1; j < i; j++)
snprintf(temp_agrs + strlen(temp_agrs), sizeof(temp_agrs) - strlen(temp_agrs), "%s ", args[j]);
MMI_ALOGI("exec command:'%s', args:%s", execmd.cmd, temp_agrs);
}
ret = exe_cmd(cb_function, &execmd);
if(ret != SUCCESS) {
MMI_ALOGE("'%s' exec fail", execmd.cmd);
return FAILED;
}
MMI_ALOGI("'%s' exec result: %s", execmd.cmd, result);
char *p = result;
char *ptr;
while(*p != '\0') { /*print every line of scan result information */
ptr = tmp;
while(*p != '\n' && *p != '\0') {
*ptr++ = *p++;
}
p++;
*ptr = '\0';
ptr = strstr(tmp, KEY_WORD_ADDRESS);
if(strstr(tmp, KEY_WORD_ADDRESS) != NULL) {
found = true;
ptr = strstr(tmp, ":");
ptr++;
memset(bt_result.ap_device, 0, sizeof(bt_result.ap_device));
snprintf(bt_result.ap_device, sizeof(bt_result.ap_device), "AP=Device name:%s;", ptr);
MMI_ALOGI("AP device name: %s", ptr);
} else if(strstr(tmp, KEY_WORD_DEVICE) != NULL) {
ptr = strstr(tmp, ":");
ptr++;
memset(bt_result.ap_device, 0, sizeof(bt_result.ap_device));
snprintf(bt_result.ap_device, sizeof(bt_result.ap_device), "AP=Device name:%s;", ptr);
MMI_ALOGI("AP device name: %s", ptr);
} else if(strstr(tmp, KEY_WORD_RSSI) != NULL) {
found = true;
if(strstr(bt_result.ap_device, "AP=Device name") == NULL)
continue;
ptr = strstr(tmp, ":");
ptr++;
memset(bt_result.rssi, 0, sizeof(bt_result.rssi));
snprintf(bt_result.rssi, sizeof(bt_result.rssi), "RSSI:%s;", ptr);
strlcat(buf, bt_result.ap_device, size);
strlcat(buf, bt_result.rssi, size);
strlcat(buf, "\n", size);
MMI_ALOGI("device RSSI: %s", ptr);
}
}
return found ? SUCCESS : FAILED;
}
static int32_t module_init(const mmi_module_t * module, unordered_map < string, string > ¶ms) {
if(module == NULL) {
MMI_ALOGE("NULL point received");
return FAILED;
}
MMI_ALOGI("module init start for module:[%s]", module->name);
g_module = module;
pthread_mutex_init(&g_mutex, NULL);
MMI_ALOGI("module init finished for module:[%s]", module->name);
return SUCCESS;
}
static int32_t module_deinit(const mmi_module_t * module) {
if(module == NULL) {
MMI_ALOGE("NULL point received");
return FAILED;
}
MMI_ALOGI("module deinit start for module:[%s]", module->name);
MMI_ALOGI("module deinit finished for module:[%s]", module->name);
return SUCCESS;
}
static int32_t module_stop(const mmi_module_t * module) {
if(module == NULL) {
MMI_ALOGE("NULL point received");
return FAILED;
}
MMI_ALOGI("module stop start for module:[%s]", module->name);
kill_proc(g_pid);
kill_thread(module->run_pid);
MMI_ALOGI("module stop finished for module:[%s]", module->name);
return SUCCESS;
}
/**
* Before call Run function, caller should call module_init first to initialize the module.
* the "cmd" passd in MUST be defined in cmd_list ,mmi_agent will validate the cmd before run.
*
*/
static int32_t module_run(const mmi_module_t * module, const char *cmd, unordered_map < string, string > ¶ms) {
int ret = FAILED;
char buf[SIZE_1K] = { 0 };
if(!module || !cmd) {
MMI_ALOGE("NULL point received");
return FAILED;
}
MMI_ALOGI("module run start for module:[%s], subcmd:%s", module->name, MMI_STR(cmd));
g_module = module;
pthread_mutex_lock(&g_mutex);
ret = start_test(buf, sizeof(buf), params);
if(SUCCESS == ret) {
MMI_ALOGI("module:[%s] test %s", module->name, MMI_TEST_RESULT(ret));
} else {
MMI_ALOGE("module:[%s] test %s", module->name, MMI_TEST_RESULT(ret));
}
pthread_mutex_unlock(&g_mutex);
if(!strcmp(cmd, SUBCMD_MMI)) {
module->cb_print(params[KEY_MODULE_NAME].c_str(), SUBCMD_MMI, buf, strlen(buf), PRINT_DATA);
} else if(!strcmp(cmd, SUBCMD_PCBA)) {
module->cb_print(params[KEY_MODULE_NAME].c_str(), SUBCMD_PCBA, buf, strlen(buf), PRINT_DATA);
} else {
MMI_ALOGE("Received error subcmd: %s", MMI_STR(cmd));
}
MMI_ALOGI("module run finished for module:[%s], subcmd:%s", module->name, MMI_STR(cmd));
/** Default RUN mmi*/
return ret;
}
/**
* Methods must be implemented by module.
*/
static struct mmi_module_methods_t module_methods = {
.module_init = module_init,
.module_deinit = module_deinit,
.module_run = module_run,
.module_stop = module_stop,
};
/**
* Every mmi module must have a data structure named MMI_MODULE_INFO_SYM
* and the fields of this data structure must be initialize in strictly sequence as definition,
* please don't change the sequence as g++ not supported in CPP file.
*/
mmi_module_t MMI_MODULE_INFO_SYM = {
.version_major = 1,
.version_minor = 0,
.name = "Bluetooth",
.author = "Qualcomm Technologies, Inc.",
.methods = &module_methods,
.module_handle = NULL,
.supported_cmd_list = NULL,
.supported_cmd_list_size = 0,
.cb_print = NULL, /**it is initialized by mmi agent*/
.run_pid = -1,
};
|
[
"jagadeshkumar.s@pathpartnertech.com"
] |
jagadeshkumar.s@pathpartnertech.com
|
4dc62d739f684cce068b58c855a595dd43012688
|
c4a70a2ef03ee4b89b61b4c6d65a3898b1133958
|
/vol124/12469_Stones.cpp
|
a0a7a4921d0ff5c818239919119f4cb4db615963
|
[] |
no_license
|
GonzaloCirilo/UVa
|
40803053f26aba966e95e6d08c44cb6dee294651
|
2f106aa76ef5bb9471b747322302fad3051de7d7
|
refs/heads/master
| 2023-04-13T05:08:57.704904
| 2023-04-06T20:06:09
| 2023-04-06T20:06:09
| 98,001,587
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 348
|
cpp
|
#include <stdio.h>
using namespace std;
bool fibonacci[10001];
void calFibonacci(int prev, int now){
if(prev + now > 1000)
return;
fibonacci[prev + now] = true;
calFibonacci(now, prev + now);
}
int main(){
int n;
calFibonacci(0,1);
while(scanf("%d", &n) != EOF && n){
fibonacci[n]?printf("Roberto\n"):printf("Alicia\n");
}
return 0;
}
|
[
"gonzalo_cirilo@hotmail.com"
] |
gonzalo_cirilo@hotmail.com
|
536493081ee1bf548d92c50db92c0065e3718158
|
5b398ff08cae8a27c1969713ec42cba50eb595e7
|
/DIV-A/2_AntonAndDanik/example.cpp
|
374d81fb6db4dfea54909a40fc0c310e4f2c1e84
|
[] |
no_license
|
ashishlakhani04/_CpToDo
|
7e06c16d444e0b1eb49be8001fda925fc675d36e
|
fa85e1d6644c55ca9fdcdd656193b56f857d760a
|
refs/heads/master
| 2020-03-12T15:34:40.173405
| 2019-01-08T07:44:02
| 2019-01-08T07:44:02
| 130,693,544
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 520
|
cpp
|
#include <iostream>
#include <map>
#define fastio ios_base::sync_with_stdio(false)
#define fastcin cin.tie(NULL)
using namespace std;
int main(){
fastio;
fastcin;
// freopen("small_input.txt", "r", stdin);
// freopen("small_output.txt", "w", stdout);
int n;
cin>>n;
string s;
cin>>s;
map<char,int> m;
for(int i=0;i<s.length();i++){
m[s[i]]++;
}
int a=0,d=0;
a=m['A'];
d=m['D'];
if(a>d){
cout<<"Anton";
}else if(a == d){
cout<<"Friendship";
}else{
cout<<"Danik";
}
}
|
[
"depashlakhani@gmail.com"
] |
depashlakhani@gmail.com
|
721398b2ad4c959e6b5b9f15d8a74537d21568b9
|
e074657c2bc6c11b48b64c07f47ec7981d0a83ad
|
/剑指offer(第二版)/剑指 Offer 03. 数组中重复的数字/solution.cpp
|
b700e82237584101be9670a8d094a8a350e43cea
|
[
"MIT"
] |
permissive
|
LiZhiHao97/algorithm
|
775551f75319bcf094fcdb8e786443894fe3b4a6
|
cdfbfc538b45e3917119853142d1a645cb95d3a2
|
refs/heads/master
| 2022-09-18T18:20:27.093265
| 2022-09-02T06:42:14
| 2022-09-02T06:42:14
| 152,013,668
| 4
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 731
|
cpp
|
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
int findRepeatNumber(vector<int>& nums) {
int n = nums.size();
if (n == 0) {
return -1;
}
for (int i = 0; i < n; i++) {
while (nums[i] != i) {
if (nums[i] == nums[nums[i]]) {
return nums[i];
}
int tmp = nums[i];
nums[i] = nums[tmp];
nums[tmp] = tmp;
}
}
return -1;
}
};
int main() {
vector<int> nums{2, 3, 1, 0, 2, 5, 3};
Solution solution;
int ans = solution.findRepeatNumber(nums);
cout << ans << endl;
}
|
[
"940166841@qq.com"
] |
940166841@qq.com
|
ea46f5d26e692e57c2f020d170125ae1086b462b
|
fcdacd8bdf4da860cdffd92c28e59a4f3591b1f4
|
/图/kruskal.cpp
|
29914d68cc6ac249a057289ededff5a01c54b6ad
|
[] |
no_license
|
yiuyh/MyTemplate
|
73ea13a29f7fe796d4030dcc064d07c54672990b
|
22c0784b95f0a564100d8a90ad8e30e93a2b470b
|
refs/heads/master
| 2020-07-06T19:25:15.962043
| 2019-11-02T11:53:59
| 2019-11-02T11:53:59
| 202,965,269
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 988
|
cpp
|
#include<iostream>
#include<cstdio>
#include<algorithm>
#define maxn 10000+10
using namespace std;
typedef long long ll;
struct node{
int u, v, w;
bool operator <(const node b) const{
return w > b.w;
}
};
node edge[maxn];
int fa[maxn];
int Find(int x){
if(x == fa[x]) return x;
fa[x] = Find(fa[x]);
return fa[x];
}
int main(){
int n, m;
while(~scanf("%d%d", n, m) && n){
for(int i = 1; i <= n; i++) fa[i] = i;
for(int i = 0; i < n; i++){
scanf("%d%d%d", edge[i].u, edge[i].v, edge[i].w);
}
sort(edge, edge+n);
ll sum = 0;
int total = 0;
for(int i = 0; i < n; i++){
int fx = Find(edge[i].u);
int fy = Find(edge[i].v);
if(fx != fy){
fa[fx] = fy;
sum += edge[i].w;
total++;
}
if(total == m-1) printf("%lld\n", sum);
else printf("?\n");
}
}
return 0;
}
|
[
"38040643+yiuyh@users.noreply.github.com"
] |
38040643+yiuyh@users.noreply.github.com
|
86abe9166a246a3c4e84cbd850d2c828c8459169
|
df7d4189cae1e9fb581b7758ee0bc46d0a383799
|
/android/jni/S3DX/S3DXAIVariable.h
|
55c38b6106029e5581c2e3d54911e0b52bf18bb1
|
[] |
no_license
|
error454/ShiVa-Android-All-In-One
|
ea8c97fd939d1aec05b107347524f39ca5a74262
|
1664c1206cba319480cf180e6e135352aefb9b5c
|
refs/heads/master
| 2020-05-17T20:34:46.541077
| 2019-05-16T18:00:28
| 2019-05-16T18:00:28
| 4,881,230
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 81,160
|
h
|
//-----------------------------------------------------------------------------
#ifndef __S3DXAIVariable_h__
#define __S3DXAIVariable_h__
//-----------------------------------------------------------------------------
#include "S3DXTypes.h"
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
namespace S3DX
//-----------------------------------------------------------------------------
{
// Forward declaration for conversion operators
//
template < uint8 _iCount > class AIVariables ;
//-------------------------------------------------------------------------
class AIVariable
{
public :
//---------------------------------------------------------------------
// Constants
//---------------------------------------------------------------------
enum Type
{
eTypeNil = 0x00,
eTypeNumber = 0x01,
eTypeString = 0x02,
eTypeBoolean = 0x03,
eTypeHandle = 0x80
} ;
//---------------------------------------------------------------------
// Constructor / Destructor
//---------------------------------------------------------------------
inline AIVariable ( ) ;
//inline ~AIVariable ( ) ;
inline AIVariable ( const int8 _iValue ) ;
inline AIVariable ( const uint8 _iValue ) ;
inline AIVariable ( const int16 _iValue ) ;
inline AIVariable ( const uint16 _iValue ) ;
inline AIVariable ( const int32 _iValue ) ;
inline AIVariable ( const uint32 _iValue ) ;
inline AIVariable ( const float32 _fValue ) ;
inline AIVariable ( const bool _bValue ) ;
inline AIVariable ( const char *_pValue ) ;
inline AIVariable ( const void *_pValue ) ;
template< uint8 _iCount >
inline AIVariable ( const AIVariables< _iCount > &_oValue ) ;
//---------------------------------------------------------------------
// Accessors
//---------------------------------------------------------------------
inline bool CheckType ( const Type _eType ) const ;
inline bool IsNil ( ) const ;
inline bool IsBoolean ( ) const ;
inline bool IsNumber ( ) const ;
inline bool IsString ( ) const ;
inline bool IsHandle ( ) const ;
inline bool CanConvertToNumber ( ) const ;
inline bool CanConvertToString ( ) const ;
inline Type GetType ( ) const ;
inline bool GetBooleanValue ( ) const ;
inline float32 GetNumberValue ( ) const ;
inline const char *GetStringValue ( ) const ;
inline const void *GetHandleValue ( ) const ;
inline void SetNil ( ) ;
inline void SetBooleanValue ( const bool _bValue ) ;
inline void SetNumberValue ( const float32 _fValue ) ;
inline void SetStringValue ( const char *_pValue ) ;
inline void SetHandleValue ( const void *_pValue ) ;
//---------------------------------------------------------------------
// Misc
//---------------------------------------------------------------------
inline static AIVariable Concat ( const AIVariable &_v0, const AIVariable &_v1 ) ;
//---------------------------------------------------------------------
// Operators
//---------------------------------------------------------------------
inline operator int8 ( ) const ;
inline operator uint8 ( ) const ;
inline operator int16 ( ) const ;
inline operator uint16 ( ) const ;
inline operator int32 ( ) const ;
inline operator uint32 ( ) const ;
inline operator float32 ( ) const ;
inline operator bool ( ) const ;
//???inline operator const char * ( ) const ;
//???inline operator const void * ( ) const ;
inline bool operator ! ( ) const ;
inline AIVariable operator + ( ) const ;
inline AIVariable operator - ( ) const ;
inline AIVariable &operator = ( const int8 _iValue ) ;
inline AIVariable &operator = ( const uint8 _iValue ) ;
inline AIVariable &operator = ( const int16 _iValue ) ;
inline AIVariable &operator = ( const uint16 _iValue ) ;
inline AIVariable &operator = ( const int32 _iValue ) ;
inline AIVariable &operator = ( const uint32 _iValue ) ;
inline AIVariable &operator = ( const float32 _fValue ) ;
inline AIVariable &operator = ( const bool _bValue ) ;
inline AIVariable &operator = ( const char *_pValue ) ;
inline AIVariable &operator = ( const void *_pValue ) ;
inline AIVariable &operator = ( const AIVariable &_vValue ) ;
template< uint8 _iCount >
inline AIVariable &operator = ( const AIVariables< _iCount > &_oValue ) ;
inline AIVariable operator + ( const int8 _iValue ) const ;
inline AIVariable operator + ( const uint8 _iValue ) const ;
inline AIVariable operator + ( const int16 _iValue ) const ;
inline AIVariable operator + ( const uint16 _iValue ) const ;
inline AIVariable operator + ( const int32 _iValue ) const ;
inline AIVariable operator + ( const uint32 _iValue ) const ;
inline AIVariable operator + ( const float32 _fValue ) const ;
inline AIVariable operator + ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline AIVariable operator + ( const AIVariables< _iCount > &_oValue ) ;
inline AIVariable &operator += ( const int8 _iValue ) ;
inline AIVariable &operator += ( const uint8 _iValue ) ;
inline AIVariable &operator += ( const int16 _iValue ) ;
inline AIVariable &operator += ( const uint16 _iValue ) ;
inline AIVariable &operator += ( const int32 _iValue ) ;
inline AIVariable &operator += ( const uint32 _iValue ) ;
inline AIVariable &operator += ( const float32 _fValue ) ;
inline AIVariable &operator += ( const AIVariable &_vValue ) ;
template< uint8 _iCount >
inline AIVariable &operator += ( const AIVariables< _iCount > &_oValue ) ;
inline AIVariable operator - ( const int8 _iValue ) const ;
inline AIVariable operator - ( const uint8 _iValue ) const ;
inline AIVariable operator - ( const int16 _iValue ) const ;
inline AIVariable operator - ( const uint16 _iValue ) const ;
inline AIVariable operator - ( const int32 _iValue ) const ;
inline AIVariable operator - ( const uint32 _iValue ) const ;
inline AIVariable operator - ( const float32 _fValue ) const ;
inline AIVariable operator - ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline AIVariable operator - ( const AIVariables< _iCount > &_oValue ) ;
inline AIVariable &operator -= ( const int8 _iValue ) ;
inline AIVariable &operator -= ( const uint8 _iValue ) ;
inline AIVariable &operator -= ( const int16 _iValue ) ;
inline AIVariable &operator -= ( const uint16 _iValue ) ;
inline AIVariable &operator -= ( const int32 _iValue ) ;
inline AIVariable &operator -= ( const uint32 _iValue ) ;
inline AIVariable &operator -= ( const float32 _fValue ) ;
inline AIVariable &operator -= ( const AIVariable &_vValue ) ;
template< uint8 _iCount >
inline AIVariable &operator -= ( const AIVariables< _iCount > &_oValue ) ;
inline AIVariable operator * ( const int8 _iValue ) const ;
inline AIVariable operator * ( const uint8 _iValue ) const ;
inline AIVariable operator * ( const int16 _iValue ) const ;
inline AIVariable operator * ( const uint16 _iValue ) const ;
inline AIVariable operator * ( const int32 _iValue ) const ;
inline AIVariable operator * ( const uint32 _iValue ) const ;
inline AIVariable operator * ( const float32 _fValue ) const ;
inline AIVariable operator * ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline AIVariable operator * ( const AIVariables< _iCount > &_oValue ) ;
inline AIVariable &operator *= ( const int8 _iValue ) ;
inline AIVariable &operator *= ( const uint8 _iValue ) ;
inline AIVariable &operator *= ( const int16 _iValue ) ;
inline AIVariable &operator *= ( const uint16 _iValue ) ;
inline AIVariable &operator *= ( const int32 _iValue ) ;
inline AIVariable &operator *= ( const uint32 _iValue ) ;
inline AIVariable &operator *= ( const float32 _fValue ) ;
inline AIVariable &operator *= ( const AIVariable &_vValue ) ;
template< uint8 _iCount >
inline AIVariable &operator *= ( const AIVariables< _iCount > &_oValue ) ;
inline AIVariable operator / ( const int8 _iValue ) const ;
inline AIVariable operator / ( const uint8 _iValue ) const ;
inline AIVariable operator / ( const int16 _iValue ) const ;
inline AIVariable operator / ( const uint16 _iValue ) const ;
inline AIVariable operator / ( const int32 _iValue ) const ;
inline AIVariable operator / ( const uint32 _iValue ) const ;
inline AIVariable operator / ( const float32 _fValue ) const ;
inline AIVariable operator / ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline AIVariable operator / ( const AIVariables< _iCount > &_oValue ) ;
inline AIVariable &operator /= ( const int8 _iValue ) ;
inline AIVariable &operator /= ( const uint8 _iValue ) ;
inline AIVariable &operator /= ( const int16 _iValue ) ;
inline AIVariable &operator /= ( const uint16 _iValue ) ;
inline AIVariable &operator /= ( const int32 _iValue ) ;
inline AIVariable &operator /= ( const uint32 _iValue ) ;
inline AIVariable &operator /= ( const float32 _fValue ) ;
inline AIVariable &operator /= ( const AIVariable &_vValue ) ;
template< uint8 _iCount >
inline AIVariable &operator /= ( const AIVariables< _iCount > &_oValue ) ;
inline bool operator < ( const int8 _iValue ) const ;
inline bool operator < ( const uint8 _iValue ) const ;
inline bool operator < ( const int16 _iValue ) const ;
inline bool operator < ( const uint16 _iValue ) const ;
inline bool operator < ( const int32 _iValue ) const ;
inline bool operator < ( const uint32 _iValue ) const ;
inline bool operator < ( const float32 _fValue ) const ;
inline bool operator < ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline bool operator < ( const AIVariables< _iCount > &_oValue ) ;
inline bool operator > ( const int8 _iValue ) const ;
inline bool operator > ( const uint8 _iValue ) const ;
inline bool operator > ( const int16 _iValue ) const ;
inline bool operator > ( const uint16 _iValue ) const ;
inline bool operator > ( const int32 _iValue ) const ;
inline bool operator > ( const uint32 _iValue ) const ;
inline bool operator > ( const float32 _fValue ) const ;
inline bool operator > ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline bool operator > ( const AIVariables< _iCount > &_oValue ) ;
inline bool operator <= ( const int8 _iValue ) const ;
inline bool operator <= ( const uint8 _iValue ) const ;
inline bool operator <= ( const int16 _iValue ) const ;
inline bool operator <= ( const uint16 _iValue ) const ;
inline bool operator <= ( const int32 _iValue ) const ;
inline bool operator <= ( const uint32 _iValue ) const ;
inline bool operator <= ( const float32 _fValue ) const ;
inline bool operator <= ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline bool operator <= ( const AIVariables< _iCount > &_oValue ) ;
inline bool operator >= ( const int8 _iValue ) const ;
inline bool operator >= ( const uint8 _iValue ) const ;
inline bool operator >= ( const int16 _iValue ) const ;
inline bool operator >= ( const uint16 _iValue ) const ;
inline bool operator >= ( const int32 _iValue ) const ;
inline bool operator >= ( const uint32 _iValue ) const ;
inline bool operator >= ( const float32 _fValue ) const ;
inline bool operator >= ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline bool operator >= ( const AIVariables< _iCount > &_oValue ) ;
inline bool operator == ( const int8 _iValue ) const ;
inline bool operator == ( const uint8 _iValue ) const ;
inline bool operator == ( const int16 _iValue ) const ;
inline bool operator == ( const uint16 _iValue ) const ;
inline bool operator == ( const int32 _iValue ) const ;
inline bool operator == ( const uint32 _iValue ) const ;
inline bool operator == ( const float32 _fValue ) const ;
inline bool operator == ( const bool _bValue ) const ;
inline bool operator == ( const char *_pValue ) const ;
inline bool operator == ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline bool operator == ( const AIVariables< _iCount > &_oValue ) ;
inline bool operator != ( const int8 _iValue ) const ;
inline bool operator != ( const uint8 _iValue ) const ;
inline bool operator != ( const int16 _iValue ) const ;
inline bool operator != ( const uint16 _iValue ) const ;
inline bool operator != ( const int32 _iValue ) const ;
inline bool operator != ( const uint32 _iValue ) const ;
inline bool operator != ( const float32 _fValue ) const ;
inline bool operator != ( const bool _bValue ) const ;
inline bool operator != ( const char *_pValue ) const ;
inline bool operator != ( const AIVariable &_vValue ) const ;
template< uint8 _iCount >
inline bool operator != ( const AIVariables< _iCount > &_oValue ) ;
//---------------------------------------------------------------------
// "Special" operators
//---------------------------------------------------------------------
// Bitwise left shift, replacing '..' in Lua
//
inline AIVariable operator << ( const int8 _iValue ) const ;
inline AIVariable operator << ( const uint8 _iValue ) const ;
inline AIVariable operator << ( const int16 _iValue ) const ;
inline AIVariable operator << ( const uint16 _iValue ) const ;
inline AIVariable operator << ( const int32 _iValue ) const ;
inline AIVariable operator << ( const uint32 _iValue ) const ;
inline AIVariable operator << ( const float32 _fValue ) const ;
inline AIVariable operator << ( const AIVariable &_vValue ) const ;
// Bitwise AND replacing 'and' in Lua (DEPRECATED)
//
inline AIVariable operator & ( const int8 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator & ( const uint8 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator & ( const int16 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator & ( const uint16 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator & ( const int32 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator & ( const uint32 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator & ( const float32 _fValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator & ( const bool _bValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator & ( const AIVariable &_vValue ) const ; // DEPRECATED, PLEASE DO NOT USE
// Bitwise OR replacing 'or' in Lua (DEPRECATED)
//
inline AIVariable operator | ( const int8 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator | ( const uint8 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator | ( const int16 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator | ( const uint16 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator | ( const int32 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator | ( const uint32 _iValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator | ( const float32 _fValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator | ( const bool _bValue ) const ; // DEPRECATED, PLEASE DO NOT USE
inline AIVariable operator | ( const AIVariable &_vValue ) const ; // DEPRECATED, PLEASE DO NOT USE
//---------------------------------------------------------------------
// Temporary string buffer access
// Public for some reasons but do *not* use it!!!
//---------------------------------------------------------------------
static char *GetStringPoolBuffer ( const uint32 _iSize ) ;
static char *GetStringPoolBufferAndCopy ( const char *_pString ) ;
static char *GetStringPoolBufferAndCopy ( const uint32 _iSize,
const char *_pString ) ;
private :
//---------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------
inline void SetType ( const Type _eType ) ;
inline bool StringToFloat ( const char *_pString, float32 *_pFloat ) const ;
inline float32 StringToFloat ( const char *_pString ) const ;
inline const char *FloatToString ( float32 _fFloat ) const ;
//---------------------------------------------------------------------
// Variables
//---------------------------------------------------------------------
uint8 iType ;
uint8 iUnused0 ; // For alignment, not actually used
uint16 iUnused1 ; // For alignment, not actually used
union
{
uintptr iUnknownValue ;
bool bBooleanValue ;
float32 fNumberValue ;
const char *pStringValue ;
const void *pHandleValue ;
} ;
//---------------------------------------------------------------------
// Static variables
//---------------------------------------------------------------------
static uint32 iStringPoolCursor ;
static uint32 iStringPoolSize ;
static char *pStringPool ;
} ;
//-------------------------------------------------------------------------
// Constructor / Destructor
//-------------------------------------------------------------------------
inline AIVariable::AIVariable ( )
{
iType = (uint8)eTypeNil ;
iUnknownValue = 0 ;
}
//-------------------------------------------------------------------------
/*
inline AIVariable::~AIVariable ( )
{
iType = (uint8)eTypeNil ;
iUnknownValue = 0 ;
}
*/
//-------------------------------------------------------------------------
inline AIVariable::AIVariable ( const int8 _iValue ) { SetNumberValue ( (float32) _iValue ) ; }
inline AIVariable::AIVariable ( const uint8 _iValue ) { SetNumberValue ( (float32) _iValue ) ; }
inline AIVariable::AIVariable ( const int16 _iValue ) { SetNumberValue ( (float32) _iValue ) ; }
inline AIVariable::AIVariable ( const uint16 _iValue ) { SetNumberValue ( (float32) _iValue ) ; }
inline AIVariable::AIVariable ( const int32 _iValue ) { SetNumberValue ( (float32) _iValue ) ; }
inline AIVariable::AIVariable ( const uint32 _iValue ) { SetNumberValue ( (float32) _iValue ) ; }
inline AIVariable::AIVariable ( const float32 _fValue ) { SetNumberValue ( _fValue ) ; }
inline AIVariable::AIVariable ( const bool _bValue ) { SetBooleanValue ( _bValue ) ; }
inline AIVariable::AIVariable ( const char *_pValue ) { SetStringValue ( _pValue ) ; }
inline AIVariable::AIVariable ( const void *_pValue ) { SetHandleValue ( _pValue ) ; }
template< uint8 _iCount >
inline AIVariable::AIVariable ( const AIVariables< _iCount > &_oValue ) { *this = (const AIVariable &)_oValue ; }
//-------------------------------------------------------------------------
// Misc functions
//-------------------------------------------------------------------------
inline AIVariable AIVariable::Concat ( const AIVariable &_v0, const AIVariable &_v1 )
{
// FIXME: to verify/optimize/...
//
const char *p0 = _v0.GetStringValue ( ) ;
const char *p1 = _v1.GetStringValue ( ) ;
if ( p0 && ! p1 ) return p0 ; // FIXME: return a copy?
if ( p1 && ! p0 ) return p1 ; // FIXME: return a copy?
if ( p0 && p1 )
{
const uint32 iLen0 = S3DX_STRLEN( p0 ) ;
const uint32 iLen1 = S3DX_STRLEN( p1 ) ;
char *pNewStr = GetStringPoolBuffer ( iLen0 + iLen1 + 1 ) ;
if ( pNewStr )
{
S3DX_MEMCPY ( pNewStr, p0, iLen0 ) ;
S3DX_MEMCPY ( pNewStr + iLen0, p1, iLen1 + 1 ) ;
return AIVariable ( pNewStr ) ;
}
}
return AIVariable ( "" ) ;
}
//-------------------------------------------------------------------------
// Private functions
//-------------------------------------------------------------------------
inline bool AIVariable::StringToFloat ( const char *_pString, float32 *_pFloat ) const
{
char *pEndPtr ;
float32 fResult = S3DX_STRTOF( _pString, &pEndPtr ) ;
if ( pEndPtr == _pString ) return false ; // no conversion
while ( S3DX_ISSPACE((unsigned char)(*pEndPtr))) pEndPtr++ ;
if ( *pEndPtr != '\0' ) return false ; // invalid trailing characters
*_pFloat = fResult ;
return true ;
}
//-------------------------------------------------------------------------
inline float32 AIVariable::StringToFloat ( const char *_pString ) const
{
float32 fRet = 0.0f ; StringToFloat ( _pString, &fRet ) ;
return fRet ;
}
//-------------------------------------------------------------------------
inline const char *AIVariable::FloatToString ( float32 _fFloat ) const
{
char *pNewStr = GetStringPoolBuffer ( 32 ) ;
if ( pNewStr )
{
S3DX_SPRINTF( pNewStr, "%g", _fFloat ) ;
return pNewStr;
}
return "" ;
}
//-------------------------------------------------------------------------
// Accessors
//-------------------------------------------------------------------------
inline bool AIVariable::CheckType ( const Type _eType ) const
{
return ( iType == _eType ) ;
}
//-------------------------------------------------------------------------
inline bool AIVariable::IsNil ( ) const
{
return CheckType ( eTypeNil ) ;
}
//-------------------------------------------------------------------------
inline bool AIVariable::IsBoolean ( ) const
{
return CheckType ( eTypeBoolean ) ;
}
//-------------------------------------------------------------------------
inline bool AIVariable::IsNumber ( ) const
{
return CheckType ( eTypeNumber ) ;
}
//-------------------------------------------------------------------------
inline bool AIVariable::IsString ( ) const
{
return CheckType ( eTypeString ) ;
}
//-------------------------------------------------------------------------
inline bool AIVariable::IsHandle ( ) const
{
return CheckType ( eTypeHandle ) ;
}
//-------------------------------------------------------------------------
inline bool AIVariable::CanConvertToNumber ( ) const
{
if ( IsNumber ( ) ) return true ;
if ( IsString ( ) && pStringValue )
{
float32 fDummy ;
return StringToFloat ( pStringValue, &fDummy ) ;
}
return false ;
}
//-------------------------------------------------------------------------
inline bool AIVariable::CanConvertToString ( ) const
{
return IsString ( ) || IsNumber ( ) ;
}
//-------------------------------------------------------------------------
inline AIVariable::Type AIVariable::GetType ( ) const
{
return (Type)iType ;
}
//-------------------------------------------------------------------------
inline bool AIVariable::GetBooleanValue ( ) const
{
return IsBoolean ( ) ? bBooleanValue : ( ! IsNil ( ) ) ;
}
//-------------------------------------------------------------------------
inline float32 AIVariable::GetNumberValue ( ) const
{
return IsNumber ( ) ? fNumberValue : ( ( IsString ( ) && pStringValue ) ? StringToFloat ( pStringValue ) : 0.0f ) ;
}
//-------------------------------------------------------------------------
inline const char *AIVariable::GetStringValue ( ) const
{
return IsString ( ) ? ( pStringValue ? pStringValue : "" ) : ( IsNumber ( ) ? FloatToString ( fNumberValue ) : NULL ) ;
}
//-------------------------------------------------------------------------
inline const void *AIVariable::GetHandleValue ( ) const
{
return IsHandle ( ) ? pHandleValue : NULL ;
}
//-------------------------------------------------------------------------
inline void AIVariable::SetType ( const Type _eType )
{
iType = (uint8)_eType ;
iUnknownValue = 0 ;
}
//-------------------------------------------------------------------------
inline void AIVariable::SetNil ( )
{
SetType ( eTypeNil ) ;
}
//-------------------------------------------------------------------------
inline void AIVariable::SetBooleanValue ( const bool _bValue )
{
SetType ( eTypeBoolean ) ;
bBooleanValue = _bValue ;
}
//-------------------------------------------------------------------------
inline void AIVariable::SetNumberValue ( const float32 _fValue )
{
SetType ( eTypeNumber ) ;
fNumberValue = _fValue ;
}
//-------------------------------------------------------------------------
inline void AIVariable::SetStringValue ( const char *_pValue )
{
SetType ( eTypeString ) ;
pStringValue = _pValue ;
}
//-------------------------------------------------------------------------
inline void AIVariable::SetHandleValue ( const void *_pValue )
{
SetType ( eTypeHandle ) ;
pHandleValue = _pValue ;
}
//-------------------------------------------------------------------------
// Operators
//-------------------------------------------------------------------------
inline AIVariable::operator int8 ( ) const { return (int8) GetNumberValue ( ) ; }
inline AIVariable::operator uint8 ( ) const { return (uint8) GetNumberValue ( ) ; }
inline AIVariable::operator int16 ( ) const { return (int16) GetNumberValue ( ) ; }
inline AIVariable::operator uint16 ( ) const { return (uint16) GetNumberValue ( ) ; }
inline AIVariable::operator int32 ( ) const { return (int32) GetNumberValue ( ) ; }
inline AIVariable::operator uint32 ( ) const { return (uint32) GetNumberValue ( ) ; }
inline AIVariable::operator float32 ( ) const { return (float32) GetNumberValue ( ) ; }
inline AIVariable::operator bool ( ) const { return GetBooleanValue ( ) ; }
//???inline AIVariable::operator const char * ( ) const { return GetStringValue ( ) ; }
//???inline AIVariable::operator const void * ( ) const { return GetHandleValue ( ) ; }
inline bool AIVariable::operator ! ( ) const { return ! GetBooleanValue ( ) ; }
inline AIVariable AIVariable::operator + ( ) const { return *this ; }
inline AIVariable AIVariable::operator - ( ) const { AIVariable v ; v.SetNumberValue ( - fNumberValue ) ; return v ; } // FIXME...
inline AIVariable &AIVariable::operator = ( const int8 _iValue ) { SetNumberValue ( (float32) _iValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const uint8 _iValue ) { SetNumberValue ( (float32) _iValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const int16 _iValue ) { SetNumberValue ( (float32) _iValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const uint16 _iValue ) { SetNumberValue ( (float32) _iValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const int32 _iValue ) { SetNumberValue ( (float32) _iValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const uint32 _iValue ) { SetNumberValue ( (float32) _iValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const float32 _fValue ) { SetNumberValue ( _fValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const bool _bValue ) { SetBooleanValue ( _bValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const char *_pValue ) { SetStringValue ( _pValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const void *_pValue ) { SetHandleValue ( _pValue ) ; return *this ; }
inline AIVariable &AIVariable::operator = ( const AIVariable &_vValue ) { iType =_vValue.iType ; iUnknownValue = _vValue.iUnknownValue ; return *this ; }
template< uint8 _iCount >
inline AIVariable &AIVariable::operator = ( const AIVariables< _iCount > &_oValue ) { return *this = (const AIVariable &)_oValue ; }
inline AIVariable AIVariable::operator + ( const int8 _iValue ) const { return GetNumberValue ( ) + (float32)_iValue ; }
inline AIVariable AIVariable::operator + ( const uint8 _iValue ) const { return GetNumberValue ( ) + (float32)_iValue ; }
inline AIVariable AIVariable::operator + ( const int16 _iValue ) const { return GetNumberValue ( ) + (float32)_iValue ; }
inline AIVariable AIVariable::operator + ( const uint16 _iValue ) const { return GetNumberValue ( ) + (float32)_iValue ; }
inline AIVariable AIVariable::operator + ( const int32 _iValue ) const { return GetNumberValue ( ) + (float32)_iValue ; }
inline AIVariable AIVariable::operator + ( const uint32 _iValue ) const { return GetNumberValue ( ) + (float32)_iValue ; }
inline AIVariable AIVariable::operator + ( const float32 _fValue ) const { return GetNumberValue ( ) + (float32)_fValue ; }
inline AIVariable AIVariable::operator + ( const AIVariable &_vValue ) const { return GetNumberValue ( ) + _vValue.GetNumberValue ( ) ; }
template< uint8 _iCount >
inline AIVariable AIVariable::operator + ( const AIVariables< _iCount > &_oValue ) { return *this + (const AIVariable &)_oValue ; }
inline AIVariable operator + ( const int8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue + _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator + ( const uint8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue + _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator + ( const int16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue + _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator + ( const uint16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue + _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator + ( const int32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue + _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator + ( const uint32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue + _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator + ( const float32 _fValue, const AIVariable &_vVariable ) { return (float32)_fValue + _vVariable.GetNumberValue ( ) ; }
inline AIVariable &AIVariable::operator += ( const int8 _iValue ) { *this = *this + _iValue ; return *this ; }
inline AIVariable &AIVariable::operator += ( const uint8 _iValue ) { *this = *this + _iValue ; return *this ; }
inline AIVariable &AIVariable::operator += ( const int16 _iValue ) { *this = *this + _iValue ; return *this ; }
inline AIVariable &AIVariable::operator += ( const uint16 _iValue ) { *this = *this + _iValue ; return *this ; }
inline AIVariable &AIVariable::operator += ( const int32 _iValue ) { *this = *this + _iValue ; return *this ; }
inline AIVariable &AIVariable::operator += ( const uint32 _iValue ) { *this = *this + _iValue ; return *this ; }
inline AIVariable &AIVariable::operator += ( const float32 _fValue ) { *this = *this + _fValue ; return *this ; }
inline AIVariable &AIVariable::operator += ( const AIVariable &_vValue ) { *this = *this + _vValue ; return *this ; }
template< uint8 _iCount >
inline AIVariable &AIVariable::operator += ( const AIVariables< _iCount > &_oValue ) { return *this += (const AIVariable &)_oValue ; }
inline AIVariable AIVariable::operator - ( const int8 _iValue ) const { return GetNumberValue ( ) - (float32)_iValue ; }
inline AIVariable AIVariable::operator - ( const uint8 _iValue ) const { return GetNumberValue ( ) - (float32)_iValue ; }
inline AIVariable AIVariable::operator - ( const int16 _iValue ) const { return GetNumberValue ( ) - (float32)_iValue ; }
inline AIVariable AIVariable::operator - ( const uint16 _iValue ) const { return GetNumberValue ( ) - (float32)_iValue ; }
inline AIVariable AIVariable::operator - ( const int32 _iValue ) const { return GetNumberValue ( ) - (float32)_iValue ; }
inline AIVariable AIVariable::operator - ( const uint32 _iValue ) const { return GetNumberValue ( ) - (float32)_iValue ; }
inline AIVariable AIVariable::operator - ( const float32 _fValue ) const { return GetNumberValue ( ) - (float32)_fValue ; }
inline AIVariable AIVariable::operator - ( const AIVariable &_vValue ) const { return GetNumberValue ( ) - _vValue.GetNumberValue ( ) ; }
template< uint8 _iCount >
inline AIVariable AIVariable::operator - ( const AIVariables< _iCount > &_oValue ) { return *this - (const AIVariable &)_oValue ; }
inline AIVariable operator - ( const int8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue - _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator - ( const uint8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue - _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator - ( const int16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue - _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator - ( const uint16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue - _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator - ( const int32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue - _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator - ( const uint32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue - _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator - ( const float32 _fValue, const AIVariable &_vVariable ) { return (float32)_fValue - _vVariable.GetNumberValue ( ) ; }
inline AIVariable &AIVariable::operator -= ( const int8 _iValue ) { *this = *this - _iValue ; return *this ; }
inline AIVariable &AIVariable::operator -= ( const uint8 _iValue ) { *this = *this - _iValue ; return *this ; }
inline AIVariable &AIVariable::operator -= ( const int16 _iValue ) { *this = *this - _iValue ; return *this ; }
inline AIVariable &AIVariable::operator -= ( const uint16 _iValue ) { *this = *this - _iValue ; return *this ; }
inline AIVariable &AIVariable::operator -= ( const int32 _iValue ) { *this = *this - _iValue ; return *this ; }
inline AIVariable &AIVariable::operator -= ( const uint32 _iValue ) { *this = *this - _iValue ; return *this ; }
inline AIVariable &AIVariable::operator -= ( const float32 _fValue ) { *this = *this - _fValue ; return *this ; }
inline AIVariable &AIVariable::operator -= ( const AIVariable &_vValue ) { *this = *this - _vValue ; return *this ; }
template< uint8 _iCount >
inline AIVariable &AIVariable::operator -= ( const AIVariables< _iCount > &_oValue ) { return *this -= (const AIVariable &)_oValue ; }
inline AIVariable AIVariable::operator * ( const int8 _iValue ) const { return GetNumberValue ( ) * (float32)_iValue ; }
inline AIVariable AIVariable::operator * ( const uint8 _iValue ) const { return GetNumberValue ( ) * (float32)_iValue ; }
inline AIVariable AIVariable::operator * ( const int16 _iValue ) const { return GetNumberValue ( ) * (float32)_iValue ; }
inline AIVariable AIVariable::operator * ( const uint16 _iValue ) const { return GetNumberValue ( ) * (float32)_iValue ; }
inline AIVariable AIVariable::operator * ( const int32 _iValue ) const { return GetNumberValue ( ) * (float32)_iValue ; }
inline AIVariable AIVariable::operator * ( const uint32 _iValue ) const { return GetNumberValue ( ) * (float32)_iValue ; }
inline AIVariable AIVariable::operator * ( const float32 _fValue ) const { return GetNumberValue ( ) * (float32)_fValue ; }
inline AIVariable AIVariable::operator * ( const AIVariable &_vValue ) const { return GetNumberValue ( ) * _vValue.GetNumberValue ( ) ; }
template< uint8 _iCount >
inline AIVariable AIVariable::operator * ( const AIVariables< _iCount > &_oValue ) { return *this * (const AIVariable &)_oValue ; }
inline AIVariable operator * ( const int8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue * _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator * ( const uint8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue * _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator * ( const int16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue * _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator * ( const uint16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue * _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator * ( const int32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue * _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator * ( const uint32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue * _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator * ( const float32 _fValue, const AIVariable &_vVariable ) { return (float32)_fValue * _vVariable.GetNumberValue ( ) ; }
inline AIVariable &AIVariable::operator *= ( const int8 _iValue ) { *this = *this * _iValue ; return *this ; }
inline AIVariable &AIVariable::operator *= ( const uint8 _iValue ) { *this = *this * _iValue ; return *this ; }
inline AIVariable &AIVariable::operator *= ( const int16 _iValue ) { *this = *this * _iValue ; return *this ; }
inline AIVariable &AIVariable::operator *= ( const uint16 _iValue ) { *this = *this * _iValue ; return *this ; }
inline AIVariable &AIVariable::operator *= ( const int32 _iValue ) { *this = *this * _iValue ; return *this ; }
inline AIVariable &AIVariable::operator *= ( const uint32 _iValue ) { *this = *this * _iValue ; return *this ; }
inline AIVariable &AIVariable::operator *= ( const float32 _fValue ) { *this = *this * _fValue ; return *this ; }
inline AIVariable &AIVariable::operator *= ( const AIVariable &_vValue ) { *this = *this * _vValue ; return *this ; }
template< uint8 _iCount >
inline AIVariable &AIVariable::operator *= ( const AIVariables< _iCount > &_oValue ) { return *this *= (const AIVariable &)_oValue ; }
inline AIVariable AIVariable::operator / ( const int8 _iValue ) const { return GetNumberValue ( ) / (float32)_iValue ; }
inline AIVariable AIVariable::operator / ( const uint8 _iValue ) const { return GetNumberValue ( ) / (float32)_iValue ; }
inline AIVariable AIVariable::operator / ( const int16 _iValue ) const { return GetNumberValue ( ) / (float32)_iValue ; }
inline AIVariable AIVariable::operator / ( const uint16 _iValue ) const { return GetNumberValue ( ) / (float32)_iValue ; }
inline AIVariable AIVariable::operator / ( const int32 _iValue ) const { return GetNumberValue ( ) / (float32)_iValue ; }
inline AIVariable AIVariable::operator / ( const uint32 _iValue ) const { return GetNumberValue ( ) / (float32)_iValue ; }
inline AIVariable AIVariable::operator / ( const float32 _fValue ) const { return GetNumberValue ( ) / (float32)_fValue ; }
inline AIVariable AIVariable::operator / ( const AIVariable &_vValue ) const { return GetNumberValue ( ) / _vValue.GetNumberValue ( ) ; }
template< uint8 _iCount >
inline AIVariable AIVariable::operator / ( const AIVariables< _iCount > &_oValue ) { return *this / (const AIVariable &)_oValue ; }
inline AIVariable operator / ( const int8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue / _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator / ( const uint8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue / _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator / ( const int16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue / _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator / ( const uint16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue / _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator / ( const int32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue / _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator / ( const uint32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue / _vVariable.GetNumberValue ( ) ; }
inline AIVariable operator / ( const float32 _fValue, const AIVariable &_vVariable ) { return (float32)_fValue / _vVariable.GetNumberValue ( ) ; }
inline AIVariable &AIVariable::operator /= ( const int8 _iValue ) { *this = *this / _iValue ; return *this ; }
inline AIVariable &AIVariable::operator /= ( const uint8 _iValue ) { *this = *this / _iValue ; return *this ; }
inline AIVariable &AIVariable::operator /= ( const int16 _iValue ) { *this = *this / _iValue ; return *this ; }
inline AIVariable &AIVariable::operator /= ( const uint16 _iValue ) { *this = *this / _iValue ; return *this ; }
inline AIVariable &AIVariable::operator /= ( const int32 _iValue ) { *this = *this / _iValue ; return *this ; }
inline AIVariable &AIVariable::operator /= ( const uint32 _iValue ) { *this = *this / _iValue ; return *this ; }
inline AIVariable &AIVariable::operator /= ( const float32 _fValue ) { *this = *this / _fValue ; return *this ; }
inline AIVariable &AIVariable::operator /= ( const AIVariable &_vValue ) { *this = *this / _vValue ; return *this ; }
template< uint8 _iCount >
inline AIVariable &AIVariable::operator /= ( const AIVariables< _iCount > &_oValue ) { return *this /= (const AIVariable &)_oValue ; }
inline bool AIVariable::operator < ( const int8 _iValue ) const { return GetNumberValue ( ) < (float32)_iValue ; }
inline bool AIVariable::operator < ( const uint8 _iValue ) const { return GetNumberValue ( ) < (float32)_iValue ; }
inline bool AIVariable::operator < ( const int16 _iValue ) const { return GetNumberValue ( ) < (float32)_iValue ; }
inline bool AIVariable::operator < ( const uint16 _iValue ) const { return GetNumberValue ( ) < (float32)_iValue ; }
inline bool AIVariable::operator < ( const int32 _iValue ) const { return GetNumberValue ( ) < (float32)_iValue ; }
inline bool AIVariable::operator < ( const uint32 _iValue ) const { return GetNumberValue ( ) < (float32)_iValue ; }
inline bool AIVariable::operator < ( const float32 _fValue ) const { return GetNumberValue ( ) < (float32)_fValue ; }
inline bool AIVariable::operator < ( const AIVariable &_vValue ) const { return GetNumberValue ( ) < _vValue.GetNumberValue ( ) ; }
template< uint8 _iCount >
inline bool AIVariable::operator < ( const AIVariables< _iCount > &_oValue ) { return *this < (const AIVariable &)_oValue ; }
inline bool operator < ( const int8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue < _vVariable.GetNumberValue ( ) ; }
inline bool operator < ( const uint8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue < _vVariable.GetNumberValue ( ) ; }
inline bool operator < ( const int16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue < _vVariable.GetNumberValue ( ) ; }
inline bool operator < ( const uint16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue < _vVariable.GetNumberValue ( ) ; }
inline bool operator < ( const int32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue < _vVariable.GetNumberValue ( ) ; }
inline bool operator < ( const uint32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue < _vVariable.GetNumberValue ( ) ; }
inline bool operator < ( const float32 _fValue, const AIVariable &_vVariable ) { return (float32)_fValue < _vVariable.GetNumberValue ( ) ; }
inline bool AIVariable::operator > ( const int8 _iValue ) const { return GetNumberValue ( ) > (float32)_iValue ; }
inline bool AIVariable::operator > ( const uint8 _iValue ) const { return GetNumberValue ( ) > (float32)_iValue ; }
inline bool AIVariable::operator > ( const int16 _iValue ) const { return GetNumberValue ( ) > (float32)_iValue ; }
inline bool AIVariable::operator > ( const uint16 _iValue ) const { return GetNumberValue ( ) > (float32)_iValue ; }
inline bool AIVariable::operator > ( const int32 _iValue ) const { return GetNumberValue ( ) > (float32)_iValue ; }
inline bool AIVariable::operator > ( const uint32 _iValue ) const { return GetNumberValue ( ) > (float32)_iValue ; }
inline bool AIVariable::operator > ( const float32 _fValue ) const { return GetNumberValue ( ) > (float32)_fValue ; }
inline bool AIVariable::operator > ( const AIVariable &_vValue ) const { return GetNumberValue ( ) > _vValue.GetNumberValue ( ) ; }
template< uint8 _iCount >
inline bool AIVariable::operator > ( const AIVariables< _iCount > &_oValue ) { return *this > (const AIVariable &)_oValue ; }
inline bool operator > ( const int8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue > _vVariable.GetNumberValue ( ) ; }
inline bool operator > ( const uint8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue > _vVariable.GetNumberValue ( ) ; }
inline bool operator > ( const int16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue > _vVariable.GetNumberValue ( ) ; }
inline bool operator > ( const uint16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue > _vVariable.GetNumberValue ( ) ; }
inline bool operator > ( const int32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue > _vVariable.GetNumberValue ( ) ; }
inline bool operator > ( const uint32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue > _vVariable.GetNumberValue ( ) ; }
inline bool operator > ( const float32 _fValue, const AIVariable &_vVariable ) { return (float32)_fValue > _vVariable.GetNumberValue ( ) ; }
inline bool AIVariable::operator <= ( const int8 _iValue ) const { return GetNumberValue ( ) <= (float32)_iValue ; }
inline bool AIVariable::operator <= ( const uint8 _iValue ) const { return GetNumberValue ( ) <= (float32)_iValue ; }
inline bool AIVariable::operator <= ( const int16 _iValue ) const { return GetNumberValue ( ) <= (float32)_iValue ; }
inline bool AIVariable::operator <= ( const uint16 _iValue ) const { return GetNumberValue ( ) <= (float32)_iValue ; }
inline bool AIVariable::operator <= ( const int32 _iValue ) const { return GetNumberValue ( ) <= (float32)_iValue ; }
inline bool AIVariable::operator <= ( const uint32 _iValue ) const { return GetNumberValue ( ) <= (float32)_iValue ; }
inline bool AIVariable::operator <= ( const float32 _fValue ) const { return GetNumberValue ( ) <= (float32)_fValue ; }
inline bool AIVariable::operator <= ( const AIVariable &_vValue ) const { return GetNumberValue ( ) <= _vValue.GetNumberValue ( ) ; }
template< uint8 _iCount >
inline bool AIVariable::operator <= ( const AIVariables< _iCount > &_oValue ) { return *this <= (const AIVariable &)_oValue ; }
inline bool operator <= ( const int8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue <= _vVariable.GetNumberValue ( ) ; }
inline bool operator <= ( const uint8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue <= _vVariable.GetNumberValue ( ) ; }
inline bool operator <= ( const int16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue <= _vVariable.GetNumberValue ( ) ; }
inline bool operator <= ( const uint16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue <= _vVariable.GetNumberValue ( ) ; }
inline bool operator <= ( const int32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue <= _vVariable.GetNumberValue ( ) ; }
inline bool operator <= ( const uint32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue <= _vVariable.GetNumberValue ( ) ; }
inline bool operator <= ( const float32 _fValue, const AIVariable &_vVariable ) { return (float32)_fValue <= _vVariable.GetNumberValue ( ) ; }
inline bool AIVariable::operator >= ( const int8 _iValue ) const { return GetNumberValue ( ) >= (float32)_iValue ; }
inline bool AIVariable::operator >= ( const uint8 _iValue ) const { return GetNumberValue ( ) >= (float32)_iValue ; }
inline bool AIVariable::operator >= ( const int16 _iValue ) const { return GetNumberValue ( ) >= (float32)_iValue ; }
inline bool AIVariable::operator >= ( const uint16 _iValue ) const { return GetNumberValue ( ) >= (float32)_iValue ; }
inline bool AIVariable::operator >= ( const int32 _iValue ) const { return GetNumberValue ( ) >= (float32)_iValue ; }
inline bool AIVariable::operator >= ( const uint32 _iValue ) const { return GetNumberValue ( ) >= (float32)_iValue ; }
inline bool AIVariable::operator >= ( const float32 _fValue ) const { return GetNumberValue ( ) >= (float32)_fValue ; }
inline bool AIVariable::operator >= ( const AIVariable &_vValue ) const { return GetNumberValue ( ) >= _vValue.GetNumberValue ( ) ; }
template< uint8 _iCount >
inline bool AIVariable::operator >= ( const AIVariables< _iCount > &_oValue ) { return *this >= (const AIVariable &)_oValue ; }
inline bool operator >= ( const int8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue >= _vVariable.GetNumberValue ( ) ; }
inline bool operator >= ( const uint8 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue >= _vVariable.GetNumberValue ( ) ; }
inline bool operator >= ( const int16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue >= _vVariable.GetNumberValue ( ) ; }
inline bool operator >= ( const uint16 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue >= _vVariable.GetNumberValue ( ) ; }
inline bool operator >= ( const int32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue >= _vVariable.GetNumberValue ( ) ; }
inline bool operator >= ( const uint32 _iValue, const AIVariable &_vVariable ) { return (float32)_iValue >= _vVariable.GetNumberValue ( ) ; }
inline bool operator >= ( const float32 _fValue, const AIVariable &_vVariable ) { return (float32)_fValue >= _vVariable.GetNumberValue ( ) ; }
inline bool AIVariable::operator == ( const int8 _iValue ) const { return IsNumber ( ) ? ( GetNumberValue ( ) == (float32)_iValue ) : false ; }
inline bool AIVariable::operator == ( const uint8 _iValue ) const { return IsNumber ( ) ? ( GetNumberValue ( ) == (float32)_iValue ) : false ; }
inline bool AIVariable::operator == ( const int16 _iValue ) const { return IsNumber ( ) ? ( GetNumberValue ( ) == (float32)_iValue ) : false ; }
inline bool AIVariable::operator == ( const uint16 _iValue ) const { return IsNumber ( ) ? ( GetNumberValue ( ) == (float32)_iValue ) : false ; }
inline bool AIVariable::operator == ( const int32 _iValue ) const { return IsNumber ( ) ? ( GetNumberValue ( ) == (float32)_iValue ) : false ; }
inline bool AIVariable::operator == ( const uint32 _iValue ) const { return IsNumber ( ) ? ( GetNumberValue ( ) == (float32)_iValue ) : false ; }
inline bool AIVariable::operator == ( const float32 _fValue ) const { return IsNumber ( ) ? ( GetNumberValue ( ) == (float32)_fValue ) : false ; }
inline bool AIVariable::operator == ( const bool _bValue ) const { return IsBoolean ( ) ? ( GetBooleanValue ( ) == _bValue ) : false ; }
inline bool AIVariable::operator == ( const char *_pValue ) const { return CanConvertToString ( ) ? ( S3DX_STREQ( GetStringValue ( ), _pValue ) ) : false ; }
inline bool AIVariable::operator == ( const AIVariable &_vValue ) const { return ( iType == _vValue.iType ) && ( IsString ( ) ? ( S3DX_STREQ( GetStringValue ( ), _vValue.GetStringValue ( ) ) ) : ( iUnknownValue == _vValue.iUnknownValue ) ) ; }
template< uint8 _iCount >
inline bool AIVariable::operator == ( const AIVariables< _iCount > &_oValue ) { return *this == (const AIVariable &)_oValue ; }
inline bool operator == ( const int8 _iValue, const AIVariable &_vVariable ) { return _vVariable == _iValue ; }
inline bool operator == ( const uint8 _iValue, const AIVariable &_vVariable ) { return _vVariable == _iValue ; }
inline bool operator == ( const int16 _iValue, const AIVariable &_vVariable ) { return _vVariable == _iValue ; }
inline bool operator == ( const uint16 _iValue, const AIVariable &_vVariable ) { return _vVariable == _iValue ; }
inline bool operator == ( const int32 _iValue, const AIVariable &_vVariable ) { return _vVariable == _iValue ; }
inline bool operator == ( const uint32 _iValue, const AIVariable &_vVariable ) { return _vVariable == _iValue ; }
inline bool operator == ( const float32 _fValue, const AIVariable &_vVariable ) { return _vVariable == _fValue ; }
inline bool operator == ( const bool _bValue, const AIVariable &_vVariable ) { return _vVariable == _bValue ; }
inline bool operator == ( const char *_pValue, const AIVariable &_vVariable ) { return _vVariable == _pValue ; }
inline bool AIVariable::operator != ( const int8 _iValue ) const { return ! ( *this == _iValue ) ; }
inline bool AIVariable::operator != ( const uint8 _iValue ) const { return ! ( *this == _iValue ) ; }
inline bool AIVariable::operator != ( const int16 _iValue ) const { return ! ( *this == _iValue ) ; }
inline bool AIVariable::operator != ( const uint16 _iValue ) const { return ! ( *this == _iValue ) ; }
inline bool AIVariable::operator != ( const int32 _iValue ) const { return ! ( *this == _iValue ) ; }
inline bool AIVariable::operator != ( const uint32 _iValue ) const { return ! ( *this == _iValue ) ; }
inline bool AIVariable::operator != ( const float32 _fValue ) const { return ! ( *this == _fValue ) ; }
inline bool AIVariable::operator != ( const bool _bValue ) const { return ! ( *this == _bValue ) ; }
inline bool AIVariable::operator != ( const char *_pValue ) const { return ! ( *this == _pValue ) ; }
inline bool AIVariable::operator != ( const AIVariable &_vValue ) const { return ! ( *this == _vValue ) ; }
template< uint8 _iCount >
inline bool AIVariable::operator != ( const AIVariables< _iCount > &_oValue ) { return *this != (const AIVariable &)_oValue ; }
inline bool operator != ( const int8 _iValue, const AIVariable &_vVariable ) { return _vVariable != _iValue ; }
inline bool operator != ( const uint8 _iValue, const AIVariable &_vVariable ) { return _vVariable != _iValue ; }
inline bool operator != ( const int16 _iValue, const AIVariable &_vVariable ) { return _vVariable != _iValue ; }
inline bool operator != ( const uint16 _iValue, const AIVariable &_vVariable ) { return _vVariable != _iValue ; }
inline bool operator != ( const int32 _iValue, const AIVariable &_vVariable ) { return _vVariable != _iValue ; }
inline bool operator != ( const uint32 _iValue, const AIVariable &_vVariable ) { return _vVariable != _iValue ; }
inline bool operator != ( const float32 _fValue, const AIVariable &_vVariable ) { return _vVariable != _fValue ; }
inline bool operator != ( const bool _bValue, const AIVariable &_vVariable ) { return _vVariable != _bValue ; }
inline bool operator != ( const char *_pValue, const AIVariable &_vVariable ) { return _vVariable != _pValue ; }
//-------------------------------------------------------------------------
// "Special" operators
//-------------------------------------------------------------------------
inline AIVariable AIVariable::operator << ( const int8 _iValue ) const { return Concat( *this, AIVariable( _iValue ) ) ; }
inline AIVariable AIVariable::operator << ( const uint8 _iValue ) const { return Concat( *this, AIVariable( _iValue ) ) ; }
inline AIVariable AIVariable::operator << ( const int16 _iValue ) const { return Concat( *this, AIVariable( _iValue ) ) ; }
inline AIVariable AIVariable::operator << ( const uint16 _iValue ) const { return Concat( *this, AIVariable( _iValue ) ) ; }
inline AIVariable AIVariable::operator << ( const int32 _iValue ) const { return Concat( *this, AIVariable( _iValue ) ) ; }
inline AIVariable AIVariable::operator << ( const uint32 _iValue ) const { return Concat( *this, AIVariable( _iValue ) ) ; }
inline AIVariable AIVariable::operator << ( const float32 _fValue ) const { return Concat( *this, AIVariable( _fValue ) ) ; }
inline AIVariable AIVariable::operator << ( const AIVariable &_vValue ) const { return Concat( *this, _vValue ) ; }
inline AIVariable operator << ( const char *_pValue,
const AIVariable &_vValue ) { return AIVariable::Concat( _pValue, _vValue ) ; }
// DEPRECATED. Code kept for emergency cases ;)
/*
inline AIVariable AIVariable::operator & ( const int8 _iValue ) const { return bool(*this) ? AIVariable( _iValue ) : *this ; }
inline AIVariable AIVariable::operator & ( const uint8 _iValue ) const { return bool(*this) ? AIVariable( _iValue ) : *this ; }
inline AIVariable AIVariable::operator & ( const int16 _iValue ) const { return bool(*this) ? AIVariable( _iValue ) : *this ; }
inline AIVariable AIVariable::operator & ( const uint16 _iValue ) const { return bool(*this) ? AIVariable( _iValue ) : *this ; }
inline AIVariable AIVariable::operator & ( const int32 _iValue ) const { return bool(*this) ? AIVariable( _iValue ) : *this ; }
inline AIVariable AIVariable::operator & ( const uint32 _iValue ) const { return bool(*this) ? AIVariable( _iValue ) : *this ; }
inline AIVariable AIVariable::operator & ( const float32 _fValue ) const { return bool(*this) ? AIVariable( _fValue ) : *this ; }
inline AIVariable AIVariable::operator & ( const bool _bValue ) const { return bool(*this) ? AIVariable( _bValue ) : *this ; }
inline AIVariable AIVariable::operator & ( const AIVariable &_vValue ) const { return bool(*this) ? _vValue : *this ; }
inline AIVariable AIVariable::operator | ( const int8 _iValue ) const { return bool(*this) ? *this : AIVariable( _iValue ) ; }
inline AIVariable AIVariable::operator | ( const uint8 _iValue ) const { return bool(*this) ? *this : AIVariable( _iValue ) ; }
inline AIVariable AIVariable::operator | ( const int16 _iValue ) const { return bool(*this) ? *this : AIVariable( _iValue ) ; }
inline AIVariable AIVariable::operator | ( const uint16 _iValue ) const { return bool(*this) ? *this : AIVariable( _iValue ) ; }
inline AIVariable AIVariable::operator | ( const int32 _iValue ) const { return bool(*this) ? *this : AIVariable( _iValue ) ; }
inline AIVariable AIVariable::operator | ( const uint32 _iValue ) const { return bool(*this) ? *this : AIVariable( _iValue ) ; }
inline AIVariable AIVariable::operator | ( const float32 _fValue ) const { return bool(*this) ? *this : AIVariable( _fValue ) ; }
inline AIVariable AIVariable::operator | ( const bool _bValue ) const { return bool(*this) ? *this : AIVariable( _bValue ) ; }
inline AIVariable AIVariable::operator | ( const AIVariable &_vValue ) const { return bool(*this) ? *this : _vValue ; }
*/
//-------------------------------------------------------------------------
// "nil" constant definition
//
#ifdef nil
#undef nil
#endif
const AIVariable nil = AIVariable ( ) ;
//-------------------------------------------------------------------------
// Macro to call when developing a plugin that needs string operations.
// Note that this implementation is trivial but sufficient in most if not
// all cases. The main advantage is that there is nothing faster :)
// Increase __size value if you encounter problems while manipulating long
// strings. A value of 524288 should largely be enough.
//
#if (defined S3DX_DLL) || (defined S3DX_DISCRETE_STRING_POOL)
#define S3DX_IMPLEMENT_AIVARIABLE_STRING_POOL( __size ) \
\
static char __aStringPool [__size] = "" ; \
S3DX::uint32 S3DX::AIVariable::iStringPoolCursor = 0 ; \
S3DX::uint32 S3DX::AIVariable::iStringPoolSize = __size ; \
char *S3DX::AIVariable::pStringPool = __aStringPool ; \
\
char *S3DX::AIVariable::GetStringPoolBuffer ( const S3DX::uint32 _iSize ) \
{ \
if ( iStringPoolCursor + _iSize > iStringPoolSize ) \
{ \
if ( _iSize > iStringPoolSize ) \
{ \
return NULL ; \
} \
iStringPoolCursor = 0 ; \
} \
char *pRet = pStringPool + iStringPoolCursor ; iStringPoolCursor += _iSize ; \
return pRet ; \
}
#else
#define S3DX_IMPLEMENT_AIVARIABLE_STRING_POOL( __size )
#endif
//-------------------------------------------------------------------------
// Macros defining the Lua compliant 'and' and 'or' operators.
// They are provided for C++ AIModels, and cannot be used in dynamically linked plug-ins,
// unless you define S3DX::__lua_and_helper and/or S3DX::__lua_or_helper in your code.
// Anyways it is better to use C++ '&&' and '||' operators whenever possible for speed.
//
extern S3DX::AIVariable __lua_and_helper ;
extern S3DX::AIVariable __lua_or_helper ;
#define S3DX_LUA_AND( __a__, __b__ ) ((S3DX::__lua_and_helper=(__a__)).GetBooleanValue()?S3DX::AIVariable(__b__):S3DX::__lua_and_helper)
#define S3DX_LUA_OR( __a__, __b__ ) ((S3DX::__lua_or_helper =(__a__)).GetBooleanValue()?S3DX::__lua_or_helper:S3DX::AIVariable(__b__))
#define S3DX_CPP_AND( __a__, __b__ ) ((S3DX::AIVariable(__a__)).GetBooleanValue() && (S3DX::AIVariable(__b__)).GetBooleanValue())
#define S3DX_CPP_OR( __a__, __b__ ) ((S3DX::AIVariable(__a__)).GetBooleanValue() || (S3DX::AIVariable(__b__)).GetBooleanValue())
#define S3DX_DEFAULT_AND S3DX_LUA_AND
#define S3DX_DEFAULT_OR S3DX_LUA_OR
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#endif
//-----------------------------------------------------------------------------
|
[
"zachary.burke@gmail.com"
] |
zachary.burke@gmail.com
|
c553a275766ffdb99804f9a6b561c722eae2ec35
|
d1cf34b4d5280e33ebcf1cd788b470372fdd5a26
|
/leetcode/weekly-261/2030.cpp
|
fa3786ee2ea8f74686079b492fa5a4386c181108
|
[] |
no_license
|
watashi/AlgoSolution
|
985916ac511892b7e87f38c9b364069f6b51a0ea
|
bbbebda189c7e74edb104615f9c493d279e4d186
|
refs/heads/master
| 2023-08-17T17:25:10.748003
| 2023-08-06T04:34:19
| 2023-08-06T04:34:19
| 2,525,282
| 97
| 32
| null | 2020-10-09T18:52:29
| 2011-10-06T10:40:07
|
C++
|
UTF-8
|
C++
| false
| false
| 825
|
cpp
|
class Solution {
public:
string smallestSubsequence(string s, int k, char letter, int repetition) {
int n = (int)s.size();
vector<int> cnt(n + 1, 0);
vector<vector<int>> next(n + 1);
next[n] = vector<int>(26, n);
for (int i = n - 1; i >= 0; --i) {
cnt[i] = cnt[i + 1] + (s[i] == letter ? 1 : 0);
next[i] = next[i + 1];
next[i][s[i] - 'a'] = i;
}
int pos = 0;
string ans;
for (int i = k - 1; i >= 0; --i) {
for (int c = 0; c < 26; ++c) {
int newpos = next[pos][c] + 1;
int newrep = repetition - (c == letter - 'a' ? 1 : 0);
if (n - newpos >= i && cnt[newpos] >= newrep && newrep <= i) {
ans += (char)('a' + c);
pos = newpos;
repetition = newrep;
break;
}
}
}
return ans;
}
};
|
[
"watashi@watashi.ws"
] |
watashi@watashi.ws
|
07623720af4f71b420f42b15c7eb69a94c23fc28
|
091af7eabed99cc72dfe1dbb54f109957d83b9f2
|
/360Lib-5.0/.svn/pristine/07/07623720af4f71b420f42b15c7eb69a94c23fc28.svn-base
|
73630a8a216e99f1995b42bfd25dc8c89f961252
|
[] |
no_license
|
iagostorch/HM-16.16_360_InterOpt
|
a2b723aaf3ce94a223f839152e31202282cad58f
|
330c0690b07e5afa35a591186308113d8e6d647f
|
refs/heads/master
| 2023-08-05T11:52:29.701813
| 2021-09-22T14:18:09
| 2021-09-22T14:18:09
| 169,303,453
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,472
|
/* The copyright in this software is being made available under the BSD
* License, included below. This software may be subject to other third party
* and contributor rights, including patent rights, and no such rights are
* granted under this license.
*
* Copyright (c) 2010-2015, ITU/ISO/IEC
* 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 ITU/ISO/IEC nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/** \file TEquatorialCylindrical.cpp
\brief TEquatorialCylindrical class
*/
#include <assert.h>
#include <math.h>
#include "TEquatorialCylindrical.h"
#if EXTENSION_360_VIDEO
#if SVIDEO_EQUATORIAL_CYLINDRICAL
/*************************************
Cubemap geometry related functions;
**************************************/
TEquatorialCylindrical::TEquatorialCylindrical(SVideoInfo& sVideoInfo, InputGeoParam *pInGeoParam) : TCubeMap(sVideoInfo, pInGeoParam)
{
assert(sVideoInfo.geoType == SVIDEO_EQUATORIALCYLINDRICAL);
assert(sVideoInfo.iNumFaces == 6);
}
TEquatorialCylindrical::~TEquatorialCylindrical()
{
}
/********************
face order:
PX: 0
NX: 1
PY: 2
NY: 3
PZ: 4
NZ: 5
********************/
Void TEquatorialCylindrical::map2DTo3D(SPos& IPosIn, SPos *pSPosOut)
{
POSType u, v;
POSType square = m_sVideoInfo.iFaceHeight;
POSType x, y, sqc;
POSType pitch, yaw;
u = IPosIn.x + (POSType)(0.5);
v = IPosIn.y + (POSType)(0.5);
u = (POSType)((2.0*u)/m_sVideoInfo.iFaceWidth-1.0);
v = (POSType)((2.0*v)/m_sVideoInfo.iFaceHeight-1.0);
Double ecpad_margin = 4.0;
Double ecpad_factor = 1.0 + 2.0*ecpad_margin/(m_sVideoInfo.iFaceWidth - 2.0*ecpad_margin);
Double ecpad_factor2 = m_sVideoInfo.iFaceWidth/(m_sVideoInfo.iFaceWidth - ecpad_margin);
switch(IPosIn.faceIdx)
{
case 0:
u *= ecpad_factor;
v = v*ecpad_factor2 + ecpad_factor2 - 1.0;
break;
case 1:
u *= ecpad_factor;
v = v*ecpad_factor2 - ecpad_factor2 + 1.0;
break;
case 2:
u = u*ecpad_factor2 - ecpad_factor2 + 1.0;
v *= ecpad_factor;
break;
case 3:
v *= ecpad_factor;
break;
case 4:
u = u*ecpad_factor2 + ecpad_factor2 - 1.0;
v *= ecpad_factor;
break;
case 5:
u *= ecpad_factor;
break;
default:
assert(!"Error ECP::map2DTo3D()");
break;
}
POSType pole_x, pole_y, pole_d;
if (IPosIn.faceIdx == 0)
{
Double b = 0.2;
Double cu = 1.0 + tanh((-v - 1.0)/b);
x = stan(satan(cu)*u)/cu;
y = v;
sqc = ssqrt(x*x + y*y - x*x*y*y) / ssqrt(x*x + y*y);
u = (x == 0 && y == 0) ? 0 : x * sqc;
v = (x == 0 && y == 0) ? 0 : y * sqc;
pole_x = u*m_sVideoInfo.iFaceWidth/2.0;
pole_y = v*m_sVideoInfo.iFaceHeight/2.0;
pole_d = ssqrt(pole_x*pole_x + pole_y*pole_y);
yaw = (pole_d > 0) ? acos(pole_y / pole_d) : 0;
yaw = (pole_x < 0) ? S_PI*2 - yaw : yaw;
pitch = S_PI_2 - 2.0 * pole_d * (S_PI_2 - sasin(2.0/3.0)) / square;
yaw -= S_PI/4.0;
}
else if (IPosIn.faceIdx == 1)
{
Double b = 0.2;
Double cu = 1.0 + tanh((v - 1.0)/b);
x = stan(satan(cu)*u)/cu;
y = v;
sqc = ssqrt(x*x + y*y - x*x*y*y) / ssqrt(x*x + y*y);
u = (x == 0 && y == 0) ? 0 : x * sqc;
v = (x == 0 && y == 0) ? 0 : y * sqc;
pole_x = u*m_sVideoInfo.iFaceWidth/2.0;
pole_y = v*m_sVideoInfo.iFaceHeight/2.0;
pole_d = ssqrt(pole_x*pole_x + pole_y*pole_y);
yaw = (pole_d > 0) ? satan2(pole_y, pole_x) + S_PI_2 : 0;
pitch = 2.0 * pole_d * (S_PI_2 - sasin(2.0/3.0)) / square - S_PI_2;
yaw -= S_PI/4.0;
}
else if (IPosIn.faceIdx == 2)
{
yaw = (POSType)((u - 3.0)*S_PI_2/2.0);
pitch = (POSType)sasin((POSType)(2.0*(-v)/3.0));
}
else if (IPosIn.faceIdx == 3)
{
yaw = (POSType)((u - 1.0)*S_PI_2/2.0);
pitch = (POSType)sasin((POSType)(2.0*(-v)/3.0));
}
else if (IPosIn.faceIdx == 4)
{
yaw = (POSType)((u + 1.0)*S_PI_2/2.0);
pitch = (POSType)sasin((POSType)(2.0*(-v)/3.0));
}
else if (IPosIn.faceIdx == 5)
{
yaw = (POSType)((u + 3.0)*S_PI_2/2.0);
pitch = (POSType)sasin((POSType)(2.0*(-v)/3.0));
}
else
{
assert(!"Face index Error!\n");
}
pSPosOut->faceIdx = IPosIn.faceIdx;
pSPosOut->x = (POSType)(scos(pitch)*scos(yaw));
pSPosOut->y = (POSType)(ssin(pitch));
pSPosOut->z = -(POSType)(scos(pitch)*ssin(yaw));
}
Void TEquatorialCylindrical::map3DTo2D(SPos *pSPosIn, SPos *pSPosOut)
{
POSType x = pSPosIn->x;
POSType y = pSPosIn->y;
POSType z = pSPosIn->z;
POSType px, py, u, v, w, sgn;
POSType len = ssqrt(x*x + y*y + z*z);
POSType yaw = (POSType)(satan2(-z, x));
POSType pitch = (POSType)(sasin(y / len));
pSPosOut->z = 0;
if (y > len*2.0/3.0)
{
pSPosOut->faceIdx = 0;
yaw += S_PI/4.0;
u = ssin(yaw)*(S_PI_2 - pitch)/(S_PI_2 - sasin(2.0/3.0));
v = scos(yaw)*(S_PI_2 - pitch)/(S_PI_2 - sasin(2.0/3.0));
sgn = (u*v >= 0.0) ? 1.0 : -1.0;
w = sgn / ssqrt(2) * ssqrt(u*u + v*v - ssqrt((u*u + v*v)*(u*u + v*v - 4*u*u*v*v)));
if (sfabs(w) > S_EPS)
{
px = (v != 0) ? w / v : 0;
py = (u != 0) ? w / u : 0;
}
else
{
px = u;
py = v;
}
Double b = 0.2;
Double cx = 1.0 + tanh((-py - 1.0)/b);
x = satan(cx*px)/satan(cx);
y = py;
}
else if (y < -len*2.0/3.0)
{
pSPosOut->faceIdx = 1;
yaw += S_PI/4.0;
u = ssin(yaw)*(S_PI_2 + pitch)/(S_PI_2 - sasin(2.0/3.0));
v = (-scos(yaw)*(S_PI_2 + pitch)/(S_PI_2 - sasin(2.0/3.0)));
sgn = (u*v >= 0.0) ? 1.0 : -1.0;
w = sgn / ssqrt(2) * ssqrt(u*u + v*v - ssqrt((u*u + v*v)*(u*u + v*v - 4*u*u*v*v)));
if (sfabs(w) > S_EPS)
{
px = (v != 0) ? w / v : 0;
py = (u != 0) ? w / u : 0;
}
else
{
px = u;
py = v;
}
Double b = 0.2;
Double cx = 1.0 + tanh((py - 1.0)/b);
x = satan(cx*px)/satan(cx);
y = py;
}
else if (z >= 0 && x < 0)
{
pSPosOut->faceIdx = 2;
x = 4.0*yaw/S_PI + 3.0;
y = -3.0*ssin(pitch)/2.0;
}
else if (z > 0 && x >= 0)
{
pSPosOut->faceIdx = 3;
x = 4.0*yaw/S_PI + 1.0;
y = -3.0*ssin(pitch)/2.0;
}
else if (z <= 0 && x > 0)
{
pSPosOut->faceIdx = 4;
x = 4.0*yaw/S_PI - 1.0;
y = -3.0*ssin(pitch)/2.0;
}
else if (z < 0 && x <= 0)
{
pSPosOut->faceIdx = 5;
x = 4.0*yaw/S_PI - 3.0;
y = -3.0*ssin(pitch)/2.0;
}
Double ecpad_margin = 4.0;
Double ecpad_factor = 1.0 + 2.0*ecpad_margin/(m_sVideoInfo.iFaceWidth - 2.0*ecpad_margin);
Double ecpad_factor2 = m_sVideoInfo.iFaceWidth/(m_sVideoInfo.iFaceWidth - ecpad_margin);
switch(pSPosOut->faceIdx)
{
case 0:
x /= ecpad_factor;
y = (y - ecpad_factor2 + 1.0)/ecpad_factor2;
break;
case 1:
x /= ecpad_factor;
y = (y + ecpad_factor2 - 1.0)/ecpad_factor2;
break;
case 2:
x = (x + ecpad_factor2 - 1.0)/ecpad_factor2;
y /= ecpad_factor;
break;
case 3:
y /= ecpad_factor;
break;
case 4:
x = (x - ecpad_factor2 + 1.0)/ecpad_factor2;
y /= ecpad_factor;
break;
case 5:
x /= ecpad_factor;
break;
default:
assert(!"Error ECP::map3DTo2D()");
break;
}
pSPosOut->x = (x + 1.0)*m_sVideoInfo.iFaceWidth/2.0 - 0.5;
pSPosOut->y = (y + 1.0)*m_sVideoInfo.iFaceHeight/2.0 - 0.5;
}
#endif
#endif
|
[
"icstorch@inf.ufpel.edu.br"
] |
icstorch@inf.ufpel.edu.br
|
|
304247d2915805c324a919a1874db4ef46c00440
|
e51512b5c3a112a0cdae2c0eb2a69a5d24460996
|
/src/teapot.cc
|
7bb4bdca9802eb7d833d5aaec4cc746d3f18e50f
|
[] |
no_license
|
DiegoAlfaroV/04MVID2018_EJ
|
1b534e8903205a019e6cfae0f067af5bc07ef2f2
|
b422e2771eace344de16845bba1b984463cf6274
|
refs/heads/master
| 2020-04-24T03:19:28.381710
| 2019-02-20T12:16:36
| 2019-02-20T12:16:36
| 171,666,761
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,344
|
cc
|
#include "teapot.h"
#include "teapotdata.h"
#include <cstdio>
#include <glm/gtc/matrix_transform.hpp>
Teapot::Teapot() {}
Teapot::~Teapot() {
glDeleteVertexArrays(1, &_vao);
glDeleteBuffers(4, vbo);
}
void Teapot::Init(int grid, glm::mat4 lidTransform) {
int verts = 32 * (grid + 1) * (grid + 1);
faces = grid * grid * 32;
float * v = new float[verts * 3];
float * n = new float[verts * 3];
float * tc = new float[verts * 2];
unsigned int * el = new unsigned int[faces * 6];
glGenVertexArrays(1, &_vao);
glBindVertexArray(_vao);
glGenBuffers(4, vbo);
generatePatches(v, n, tc, el, grid);
moveLid(grid, v, lidTransform);
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
glBufferData(GL_ARRAY_BUFFER, (3 * verts) * sizeof(float), v, GL_STATIC_DRAW);
glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, ((GLubyte *)NULL + (0)));
glEnableVertexAttribArray(0); // Vertex position
glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
glBufferData(GL_ARRAY_BUFFER, (3 * verts) * sizeof(float), n, GL_STATIC_DRAW);
glVertexAttribPointer((GLuint)1, 3, GL_FLOAT, GL_FALSE, 0, ((GLubyte *)NULL + (0)));
glEnableVertexAttribArray(1); // Vertex normal
glBindBuffer(GL_ARRAY_BUFFER, vbo[2]);
glBufferData(GL_ARRAY_BUFFER, (2 * verts) * sizeof(float), tc, GL_STATIC_DRAW);
glVertexAttribPointer((GLuint)2, 2, GL_FLOAT, GL_FALSE, 0, ((GLubyte *)NULL + (0)));
glEnableVertexAttribArray(2); // texture coords
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo[3]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6 * faces * sizeof(unsigned int), el, GL_STATIC_DRAW);
delete[] v;
delete[] n;
delete[] el;
delete[] tc;
glBindVertexArray(0);
}
void Teapot::generatePatches(float * v, float * n, float * tc, unsigned int* el, int grid) {
float * B = new float[4 * (grid + 1)]; // Pre-computed Bernstein basis functions
float * dB = new float[4 * (grid + 1)]; // Pre-computed derivitives of basis functions
int idx = 0, elIndex = 0, tcIndex = 0;
// Pre-compute the basis functions (Bernstein polynomials) and their derivatives
computeBasisFunctions(B, dB, grid);
// The rim
buildPatchReflect(0, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, true, true);
// The body
buildPatchReflect(1, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, true, true);
buildPatchReflect(2, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, true, true);
// The lid
buildPatchReflect(3, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, true, true);
buildPatchReflect(4, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, true, true);
// The bottom
buildPatchReflect(5, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, true, true);
// The handle
buildPatchReflect(6, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, false, true);
buildPatchReflect(7, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, false, true);
// The spout
buildPatchReflect(8, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, false, true);
buildPatchReflect(9, B, dB, v, n, tc, el, idx, elIndex, tcIndex, grid, false, true);
delete[] B;
delete[] dB;
}
void Teapot::moveLid(int grid, float *v, glm::mat4 lidTransform) {
int start = 3 * 12 * (grid + 1) * (grid + 1);
int end = 3 * 20 * (grid + 1) * (grid + 1);
for (int i = start; i < end; i += 3) {
glm::vec4 vert = glm::vec4(v[i], v[i + 1], v[i + 2], 1.0f);
vert = lidTransform * vert;
v[i] = vert.x;
v[i + 1] = vert.y;
v[i + 2] = vert.z;
}
}
void Teapot::buildPatchReflect(int patchNum, float *B, float *dB,
float *v, float *n,
float *tc, unsigned int *el,
int &index, int &elIndex, int &tcIndex, int grid,
bool reflectX, bool reflectY)
{
glm::vec3 patch[4][4];
glm::vec3 patchRevV[4][4];
getPatch(patchNum, patch, false);
getPatch(patchNum, patchRevV, true);
// Patch without modification
buildPatch(patch, B, dB, v, n, tc, el, index, elIndex, tcIndex, grid, glm::mat3(1.0f), true);
// Patch reflected in x
if (reflectX) {
buildPatch(patchRevV, B, dB, v, n, tc, el,
index, elIndex, tcIndex, grid, glm::mat3(glm::vec3(-1.0f, 0.0f, 0.0f),
glm::vec3(0.0f, 1.0f, 0.0f),
glm::vec3(0.0f, 0.0f, 1.0f)), false);
}
// Patch reflected in y
if (reflectY) {
buildPatch(patchRevV, B, dB, v, n, tc, el,
index, elIndex, tcIndex, grid, glm::mat3(glm::vec3(1.0f, 0.0f, 0.0f),
glm::vec3(0.0f, -1.0f, 0.0f),
glm::vec3(0.0f, 0.0f, 1.0f)), false);
}
// Patch reflected in x and y
if (reflectX && reflectY) {
buildPatch(patch, B, dB, v, n, tc, el,
index, elIndex, tcIndex, grid, glm::mat3(glm::vec3(-1.0f, 0.0f, 0.0f),
glm::vec3(0.0f, -1.0f, 0.0f),
glm::vec3(0.0f, 0.0f, 1.0f)), true);
}
}
void Teapot::buildPatch(glm::vec3 patch[][4], float *B, float *dB,
float *v, float *n, float *tc,
unsigned int *el,
int &index, int &elIndex, int &tcIndex, int grid, glm::mat3 reflect,
bool invertNormal)
{
int startIndex = index / 3;
float tcFactor = 1.0f / grid;
for (int i = 0; i <= grid; i++) {
for (int j = 0; j <= grid; j++) {
glm::vec3 pt = reflect * evaluate(i, j, B, patch);
glm::vec3 norm = reflect * evaluateNormal(i, j, B, dB, patch);
if (invertNormal)
norm = -norm;
v[index] = pt.x;
v[index + 1] = pt.y;
v[index + 2] = pt.z;
n[index] = norm.x;
n[index + 1] = norm.y;
n[index + 2] = norm.z;
tc[tcIndex] = i * tcFactor;
tc[tcIndex + 1] = j * tcFactor;
index += 3;
tcIndex += 2;
}
}
for (int i = 0; i < grid; i++) {
int iStart = i * (grid + 1) + startIndex;
int nextiStart = (i + 1) * (grid + 1) + startIndex;
for (int j = 0; j < grid; j++)
{
el[elIndex] = iStart + j;
el[elIndex + 1] = nextiStart + j + 1;
el[elIndex + 2] = nextiStart + j;
el[elIndex + 3] = iStart + j;
el[elIndex + 4] = iStart + j + 1;
el[elIndex + 5] = nextiStart + j + 1;
elIndex += 6;
}
}
}
void Teapot::getPatch(int patchNum, glm::vec3 patch[][4], bool reverseV)
{
for (int u = 0; u < 4; u++) { // Loop in u direction
for (int v = 0; v < 4; v++) { // Loop in v direction
if (reverseV) {
patch[u][v] = glm::vec3(
TeapotData::cpdata[TeapotData::patchdata[patchNum][u * 4 + (3 - v)]][0],
TeapotData::cpdata[TeapotData::patchdata[patchNum][u * 4 + (3 - v)]][1],
TeapotData::cpdata[TeapotData::patchdata[patchNum][u * 4 + (3 - v)]][2]
);
}
else {
patch[u][v] = glm::vec3(
TeapotData::cpdata[TeapotData::patchdata[patchNum][u * 4 + v]][0],
TeapotData::cpdata[TeapotData::patchdata[patchNum][u * 4 + v]][1],
TeapotData::cpdata[TeapotData::patchdata[patchNum][u * 4 + v]][2]
);
}
}
}
}
void Teapot::computeBasisFunctions(float * B, float * dB, int grid) {
float inc = 1.0f / grid;
for (int i = 0; i <= grid; i++) {
float t = i * inc;
float tSqr = t * t;
float oneMinusT = (1.0f - t);
float oneMinusT2 = oneMinusT * oneMinusT;
B[i * 4 + 0] = oneMinusT * oneMinusT2;
B[i * 4 + 1] = 3.0f * oneMinusT2 * t;
B[i * 4 + 2] = 3.0f * oneMinusT * tSqr;
B[i * 4 + 3] = t * tSqr;
dB[i * 4 + 0] = -3.0f * oneMinusT2;
dB[i * 4 + 1] = -6.0f * t * oneMinusT + 3.0f * oneMinusT2;
dB[i * 4 + 2] = -3.0f * tSqr + 6.0f * t * oneMinusT;
dB[i * 4 + 3] = 3.0f * tSqr;
}
}
glm::vec3 Teapot::evaluate(int gridU, int gridV, float *B, glm::vec3 patch[][4]) {
glm::vec3 p(0.0f, 0.0f, 0.0f);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
p += patch[i][j] * B[gridU * 4 + i] * B[gridV * 4 + j];
}
}
return p;
}
glm::vec3 Teapot::evaluateNormal(int gridU, int gridV, float *B, float *dB, glm::vec3 patch[][4]) {
glm::vec3 du(0.0f, 0.0f, 0.0f);
glm::vec3 dv(0.0f, 0.0f, 0.0f);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
du += patch[i][j] * dB[gridU * 4 + i] * B[gridV * 4 + j];
dv += patch[i][j] * B[gridU * 4 + i] * dB[gridV * 4 + j];
}
}
glm::vec3 norm = glm::cross(du, dv);
if (glm::length(norm) != 0.0f) {
norm = glm::normalize(norm);
}
return norm;
}
void Teapot::render() {
glBindVertexArray(_vao);
glDrawElements(GL_TRIANGLES, 6 * faces, GL_UNSIGNED_INT, ((GLubyte *)NULL + (0)));
}
|
[
"diego.alfarovives@gmail.com"
] |
diego.alfarovives@gmail.com
|
2e19f01b919227d86de47b8aeb4bae5915874153
|
32b934cb3ef99474b7295da510420ca4a03d6017
|
/GamosSD/include/GmHitList.hh
|
dc025d0da14e49165ad4bb1ee18d8478afd915fc
|
[] |
no_license
|
ethanlarochelle/GamosCore
|
450fc0eeb4a5a6666da7fdb75bcf5ee23a026238
|
70612e9a2e45b3b1381713503eb0f405530d44f0
|
refs/heads/master
| 2022-03-24T16:03:39.569576
| 2018-01-20T12:43:43
| 2018-01-20T12:43:43
| 116,504,426
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,691
|
hh
|
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The GAMOS software is copyright of the Copyright Holders of *
// * the GAMOS Collaboration. It is provided under the terms and *
// * conditions of the GAMOS Software License, included in the file *
// * LICENSE and available at http://fismed.ciemat.es/GAMOS/license .*
// * These include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GAMOS collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the GAMOS Software license. *
// ********************************************************************
//
#ifndef GmHitList_HH
#define GmHitList_HH
#include "GamosCore/GamosSD/include/GmHit.hh"
#include <map>
#include <set>
class GmVDeadTimeDUList;
class G4RunManager;
typedef std::vector< GmHit* > hitVector;
enum MeasuringType{ bMTBackwards, bMTInterval, bMTTriggerGlobal, bMTTriggerIndependent };
class GmHitList : public std::vector<GmHit*>
{
public:
GmHitList( G4String& sdtyp );
~GmHitList();
void AddHit( GmHit* hit );
const G4String GetSDType() const {
return theSDType; }
void BuildHitsCompatibleInTime( G4double tim = -1. );
void BuildHitsAll();
void BuildHitsCompatibleInTimeBackwards( G4double tim = -1. );
void BuildHitsCompatibleInTimeInterval( G4double tim );
void BuildHitsCompatibleInTimeTriggerGlobal( G4double tim );
void BuildHitsCompatibleInTimeTriggerIndependent( G4double tim );
void AddHitToDeadTimeDetUnitList();
void CleanHits( G4double tim = -1. );
void CleanHitsBefore( G4double tim );
void CleanHitsBefore( G4double tim, unsigned long long trigID );
void CleanDeadTimeDetUnitList( G4double tim = 1.);
void DeleteHit( iterator hit );
const hitVector* GetHitsCompatibleInTime() const {
return &theHitsCompatibleInTime;
}
G4double GetTriggerTime( G4double hitTime, unsigned long long detUnitID );
G4double GetMeasuringTime() const {
return theMeasuringTime;
}
private:
G4String theSDType;
G4double theMeasuringTime;
G4double theDeadTime;
GmVDeadTimeDUList* theDeadTimeDetUnitList;
hitVector theHitsCompatibleInTime;
G4bool bParalizable;
MeasuringType theMeasuringType;
G4double theCurrentIntervalStartTime;
G4double thePreviousEventIntervalTime;
G4RunManager* theRunManager;
// for trigger independent
std::map<unsigned long long, G4double> theCurrentIntervalStartTimes;
std::map<unsigned long long, G4double> thePreviousEventIntervalTimes;
G4int theNShift;
G4int theNTrigAncestors;
std::set<unsigned long long> theHitTrigIDs;
};
typedef std::map< G4String, GmHitList* > gamosSDHitMap;
#endif
|
[
"ethanlarochelle@gmail.com"
] |
ethanlarochelle@gmail.com
|
86fd3a335f54103e046fc92cea241cad5064379a
|
20287dbc4cf0e274cdc8e0a9d42a9303cf6ecd74
|
/test_library/test_library.h/test_library.h.ino
|
f897b9eec6d8f4e2c950dd123c5627903ec6940e
|
[] |
no_license
|
ChrisToxz/arduino
|
d526143b5214dc96d0187aab583e840ae1745d0f
|
4267aa61b50d8e856d91732c4127e4d7a8ecf8e3
|
refs/heads/master
| 2020-04-27T08:31:37.644419
| 2019-03-06T15:59:27
| 2019-03-06T15:59:27
| 174,174,456
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 105
|
ino
|
class Morse
{
public:
Morse(int pin);
void dot();
void dash();
private:
int _pin;
};
|
[
"chris@toxz.nl"
] |
chris@toxz.nl
|
69ab9f39427cf45eac135d6feed41dd4ed6fd54e
|
e401075d9c64e7774aa8c39477fba61e04502e2c
|
/DocumentDBCpp/lib/src/DocumentDBConfiguration.cpp
|
dd663710ec2448a5ee864acada8d0ecfb8e23ad5
|
[
"MIT"
] |
permissive
|
chaseYLC/OpenLib
|
c6f4068b1bec0dced4afe094786ef2b3e8587d6b
|
f9a565ad5b18359974befd7bccd8322d029d27bb
|
refs/heads/master
| 2020-03-29T08:13:50.563160
| 2018-09-21T03:08:39
| 2018-09-21T03:08:39
| 149,700,507
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,532
|
cpp
|
/***
* The MIT License (MIT)
*
* Copyright (c) 2015 DocumentDBCpp
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
***/
#include "DocumentDBConfiguration.h"
using namespace std;
using namespace utility;
using namespace web::http;
DocumentDBConfiguration::DocumentDBConfiguration(
string_t url_connection,
string_t master_key)
: url_connection_(url_connection)
, http_client_(url_connection)
{
master_key_ = utility::conversions::from_base64(master_key);
}
DocumentDBConfiguration::~DocumentDBConfiguration()
{
}
|
[
"w3history@empal.com"
] |
w3history@empal.com
|
79db7c4aabae7f12cda12614e6582b14570db34d
|
9e0ea27a21c5a60b9bf27639babaf63d2a79c110
|
/exercise_problems/read_file.cpp
|
640569559eef78730e609df4c2b0d54ad05b947d
|
[] |
no_license
|
stamaniorec/playing-with-c-and-cpp
|
9bdbc41005b0032fb80ff43a64d640a276bac2cf
|
f67a34328eec54ce096ec5023f09229bc215532f
|
refs/heads/master
| 2020-12-07T17:08:24.471573
| 2016-04-25T18:58:54
| 2016-04-25T18:58:54
| 44,012,236
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 295
|
cpp
|
#include <iostream>
#include <fstream>
#include <string>
int main()
{
std::ifstream file("info.txt");
std::string name;
int age;
float random;
while(file >> name >> age >> random)
{
std::cout << "Record: " << name << "; " <<
age << "; " << random << std::endl;
}
return 0;
}
|
[
"stamaniorec@gmail.com"
] |
stamaniorec@gmail.com
|
f61d64a758213d77c093cdaf985f133dbb3baa1d
|
1ea1a48f4762e1dd22e4321c4d09b1f8d00be147
|
/cocos2d/cocos/2d/platform/linux/CCFileUtilsLinux.cpp
|
2d86c1ec876b1d2089af42b57011e7d7258a5b82
|
[] |
no_license
|
gloryming/LuaBinding
|
d416263a5647395894225646ae2df15bbaf5b9e4
|
2098ebcf3e8fd7f80a3df10069e713ed7ea7c5ed
|
refs/heads/master
| 2021-01-22T09:46:59.214694
| 2014-02-07T03:33:59
| 2014-02-07T03:33:59
| 16,126,735
| 8
| 7
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,525
|
cpp
|
/****************************************************************************
Copyright (c) 2011 Laschweinski
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCFileUtilsLinux.h"
#include "platform/CCCommon.h"
#include "ccMacros.h"
#include "CCApplication.h"
#include "CCString.h"
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
using namespace std;
NS_CC_BEGIN
FileUtils* FileUtils::getInstance()
{
if (s_sharedFileUtils == NULL)
{
s_sharedFileUtils = new FileUtilsLinux();
if(!s_sharedFileUtils->init())
{
delete s_sharedFileUtils;
s_sharedFileUtils = NULL;
CCLOG("ERROR: Could not init CCFileUtilsLinux");
}
}
return s_sharedFileUtils;
}
FileUtilsLinux::FileUtilsLinux()
{}
bool FileUtilsLinux::init()
{
// get application path
char fullpath[256] = {0};
ssize_t length = readlink("/proc/self/exe", fullpath, sizeof(fullpath)-1);
if (length <= 0) {
return false;
}
fullpath[length] = '\0';
std::string appPath = fullpath;
_defaultResRootPath = appPath.substr(0, appPath.find_last_of("/"));
_defaultResRootPath += "/Resources/";
// Set writable path to $XDG_CONFIG_HOME or ~/.config/<app name>/ if $XDG_CONFIG_HOME not exists.
const char* xdg_config_path = getenv("XDG_CONFIG_HOME");
std::string xdgConfigPath;
if (xdg_config_path == NULL) {
xdgConfigPath = getenv("HOME");
xdgConfigPath += "/.config";
} else {
xdgConfigPath = xdg_config_path;
}
_writablePath = xdgConfigPath;
_writablePath += appPath.substr(appPath.find_last_of("/"));
_writablePath += "/";
return FileUtils::init();
}
string FileUtilsLinux::getWritablePath() const
{
struct stat st;
stat(_writablePath.c_str(), &st);
if (!S_ISDIR(st.st_mode)) {
mkdir(_writablePath.c_str(), 0744);
}
return _writablePath;
}
bool FileUtilsLinux::isFileExist(const std::string& strFilePath) const
{
if (0 == strFilePath.length())
{
return false;
}
std::string strPath = strFilePath;
if (!isAbsolutePath(strPath))
{ // Not absolute path, add the default root path at the beginning.
strPath.insert(0, _defaultResRootPath);
}
struct stat sts;
return (stat(strPath.c_str(), &sts) != -1) ? true : false;
}
NS_CC_END
|
[
"gloryming910222@gmail.com"
] |
gloryming910222@gmail.com
|
4416ef796da7d5f8184bc03d23457aa605e8bb61
|
c5c9aa80ad61a72c3c2369e468c187d7e86c0ac1
|
/ublox_msg_filters/src/example.cpp
|
ba0bf707324a811f0fae699f3ea9c5c8d0895121
|
[
"BSD-3-Clause"
] |
permissive
|
KumarRobotics/ublox
|
6fe828a5564c278c1faa022fcfbc30f8cbcb64c7
|
4f107f3b82135160a1aca3ef0689fd119199bbef
|
refs/heads/master
| 2023-07-22T09:58:16.843704
| 2022-12-07T04:39:33
| 2022-12-07T04:39:33
| 21,113,803
| 394
| 331
|
BSD-3-Clause
| 2023-05-02T18:38:02
| 2014-06-23T04:19:43
|
C++
|
UTF-8
|
C++
| false
| false
| 1,122
|
cpp
|
#include "ros/ros.h"
#include <message_filters/subscriber.h>
#include <ublox_msg_filters/exact_time.h>
#include <ublox_msgs/NavHPPOSLLH.h>
#include <ublox_msgs/NavRELPOSNED9.h>
#include <ublox_msgs/NavVELNED.h>
void callback(const ublox_msgs::NavHPPOSLLHConstPtr &msg1,
const ublox_msgs::NavRELPOSNED9ConstPtr &msg2,
const ublox_msgs::NavVELNEDConstPtr &msg3) {
ROS_INFO("RX %u %u %u", msg1->iTOW, msg2->iTOW, msg3->iTOW);
}
int main(int argc, char **argv) {
ros::init(argc, argv, "ublox_sync");
ros::NodeHandle nh;
message_filters::Subscriber<ublox_msgs::NavHPPOSLLH> sub1(nh, "msg1", 1);
message_filters::Subscriber<ublox_msgs::NavRELPOSNED9> sub2(nh, "msg2", 1);
message_filters::Subscriber<ublox_msgs::NavVELNED> sub3(nh, "msg3", 1);
typedef ublox_msg_filters::ExactTime<ublox_msgs::NavHPPOSLLH, ublox_msgs::NavRELPOSNED9, ublox_msgs::NavVELNED> MySyncPolicy;
message_filters::Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), sub1, sub2, sub3);
sync.registerCallback(boost::bind(callback, _1, _2, _3));
ROS_INFO("Ready to receive");
ros::spin();
return 0;
}
|
[
"khallenbeck@dataspeedinc.com"
] |
khallenbeck@dataspeedinc.com
|
73027dd0740b66b82f48ee271be6bf3c7cacfb4d
|
c202deddfc88af90de949730d4deebfc5b647f8c
|
/src/lib/isa/Lru.cpp
|
77d96cfa2fd8ce8a63731fa0afb7bb294e49782a
|
[] |
no_license
|
parsa/iato
|
11523df0aa73290c3eb70129b25e4e9d1c3f95bf
|
28d75c28fa96be6aad43d07b9f8e1ca1d42192dd
|
refs/heads/master
| 2020-04-26T16:34:05.303929
| 2019-03-06T20:46:33
| 2019-03-06T20:46:33
| 173,683,631
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,458
|
cpp
|
// ---------------------------------------------------------------------------
// - Lru.cpp -
// - iato:isa library - least recently used matrix class implmentation -
// ---------------------------------------------------------------------------
// - (c) inria 2002-2004 -
// ---------------------------------------------------------------------------
// - authors Amaury Darsch 2002:2004 -
// - Pierre Villalon 2002:2003 -
// - Andre Seznec 2002:2004 -
// ---------------------------------------------------------------------------
// - This program is free software; you can redistribute it and/or modify -
// - it under the terms of the GNU General Public License version 2, as -
// - published by the Free Software Foundation. -
// - -
// - This program is distributed in the hope that it will be useful, -
// - but without any warranty; without even the implied warranty of -
// - merchantability or fitness for a particular purpose. -
// - -
// - See the GNU General Public License version 2 for more details -
// ---------------------------------------------------------------------------
#include "Lru.hpp"
namespace iato {
// create a lru matrix by size
Lru::Lru (const long size) {
d_size = size; assert (d_size > 0);
p_vlru = new bool*[d_size];
for (long i = 0; i < d_size; i++) p_vlru[i] = new bool[d_size];
reset ();
}
// destroy this lru matrix
Lru::~Lru (void) {
for (long i = 0; i < d_size; i++) delete [] p_vlru[i];
delete [] p_vlru;
}
// reset this matrix
void Lru::reset (void) {
for (long i = 0; i < d_size; i++) {
bool* row = p_vlru[i];
for (long j = 0; j < d_size; j++) row[j] = false;
}
}
// update an access by index
void Lru::update (const long index) {
assert ((index >= 0) && (index < d_size));
// set the row
bool* row = p_vlru[index];
for (long j = 0; j < d_size; j++) row[j] = true;
// set the column
for (long i = 0; i < d_size; i++) {
row = p_vlru[i];
row[index] = false;
}
}
// return the lru index
long Lru::getlru (void) const {
long index = -1;
long count = -1;
for (long i = 0; i < d_size; i++) {
// get the number of true elements
bool* row = p_vlru[i];
long len = 0;
for (long j = 0; j < d_size; j++) if (row[j] == true) len ++;
// update index and counter
if ((index == -1) || (len < count)) {
index = i;
count = len;
}
}
// return least index
return index;
}
// return the mru index
long Lru::getmru (void) const {
long index = -1;
long count = -1;
for (long i = 0; i < d_size; i++) {
// get the number of true elements
bool* row = p_vlru[i];
long len = 0;
for (long j = 0; j < d_size; j++) if (row[j] == true) len ++;
// update index and counter
if ((index == -1) || (len > count)) {
index = i;
count = len;
}
}
// return most index
return index;
}
}
|
[
"me@parsaamini.net"
] |
me@parsaamini.net
|
afdfb731749ceed8d755b077c02f709402349026
|
d7e33511c2d5f9a115b34fdfae3d22d3d8d3a41b
|
/test/server/utility_test.cpp
|
3b8acfc6869ccf2c687eaa5fca429308c5414750
|
[] |
no_license
|
jjuri-socialmining/public
|
7c4f2351a346d4ddb92efe1c46f8819be3e4754f
|
7c759aa9fa12ffdc80d0aeb2e2d854c39dcf4980
|
refs/heads/master
| 2022-03-04T05:14:32.543235
| 2016-12-27T04:22:44
| 2016-12-27T04:22:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,462
|
cpp
|
#include "stdafx.h"
#include "utility_test.h"
#include <keye/utility/utility_fwd.h>
using namespace keye;
// --------------------------------------------------------
class PrintNode:public joint_observer{
public:
virtual void update(joint* n){
if(n)
printf("%d updated\n",n->id());
}
};
// --------------------------------------------------------
class Player{
public:
void walk(){
printf("I'm walking.\n");
}
};
class Walk:public Behavior<>{
public:
Walk(Player* p,joint_scheduler& sx)
:Behavior(sx)
,_player(p){}
//derived from joint_observer,do real action
virtual void update(joint*){if(_player)_player->walk();};
private:
Player* _player;
};
void test_bahavior(){
joint_scheduler jsch;
Player player;
s_ptr<behavior> walk(new Walk(&player,jsch));
bh_signal sig(&walk);
}
// --------------------------------------------------------
void utility_test(){
joint_scheduler g;
PrintNode observer;
const size_t N=100;
joint* joints[N];
for(int i=1;i<N;++i){
joints[i]=joint::create(i);
joints[i]->link(&observer);
}
for(int i=1;i<4;++i)
g.root().insert(joints[i]);
joints[1]->insert(joints[4]);
joints[1]->insert(joints[5]);
joints[2]->insert(joints[6]);
joints[4]->insert(joints[7]);
joints[4]->insert(joints[8]);
joints[7]->insert(joints[9]);
joints[8]->insert(joints[9]);
joints[9]->insert(joints[5]);
joints[5]->insert(joints[2]);
// joints[2]->insert(joints[9]);
g.start_update();
pause();
}
|
[
"keyeleo@163.com"
] |
keyeleo@163.com
|
ab12b1c8332d365b732d4c3effc6ce8e535cff59
|
0218c60da485f6e711759d5363d33c1ddf9f763d
|
/libcpp/Include/Proto/Qot_RegQotPush.pb.cc
|
0e646a39eb32ab73385d4c3daa9296b9a086fd71
|
[
"MIT"
] |
permissive
|
stephenlyu/gofutuapi
|
9b9c8eda151ff501d76a0bc3eb9b0fb2af967fbf
|
1a60310dd142ac7049c9ef9cf22c7d78d0f880ef
|
refs/heads/master
| 2021-01-26T00:37:13.910922
| 2020-03-17T04:27:24
| 2020-03-17T04:27:24
| 243,243,130
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| true
| 52,924
|
cc
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: Qot_RegQotPush.proto
#include "Qot_RegQotPush.pb.h"
#include <algorithm>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// This is a temporary google only hack
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
#include "third_party/protobuf/version.h"
#endif
// @@protoc_insertion_point(includes)
namespace Qot_RegQotPush {
class C2SDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<C2S>
_instance;
} _C2S_default_instance_;
class S2CDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<S2C>
_instance;
} _S2C_default_instance_;
class RequestDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<Request>
_instance;
} _Request_default_instance_;
class ResponseDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<Response>
_instance;
} _Response_default_instance_;
} // namespace Qot_RegQotPush
namespace protobuf_Qot_5fRegQotPush_2eproto {
void InitDefaultsC2SImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
::google::protobuf::internal::InitProtobufDefaults();
#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
protobuf_Qot_5fCommon_2eproto::InitDefaultsSecurity();
{
void* ptr = &::Qot_RegQotPush::_C2S_default_instance_;
new (ptr) ::Qot_RegQotPush::C2S();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::Qot_RegQotPush::C2S::InitAsDefaultInstance();
}
void InitDefaultsC2S() {
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
::google::protobuf::GoogleOnceInit(&once, &InitDefaultsC2SImpl);
}
void InitDefaultsS2CImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
::google::protobuf::internal::InitProtobufDefaults();
#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
{
void* ptr = &::Qot_RegQotPush::_S2C_default_instance_;
new (ptr) ::Qot_RegQotPush::S2C();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::Qot_RegQotPush::S2C::InitAsDefaultInstance();
}
void InitDefaultsS2C() {
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
::google::protobuf::GoogleOnceInit(&once, &InitDefaultsS2CImpl);
}
void InitDefaultsRequestImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
::google::protobuf::internal::InitProtobufDefaults();
#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsC2S();
{
void* ptr = &::Qot_RegQotPush::_Request_default_instance_;
new (ptr) ::Qot_RegQotPush::Request();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::Qot_RegQotPush::Request::InitAsDefaultInstance();
}
void InitDefaultsRequest() {
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
::google::protobuf::GoogleOnceInit(&once, &InitDefaultsRequestImpl);
}
void InitDefaultsResponseImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
::google::protobuf::internal::InitProtobufDefaults();
#endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsS2C();
{
void* ptr = &::Qot_RegQotPush::_Response_default_instance_;
new (ptr) ::Qot_RegQotPush::Response();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::Qot_RegQotPush::Response::InitAsDefaultInstance();
}
void InitDefaultsResponse() {
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
::google::protobuf::GoogleOnceInit(&once, &InitDefaultsResponseImpl);
}
::google::protobuf::Metadata file_level_metadata[4];
const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::C2S, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::C2S, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::C2S, securitylist_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::C2S, subtypelist_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::C2S, rehabtypelist_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::C2S, isregorunreg_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::C2S, isfirstpush_),
~0u,
~0u,
~0u,
0,
1,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::S2C, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::S2C, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::Request, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::Request, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::Request, c2s_),
0,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::Response, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::Response, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::Response, rettype_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::Response, retmsg_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::Response, errcode_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::Qot_RegQotPush::Response, s2c_),
3,
0,
2,
1,
};
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 10, sizeof(::Qot_RegQotPush::C2S)},
{ 15, 20, sizeof(::Qot_RegQotPush::S2C)},
{ 20, 26, sizeof(::Qot_RegQotPush::Request)},
{ 27, 36, sizeof(::Qot_RegQotPush::Response)},
};
static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::Qot_RegQotPush::_C2S_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::Qot_RegQotPush::_S2C_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::Qot_RegQotPush::_Request_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::Qot_RegQotPush::_Response_default_instance_),
};
void protobuf_AssignDescriptors() {
AddDescriptors();
::google::protobuf::MessageFactory* factory = NULL;
AssignDescriptors(
"Qot_RegQotPush.proto", schemas, file_default_instances, TableStruct::offsets, factory,
file_level_metadata, NULL, NULL);
}
void protobuf_AssignDescriptorsOnce() {
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4);
}
void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\024Qot_RegQotPush.proto\022\016Qot_RegQotPush\032\014"
"Common.proto\032\020Qot_Common.proto\"\210\001\n\003C2S\022*"
"\n\014securityList\030\001 \003(\0132\024.Qot_Common.Securi"
"ty\022\023\n\013subTypeList\030\002 \003(\005\022\025\n\rrehabTypeList"
"\030\003 \003(\005\022\024\n\014isRegOrUnReg\030\004 \002(\010\022\023\n\013isFirstP"
"ush\030\005 \001(\010\"\005\n\003S2C\"+\n\007Request\022 \n\003c2s\030\001 \002(\013"
"2\023.Qot_RegQotPush.C2S\"d\n\010Response\022\025\n\007ret"
"Type\030\001 \002(\005:\004-400\022\016\n\006retMsg\030\002 \001(\t\022\017\n\007errC"
"ode\030\003 \001(\005\022 \n\003s2c\030\004 \001(\0132\023.Qot_RegQotPush."
"S2CB\025\n\023com.futu.openapi.pb"
};
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
descriptor, 386);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"Qot_RegQotPush.proto", &protobuf_RegisterTypes);
::protobuf_Common_2eproto::AddDescriptors();
::protobuf_Qot_5fCommon_2eproto::AddDescriptors();
}
void AddDescriptors() {
static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at dynamic initialization time.
struct StaticDescriptorInitializer {
StaticDescriptorInitializer() {
AddDescriptors();
}
} static_descriptor_initializer;
} // namespace protobuf_Qot_5fRegQotPush_2eproto
namespace Qot_RegQotPush {
// ===================================================================
void C2S::InitAsDefaultInstance() {
}
void C2S::clear_securitylist() {
securitylist_.Clear();
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int C2S::kSecurityListFieldNumber;
const int C2S::kSubTypeListFieldNumber;
const int C2S::kRehabTypeListFieldNumber;
const int C2S::kIsRegOrUnRegFieldNumber;
const int C2S::kIsFirstPushFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
C2S::C2S()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
::protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsC2S();
}
SharedCtor();
// @@protoc_insertion_point(constructor:Qot_RegQotPush.C2S)
}
C2S::C2S(const C2S& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0),
securitylist_(from.securitylist_),
subtypelist_(from.subtypelist_),
rehabtypelist_(from.rehabtypelist_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
::memcpy(&isregorunreg_, &from.isregorunreg_,
static_cast<size_t>(reinterpret_cast<char*>(&isfirstpush_) -
reinterpret_cast<char*>(&isregorunreg_)) + sizeof(isfirstpush_));
// @@protoc_insertion_point(copy_constructor:Qot_RegQotPush.C2S)
}
void C2S::SharedCtor() {
_cached_size_ = 0;
::memset(&isregorunreg_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&isfirstpush_) -
reinterpret_cast<char*>(&isregorunreg_)) + sizeof(isfirstpush_));
}
C2S::~C2S() {
// @@protoc_insertion_point(destructor:Qot_RegQotPush.C2S)
SharedDtor();
}
void C2S::SharedDtor() {
}
void C2S::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* C2S::descriptor() {
::protobuf_Qot_5fRegQotPush_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_Qot_5fRegQotPush_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const C2S& C2S::default_instance() {
::protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsC2S();
return *internal_default_instance();
}
C2S* C2S::New(::google::protobuf::Arena* arena) const {
C2S* n = new C2S;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void C2S::Clear() {
// @@protoc_insertion_point(message_clear_start:Qot_RegQotPush.C2S)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
securitylist_.Clear();
subtypelist_.Clear();
rehabtypelist_.Clear();
::memset(&isregorunreg_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&isfirstpush_) -
reinterpret_cast<char*>(&isregorunreg_)) + sizeof(isfirstpush_));
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool C2S::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:Qot_RegQotPush.C2S)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .Qot_Common.Security securityList = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_securitylist()));
} else {
goto handle_unusual;
}
break;
}
// repeated int32 subTypeList = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
1, 16u, input, this->mutable_subtypelist())));
} else if (
static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_subtypelist())));
} else {
goto handle_unusual;
}
break;
}
// repeated int32 rehabTypeList = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
1, 24u, input, this->mutable_rehabtypelist())));
} else if (
static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_rehabtypelist())));
} else {
goto handle_unusual;
}
break;
}
// required bool isRegOrUnReg = 4;
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) {
set_has_isregorunreg();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &isregorunreg_)));
} else {
goto handle_unusual;
}
break;
}
// optional bool isFirstPush = 5;
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) {
set_has_isfirstpush();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &isfirstpush_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:Qot_RegQotPush.C2S)
return true;
failure:
// @@protoc_insertion_point(parse_failure:Qot_RegQotPush.C2S)
return false;
#undef DO_
}
void C2S::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:Qot_RegQotPush.C2S)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .Qot_Common.Security securityList = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->securitylist_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, this->securitylist(static_cast<int>(i)), output);
}
// repeated int32 subTypeList = 2;
for (int i = 0, n = this->subtypelist_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32(
2, this->subtypelist(i), output);
}
// repeated int32 rehabTypeList = 3;
for (int i = 0, n = this->rehabtypelist_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32(
3, this->rehabtypelist(i), output);
}
cached_has_bits = _has_bits_[0];
// required bool isRegOrUnReg = 4;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteBool(4, this->isregorunreg(), output);
}
// optional bool isFirstPush = 5;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteBool(5, this->isfirstpush(), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:Qot_RegQotPush.C2S)
}
::google::protobuf::uint8* C2S::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:Qot_RegQotPush.C2S)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .Qot_Common.Security securityList = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->securitylist_size()); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
1, this->securitylist(static_cast<int>(i)), deterministic, target);
}
// repeated int32 subTypeList = 2;
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32ToArray(2, this->subtypelist_, target);
// repeated int32 rehabTypeList = 3;
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32ToArray(3, this->rehabtypelist_, target);
cached_has_bits = _has_bits_[0];
// required bool isRegOrUnReg = 4;
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->isregorunreg(), target);
}
// optional bool isFirstPush = 5;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->isfirstpush(), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:Qot_RegQotPush.C2S)
return target;
}
size_t C2S::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:Qot_RegQotPush.C2S)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
// required bool isRegOrUnReg = 4;
if (has_isregorunreg()) {
total_size += 1 + 1;
}
// repeated .Qot_Common.Security securityList = 1;
{
unsigned int count = static_cast<unsigned int>(this->securitylist_size());
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSize(
this->securitylist(static_cast<int>(i)));
}
}
// repeated int32 subTypeList = 2;
{
size_t data_size = ::google::protobuf::internal::WireFormatLite::
Int32Size(this->subtypelist_);
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->subtypelist_size());
total_size += data_size;
}
// repeated int32 rehabTypeList = 3;
{
size_t data_size = ::google::protobuf::internal::WireFormatLite::
Int32Size(this->rehabtypelist_);
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->rehabtypelist_size());
total_size += data_size;
}
// optional bool isFirstPush = 5;
if (has_isfirstpush()) {
total_size += 1 + 1;
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void C2S::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:Qot_RegQotPush.C2S)
GOOGLE_DCHECK_NE(&from, this);
const C2S* source =
::google::protobuf::internal::DynamicCastToGenerated<const C2S>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:Qot_RegQotPush.C2S)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:Qot_RegQotPush.C2S)
MergeFrom(*source);
}
}
void C2S::MergeFrom(const C2S& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:Qot_RegQotPush.C2S)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
securitylist_.MergeFrom(from.securitylist_);
subtypelist_.MergeFrom(from.subtypelist_);
rehabtypelist_.MergeFrom(from.rehabtypelist_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
isregorunreg_ = from.isregorunreg_;
}
if (cached_has_bits & 0x00000002u) {
isfirstpush_ = from.isfirstpush_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void C2S::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:Qot_RegQotPush.C2S)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void C2S::CopyFrom(const C2S& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:Qot_RegQotPush.C2S)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool C2S::IsInitialized() const {
if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->securitylist())) return false;
return true;
}
void C2S::Swap(C2S* other) {
if (other == this) return;
InternalSwap(other);
}
void C2S::InternalSwap(C2S* other) {
using std::swap;
securitylist_.InternalSwap(&other->securitylist_);
subtypelist_.InternalSwap(&other->subtypelist_);
rehabtypelist_.InternalSwap(&other->rehabtypelist_);
swap(isregorunreg_, other->isregorunreg_);
swap(isfirstpush_, other->isfirstpush_);
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata C2S::GetMetadata() const {
protobuf_Qot_5fRegQotPush_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_Qot_5fRegQotPush_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void S2C::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
S2C::S2C()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
::protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsS2C();
}
SharedCtor();
// @@protoc_insertion_point(constructor:Qot_RegQotPush.S2C)
}
S2C::S2C(const S2C& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:Qot_RegQotPush.S2C)
}
void S2C::SharedCtor() {
_cached_size_ = 0;
}
S2C::~S2C() {
// @@protoc_insertion_point(destructor:Qot_RegQotPush.S2C)
SharedDtor();
}
void S2C::SharedDtor() {
}
void S2C::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* S2C::descriptor() {
::protobuf_Qot_5fRegQotPush_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_Qot_5fRegQotPush_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const S2C& S2C::default_instance() {
::protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsS2C();
return *internal_default_instance();
}
S2C* S2C::New(::google::protobuf::Arena* arena) const {
S2C* n = new S2C;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void S2C::Clear() {
// @@protoc_insertion_point(message_clear_start:Qot_RegQotPush.S2C)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool S2C::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:Qot_RegQotPush.S2C)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
}
success:
// @@protoc_insertion_point(parse_success:Qot_RegQotPush.S2C)
return true;
failure:
// @@protoc_insertion_point(parse_failure:Qot_RegQotPush.S2C)
return false;
#undef DO_
}
void S2C::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:Qot_RegQotPush.S2C)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:Qot_RegQotPush.S2C)
}
::google::protobuf::uint8* S2C::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:Qot_RegQotPush.S2C)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:Qot_RegQotPush.S2C)
return target;
}
size_t S2C::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:Qot_RegQotPush.S2C)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void S2C::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:Qot_RegQotPush.S2C)
GOOGLE_DCHECK_NE(&from, this);
const S2C* source =
::google::protobuf::internal::DynamicCastToGenerated<const S2C>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:Qot_RegQotPush.S2C)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:Qot_RegQotPush.S2C)
MergeFrom(*source);
}
}
void S2C::MergeFrom(const S2C& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:Qot_RegQotPush.S2C)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
}
void S2C::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:Qot_RegQotPush.S2C)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void S2C::CopyFrom(const S2C& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:Qot_RegQotPush.S2C)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool S2C::IsInitialized() const {
return true;
}
void S2C::Swap(S2C* other) {
if (other == this) return;
InternalSwap(other);
}
void S2C::InternalSwap(S2C* other) {
using std::swap;
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata S2C::GetMetadata() const {
protobuf_Qot_5fRegQotPush_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_Qot_5fRegQotPush_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void Request::InitAsDefaultInstance() {
::Qot_RegQotPush::_Request_default_instance_._instance.get_mutable()->c2s_ = const_cast< ::Qot_RegQotPush::C2S*>(
::Qot_RegQotPush::C2S::internal_default_instance());
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Request::kC2SFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Request::Request()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
::protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsRequest();
}
SharedCtor();
// @@protoc_insertion_point(constructor:Qot_RegQotPush.Request)
}
Request::Request(const Request& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.has_c2s()) {
c2s_ = new ::Qot_RegQotPush::C2S(*from.c2s_);
} else {
c2s_ = NULL;
}
// @@protoc_insertion_point(copy_constructor:Qot_RegQotPush.Request)
}
void Request::SharedCtor() {
_cached_size_ = 0;
c2s_ = NULL;
}
Request::~Request() {
// @@protoc_insertion_point(destructor:Qot_RegQotPush.Request)
SharedDtor();
}
void Request::SharedDtor() {
if (this != internal_default_instance()) delete c2s_;
}
void Request::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Request::descriptor() {
::protobuf_Qot_5fRegQotPush_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_Qot_5fRegQotPush_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const Request& Request::default_instance() {
::protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsRequest();
return *internal_default_instance();
}
Request* Request::New(::google::protobuf::Arena* arena) const {
Request* n = new Request;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void Request::Clear() {
// @@protoc_insertion_point(message_clear_start:Qot_RegQotPush.Request)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(c2s_ != NULL);
c2s_->Clear();
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool Request::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:Qot_RegQotPush.Request)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// required .Qot_RegQotPush.C2S c2s = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_c2s()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:Qot_RegQotPush.Request)
return true;
failure:
// @@protoc_insertion_point(parse_failure:Qot_RegQotPush.Request)
return false;
#undef DO_
}
void Request::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:Qot_RegQotPush.Request)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// required .Qot_RegQotPush.C2S c2s = 1;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, *this->c2s_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:Qot_RegQotPush.Request)
}
::google::protobuf::uint8* Request::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:Qot_RegQotPush.Request)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// required .Qot_RegQotPush.C2S c2s = 1;
if (cached_has_bits & 0x00000001u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
1, *this->c2s_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:Qot_RegQotPush.Request)
return target;
}
size_t Request::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:Qot_RegQotPush.Request)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
// required .Qot_RegQotPush.C2S c2s = 1;
if (has_c2s()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*this->c2s_);
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void Request::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:Qot_RegQotPush.Request)
GOOGLE_DCHECK_NE(&from, this);
const Request* source =
::google::protobuf::internal::DynamicCastToGenerated<const Request>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:Qot_RegQotPush.Request)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:Qot_RegQotPush.Request)
MergeFrom(*source);
}
}
void Request::MergeFrom(const Request& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:Qot_RegQotPush.Request)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.has_c2s()) {
mutable_c2s()->::Qot_RegQotPush::C2S::MergeFrom(from.c2s());
}
}
void Request::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:Qot_RegQotPush.Request)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Request::CopyFrom(const Request& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:Qot_RegQotPush.Request)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Request::IsInitialized() const {
if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
if (has_c2s()) {
if (!this->c2s_->IsInitialized()) return false;
}
return true;
}
void Request::Swap(Request* other) {
if (other == this) return;
InternalSwap(other);
}
void Request::InternalSwap(Request* other) {
using std::swap;
swap(c2s_, other->c2s_);
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Request::GetMetadata() const {
protobuf_Qot_5fRegQotPush_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_Qot_5fRegQotPush_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void Response::InitAsDefaultInstance() {
::Qot_RegQotPush::_Response_default_instance_._instance.get_mutable()->s2c_ = const_cast< ::Qot_RegQotPush::S2C*>(
::Qot_RegQotPush::S2C::internal_default_instance());
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Response::kRetTypeFieldNumber;
const int Response::kRetMsgFieldNumber;
const int Response::kErrCodeFieldNumber;
const int Response::kS2CFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Response::Response()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
::protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsResponse();
}
SharedCtor();
// @@protoc_insertion_point(constructor:Qot_RegQotPush.Response)
}
Response::Response(const Response& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL),
_has_bits_(from._has_bits_),
_cached_size_(0) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
retmsg_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.has_retmsg()) {
retmsg_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.retmsg_);
}
if (from.has_s2c()) {
s2c_ = new ::Qot_RegQotPush::S2C(*from.s2c_);
} else {
s2c_ = NULL;
}
::memcpy(&errcode_, &from.errcode_,
static_cast<size_t>(reinterpret_cast<char*>(&rettype_) -
reinterpret_cast<char*>(&errcode_)) + sizeof(rettype_));
// @@protoc_insertion_point(copy_constructor:Qot_RegQotPush.Response)
}
void Response::SharedCtor() {
_cached_size_ = 0;
retmsg_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(&s2c_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&errcode_) -
reinterpret_cast<char*>(&s2c_)) + sizeof(errcode_));
rettype_ = -400;
}
Response::~Response() {
// @@protoc_insertion_point(destructor:Qot_RegQotPush.Response)
SharedDtor();
}
void Response::SharedDtor() {
retmsg_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete s2c_;
}
void Response::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Response::descriptor() {
::protobuf_Qot_5fRegQotPush_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_Qot_5fRegQotPush_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const Response& Response::default_instance() {
::protobuf_Qot_5fRegQotPush_2eproto::InitDefaultsResponse();
return *internal_default_instance();
}
Response* Response::New(::google::protobuf::Arena* arena) const {
Response* n = new Response;
if (arena != NULL) {
arena->Own(n);
}
return n;
}
void Response::Clear() {
// @@protoc_insertion_point(message_clear_start:Qot_RegQotPush.Response)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 3u) {
if (cached_has_bits & 0x00000001u) {
GOOGLE_DCHECK(!retmsg_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
(*retmsg_.UnsafeRawStringPointer())->clear();
}
if (cached_has_bits & 0x00000002u) {
GOOGLE_DCHECK(s2c_ != NULL);
s2c_->Clear();
}
}
if (cached_has_bits & 12u) {
errcode_ = 0;
rettype_ = -400;
}
_has_bits_.Clear();
_internal_metadata_.Clear();
}
bool Response::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:Qot_RegQotPush.Response)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// required int32 retType = 1 [default = -400];
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
set_has_rettype();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &rettype_)));
} else {
goto handle_unusual;
}
break;
}
// optional string retMsg = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_retmsg()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->retmsg().data(), static_cast<int>(this->retmsg().length()),
::google::protobuf::internal::WireFormat::PARSE,
"Qot_RegQotPush.Response.retMsg");
} else {
goto handle_unusual;
}
break;
}
// optional int32 errCode = 3;
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) {
set_has_errcode();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &errcode_)));
} else {
goto handle_unusual;
}
break;
}
// optional .Qot_RegQotPush.S2C s2c = 4;
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_s2c()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:Qot_RegQotPush.Response)
return true;
failure:
// @@protoc_insertion_point(parse_failure:Qot_RegQotPush.Response)
return false;
#undef DO_
}
void Response::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:Qot_RegQotPush.Response)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// required int32 retType = 1 [default = -400];
if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->rettype(), output);
}
// optional string retMsg = 2;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->retmsg().data(), static_cast<int>(this->retmsg().length()),
::google::protobuf::internal::WireFormat::SERIALIZE,
"Qot_RegQotPush.Response.retMsg");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
2, this->retmsg(), output);
}
// optional int32 errCode = 3;
if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->errcode(), output);
}
// optional .Qot_RegQotPush.S2C s2c = 4;
if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
4, *this->s2c_, output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:Qot_RegQotPush.Response)
}
::google::protobuf::uint8* Response::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:Qot_RegQotPush.Response)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// required int32 retType = 1 [default = -400];
if (cached_has_bits & 0x00000008u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->rettype(), target);
}
// optional string retMsg = 2;
if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->retmsg().data(), static_cast<int>(this->retmsg().length()),
::google::protobuf::internal::WireFormat::SERIALIZE,
"Qot_RegQotPush.Response.retMsg");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
2, this->retmsg(), target);
}
// optional int32 errCode = 3;
if (cached_has_bits & 0x00000004u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->errcode(), target);
}
// optional .Qot_RegQotPush.S2C s2c = 4;
if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
4, *this->s2c_, deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:Qot_RegQotPush.Response)
return target;
}
size_t Response::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:Qot_RegQotPush.Response)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
// required int32 retType = 1 [default = -400];
if (has_rettype()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->rettype());
}
if (_has_bits_[0 / 32] & 7u) {
// optional string retMsg = 2;
if (has_retmsg()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->retmsg());
}
// optional .Qot_RegQotPush.S2C s2c = 4;
if (has_s2c()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*this->s2c_);
}
// optional int32 errCode = 3;
if (has_errcode()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->errcode());
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void Response::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:Qot_RegQotPush.Response)
GOOGLE_DCHECK_NE(&from, this);
const Response* source =
::google::protobuf::internal::DynamicCastToGenerated<const Response>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:Qot_RegQotPush.Response)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:Qot_RegQotPush.Response)
MergeFrom(*source);
}
}
void Response::MergeFrom(const Response& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:Qot_RegQotPush.Response)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 15u) {
if (cached_has_bits & 0x00000001u) {
set_has_retmsg();
retmsg_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.retmsg_);
}
if (cached_has_bits & 0x00000002u) {
mutable_s2c()->::Qot_RegQotPush::S2C::MergeFrom(from.s2c());
}
if (cached_has_bits & 0x00000004u) {
errcode_ = from.errcode_;
}
if (cached_has_bits & 0x00000008u) {
rettype_ = from.rettype_;
}
_has_bits_[0] |= cached_has_bits;
}
}
void Response::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:Qot_RegQotPush.Response)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Response::CopyFrom(const Response& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:Qot_RegQotPush.Response)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Response::IsInitialized() const {
if ((_has_bits_[0] & 0x00000008) != 0x00000008) return false;
return true;
}
void Response::Swap(Response* other) {
if (other == this) return;
InternalSwap(other);
}
void Response::InternalSwap(Response* other) {
using std::swap;
retmsg_.Swap(&other->retmsg_);
swap(s2c_, other->s2c_);
swap(errcode_, other->errcode_);
swap(rettype_, other->rettype_);
swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Response::GetMetadata() const {
protobuf_Qot_5fRegQotPush_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_Qot_5fRegQotPush_2eproto::file_level_metadata[kIndexInFileMessages];
}
// @@protoc_insertion_point(namespace_scope)
} // namespace Qot_RegQotPush
// @@protoc_insertion_point(global_scope)
|
[
"64734301@qq.com"
] |
64734301@qq.com
|
68f3483ff76aa604c7439489bd0abaae73a4f2bf
|
984c4f962762a8a1c2d7b12c7797ac5c4084caad
|
/jni/cn_Ragnarok_NativeFilterFunc.cpp
|
bcc23a394ed676f47d0be1a01a6157688c94a29b
|
[] |
no_license
|
csshuai/android-image-filter
|
3619cfb3bb38c8120f5e567c89b23dcde3b0b0ad
|
4892eeb387ae52c8be1c340a480afd967ccc51cc
|
refs/heads/master
| 2021-01-20T21:32:25.468899
| 2013-02-26T14:41:54
| 2013-02-26T14:41:54
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,412
|
cpp
|
/*
* cn_Ragnarok_NativeFilterFunc.cpp
*
* Created on: 2013-2-9
* Author: ragnarok
*/
#include "cn_Ragnarok_NativeFilterFunc.h"
#include "LightFilter.h"
#include "NeonFilter.h"
#include "OilFilter.h"
#include "TvFilter.h"
#include "AverageSmooth.h"
#include "LomoAddBlackRound.h"
#include "HDRFilter.h"
#include "DiscreteGaussianBlur.h"
#include "SoftGlowFilter.h"
#include "Util.h"
jintArray Java_cn_Ragnarok_NativeFilterFunc_lightFilter(JNIEnv* env,
jclass object, jintArray pixels, jint width, jint height) {
jintArray result = procImage(env, pixels, width, height, lightFilter);
return result;
}
jintArray Java_cn_Ragnarok_NativeFilterFunc_lomoAddBlckRound(JNIEnv* env,
jclass object, jintArray pixels, jint width, jint height) {
jintArray result = procImage(env, pixels, width, height, lomoAddBlackRound);
return result;
}
jintArray Java_cn_Ragnarok_NativeFilterFunc_neonFilter(JNIEnv* env,
jclass object, jintArray pixels, jint width, jint height) {
jintArray result = procImage(env, pixels, width, height, neonFilter);
return result;
}
jintArray Java_cn_Ragnarok_NativeFilterFunc_oilFilter(JNIEnv* env,
jclass object, jintArray pixels, jint width, jint height) {
jintArray result = procImage(env, pixels, width, height, oilFilter);
return result;
}
jintArray Java_cn_Ragnarok_NativeFilterFunc_tvFilter(JNIEnv* env, jclass object,
jintArray pixels, jint width, jint height) {
jintArray result = procImage(env, pixels, width, height, tvFilter);
return result;
}
jintArray Java_cn_Ragnarok_NativeFilterFunc_averageSmooth(JNIEnv* env,
jclass object, jintArray pixels, jint width, jint height) {
jintArray result = procImage(env, pixels, width, height, averageSmooth);
return result;
}
jintArray Java_cn_Ragnarok_NativeFilterFunc_hdrFilter(JNIEnv* env, jclass object,
jintArray pixels, jint width, jint height) {
jintArray result = procImage(env, pixels, width, height, hdrFilter);
return result;
}
jintArray Java_cn_Ragnarok_NativeFilterFunc_discreteGaussianBlur(JNIEnv* env,
jclass object, jintArray pixels, jint width, jint height) {
jintArray result = procImage(env, pixels, width, height, discreteGaussianBlur);
return result;
}
jintArray Java_cn_Ragnarok_NativeFilterFunc_softGlow(JNIEnv* env, jclass object,
jintArray pixels, jint width, jint height) {
jintArray result = procImage(env, pixels, width, height, softGlowFilter);
return result;
}
|
[
"okone1288@gmail.com"
] |
okone1288@gmail.com
|
10663ecd6affed458fdca455f01f8662e3df5132
|
bd953c12dec3f39ad490284c1d5e025d68a7f39b
|
/expression/Expression.cpp
|
c64a5ddb648f04d92338143c3786fe6398c89915
|
[
"MIT"
] |
permissive
|
benazoulaydev/Flight-Simulator-Cpp
|
b851d9e40027e9f27e8d393e2ac2fc6e3c2ef135
|
aa96de70de78d483636f558648238442ab4c306c
|
refs/heads/master
| 2020-10-01T13:17:06.511283
| 2020-01-05T13:43:20
| 2020-01-05T13:43:20
| 227,545,106
| 0
| 2
| null | 2020-01-05T13:43:21
| 2019-12-12T07:21:35
|
C++
|
UTF-8
|
C++
| false
| false
| 62
|
cpp
|
//
// Created by kfir on 11/3/19.
//
#include "Expression.h"
|
[
"kfir.yehuda50@gmail.com"
] |
kfir.yehuda50@gmail.com
|
8fe19177107fb10563e7f67ee6b5aac8fef7f061
|
23e393f8c385a4e0f8f3d4b9e2d80f98657f4e1f
|
/Windows API函数参考手册/第07章文件处理/7.2设置和获得文件的各种信息/7_2_4_2/7_2_4_2.cpp
|
61d81a04f167ac9cd277529286f66549066ef271
|
[] |
no_license
|
IgorYunusov/Mega-collection-cpp-1
|
c7c09e3c76395bcbf95a304db6462a315db921ba
|
42d07f16a379a8093b6ddc15675bf777eb10d480
|
refs/heads/master
| 2020-03-24T10:20:15.783034
| 2018-06-12T13:19:05
| 2018-06-12T13:19:05
| 142,653,486
| 3
| 1
| null | 2018-07-28T06:36:35
| 2018-07-28T06:36:35
| null |
GB18030
|
C++
| false
| false
| 5,864
|
cpp
|
// 7_2_4_2.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_MY7_2_4_2, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance(hInstance, nCmdShow)) {
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MY7_2_4_2);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_MY7_2_4_2);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = (LPCSTR)IDC_MY7_2_4_2;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd) {
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
switch (message) {
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId) {
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
break;
case WM_LBUTTONDOWN:
DWORD dwLen;
DWORD dwTemp;
LPVOID pVersion;
int rt1;
//获取保存指定文件版本信息所需要的内存大小
dwLen = GetFileVersionInfoSize("C:\\Windows\\system\\User32.DLL", &dwTemp);
//为文件版本信息分配内存
pVersion = malloc(dwLen);
//获取指定文件的文件版本信息
rt1 = GetFileVersionInfo("C:\\Windows\\system\\User32.DLL", 0, dwLen, pVersion);
DWORD dwBytes;
VS_FIXEDFILEINFO* pvsffi;
pvsffi = (VS_FIXEDFILEINFO*)malloc(sizeof(VS_FIXEDFILEINFO));
//获取文件的操作系统信息
rt1 = VerQueryValue(pVersion, (LPTSTR)TEXT("VarFileInfo\\Translation"),
(void**)&pvsffi, (unsigned int*)&dwBytes);
if (pvsffi->dwFileOS & (VOS__WINDOWS32 | VOS_DOS_WINDOWS32))
MessageBox(NULL, "File Is Designed For Win32 API", "FileOS", MB_OK);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
|
[
"wyrover@gmail.com"
] |
wyrover@gmail.com
|
a24a66dcc044754a59f71c67a7261d29641d5cf7
|
5c4a86b7617b35acb2f1bdcbd5d15150914d6695
|
/sourcefile/test 6.3.5.cpp
|
df77a092d24f7a9c4cb63fe06af03425b1d8ee43
|
[
"MIT"
] |
permissive
|
soh9646/soh9646.github.io
|
69f3854c97dbbea0884c42850e8f82061b3cd3e8
|
f820ce25d8945b7d23a18c52c1904b75e9e5b9ef
|
refs/heads/master
| 2020-11-28T05:35:42.306248
| 2020-01-07T14:38:55
| 2020-01-07T14:38:55
| 229,443,954
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 151
|
cpp
|
#include <stdio.h>
int mult(int, int);
main()
{
}
int mult(int x, int y)
{
if(y == 0)
{
return 0;
}
else
{
return x + mult(x, y-1);
}
}
|
[
"59116192+soh9646@users.noreply.github.com"
] |
59116192+soh9646@users.noreply.github.com
|
3c689955592f4d8efff1031a4cec37e8b287551c
|
474ca3fbc2b3513d92ed9531a9a99a2248ec7f63
|
/ThirdParty/boost_1_63_0/libs/geometry/test/algorithms/is_simple.cpp
|
0c42d7e6e1da5f394fee5b6def4e2b8ebc2bef67
|
[
"BSL-1.0"
] |
permissive
|
LazyPlanet/MX-Architecture
|
17b7b2e6c730409b22b7f38633e7b1f16359d250
|
732a867a5db3ba0c716752bffaeb675ebdc13a60
|
refs/heads/master
| 2020-12-30T15:41:18.664826
| 2018-03-02T00:59:12
| 2018-03-02T00:59:12
| 91,156,170
| 4
| 0
| null | 2018-02-04T03:29:46
| 2017-05-13T07:05:52
|
C++
|
UTF-8
|
C++
| false
| false
| 15,214
|
cpp
|
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2014-2015, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#ifndef BOOST_TEST_MODULE
#define BOOST_TEST_MODULE test_is_simple
#endif
#include <iostream>
#include <string>
#include <boost/assert.hpp>
#include <boost/variant/variant.hpp>
#include <boost/test/included/unit_test.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/multi_point.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/algorithms/is_valid.hpp>
#include <boost/geometry/algorithms/is_simple.hpp>
#include <from_wkt.hpp>
#ifdef BOOST_GEOMETRY_TEST_DEBUG
#include "pretty_print_geometry.hpp"
#endif
namespace bg = ::boost::geometry;
typedef bg::model::point<double, 2, bg::cs::cartesian> point_type;
typedef bg::model::segment<point_type> segment_type;
typedef bg::model::linestring<point_type> linestring_type;
typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
// ccw open and closed polygons
typedef bg::model::polygon<point_type,false,false> open_ccw_polygon_type;
typedef bg::model::polygon<point_type,false,true> closed_ccw_polygon_type;
// multi-geometries
typedef bg::model::multi_point<point_type> multi_point_type;
typedef bg::model::multi_polygon<open_ccw_polygon_type> multi_polygon_type;
// box
typedef bg::model::box<point_type> box_type;
//----------------------------------------------------------------------------
template <typename Geometry>
void test_simple(Geometry const& geometry, bool expected_result,
bool check_validity = true)
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << "=======" << std::endl;
#endif
bool simple = bg::is_simple(geometry);
BOOST_ASSERT( ! check_validity || bg::is_valid(geometry) );
BOOST_CHECK_MESSAGE( simple == expected_result,
"Expected: " << expected_result
<< " detected: " << simple
<< " wkt: " << bg::wkt(geometry) );
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << "Geometry: ";
pretty_print_geometry<Geometry>::apply(std::cout, geometry);
std::cout << std::endl;
std::cout << std::boolalpha;
std::cout << "is simple: " << simple << std::endl;
std::cout << "expected result: " << expected_result << std::endl;
std::cout << "=======" << std::endl;
std::cout << std::endl << std::endl;
std::cout << std::noboolalpha;
#endif
}
//----------------------------------------------------------------------------
BOOST_AUTO_TEST_CASE( test_is_simple_point )
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << std::endl << std::endl;
std::cout << "************************************" << std::endl;
std::cout << " is_simple: POINT " << std::endl;
std::cout << "************************************" << std::endl;
#endif
typedef point_type G;
test_simple(from_wkt<G>("POINT(0 0)"), true);
}
BOOST_AUTO_TEST_CASE( test_is_simple_multipoint )
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << std::endl << std::endl;
std::cout << "************************************" << std::endl;
std::cout << " is_simple: MULTIPOINT " << std::endl;
std::cout << "************************************" << std::endl;
#endif
typedef multi_point_type G;
test_simple(from_wkt<G>("MULTIPOINT(0 0)"), true);
test_simple(from_wkt<G>("MULTIPOINT(0 0,1 0,1 1,0 1)"), true);
test_simple(from_wkt<G>("MULTIPOINT(0 0,1 0,1 1,1 0,0 1)"), false);
// empty multipoint
test_simple(from_wkt<G>("MULTIPOINT()"), true);
}
BOOST_AUTO_TEST_CASE( test_is_simple_segment )
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << std::endl << std::endl;
std::cout << "************************************" << std::endl;
std::cout << " is_simple: SEGMENT " << std::endl;
std::cout << "************************************" << std::endl;
#endif
typedef segment_type G;
test_simple(from_wkt<G>("SEGMENT(0 0,1 0)"), true);
}
BOOST_AUTO_TEST_CASE( test_is_simple_linestring )
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << std::endl << std::endl;
std::cout << "************************************" << std::endl;
std::cout << " is_simple: LINESTRING " << std::endl;
std::cout << "************************************" << std::endl;
#endif
typedef linestring_type G;
// valid linestrings with multiple points
test_simple(from_wkt<G>("LINESTRING(0 0,0 0,1 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,0 0,1 0,0 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,0 0,1 0,1 0,1 1,0 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,2 0,1 1,1 0,1 -1)"), false);
// simple open linestrings
test_simple(from_wkt<G>("LINESTRING(0 0,1 2)"), true);
test_simple(from_wkt<G>("LINESTRING(0 0,1 2,2 3)"), true);
// simple closed linestrings
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,1 1,0 0)"), true);
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,1 1,0 1,0 0)"), true);
test_simple(from_wkt<G>("LINESTRING(0 0,10 0,10 10,0 10,0 0)"), true);
// non-simple linestrings
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,0 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,2 10,0.5 -1)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,2 1,1 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,2 1,0.5 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,2 0,1 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,3 0,5 0,1 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,3 0,5 0,4 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,3 0,5 0,4 0,2 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,3 0,2 0,5 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,2 0,2 2,1 0,0 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,2 0,2 2,1 0,0 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,10 0,10 10,0 10,0 0,0 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,0 10,5 10,0 0,10 10,10 5,10 0,0 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,0 0,10 0,10 10,0 10,0 0,0 0)"),
false);
test_simple(from_wkt<G>("LINESTRING(0 0,0 0,0 0,10 0,10 10,0 10,0 0,0 0,0 0,0 0)"),
false);
test_simple(from_wkt<G>("LINESTRING(0 0,0 0,10 0,10 10,10 10,10 10,10 10,10 10,0 10,0 0,0 0)"),
false);
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,2 0,2 2,1 0)"), false);
test_simple(from_wkt<G>("LINESTRING(1 0,2 2,2 0,1 0,0 0)"), false);
test_simple(from_wkt<G>("LINESTRING(0 0,1 0,2 0,2 2,1 0,1 4,0 0)"), false);
test_simple(from_wkt<G>("LINESTRING(4 1,10 8,4 6,4 1,10 5,10 3)"),
false);
test_simple(from_wkt<G>("LINESTRING(10 3,10 5,4 1,4 6,10 8,4 1)"),
false);
// empty linestring
// the simplicity result is irrelevant since an empty linestring
// is considered as invalid
test_simple(from_wkt<G>("LINESTRING()"), false, false);
}
BOOST_AUTO_TEST_CASE( test_is_simple_multilinestring )
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << std::endl << std::endl;
std::cout << "************************************" << std::endl;
std::cout << " is_simple: MULTILINESTRING " << std::endl;
std::cout << "************************************" << std::endl;
#endif
typedef multi_linestring_type G;
// multilinestrings with linestrings with spikes
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0,0 0),(5 0,6 0,7 0))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0,0 0),(5 0,1 0,4 1))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0,0 0),(5 0,1 0,4 0))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0,0 0),(1 0,2 0))"),
false);
// simple multilinestrings
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 1),(1 1,1 0))"), true);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 1),(1 1,1 0),(0 1,1 1))"),
true);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2),(0 0,1 0,2 0,2 2))"), true);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2),(2 2,2 0,1 0,0 0))"), true);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0),(0 0,-1 0),(1 0,2 0))"),
true);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0),(-1 0,0 0),(2 0,1 0))"),
true);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0),(0 0,0 1),(0 0,-1 0),(0 0,0 -1))"),
true);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0))"), true);
// non-simple multilinestrings
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2),(0 0,2 2))"), false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2),(2 2,0 0))"), false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2),(0 0,1 0,1 1,2 0,2 2))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 1,2 2),(0 0,1 0,1 1,2 0,2 2))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 1,2 2),(2 2,0 0))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2,4 4),(0 0,1 1))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2,4 4),(0 0,3 3))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2,4 4),(1 1,3 3))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2,4 4),(1 1,2 2))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2,4 4),(2 2,3 3))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2,4 4),(2 2,4 4))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 2,4 4),(4 4,2 2))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 1),(0 1,1 0))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,2 0),(1 0,0 1))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 1),(1 1,1 0),(1 1,0 1,0.5,0.5))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0,1 1,0 1,0 0),(1 0,1 -1))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0,1 1,0 1,0 0),(-1 0,0 0))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0,1 1,0 1,0 0),(0 0,-1 0,-1 -1,0 -1,0 0))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,1 0,1 1,0 1,0 0),(-1 -1,-1 0,0 0,0 -1,-1 -1))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((0 0,0 10,5 10,0 0,10 10,10 5,10 0,0 0))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((4 1,10 8,4 6,4 1,10 5,10 3))"),
false);
test_simple(from_wkt<G>("MULTILINESTRING((10 3,10 5,4 1,4 6,10 8,4 1))"),
false);
// empty multilinestring
test_simple(from_wkt<G>("MULTILINESTRING()"), true);
}
BOOST_AUTO_TEST_CASE( test_is_simple_areal )
{
typedef box_type b;
typedef open_ccw_polygon_type o_ccw_p;
typedef multi_polygon_type mpl;
// check that is_simple compiles for boxes
test_simple(from_wkt<b>("BOX(0 0,1 1)"), true);
// simple polygons and multi-polygons
test_simple(from_wkt<o_ccw_p>("POLYGON((0 0,1 0,1 1))"), true);
test_simple(from_wkt<o_ccw_p>("POLYGON((0 0,10 0,10 10,0 10),(1 1,1 9,9 9,9 1))"),
true);
test_simple(from_wkt<mpl>("MULTIPOLYGON(((0 0,1 0,1 1)),((10 0,20 0,20 10,10 10)))"),
true);
// non-simple polygons & multi-polygons (have duplicate points)
test_simple(from_wkt<o_ccw_p>("POLYGON((0 0,1 0,1 0,1 1))"), false);
test_simple(from_wkt<o_ccw_p>("POLYGON((0 0,10 0,10 10,0 10),(1 1,1 9,9 9,9 9,9 1))"),
false);
test_simple(from_wkt<mpl>("MULTIPOLYGON(((0 0,1 0,1 1,1 1)),((10 0,20 0,20 0,20 10,10 10)))"),
false);
// empty polygon
// the simplicity result is irrelevant since an empty polygon
// is considered as invalid
test_simple(from_wkt<o_ccw_p>("POLYGON(())"), false, false);
// empty multipolygon
test_simple(from_wkt<mpl>("MULTIPOLYGON()"), true);
}
BOOST_AUTO_TEST_CASE( test_geometry_with_NaN_coordinates )
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << std::endl << std::endl;
std::cout << "************************************" << std::endl;
std::cout << " is_valid: geometry with NaN coordinates" << std::endl;
std::cout << "************************************" << std::endl;
#endif
linestring_type ls1, ls2;
bg::read_wkt("LINESTRING(1 1,1.115235e+308 1.738137e+308)", ls1);
bg::read_wkt("LINESTRING(-1 1,1.115235e+308 1.738137e+308)", ls2);
// the intersection of the two linestrings is a new linestring
// (multilinestring with a single element) that has NaN coordinates
multi_linestring_type mls;
bg::intersection(ls1, ls2, mls);
test_simple(mls, true, false);
}
BOOST_AUTO_TEST_CASE( test_is_simple_variant )
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << std::endl << std::endl;
std::cout << "************************************" << std::endl;
std::cout << " is_simple: variant support" << std::endl;
std::cout << "************************************" << std::endl;
#endif
typedef bg::model::polygon<point_type> polygon_type; // cw, closed
typedef boost::variant
<
linestring_type, multi_linestring_type, polygon_type
> variant_geometry;
variant_geometry vg;
linestring_type simple_linestring =
from_wkt<linestring_type>("LINESTRING(0 0,1 0)");
multi_linestring_type non_simple_multi_linestring = from_wkt
<
multi_linestring_type
>("MULTILINESTRING((0 0,1 0,1 1,0 0),(10 0,1 1))");
polygon_type simple_polygon =
from_wkt<polygon_type>("POLYGON((0 0,1 1,1 0,0 0))");
polygon_type non_simple_polygon =
from_wkt<polygon_type>("POLYGON((0 0,1 1,1 0,1 0,0 0))");
vg = simple_linestring;
test_simple(vg, true);
vg = non_simple_multi_linestring;
test_simple(vg, false);
vg = simple_polygon;
test_simple(vg, true);
vg = non_simple_polygon;
test_simple(vg, false);
}
|
[
"1211618464@qq.com"
] |
1211618464@qq.com
|
7322aea21e900190e135362a70beaf83fed8e96e
|
157fd7fe5e541c8ef7559b212078eb7a6dbf51c6
|
/TRiAS/TRiAS/TRiAS01/FLEX.CXX
|
9db7942f2347b921957423f208a680603cfe2740
|
[] |
no_license
|
15831944/TRiAS
|
d2bab6fd129a86fc2f06f2103d8bcd08237c49af
|
840946b85dcefb34efc219446240e21f51d2c60d
|
refs/heads/master
| 2020-09-05T05:56:39.624150
| 2012-11-11T02:24:49
| 2012-11-11T02:24:49
| null | 0
| 0
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 14,304
|
cxx
|
/* Dynamische Felder fuer F77 Anwendungen */
/* File: FLEX.C */
#include "trias01p.hxx"
#include <flex.h>
#include <fprotos.h>
#if !defined(_MSC_VER)
#define _MSC_VER 500
#endif
FLEX flexes[MAXFLEXES] = {
{ NULL, 0, 0, FALSE, FALSE }, /* 1 */
{ NULL, 0, 0, FALSE, FALSE }, /* 2 */
{ NULL, 0, 0, FALSE, FALSE }, /* 3 */
{ NULL, 0, 0, FALSE, FALSE }, /* 4 */
{ NULL, 0, 0, FALSE, FALSE }, /* 5 */
{ NULL, 0, 0, FALSE, FALSE }, /* 6 */
{ NULL, 0, 0, FALSE, FALSE }, /* 7 */
{ NULL, 0, 0, FALSE, FALSE }, /* 8 */
{ NULL, 0, 0, FALSE, FALSE }, /* 9 */
{ NULL, 0, 0, FALSE, FALSE }, /* 10 */
{ NULL, 0, 0, FALSE, FALSE }, /* 11 */
{ NULL, 0, 0, FALSE, FALSE }, /* 12 */
{ NULL, 0, 0, FALSE, FALSE }, /* 13 */
{ NULL, 0, 0, FALSE, FALSE }, /* 14 */
{ NULL, 0, 0, FALSE, FALSE }, /* 15 */
{ NULL, 0, 0, FALSE, FALSE }, /* 16 */
{ NULL, 0, 0, FALSE, FALSE }, /* 17 */
{ NULL, 0, 0, FALSE, FALSE }, /* 18 */
{ NULL, 0, 0, FALSE, FALSE }, /* 19 */
{ NULL, 0, 0, FALSE, FALSE }, /* 20 */
};
// static functions
int flcomp (const void FAR *prim, const void FAR *sec);
/* Initialisieren eines Flex's */
extern "C" long FUNCTYPE EXPORT01 feini_ (long *lnum)
// INT *lnum; /* wenn gleich 0, dann neuen Flex anfordern */
{
register short num = (short)*lnum;
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
register FLEX __based((__segment)&flexes) *fl_p;
#else
register FLEX *fl_p;
#endif
if (num < 0 || num >= MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_INI));
if (num == 0) {
/* Flex noch nicht existent */
register int i;
for (i = 0; i < MAXFLEXES; ++i)
if (flexes[i].used == FALSE) break;
if (i == MAXFLEXES)
/* Kein Flex mehr frei */
return ((long)db_error (S_NOFLEX, FLEX_INI));
*lnum = num = i + 1;
flexes[i].used = TRUE;
}
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
fl_p = (FLEX __based((__segment)&flexes) *)&flexes[num-1];
#else
fl_p = &flexes[num-1];
#endif
/* Freigeben des Speicherplatzes */
if (fl_p->pFlex != NULL) {
#ifdef MSWIND
GlobalUnlock (fl_p->handle);
GlobalFree (fl_p->handle);
fl_p->handle = 0;
#else
free (fl_p->pFlex);
#endif
}
fl_p->pFlex = NULL;
/* Initialisieren der Laengenangaben */
fl_p->len = 0;
fl_p->max = 0;
fl_p->iShrink = FALSE;
return ((long)(db_status = S_OKAY));
}
/* Setzen des Flags, welches die Verdichtbarkeit beschreibt */
extern "C" long FUNCTYPE EXPORT01 FlexShrink (short num, short newFlag)
{
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
register FLEX __based((__segment)&flexes) *fl_p;
#else
register FLEX *fl_p;
#endif
if (num <= 0 || num > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_SHRINK));
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
fl_p = (FLEX __based((__segment)&flexes) *)&flexes[num-1];
#else
fl_p = &flexes[num-1];
#endif
// ShrinkFlag setzen
fl_p -> iShrink = newFlag;
return ((long)(db_status = S_OKAY));
}
/* Freigeben eines Flex's */
extern "C" long FUNCTYPE EXPORT01 ferel_ (long *lnum)
{
register short num = (short)*lnum;
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
register FLEX __based((__segment)&flexes) *fl_p;
#else
register FLEX *fl_p;
#endif
if (num <= 0 || num > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_RELEASE));
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
fl_p = (FLEX __based((__segment)&flexes) *)&flexes[num-1];
#else
fl_p = &flexes[num-1];
#endif
/* Freigeben des Speicherplatzes */
if (fl_p->pFlex != NULL) {
#ifdef MSWIND
GlobalUnlock (fl_p->handle);
GlobalFree (fl_p->handle);
fl_p->handle = 0;
#else
free (fl_p->pFlex);
#endif
}
fl_p->pFlex = NULL;
/* Initialisieren der Laengenangaben */
fl_p->len = 0;
fl_p->max = 0;
fl_p->used = FALSE;
fl_p->iShrink = FALSE;
return ((long)(db_status = S_OKAY));
}
/* Einspeichern eines Elementes */
extern "C" long FUNCTYPE EXPORT01 feput_ (long *lnum, long *new_elem)
{
register short num = (short)*lnum;
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
register FLEX __based ((__segment)&flexes) *fl_p;
#else
register FLEX *fl_p;
#endif
if (num <= 0 || num > MAXFLEXES) return ((long)db_error (S_BADFLEX, FLEX_PUT));
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
fl_p = (FLEX __based((__segment)&flexes) *)&flexes[num-1];
#else
fl_p = &flexes[num-1];
#endif
if (fl_p->pFlex == NULL) {
#ifdef MSWIND
fl_p -> handle = GlobalAlloc (GHND, FLEXSTEP*sizeof(long));
if (fl_p -> handle == NULL)
return ((long)db_error (S_NOMEMORY, FLEX_PUT));
fl_p->pFlex = (long *)GlobalLock (fl_p -> handle);
#else
fl_p->pFlex = calloc (FLEXSTEP, sizeof(long));
#endif
if (fl_p->pFlex == NULL)
return ((long)db_error (S_NOMEMORY, FLEX_PUT));
fl_p->max = FLEXSTEP;
fl_p->len = 0;
} else if (fl_p->len == fl_p->max) {
// Feld ist zu klein, evtl. vergrößern
/* if (fl_p -> iShrink == TRUE) {
// Feld wird zu klein, erst mal packen #HK920205
INT newLen;
flqsrt_ (lnum); // sortieren
flredn_ (lnum, &newLen); // und packen
}
if (fl_p->len == fl_p->max)
*/ {
// Feld ist immer noch zu klein
unsigned long newSize = ((unsigned)fl_p->max * 2L)*sizeof(long);
#ifdef MSWIND
GlobalUnlock (fl_p -> handle);
HGLOBAL hGlb = GlobalReAlloc (fl_p -> handle, newSize, GMEM_MOVEABLE);
if (hGlb == NULL)
return ((long)db_error (S_NOMEMORY, FLEX_PUT));
fl_p -> handle = hGlb;
fl_p->pFlex = (long *)GlobalLock (fl_p->handle);
#else
fl_p->pFlex = realloc (fl_p->pFlex,
(fl_p->max + FLEXSTEP)*sizeof(long));
#endif
if (fl_p->pFlex == NULL)
return ((long)db_error (S_NOMEMORY, FLEX_PUT));
// fl_p->max += FLEXSTEP;
fl_p->max = newSize/sizeof(long);
}
}
fl_p->pFlex[fl_p->len++] = *new_elem;
db_status = S_OKAY;
return ((long)fl_p->len);
}
/* Lesen eines Elementes aus einem Flex */
extern "C" long FUNCTYPE EXPORT01 feget_ (long *lnum, long *index, long *elem)
// INT *lnum; /* Flexnummer */
// INT *index; /* Flexindex */
// INT *elem; /* Element hierhin schreiben */
{
register short num = (short)*lnum;
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
register FLEX __based((__segment)&flexes) *fl_p;
#else
register FLEX *fl_p;
#endif
if (num <= 0 || num > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_GET));
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
fl_p = (FLEX __based((__segment)&flexes) *)&flexes[num-1];
#else
fl_p = &flexes[num-1];
#endif
if (fl_p->pFlex == NULL)
return ((long)db_error (S_FLEXINI, FLEX_GET));
if (*index <= 0 || *index > (long)fl_p->len)
return ((long)db_error (S_BADINDEX, FLEX_GET));
*elem = fl_p->pFlex[*index-1];
return ((long)(db_status = S_OKAY));
}
/* Feststellen der Flexlaenge */
extern "C" long FUNCTYPE EXPORT01 felen_ (long *lnum, long *len)
// INT *lnum; /* Flexnummer */
// INT *len; /* Resultat: Flexlaenge */
{
register short num = (short)*lnum;
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
register FLEX __based((__segment)&flexes) *fl_p;
#else
register FLEX *fl_p;
#endif
if (num <= 0 || num > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_LEN));
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
fl_p = (FLEX __based((__segment)&flexes) *)&flexes[num-1];
#else
fl_p = &flexes[num-1];
#endif
if (fl_p->pFlex == NULL)
*len = 0;
else
*len = fl_p->len;
return ((long)(db_status = S_OKAY));
}
/* Lesen eines Bereiches eines Flex's */
extern "C" long FUNCTYPE EXPORT01 feread_ (long *num, long *lbegin, long *llen, long *feld)
// INT *num; /* Flexnummer */
// INT *lbegin; /* Startindex */
// INT *llen; /* Feldgroesse */
// INT *feld; /* wohin zu schreiben */
{
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
register FLEX __based((__segment)&flexes) *fl_p;
#else
register FLEX *fl_p;
#endif
long begin = *lbegin, len = *llen;
long i;
long j;
if (*num <= 0 || *num > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_READ));
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
fl_p = (FLEX __based((__segment)&flexes) *)&flexes[*num-1];
#else
fl_p = &flexes[*num-1];
#endif
if (fl_p->pFlex == NULL)
return ((long)db_error (S_FLEXINI, FLEX_READ));
if (begin > (long)fl_p->len || begin + len <= 0)
return ((long)db_error (S_BADINDEX, FLEX_READ));
/* Teilfeld umkopieren */
long lLast = ((begin + len -1 <= (long)fl_p->len) ? begin + len -1 : (long)fl_p->len);
for (i = (begin > 0) ? begin -1 : 0, j = 0; i < lLast; ++i, ++j)
feld[j] = fl_p->pFlex[i];
/* Anzahl der real geschriebenen Feldelemente */
*llen = j;
return ((long)(db_status = S_OKAY));
}
/* Schreiben eines Bereiches eines Flex's */
extern "C" long FUNCTYPE EXPORT01 fewrit_ (long *num, long *begin, long *len, long *feld)
// INT *num; /* Flexnummer */
// INT *begin; /* Startindex */
// INT *len; /* Feldgroesse */
// INT *feld; /* Quellfeld */
{
register FLEX *fl_p;
register long i, j;
if (*num <= 0 || *num > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_WRITE));
fl_p = &flexes[*num-1];
if (fl_p->pFlex == NULL)
return ((long)db_error (S_FLEXINI, FLEX_WRITE));
if (*begin > (long)fl_p->len || *begin + *len <= 0)
return ((long)db_error (S_BADINDEX, FLEX_WRITE));
/* Teilfeld umkopieren */
long lLast = ((*begin + *len -1 <= (long)fl_p->len) ? *begin + *len -1 : (long)fl_p->len);
for (i = (*begin > 0) ? *begin -1 : 0, j = 0; i < lLast; ++i, ++j)
fl_p->pFlex[i] = feld[j];
/* solange Feld noch nicht vollstaendig geschrieben */
while (j < *len)
if (feput_ (num, &feld[j++]) < 0) return ((long)db_status);
/* Anzahl der real geschriebenen Feldelemente */
*len = j;
return ((long)(db_status = S_OKAY));
}
/* Sortieren eines der dynamischen Felder */
extern "C" long FUNCTYPE EXPORT01 flqsrt_ (long *num)
{
register FLEX *fl_p;
if (*num <= 0 || *num > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_QSRT));
fl_p = &flexes[*num-1];
if (fl_p->pFlex == NULL)
return ((long)db_error (S_FLEXINI, FLEX_QSRT));
qsort (fl_p->pFlex, (size_t)fl_p->len, sizeof(long), flcomp);
return ((long)(db_status = S_OKAY));
}
/* Vergleichsfunktion fuer QSORT */
int flcomp (const void *prim, const void *sec)
{
long tmp = *(long *)prim - *(long *)sec;
if (tmp < 0) return -1;
if (tmp > 0) return 1;
return 0;
}
/* loeschen doppelter Feldelemente, setzt voraus, dass Feld sortiert ist */
extern "C" long FUNCTYPE EXPORT01 flredn_ (long *lnum, long *len)
// INT *lnum; /* Feldnummer */
// INT *len; /* Rueckgabewert: neue Feldlaenge */
{
short num = (short)*lnum;
register FLEX *fl_p;
register long __huge *pNew, __huge *old;
long __huge *top;
if (num <= 0 || num > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_REDN));
fl_p = &flexes[num-1];
if (fl_p->pFlex == NULL)
return ((long)db_error (S_FLEXINI, FLEX_REDN));
top = &fl_p->pFlex[fl_p->len];
for (pNew = fl_p->pFlex, old = pNew + 1; old < top; ++old) {
if (*pNew == *old)
/* gleiche Feldelemente */
continue; /* nur oberen Zeiger weitersetzen */
else if (old - pNew > 1)
/* Elemente ungleich und kopieren */
*++pNew = *old;
else
/* Elemente ungleich aber nicht kopieren */
++pNew; /* naechstes Bezugselement */
}
*len = fl_p->len = pNew - fl_p->pFlex + 1; /* neue Feldlaenge */
return ((long)(db_status = S_OKAY));
}
// Funktion liefert die Speicheradresse eines Flex's
extern "C" long FUNCTYPE EXPORT01 FlexAdr (short lnum, long **Address)
{
if (lnum <= 0 || lnum > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_ADR));
*Address = flexes[lnum-1].pFlex;
return ((long)(db_status = S_OKAY));
}
// Funktion liefert die Speicheradresse eines Flex's
extern "C" long FUNCTYPE EXPORT01 FlexAccessAdr (short lnum, long **Address, unsigned long **pLen)
{
if (lnum <= 0 || lnum > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_ADR));
*Address = flexes[lnum-1].pFlex;
*pLen = &flexes[lnum-1].len;
return ((long)(db_status = S_OKAY));
}
/* Einspeichern eines Elementes */
extern "C" long FUNCTYPE EXPORT01 FlexReserve (short lnum, long new_elems)
{
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
register FLEX __based ((__segment)&flexes) *fl_p;
#else
register FLEX *fl_p;
#endif
if (lnum <= 0 || lnum > MAXFLEXES)
return ((long)db_error (S_BADFLEX, FLEX_RESERVE));
#if !defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 600
fl_p = (FLEX __based((__segment)&flexes) *)&flexes[lnum-1];
#else
fl_p = &flexes[lnum-1];
#endif
if (NULL == fl_p->pFlex) {
#ifdef MSWIND
fl_p -> handle = GlobalAlloc (GHND, new_elems*sizeof(long));
if (fl_p -> handle == NULL)
return ((long)db_error (S_NOMEMORY, FLEX_RESERVE));
fl_p->pFlex = (long *)GlobalLock (fl_p -> handle);
#else
fl_p->pFlex = calloc (FLEXSTEP, sizeof(long));
#endif
if (fl_p->pFlex == NULL)
return ((long)db_error (S_NOMEMORY, FLEX_RESERVE));
fl_p->max = new_elems;
fl_p->len = 0;
} else if (fl_p->max < new_elems) {
// Feld ist zu klein, evtl. vergrößern
#ifdef MSWIND
GlobalUnlock (fl_p -> handle);
HGLOBAL hGlb = GlobalReAlloc (fl_p -> handle, new_elems*sizeof(long), GMEM_MOVEABLE);
if (hGlb == NULL)
return ((long)db_error (S_NOMEMORY, FLEX_RESERVE));
fl_p -> handle = hGlb;
fl_p->pFlex = (long *)GlobalLock (fl_p->handle);
#else
fl_p->pFlex = realloc (fl_p->pFlex, new_elems*sizeof(long));
#endif
if (fl_p->pFlex == NULL)
return ((long)db_error (S_NOMEMORY, FLEX_RESERVE));
fl_p->max = new_elems;
}
db_status = S_OKAY;
return ((long)fl_p->max);
}
|
[
"Windows Live ID\\hkaiser@cct.lsu.edu"
] |
Windows Live ID\hkaiser@cct.lsu.edu
|
39cbdb82c31bdf2fa309648da3bf0a6566acf247
|
a62342d6359a88b0aee911e549a4973fa38de9ea
|
/0.6.0.3/External/SDK/BP_FurnitureWorkbench_ToolShed_parameters.h
|
7852b8baa501e91be99c0d0d2b9fe42f74564b38
|
[] |
no_license
|
zanzo420/Medieval-Dynasty-SDK
|
d020ad634328ee8ee612ba4bd7e36b36dab740ce
|
d720e49ae1505e087790b2743506921afb28fc18
|
refs/heads/main
| 2023-06-20T03:00:17.986041
| 2021-07-15T04:51:34
| 2021-07-15T04:51:34
| 386,165,085
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,219
|
h
|
#pragma once
// Name: Medieval Dynasty, Version: 0.6.0.3
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Parameters
//---------------------------------------------------------------------------
// Function BP_FurnitureWorkbench_ToolShed.BP_FurnitureWorkbench_ToolShed_C.FinishFurniture
struct ABP_FurnitureWorkbench_ToolShed_C_FinishFurniture_Params
{
bool Load; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor)
};
// Function BP_FurnitureWorkbench_ToolShed.BP_FurnitureWorkbench_ToolShed_C.ExecuteUbergraph_BP_FurnitureWorkbench_ToolShed
struct ABP_FurnitureWorkbench_ToolShed_C_ExecuteUbergraph_BP_FurnitureWorkbench_ToolShed_Params
{
int EntryPoint; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
[
"zp2kshield@gmail.com"
] |
zp2kshield@gmail.com
|
91f559d611f0779a9cd80201eb3fa9a532681537
|
9bb35fdebb945f4c1f09c0aeba9ff4ff053fe74b
|
/code/SK-iM282A/WiMOD_LR_ExampleCode_V1_1/PC/WiMODLR_ExampleCode/WiMODLR_ExampleCode/Utils/RegistryKey.h
|
e46f89e3306fc664cf5e7ad644ff08867f7ff020
|
[] |
no_license
|
junyang28/paper-ctclora
|
4c9bb25767a30ae2d016c1d76e82a0132f6e527a
|
524574ada9149d482dc76e8699c275d4986b1e3c
|
refs/heads/master
| 2022-11-27T21:38:06.723717
| 2020-08-10T14:01:14
| 2020-08-10T14:01:14
| 282,961,802
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,653
|
h
|
//------------------------------------------------------------------------------
//
// File: RegistryKey.h
//
// Abstract: Windows Registry Helper Class Declaration
//
// Version: 0.1
//
// Date: 09.02.2015
//
// Disclaimer: This example code is provided by IMST GmbH on an "AS IS" basis
// without any warranties.
//
//------------------------------------------------------------------------------
#ifndef REGISTRYKEY_H
#define REGISTRYKEY_H
#include <Qt>
// only supported for windows platforms !
#ifdef Q_OS_WIN
#include <qstringlist.h>
#include <windows.h>
#define MAX_KEY_LENGTH 256
#define MAX_VALUE_NAME 4096
//------------------------------------------------------------------------------
//
// TRegistryKey - Class Declaration
//
//------------------------------------------------------------------------------
class TRegistryKey
{
public:
TRegistryKey();
TRegistryKey(HKEY key);
virtual ~TRegistryKey();
void LocalMachine();
TRegistryKey* OpenSubKey(const QString& keyName);
const QStringList& GetSubKeyNames();
int GetKeyValues(QStringList& list);
const QString& GetValue(const QString keyName);
private:
private:
HKEY HKey;
QStringList SubKeys;
QString Value;
};
#endif // WINDOWS
#endif // REGISTRYKEY_H
//------------------------------------------------------------------------------
// end of file
//------------------------------------------------------------------------------
|
[
"shijunyanghust@hotmail.com"
] |
shijunyanghust@hotmail.com
|
8a782c169bf3079cc74540207af430e09cd3f988
|
ff60060132b6e991457e6971d867ee8c44b32843
|
/consumer.cpp
|
032723f09b3c205edcd77fa341fb728de7e066ed
|
[] |
no_license
|
profsung/os_shared_memory_racecondition
|
d8c62acbb9756ae3ca246d1154a88cf4e547898c
|
f88df4dd15130b3a3c02e9c84a138549c4c23ec6
|
refs/heads/master
| 2023-07-13T03:17:39.971796
| 2021-08-22T18:34:15
| 2021-08-22T18:34:15
| 398,837,288
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 822
|
cpp
|
#include <sys/mman.h> // shm_open() mmap() munmap()
#include <sys/stat.h> // mode constants
#include <fcntl.h> // O_* constants
#include <unistd.h> // ftruncate() close()
#include <stdlib.h> // exit()
#include <stdio.h> // printf/scanf
#include "my_defs.h"
int main() {
int fd;
for ( ; ;) {
fd = shm_open(NAME, O_RDWR, 0666);
if (fd >= 0) break;
printf("waiting for producer to create a shared memory ...\n");
sleep(1);
}
int* p_data = (int *)
mmap(0, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
printf("Consumer successfully opened shared memory.\n");
for (int i = 0; i < 1000; i++) {
p_data[0] = 9999;
int us = rand() % 1500000; // 1.5 sec
usleep(us);
printf("[%d] consumer: %d\n", i, p_data[0]);
}
munmap(p_data, SIZE);
close(fd);
shm_unlink(NAME); // shared memory is deleted
}
|
[
"hsung@uco.edu"
] |
hsung@uco.edu
|
bac8b73bfdd5a789464d48d99ab0ea46b9457b78
|
b33a9177edaaf6bf185ef20bf87d36eada719d4f
|
/qttools/src/designer/src/designer/doc/snippets/lib/tools_designer_src_lib_uilib_abstractformbuilder.cpp
|
7d9346adde3cd9c191662abf38400dfa7f86f8bb
|
[
"Qt-LGPL-exception-1.1",
"LGPL-2.1-only",
"LGPL-2.0-or-later",
"LGPL-3.0-only",
"GPL-3.0-only",
"LGPL-2.1-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"GPL-2.0-only",
"GFDL-1.3-only",
"LicenseRef-scancode-digia-qt-preview",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-generic-exception"
] |
permissive
|
wgnet/wds_qt
|
ab8c093b8c6eead9adf4057d843e00f04915d987
|
8db722fd367d2d0744decf99ac7bafaba8b8a3d3
|
refs/heads/master
| 2021-04-02T11:07:10.181067
| 2020-06-02T10:29:03
| 2020-06-02T10:34:19
| 248,267,925
| 1
| 0
|
Apache-2.0
| 2020-04-30T12:16:53
| 2020-03-18T15:20:38
| null |
UTF-8
|
C++
| false
| false
| 2,399
|
cpp
|
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "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 Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
//! [0]
MyForm::MyForm(QWidget *parent)
: QWidget(parent)
{
QFormBuilder builder;
QFile file(":/forms/myWidget.ui");
file.open(QFile::ReadOnly);
QWidget *myWidget = builder.load(&file, this);
file.close();
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(myWidget);
setLayout(layout);
}
//! [0]
|
[
"p_pavlov@wargaming.net"
] |
p_pavlov@wargaming.net
|
7d7f3bc2918fcc5a952da37850502ed8b65e0aa6
|
86196410ce9fc5764c95c8202bf11a30ae0ac8bd
|
/QTCube/gui/float_buffer.cpp
|
c7b8958ae111d383c06f5cb8291c03bd8b89a21f
|
[] |
no_license
|
scc-gatech/born-mono
|
3af90cde4547e57e9dacd1d12859918f1b0d5926
|
3749665a2cf07409803b92d963cd53b53c01edd9
|
refs/heads/master
| 2021-08-12T00:33:30.482707
| 2017-11-14T07:15:54
| 2017-11-14T07:15:54
| 106,741,008
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,584
|
cpp
|
#include "float_buffer.h"
#include<iostream>
#include<stdlib.h>
using namespace SEP;
//Initialize and read in buffer
float_buffer::float_buffer(std::shared_ptr<paramObj>p, std::shared_ptr<hypercube>h,std::shared_ptr<io_func>i,int in,std::vector<int>&nwbuf, std::vector<int>&fwbuf){
set_basics(p,h,i,in);
window_to_local(nwbuf,fwbuf);
fbuf=new float [n123_buf];
int ndim;
std::vector<int> nwio(8,1),fwio(8,0),nloop(8,1);
calc_read_loop(nwbuf,fwbuf,nwio,fwio,nloop,ndim);
read_buffer(nwbuf,fwbuf,nwio,fwio,ndim,nloop);
float minv, maxv;
io->return_clips(&minv,&maxv);
}
void float_buffer::read_buffer(std::vector<int>&nwbuf, std::vector<int>&fwbuf,std::vector<int>&nwio, std::vector<int>&fwio, int ndim ,std::vector<int>&nloop){
long long nblock=1,off=0;
long long block=1;
for(int i=0; i< ndim; i++) block=block*(long long) nwbuf[i];
for(int i=0; i< ndim; i++) nblock=nblock*(long long)nwio[i];
long long count=0;
std::vector<int>fsend(8,0);fsend[0]=fwbuf[0]; fsend[1]=fwbuf[1];
for(int i7=0; i7 < nloop[7];i7++){ fsend[7]=fwbuf[7]+i7;
for(int i6=0; i6 < nloop[6];i6++){ fsend[6]=fwbuf[6]+i6;
for(int i5=0; i5 < nloop[5];i5++){ fsend[5]=fwbuf[5]+i5;
for(int i4=0; i4 < nloop[4];i4++){ fsend[4]=fwbuf[4]+i4;
for(int i3=0; i3 < nloop[3];i3++){ fsend[3]=fwbuf[3]+i3;
for(int i2=0; i2 < nloop[2];i2++){fsend[2]=fwbuf[2]+i2;
for(int i1=0; i1 < nloop[1];i1++){fsend[1]=fwbuf[1]+i1;
io->read_block_float(nwio,fsend,(float*)(fbuf+count*nblock));
// off+=resize_buffer(nwbuf,fwbuf,nwio,fsend,ndim,
// off,(unsigned char*)tbuf,(unsigned char*)fbuf,(int)sizeof(float));
off+=nblock;
count+=1;
}
}
}
}
}
}
}
if(off >10000000) off=10000000;
if(io->not_byte()){
fprintf(stderr,"CHECM ME =%d d=%d \n",inum,off);
io->set_clip(fbuf,inum,off);
io->return_clips(&bclip,&eclip);
}
//srite("x22.H",fbuf,1000*250*4);
calc_histo();
}
unsigned char *float_buffer::get_char_data(std::shared_ptr<orient_cube>pos, int iax1, int f1, int e1, int iax2, int f2, int e2){
if(!hold[iax1] || !hold[iax2]) _par->error("Internal error don't hold axes requested");
int n1=abs(e1-f1), n2=abs(e2-f2);
if(pos->get_rotate() && (!hold[pos->rot_ax[0]] || !hold[pos->rot_ax[1]])){
fprintf(stderr,"Must hold rotated axes. Defaulting to no rotation.\n");
pos->set_no_rotate();
}
long long *index=form_index_map(pos,iax1,iax2,f1,e1,f2,e2);
unsigned char *out=get_char_data(n1*n2,index);
delete [] index;
return out;
}
unsigned char *float_buffer::get_char_data(int n, long long *index){
unsigned char *out=new unsigned char[n];
float minv,maxv;
io->return_clips(&minv,&maxv);
float j=maxv-minv;
for(int i=0 ; i < n; i++){
if(index[i] <0) {
out[i]=0;
}
else{
int b=(int)(255*(fbuf[index[i]]-minv)/j);
if(b<0) b=0; if(b>255) b=255;
out[i]=b;
}
}
// delete [] index;
return out;
}
float *float_buffer::get_float_data(std::shared_ptr<orient_cube>pos, int iax1, int f1, int e1, int iax2,
int f2, int e2){
if(!hold[iax1] || !hold[iax2]) _par->error("Internal error don't hold axes requested");
if(pos->get_rotate() && (!hold[pos->rot_ax[0]] || !hold[pos->rot_ax[1]])){
fprintf(stderr,"Must hold rotated axes. Defaulting to no rotation.\n");
pos->set_no_rotate();
}
int n1=abs(e1-f1), n2=abs(e2-f2);
long long *index=form_index_map(pos,iax1,iax2,f1,e1,f2,e2);
float *out=new float[n1*n2];
float minv,maxv;
io->return_clips(&minv,&maxv);
for(int i=0 ; i < n1*n2; i++){
if(index[i] <0) {
out[i]=minv;
}
else{
out[i]=fbuf[index[i]];
}
}
delete [] index;
return out;
}
void float_buffer::calc_histo(){
long long count[256];
for(int i=0; i < 256; i++) count[i]=0;
io->return_clips(&bclip,&eclip);
float j=eclip-bclip;
int b;
for(long long i=0; i < n123_view; i++){
b=(int)(255*(fbuf[i]-bclip)/j+.5);
if(b<0) b=0;
else if(b>255) b=255;
count[b]++;
}
long long mym=0;
for(int i=0; i < 256; i++){
if(count[i] > mym) mym=count[i];
}
for(int i=0; i < 256; i++){
histo[i]=(float)count[i]/(float)mym;
}
}
float float_buffer::get_value(std::shared_ptr<orient_cube>pos){
return fbuf[point_to_local(pos)];
}
|
[
"andy@ramblin.cc.gt.atl.ga.us"
] |
andy@ramblin.cc.gt.atl.ga.us
|
a6e41ebbfb8fda6f8e4567578b4388ea5e02be09
|
fabe2d9262ed0404f796d1b2cba4ffc5a83c7ff1
|
/chapter5/5-22.cpp
|
f885a133e869d9db700a84d539d70d3fee838d80
|
[
"MIT"
] |
permissive
|
GSNICE/ZK_04743
|
20ceece3ea8e7e9a979ea16690a8b913e7a391f5
|
7e49fc5045cc127c72a14d1717c34c939871f1d0
|
refs/heads/master
| 2023-04-06T17:03:50.816210
| 2020-09-06T03:09:49
| 2020-09-06T03:09:49
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,717
|
cpp
|
#include <iostream>
using namespace std;
class BaseClass1
{
protected:
int v1,v2;
public:
BaseClass1();
BaseClass1(int, int);
~BaseClass1();
};
BaseClass1::BaseClass1()
{
cout << "BaseClass1 无参构造函数" << endl;
}
BaseClass1::BaseClass1(int m, int n):v1(m),v2(n)
{
cout << "BaseClass1 带二个参数构造函数" << endl;
}
BaseClass1::~BaseClass1()
{
cout << "BaseClass1 的析构函数" << endl;
}
class BaseClass2:public BaseClass1
{
protected:
int v3;
public:
BaseClass2();
BaseClass2(int);
BaseClass2(int, int, int);
~BaseClass2();
};
BaseClass2::BaseClass2()
{
cout << "BaseClass2 无参构造函数" << endl;
}
BaseClass2::BaseClass2(int m):v3(m)
{
cout << "BaseClass2 带一个参数的构造函数" << endl;
}
BaseClass2::BaseClass2(int m, int n, int k):BaseClass1(m, n),v3(k)
{
cout << "BaseClass2 带三个参数的构造函数" << endl;
}
BaseClass2::~BaseClass2()
{
cout << "BaseClass2 析构函数" << endl;
}
class DerivedClass:public BaseClass2
{
public:
int v4;
public:
DerivedClass();
DerivedClass(int);
DerivedClass(int, int, int, int);
~DerivedClass();
};
DerivedClass::DerivedClass()
{
cout << "DerivedClass 无参构造函数" << endl;
}
DerivedClass::DerivedClass(int k):v4(k)
{
cout << "DerivedClass 带1个参数的构造函数" << endl;
}
DerivedClass::DerivedClass(int m, int n, int k, int t):BaseClass2(m, n, k),v4(t)
{
cout << "DerivedClass 带4个参数的构造函数" << endl;
}
DerivedClass::~DerivedClass()
{
cout << "DerivedClass 析构函数" << endl;
}
int main()
{
cout << "无参对象创建" << endl;
DerivedClass derivedCla;
return 0;
}
|
[
"wewin-tech@foxmail.com"
] |
wewin-tech@foxmail.com
|
0708a385dbbf45cab5b10564fbaccfabf845c547
|
0b74b4859c1242fd0793611e36d5778c1c9ece38
|
/extern/llvm/lib/Support/FileUtilities.cpp
|
b5cd7db1c32ef02ba313e0fde01b9bb83b09ddf3
|
[
"NCSA",
"Spencer-94",
"BSD-3-Clause",
"MIT"
] |
permissive
|
abduld/clreflect
|
682b98694ec50dfcd65168fdf40e7d04ec44e0e5
|
76b47c518d9b046382618a5e5863f8fe6163e595
|
refs/heads/master
| 2022-07-15T21:02:58.217422
| 2015-04-07T16:06:07
| 2015-04-07T16:06:07
| 35,754,939
| 0
| 0
|
MIT
| 2020-02-22T09:59:11
| 2015-05-17T06:36:28
|
C++
|
UTF-8
|
C++
| false
| false
| 9,555
|
cpp
|
//===- Support/FileUtilities.cpp - File System Utilities ------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements a family of utility functions which are useful for doing
// various things with files.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/system_error.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallString.h"
#include <cstdlib>
#include <cstring>
#include <cctype>
using namespace llvm;
static bool isSignedChar(char C) {
return (C == '+' || C == '-');
}
static bool isExponentChar(char C) {
switch (C) {
case 'D': // Strange exponential notation.
case 'd': // Strange exponential notation.
case 'e':
case 'E': return true;
default: return false;
}
}
static bool isNumberChar(char C) {
switch (C) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case '.': return true;
default: return isSignedChar(C) || isExponentChar(C);
}
}
static const char *BackupNumber(const char *Pos, const char *FirstChar) {
// If we didn't stop in the middle of a number, don't backup.
if (!isNumberChar(*Pos)) return Pos;
// Otherwise, return to the start of the number.
bool HasPeriod = false;
while (Pos > FirstChar && isNumberChar(Pos[-1])) {
// Backup over at most one period.
if (Pos[-1] == '.') {
if (HasPeriod)
break;
HasPeriod = true;
}
--Pos;
if (Pos > FirstChar && isSignedChar(Pos[0]) && !isExponentChar(Pos[-1]))
break;
}
return Pos;
}
/// EndOfNumber - Return the first character that is not part of the specified
/// number. This assumes that the buffer is null terminated, so it won't fall
/// off the end.
static const char *EndOfNumber(const char *Pos) {
while (isNumberChar(*Pos))
++Pos;
return Pos;
}
/// CompareNumbers - compare two numbers, returning true if they are different.
static bool CompareNumbers(const char *&F1P, const char *&F2P,
const char *F1End, const char *F2End,
double AbsTolerance, double RelTolerance,
std::string *ErrorMsg) {
const char *F1NumEnd, *F2NumEnd;
double V1 = 0.0, V2 = 0.0;
// If one of the positions is at a space and the other isn't, chomp up 'til
// the end of the space.
while (isspace(*F1P) && F1P != F1End)
++F1P;
while (isspace(*F2P) && F2P != F2End)
++F2P;
// If we stop on numbers, compare their difference.
if (!isNumberChar(*F1P) || !isNumberChar(*F2P)) {
// The diff failed.
F1NumEnd = F1P;
F2NumEnd = F2P;
} else {
// Note that some ugliness is built into this to permit support for numbers
// that use "D" or "d" as their exponential marker, e.g. "1.234D45". This
// occurs in 200.sixtrack in spec2k.
V1 = strtod(F1P, const_cast<char**>(&F1NumEnd));
V2 = strtod(F2P, const_cast<char**>(&F2NumEnd));
if (*F1NumEnd == 'D' || *F1NumEnd == 'd') {
// Copy string into tmp buffer to replace the 'D' with an 'e'.
SmallString<200> StrTmp(F1P, EndOfNumber(F1NumEnd)+1);
// Strange exponential notation!
StrTmp[static_cast<unsigned>(F1NumEnd-F1P)] = 'e';
V1 = strtod(&StrTmp[0], const_cast<char**>(&F1NumEnd));
F1NumEnd = F1P + (F1NumEnd-&StrTmp[0]);
}
if (*F2NumEnd == 'D' || *F2NumEnd == 'd') {
// Copy string into tmp buffer to replace the 'D' with an 'e'.
SmallString<200> StrTmp(F2P, EndOfNumber(F2NumEnd)+1);
// Strange exponential notation!
StrTmp[static_cast<unsigned>(F2NumEnd-F2P)] = 'e';
V2 = strtod(&StrTmp[0], const_cast<char**>(&F2NumEnd));
F2NumEnd = F2P + (F2NumEnd-&StrTmp[0]);
}
}
if (F1NumEnd == F1P || F2NumEnd == F2P) {
if (ErrorMsg) {
*ErrorMsg = "FP Comparison failed, not a numeric difference between '";
*ErrorMsg += F1P[0];
*ErrorMsg += "' and '";
*ErrorMsg += F2P[0];
*ErrorMsg += "'";
}
return true;
}
// Check to see if these are inside the absolute tolerance
if (AbsTolerance < std::abs(V1-V2)) {
// Nope, check the relative tolerance...
double Diff;
if (V2)
Diff = std::abs(V1/V2 - 1.0);
else if (V1)
Diff = std::abs(V2/V1 - 1.0);
else
Diff = 0; // Both zero.
if (Diff > RelTolerance) {
if (ErrorMsg) {
raw_string_ostream(*ErrorMsg)
<< "Compared: " << V1 << " and " << V2 << '\n'
<< "abs. diff = " << std::abs(V1-V2) << " rel.diff = " << Diff << '\n'
<< "Out of tolerance: rel/abs: " << RelTolerance << '/'
<< AbsTolerance;
}
return true;
}
}
// Otherwise, advance our read pointers to the end of the numbers.
F1P = F1NumEnd; F2P = F2NumEnd;
return false;
}
/// DiffFilesWithTolerance - Compare the two files specified, returning 0 if the
/// files match, 1 if they are different, and 2 if there is a file error. This
/// function differs from DiffFiles in that you can specify an absolete and
/// relative FP error that is allowed to exist. If you specify a string to fill
/// in for the error option, it will set the string to an error message if an
/// error occurs, allowing the caller to distinguish between a failed diff and a
/// file system error.
///
int llvm::DiffFilesWithTolerance(const sys::PathWithStatus &FileA,
const sys::PathWithStatus &FileB,
double AbsTol, double RelTol,
std::string *Error) {
const sys::FileStatus *FileAStat = FileA.getFileStatus(false, Error);
if (!FileAStat)
return 2;
const sys::FileStatus *FileBStat = FileB.getFileStatus(false, Error);
if (!FileBStat)
return 2;
// Check for zero length files because some systems croak when you try to
// mmap an empty file.
size_t A_size = FileAStat->getSize();
size_t B_size = FileBStat->getSize();
// If they are both zero sized then they're the same
if (A_size == 0 && B_size == 0)
return 0;
// If only one of them is zero sized then they can't be the same
if ((A_size == 0 || B_size == 0)) {
if (Error)
*Error = "Files differ: one is zero-sized, the other isn't";
return 1;
}
// Now its safe to mmap the files into memory because both files
// have a non-zero size.
OwningPtr<MemoryBuffer> F1;
if (error_code ec = MemoryBuffer::getFile(FileA.c_str(), F1)) {
if (Error)
*Error = ec.message();
return 2;
}
OwningPtr<MemoryBuffer> F2;
if (error_code ec = MemoryBuffer::getFile(FileB.c_str(), F2)) {
if (Error)
*Error = ec.message();
return 2;
}
// Okay, now that we opened the files, scan them for the first difference.
const char *File1Start = F1->getBufferStart();
const char *File2Start = F2->getBufferStart();
const char *File1End = F1->getBufferEnd();
const char *File2End = F2->getBufferEnd();
const char *F1P = File1Start;
const char *F2P = File2Start;
// Are the buffers identical? Common case: Handle this efficiently.
if (A_size == B_size &&
std::memcmp(File1Start, File2Start, A_size) == 0)
return 0;
// Otherwise, we are done a tolerances are set.
if (AbsTol == 0 && RelTol == 0) {
if (Error)
*Error = "Files differ without tolerance allowance";
return 1; // Files different!
}
bool CompareFailed = false;
while (1) {
// Scan for the end of file or next difference.
while (F1P < File1End && F2P < File2End && *F1P == *F2P)
++F1P, ++F2P;
if (F1P >= File1End || F2P >= File2End) break;
// Okay, we must have found a difference. Backup to the start of the
// current number each stream is at so that we can compare from the
// beginning.
F1P = BackupNumber(F1P, File1Start);
F2P = BackupNumber(F2P, File2Start);
// Now that we are at the start of the numbers, compare them, exiting if
// they don't match.
if (CompareNumbers(F1P, F2P, File1End, File2End, AbsTol, RelTol, Error)) {
CompareFailed = true;
break;
}
}
// Okay, we reached the end of file. If both files are at the end, we
// succeeded.
bool F1AtEnd = F1P >= File1End;
bool F2AtEnd = F2P >= File2End;
if (!CompareFailed && (!F1AtEnd || !F2AtEnd)) {
// Else, we might have run off the end due to a number: backup and retry.
if (F1AtEnd && isNumberChar(F1P[-1])) --F1P;
if (F2AtEnd && isNumberChar(F2P[-1])) --F2P;
F1P = BackupNumber(F1P, File1Start);
F2P = BackupNumber(F2P, File2Start);
// Now that we are at the start of the numbers, compare them, exiting if
// they don't match.
if (CompareNumbers(F1P, F2P, File1End, File2End, AbsTol, RelTol, Error))
CompareFailed = true;
// If we found the end, we succeeded.
if (F1P < File1End || F2P < File2End)
CompareFailed = true;
}
return CompareFailed;
}
|
[
"xxuejie@gmail.com"
] |
xxuejie@gmail.com
|
b3eb1317006131f2bb71e303b7020696a93aea83
|
b30b6deb426fb16557e1a1f2b370f2db9a6892f3
|
/Code/snek/snek_game.cpp
|
da488df08fd5f390d14c0285f4f42962c4b4929c
|
[
"Unlicense"
] |
permissive
|
cppimprov/snek
|
5ac5732908f34d9c7d7f9284f5a973474bf73bee
|
db3c858fc7b26c3ff30af7d45d9c3cc6d506fe8a
|
refs/heads/master
| 2023-03-09T02:40:02.283684
| 2021-03-08T21:56:53
| 2021-03-08T21:56:53
| 341,000,420
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,374
|
cpp
|
#include "snek_game.hpp"
#include "snek_die.hpp"
#include "snek_game_app.hpp"
#include <glm/glm.hpp>
#include <algorithm>
#include <chrono>
#include <deque>
#include <iterator>
#include <random>
#include <string>
namespace snek
{
namespace game
{
gamestate do_countdown(app& app)
{
auto const bg_color = glm::u8vec4{ 191, 191, 191, 255 };
auto count = 3;
auto count_texture = &app.m_assets.m_textures.at(std::to_string(count));
auto const count_sound = &app.m_assets.m_sounds.at("count");
app.m_mixer_context.play_once(*count_sound);
auto const count_period = std::chrono::seconds(1);
auto count_period_start = std::chrono::high_resolution_clock::now();
while (true)
{
// input
{
SDL_Event e;
while (SDL_PollEvent(&e))
{
if (e.type == SDL_QUIT)
return { };
if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_ESCAPE)
return { };
}
}
// update
{
auto const now = std::chrono::high_resolution_clock::now();
if (now - count_period_start >= count_period)
{
--count;
if (count == 0)
return { do_gameplay };
count_texture = &app.m_assets.m_textures.at(std::to_string(count));
app.m_mixer_context.play_once(*count_sound);
count_period_start = now;
}
}
// render
{
app.m_renderer.clear(bg_color);
app.m_renderer.draw_quad_texture({ 0, 0 }, app.m_window.get_size(), *count_texture, { 0, 0 }, count_texture->get_size());
app.m_renderer.present();
}
}
return { };
}
gamestate do_gameplay(app& app)
{
// grid
auto const cell_count = glm::i32vec2{ 24, 24 };
auto const cell_size = app.m_window.get_size() / cell_count;
// directions
auto const LEFT = glm::i32vec2{ -1, 0 };
auto const RIGHT = glm::i32vec2{ 1, 0 };
auto const UP = glm::i32vec2{ 0, -1 };
auto const DOWN = glm::i32vec2{ 0, 1 };
// rendering
auto const bg_color = glm::u8vec4{ 191, 191, 191, 255 };
auto const snake_color = glm::u8vec4{ 0, 128, 0, 255 };
auto const snake_collided_color = glm::u8vec4{ 191, 0, 0, 255 };
auto const snake_won_color = glm::u8vec4{ 255, 191, 64, 255 };
auto const snake_head_color = glm::u8vec4(255);
auto const snake_head_border_size = 6;
auto const food_color = glm::u8vec4{ 255, 106, 0, 255 };
auto const score_char_size = glm::i32vec2{ 8, 8 };
auto const score_draw_scale = 2;
auto const score_texture = &app.m_assets.m_textures.at("score");
// snake
auto growth = 0;
auto const food_growth = 5;
auto const snake_start_length = 5;
auto const snake_start_pos = glm::i32vec2{ 5, 5 };
auto const snake_start_dir = RIGHT;
auto snake_dir = snake_start_dir;
auto snake = std::deque<glm::i32vec2>();
for (auto x = 0; x != snake_start_length; ++x)
snake.push_back({ snake_start_pos.x + x, snake_start_pos.y });
// food
auto score = 0;
auto const food_score = 10;
auto constexpr i32vec2_less = [] (glm::i32vec2 a, glm::i32vec2 b)
{
auto const a_list = { a.y, a.x };
auto const b_list = { b.y, b.x };
return std::lexicographical_compare(a_list.begin(), a_list.end(), b_list.begin(), b_list.end());
};
auto all_cells = std::vector<glm::i32vec2>();
all_cells.reserve(cell_count.x * cell_count.y);
for (auto y = 0; y != cell_count.y; ++y)
for (auto x = 0; x != cell_count.x; ++x)
all_cells.push_back({ x, y });
std::sort(all_cells.begin(), all_cells.end(), i32vec2_less); // (should do nothing!)
auto get_food_pos = [&] (std::mt19937& rng, std::vector<glm::i32vec2> const& all_cells, std::deque<glm::i32vec2> snake_copy)
{
std::sort(snake_copy.begin(), snake_copy.end(), i32vec2_less);
auto const size = all_cells.size() - snake_copy.size();
die_if(size == 0);
auto empty = std::vector<glm::i32vec2>();
empty.reserve(size);
std::set_difference(all_cells.begin(), all_cells.end(), snake_copy.begin(), snake_copy.end(), std::back_inserter(empty), i32vec2_less);
die_if(empty.empty());
auto const dist = std::uniform_int_distribution<std::size_t>(0, empty.size() - 1);
return empty[dist(rng)];
};
auto rng = std::mt19937(std::random_device()());
auto food_pos = get_food_pos(rng, all_cells, snake);
// timing
auto snake_update_period = std::chrono::milliseconds(250);
auto const snake_update_period_speedup = std::chrono::milliseconds(25);
auto const snake_update_period_max_speedups = 5;
auto snake_update_period_speedups = 0;
auto snake_update_period_start = std::chrono::high_resolution_clock::now();
// move types
enum class move_type { moved, grew, ate, collided, won };
auto last_move = move_type::moved;
// sound setup
auto const start_sound = &app.m_assets.m_sounds.at("start");
auto sounds = std::map<move_type, sdl::mixer_chunk*>
{
{ move_type::moved, &app.m_assets.m_sounds.at("step") },
{ move_type::grew, &app.m_assets.m_sounds.at("grow") },
{ move_type::ate, &app.m_assets.m_sounds.at("eat") },
{ move_type::collided, &app.m_assets.m_sounds.at("die") },
{ move_type::won, &app.m_assets.m_sounds.at("win") },
};
// start!
app.m_mixer_context.play_once(*start_sound);
while (true)
{
// input
{
SDL_Event e;
while (SDL_PollEvent(&e))
{
if (e.type == SDL_QUIT)
return { };
if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_ESCAPE)
return { };
if (e.type == SDL_KEYDOWN && e.key.keysym.scancode == SDL_SCANCODE_W) snake_dir = UP;
if (e.type == SDL_KEYDOWN && e.key.keysym.scancode == SDL_SCANCODE_UP) snake_dir = UP;
if (e.type == SDL_KEYDOWN && e.key.keysym.scancode == SDL_SCANCODE_S) snake_dir = DOWN;
if (e.type == SDL_KEYDOWN && e.key.keysym.scancode == SDL_SCANCODE_DOWN) snake_dir = DOWN;
if (e.type == SDL_KEYDOWN && e.key.keysym.scancode == SDL_SCANCODE_A) snake_dir = LEFT;
if (e.type == SDL_KEYDOWN && e.key.keysym.scancode == SDL_SCANCODE_LEFT) snake_dir = LEFT;
if (e.type == SDL_KEYDOWN && e.key.keysym.scancode == SDL_SCANCODE_D) snake_dir = LEFT;
if (e.type == SDL_KEYDOWN && e.key.keysym.scancode == SDL_SCANCODE_RIGHT) snake_dir = RIGHT;
}
}
// update
{
auto const now = std::chrono::high_resolution_clock::now();
if (now - snake_update_period_start >= snake_update_period)
{
// reset the update period
while (now - snake_update_period_start >= snake_update_period)
snake_update_period_start += snake_update_period;
// end the game if we collided or won
if (last_move == move_type::collided || last_move == move_type::won)
return { do_countdown };
// update head position
snake.push_back((((snake.back() + snake_dir) % cell_count) + cell_count) % cell_count);
// update tail position
if (growth == 0)
{
snake.pop_front();
last_move = move_type::moved;
}
else
{
--growth;
last_move = move_type::grew;
}
// check collision w/ self
if (snake.size() > 1)
{
if (std::find(snake.begin(), snake.end() - 1, snake.back()) != snake.end() - 1)
last_move = move_type::collided;
}
// check collision w/ food
if (snake.back() == food_pos)
{
score += food_score;
growth += food_growth;
if (snake.size() == all_cells.size())
{
last_move = move_type::won;
}
else
{
food_pos = get_food_pos(rng, all_cells, snake);
last_move = move_type::ate;
if (snake_update_period_speedups < snake_update_period_max_speedups)
{
++snake_update_period_speedups;
snake_update_period -= snake_update_period_speedup;
}
}
}
app.m_mixer_context.play_once(*sounds.at(last_move));
}
}
// render
{
app.m_renderer.clear(bg_color);
// snake
{
auto color = (last_move == move_type::collided) ? snake_collided_color : (last_move == move_type::won) ? snake_won_color : snake_color;
// body
for (auto p : snake)
app.m_renderer.draw_quad_fill(p * cell_size, cell_size, color, sdl::blend_mode::NONE);
// head
app.m_renderer.draw_quad_fill(snake.back() * cell_size + snake_head_border_size / 2, cell_size - snake_head_border_size, snake_head_color, sdl::blend_mode::NONE);
}
// food
{
app.m_renderer.draw_quad_fill(food_pos * cell_size, cell_size, food_color, sdl::blend_mode::NONE);
}
// score
{
auto score_str = std::to_string(score);
auto const score_pos = glm::i32vec2{ app.m_window.get_size().x - 5, 5 };
for (auto i = std::size_t{ 0 }; i != score_str.size(); ++i)
{
auto digit = score_str[i] - '0';
die_if(digit < 0 || digit > 9);
auto offset = glm::i32vec2{ score_char_size.x * digit, 0 };
auto align = i - score_str.size();
auto pos = glm::i32vec2{ score_pos.x + align * score_char_size.x * score_draw_scale, score_pos.y };
app.m_renderer.draw_quad_texture(pos, score_char_size * score_draw_scale, *score_texture, offset, score_char_size);
}
}
app.m_renderer.present();
}
}
return { };
}
} // game
} // snek
|
[
"cppimprov@gmail.com"
] |
cppimprov@gmail.com
|
d558eb442889c6035e7769218c6e28c032e53568
|
d53ab4552e5e923b3051a5e99d30db46cf64e67a
|
/ExEvent.cpp
|
10550608854857443aa8c2a552baf81c53ddfd28
|
[] |
no_license
|
jjg0606/Prac_CPPServer
|
e15b895a4330b28717c7f3091128d4163d28e3b1
|
91c0de6e07f109da1e387b616997c3a9548e4960
|
refs/heads/master
| 2020-07-29T09:34:58.200033
| 2019-09-20T08:56:08
| 2019-09-20T08:56:08
| 209,747,825
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,333
|
cpp
|
#include <Windows.h>
#include <stdio.h>
#define BUFSIZE 10
HANDLE hReadEvent;
HANDLE hWriteEvent;
int buf[BUFSIZE];
DWORD WINAPI WriteThread(LPVOID arg)
{
DWORD retval;
for (int k = 1; k <= 500; k++)
{
retval = WaitForSingleObject(hReadEvent, INFINITE);
if (retval != WAIT_OBJECT_0)
break;
for (int i = 0; i < BUFSIZE; i++)
{
buf[i] = k;
}
SetEvent(hWriteEvent);
}
return 0;
}
DWORD WINAPI ReadThread(LPVOID arg)
{
DWORD retval;
while (1)
{
retval = WaitForSingleObject(hWriteEvent, INFINITE);
if (retval != WAIT_OBJECT_0)
{
break;
}
printf("Thread %4d: ", GetCurrentThreadId());
for (int i = 0; i < BUFSIZE; i++)
{
printf("%3d ", buf[i]);
}
printf("\n");
ZeroMemory(buf, sizeof(buf));
SetEvent(hReadEvent);
}
return 0;
}
int main()
{
hWriteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (hWriteEvent == NULL)
{
return 1;
}
hReadEvent = CreateEvent(NULL, FALSE, TRUE, NULL);
if (hReadEvent == NULL)
{
return 1;
}
HANDLE hThread[3];
hThread[0] = CreateThread(NULL, 0, WriteThread, NULL, 0, NULL);
hThread[1] = CreateThread(NULL, 0, ReadThread, NULL, 0, NULL);
hThread[2] = CreateThread(NULL, 0, ReadThread, NULL, 0, NULL);
WaitForMultipleObjects(3, hThread, TRUE, INFINITE);
CloseHandle(hWriteEvent);
CloseHandle(hReadEvent);
return 0;
}
|
[
"ccm7772003@naver.com"
] |
ccm7772003@naver.com
|
0cc333ab5e710a31ec250bfe6d706ca25d7eb8e2
|
00413d600530396733988bbc9ecd48b6a67fd359
|
/enigma/include/enigma/common/dictionary.h
|
8fd62dfd438e20f14178bda690197c5ca022d8aa
|
[] |
no_license
|
carzil/enigma
|
520a44a69985390704188658e9c882e048caf69f
|
0156a89a66adc62c6afea4d03fa1fd4224ab4162
|
refs/heads/master
| 2020-12-24T19:28:19.305487
| 2016-06-04T23:49:39
| 2016-06-04T23:49:39
| 58,167,126
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,048
|
h
|
#pragma once
#include <map>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream>
#include "enigma_export.h"
#include "enigma/utils.h"
namespace Enigma {
class ENIGMA_NO_EXPORT Dictionary {
public:
static const size_t MAX_SIZE = 1 << 17;
struct Node {
uint8_t ch;
uint8_t* chars;
int* nexts;
int parent;
size_t depth;
Node() : ch(0), chars(nullptr), nexts(nullptr), parent(1), depth(0) {
chars = new uint8_t[4];
nexts = new int[4];
memset(chars, 0, sizeof(uint8_t) * 4);
memset(nexts, 0, sizeof(int) * 4);
}
~Node() {
if (chars) {
delete[] chars;
}
if (nexts) {
delete[] nexts;
}
}
};
Dictionary() {
nodes = new Node[MAX_SIZE + 2];
capacities = new uint8_t[MAX_SIZE + 2];
sizes = new uint8_t[MAX_SIZE + 2];
for (size_t i = 0; i < MAX_SIZE + 2; i++) {
capacities[i] = 4;
sizes[i] = 0;
}
// memset(capacities, 4, sizeof(uint8_t) * (MAX_SIZE + 2));
next_free = 2;
root = 1;
}
~Dictionary() {
delete[] nodes;
delete[] capacities;
delete[] sizes;
}
int AddNode(int ptr, uint8_t c) {
// std::cout << (int*)capacities << std::endl;
// for (size_t i = 0; i < Size(); i++) {
// std::cout << (int)capacities[i] << " ";
// }
// std::cout << std::endl;
Node* node = nodes + ptr;
uint8_t capacity = *(capacities + ptr);
uint8_t size = *(sizes + ptr);
// std::cout << ptr << " " << (int)c << " " << (int)capacity << std::endl;
// std::cout << node->nexts << std::endl;
if (capacity == 255) {
if (node->nexts[c] == 0) {
node->nexts[c] = CreateNode(ptr, c);
}
return node->nexts[c];
} else {
for (size_t i = 0; i < size; i++) {
if (node->chars[i] == c) {
return node->nexts[i];
}
}
// uint8_t* p = (uint8_t*)memchr(node->chars, c, node->size);
// if (p) {
// return node->nexts[p - node->chars];
// }
if (size >= capacity) {
// std::cout << (int)capacities[ptr] << std::endl;
if (capacity <= 16) {
uint8_t* new_chars = new uint8_t[capacity * 2];
int* new_nexts = new int[capacity * 2];
memset(new_chars, 0, sizeof(uint8_t) * capacity * 2);
memset(new_nexts, 0, sizeof(int) * capacity * 2);
memcpy(new_chars, node->chars, sizeof(uint8_t) * size);
memcpy(new_nexts, node->nexts, sizeof(int) * size);
delete[] node->chars;
delete[] node->nexts;
node->chars = new_chars;
node->nexts = new_nexts;
// std::cout << "reallocation for node " << ptr << ", last capacity = " << (int)capacity << std::endl;
capacities[ptr] *= 2;
} else {
int* new_nexts = new int[256];
memset(new_nexts, 0, sizeof(int) * 256);
for (size_t i = 0; i < size; i++) {
new_nexts[node->chars[i]] = node->nexts[i];
}
delete[] node->chars;
delete[] node->nexts;
node->chars = nullptr;
node->nexts = new_nexts;
capacities[ptr] = 255;
sizes[ptr] = 255;
node->nexts[c] = CreateNode(ptr, c);
// std::cout << "full reallocation for node " << ptr << ", c = " << (int)c << ", nexts = " << node->nexts << std::endl;
return node->nexts[c];
}
}
int n = CreateNode(ptr, c);
node->chars[size] = c;
node->nexts[size] = n;
sizes[ptr]++;
return n;
}
}
int CreateNode(int parent, uint8_t ch) {
Node* node = nodes + next_free;
node->parent = parent;
node->ch = ch;
node->depth = nodes[parent].depth + 1;
size_t res = next_free;
next_free++;
return res;
}
int NextNode(int ptr, uint8_t c) const {
// for (size_t i = 0; i < Size(); i++) {
// std::cout << (int)capacities[i] << " ";
// }
// std::cout << std::endl;
Node* node = nodes + ptr;
uint8_t size = sizes[ptr];
if (capacities[ptr] == 255) {
return node->nexts[c];
} else {
// for (size_t i = 0; i < node->size; i++) {
// std::cout << (int)(uint8_t)node->chars[i] << " ";
// }
// std::cout << std::endl;
// for (size_t i = 0; i < node->size; i++) {
// std::cout << node->nexts[i] << " ";
// }
// std::cout << std::endl;
for (uint8_t i = 0; i < size; i++) {
if (node->chars[i] == c) {
return node->nexts[i];
}
}
return 0;
// // std::cout << "found '" << c << "' at pos = " << p - node->chars << std::endl;
// // std::cout << "next = " << node->nexts[p - node->chars] << std::endl;
}
}
size_t Size() const {
return next_free;
}
bool IsFull() const {
return Size() >= MAX_SIZE;
}
bool IsValid(int ptr) const {
return ptr > 0;
}
int GetRoot() const {
return root;
}
const Dictionary::Node& GetNode(int ptr) const {
return nodes[ptr];
}
std::string RestoreString(int ptr) const {
std::string s;
while (nodes[ptr].parent != root) {
s.push_back(nodes[ptr].ch);
ptr = nodes[ptr].parent;
// std::cout << ptr << std::endl;
}
s.push_back(nodes[ptr].ch);
std::reverse(s.begin(), s.end());
return s;
}
void Save(DataOutput& out) const {
out.WriteInt(Size());
// std::cout << "size = " << Size() << std::endl;
for (size_t i = 2; i < Size(); i++) {
out.WriteChar(nodes[i].ch);
out.WriteInt(nodes[i].parent);
// std::cout << "saved " << i << " " << nodes[i].ch << " " << std::endl;
}
}
void Load(DataInput& in) {
delete[] nodes;
nodes = new Node[Dictionary::MAX_SIZE + 2];
for (size_t i = 0; i < Dictionary::MAX_SIZE + 2; i++) {
capacities[i] = 4;
}
next_free = 2;
size_t size = in.ReadInt();
// std::cout << "size = " << size << std::endl;
for (size_t i = 2; i < size; i++) {
uint8_t ch = in.ReadChar();
int parent = in.ReadInt();
AddNode(parent, ch);
// std::cout << "added " << parent << " " << ch << std::endl;
}
}
void Reorder(size_t* frequencies, size_t* new_frequencies, size_t* old_frequencies) {
std::vector<size_t> ns;
for (size_t i = 0; i < Size(); i++) {
ns.push_back(i);
}
cmp c(frequencies);
std::sort(ns.begin(), ns.end(), c);
Node* new_nodes = new Node[Dictionary::MAX_SIZE + 2];
memset(new_nodes, 0, sizeof(Node) * (Dictionary::MAX_SIZE + 2));
uint8_t* new_capacities = new uint8_t[Dictionary::MAX_SIZE + 2];
uint8_t* new_sizes = new uint8_t[Dictionary::MAX_SIZE + 2];
size_t* new_poses = new size_t[Dictionary::MAX_SIZE + 2];
ns.insert(ns.begin(), 0);
for (size_t i = 0; i < ns.size(); i++) {
new_poses[ns[i]] = i;
// std::cout << "remap " << ns[i] << " -> " << i << " (freq = " << frequencies[ns[i]] << ")" << std::endl;
}
for (size_t i = 0; i < ns.size(); i++) {
size_t old_pos = ns[i];
size_t new_pos = new_poses[old_pos];
size_t parent_old_pos = nodes[old_pos].parent;
size_t parent_new_pos = new_poses[parent_old_pos];
new_nodes[new_pos].ch = nodes[old_pos].ch;
new_nodes[new_pos].depth = nodes[old_pos].depth;
new_nodes[new_pos].parent = new_poses[parent_old_pos];
if (parent_old_pos == 0) {
new_nodes[new_pos].parent = 0;
}
// std::cout << parent_new_pos << " <-" << nodes[old_pos].ch << "-> " << new_pos << " " << new_nodes[new_pos].parent << std::endl;
new_capacities[new_pos] = capacities[old_pos];
new_sizes[new_pos] = sizes[old_pos];
if (capacities[parent_old_pos] == 255) {
// std::cout << nodes[old_pos].ch << std::endl;
if (new_nodes[parent_new_pos].nexts == 0) {
new_nodes[parent_new_pos].nexts = new int[256];
new_nodes[parent_new_pos].chars = nullptr;
// std::cout << "here" << std::endl;
}
new_nodes[parent_new_pos].nexts[nodes[old_pos].ch] = new_pos;
} else {
if (new_nodes[parent_new_pos].nexts == 0) {
new_nodes[parent_new_pos].chars = new uint8_t[capacities[parent_old_pos]];
new_nodes[parent_new_pos].nexts = new int[capacities[parent_old_pos]];
// std::cout << "and here" << std::endl;
}
for (size_t j = 0; j < sizes[parent_old_pos]; j++) {
if (nodes[parent_old_pos].chars[j] == nodes[old_pos].ch) {
new_nodes[parent_new_pos].chars[j] = nodes[old_pos].ch;
new_nodes[parent_new_pos].nexts[j] = new_pos;
}
}
}
}
for (size_t i = 0; i < ns.size(); i++) {
new_frequencies[i] = old_frequencies[ns[i]];
}
root = new_poses[root];
delete[] new_poses;
delete[] sizes;
delete[] capacities;
delete[] nodes;
nodes = new_nodes;
sizes = new_sizes;
capacities = new_capacities;
// for (size_t i = 2; i < Size(); i++) {
// std::cout << RestoreString(i) << std::endl;
// }
}
private:
Node* nodes;
uint8_t* capacities;
uint8_t* sizes;
size_t next_free;
int root;
class cmp {
size_t* frequencies;
public:
cmp(size_t* frequencies) : frequencies(frequencies) {}
bool operator()(size_t a, size_t b) {
return frequencies[a] > frequencies[b];
}
};
};
}
|
[
"carzil@yandex.ru"
] |
carzil@yandex.ru
|
502612234b87e9039f3ecb1893d38187186e53f6
|
8dc84558f0058d90dfc4955e905dab1b22d12c08
|
/third_party/blink/renderer/modules/mediasource/source_buffer_list.cc
|
e52c53cf71984725f0b3916fc65e45d5bbd2a39f
|
[
"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
| 3,310
|
cc
|
/*
* Copyright (C) 2013 Google 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 Google 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "third_party/blink/renderer/modules/mediasource/source_buffer_list.h"
#include "third_party/blink/renderer/core/dom/events/media_element_event_queue.h"
#include "third_party/blink/renderer/modules/event_modules.h"
#include "third_party/blink/renderer/modules/mediasource/source_buffer.h"
namespace blink {
SourceBufferList::SourceBufferList(ExecutionContext* context,
MediaElementEventQueue* async_event_queue)
: ContextClient(context), async_event_queue_(async_event_queue) {}
SourceBufferList::~SourceBufferList() = default;
void SourceBufferList::Add(SourceBuffer* buffer) {
list_.push_back(buffer);
ScheduleEvent(EventTypeNames::addsourcebuffer);
}
void SourceBufferList::insert(size_t position, SourceBuffer* buffer) {
list_.insert(position, buffer);
ScheduleEvent(EventTypeNames::addsourcebuffer);
}
void SourceBufferList::Remove(SourceBuffer* buffer) {
size_t index = list_.Find(buffer);
if (index == kNotFound)
return;
list_.EraseAt(index);
ScheduleEvent(EventTypeNames::removesourcebuffer);
}
void SourceBufferList::Clear() {
list_.clear();
ScheduleEvent(EventTypeNames::removesourcebuffer);
}
void SourceBufferList::ScheduleEvent(const AtomicString& event_name) {
DCHECK(async_event_queue_);
Event* event = Event::Create(event_name);
event->SetTarget(this);
async_event_queue_->EnqueueEvent(FROM_HERE, event);
}
const AtomicString& SourceBufferList::InterfaceName() const {
return EventTargetNames::SourceBufferList;
}
void SourceBufferList::Trace(blink::Visitor* visitor) {
visitor->Trace(async_event_queue_);
visitor->Trace(list_);
EventTargetWithInlineData::Trace(visitor);
ContextClient::Trace(visitor);
}
} // namespace blink
|
[
"arnaud@geometry.ee"
] |
arnaud@geometry.ee
|
63658ed173e6ffe1069ca49f64f1b7b5f540162b
|
7e88587fb56d494adf0f0d35ba414d4bdfc81664
|
/LAWA-lite/iris2/test/print-laplace1d.cc
|
5f3539a50eb94d540effec6fbfa8e7fc5bbedbf1
|
[] |
no_license
|
iris-haecker/LAWA
|
8c488652b64db299299dd72fa7fb0a0e3baf4d83
|
a79c6b70e4558935da34a04da62bdb4af2da08af
|
refs/heads/master
| 2021-01-25T04:57:43.279709
| 2013-09-18T10:31:05
| 2013-09-18T10:31:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 626
|
cc
|
#include <iris2/iris2.cxx>
using namespace lawa;
using namespace std;
int
main()
{
Laplace1D<double> A(2,4);
int j1 = A.j0;
int j2 = A.j0;
int minK1 = A.V.rangeI(j1).firstIndex();
int maxK1 = A.V.rangeI(j1).lastIndex();
for (int k1=minK1; k1<=maxK1; ++k1) {
Index1D nu(j1, k1, XBSpline);
int minK2 = A.minK2(j1, k1, XBSpline, j2, XBSpline);
int maxK2 = A.maxK2(j1, k1, XBSpline, j2, XBSpline);
for (int k2=minK2; k2<=maxK2; ++k2) {
Index1D lambda(j2, k2, XBSpline);
cout << A(nu, lambda) << " ";
}
cout << endl;
}
}
|
[
"iris.haecker@uni-ulm.de"
] |
iris.haecker@uni-ulm.de
|
aebf178bfbb41ab019f19dc806b0b593db89962e
|
260ee67308ecb1c4873a4b1815d0751bf9742ea5
|
/shared_cpp/Encoding.cpp
|
9078d9214f6f10e47ef1b3d35931b167b96b2b3d
|
[] |
no_license
|
danielruskin-ses/voting-system
|
a7c652b6ae69a676a7ea18befed4aabb3e47f59c
|
c540c39c9b0ebe92028f2cd7c8ce89a274e79bcd
|
refs/heads/master
| 2023-06-23T05:31:33.286472
| 2019-04-18T13:23:43
| 2019-05-22T01:17:48
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,278
|
cpp
|
#include "Encoding.h"
#include <string>
#include <tuple>
#include <iostream>
bool ByteTArrayEncodeFunc(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
if (!pb_encode_tag_for_field(stream, field))
return false;
const std::vector<BYTE_T>& argReal = *((const std::vector<BYTE_T>* const) *arg);
return pb_encode_string(stream, &(argReal[0]), argReal.size());
}
bool StringEncodeFunc(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
if (!pb_encode_tag_for_field(stream, field))
return false;
const std::string& argReal = *((const std::string* const) *arg);
return pb_encode_string(stream, (const BYTE_T*) argReal.c_str(), argReal.size() + 1);
}
bool IntArrayEncodeFunc(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
const std::vector<int>& argReal = *((const std::vector<int>* const) *arg);
for(int i = 0; i < argReal.size(); i++) {
if (!pb_encode_tag_for_field(stream, field)) {
return false;
}
if (!pb_encode_varint(stream, argReal[i])) {
return false;
}
}
return true;
}
// TODO: DRY up these funcs
bool RepeatedCandidateEncodeFunc(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
const std::vector<Candidate>& argReal = *((const std::vector<Candidate>* const) *arg);
for(int i = 0; i < argReal.size(); i++) {
if (!pb_encode_tag_for_field(stream, field)) {
return false;
}
if (!pb_encode_submessage(stream, Candidate_fields, &(argReal[i]))) {
return false;
}
}
return true;
}
bool RepeatedTallyEntryEncodeFunc(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
const std::vector<TallyEntry>& argReal = *((const std::vector<TallyEntry>* const) *arg);
for(int i = 0; i < argReal.size(); i++) {
if (!pb_encode_tag_for_field(stream, field)) {
return false;
}
if (!pb_encode_submessage(stream, TallyEntry_fields, &(argReal[i]))) {
return false;
}
}
return true;
}
bool RepeatedElectionEncodeFunc(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
const std::vector<Election>& argReal = *((const std::vector<Election>* const) *arg);
for(int i = 0; i < argReal.size(); i++) {
if (!pb_encode_tag_for_field(stream, field)) {
return false;
}
if (!pb_encode_submessage(stream, Election_fields, &(argReal[i]))) {
return false;
}
}
return true;
}
bool RepeatedEncryptedBallotEntryEncodeFunc(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
const std::vector<EncryptedBallotEntry>& argReal = *((const std::vector<EncryptedBallotEntry>* const) *arg);
for(int i = 0; i < argReal.size(); i++) {
if (!pb_encode_tag_for_field(stream, field))
return false;
if (!pb_encode_submessage(stream, EncryptedBallotEntry_fields, &(argReal[i])))
return false;
}
return true;
}
bool RepeatedCastEncryptedBallotEncodeFunc(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
const std::vector<CastEncryptedBallot>& argReal = *((const std::vector<CastEncryptedBallot>* const) *arg);
for(int i = 0; i < argReal.size(); i++) {
if (!pb_encode_tag_for_field(stream, field))
return false;
if (!pb_encode_submessage(stream, CastEncryptedBallot_fields, &(argReal[i])))
return false;
}
return true;
}
bool RepeatedVoterEncodeFunc(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) {
const std::vector<Voter>& argReal = *((const std::vector<Voter>* const) *arg);
for(int i = 0; i < argReal.size(); i++) {
if (!pb_encode_tag_for_field(stream, field))
return false;
if (!pb_encode_submessage(stream, Voter_fields, &(argReal[i])))
return false;
}
return true;
}
bool ByteTArrayDecodeFunc(pb_istream_t *stream, const pb_field_t *field, void **arg) {
auto argReal = (std::vector<BYTE_T>*) *arg;
argReal->resize(stream->bytes_left);
if (!pb_read(stream, &((*argReal)[0]), stream->bytes_left))
return false;
return true;
}
bool EncryptedBallotEntriesDecodeFunc(pb_istream_t *stream, const pb_field_t *field, void **arg) {
auto argReal = (std::pair<std::vector<EncryptedBallotEntry>*, std::vector<std::vector<BYTE_T>>*>*) *arg;
std::vector<EncryptedBallotEntry>& argRealFirst = *(argReal->first);
std::vector<std::vector<BYTE_T>>& argRealSecond = *(argReal->second);
argRealFirst.resize(argRealFirst.size() + 1);
argRealSecond.resize(argRealSecond.size() + 1);
EncryptedBallotEntry* ebe = &(argRealFirst[argRealFirst.size() - 1]);
ebe->encrypted_value.arg = &(argRealSecond[argRealSecond.size() - 1]);
ebe->encrypted_value.funcs.decode = ByteTArrayDecodeFunc;
if (!pb_decode(stream, EncryptedBallotEntry_fields, ebe))
return false;
return true;
}
bool StringDecodeFunc(pb_istream_t *stream, const pb_field_t *field, void **arg) {
auto argReal = (std::string*) *arg;
char buffer[stream->bytes_left];
if(!pb_read(stream, (BYTE_T*) buffer, stream->bytes_left))
return false;
*argReal = std::string(buffer, sizeof(buffer));
return true;
}
bool IntArrayDecodeFunc(pb_istream_t *stream, const pb_field_t *field, void **arg) {
auto argReal = (std::vector<int>*) *arg;
argReal->resize(argReal->size() + 1);
uint64_t value;
if (!pb_decode_varint(stream, &value))
return false;
(*argReal)[argReal->size() - 1] = value;
return true;
}
bool CandidatesDecodeFunc(pb_istream_t *stream, const pb_field_t *field, void **arg) {
auto argReal = (std::vector<std::tuple<Candidate, std::string, std::string>>*) *arg;
argReal->resize(argReal->size() + 1);
auto& lastElem = (*argReal)[argReal->size() - 1];
std::get<0>(lastElem).first_name.arg = &(std::get<1>(lastElem));
std::get<0>(lastElem).first_name.funcs.decode = StringDecodeFunc;
std::get<0>(lastElem).last_name.arg = &(std::get<2>(lastElem));
std::get<0>(lastElem).last_name.funcs.decode = StringDecodeFunc;
if (!pb_decode(stream, Candidate_fields, &(std::get<0>(lastElem)))) {
return false;
}
return true;
}
bool TallyEntriesDecodeFunc(pb_istream_t *stream, const pb_field_t *field, void **arg) {
auto argReal = (std::vector<std::tuple<TallyEntry, std::vector<BYTE_T>, std::vector<BYTE_T>>>*) *arg;
argReal->resize(argReal->size() + 1);
auto& lastElem = (*argReal)[argReal->size() - 1];
std::get<0>(lastElem).encrypted_value.arg = &(std::get<1>(lastElem));
std::get<0>(lastElem).encrypted_value.funcs.decode = ByteTArrayDecodeFunc;
std::get<0>(lastElem).encryption_r.arg = &(std::get<2>(lastElem));
std::get<0>(lastElem).encryption_r.funcs.decode = ByteTArrayDecodeFunc;
if (!pb_decode(stream, TallyEntry_fields, &(std::get<0>(lastElem)))) {
return false;
}
return true;
}
bool CastEncryptedBallotsDecodeFunc(pb_istream_t *stream, const pb_field_t *field, void **arg) {
auto argReal = (std::tuple<std::vector<CastEncryptedBallot>*, std::vector<std::pair<std::vector<BYTE_T>, std::vector<BYTE_T>>>*, std::vector<std::vector<EncryptedBallotEntry>>*, std::vector<std::vector<std::vector<BYTE_T>>>*>*) *arg;
std::vector<CastEncryptedBallot>& argRealFirst = *(std::get<0>(*argReal));
std::vector<std::pair<std::vector<BYTE_T>, std::vector<BYTE_T>>>& argRealSecond = *(std::get<1>(*argReal));
std::vector<std::vector<EncryptedBallotEntry>>& argRealThird = *(std::get<2>(*argReal));
std::vector<std::vector<std::vector<BYTE_T>>>& argRealFourth = *(std::get<3>(*argReal));
argRealFirst.resize(argRealFirst.size() + 1);
argRealSecond.resize(argRealSecond.size() + 1);
argRealThird.resize(argRealThird.size() + 1);
argRealFourth.resize(argRealFourth.size() + 1);
CastEncryptedBallot* ceb = &(argRealFirst.back());
ceb->cast_command_data.arg = &(argRealSecond.back().first);
ceb->cast_command_data.funcs.decode = ByteTArrayDecodeFunc;
ceb->voter_signature.arg = &(argRealSecond.back().second);
ceb->voter_signature.funcs.decode = ByteTArrayDecodeFunc;
std::pair<std::vector<EncryptedBallotEntry>*, std::vector<std::vector<BYTE_T>>*> argsInner = {&(argRealThird.back()), &(argRealFourth.back())};
ceb->encrypted_ballot.encrypted_ballot_entries.arg = &argsInner;
ceb->encrypted_ballot.encrypted_ballot_entries.funcs.decode = EncryptedBallotEntriesDecodeFunc;
if (!pb_decode(stream, CastEncryptedBallot_fields, ceb)) {
return false;
}
return true;
}
bool ElectionsDecodeFunc(pb_istream_t *stream, const pb_field_t *field, void **arg) {
auto argReal = (std::tuple<std::vector<Election>*, std::vector<std::vector<int>>*, std::vector<std::vector<std::tuple<Candidate, std::string, std::string>>>*, std::vector<std::vector<std::tuple<TallyEntry, std::vector<BYTE_T>, std::vector<BYTE_T>>>>*>*) *arg;
std::vector<Election>& argRealFirst = *(std::get<0>(*argReal));
std::vector<std::vector<int>>& argRealSecond = *(std::get<1>(*argReal));
std::vector<std::vector<std::tuple<Candidate, std::string, std::string>>>& argRealThird = *(std::get<2>(*argReal));
std::vector<std::vector<std::tuple<TallyEntry, std::vector<BYTE_T>, std::vector<BYTE_T>>>>& argRealFourth = *(std::get<3>(*argReal));
argRealFirst.resize(argRealFirst.size() + 1);
argRealSecond.resize(argRealSecond.size() + 1);
argRealThird.resize(argRealThird.size() + 1);
argRealFourth.resize(argRealFourth.size() + 1);
Election* election = &(argRealFirst[argRealFirst.size() - 1]);
election->authorized_voter_group_ids.arg = &(argRealSecond[argRealSecond.size() - 1]);
election->authorized_voter_group_ids.funcs.decode = IntArrayDecodeFunc;
election->candidates.arg = &(argRealThird[argRealThird.size() - 1]);
election->candidates.funcs.decode = CandidatesDecodeFunc;
election->tally.tally_entries.arg = &(argRealFourth[argRealFourth.size() - 1]);
election->tally.tally_entries.funcs.decode = TallyEntriesDecodeFunc;
if (!pb_decode(stream, Election_fields, election)) {
return false;
}
return true;
}
template<typename T>
std::pair<bool, std::vector<BYTE_T>> encodeMessage(const pb_msgdesc_t* pb_fields, const T& message) {
std::vector<BYTE_T> vec;
size_t encodedSize = 0;
bool resB = pb_get_encoded_size(&encodedSize, pb_fields, &message);
if(!resB) {
return {false, vec};
}
vec.resize(encodedSize); // Extra bytes for size field
pb_ostream_t buf = pb_ostream_from_buffer(&vec[0], vec.size());
resB = pb_encode(&buf, pb_fields, &message);
if(!resB) {
return {false, vec};
}
return {true, vec};
}
// Explicit instantiation. Required to fix linker errors arising from template fctns in cpp file.
template std::pair<bool, std::vector<BYTE_T>> encodeMessage<Response>(const pb_msgdesc_t* pb_fields, const Response& message);
template std::pair<bool, std::vector<BYTE_T>> encodeMessage<Command>(const pb_msgdesc_t* pb_fields, const Command& message);
template std::pair<bool, std::vector<BYTE_T>> encodeMessage<EncryptedBallot>(const pb_msgdesc_t* pb_fields, const EncryptedBallot& message);
template std::pair<bool, std::vector<BYTE_T>> encodeMessage<PaginationMetadata>(const pb_msgdesc_t* pb_fields, const PaginationMetadata& message);
template std::pair<bool, std::vector<BYTE_T>> encodeMessage<CastEncryptedBallot>(const pb_msgdesc_t* pb_fields, const CastEncryptedBallot& message);
template std::pair<bool, std::vector<BYTE_T>> encodeMessage<CastEncryptedBallots>(const pb_msgdesc_t* pb_fields, const CastEncryptedBallots& message);
template std::pair<bool, std::vector<BYTE_T>> encodeMessage<CastEncryptedBallotsRequest>(const pb_msgdesc_t* pb_fields, const CastEncryptedBallotsRequest& message);
template std::pair<bool, std::vector<BYTE_T>> encodeMessage<Voters>(const pb_msgdesc_t* pb_fields, const Voters& message);
template std::pair<bool, std::vector<BYTE_T>> encodeMessage<Elections>(const pb_msgdesc_t* pb_fields, const Elections& message);
|
[
"daniel.ruskin@uconn.edu"
] |
daniel.ruskin@uconn.edu
|
76ab275b57ae0998cb8de199399f22cf7fbaaf92
|
7012521d737dd9de98461e8d74d1df413aad5187
|
/Object Oriented Algo Design in C++/exam/max_min3way.cpp
|
bf840a6e521ac3f7bcb1ca030c935f08cade2d2c
|
[
"MIT"
] |
permissive
|
aishwaryamallampati/BTech-IIITDM
|
2282c9288dc5ae31acbfaa6f50b1067c91a8750e
|
4cfc25a4e6e066b848361cb92770cad3260c7d48
|
refs/heads/master
| 2021-02-07T17:31:40.777450
| 2021-01-05T16:50:45
| 2021-01-05T16:50:45
| 244,057,221
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,043
|
cpp
|
#include<iostream>
using namespace std;
static int min1=1000000;
static int max1=-10000000;
int used[1000]={0};
int size;
class array
{
public:
array();
int a[1000];
};
array::array()
{
int index1;
cout<<"\nenter the size of the array:";
cin>>size;
cout<<"\nenter the elements of the array: ";
for(index1=1;index1<=size;index1++)
cin>>a[index1];
}
class maxmin
{
public:
maxmin();
void find(int array[1000],int start,int end);
};
maxmin::maxmin()
{
array array1;
find(array1.a,1,size);
cout<<"\nmax="<<max1;
cout<<"\nmin="<<min1;
cout<<endl;
}
void maxmin::find(int array[100],int start,int end)
{
if(start==end)
{
if(max1<array[start])
max1=array[start];
if(min1>array[start])
min1=array[start];
}
else if(start<end)
{
int mid=(start+end)/3;
if(mid<start)
{
mid=start;
find(array,start,mid);
}
else
find(array,start,mid);
if(2*mid>end)
find(array,mid+1,end);
else
find(array,mid+1,2*mid);
find(array,2*mid+1,end);
}
}
main()
{
maxmin maxmin1;
return 0;
}
|
[
"aishwarya.mallampati@gmail.com"
] |
aishwarya.mallampati@gmail.com
|
d21b19e8baed52919c6e91beee82fa7345f0577f
|
69957429158cc2baff2b718b8d0e54c4dd4661b8
|
/chap04/list0404.cpp
|
1160d71a099e307ff7faa4a239b4c47233c8ba80
|
[] |
no_license
|
chc1129/MeikaiCpp
|
d7bbbab37a7f7ab7de5d467d097ef2dd8b5ad5f4
|
4140133fbb87f9644ce62aa1b2ef470b16afca72
|
refs/heads/main
| 2023-04-12T13:39:55.451715
| 2021-05-02T02:12:13
| 2021-05-02T02:12:13
| 357,937,061
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 264
|
cpp
|
// 読み込んだ文字のコードを表示
#include <climits>
#include <iostream>
using namespace std;
int main()
{
char c;
cout << "文字を入力せよ: ";
cin >> c;
cout << "文字'" << c << "'の文字コードは" << int(c) << "です.\n";
}
|
[
"chc1129@gmail.com"
] |
chc1129@gmail.com
|
383464c18f98aa362caa56e90bf26178c0d0f31a
|
bf61e851741e5d6673e60e0874fbe70ce6f699f8
|
/SemestralnaPraca2/Menu.h
|
1c6520fada058daf800bfec1355b20e96b2825b2
|
[] |
no_license
|
mkmec/SemestralnaPraca2
|
8de911526c9bcdd745c5e56073c7839b7fb96e69
|
bca27aa3577c7d2313678f57e7c7f9715514c405
|
refs/heads/master
| 2022-01-20T10:55:46.151103
| 2019-05-12T11:53:14
| 2019-05-12T11:53:14
| 181,847,946
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 993
|
h
|
#pragma once
#include "structures/heap_monitor.h"
#include "structures/table/unsorted_sequence_table.h"
#include "structures/table/sorted_sequence_table.h"
#include "DataObec.h"
class Menu
{
private:
structures::SortedSequenceTable<std::string, Data*>* obecData;
structures::UnsortedSequenceTable<std::string, Data*>* obecDataUns;
structures::SortedSequenceTable<std::string, Data*>* okresData;
structures::SortedSequenceTable<std::string, Data*>* krajData;
bool run_ = true;
void vypisKandidatovVUZ();
void vypis21(int zoradenie, structures::UnsortedSequenceTable<std::string, Data*>* table);
void vypis22(int zoradenie, structures::UnsortedSequenceTable<std::string, Data*>* table, int kolo);
void vypis23(int zoradenie, structures::UnsortedSequenceTable<std::string, Data*>* table, int kolo);
void zoradUzemneJednotky();
void vypisInfoOUzemnychJednotkach();
void vypisMenu();
int skontrolujIntVstup();
void nacitajData();
public:
void vyber();
Menu();
~Menu();
};
|
[
"mmkmec@gmail.com"
] |
mmkmec@gmail.com
|
ec93712d45506756aeaab239b21f88478e9763e3
|
208650de138a6b05b8b8e7e4ca6df9dc72290402
|
/Problems/Practice/C/163_remn.cpp
|
b6fe6c12c5315ac12b5dfec52cb75d250725516e
|
[] |
no_license
|
cs15b047/CF
|
9fcf83c5fd09124b6eaebbd4ecd67d19a1302582
|
d220d73a2d8739bbb10f4ed71437c06625870490
|
refs/heads/master
| 2021-08-20T06:21:24.577260
| 2021-06-09T04:56:47
| 2021-06-09T04:57:29
| 177,541,957
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 704
|
cpp
|
#include <bits/stdc++.h>
using namespace std ;
typedef long long int ll ;
vector<ll> thickness, width;
ll dp[101][201][201]={};
int main(){
ll n; scanf("%lld",&n);
thickness.resize(n+1);width.resize(n+1);
for(int i=1;i<=n;i++)cin >> thickness[i] >> width[i] ;
dp[0][0][0] = 1;
for(int i=1;i<=n;i++){
for(int j=1;j<=200;j++){
for(int k=0;k<=200;k++){
if(j >= thickness[i])dp[i][j][k] = dp[i - 1][j - thickness[i]][k];
if(k >= width[i])dp[i][j][k] = dp[i][j][k] + dp[i-1][j][k - width[i]] ;
}
}
}
ll answer=-1;
for(int j=1;j<=200;j++){
for(int k=0;k<=j;k++){
if(dp[n][j][k] > 0){
answer = j;
break;
}
}
if(answer != -1)break;
}
cout << answer << endl;
}
|
[
"cs15b047@smail.iitm.ac.in"
] |
cs15b047@smail.iitm.ac.in
|
7c4891fe5bcadd927e7e3f8366573fdfdc465e9c
|
8cad4a06b7a16b285f6b76f01fadd8f0717cf514
|
/Problem1/main.cpp
|
9e73ccedbac9e354559b61774558a2d311c6949f
|
[] |
no_license
|
davidwangd/OOPTeamProject
|
0812279049c250a57b072621081c16da10c2172d
|
87b86bd6498dda8c49856820026147df90c3cc6f
|
refs/heads/master
| 2021-01-21T18:10:25.469767
| 2017-06-17T06:39:44
| 2017-06-17T06:39:44
| 92,019,137
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,382
|
cpp
|
#include <time.h>
#include <sys/timeb.h>
#include <cstdlib>
#include <cstdio>
#include <windows.h>
#include <iostream>
#include "func.h"
using namespace std;
int main (int argc, char *argv[])
{
LARGE_INTEGER winFreq;
LARGE_INTEGER winStart, winNow;
double polysum_1=0;
double polysum_2=0;
double posysum_1=0;
double posysum_2=0;
if (!QueryPerformanceFrequency (&winFreq))
printf ("QueryPerformanceFrequency failed\n");
if (!QueryPerformanceCounter (&winStart))
printf ("QueryPerformanceCounter failed\n");
for (int i = 0; i < 10000; i++)
for (int j = 0; j < 10000; j++)
polysum_1=polynomial(argc,argv,true);
if (!QueryPerformanceCounter (&winNow))
printf ("QueryPerformanceCounter failed\n");
double time_poly_new=winNow.QuadPart-winStart.QuadPart;//使用秦九韶算法计算polynomial的时间
if(!QueryPerformanceCounter(&winStart))
printf("QueryPerformanceCounter failed\n");
for(int i=0;i<10000;i++)
for(int j=0;j<10000;j++)
posysum_1=posynomial(argc,argv,true);
if (!QueryPerformanceCounter (&winNow))
printf ("QueryPerformanceCounter failed\n");
double time_posy_new=winNow.QuadPart-winStart.QuadPart;//使用秦九韶算法计算posynomial的时间
if (!QueryPerformanceCounter (&winStart))
printf ("QueryPerformanceCounter failed\n");
for (int i = 0; i < 10000; i++)
for (int j = 0; j < 10000; j++)
polysum_2=polynomial(argc,argv,false);
if (!QueryPerformanceCounter (&winNow))
printf ("QueryPerformanceCounter failed\n");
double time_poly_old=winNow.QuadPart-winStart.QuadPart;//使用暴力方法计算polynomial的时间
if(!QueryPerformanceCounter(&winStart))
printf("QueryPerformanceCounter failed\n");
for(int i=0;i<10000;i++)
for(int j=0;j<10000;j++)
posysum_2=posynomial(argc,argv,false);
if (!QueryPerformanceCounter (&winNow))
printf ("QueryPerformanceCounter failed\n");
double time_posy_old=winNow.QuadPart-winStart.QuadPart;//使用暴力方法计算posynomial的时间
double poly_imp=(time_poly_old-time_poly_new)/time_poly_old;//polynomial的效率增长
double posy_imp=(time_posy_old-time_posy_new)/time_posy_old;//posynomial的效率增长
char buffer[1000];
sprintf(buffer, "Polysum_1:%g Polysum_2:%g Polysum improvement:%g%%\nPosysum_1:%g Posysum_2:%g Posy improvement:%g%%\n",
polysum_1,polysum_2,poly_imp*100,posysum_1,posysum_2,posy_imp*100);
cout << buffer <<endl;
return 0;
}
|
[
"davidwangnoi@163.com"
] |
davidwangnoi@163.com
|
d99f13707e48af9addb23d04b9fef21e0b4f22e0
|
4bc6d2dcc7aadcd075890c0e75d9645896314710
|
/vol3/324.cpp
|
2bd1cf7b7b20e9d3c04726a95e8378f7fe919d1a
|
[] |
no_license
|
dibery/UVa
|
ed50d28abae01a2bc119648b448ebb48f249d0b0
|
9696e6b8ed8cf459a9f3b917d6fb0549b13504e6
|
refs/heads/master
| 2021-06-09T11:10:07.721013
| 2021-05-14T17:07:58
| 2021-05-14T17:07:58
| 19,485,747
| 6
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 958
|
cpp
|
#include<cstdio>
int fact[ 367 ][ 1200 ] = { 1 }, ans[ 367 ][ 10 ] = { 0, 1 };
int main()
{
int in;
for( int i = 1, k = 1199; i <= 366; ++i, k = 1199 )
{
for( int j = 0; j < 1200; ++j )
if( fact[ i-1 ][ j ] )
fact[ i ][ j ] = fact[ i-1 ][ j ] * i;
for( int j = 0; j < 1200; ++j )
if( fact[ i ][ j ] > 9 )
{
fact[ i ][ j+1 ] += fact[ i ][ j ] / 10;
fact[ i ][ j ] %= 10;
}
while( !fact[ i ][ k ] )
--k;
for( ; k >= 0; --k )
++ans[ i ][ fact[ i ][ k ] ];
}
while( scanf( "%d", &in ) && in )
{
printf( "%d! --\n", in );
for( int i = 0; i < 5; ++i )
printf( " (%d) %d", i, ans[ in ][ i ] );
puts( "" );
for( int i = 5; i < 10; ++i )
printf( " (%d) %d", i, ans[ in ][ i ] );
puts( "" );
}
return 0;
}
|
[
"bor810818@yahoo.com.tw"
] |
bor810818@yahoo.com.tw
|
b61361dfc9e0373cf965965a75a64f09fe206f87
|
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
|
/cmake-build-debug/programs_tiling/function14699/function14699_schedule_38/function14699_schedule_38.cpp
|
40a2768ed9d410c3ed9a17881c7ae4941046455a
|
[] |
no_license
|
IsraMekki/tiramisu_code_generator
|
8b3f1d63cff62ba9f5242c019058d5a3119184a3
|
5a259d8e244af452e5301126683fa4320c2047a3
|
refs/heads/master
| 2020-04-29T17:27:57.987172
| 2019-04-23T16:50:32
| 2019-04-23T16:50:32
| 176,297,755
| 1
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,047
|
cpp
|
#include <tiramisu/tiramisu.h>
using namespace tiramisu;
int main(int argc, char **argv){
tiramisu::init("function14699_schedule_38");
constant c0("c0", 512), c1("c1", 256), c2("c2", 256);
var i0("i0", 0, c0), i1("i1", 0, c1), i2("i2", 0, c2), i100("i100", 1, c0 - 1), i101("i101", 1, c1 - 1), i102("i102", 1, c2 - 1), i01("i01"), i02("i02"), i03("i03"), i04("i04"), i05("i05"), i06("i06");
input input0("input0", {i0, i1, i2}, p_int32);
computation comp0("comp0", {i100, i101, i102}, (input0(i100, i101, i102) + input0(i100 + 1, i101, i102) - input0(i100 - 1, i101, i102)));
comp0.tile(i100, i101, i102, 128, 32, 128, i01, i02, i03, i04, i05, i06);
comp0.parallelize(i01);
buffer buf00("buf00", {512, 256, 256}, p_int32, a_input);
buffer buf0("buf0", {512, 256, 256}, p_int32, a_output);
input0.store_in(&buf00);
comp0.store_in(&buf0);
tiramisu::codegen({&buf00, &buf0}, "../data/programs/function14699/function14699_schedule_38/function14699_schedule_38.o");
return 0;
}
|
[
"ei_mekki@esi.dz"
] |
ei_mekki@esi.dz
|
0735b605eaa9216699e7e65d5bf44dd7ca3aaf0b
|
dccd1058e723b6617148824dc0243dbec4c9bd48
|
/aoj/vol23/2300.cpp
|
8eacc0aaa2ad229c1613d19267bc5bfbce02d1b2
|
[] |
no_license
|
imulan/procon
|
488e49de3bcbab36c624290cf9e370abfc8735bf
|
2a86f47614fe0c34e403ffb35108705522785092
|
refs/heads/master
| 2021-05-22T09:24:19.691191
| 2021-01-02T14:27:13
| 2021-01-02T14:27:13
| 46,834,567
| 7
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,072
|
cpp
|
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
typedef struct{
double L;
double a;
double b;
}color;
double dist(color x, color y){
double p=x.L-y.L, q=x.a-y.a, r=x.b-y.b;
return p*p+q*q+r*r;
}
int main(){
int n, m;
color c[20];
double max=0;
scanf(" %d %d", &n, &m);
for(int i=0; i<n; ++i){
scanf(" %lf %lf %lf", &c[i].L, &c[i].a, &c[i].b);
}
for(int i=(1<<n)-1; i>0; --i){
int ct=0;
for(int j=0; j<n; ++j){
if((i>>j) & 1) ct++;
}
if(ct!=m) continue;
//mビット分だけ1になっている(1になっているものが色の候補)
int nums[20];
int pp=0;
for(int j=0; j<n; ++j){
if((i>>j) & 1) nums[pp++]=j; //使う色番号のメモ
}
/*
printf(" now:: i= %d\n", i);
for(int j=0; j<pp; ++j){
printf("nums[%d]=%d\n", j, nums[j]);
}
*/
//sum of distances
double tmp=0;
for(int j=0; j<pp; ++j){
for(int k=j+1; k<pp; ++k){
tmp+=dist(c[nums[j]], c[nums[k]]);
}
}
//printf(" tmp= %lf\n", tmp);
if(tmp>max) max=tmp;
}
printf("%lf\n", max);
}
|
[
"k0223.teru@gamil.com"
] |
k0223.teru@gamil.com
|
203d15c942a053234b5d17f50f8444e429000f84
|
e732bd7e451dea33190f256d5fd9d2eccf33dd30
|
/Thuat Toan Ung Dung/Training3/Permutationgen.cpp
|
85e1512628acf45c0e39f7af4cba47f6114355fd
|
[] |
no_license
|
samreachyan/BKCodes
|
4f9486ceb8a27db29cc3d8ac584cc233a17918bd
|
fa91a55d9ef7e48aeb3be3589040c7bd9be128b2
|
refs/heads/master
| 2023-02-17T22:46:07.287094
| 2021-01-12T04:59:45
| 2021-01-12T04:59:45
| 192,798,916
| 5
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 582
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int n,a[10005];
int main()
{
cin >> n;
for(int i = 1; i <= n; ++i)
cin >> a[i];
for(int i = n-1; i >= 1; --i){
if(a[i] < a[i+1]){
int t = a[i];
swap(a[i],a[i+1]);
for(int j = i + 1; j <= n; j++){
if(a[j] > t && a[j] < a[i])
swap(a[i],a[j]);
}
sort(a+i+1,a+n+1);
for(int i = 1; i <= n; i++)
cout << a[i] << ' ';
return 0;
}
}
cout << -1;
return 0;
}
|
[
"samreachyan@gmail.com"
] |
samreachyan@gmail.com
|
71005c64abc1035c5a8cdf04a84222f63f50c12d
|
685c151efb36ed60a8de318b2eca119de1372f87
|
/3/source/Crestfall/aplusb.cpp
|
5faf1d461daaf60ab237c31f0fc36aedabe0116c
|
[] |
no_license
|
EAirPeter/wh2014
|
95cb9e7e2eb311900253ac5bfcba1ff31397b9bd
|
66e72f671f64012374f47be0cd86e0acef133de0
|
refs/heads/master
| 2020-05-09T12:03:57.146410
| 2014-02-21T11:11:12
| 2014-02-21T11:11:12
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,563
|
cpp
|
#include <cstdio>
using namespace std;
int P, N, M, S;
int A[ 100001 ], B[ 100001 ];
int F[ 400001 ];
void fc( int x, const int v ) {
for( x += S; x; x >>= 1 )
F[ x ] += v;
}
int fq( int x ) {
x += S;
int v = 1;
while( v ) {
if( v == F[ x ] ) {
x >>= 1;
v <<= 1;
}
else {
x <<= 1;
v >>= 1;
if( F[ x + 1 ] ^ v )
++x;
}
}
return ( x >> 1 ) - S;
}
int main() {
freopen( "aplusb.in", "r", stdin );
freopen( "aplusb.out", "w", stdout );
scanf( "%d%d", &P, &N );
for( S = 1; S <= N; S <<= 1 );
S = ( S >> 1 ) - 1;
for( int i = N; i; --i )
scanf( "%d", A + i );
for( int i = N; i; --i )
scanf( "%d", B + i );
for( int i = 1; i <= N; ++i )
if( A[ i ] + B[ i ] == P - 1 )
fc( i, 1 );
scanf( "%d", &M );
char s[ 4 ];
int a, b;
while( M-- ) {
scanf( "%s", s );
if( s[ 0 ] == 'C' ) {
scanf( "%s%d%d", s, &a, &b );
++a;
if( A[ a ] + B[ a ] == P - 1 )
fc( a, -1 );
if( s[ 0 ] == 'A' )
A[ a ] = b;
else
B[ a ] = b;
if( A[ a ] + B[ a ] == P - 1 )
fc( a, 1 );
}
else {
scanf( "%d", &a );
++a;
if( a == 1 ) {
printf( "%d\n", ( A[ a ] + B[ a ] ) % P );
continue;
}
/*if( A[ a - 1 ] + B[ a - 1 ] != P - 1 ) {
if( A[ a - 1 ] + B[ a - 1 ] < P )
printf( "%d\n", ( A[ a ] + B[ a ] ) % P );
else
printf( "%d\n", ( A[ a ] + B[ a ] + 1 ) % P );
continue;
}*/
int l = fq( a - 1 );
if( A[ l ] + B[ l ] < P )
printf( "%d\n", ( A[ a ] + B[ a ] ) % P );
else
printf( "%d\n", ( A[ a ] + B[ a ] + 1 ) % P );
}
}
return 0;
}
|
[
"thunderlz@vip.qq.com"
] |
thunderlz@vip.qq.com
|
2ee36d6f75dd0077634efab72eab5bc33c2aefaf
|
2084a0a4b47223bc5b38073886ffd7ca33e6b935
|
/WebrtcLogic/HttpAPI/NetworkHelper.cpp
|
4306cbf43168f91a38e96c560e58f2238cf19f4d
|
[] |
no_license
|
zhangj1024/QtWebrtc
|
2257910e27bf57db3b69ed9470b9b7fef2567c7e
|
6a66ad52b11c3f8587b6761485f06a7f9da4d71a
|
refs/heads/master
| 2020-04-01T09:06:53.210916
| 2018-10-19T10:20:59
| 2018-10-19T10:20:59
| 153,060,564
| 7
| 4
| null | null | null | null |
GB18030
|
C++
| false
| false
| 3,242
|
cpp
|
#include "stdafx.h"
#include "NetworkHelper.h"
NetworkHelper::NetworkHelper(QString url, QByteArray content, ReceiveFun receiver, int timeout, QString contenttype)
{
m_url = url;
m_content = content;
m_receiver = receiver;
m_timeout = timeout;
m_ContentType = contenttype;
m_pNetworkAccessManager = new QNetworkAccessManager();
m_pTimer = new QTimer();
connect( m_pNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(OnReplyFinished(QNetworkReply*)) );
connect( m_pTimer, SIGNAL(timeout()), this, SLOT(OnTimer()) );
}
NetworkHelper::~NetworkHelper()
{
SafeDelete(m_pNetworkAccessManager);
SafeDelete(m_pTimer);
}
void NetworkHelper::get(const QString& url, ReceiveFun receiver, int timeout, QString contenttype)
{
NetworkHelper* p = new NetworkHelper(url, "", receiver, timeout, contenttype);
p->excuteGet();
}
void NetworkHelper::post(const QString& url, const QByteArray& content, ReceiveFun receiver, int timeout, QString contenttype)
{
NetworkHelper* p = new NetworkHelper(url, content, receiver, timeout, contenttype);
p->excutePost();
}
void NetworkHelper::OnReplyFinished( QNetworkReply* reply )
{
if (m_pTimer->isActive())
{
m_pTimer->stop();
if (reply->error() == QNetworkReply::NoError)
{
QByteArray bytes = reply->readAll();
if (m_receiver)
{
RTC_LOG(LS_INFO) << QT_TO_STD(QString("E_NetOK bytes[%1]").arg(QString(bytes)));
m_receiver(E_NetOK, bytes);
}
}
else
{
if (m_receiver)
{
m_receiver(E_NetReplyError, QByteArray());
}
QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
RTC_LOG(LS_INFO) << QT_TO_STD(QString("found error ....code: %1 %2").arg(statusCodeV.toInt()).arg((int)reply->error()));
RTC_LOG(LS_INFO) << qPrintable(reply->errorString());
}
this->deleteLater();
}
reply->deleteLater();
}
void NetworkHelper::OnTimer()
{
m_pTimer->stop();
if (m_receiver)
{
RTC_LOG(LS_INFO) << "E_NetTimeOut";
m_receiver(E_NetTimeOut, QByteArray()); //超时
}
this->deleteLater();
}
void NetworkHelper::excuteGet()
{
RTC_LOG(LS_INFO) << QT_TO_STD(m_url);
QNetworkRequest network_request;
network_request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(m_ContentType));
network_request.setUrl( QUrl(m_url) );
m_pNetworkAccessManager->get(network_request);
m_pTimer->start(m_timeout);
}
void NetworkHelper::excutePost()
{
RTC_LOG(LS_INFO) << QT_TO_STD(m_url);
QNetworkRequest network_request;
network_request.setUrl( QUrl(m_url) );
network_request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(m_ContentType));
network_request.setHeader(QNetworkRequest::ContentLengthHeader, QVariant(m_content.size()).toString());
if (m_url.startsWith("https", Qt::CaseInsensitive))
{
//QNetworkAccessManager建立SSH连接时出现SslHandshakeFailedError
QSslConfiguration config = QSslConfiguration::defaultConfiguration();
// config.setProtocol(QSsl::TlsV1);
config.setPeerVerifyMode(QSslSocket::VerifyNone);
network_request.setSslConfiguration(config);
}
m_pNetworkAccessManager->post(network_request, m_content);
m_pTimer->start(m_timeout);
}
|
[
"hi5681148@163.com"
] |
hi5681148@163.com
|
637ce98656bcb900790c8ba86a25ac2e49d122e8
|
3ac0f5d35443fdcd93a7e32d5e82310c923fe431
|
/ships_in_space.cpp
|
8633b7025c389334287b018cea1b06955050cc19
|
[] |
no_license
|
nikita-p/game
|
fd4878debcd0a9d50e44452b48d4b52a33d33d0b
|
f3bf322a1e551972c57b1f8eda01d0a481c4fd0a
|
refs/heads/master
| 2021-01-10T06:22:23.742643
| 2015-12-23T11:19:25
| 2015-12-23T11:19:25
| 47,017,360
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,516
|
cpp
|
#include <math.h>
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "header.h"
struct ships_type* create_list_types ()
//Здесь создаются типы кораблей. Нужно сделать один раз в начале игры.
{
struct ships_type* list = new struct ships_type [NUM_TYPES];
for(int i=0;i<NUM_TYPES;i++)
{
list[i].attack=10*(i+1);
list[i].walking_ability=200*(i+1);
}
return list;
}
struct group_ships* create_list_groups(struct planets* all_planets)
//Функция инициализирует список групп. Нужно сделать один раз в начале игры + идёт сопоставление планет и кораблей на них
{
struct group_ships* head = new struct group_ships;
head->next = NULL;
for(int i=0;i<NUM_PLANETS;i++)
{
struct group_ships* plusShip = new struct group_ships;
plusShip->next = head;
all_planets[i].defenders= plusShip;
plusShip->current_position[0]=all_planets[i].x;
plusShip->current_position[1]=all_planets[i].y;
plusShip->next_position[0]=all_planets[i].x;
plusShip->next_position[1]=all_planets[i].y;
plusShip->player=all_planets[i].belong;
for(int j=0; j<NUM_TYPES;j++)
{
plusShip->ships_types[j]=15*(j+1);
plusShip->amount_ships += plusShip->ships_types[j];
}
head = plusShip;
}
return head;
}
int walking(struct group_ships* one_group, struct ships_type* all_types)
{
for (int i=0; i<NUM_TYPES;i++)
if(one_group->ships_types[i] != 0)
return all_types[i].walking_ability;
return 0;
}
void create_ship(struct planets creator, int type_index, int activePlayer)
//Создание корабля. Список планет, какой тип (int индекс этого типа)!, сколько может пройти, куда поставить.
{
if(creator.belong != activePlayer)
return;
creator.defenders->ships_types[type_index] ++;
creator.defenders->amount_ships++;
}
int amount_groups_ships(struct group_ships* l)
//Сколько групп кораблей существует
{
int len =0;
for(;l->next!=NULL;l=l->next)
len++;
return len;
}
struct group_ships* add_new_group(struct group_ships* all_groups)
//Создаю новую группу кораблей. Вывожу лист групп. Нулевое место в листе групп будет занимать новая группа.
{
struct group_ships* pasteGroup = new struct group_ships;
pasteGroup->amount_ships = 0;
for(int j=0;j<NUM_TYPES;j++)
pasteGroup->ships_types[j] = 0;
pasteGroup->next = all_groups;
return pasteGroup;
}
struct group_ships* delete_one_group(struct group_ships* all, int trash_index)
//Функция позволяет удалить из списка групп одну с заданным индексом.
{
struct group_ships* head = all;
struct group_ships* prev = new struct group_ships;
if(trash_index==0)
head=head->next;
for(int i=0; i<trash_index && all->next!=NULL; i++)
{
prev = all;
all=all->next;
}
prev->next = all->next;
delete all;
return head;
}
struct group_ships* delete_empty_groups(struct group_ships* l) //Не очень
//Удаляю пустые группы кораблей. Вывожу лист групп.
{
struct group_ships* head = l;
for(int i=0; l->next!=NULL; i++)
if(l->amount_ships==0)
{
head = delete_one_group(head, i);
l = head;
i=0;
}
return l;
}
void add_ship_in_group(struct group_ships* fromGroup, struct group_ships* inGroup, int typeAmount[], struct ships_type* allTypes)
{
inGroup->player=fromGroup->player;
for (int i=0; i<2; i++) //Проставляю координаты группе
{
inGroup->current_position[i] = fromGroup->current_position[i];
inGroup->next_position[i] = fromGroup->next_position[i];
}
for (int i=0; i<NUM_TYPES; i++) //Перекидываю корабли в группу
{
if(typeAmount[i]<=fromGroup->ships_types[i])
{
inGroup->ships_types[i] += typeAmount[i];
fromGroup->ships_types[i] -= typeAmount[i];
inGroup->amount_ships += typeAmount[i];
fromGroup->amount_ships -= typeAmount[i];
}
else{
inGroup->ships_types[i] += fromGroup->ships_types[i];
fromGroup->ships_types[i] = 0;
inGroup->amount_ships += fromGroup->ships_types[i];
fromGroup->amount_ships -= fromGroup->ships_types[i];
}
}
}
struct group_ships* target(struct planets planets, struct group_ships* all_groups, struct planets* planetTwo, struct ships_type* all_types)
{
int* flighters = new int [NUM_TYPES];
int sumFlighters = 0;
for(int i=0;i<NUM_TYPES;i++)
{
flighters[i]=planets.defenders->ships_types[i] - 1;
sumFlighters+= flighters[i];
}
if(sumFlighters==0)
return all_groups;
all_groups = add_new_group(all_groups);
add_ship_in_group(planets.defenders, all_groups, flighters, all_types);
delete[] flighters;
all_groups->current_position[0]=planetTwo->x;
all_groups->current_position[1]=planetTwo->y;
planetTwo->defenders = all_groups;
planetTwo->belong = all_groups->player;
return all_groups;
}
void step_group(struct group_ships* one, struct ships_type* all_types) //Вроде работает
//Беспрепятственный шаг полёта одной группы кораблей
{
if(one->next_position[0] == one->current_position[0] &&
one->next_position[1] == one->current_position[1]);
int delta_x = (one->next_position[0]) - (one->current_position[0]);
int delta_y = (one->next_position[1]) - (one->current_position[1]);
double z = sqrt(delta_x*delta_x + delta_y*delta_y);
if (z<=walking(one, all_types))
{
one->current_position[0] = one->next_position[0];
one->current_position[1] = one->next_position[1];
}
one->current_position[0] = one->current_position[0] + int(walking(one, all_types)*(delta_x/z));
one->current_position[1] = one->current_position[1] + int(walking(one, all_types)*(delta_y/z));
}
struct group_ships* step_one_ships(struct group_ships* allGroups, struct ships_type* all_types) //Вроде работает
//Беспрепятственный шаг полёта всех групп кораблей
{
int len = amount_groups_ships(allGroups);
for(int i=0; i<len; i++)
step_group(&allGroups[i], all_types);
return allGroups;
}
int check_index (int* index_active, int* index_passive, int array_active[NUM_TYPES], int array_passive[NUM_TYPES])
//Ищем лучший тип кораблей, который есть у противников
{
for(int i=0;i<NUM_TYPES;i++)
{
if(array_active[i] != 0)
*index_active = i;
if(array_passive[i] != 0)
*index_passive = i;
}
return 0;
}
struct planets* seize(struct group_ships* new_kings, struct planets* change_planet)
//Захват планеты. Необходимо сменить defenders у этой планеты
{
change_planet->defenders=new_kings;
return change_planet;
}
|
[
"nikita.petrov.1997@gmail.com"
] |
nikita.petrov.1997@gmail.com
|
304eba0f32ef266925c34aef0e43391bec80c316
|
0984181ff0c8fa0dcad62c9e54c1f6ccfe08902c
|
/SCSGA/coalitional_values_generator_sparse.cpp
|
e114b27daf73bec9ae1f63343cbb2c4881ef7f49
|
[
"MIT"
] |
permissive
|
hccz95/scsga-aaai21
|
0b11a303ab383406921192df06e89a05b5bb451d
|
58030865964c6bc44b12f2acc40970bdbed25874
|
refs/heads/main
| 2023-06-06T00:07:42.848573
| 2021-06-21T08:13:53
| 2021-06-21T08:13:53
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,257
|
cpp
|
#include "coalitional_values_generator_sparse.h"
#include <cassert>
coalitional_values_generator_sparse::coalitional_values_generator_sparse() :
sparse_generator(coalition::value_t(1.0), coalition::value_t(0.1)),
uniform_01_generator(coalition::value_t(0.0), coalition::value_t(1.0)),
sparse_uniform_generator(coalition::value_t(0.0), coalition::value_t(1.0))
{
}
void coalitional_values_generator_sparse::reset(uint32_t n_agents, uint32_t n_tasks, int seed)
{
if (seed >= 0)
{
generator.seed(seed); // Used to generate samples.
}
}
coalition::value_t coalitional_values_generator_sparse::generate_new_value(
const coalition::coalition_t& coalition,
const uint32_t task
)
{
if (uniform_01_generator(generator) < probability_to_draw_good_value)
{
if (use_uniform)
{
return sparse_uniform_generator(generator);
}
return sparse_generator(generator);
}
else
{
if (use_uniform)
{
return 0.1f * sparse_uniform_generator(generator);
}
return 0.1f * sparse_generator(generator);
}
}
std::string coalitional_values_generator_sparse::get_file_name() const
{
return "sparse_" + std::to_string(seed) + "_" + std::to_string(n_agents) + "_" + std::to_string(n_tasks) + ".problem";
}
|
[
"prantare@gmail.com"
] |
prantare@gmail.com
|
ee82a8ef6811e93ecbea469af861317a0bccc319
|
5b46738402f4c4f3c46d0e67c0e6fdc08031d9fa
|
/Contests/Microsoft/C.cpp
|
3bfe80256a177addfe4b35dc27366f6086c30a82
|
[] |
no_license
|
gafeol/competitive-programming
|
a57dcd6fbcc7eed9e4aa77815e7cb525c9ace30c
|
1af50554afe4b869f341b16681618aef0e291534
|
refs/heads/master
| 2021-07-07T09:23:51.984327
| 2021-04-18T18:20:21
| 2021-04-18T18:20:21
| 67,904,346
| 5
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,470
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
const int MAXN = 212345;
int n, m, k;
char s[MAXN];
int M[20][20];
int aux[20][20];
int has(int i, int j){
return (i >= 0 && j >= 0 && i < n && j < n && M[i][j] == 1);
}
int vi[] = {0, -1, 1, 0};
int vj[] = {1, 0, 0, -1};
int go(){
int ch = 0;
for(int a=0;a<n;a++){
for(int b=0;b<n;b++){
aux[a][b] = 0;
}
}
for(int a=0;a<n;a++){
for(int b=0;b<n;b++){
int cnt = 0;
for(int d=0;d<4;d++){
cnt += has(a+vi[d], b+vj[d]);
}
aux[a][b] = ((cnt > 1) || (M[a][b] == 1));
if(M[a][b] != aux[a][b]) ch = 1;
}
}
for(int a=0;a<n;a++){
for(int b=0;b<n;b++){
M[a][b] = aux[a][b];
}
}
return ch;
}
int main (){
scanf(" %s", s);
n = strlen(s);
for(int a=0;a<n;a++){
M[0][a] = (s[a]-'0');
}
for(int a=1;a<n;a++){
for(int b=0;b<n;b++){
char c;
scanf(" %c", &c);
M[a][b] = (c-'0');
}
}
while(go());
for(int a=0;a<n;a++){
for(int b=0;b<n;b++){
printf("%d", M[a][b]);
}
printf("\n");
}
}
|
[
"gabfeol@gmail.com"
] |
gabfeol@gmail.com
|
56e9a3d31e5a49e98728c50c0110facec22a045f
|
3cf9e141cc8fee9d490224741297d3eca3f5feff
|
/C++ Benchmark Programs/Benchmark Files 1/classtester/autogen-sources/source-5648.cpp
|
d64ff194df71a77d18e634f6ecfb6b2f0b05a697
|
[] |
no_license
|
TeamVault/tauCFI
|
e0ac60b8106fc1bb9874adc515fc01672b775123
|
e677d8cc7acd0b1dd0ac0212ff8362fcd4178c10
|
refs/heads/master
| 2023-05-30T20:57:13.450360
| 2021-06-14T09:10:24
| 2021-06-14T09:10:24
| 154,563,655
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,485
|
cpp
|
struct c0;
void __attribute__ ((noinline)) tester0(c0* p);
struct c0
{
bool active0;
c0() : active0(true) {}
virtual ~c0()
{
tester0(this);
active0 = false;
}
virtual void f0(){}
};
void __attribute__ ((noinline)) tester0(c0* p)
{
p->f0();
}
struct c1;
void __attribute__ ((noinline)) tester1(c1* p);
struct c1
{
bool active1;
c1() : active1(true) {}
virtual ~c1()
{
tester1(this);
active1 = false;
}
virtual void f1(){}
};
void __attribute__ ((noinline)) tester1(c1* p)
{
p->f1();
}
struct c2;
void __attribute__ ((noinline)) tester2(c2* p);
struct c2 : virtual c0
{
bool active2;
c2() : active2(true) {}
virtual ~c2()
{
tester2(this);
c0 *p0_0 = (c0*)(c2*)(this);
tester0(p0_0);
active2 = false;
}
virtual void f2(){}
};
void __attribute__ ((noinline)) tester2(c2* p)
{
p->f2();
if (p->active0)
p->f0();
}
struct c3;
void __attribute__ ((noinline)) tester3(c3* p);
struct c3 : virtual c0
{
bool active3;
c3() : active3(true) {}
virtual ~c3()
{
tester3(this);
c0 *p0_0 = (c0*)(c3*)(this);
tester0(p0_0);
active3 = false;
}
virtual void f3(){}
};
void __attribute__ ((noinline)) tester3(c3* p)
{
p->f3();
if (p->active0)
p->f0();
}
struct c4;
void __attribute__ ((noinline)) tester4(c4* p);
struct c4 : c3, c1, virtual c0
{
bool active4;
c4() : active4(true) {}
virtual ~c4()
{
tester4(this);
c0 *p0_0 = (c0*)(c3*)(c4*)(this);
tester0(p0_0);
c0 *p0_1 = (c0*)(c4*)(this);
tester0(p0_1);
c1 *p1_0 = (c1*)(c4*)(this);
tester1(p1_0);
c3 *p3_0 = (c3*)(c4*)(this);
tester3(p3_0);
active4 = false;
}
virtual void f4(){}
};
void __attribute__ ((noinline)) tester4(c4* p)
{
p->f4();
if (p->active1)
p->f1();
if (p->active3)
p->f3();
if (p->active0)
p->f0();
}
int __attribute__ ((noinline)) inc(int v) {return ++v;}
int main()
{
c0* ptrs0[25];
ptrs0[0] = (c0*)(new c0());
ptrs0[1] = (c0*)(c2*)(new c2());
ptrs0[2] = (c0*)(c3*)(new c3());
ptrs0[3] = (c0*)(c3*)(c4*)(new c4());
ptrs0[4] = (c0*)(c4*)(new c4());
for (int i=0;i<5;i=inc(i))
{
tester0(ptrs0[i]);
delete ptrs0[i];
}
c1* ptrs1[25];
ptrs1[0] = (c1*)(new c1());
ptrs1[1] = (c1*)(c4*)(new c4());
for (int i=0;i<2;i=inc(i))
{
tester1(ptrs1[i]);
delete ptrs1[i];
}
c2* ptrs2[25];
ptrs2[0] = (c2*)(new c2());
for (int i=0;i<1;i=inc(i))
{
tester2(ptrs2[i]);
delete ptrs2[i];
}
c3* ptrs3[25];
ptrs3[0] = (c3*)(new c3());
ptrs3[1] = (c3*)(c4*)(new c4());
for (int i=0;i<2;i=inc(i))
{
tester3(ptrs3[i]);
delete ptrs3[i];
}
c4* ptrs4[25];
ptrs4[0] = (c4*)(new c4());
for (int i=0;i<1;i=inc(i))
{
tester4(ptrs4[i]);
delete ptrs4[i];
}
return 0;
}
|
[
"ga72foq@mytum.de"
] |
ga72foq@mytum.de
|
9418a06a9859060699f0a10562ee4c8b1e253cb6
|
b62b9985ea9649e13eb9288af6a771483930f3da
|
/ExodusImport/Source/ExodusImport/Private/JsonObjects/JsonReflectionProbe.cpp
|
100a99a2f26446783a3baadb28b66a85adcbd09b
|
[
"BSD-3-Clause"
] |
permissive
|
ericblade/ProjectExodus
|
109e5f58c38a9883fac6e2c5a940b4250de2e303
|
8503fb295f327b942471e316efddf5be359bd7c0
|
refs/heads/master
| 2021-06-20T12:00:21.702983
| 2019-05-29T17:19:07
| 2019-05-29T17:19:07
| 189,268,683
| 1
| 0
|
BSD-3-Clause
| 2021-02-20T12:52:08
| 2019-05-29T17:19:46
|
C++
|
UTF-8
|
C++
| false
| false
| 1,039
|
cpp
|
#include "JsonImportPrivatePCH.h"
#include "JsonReflectionProbe.h"
#include "macros.h"
void JsonReflectionProbe::load(JsonObjPtr jsonData){
using namespace JsonObjects;
JSON_GET_PARAM(jsonData, backgroundColor, getColor);
JSON_GET_PARAM(jsonData, blendDistance, getFloat);
JSON_GET_PARAM(jsonData, boxProjection, getBool);
JSON_GET_PARAM(jsonData, center, getVector);
JSON_GET_PARAM(jsonData, size, getVector);
JSON_GET_PARAM(jsonData, clearType, getString);
JSON_GET_PARAM(jsonData, cullingMask, getInt);
JSON_GET_PARAM(jsonData, hdr, getBool);
JSON_GET_PARAM(jsonData, intensity, getFloat);
JSON_GET_PARAM(jsonData, nearClipPlane, getFloat);
JSON_GET_PARAM(jsonData, farClipPlane, getFloat);
JSON_GET_PARAM(jsonData, resolution, getInt);
JSON_GET_PARAM(jsonData, mode, getString);
JSON_GET_PARAM(jsonData, refreshMode, getString);
JSON_GET_PARAM(jsonData, customCubemapId, getInt);
JSON_GET_PARAM(jsonData, customTex2dId, getInt);
}
JsonReflectionProbe::JsonReflectionProbe(JsonObjPtr jsonData){
load(jsonData);
}
|
[
"altctrlsysrqb@gmail.com"
] |
altctrlsysrqb@gmail.com
|
400fb480b63b21c71c3689f40768812c04aba10c
|
20f360e6a120bc10c55c85cfe5da8cadf40b8dc1
|
/Game/cocos2d/external/bullet/BulletCollision/Gimpact/gim_memory.cpp
|
fc366c7d3906e2ee40c62e6766aae02cad929eb8
|
[
"MIT"
] |
permissive
|
Moreonenight/Project2019
|
40fe26d269215faca10250fada12a87b302aaa0c
|
83808d6505554a868aa526acd992a6b28aee0373
|
refs/heads/master
| 2020-05-15T11:32:40.585017
| 2019-08-08T09:33:19
| 2019-08-08T09:33:19
| 182,221,074
| 6
| 2
|
MIT
| 2019-06-16T06:52:43
| 2019-04-19T07:22:39
|
C++
|
UTF-8
|
C++
| false
| false
| 2,915
|
cpp
|
/*
-----------------------------------------------------------------------------
This source file is part of GIMPACT Library.
For the latest info, see http://gimpact.sourceforge.net/
Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
email: projectileman@yahoo.com
This library is free software; you can redistribute it and/or
modify it under the terms of EITHER:
(1) The GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at
your option) any later version. The text of the GNU Lesser
General Public License is included with this library in the
file GIMPACT-LICENSE-LGPL.TXT.
(2) The BSD-style license that is included with this library in
the file GIMPACT-LICENSE-BSD.TXT.
(3) The zlib/libpng license that is included with this library in
the file GIMPACT-LICENSE-ZLIB.TXT.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
-----------------------------------------------------------------------------
*/
#include "gim_memory.h"
#include "stdlib.h"
#ifdef GIM_SIMD_MEMORY
#include "bullet/LinearMath/btAlignedAllocator.h"
#endif
static gim_alloc_function *g_allocfn = 0;
static gim_alloca_function *g_allocafn = 0;
static gim_realloc_function *g_reallocfn = 0;
static gim_free_function *g_freefn = 0;
void gim_set_alloc_handler (gim_alloc_function *fn)
{
g_allocfn = fn;
}
void gim_set_alloca_handler (gim_alloca_function *fn)
{
g_allocafn = fn;
}
void gim_set_realloc_handler (gim_realloc_function *fn)
{
g_reallocfn = fn;
}
void gim_set_free_handler (gim_free_function *fn)
{
g_freefn = fn;
}
gim_alloc_function *gim_get_alloc_handler()
{
return g_allocfn;
}
gim_alloca_function *gim_get_alloca_handler()
{
return g_allocafn;
}
gim_realloc_function *gim_get_realloc_handler ()
{
return g_reallocfn;
}
gim_free_function *gim_get_free_handler ()
{
return g_freefn;
}
void * gim_alloc(size_t size)
{
void * ptr;
if (g_allocfn)
{
ptr = g_allocfn(size);
}
else
{
#ifdef GIM_SIMD_MEMORY
ptr = btAlignedAlloc(size,16);
#else
ptr = malloc(size);
#endif
}
return ptr;
}
void * gim_alloca(size_t size)
{
if (g_allocafn) return g_allocafn(size); else return gim_alloc(size);
}
void * gim_realloc(void *ptr, size_t oldsize, size_t newsize)
{
void * newptr = gim_alloc(newsize);
size_t copysize = oldsize<newsize?oldsize:newsize;
gim_simd_memcpy(newptr,ptr,copysize);
gim_free(ptr);
return newptr;
}
void gim_free(void *ptr)
{
if (!ptr) return;
if (g_freefn)
{
g_freefn(ptr);
}
else
{
#ifdef GIM_SIMD_MEMORY
btAlignedFree(ptr);
#else
free(ptr);
#endif
}
}
|
[
"892542697@qq.com"
] |
892542697@qq.com
|
b75636f3cf687cd0591ec0699fe418c894b586e0
|
2f07af42f60c5b7b6e365b7aa75ec0ef52a86ffc
|
/PE/8.cpp
|
c869f5a1a0f89e81d9c97cdcc7c8351e762315ca
|
[
"MIT"
] |
permissive
|
MrSiz/Coding
|
d1cff5f47a0b4b3530bdc0db641b23f55bd8e2ae
|
6e3454c9143563748b98f192102c3b6ff4c3be4f
|
refs/heads/master
| 2021-01-19T06:47:43.503988
| 2018-06-18T02:26:02
| 2018-06-18T02:26:02
| 87,500,519
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,022
|
cpp
|
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cout << #x << ' ' << x << ' ')
#define prln(x) (cout << #x << ' ' << x << endl)
char str[] = {
"73167176531330624919225119674426574742355349194934"
"96983520312774506326239578318016984801869478851843"
"85861560789112949495459501737958331952853208805511"
"12540698747158523863050715693290963295227443043557"
"66896648950445244523161731856403098711121722383113"
"62229893423380308135336276614282806444486645238749"
"30358907296290491560440772390713810515859307960866"
"70172427121883998797908792274921901699720888093776"
"65727333001053367881220235421809751254540594752243"
"52584907711670556013604839586446706324415722155397"
"53697817977846174064955149290862569321978468622482"
"83972241375657056057490261407972968652414535100474"
"82166370484403199890008895243450658541227588666881"
"16427171479924442928230863465674813919123162824586"
"17866458359124566529476545682848912883142607690042"
"24219022671055626321111109370544217506941658960408"
"07198403850962455444362981230987879927244284909188"
"84580156166097919133875499200524063689912560717606"
"05886116467109405077541002256983155200055935729725"
"71636269561882670428252483600823257530420752963450"
};
int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif // LOCAL
ll ans = 1;
int length = strlen(str);
prln(length);
for (int i = 0; i < length; ++i){
ll temp = 1;
for (int j = i; j < i + 13 && i + 13 < length; ++j){
temp *= str[j] - '0';
}
prln(temp);
ans = max(ans, temp);
}
cout << ans << endl;
return 0;
}
|
[
"zhmssl@outlook.com"
] |
zhmssl@outlook.com
|
725e53bb6d3f40018b522be238c68792a072193a
|
405d989f9ca3e3c8942934a36c92eeffdbfcf1b4
|
/animal/node.cpp
|
2097f770b55c14e22b2c952021ecd47f250fb235
|
[] |
no_license
|
flavorlessfunk/cs361
|
10294bbf23f75d268488c4764c6141e9286df851
|
a6768fb5d18d7a85baac64ba6ac2e80aa90b589c
|
refs/heads/master
| 2021-01-20T08:54:25.562473
| 2017-05-03T23:09:01
| 2017-05-03T23:09:26
| 89,802,921
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 998
|
cpp
|
#include "node.h"
#include <cassert>
using namespace std;
// write the tree whose root is given.
// Note: the form written out by this function should be something
// that read(...) will accept, recreating the original tree.
void node::write (std::ostream& out, const node* root)
{
if (root != NULL)
{
char nodeType = (root->ifYes != 0) ? 'Q' : 'A';
out << nodeType << " " << root->question << endl;
if (root->ifYes != NULL)
{
write (out, root->ifYes);
write (out, root->ifNo);
}
}
}
// read a tree from in storing the tree root in t
void node::read (istream& in, node*& root)
{
char nodeType;
in >> nodeType;
char firstCharOfQuestion;
string question;
in >> firstCharOfQuestion; // skips over any blanks
getline (in, question);
question = string(1,firstCharOfQuestion) + question;
node* yes = NULL;
node* no = NULL;
if (nodeType == 'Q')
{
read (in, yes);
read (in, no);
}
root = new node(question, yes, no);
}
|
[
"flavorlessfunk@gmail.com"
] |
flavorlessfunk@gmail.com
|
c7633d9fc27a7fa1702e7d5553ee0b9eec03c250
|
167c7506aab0e0f2d2de0994f986b846593286b1
|
/cplusplus_base_library/Qt/boost/geometry/strategies/cartesian/box_in_box.hpp
|
11e50b9c5730c744a32447288adee6feafa8a913
|
[] |
no_license
|
ngzHappy/bd2
|
78ee1755c8b83b8269e7f41bf72506bfd27564de
|
aacfc22aa1919b5ab5f5f4473375a1e8856dc213
|
refs/heads/master
| 2020-05-30T07:13:50.283590
| 2016-11-20T12:36:30
| 2016-11-20T12:36:30
| 69,462,962
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,474
|
hpp
|
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2015, 2016.
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to 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)
#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP
#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP
#include <Qt/boost/geometry/core/access.hpp>
#include <Qt/boost/geometry/core/coordinate_dimension.hpp>
#include <Qt/boost/geometry/strategies/covered_by.hpp>
#include <Qt/boost/geometry/strategies/within.hpp>
#include <Qt/boost/geometry/util/normalize_spheroidal_coordinates.hpp>
namespace boost { namespace geometry { namespace strategy
{
namespace within
{
template <typename Geometry, std::size_t Dimension, typename CSTag>
struct box_within_range
{
template <typename BoxContainedValue, typename BoxContainingValue>
static inline bool apply(BoxContainedValue const& bed_min,
BoxContainedValue const& bed_max,
BoxContainingValue const& bing_min,
BoxContainingValue const& bing_max)
{
return bing_min <= bed_min && bed_max <= bing_max // contained in containing
&& bed_min < bed_max; // interiors overlap
}
};
template <typename Geometry, std::size_t Dimension, typename CSTag>
struct box_covered_by_range
{
template <typename BoxContainedValue, typename BoxContainingValue>
static inline bool apply(BoxContainedValue const& bed_min,
BoxContainedValue const& bed_max,
BoxContainingValue const& bing_min,
BoxContainingValue const& bing_max)
{
return bed_min >= bing_min && bed_max <= bing_max;
}
};
struct box_within_longitude_check
{
template <typename CalcT>
static inline bool apply(CalcT const& diff_ed)
{
return diff_ed > CalcT(0);
}
};
struct box_covered_by_longitude_check
{
template <typename CalcT>
static inline bool apply(CalcT const&)
{
return true;
}
};
template <typename Geometry,
typename InteriorCheck>
struct box_longitude_range
{
template <typename BoxContainedValue, typename BoxContainingValue>
static inline bool apply(BoxContainedValue const& bed_min,
BoxContainedValue const& bed_max,
BoxContainingValue const& bing_min,
BoxContainingValue const& bing_max)
{
typedef typename select_most_precise
<
BoxContainedValue,
BoxContainingValue
>::type calc_t;
typedef typename coordinate_system<Geometry>::type::units units_t;
typedef math::detail::constants_on_spheroid<calc_t, units_t> constants;
// min <= max <=> diff >= 0
calc_t const diff_ed = bed_max - bed_min;
calc_t const diff_ing = bing_max - bing_min;
// if containing covers the whole globe it contains all
if (diff_ing >= constants::period())
{
return true;
}
// if containing is smaller it cannot contain
// and check interior (within vs covered_by)
if (diff_ing < diff_ed || ! InteriorCheck::apply(diff_ed))
{
return false;
}
// calculate positive longitude translation with bing_min as origin
calc_t const diff_min = math::longitude_distance_unsigned<units_t>(bing_min, bed_min);
// max of contained translated into the containing origin must be lesser than max of containing
return bing_min + diff_min + diff_ed <= bing_max;
}
};
// spherical_equatorial_tag, spherical_polar_tag and geographic_cat are casted to spherical_tag
template <typename Geometry>
struct box_within_range<Geometry, 0, spherical_tag>
: box_longitude_range<Geometry, box_within_longitude_check>
{};
template <typename Geometry>
struct box_covered_by_range<Geometry, 0, spherical_tag>
: box_longitude_range<Geometry, box_covered_by_longitude_check>
{};
template
<
template <typename, std::size_t, typename> class SubStrategy,
typename Box1,
typename Box2,
std::size_t Dimension,
std::size_t DimensionCount
>
struct relate_box_box_loop
{
static inline bool apply(Box1 const& b_contained, Box2 const& b_containing)
{
assert_dimension_equal<Box1, Box2>();
typedef typename tag_cast<typename cs_tag<Box1>::type, spherical_tag>::type cs_tag_t;
if (! SubStrategy<Box1, Dimension, cs_tag_t>::apply(
get<min_corner, Dimension>(b_contained),
get<max_corner, Dimension>(b_contained),
get<min_corner, Dimension>(b_containing),
get<max_corner, Dimension>(b_containing)
)
)
{
return false;
}
return relate_box_box_loop
<
SubStrategy,
Box1, Box2,
Dimension + 1, DimensionCount
>::apply(b_contained, b_containing);
}
};
template
<
template <typename, std::size_t, typename> class SubStrategy,
typename Box1,
typename Box2,
std::size_t DimensionCount
>
struct relate_box_box_loop<SubStrategy, Box1, Box2, DimensionCount, DimensionCount>
{
static inline bool apply(Box1 const& , Box2 const& )
{
return true;
}
};
template
<
typename Box1,
typename Box2,
template <typename, std::size_t, typename> class SubStrategy = box_within_range
>
struct box_in_box
{
static inline bool apply(Box1 const& box1, Box2 const& box2)
{
return relate_box_box_loop
<
SubStrategy,
Box1, Box2, 0, dimension<Box1>::type::value
>::apply(box1, box2);
}
};
} // namespace within
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
namespace within { namespace services
{
template <typename BoxContained, typename BoxContaining>
struct default_strategy
<
box_tag, box_tag,
box_tag, areal_tag,
cartesian_tag, cartesian_tag,
BoxContained, BoxContaining
>
{
typedef within::box_in_box<BoxContained, BoxContaining> type;
};
// spherical_equatorial_tag, spherical_polar_tag and geographic_cat are casted to spherical_tag
template <typename BoxContained, typename BoxContaining>
struct default_strategy
<
box_tag, box_tag,
box_tag, areal_tag,
spherical_tag, spherical_tag,
BoxContained, BoxContaining
>
{
typedef within::box_in_box<BoxContained, BoxContaining> type;
};
}} // namespace within::services
namespace covered_by { namespace services
{
template <typename BoxContained, typename BoxContaining>
struct default_strategy
<
box_tag, box_tag,
box_tag, areal_tag,
cartesian_tag, cartesian_tag,
BoxContained, BoxContaining
>
{
typedef within::box_in_box
<
BoxContained, BoxContaining,
within::box_covered_by_range
> type;
};
// spherical_equatorial_tag, spherical_polar_tag and geographic_cat are casted to spherical_tag
template <typename BoxContained, typename BoxContaining>
struct default_strategy
<
box_tag, box_tag,
box_tag, areal_tag,
spherical_tag, spherical_tag,
BoxContained, BoxContaining
>
{
typedef within::box_in_box
<
BoxContained, BoxContaining,
within::box_covered_by_range
> type;
};
}} // namespace covered_by::services
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
}}} // namespace boost::geometry::strategy
#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP
|
[
"819869472@qq.com"
] |
819869472@qq.com
|
8244cea7d2a30b22fae482adfbdb09445b878408
|
57ac85ca91d0f218be2a97e41ad7f8967728e7b9
|
/blaze/math/lapack/hesv.h
|
abeb99cfb85349689642d0f2a34d176cffb28118
|
[
"BSD-3-Clause"
] |
permissive
|
AuroraDysis/blaze
|
b297baa6c96b77c3d32de789e0e3af27782ced77
|
d5cacf64e8059ca924eef4b4e2a74fc9446d71cb
|
refs/heads/master
| 2021-01-01T16:49:28.921446
| 2017-07-22T23:24:26
| 2017-07-22T23:24:26
| 97,930,727
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,392
|
h
|
//=================================================================================================
/*!
// \file blaze/math/lapack/hesv.h
// \brief Header file for the LAPACK Hermitian indefinite linear system solver functions (hesv)
//
// Copyright (C) 2013 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. Redistribution and use in source and binary
// forms, with or without modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
// 3. Neither the names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
*/
//=================================================================================================
#ifndef _BLAZE_MATH_LAPACK_HESV_H_
#define _BLAZE_MATH_LAPACK_HESV_H_
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <memory>
#include <blaze/math/Aliases.h>
#include <blaze/math/constraints/Adaptor.h>
#include <blaze/math/constraints/BLASCompatible.h>
#include <blaze/math/constraints/Computation.h>
#include <blaze/math/constraints/MutableDataAccess.h>
#include <blaze/math/Exception.h>
#include <blaze/math/expressions/DenseMatrix.h>
#include <blaze/math/lapack/clapack/hesv.h>
#include <blaze/math/typetraits/IsRowMajorMatrix.h>
#include <blaze/util/Assert.h>
#include <blaze/util/constraints/SameType.h>
#include <blaze/util/NumericCast.h>
namespace blaze {
//=================================================================================================
//
// LAPACK HERMITIAN INDEFINITE LINEAR SYSTEM FUNCTIONS (HESV)
//
//=================================================================================================
//*************************************************************************************************
/*!\name LAPACK Hermitian indefinite linear system functions (hesv) */
//@{
template< typename MT, bool SO, typename VT, bool TF >
inline void hesv( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& b, char uplo, int* ipiv );
template< typename MT1, bool SO1, typename MT2, bool SO2 >
inline void hesv( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B, char uplo, int* ipiv );
//@}
//*************************************************************************************************
//*************************************************************************************************
/*!\brief LAPACK kernel for solving a Hermitian indefinite linear system of equations (\f$ A*x=b \f$).
// \ingroup lapack_solver
//
// \param A The column-major system matrix.
// \param b The right-hand side vector.
// \param uplo \c 'L' to use the lower part of the matrix, \c 'U' to use the upper part.
// \param ipiv Auxiliary array of size \a n for the pivot indices.
// \return void
// \exception std::invalid_argument Invalid non-square matrix provided.
// \exception std::invalid_argument Invalid right-hand side vector provided.
// \exception std::invalid_argument Invalid uplo argument provided.
// \exception std::runtime_error Inversion of singular matrix failed.
//
// This function uses the LAPACK hesv() functions to compute the solution to the Hermitian
// indefinite system of linear equations;
//
// - \f$ A *x=b \f$ if \a A is column-major
// - \f$ A^T*x=b \f$ if \a A is row-major
//
// In this context the Hermitian indefinite system matrix \a A is a \a n-by-\a n matrix and \a x
// and \a b are n-dimensional vectors. Note that the function only works for general, non-adapted
// matrices with \c complex<float>, or \c complex<double> element type. The attempt to call the
// function with adaptors or matrices of any other element type results in a compile time error!
//
// If the function exits successfully, the vector \a b contains the solution of the linear system
// of equations and \a A has been decomposed by means of the Bunch-Kaufman decomposition. The
// decomposition has the form
\f[ A = U D U^{H} \texttt{ (if uplo = 'U'), or }
A = L D L^{H} \texttt{ (if uplo = 'L'), } \f]
// where \c U (or \c L) is a product of permutation and unit upper (lower) triangular matrices,
// and \c D is Hermitian and block diagonal with 1-by-1 and 2-by-2 diagonal blocks. The resulting
// decomposition is stored within \a A: In case \a uplo is set to \c 'L' the result is stored in
// the lower part of the matrix and the upper part remains untouched, in case \a uplo is set to
// \c 'U' the result is stored in the upper part and the lower part remains untouched. The factored
// form of \a A is then used to solve the system of equations.
//
// The function fails if ...
//
// - ... the given system matrix is not a square matrix;
// - ... the given \a uplo argument is neither \c 'L' nor \c 'U';
// - ... the given system matrix is singular and not invertible.
//
// In all failure cases an exception is thrown.
//
// For more information on the hesv() functions (i.e. chesv() and zhesv()) see the LAPACK online
// documentation browser:
//
// http://www.netlib.org/lapack/explore-html/
//
// \note This function can only be used if a fitting LAPACK library, which supports this function,
// is available and linked to the executable. Otherwise a call to this function will result in a
// linker error.
//
// \note This function does only provide the basic exception safety guarantee, i.e. in case of an
// exception \a A may already have been modified.
*/
template< typename MT // Type of the system matrix
, bool SO // Storage order of the system matrix
, typename VT // Type of the right-hand side vector
, bool TF > // Transpose flag of the right-hand side vector
inline void hesv( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& b, char uplo, int* ipiv )
{
BLAZE_CONSTRAINT_MUST_NOT_BE_ADAPTOR_TYPE( MT );
BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE( MT );
BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE( VT );
BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS( MT );
BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS( VT );
BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_<MT> );
BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ElementType_<MT>, ElementType_<VT> );
using ET = ElementType_<MT>;
if( !isSquare( ~A ) ) {
BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
}
if( (~b).size() != (~A).rows() ) {
BLAZE_THROW_INVALID_ARGUMENT( "Invalid right-hand side vector provided" );
}
if( uplo != 'L' && uplo != 'U' ) {
BLAZE_THROW_INVALID_ARGUMENT( "Invalid uplo argument provided" );
}
int n ( numeric_cast<int>( (~A).rows() ) );
int nrhs( 1 );
int lda ( numeric_cast<int>( (~A).spacing() ) );
int ldb ( numeric_cast<int>( (~b).size() ) );
int info( 0 );
if( n == 0 ) {
return;
}
if( IsRowMajorMatrix<MT>::value ) {
( uplo == 'L' )?( uplo = 'U' ):( uplo = 'L' );
}
int lwork( n*lda );
const std::unique_ptr<ET[]> work( new ET[lwork] );
hesv( uplo, n, nrhs, (~A).data(), lda, ipiv, (~b).data(), ldb, work.get(), lwork, &info );
BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid function argument" );
if( info > 0 ) {
BLAZE_THROW_LAPACK_ERROR( "Inversion of singular matrix failed" );
}
}
//*************************************************************************************************
//*************************************************************************************************
/*!\brief LAPACK kernel for solving a Hermitian indefinite linear system of equations (\f$ A*X=B \f$).
// \ingroup lapack_solver
//
// \param A The system matrix.
// \param B The matrix of right-hand sides.
// \param uplo \c 'L' to use the lower part of the matrix, \c 'U' to use the upper part.
// \param ipiv Auxiliary array of size \a n for the pivot indices.
// \return void
// \exception std::invalid_argument Invalid non-square matrix provided.
// \exception std::invalid_argument Invalid right-hand side matrix provided.
// \exception std::invalid_argument Invalid uplo argument provided.
// \exception std::runtime_error Inversion of singular matrix failed.
//
// This function uses the LAPACK hesv() functions to compute the solution to the Hermitian
// indefinite system of linear equations:
//
// - \f$ A *X =B \f$ if both \a A and \a B are column-major
// - \f$ A^T*X =B \f$ if \a A is row-major and \a B is column-major
// - \f$ A *X^T=B^T \f$ if \a A is column-major and \a B is row-major
// - \f$ A^T*X^T=B^T \f$ if both \a A and \a B are row-major
//
// In this context the Hermitian indefinite system matrix \a A is a \a n-by-\a n matrix and \a X
// and \a B are either row-major \a m-by-\a n matrices or column-major \a n-by-\a m matrices.
// Note that the function only works for general, non-adapted matrices with \c complex<float> or
// \c complex<double> element type. The attempt to call the function with adaptors or matrices
// of any other element type results in a compile time error!
//
// If the function exits successfully, the matrix \a B contains the solution of the linear system
// of equations and \a A has been decomposed by means of a Bunch-Kaufman decomposition. The
// decomposition has the form
\f[ A = U D U^{H} \texttt{ (if uplo = 'U'), or }
A = L D L^{H} \texttt{ (if uplo = 'L'), } \f]
// where \c U (or \c L) is a product of permutation and unit upper (lower) triangular matrices,
// and \c D is Hermitian and block diagonal with 1-by-1 and 2-by-2 diagonal blocks. The resulting
// decomposition is stored within \a A: In case \a uplo is set to \c 'L' the result is stored in
// the lower part of the matrix and the upper part remains untouched, in case \a uplo is set to
// \c 'U' the result is stored in the upper part and the lower part remains untouched. The factored
// form of \a A is then used to solve the system of equations.
//
// The function fails if ...
//
// - ... the given system matrix is not a square matrix;
// - ... the given \a uplo argument is neither \c 'L' nor \c 'U';
// - ... the sizes of the two given matrices do not match;
// - ... the given system matrix is singular and not invertible.
//
// In all failure cases an exception is thrown.
//
// For more information on the hesv() functions (i.e. chesv() and zhesv()) see the LAPACK online
// documentation browser:
//
// http://www.netlib.org/lapack/explore-html/
//
// \note This function can only be used if a fitting LAPACK library, which supports this function,
// is available and linked to the executable. Otherwise a call to this function will result in a
// linker error.
//
// \note This function does only provide the basic exception safety guarantee, i.e. in case of an
// exception \a A may already have been modified.
*/
template< typename MT1 // Type of the system matrix
, bool SO1 // Storage order of the system matrix
, typename MT2 // Type of the right-hand side matrix
, bool SO2 > // Storage order of the right-hand side matrix
inline void hesv( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
char uplo, int* ipiv )
{
BLAZE_CONSTRAINT_MUST_NOT_BE_ADAPTOR_TYPE( MT1 );
BLAZE_CONSTRAINT_MUST_NOT_BE_ADAPTOR_TYPE( MT2 );
BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE( MT1 );
BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE( MT2 );
BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS( MT1 );
BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS( MT2 );
BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_<MT1> );
BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ElementType_<MT1>, ElementType_<MT2> );
using ET = ElementType_<MT1>;
if( !isSquare( ~A ) ) {
BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
}
if( uplo != 'L' && uplo != 'U' ) {
BLAZE_THROW_INVALID_ARGUMENT( "Invalid uplo argument provided" );
}
int n ( numeric_cast<int>( (~A).rows() ) );
int mrhs( numeric_cast<int>( SO2 ? (~B).rows() : (~B).columns() ) );
int nrhs( numeric_cast<int>( SO2 ? (~B).columns() : (~B).rows() ) );
int lda ( numeric_cast<int>( (~A).spacing() ) );
int ldb ( numeric_cast<int>( (~B).spacing() ) );
int info( 0 );
if( n != mrhs ) {
BLAZE_THROW_INVALID_ARGUMENT( "Invalid right-hand side matrix provided" );
}
if( n == 0 ) {
return;
}
if( IsRowMajorMatrix<MT1>::value ) {
( uplo == 'L' )?( uplo = 'U' ):( uplo = 'L' );
}
int lwork( n*lda );
const std::unique_ptr<ET[]> work( new ET[lwork] );
hesv( uplo, n, nrhs, (~A).data(), lda, ipiv, (~B).data(), ldb, work.get(), lwork, &info );
BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid function argument" );
if( info > 0 ) {
BLAZE_THROW_LAPACK_ERROR( "Inversion of singular matrix failed" );
}
}
//*************************************************************************************************
} // namespace blaze
#endif
|
[
"klaus.iglberger@gmail.com"
] |
klaus.iglberger@gmail.com
|
e4f1c92fdd350b336d14d5474eae280311d64481
|
5519b62c8c36ea93bddc4592c6318188e1a74a60
|
/source/QEMU-GUI.cpp
|
2de425922c0e31704d10c4021dc0cc77df7f3181
|
[
"Apache-2.0"
] |
permissive
|
Dovgalyuk/QemuGUI
|
e5a7c0a6241522cc363d42092649a27bc12f6e64
|
12ac1522bc02e5635fcd7b873a465f38a562b641
|
refs/heads/master
| 2021-01-19T10:58:21.364482
| 2015-05-08T07:08:13
| 2015-05-08T07:08:13
| 35,213,300
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,847
|
cpp
|
#include <QHostAddress>
#include "QEMU-GUI.h"
#include "ui_MainWindow.h"
#include "VMPropertiesDialog.h"
#include "GlobalSettingsDialog.h"
QEMUGUI::QEMUGUI(QWidget *parent) :
QMainWindow(parent), currentVM(NULL), runningVM(NULL),
ui(new Ui::mainWindow)
{
ui->setupUi(this);
this->isSaveRetrace = false;
connect(ui->confTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(changeConfigurations(QTreeWidgetItem*,QTreeWidgetItem*)));
connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
connect(ui->actionStart, SIGNAL(triggered()), this, SLOT(onExecuteAction()));
connect(ui->actionRecord, SIGNAL(triggered()), this, SLOT(onRecordAction()));
connect(ui->actionCreate, SIGNAL(triggered()), this, SLOT(on_addConfButton_clicked()));
connect(ui->actionDelete, SIGNAL(triggered()), this, SLOT(on_deleteConfButton_clicked()));
connect(ui->actionEdit, SIGNAL(triggered()), this, SLOT(on_editButton_clicked()));
connect(ui->actionOptions, SIGNAL(triggered()), this, SLOT(showGlobalOptions()));
// update totalOptionsLineEdit
connect(ui->logFileName, SIGNAL(editingFinished()), this, SLOT(updateControlsState()));
connect(ui->snapshotCheckBox, SIGNAL(clicked()), this, SLOT(updateControlsState()));
connect(ui->logOptions, SIGNAL(clicked(QModelIndex)), this, SLOT(updateControlsState()));
connect(ui->additionalOptions, SIGNAL(editingFinished()), this, SLOT(updateControlsState()));
connect(&monitorSocket, SIGNAL(readyRead()), this, SLOT(terminalRead()));
connect(ui->terminalInput->lineEdit(), SIGNAL(returnPressed()), this, SLOT(terminalWrite()));
loadConfList();
}
QEMUGUI::~QEMUGUI()
{
delete ui;
}
void QEMUGUI::loadConfList()
{
QSettings *confList = QEMUSettings::getConfigurationList();
if (confList->contains("list"))
{
QStringList data = confList->value("list").toString().split(",");
if (data.size() == 1 && data.at(0).isEmpty())
data.clear();
foreach (QString chunck, data)
{
// configurations
QTreeWidgetItem* item = new QTreeWidgetItem;
item->setText(0, chunck);
ui->confTree->addTopLevelItem(item);
// scenarios
VMProperties configurationSettings(chunck);
QStringList scenarios = configurationSettings.getScenarios();
foreach (QString name, scenarios)
{
QTreeWidgetItem *scenario = new QTreeWidgetItem(item);
scenario->setText(0, name);
}
}
if (data.size() > 0)
{
ui->confTree->setCurrentItem(ui->confTree->topLevelItem(0));
changeConfiguration(ui->confTree->topLevelItem(0)->text(0));
}
}
delete confList;
}
void QEMUGUI::on_startButton_clicked()
{
if (!currentVM || runningVM)
return;
QStringList options = getConfigurationOptions();
runningVM = new VMRunner(currentVM, options, this);
connect(runningVM, SIGNAL(resultReady(QString, QString)), this, SLOT(onVMStopped(QString, QString)));
// create directory for temporary files
// and overlay files for HDD/CD/FDD
currentVM->createWorkingDirectory(getRunName());
if (isSaveRetrace)
currentVM->createDiskImages(getRunName());
QString currentDirectory = currentVM->getRunPath(getRunName());
QDir::setCurrent(currentDirectory);
runningVM->start();
QHostAddress addr("127.0.0.1");
monitorSocket.connectToHost(addr, 2014);
ui->optionsTabs->setCurrentWidget(ui->terminalPage);
QString output = QString("<font color=White>Starting ") + currentVM->getSimulatorPath();
foreach (QString s, options)
output += " " + s;
output += "</font><br><br>";
ui->terminalOutput->appendHtml(output);
updateControlsState();
}
QString QEMUGUI::getTotalCmd(const QStringList& options) const
{
QString tmp;
foreach(QString chunck, options)
{
tmp += chunck + " ";
}
return tmp;
}
QString QEMUGUI::getRunName() const
{
return ui->confTree->getCurrentScenario();
}
void QEMUGUI::loadSettings(const QString &name)
{
delete currentVM;
currentVM = NULL;
currentVM = new VMProperties(name, this);
// восстанавливаем значения
// TODO?
//ui->snapshotCheckBox->setChecked(currentVM->getSnapshot(getRunName()));
ui->logFileName->setText(currentVM->getLogFile(getRunName()));
ui->logOptions->setCheckedCells(currentVM->getLogOptions(getRunName()));
ui->additionalOptions->setText(currentVM->getAdditionalRunOptions(getRunName()));
}
void QEMUGUI::on_addConfButton_clicked()
{
ui->confTree->addNewConf();
}
void QEMUGUI::changeConfiguration(const QString &name)
{
// Сделать изменение текущей конфигурации
loadSettings(name);
updateControlsState();
}
void QEMUGUI::on_deleteConfButton_clicked()
{
ui->confTree->removeItem(currentVM);
}
/*void QEMUGUI::on_addNewVlanButton_clicked()
{
ui->netTreeWidget->addNewVlan();
}*/
void QEMUGUI::on_editButton_clicked()
{
if (currentVM)
{
VMPropertiesDialog dialog(this, currentVM);
dialog.exec();
updateControlsState();
}
}
void QEMUGUI::changeConfigurations(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
Q_UNUSED(previous);
delete currentVM;
currentVM = NULL;
if (current)
{
QString currentConfiguration = current->parent() == NULL ? current->text(0) : current->parent()->text(0);
changeConfiguration(currentConfiguration);
}
}
void QEMUGUI::showGlobalOptions()
{
GlobalSettingsDialog dialog;
dialog.exec();
/*
QDGlobalOptions* options = new QDGlobalOptions;
if (options->exec() == QDialog::Accepted)
{
QEMUSettings::getGlobalSettings()->setDefaultQEMU(options->getQEMUPath());
QEMUSettings::getGlobalSettings()->setConfigurationsPath(options->getConfigurationsPath());
}
delete options;*/
}
void QEMUGUI::updateControlsState()
{
bool running = runningVM != NULL;
// start button
ui->actionStart->setEnabled(!running);
// create button
ui->actionCreate->setEnabled(!running);
// edit button
ui->actionEdit->setEnabled(!running
&& currentVM->getScenarios().empty());
// delete button
ui->actionDelete->setEnabled(!running);
// record button
ui->actionRecord->setEnabled(
!running && ui->confTree->isConfigurationSelected());
// terminal input
ui->terminalInput->setEnabled(running);
// command line
ui->totalOptionsLineEdit->setPlainText(
(currentVM ? currentVM->getSimulatorPath() : QString()) + " " + getTotalCmd(getConfigurationOptions()));
// snapshot box
if (!running)
{
if (currentVM && !currentVM->getScenarios().empty())
{
if (ui->confTree->isConfigurationSelected())
ui->snapshotCheckBox->setChecked(true);
else
ui->snapshotCheckBox->setChecked(false);
ui->snapshotCheckBox->setEnabled(false);
}
else
{
ui->snapshotCheckBox->setEnabled(true);
}
}
else
{
ui->snapshotCheckBox->setEnabled(false);
}
// log file
ui->logFileName->setEnabled(!running);
// log options
ui->logOptions->setEnabled(!running/* && !ui->logFileName->text().isEmpty()*/);
// other options
ui->additionalOptions->setEnabled(!running);
// configurations
ui->confTree->setEnabled(!running);
}
QStringList QEMUGUI::getConfigurationOptions()
{
QStringList options;
updateVMOptions();
bool isPlay = !ui->confTree->isConfigurationSelected() && !isSaveRetrace;
if (currentVM)
currentVM->fillCommandLine(options, getRunName(), isPlay);
// snapshot
if (ui->snapshotCheckBox->isChecked() && ui->confTree->isConfigurationSelected())
options << "-snapshot";
if (isSaveRetrace)
{
options << "-retrace-save";
QString params = "fname=replay_log.bin,snapshot=off";
QString period = currentVM->getSnapshotsPeriod(getRunName());
if (!period.isEmpty())
params += ",period=" + period;
options << params;
}
else if (isPlay)
{
options << "-retrace-play" << "fname=replay_log.bin,snapshot=off";
}
// TODO: automatically select distinct port for every machine.
options << "-monitor" << "tcp:127.0.0.1:2014,server";
return options;
}
void QEMUGUI::updateVMOptions()
{
if (!currentVM)
return;
currentVM->setLogFile(getRunName(), ui->logFileName->text());
currentVM->setLogOptions(getRunName(), ui->logOptions->getCheckedCells());
currentVM->setAdditionalRunOptions(getRunName(), ui->additionalOptions->text());
//TODO: snapshot?
}
void QEMUGUI::onRecordAction()
{
updateVMOptions();
if (ui->confTree->addNewScenario(currentVM))
{
this->isSaveRetrace = true;
on_startButton_clicked();
this->isSaveRetrace = false;
}
}
void QEMUGUI::onExecuteAction()
{
on_startButton_clicked();
}
void QEMUGUI::onVMStopped(const QString &errorText, const QString &stdoutText)
{
Q_UNUSED(errorText);
Q_UNUSED(stdoutText);
delete runningVM;
runningVM = NULL;
ui->terminalOutput->appendHtml("<font color=white>VM has stopped</font><br><br>");
//ui->terminalOutput->appendPlainText(errorText);
//ui->terminalOutput->appendPlainText(stdoutText);
updateControlsState();
}
void QEMUGUI::terminalRead()
{
QByteArray bytes = monitorSocket.readAll();
QString text;
char prev1 = 0;
char prev2 = 0;
bool processed = false;
// process escape sequences
foreach (char byte, bytes)
{
if (prev2 == 27 && prev1 == '[')
{
if (byte == 'D')
{
// truncate byte that already added to output
if (text.size() < 3)
{
QTextCursor cursor(ui->terminalOutput->document());
cursor.movePosition(QTextCursor::End);
cursor.deletePreviousChar();
}
text.truncate(text.size() - 3);
}
else
{
text.truncate(text.size() - 2);
}
processed = true;
}
else
{
text += byte;
processed = false;
}
prev2 = prev1;
prev1 = byte;
}
// trailing escape sequence
if (prev2 == 27 && prev1 == '[' && !processed)
text.truncate(text.size() - 2);
// position cursor and insert text to avoid
// inserting linefeed by appendPlainText function
QTextCursor cursor(ui->terminalOutput->document());
cursor.movePosition(QTextCursor::End);
ui->terminalOutput->setTextCursor(cursor);
ui->terminalOutput->insertPlainText(text);
ui->terminalOutput->ensureCursorVisible();
}
void QEMUGUI::terminalWrite()
{
//QString text = ui->terminalInput->text() + "\n";
QString text = ui->terminalInput->lineEdit()->text() + "\n";
QByteArray bytes = text.toAscii();
monitorSocket.write(bytes);
//ui->terminalInput->clear();
ui->terminalInput->lineEdit()->clear();
ui->terminalInput->setCurrentIndex(-1);
//ui->terminalInput->insertItem(0, text);
}
|
[
"pavel.dovgaluk@ispras.ru"
] |
pavel.dovgaluk@ispras.ru
|
3a00536a993503eb155eb6ed30afc153403b939a
|
44a03bede7d20ed11e85b9d11dbdd2e6177ee565
|
/src/editors/ECore/Editor/EditObject.h
|
d3b40989899fab0f1e1f36d8d1191d015ff8d4ba
|
[] |
no_license
|
RainbowZerg/X-Ray_Engine_1.5.1.0
|
4bdcd8b38208cb6b9b13d93aac356f685fdaa766
|
95d0f1cb8a3f1e072e5676911d28fbd624195afe
|
refs/heads/master
| 2021-01-23T01:08:19.799158
| 2018-06-01T01:52:29
| 2018-06-01T01:52:29
| 85,878,409
| 8
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 16,456
|
h
|
#ifndef EditObjectH
#define EditObjectH
#include "Bone.h"
#include "Motion.h"
#ifdef _EDITOR
# include "../../../xrServerEntities/PropertiesListTypes.h"
// #include "PropertiesListHelper.h"
# include "GameMtlLib.h"
# include "pick_defs.h"
#endif
//----------------------------------------------------
struct SRayPickInfo;
class CEditableMesh;
class CFrustum;
class CCustomMotion;
class CBone;
class Shader;
class Mtl;
class CExporter;
class CMayaTranslator;
struct st_ObjectDB;
struct SXRShaderData;
struct ogf_desc;
class CCustomObject;
#ifndef _EDITOR
class PropValue;
#define ref_shader LPVOID
#endif
#ifdef _LW_IMPORT
#include <lwobjimp.h>
#include <lwsurf.h>
#endif
#define LOD_SHADER_NAME "details\\lod"
#define LOD_SAMPLE_COUNT 8
#define LOD_IMAGE_SIZE 64
#define RENDER_SKELETON_LINKS 4
// refs
class XRayMtl;
class SSimpleImage;
class ECORE_API CSurface
{
u32 m_GameMtlID;
ref_shader m_Shader;
enum ERTFlags{
rtValidShader = (1<<0),
};
public:
enum EFlags{
sf2Sided = (1<<0),
};
shared_str m_Name;
shared_str m_Texture; //
shared_str m_VMap; //
shared_str m_ShaderName;
shared_str m_ShaderXRLCName;
shared_str m_GameMtlName;
Flags32 m_Flags;
u32 m_dwFVF;
#ifdef _MAX_EXPORT
u32 mid;
Mtl* mtl;
#endif
#ifdef _LW_IMPORT
LWSurfaceID surf_id;
#endif
Flags32 m_RTFlags;
u32 tag;
SSimpleImage* m_ImageData;
public:
CSurface ()
{
m_GameMtlName="default";
m_ImageData = 0;
m_Shader = 0;
m_RTFlags.zero ();
m_Flags.zero ();
m_dwFVF = 0;
#ifdef _MAX_EXPORT
mtl = 0;
mid = 0;
#endif
#ifdef _LW_IMPORT
surf_id = 0;
#endif
tag = 0;
}
IC bool Validate ()
{
return (0!=xr_strlen(m_Texture))&&(0!=xr_strlen(m_ShaderName));
}
#ifdef _EDITOR
~CSurface (){R_ASSERT(!m_Shader);xr_delete(m_ImageData);}
IC void CopyFrom (CSurface* surf){*this = *surf; m_Shader=0;}
IC int _Priority () {return _Shader()?_Shader()->E[0]->flags.iPriority:1;}
IC bool _StrictB2F () {return _Shader()?_Shader()->E[0]->flags.bStrictB2F:false;}
IC ref_shader _Shader () {if (!m_RTFlags.is(rtValidShader)) OnDeviceCreate(); return m_Shader;}
#endif
IC LPCSTR _Name ()const {return *m_Name;}
IC LPCSTR _ShaderName ()const {return *m_ShaderName;}
IC LPCSTR _GameMtlName ()const {return *m_GameMtlName;}
IC LPCSTR _ShaderXRLCName ()const {return *m_ShaderXRLCName;}
IC LPCSTR _Texture ()const {return *m_Texture;}
IC LPCSTR _VMap ()const {return *m_VMap;}
IC u32 _FVF ()const {return m_dwFVF;}
IC void SetName (LPCSTR name){m_Name=name;}
IC void SetShader (LPCSTR name)
{
R_ASSERT2(name&&name[0],"Empty shader name.");
m_ShaderName=name;
#ifdef _EDITOR
OnDeviceDestroy();
#endif
}
IC void SetShaderXRLC (LPCSTR name){m_ShaderXRLCName=name;}
IC void SetGameMtl (LPCSTR name){m_GameMtlName=name;}
IC void SetFVF (u32 fvf){m_dwFVF=fvf;}
IC void SetTexture (LPCSTR name){string512 buf; strcpy(buf,name); if(strext(buf)) *strext(buf)=0; m_Texture=buf;}
IC void SetVMap (LPCSTR name){m_VMap=name;}
#ifdef _EDITOR
IC u32 _GameMtl ()const {return GMLib.GetMaterialID (*m_GameMtlName);}
IC void OnDeviceCreate ()
{
R_ASSERT(!m_RTFlags.is(rtValidShader));
if (m_ShaderName.size()&&m_Texture.size()) m_Shader.create(*m_ShaderName,*m_Texture);
else m_Shader.create("editor\\wire");
m_RTFlags.set(rtValidShader,TRUE);
}
IC void OnDeviceDestroy ()
{
m_Shader.destroy();
m_RTFlags.set(rtValidShader,FALSE);
}
void CreateImageData ();
void RemoveImageData ();
#endif
};
DEFINE_VECTOR (CSurface*,SurfaceVec,SurfaceIt);
DEFINE_VECTOR (CEditableMesh*,EditMeshVec,EditMeshIt);
DEFINE_VECTOR (COMotion*,OMotionVec,OMotionIt);
DEFINE_VECTOR (CSMotion*,SMotionVec,SMotionIt);
struct ECORE_API SBonePart{
shared_str alias;
RStringVec bones;
};
DEFINE_VECTOR(SBonePart,BPVec,BPIt);
const u32 FVF_SV = D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_NORMAL;
class ECORE_API CEditableObject{
friend class CSceneObject;
friend class CEditableMesh;
friend class TfrmPropertiesEObject;
friend class CSector;
friend class TUI_ControlSectorAdd;
friend class ELibrary;
friend class TfrmEditLibrary;
friend class MeshExpUtility;
#ifdef _EDITOR
ref_geom vs_SkeletonGeom;
#endif
// desc
shared_str m_CreateName;
time_t m_CreateTime;
shared_str m_ModifName;
time_t m_ModifTime;
// general
xr_string m_ClassScript;
SurfaceVec m_Surfaces;
EditMeshVec m_Meshes;
ref_shader m_LODShader;
// skeleton
BoneVec m_Bones;
SMotionVec m_SMotions;
BPVec m_BoneParts;
CSMotion* m_ActiveSMotion;
public:
SAnimParams m_SMParam;
xr_vector<shared_str> m_SMotionRefs;
shared_str m_LODs;
public:
// options
Flags32 m_objectFlags;
enum{
eoDynamic = (1<<0),
eoProgressive = (1<<1),
eoUsingLOD = (1<<2),
eoHOM = (1<<3),
eoMultipleUsage = (1<<4),
eoSoundOccluder = (1<<5),
eoFORCE32 = u32(-1)
};
IC BOOL IsDynamic (){return m_objectFlags.is(eoDynamic);}
IC BOOL IsStatic (){return !m_objectFlags.is(eoSoundOccluder)&&!m_objectFlags.is(eoDynamic)&&!m_objectFlags.is(eoHOM)&&!m_objectFlags.is(eoMultipleUsage);}
IC BOOL IsMUStatic (){return !m_objectFlags.is(eoSoundOccluder)&&!m_objectFlags.is(eoDynamic)&&!m_objectFlags.is(eoHOM)&&m_objectFlags.is(eoMultipleUsage);}
private:
// bounding volume
Fbox m_Box;
public:
// temp variable for actor
Fvector a_vPosition;
Fvector a_vRotate;
// temp variables for transformation
Fvector t_vPosition;
Fvector t_vScale;
Fvector t_vRotate;
bool bOnModified;
IC bool IsModified (){return bOnModified;}
IC void Modified (){bOnModified=true;}
AnsiString m_LoadName;
int m_RefCount;
protected:
int m_ObjectVersion;
void ClearGeometry ();
void PrepareBones ();
void DefferedLoadRP ();
void DefferedUnloadRP ();
void __stdcall OnChangeTransform (PropValue* prop);
void __stdcall OnChangeShader (PropValue* prop);
public:
enum{
LS_RBUFFERS = (1<<0),
// LS_GEOMETRY = (1<<1),
};
Flags32 m_LoadState;
AnsiString m_LibName;
public:
// constructor/destructor methods
CEditableObject (LPCSTR name);
virtual ~CEditableObject ();
LPCSTR GetName (){ return m_LibName.c_str();}
void SetVersionToCurrent (BOOL bCreate, BOOL bModif);
void Optimize ();
IC EditMeshIt FirstMesh () {return m_Meshes.begin();}
IC EditMeshIt LastMesh () {return m_Meshes.end();}
IC EditMeshVec& Meshes () {return m_Meshes; }
IC int MeshCount () {return m_Meshes.size();}
IC void AppendMesh (CEditableMesh* M){m_Meshes.push_back(M);}
IC SurfaceVec& Surfaces () {return m_Surfaces;}
IC SurfaceIt FirstSurface () {return m_Surfaces.begin();}
IC SurfaceIt LastSurface () {return m_Surfaces.end();}
IC int SurfaceCount () {return m_Surfaces.size();}
IC int Version () {return m_ObjectVersion;}
// LOD
xr_string GetLODTextureName ();
LPCSTR GetLODShaderName (){return LOD_SHADER_NAME;}
void GetLODFrame (int frame, Fvector p[4], Fvector2 t[4], const Fmatrix* parent=0);
// skeleton
IC BPIt FirstBonePart () {return m_BoneParts.begin();}
IC BPIt LastBonePart () {return m_BoneParts.end();}
IC BPVec& BoneParts () {return m_BoneParts;}
IC int BonePartCount () {return m_BoneParts.size();}
IC BPIt BonePart (CBone* B);
IC BoneIt FirstBone () {return m_Bones.begin();}
IC BoneIt LastBone () {return m_Bones.end();}
IC BoneVec& Bones () {return m_Bones;}
IC int BoneCount () {return m_Bones.size();}
shared_str BoneNameByID (int id);
int GetRootBoneID ();
int PartIDByName (LPCSTR name);
IC CBone* GetBone (u32 idx){VERIFY(idx<m_Bones.size()); return m_Bones[idx];}
void GetBoneWorldTransform (u32 bone_idx, float t, CSMotion* motion, Fmatrix& matrix);
IC SMotionIt FirstSMotion () {return m_SMotions.begin();}
IC SMotionIt LastSMotion () {return m_SMotions.end();}
SMotionVec& SMotions () {return m_SMotions;}
IC int SMotionCount () {return m_SMotions.size();}
IC bool IsAnimated () {return SMotionCount() || m_SMotionRefs.size();}
//. IC LPCSTR SMotionRefs () {return *m_SMotionRefs; }
IC void SkeletonPlay () {m_SMParam.Play();}
IC void SkeletonStop () {m_SMParam.Stop();}
IC void SkeletonPause (bool val) {m_SMParam.Pause(val);}
/// IC bool CheckVersion () {if(m_LibRef) return (m_ObjVer==m_LibRef->m_ObjVer); return true;}
// get object properties methods
IC xr_string& GetClassScript () {return m_ClassScript;}
IC const Fbox& GetBox () {return m_Box;}
IC LPCSTR GetLODs () {return m_LODs.c_str();}
// animation
IC bool IsSkeleton () {return !!m_Bones.size();}
IC bool IsSMotionActive () {return IsSkeleton()&&m_ActiveSMotion; }
CSMotion* GetActiveSMotion () {return m_ActiveSMotion; }
void SetActiveSMotion (CSMotion* mot);
bool CheckBoneCompliance (CSMotion* M);
bool VerifyBoneParts ();
void OptimizeSMotions ();
bool LoadBoneData (IReader& F);
void SaveBoneData (IWriter& F);
void ResetBones ();
CSMotion* ResetSAnimation (bool bGotoBindPose=true);
void CalculateAnimation (CSMotion* motion);
void CalculateBindPose ();
void GotoBindPose ();
void OnBindTransformChange ();
// statistics methods
void GetFaceWorld (const Fmatrix& parent, CEditableMesh* M, int idx, Fvector* verts);
int GetFaceCount ();
int GetVertexCount ();
int GetSurfFaceCount (LPCSTR surf_name);
// render methods
void Render (const Fmatrix& parent, int priority, bool strictB2F);
void RenderSelection (const Fmatrix& parent, CEditableMesh* m=0, CSurface* s=0, u32 c=0x40E64646);
void RenderEdge (const Fmatrix& parent, CEditableMesh* m=0, CSurface* s=0, u32 c=0xFFC0C0C0);
void RenderBones (const Fmatrix& parent);
void RenderAnimation (const Fmatrix& parent);
void RenderSingle (const Fmatrix& parent);
void RenderSkeletonSingle (const Fmatrix& parent);
void RenderLOD (const Fmatrix& parent);
// update methods
void OnFrame ();
void UpdateBox ();
void EvictObject ();
// pick methods
bool RayPick (float& dist, const Fvector& S, const Fvector& D, const Fmatrix& inv_parent, SRayPickInfo* pinf=0);
#ifdef _EDITOR
void AddBone (CBone* parent_bone);
void DeleteBone (CBone* bone);
void RenameBone (CBone* bone, LPCSTR new_name);
void RayQuery (SPickQuery& pinf);
void RayQuery (const Fmatrix& parent, const Fmatrix& inv_parent, SPickQuery& pinf);
void BoxQuery (const Fmatrix& parent, const Fmatrix& inv_parent, SPickQuery& pinf);
bool BoxPick (CCustomObject* obj, const Fbox& box, const Fmatrix& inv_parent, SBoxPickInfoVec& pinf);
bool FrustumPick (const CFrustum& frustum, const Fmatrix& parent);
bool SpherePick (const Fvector& center, float radius, const Fmatrix& parent);
// bone
CBone* PickBone (const Fvector& S, const Fvector& D, const Fmatrix& parent);
void SelectBones (bool bVal);
void SelectBone (CBone* b, bool bVal);
void ClampByLimits (bool bSelOnly);
#endif
// change position/orientation methods
void TranslateToWorld (const Fmatrix& parent);
// clone/copy methods
void RemoveMesh (CEditableMesh* mesh);
bool RemoveSMotion (LPCSTR name);
bool RenameSMotion (LPCSTR old_name, LPCSTR new_name);
bool AppendSMotion (LPCSTR fname, SMotionVec* inserted=0);
void ClearSMotions ();
bool SaveSMotions (LPCSTR fname);
// load/save methods
//void LoadMeshDef (FSChunkDef *chunk);
bool Reload ();
bool Load (LPCSTR fname);
bool LoadObject (LPCSTR fname);
bool SaveObject (LPCSTR fname);
bool Load (IReader&);
void Save (IWriter&);
#ifdef _EDITOR
void FillMotionList (LPCSTR pref, ListItemsVec& items, int modeID);
void FillBoneList (LPCSTR pref, ListItemsVec& items, int modeID);
void FillSurfaceList (LPCSTR pref, ListItemsVec& items, int modeID);
void FillSurfaceProps (CSurface* surf, LPCSTR pref, PropItemVec& items);
void FillBasicProps (LPCSTR pref, PropItemVec& items);
void FillSummaryProps (LPCSTR pref, PropItemVec& items);
bool CheckShaderCompatible ();
#endif
bool Import_LWO (LPCSTR fname, bool bNeedOptimize);
// contains methods
CEditableMesh* FindMeshByName (LPCSTR name, CEditableMesh* Ignore=0);
void VerifyMeshNames ();
bool ContainsMesh (const CEditableMesh* m);
CSurface* FindSurfaceByName (LPCSTR surf_name, int* s_id=0);
int FindBoneByNameIdx (LPCSTR name);
BoneIt FindBoneByNameIt (LPCSTR name);
CBone* FindBoneByName (LPCSTR name);
int GetSelectedBones (BoneVec& sel_bones);
u16 GetBoneIndexByWMap (LPCSTR wm_name);
CSMotion* FindSMotionByName (LPCSTR name, const CSMotion* Ignore=0);
void GenerateSMotionName (char* buffer, LPCSTR start_name, const CSMotion* M);
bool GenerateBoneShape (bool bSelOnly);
// device dependent routine
void OnDeviceCreate ();
void OnDeviceDestroy ();
// utils
void PrepareOGFDesc (ogf_desc& desc);
// skeleton
bool PrepareSVGeometry (IWriter& F, u8 infl);
bool PrepareSVKeys (IWriter& F);
bool PrepareSVDefs (IWriter& F);
bool PrepareSkeletonOGF (IWriter& F, u8 infl);
// rigid
bool PrepareRigidOGF (IWriter& F, bool gen_tb, CEditableMesh* mesh);
// ogf
bool PrepareOGF (IWriter& F, u8 infl, bool gen_tb, CEditableMesh* mesh);
bool ExportOGF (LPCSTR fname, u8 skl_infl);
// omf
bool PrepareOMF (IWriter& F);
bool ExportOMF (LPCSTR fname);
// obj
bool ExportOBJ (LPCSTR name);
LPCSTR GenerateSurfaceName (LPCSTR base_name);
#ifdef _MAX_EXPORT
BOOL ExtractTexName (Texmap *src, LPSTR dest);
BOOL ParseStdMaterial (StdMat* src, CSurface* dest);
BOOL ParseMultiMaterial (MultiMtl* src, u32 mid, CSurface* dest);
BOOL ParseXRayMaterial (XRayMtl* src, u32 mid, CSurface* dest);
CSurface* CreateSurface (Mtl* M, u32 mat_id);
bool ImportMAXSkeleton (CExporter* exporter);
#endif
#ifdef _LW_EXPORT
bool Import_LWO (st_ObjectDB *I);
Flags32 m_Flags;
#endif
#ifdef _LW_IMPORT
bool Export_LW (LWObjectImport *local);
#endif
#ifdef _MAYA_EXPORT
BOOL ParseMAMaterial (CSurface* dest, SXRShaderData& d);
CSurface* CreateSurface (LPCSTR m_name, SXRShaderData& d);
CSurface* CreateSurface (MObject shader);
#endif
bool ExportLWO (LPCSTR fname);
bool Validate ();
};
//----------------------------------------------------
//----------------------------------------------------
#define EOBJ_CURRENT_VERSION 0x0010
//----------------------------------------------------
#define EOBJ_CHUNK_OBJECT_BODY 0x7777
#define EOBJ_CHUNK_VERSION 0x0900
#define EOBJ_CHUNK_REFERENCE 0x0902
#define EOBJ_CHUNK_FLAGS 0x0903
#define EOBJ_CHUNK_SURFACES 0x0905
#define EOBJ_CHUNK_SURFACES2 0x0906
#define EOBJ_CHUNK_SURFACES3 0x0907
#define EOBJ_CHUNK_EDITMESHES 0x0910
#define _EOBJ_CHUNK_LIB_VERSION_ 0x0911 // obsolette
#define EOBJ_CHUNK_CLASSSCRIPT 0x0912
#define EOBJ_CHUNK_BONES 0x0913
//#define EOBJ_CHUNK_OMOTIONS 0x0914
#define EOBJ_CHUNK_SMOTIONS 0x0916
#define EOBJ_CHUNK_SURFACES_XRLC 0x0918
#define EOBJ_CHUNK_BONEPARTS 0x0919
#define EOBJ_CHUNK_ACTORTRANSFORM 0x0920
#define EOBJ_CHUNK_BONES2 0x0921
#define EOBJ_CHUNK_DESC 0x0922
#define EOBJ_CHUNK_BONEPARTS2 0x0923
#define EOBJ_CHUNK_SMOTIONS2 0x0924
#define EOBJ_CHUNK_LODS 0x0925
#define EOBJ_CHUNK_SMOTIONS3 0x0926
//----------------------------------------------------
#endif /*_INCDEF_EditObject_H_*/
|
[
"zloyzergo@gmail.com"
] |
zloyzergo@gmail.com
|
7bd71b0e357ed0f549081555f301e03d84fe2b54
|
bba21a9bbd9a136ef7f38cad3233bf7a8e80f153
|
/Backup/GDK/Branches/M1Exit/L3DGraphics/CameraComponent.h
|
6b7713508085559889549dab853fd2a05e320520
|
[] |
no_license
|
rezanour/randomoldstuff
|
da95141b3eb7698a55c27b788b2bf3315462545c
|
f78ccc05e5b86909325f7f2140b18d6134de5904
|
refs/heads/master
| 2021-01-19T18:02:40.190735
| 2014-12-15T05:27:17
| 2014-12-15T05:28:41
| 27,686,761
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,840
|
h
|
#pragma once
#include <GDK\RefCounted.h>
#include <GDK\ObjectModel\ObjectComponent.h>
#define DIRECTXMATH_INTEROP
#include <L3DMath\L3DMath.h>
#include "GraphicsTypes.h"
#include <stde\non_copyable.h>
namespace Lucid3D
{
class Renderer;
class CameraComponent;
typedef stde::ref_counted_ptr<CameraComponent> CameraPtr;
class CameraComponent : stde::non_copyable, public GDK::RefCountedBase<GDK::ICameraComponent>
{
public:
static HRESULT Create( _In_ Renderer* pRenderer,
_In_ GDK::IGameObject* pGameObject,
_In_ uint64 contentId,
_Out_ CameraPtr& spComponent);
// IObjectComponent
GDK_METHOD_(const GDK::IGameObject*) GetOwner() const;
GDK_METHOD_(GDK::ObjectComponentType) GetType() const;
// Methods
const L3DMath::Matrix& GetViewMatrix()
{
if (GetOwner()->GetTransformSalt() != _transformSalt)
{
UpdateMatrices();
}
return _view;
}
const L3DMath::Matrix& GetProjectionMatrix()
{
return _projection;
}
const float GetNearClipPlane() const
{
return _nearClipPlane;
}
const float GetFarClipPlane() const
{
return _farClipPlane;
}
private:
CameraComponent(_In_ GDK::IGameObject* pGameObject, _In_ float fov, _In_ float aspectRatio, _In_ float nearClip, _In_ float farClip);
void UpdateMatrices();
GDK::IGameObject* _pOwner;
float _fov;
float _aspectRatio;
float _nearClipPlane;
float _farClipPlane;
size_t _transformSalt;
L3DMath::Matrix _view;
L3DMath::Matrix _projection;
};
}
|
[
"rezanour@hotmail.com"
] |
rezanour@hotmail.com
|
88e8d8dec965e06a4b38ccb21a5ae288e4bc27ab
|
195104a6fb65371dae3531ecc1cf8618536304c3
|
/tests/Main.cpp
|
195571ae908772e2a8ec316eb311767b9f6277eb
|
[
"MIT"
] |
permissive
|
lineCode/MACE-1
|
7b21b21dabd5a8927dc04a698e3cdd04b56f8194
|
68f0b4f1dd5d533a933e0bef8aef205a94be489a
|
refs/heads/master
| 2020-04-08T19:27:51.014488
| 2018-04-26T17:04:03
| 2018-04-26T17:04:03
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,486
|
cpp
|
/*
The MIT License (MIT)
Copyright (c) 2016 Liav Turkia and Shahar Sandhaus
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
#define MACE_DEBUG 1
#define MACE_EXPOSE_ALL 1
#include <MACE/MACE.h>
#define CATCH_CONFIG_RUNNER
#ifdef MACE_WINDOWS
# define CATCH_CONFIG_WINDOWS_CRTDBG 1
#endif
#include <Catch.hpp>
#include <exception>
#include <iostream>
void onUnexpected[[noreturn]](){
std::cerr << "Unexpected exception occured" << std::endl;
std::abort();
}
void onTerminate[[noreturn]](){
std::cerr << "An unhandled exception occured" << std::endl;
std::abort();
}
int main(int argc, char* const argv[]) {
try {
std::set_unexpected(&onUnexpected);
std::set_terminate(&onTerminate);
//constant? get it?
const int result = Catch::Session().run(argc, argv);
return result;
} catch( const std::exception& e ) {
mc::Error::handleError(e);
return -1;
} catch (...) {
std::cerr << "An unknown exception occured";
return -1;
}
return -1;
}
|
[
"liavt@yahoo.com"
] |
liavt@yahoo.com
|
e21d244ace42039c20b6c37a6704b0ad4233c415
|
97a1a5e2cbf35052c223d12715f1ea4534aec865
|
/tests/TestEstimatorQuality.cc
|
688329e7ed3cd7d5eb08b2ffab41201e06a7d5ec
|
[] |
no_license
|
francois-drielsma/synapse
|
8502985a5cd998a037088b127fc14b24a25a5746
|
acb008f8421cd3bfbce4d4cefd43d12002addab0
|
refs/heads/master
| 2021-06-04T01:40:37.668634
| 2019-11-30T19:38:03
| 2019-11-30T19:38:03
| 134,827,182
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 18,032
|
cc
|
// Cpp includes
#include <ctime>
#include <cmath>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <regex>
#include <map>
// Root includes
#include "TStyle.h"
#include "TObject.h"
#include "TString.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TH2.h"
#include "TLegend.h"
#include "TGraphErrors.h"
#include "TColor.h"
// Additional modules
#include "DensityEstimator.hh"
#include "DGaus.hh"
#include "DMultiGaus.hh"
#include "DChiSquared.hh"
#include "DCauchy.hh"
#include "DExponential.hh"
#include "DUniform.hh"
#include "DTriangular.hh"
#include "DMaxwell.hh"
// TEMPORARYYYYYYYY TODO
double gauslevel(double *x, double *par) {
double R2 = TMath::ChisquareQuantile(x[0], par[0]);
return exp(-R2/2)/pow(2*M_PI, par[0]/2);
}
int main(int argc, char ** argv) {
gStyle->SetLabelSize(0.05, "XYZ");
gStyle->SetTitleSize(0.05, "XYZ");
std::vector<double> stops = {0., 0.125, .25, .375, .5, .625, .75, .875, 1.};
std::vector<double> red = {0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764};
std::vector<double> green = {0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832};
std::vector<double> blue = {0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539};
TColor::CreateGradientColorTable(9, &stops[0], &red[0], &green[0], &blue[0], 255, 1);
////////////////////////////////////////////
//////////// GLOBAL PARAMETERS /////////////
////////////////////////////////////////////
gStyle->SetOptStat(0);
double alpha = .5;
const size_t nsamples = 1e4;
size_t npoints = 1e4;
std::string algo = "knn";
if ( argc < 2 ) {
std::cerr << "No density estimation algorithm specified, using knn" << std::endl;
} else {
algo = argv[1];
}
////////////////////////////////////////////
/////////// TEST DISTRIBUTIONS /////////////
////////////////////////////////////////////
// 1D distributions
std::vector<DFunction*> f1d; // List of 1D functions
// Gaussian distribution
// double gaus1m(0.), gaus1s(1.);
// f1d.push_back(new DGaus(gaus1m, gaus1s));
// Two-peak gaussian
// f1d.push_back(new DMultiGaus(1, 2));
// Chi squared distribution
// f1d.push_back(new DChiSquared(4));
// Cauchy
// f1d.push_back(new DCauchy());
// Exponential
// f1d.push_back(new DExponential());
// Uniform
f1d.push_back(new DUniform());
f1d.back()->SetRange(-1, 1);
// Triangular
// f1d.push_back(new DTriangular());
// DTriangular tri1(1);
// std::cerr << "Triangular radius: " << tri1.Radius(.5) << std::endl;
// f1d.back()->SetRange(-tri1.Radius(.5), tri1.Radius(.5));
// Maxwell-Boltzmann
// f1d.push_back(new DMaxwell());
////////////////////////////////////////////
// 2D distributions
std::vector<DFunction*> f2d; // List of 2D functions
// Uncorrelated Gaussian distribution
// Matrix<double> gaus2_cov({{1, 0}, {0, 1}});
// std::vector<double> gaus2_means = {0, 0};
// f2d.push_back(new DGaus(gaus2_means, gaus2_cov));
// Correlated Gaussian distribution
/* double gaus2_rho = 0.9;
gaus2_cov = Matrix<double>({{1, gaus2_rho}, {gaus2_rho, 1}});
gaus2_means = {0, 0};
DGaus *fgaus2corr = new DGaus(gaus2_means, gaus2_cov);
f2d.push_back(fgaus2corr);
fgaus2corr->SetName("gaus2corr");
fgaus2corr->SetTitle("2D Correlated Gaussian");*/
// Three-peak Gaussian
// f2d.push_back(new DMultiGaus(2, 3));
// Exponential
f2d.push_back(new DExponential(2));
// Uniform
// f2d.push_back(new DUniform(2));
// Triangular
// f2d.push_back(new DTriangular(2));
// Maxwell-Boltzmann
f2d.push_back(new DMaxwell({0., 0.}, Matrix<double>({{1, 0}, {0, 1}})));
////////////////////////////////////////////
// 3D distributions
std::vector<DFunction*> f3d; // List of 3D functions
// Gaussian distribution
/* double Lgaus3 = 3;
Matrix<double> gaus3_cov({{1, 0, 0}, {0, 1, 0}, {0, 0, 1}});
std::vector<double> gaus3_means({0, 0, 0}),
gaus3_l({-Lgaus3, -Lgaus3, -Lgaus3}), gaus3_u({Lgaus3, Lgaus3, Lgaus3});
DGaus *fgaus3 = new DGaus(gaus3_means, gaus3_cov);
fgaus3->SetRange(gaus3_l, gaus3_u);
f3d.push_back(fgaus3);*/
// Four-peak Gaussian
// f3d.push_back(new DMultiGaus(3, 4));
// Uniform
// f3d.push_back(new DUniform(3));
// Exponential
// f3d.push_back(new DExponential(3));
// Triangular
// f3d.push_back(new DTriangular(3));
// Maxwell-Boltzmann
// f3d.push_back(new DMaxwell(3));
////////////////////////////////////////////
// Radial distributions (for higher dimensions, only way to represent functions is radially)
std::vector<DFunction*> frad; // List of Radial functions
Pitch::setAnOutput(Pitch::debug, std::cerr);
// frad.push_back(new DGaus(1));
// frad.push_back(new DGaus(2));
// frad.push_back(new DGaus(3));
frad.push_back(new DGaus(4));
// frad.push_back(new DGaus(6));
// frad.push_back(new DTriangular(1));
// frad.push_back(new DTriangular(2));
// frad.push_back(new DTriangular(3));
// frad.push_back(new DTriangular(4));
// frad.push_back(new DUniform(1));
// frad.push_back(new DUniform(4));
// frad.back()->SetRange({-1,-1,-1,-1},{1,1,1,1});
// frad.push_back(new DMaxwell(1));
// frad.push_back(new DMaxwell(2));
// frad.push_back(new DMaxwell(3));
// frad.push_back(new DMaxwell(4));
// Gaussian distribution
/* double Lgaus4 = 3;
Matrix<double> gaus4_cov({{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}});
std::vector<double> gaus4_means({0, 0, 0, 0}),
gaus4_l({-Lgaus4, -Lgaus4, -Lgaus4, -Lgaus4}), gaus4_u({Lgaus4, Lgaus4, Lgaus4, Lgaus4});
DGaus *fgaus4 = new DGaus(gaus4_means, gaus4_cov);
// fgaus4->SetRange(gaus4_l, gaus4_u);
frad.push_back(fgaus4);*/
////////////////////////////////////////////
//////////////// SAMPLING //////////////////
////////////////////////////////////////////
// 1D samples
std::vector<std::vector<std::vector<double>>> s1d(f1d.size());
size_t i, j;
for (i = 0; i < f1d.size(); i++)
for (j = 0; j < nsamples; j++)
s1d[i].push_back(f1d[i]->RandomVector());
////////////////////////////////////////////
// 2D samples
std::vector<std::vector<std::vector<double>>> s2d(f2d.size());
for (i = 0; i < f2d.size(); i++)
for (j = 0; j < nsamples; j++)
s2d[i].push_back(f2d[i]->RandomVector());
////////////////////////////////////////////
// 3D samples
std::vector<std::vector<std::vector<double>>> s3d(f3d.size());
for (i = 0; i < f3d.size(); i++)
for (j = 0; j < nsamples; j++)
s3d[i].push_back(f3d[i]->RandomVector());
////////////////////////////////////////////
// Radial samples
std::vector<std::vector<std::vector<double>>> srad(frad.size());
for (i = 0; i < frad.size(); i++)
for (j = 0; j < nsamples; j++)
srad[i].push_back(frad[i]->RandomVector());
DensityEstimator de(srad[0], algo, false, 1.);
std::vector<double> levels(nsamples);
for (i = 0; i < nsamples; i++)
levels[i] = de(srad[0][i]);
std::sort(levels.begin(), levels.end());
TGraph* gpro = new TGraph();
for (i = 0; i < nsamples; i++)
gpro->SetPoint(i, (double)(nsamples-i)/(nsamples+1), levels[i]);
TF1 *flevel = new TF1("level", gauslevel, 0, 1, 1);
flevel->SetParameter(0, 4);
TCanvas *ct = new TCanvas("c", "c", 1200, 800);
gpro->Draw("APL");
flevel->Draw("SAME");
ct->SaveAs("profile.pdf");
delete ct;
// Plot the 3D exponential samples in xy, xz, yz
/*TH2F* hxy = new TH2F("xy", "", 100, -3, 3, 100, -3, 3);
TH2F* hxz = new TH2F("xz", "", 100, -3, 3, 100, -3, 3);
TH2F* hyz = new TH2F("yz", "", 100, -3, 3, 100, -3, 3);
TH3F* hxyz = new TH3F("xyz", "", 10, -3, 3, 10, -3, 3, 10, -3, 3);
std::vector<std::vector<double>> test = srad[3];
for (i = 0; i < nsamples; i++) {
hxy->Fill(test[i][0], test[i][1]);
hxz->Fill(test[i][0], test[i][2]);
hyz->Fill(test[i][1], test[i][2]);
hxyz->Fill(test[i][0], test[i][1], test[i][2]);
}
TCanvas *ctest = new TCanvas("c", "c", 1200, 800);
hxy->Draw("COLZ");
ctest->SaveAs("xy.pdf");
delete ctest;
ctest = new TCanvas("c", "c", 1200, 800);
hxz->Draw("COLZ");
ctest->SaveAs("xz.pdf");
delete ctest;
ctest = new TCanvas("c", "c", 1200, 800);
hyz->Draw("COLZ");
ctest->SaveAs("yz.pdf");
delete ctest;
ctest = new TCanvas("c", "c", 1200, 800);
hxyz->Draw("");
ctest->SaveAs("xyz.pdf");
delete ctest;*/
////////////////////////////////////////////
/////////// DENSITY ESTIMATION /////////////
////////////////////////////////////////////
// 1D density estimators
std::vector<TGraph*> de1d; // Interpolated function
std::vector<TGraph*> band1d; // Error band with respect to true
std::vector<TH1F*> cont1d; // 1D contour
std::vector<double> ise1d; // Mean Integrated Square Error
std::vector<double> vol1d; // Volumes of the 1d contours
std::vector<double> min, max;
double x, ise, real, est;
for (i = 0; i < f1d.size(); i++) {
// Initialize the density estimator
DensityEstimator de(s1d[i], algo, false);
// Initialize graphs and fill it with points from the density estimator
TGraph *graph = new TGraph(npoints);
graph->SetTitle(f1d[i]->Title().c_str());
TGraph *band = new TGraph(2*npoints);
f1d[i]->Range(min, max);
ise = 0.;
for (j = 0; j < npoints; j++) {
x = min[0]+(double)j*(max[0]-min[0])/(npoints-1);
real = f1d[i]->Evaluate(x);
est = de(x);
ise += pow(est-real, 2)*(max[0]-min[0])/(npoints-1);
graph->SetPoint(j, x, est);
band->SetPoint(j, x, est);
band->SetPoint(2*npoints-1-j, x, real);
}
de1d.push_back(graph);
band1d.push_back(band);
ise1d.push_back(ise);
// vol1d.push_back(de.ContourVolume(alpha, "mc"));
// cont1d.push_back(de.Contour1D());
}
////////////////////////////////////////////
// 2D density estimators
npoints = 100;
std::vector<TH2F*> de2d; // Interpolated function
std::vector<TH2F*> cont2d; // TH2F at a certain contour level
std::vector<double> ise2d; // Mean Integrated Square Error
std::vector<double> vol2d; // Volumes of the 2d contours
double y;
size_t k;
for (i = 0; i < f2d.size(); i++) {
// Initialize the density estimator
DensityEstimator de(s2d[i], algo, false, 1.);
// Initialize graphs and fill it with points from the density estimator
f2d[i]->Range(min, max);
TH2F *graph = new TH2F((f2d[i]->Name()+"_de").c_str(), f2d[i]->Title().c_str(),
npoints, min[0], max[0], npoints, min[1], max[1]);
ise = 0.;
for (j = 0; j < (size_t)graph->GetNbinsX(); j++) {
for (k = 0; k < (size_t)graph->GetNbinsY(); k++) {
x = graph->GetXaxis()->GetBinCenter(j+1);
y = graph->GetYaxis()->GetBinCenter(k+1);
real = f2d[i]->Evaluate({x, y});
est = de({x, y});
ise += pow(est-real, 2)*(max[0]-min[0])*(max[1]-min[1])/pow(npoints-1, 2);
graph->SetBinContent(j+1, k+1, est);
}
}
de2d.push_back(graph);
ise2d.push_back(ise);
vol2d.push_back(de.ContourVolume(alpha, "mc"));
cont2d.push_back(de.Contour2D());
}
////////////////////////////////////////////
// 3D density estimators
std::vector<TH3F*> cont3d; // TH3F at a certain contour level
std::vector<double> ise3d; // Mean Integrated Square Error
std::vector<double> vol3d; // Volumes of the 3d contours
for (i = 0; i < f3d.size(); i++) {
// Initialize the density estimator
DensityEstimator de(s3d[i], algo, false, 1.);
f3d[i]->Range(min, max);
ise3d.push_back(0.); // TODO TODO TODO ???
vol3d.push_back(de.ContourVolume(alpha, "mc"));
cont3d.push_back(de.Contour3D());
}
////////////////////////////////////////////
// Radial density estimators
npoints = 1000;
std::vector<TGraph*> derad; // Interpolated radial function
std::vector<TGraph*> bandrad; // Error band with respect to true
std::vector<TH1F*> contrad; // Radial contour
std::vector<double> iserad; // Mean Integrated Square Error
std::vector<double> volrad; // Volumes of the contours
double r;
std::vector<double> v;
for (i = 0; i < frad.size(); i++) {
// Initialize the density estimator
DensityEstimator de(srad[i], algo, false, 1.);
v.resize(de.GetDimension());
// Initialize graphs and fill it with points from the density estimator
TGraph *graph = new TGraph(npoints);
graph->SetTitle(frad[i]->Title().c_str());
TGraph *band = new TGraph(2*npoints);
frad[i]->Range(min, max);
ise = 0.;
for (j = 0; j < npoints; j++) {
r = (double)j*max[0]/(npoints-1);
real = frad[i]->Radial(r);
v[0] = r;
if ( de.GetDimension() > 1 ) {
v[0] = r;
v[1] = 0;
}
est = de(v);
ise += pow(r, de.GetDimension()-1)*pow(est-real, 2)*max[0]/(npoints-1);
graph->SetPoint(j, r, est);
band->SetPoint(j, r, est);
band->SetPoint(2*npoints-1-j, r, real);
}
derad.push_back(graph);
bandrad.push_back(band);
// iserad.push_back(de.GetDimension()*pow(2, de.GetDimension())*ise);
iserad.push_back(de.GetDimension()*Math::UnitBallVolume(de.GetDimension(), 2)*ise);
// volrad.push_back(de.ContourVolume(alpha, "mc"));
// contrad.push_back(de.Contour1D());
}
////////////////////////////////////////////
/////////////// COMPARAISON ////////////////
////////////////////////////////////////////
// 1D distributions
for (i = 0; i < f1d.size(); i++) {
// Initialize the Canvas
TCanvas *c = new TCanvas("c", "c", 1200, 800);
// gPad->SetLogy();
gPad->SetLeftMargin(.125);
// Set the style
de1d[i]->SetLineColor(4);
band1d[i]->SetLineColor(0);
band1d[i]->SetFillColorAlpha(4, 0.25);
// Legend for the value of ISE and CRE
TLegend *leg = new TLegend(.65, .8, .89, .89);
leg->SetLineColorAlpha(0, 0);
leg->SetFillStyle(3001);
leg->SetFillColorAlpha(0, 0);
leg->AddEntry(band1d[i], TString::Format("ISE: %0.6f", ise1d[i]), "f");
double truevol = f1d[i]->ContourVolume(alpha);
// leg->AddEntry(cont1d[i], TString::Format("CRE(%d%%): %0.4f%%",
// (int)(100*alpha), 100*(vol1d[i]-truevol)/truevol), "l");
// Draw
de1d[i]->Draw("AL");
de1d[i]->SetTitle(";x;#rho(x)");
f1d[i]->Draw("L SAME");
band1d[i]->Draw("F SAME");
// for (TLine* line : f1d[i]->Contour1D(alpha))
// line->Draw("SAME");
// cont1d[i]->Draw("E SAME");
leg->Draw("SAME");
c->SaveAs(f1d[i]->Name()+TString(".pdf"));
delete c;
delete leg;
}
////////////////////////////////////////////
// 2D distributions
for (i = 0; i < f2d.size(); i++) {
// Save the true and estimated distributions separately
TCanvas *cdist = new TCanvas("c", "c", 1200, 800);
gPad->SetRightMargin(.15);
de2d[i]->GetXaxis()->SetRangeUser(-3, 3);
de2d[i]->GetYaxis()->SetRangeUser(-3, 3);
de2d[i]->Draw("CONTZ");
de2d[i]->SetTitle(";x;y;#rho(x,y)");
cdist->SaveAs(f2d[i]->Name()+TString("_de.pdf"));
delete cdist;
cdist = new TCanvas("c", "c", 1200, 800);
f2d[i]->Draw("CONTZ");
cdist->SaveAs(f2d[i]->Name()+TString("_true.pdf"));
delete cdist;
// Initialize the Canvas
TCanvas *c = new TCanvas("c", "c", 1200, 800);
// Set the style
de2d[i]->SetLineWidth(2);
de2d[i]->SetLineColor(4);
// Legend for the value of ISE and CRE
TLegend *leg = new TLegend(.6, .72, .89, .89);
leg->SetLineColorAlpha(0, 0);
leg->SetFillStyle(3001);
leg->SetFillColorAlpha(0, 0);
leg->AddEntry(de2d[i], TString::Format("ISE: %0.6f", ise2d[i]), "");
double truevol = f2d[i]->ContourVolume(alpha);
leg->AddEntry(cont2d[i], TString::Format("CRE(%d%%): %0.2f%%",
(int)(100*alpha), 100*(vol2d[i]-truevol)/truevol), "l");
// Draw
de2d[i]->Draw("CONT2");
de2d[i]->SetLineColor(0);
// f2d[i]->Draw("CONT2 SAME");
leg->Draw("SAME");
for (TObject* obj : f2d[i]->Contour2D(alpha))
obj->Draw("SAME");
cont2d[i]->Draw("CONT3 SAME");
c->SaveAs(f2d[i]->Name()+TString(".pdf"));
delete c;
delete leg;
}
////////////////////////////////////////////
// 3D distributions
for (i = 0; i < f3d.size(); i++) {
// Initialize the Canvas
TCanvas *c = new TCanvas("c", "c", 1200, 800);
// Legend for the value of ISE and CRE
TLegend *leg = new TLegend(.6, .75, .89, .89);
leg->SetLineColorAlpha(0, 0);
leg->SetFillStyle(3001);
leg->SetFillColorAlpha(0, 0);
// leg->AddEntry(de2d[i], TString::Format("ISE: %0.6f", ise2d[i]), "l");
double truevol = f3d[i]->ContourVolume(alpha);
leg->AddEntry(cont3d[i], TString::Format("CRE(%d%%): %0.4f%%",
(int)(100*alpha), 100*(vol3d[i]-truevol)/truevol), "lf");
// Draw
f3d[i]->Contour3D(alpha)->Draw("FB");
cont3d[i]->Draw("SAME ISO FBBB");
leg->Draw("SAME");
c->SaveAs(f3d[i]->Name()+TString(".pdf"));
delete c;
delete leg;
}
////////////////////////////////////////////
// Radial distributions
for (i = 0; i < frad.size(); i++) {
// Initialize the Canvas
TCanvas *c = new TCanvas("c", "c", 1200, 800);
// gPad->SetLogy();
// Set the style
derad[i]->SetLineColor(4);
bandrad[i]->SetLineColor(0);
bandrad[i]->SetFillColorAlpha(4, 0.25);
// Legend for the value of ISE and CRE
TLegend *leg = new TLegend(.6, .82, .89, .89);
leg->SetLineColorAlpha(0, 0);
leg->SetFillStyle(3001);
leg->SetFillColorAlpha(0, 0);
leg->AddEntry(bandrad[i], TString::Format("ISE: %0.6f", iserad[i]), "f");
// double truevol = frad[i]->ContourVolume(alpha);
// leg->AddEntry(contrad[i], TString::Format("CRE(%d%%): %0.4f%%",
// (int)(100*alpha), 100*(volrad[i]-truevol)/truevol), "l");
// Draw
derad[i]->Draw("AL");
derad[i]->SetTitle(";r;#hat{#rho}(r)");
gPad->SetLeftMargin(0.12);
frad[i]->DrawRadial("L SAME");
bandrad[i]->Draw("F SAME");
// for (TLine* line : frad[i]->ContourRadial(alpha))
// line->Draw("SAME");
// contrad[i]->Draw("E SAME");
leg->Draw("SAME");
c->SaveAs(frad[i]->Name()+TString("r.pdf"));
delete c;
delete leg;
}
}
|
[
"francois.drielsma@gmail.com"
] |
francois.drielsma@gmail.com
|
7ced4e90c7694b9a57f457cc4961c5331037b3d2
|
b4bf3dbb54c4a41d72367723e266becb09d68169
|
/test/Test.cpp
|
927870a1f82d24851915db830f955d1395339ce5
|
[] |
no_license
|
anlzou/c-cpp-test
|
5e84cfab436aff95d4d9cda35002853e4b782f1e
|
4151e3b6dbbeb89a7874d19469bd236357ad848d
|
refs/heads/master
| 2022-11-21T17:28:51.702811
| 2020-07-21T09:05:07
| 2020-07-21T09:05:07
| 261,930,780
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 748
|
cpp
|
#include <string.h>
#include <iostream>
using namespace std;
// class Student {
// private:
// string name;
// int num;
// int score;
// public:
// void setDate() {
// cout << "name:";
// cin >> name;
// cout << "num:";
// cin >> num;
// cout << "score:";
// cin >> score;
// }
// void display() {
// cout << "name=" << name << endl;
// cout << "num=" << num << endl;
// cout << "score=" << score << endl;
// }
// };
// Student::~Student() { cout << "finish, byby." << endl; }
int main() {
// Student student1, student2;
// student1.setDate();
// student1.display();
cout << "hello anlzou.";
getchar();
return 0;
}
|
[
"599502931@qq.com"
] |
599502931@qq.com
|
295c1147768925e70687104cbe3d77c00d4a9df4
|
38bdd304f1d47b51e37d02c0d5cc76bd7373db3f
|
/temp.cpp
|
8fa30a9e557a479364fe2f5f68da12c4565c0448
|
[] |
no_license
|
ipipip1735/CPPBasics
|
eee5c68db94b4989838d9235c299eaa92ded4414
|
5096a6f8b55e8f25e147515e9ed65faaf982d371
|
refs/heads/master
| 2021-05-23T14:50:55.841930
| 2020-04-05T22:50:38
| 2020-04-05T22:50:38
| 253,347,452
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 293
|
cpp
|
//
// Created by Administrator on 2020/4/2.
//
#include <stdio.h>
#include <math.h>
#include <string.h>
#ifdef TTT
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
DLL_EXPORT static int XX = 999;
__declspec(dllimport) static bool SEX = false;
|
[
"ipipip1735@163.com"
] |
ipipip1735@163.com
|
16e18b4eeb62664fb591a27ca8cdab106e81076d
|
20cf6482b7f5a68bd0029414c02f7ec4747c0c5f
|
/triton2/common/comm/linux/linuxnetwork.cpp
|
83583cac3e17f5dcc2b94a09f01410ea18566e64
|
[] |
no_license
|
kensniper/triton2
|
732907c76c001b2454e08ca81ad72ace45625f6c
|
7ad2a359e85df85be9d87010047a198980c121ae
|
refs/heads/master
| 2023-03-23T02:20:56.487117
| 2017-02-26T00:00:59
| 2017-02-26T00:00:59
| null | 0
| 0
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 4,316
|
cpp
|
#include "linuxnetwork.h"
#ifdef LINUX
CLinuxLock::CLinuxLock( )
{
int tRetCode = 0;
tRetCode = pthread_mutex_init( &mLock, NULL );
if ( tRetCode != 0 )
{
perror( "Error when constructing CLinuxLock" );
}
}
CLinuxLock::~CLinuxLock( )
{
int tRetCode = 0;
tRetCode = pthread_mutex_destroy( &mLock );
if ( tRetCode != 0 )
{
perror( "Error when destructing CLinuxLock" );
}
}
// ¼ÓËø
void CLinuxLock::Lock( )
{
int tRetCode = 0;
tRetCode = pthread_mutex_lock( &mLock );
if ( tRetCode != 0 )
{
perror( "Error when destructing CLinuxLock" );
}
}
// ½âËø
void CLinuxLock::Unlock( )
{
int tRetCode = 0;
#ifdef WIN32
::LeaveCriticalSection( &mLock );
#else // LINUX
tRetCode = pthread_mutex_unlock( &mLock );
if ( tRetCode != 0 )
{
perror( "Error when destructing CLinuxLock" );
}
#endif
}
// ********************************************************************** //
// CLinuxClientNetwork
// ********************************************************************** //
bool CLinuxClientNetwork::Create( const char* pAddress )
{
if ( CClientLinuxSocket::Create( ) != 0 )
return false;
if ( CClientLinuxSocket::Connect( pAddress ) != 0 )
return false;
return true;
}
void CLinuxClientNetwork::Shutdown( )
{
CClientLinuxSocket::Shutdown( );
}
void CLinuxClientNetwork::SendMsg( BYTE* pMessage, int vMsgLen )
{
Send( (char*) pMessage, vMsgLen );
}
void CLinuxClientNetwork::EnumEvent( )
{
EventProcess( );
}
int CLinuxClientNetwork::OnConnect( int vCode )
{
FireConnect( vCode, mUserData );
return 0;
}
int CLinuxClientNetwork::OnMessage( BYTE* pMessage, int vMsgLen )
{
FireMessage( pMessage, vMsgLen , mUserData );
return 0;
}
int CLinuxClientNetwork::OnClose( int vCode )
{
FireClose( vCode, mUserData );
return 0;
}
void CLinuxClientNetwork::GetStatistics( CStatistics* pStatistics )
{
}
// ********************************************************************** //
// CLinuxServerNetwork
// ********************************************************************** //
bool CLinuxServerNetwork::Create( const char* pAddress )
{
if ( CEPollSocket::Create( pAddress, true ) != 0 )
return false;
if ( CEPollSocket::Listen( 5 ) != 0 )
{
return false;
}
CEPollSocket::SetLock( &( ( ( CLinuxLock * ) mpLock )->mLock) );
return true;
}
void CLinuxServerNetwork::Shutdown( )
{
CEPollSocket::Close( );
}
char* CLinuxServerNetwork::GetRemoteIPString( int vCommHandle )
{
CClientLinuxContext* tpContext = GetClientContext( vCommHandle );
if ( tpContext == NULL )
return NULL;
return tpContext->GetRemoteIPString( );
}
void CLinuxServerNetwork::SetKeepAlive( int vCommHandle, unsigned int vTime )
{
}
unsigned short CLinuxServerNetwork::GetRemotePort( int vCommHandle )
{
CClientLinuxContext* tpContext = GetClientContext( vCommHandle );
if ( tpContext == NULL )
return 0;
return tpContext->GetRemotePort( );
}
void CLinuxServerNetwork::SendMsg( int vCommHandle, BYTE* pMessage, int vMsgLen )
{
//CSocketMessage tSocketMessage( pMessage->mMessageSize + sizeof( CSocketMessage ), pMessage->mMessageID );
//FillBuffer( vCommHandle, &tSocketMessage, sizeof( CSocketMessage ) );
FillBuffer( vCommHandle, ( (char*) pMessage ), vMsgLen );
}
int CLinuxServerNetwork::OnAccept( int vCommHandle )
{
FireAccept( vCommHandle );
return 0;
}
int CLinuxServerNetwork::OnMessage( int vCommHandle, BYTE* pMessage, int vMsgLen )
{
//CMessage* tpMessage = (CMessage*) mBuffer;
//tpMessage->mMessageID = pMessage->mMessageID;
//tpMessage->mMessageSize = pMessage->mMessageSize - sizeof( CSocketMessage );
//::memcpy( ( (char*) tpMessage ) + sizeof( CMessage ), ( (char*) pMessage ) + sizeof( CSocketMessage ), tpMessage->mMessageSize );
FireMessage( vCommHandle, pMessage, vMsgLen );
return 0;
}
int CLinuxServerNetwork::OnTimer( uint32_t vTickCount )
{
FireTimer( vTickCount );
return 0;
}
int CLinuxServerNetwork::OnClose( int vCommHandle, bool vIsLost )
{
FireClose( vCommHandle );
return 0;
}
void CLinuxServerNetwork::GetStatistics( int vCommHandle, CStatistics* pStatistics )
{
}
#endif
|
[
"243884919@QQ.COM"
] |
243884919@QQ.COM
|
51ea4e3d3f5a11c6eac37265c7f4e4c7b0d787c6
|
a5e39a86e749d58f6773523c4bd22996bbbabecd
|
/engineX/Engine/Graphics/DeviceContext/DeviceContext.h
|
9e7980db03e6844b5994f90a53e3389dbafb66c2
|
[] |
no_license
|
IDONTSUDO/EngineX
|
d4a1a93ba3f9863200f9cdcd9e20016a462639cc
|
e5865574a20dd2b3a9c6d7813114351c910d6a4f
|
refs/heads/master
| 2023-05-30T19:06:03.642079
| 2021-06-17T09:56:38
| 2021-06-17T09:56:38
| 377,422,426
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 324
|
h
|
#pragma once
#include <d3d11.h>
class SwapChain;
class DeviceContext
{
public:
DeviceContext(ID3D11DeviceContext* device_context);
bool clearRenderTargetColor(SwapChain* swap_chain,float red, float green, float blue,float alpha);
bool realese();
~DeviceContext();
private:
ID3D11DeviceContext* m_device_context;
};
|
[
"idontsudo@gmail.com"
] |
idontsudo@gmail.com
|
2a6b86362171aa3808dd3accd1cb34e1eb3fd3da
|
8dc84558f0058d90dfc4955e905dab1b22d12c08
|
/chromecast/common/extensions_api/cast_extension_messages.cc
|
cbbc2cbc2b7ce98a1e9ff32eea2e9842685b0a40
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] |
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
| 2,925
|
cc
|
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Get basic type definitions.
#define IPC_MESSAGE_IMPL
#undef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#include "chromecast/common/extensions_api/cast_extension_messages.h"
#include "content/public/common/common_param_traits.h"
#ifndef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#error "Failed to include header chromecast/common/extensions_api/"
"chrome_extension_messages.h"
#endif
// Generate constructors.
#include "ipc/struct_constructor_macros.h"
#undef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#include "chromecast/common/extensions_api/cast_extension_messages.h"
#include "content/public/common/common_param_traits.h"
#ifndef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#error "Failed to include header chromecast/common/extensions_api/"
"chrome_extension_messages.h"
#endif
// Generate destructors.
#include "ipc/struct_destructor_macros.h"
#undef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#include "chromecast/common/extensions_api/cast_extension_messages.h"
#include "content/public/common/common_param_traits.h"
#ifndef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#error "Failed to include header chromecast/common/extensions_api/"
"chrome_extension_messages.h"
#endif
// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
#undef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#include "chromecast/common/extensions_api/cast_extension_messages.h"
#include "content/public/common/common_param_traits.h"
#ifndef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#error "Failed to include header chromecast/common/extensions_api/"
"chrome_extension_messages.h"
#endif
} // namespace IPC
// Generate param traits read methods.
#include "ipc/param_traits_read_macros.h"
namespace IPC {
#undef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#include "chromecast/common/extensions_api/cast_extension_messages.h"
#include "content/public/common/common_param_traits.h"
#ifndef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#error "Failed to include header chromecast/common/extensions_api/"
"chrome_extension_messages.h"
#endif
} // namespace IPC
// Generate param traits log methods.
#include "ipc/param_traits_log_macros.h"
namespace IPC {
#undef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#include "chromecast/common/extensions_api/cast_extension_messages.h"
#include "content/public/common/common_param_traits.h"
#ifndef CHROMECAST_COMMON_EXTENSIONS_API_CAST_EXTENSION_MESSAGES_H_
#error "Failed to include header chromecast/common/extensions_api/"
"chrome_extension_messages.h"
#endif
} // namespace IPC
|
[
"arnaud@geometry.ee"
] |
arnaud@geometry.ee
|
8f5d6606c6f39eec379fb635992c1bf161f1c5eb
|
ea2cc666f3bc292435bb9a2dbe2326cf9a85f123
|
/Phoenix3D/PX2Mathematics/PX2Integrate1.hpp
|
87423206a411ec5dbede482db3d42fd3e9d72829
|
[] |
no_license
|
libla/Phoenix3D
|
c030b9b3933623dd58826f18754aaddf557575c0
|
788a04f922f38a12dc7886fe686a000785443f95
|
refs/heads/master
| 2020-12-06T19:12:36.116291
| 2015-07-27T16:14:57
| 2015-07-27T16:14:57
| 39,821,992
| 1
| 1
| null | 2015-07-28T08:24:41
| 2015-07-28T08:24:40
| null |
UTF-8
|
C++
| false
| false
| 690
|
hpp
|
// PX2Integrate1.hpp
#ifndef PX2INTEGRATE1_HPP
#define PX2INTEGRATE1_HPP
#include "PX2MathematicsPre.hpp"
namespace PX2
{
template <typename Real>
class PX2_MATHEMATICS_ITEM Integrate1
{
public:
// The last parameter is for user-defined data.
typedef Real (*Function)(Real,void*);
static Real RombergIntegral (int order, Real a, Real b, Function function,
void* userData = 0);
static Real GaussianQuadrature (Real a, Real b, Function function,
void* userData = 0);
static Real TrapezoidRule (int numSamples, Real a, Real b,
Function function, void* userData = 0);
};
typedef Integrate1<float> Integrate1f;
typedef Integrate1<double> Integrate1d;
}
#endif
|
[
"realmany@163.com"
] |
realmany@163.com
|
e7c9a95a04931cc00ce38df8a5b5f27b2fad31d1
|
31fcb8b429433699ca5c51b2d3a70861f76ab1ed
|
/src/main.cpp
|
d8645ee7234da2c18684282a9f9a20071ff6744f
|
[] |
no_license
|
kkufieta/openstreetmap_routeplanner_astar
|
c0f87d4f8b3710919656ef91d57adb52e129fb2a
|
b4fb0ff710364eccf4f3621482d9932f89c16b41
|
refs/heads/main
| 2023-01-02T03:13:45.900782
| 2020-10-25T01:16:45
| 2020-10-25T01:16:45
| 303,174,060
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,165
|
cpp
|
#include "render.h"
#include "route_model.h"
#include "route_planner.h"
#include <fstream>
#include <io2d.h>
#include <iostream>
#include <optional>
#include <string>
#include <vector>
using namespace std::experimental;
static std::optional<std::vector<std::byte>> ReadFile(const std::string &path) {
std::ifstream is{path, std::ios::binary | std::ios::ate};
if (!is)
return std::nullopt;
auto size = is.tellg();
std::vector<std::byte> contents(size);
is.seekg(0);
is.read((char *)contents.data(), size);
if (contents.empty())
return std::nullopt;
return std::move(contents);
}
int main(int argc, const char **argv) {
std::string osm_data_file = "";
if (argc > 1) {
for (int i = 1; i < argc; ++i)
if (std::string_view{argv[i]} == "-f" && ++i < argc)
osm_data_file = argv[i];
} else {
std::cout << "To specify a map file use the following format: "
<< std::endl;
std::cout << "Usage: [executable] [-f filename.osm]" << std::endl;
osm_data_file = "../map.osm";
}
std::vector<std::byte> osm_data;
if (osm_data.empty() && !osm_data_file.empty()) {
std::cout << "Reading OpenStreetMap data from the following file: "
<< osm_data_file << std::endl;
auto data = ReadFile(osm_data_file);
if (!data)
std::cout << "Failed to read." << std::endl;
else
osm_data = std::move(*data);
}
// Get the user input for the start and end point x & y values.
float start_x, start_y, end_x, end_y;
bool valid_input = false;
while (!valid_input) {
std::cout << "Enter start_x: ";
std::cin >> start_x;
std::cout << "Enter start_y: ";
std::cin >> start_y;
std::cout << "Enter end_x: ";
std::cin >> end_x;
std::cout << "Enter end_y: ";
std::cin >> end_y;
if (start_x >= 0 && start_x <= 100 && start_y >= 0 && start_y <= 100 &&
end_x >= 0 && end_x <= 100 && end_y >= 0 && end_y <= 100) {
valid_input = true;
} else {
std::cout << "Start and End point coordinates {x, y} must "
<< "be in the range of [0, 100].\n";
}
}
std::cout << "Find path from: "
<< "{" << start_x << ", " << start_y << "} => "
<< "{" << end_x << ", " << end_y << "}\n";
// Build Model.
RouteModel model{osm_data};
// Create RoutePlanner object and perform A* search.
RoutePlanner route_planner{model, start_x, start_y, end_x, end_y};
route_planner.AStarSearch();
std::cout << "Distance: " << route_planner.GetDistance() << " meters. \n";
// Render results of search.
Render render{model};
auto display = io2d::output_surface{400,
400,
io2d::format::argb32,
io2d::scaling::none,
io2d::refresh_style::fixed,
30};
display.size_change_callback([](io2d::output_surface &surface) {
surface.dimensions(surface.display_dimensions());
});
display.draw_callback(
[&](io2d::output_surface &surface) { render.Display(surface); });
display.begin_show();
}
|
[
"katharina.kufieta@gmail.com"
] |
katharina.kufieta@gmail.com
|
d19bf02fac0a81e45cd92e7e7c5e1002083bf6b4
|
438cd59a4138cd87d79dcd62d699d563ed976eb9
|
/mame/src/mame/includes/galspnbl.h
|
3dedeac9e5e3e87966b06b780d1d91b91b4f59dc
|
[] |
no_license
|
clobber/UME
|
031c677d49634b40b5db27fbc6e15d51c97de1c5
|
9d4231358d519eae294007133ab3eb45ae7e4f41
|
refs/heads/master
| 2021-01-20T05:31:28.376152
| 2013-05-01T18:42:59
| 2013-05-01T18:42:59
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,120
|
h
|
/*************************************************************************
Hot Pinball
Gals Pinball
*************************************************************************/
class galspnbl_state : public driver_device
{
public:
galspnbl_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag) ,
m_spriteram(*this, "spriteram"),
m_colorram(*this, "colorram"),
m_videoram(*this, "videoram"),
m_bgvideoram(*this, "bgvideoram"),
m_scroll(*this, "scroll"){ }
/* memory pointers */
required_shared_ptr<UINT16> m_spriteram;
required_shared_ptr<UINT16> m_colorram;
required_shared_ptr<UINT16> m_videoram;
required_shared_ptr<UINT16> m_bgvideoram;
required_shared_ptr<UINT16> m_scroll;
// UINT16 * paletteram; // currently this uses generic palette handling
/* devices */
cpu_device *m_audiocpu;
DECLARE_WRITE16_MEMBER(soundcommand_w);
virtual void machine_start();
virtual void palette_init();
UINT32 screen_update_galspnbl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
};
|
[
"brymaster@gmail.com"
] |
brymaster@gmail.com
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.